tag:blogger.com,1999:blog-34458727324373421142024-03-05T12:27:01.238-08:00 Effective Java Simplified MANOJ KUMARhttp://www.blogger.com/profile/00421517842858762886noreply@blogger.comBlogger93125tag:blogger.com,1999:blog-3445872732437342114.post-62476853470549267422014-04-22T02:09:00.000-07:002014-04-22T02:09:21.103-07:00How to avoid CSRF - Cross Side Request Forgery attack <script type="text/javascript">
google_ad_client = "ca-pub-8470945096737641";
/* seo banner */
google_ad_slot = "3657212241";
google_ad_width = 468;
google_ad_height = 100;
//-->
</script><br />
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script><br />
<br />
<br />
<br />
<div dir="ltr" style="text-align: left;" trbidi="on">How to prevent CSRF using. <br />
<br />
CSRF attack can be prevented using Synchronized Token Pattern. <br />
<br />
When an HTML form is rendered ,server assigns it a unique and random identifier in the form of hidden http parameter. Server<br />
<br />
Also stored the unique identifier in user session profile <br />
<br />
When This form is submitted server compares the identifier's value in hidden field with value stored in user session profile . If value matches only then request is further processed otherwise request is aborted. <br />
<br />
Thus if any evil website tries to submit a form with forging the client request information in that , it is not able to generate the unique identifier As <br />
It does not know How to get it , It's not there on client cookie , it's not guessable . So attacker can't make CSRF attack.<br />
<br />
<br />
<script type="text/javascript">
google_ad_client = "ca-pub-8470945096737641";
/* seo banner */
google_ad_slot = "3657212241";
google_ad_width = 468;
google_ad_height = 100;
//-->
</script><br />
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script><br />
<br />
For example : If a form named businessForm is rendered is follow ,server creates random token and form store that in hidden field. Also it's value is sotred <br />
in user session<br />
<br />
<form 0="" background:="" class="goog-spellcheck-word" name="<span style=" none="" repeat="" scroll="" yellow="">businessForm</form></div>"><br />
<br />
<br />
<input 0="" background:="" class="goog-spellcheck-word" name="<span style=" none="" repeat="" scroll="" type="hidden" yellow="" />CSRF_identifier">123#rret_val</><br />
<br />
<br />
<br />
When user submit this form token value is validated. Evil site can't steal this random number So that request will be rejected and CSRF attack will be prevented<br />
<br />
<br />
<br />
<script type="text/javascript">
google_ad_client = "ca-pub-8470945096737641";
/* 200x200, created 6/23/09 */
google_ad_slot = "8930436823";
google_ad_width = 200;
google_ad_height = 200;
</script><br />
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script><br />
<br />
<br />
MANOJ KUMARhttp://www.blogger.com/profile/00421517842858762886noreply@blogger.com0tag:blogger.com,1999:blog-3445872732437342114.post-78925895475699704362014-04-22T01:27:00.000-07:002014-04-22T01:27:28.393-07:00CSRF - Cross Side Request Forgery<script type="text/javascript">
google_ad_client = "ca-pub-8470945096737641";
/* seo banner */
google_ad_slot = "3657212241";
google_ad_width = 468;
google_ad_height = 100;
//-->
</script><br />
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script><br />
<br />
<br />
<div dir="ltr" style="text-align: left;" trbidi="on">When you are accessing your bank website ,Why should you not open any other tab in same window with some unknown /evil application?<br />
<br />
You might become s CSRF prey.<br />
<br />
How does that happen ? <br />
<br />
LEt's understand this with an simple example. <br />
<br />
Let's say you open the browser and login to you bank website www.mybank.com with your username/password.<br />
<br />
When you Do this bank might persist your authentication token in cookie. For eample : You login to the website using your username/password and bank website <br />
,after successful authentication , stores in client cookie "isUserALreadyLoggenzIn"="true" <br />
<br />
<br />
<br />
<script type="text/javascript">
google_ad_client = "ca-pub-8470945096737641";
/* 200x200, created 6/23/09 */
google_ad_slot = "8930436823";
google_ad_width = 200;
google_ad_height = 200;
</script><br />
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script><br />
<br />
<br />
After this you open an evil website in new tab , may be by clicking on some link on some other page in the same window . Now that evil website might contain <br />
<br />
a form like this <br />
<br />
<form action="www.mybank.com/transfer"><br />
<br />
<input type="text" /> name="amonut" value="50000"<br />
<br />
<input type="submit" /> Win Lottery<br />
<br />
On on page opened with evil website link you click on Win Lottery button. This click submits a request of money tranfer and money is transferred to some <br />
other account without your knowledge. Application identifies the logged in your using cookie data and there "isUserLoggedIn" is already set to true So no problem comes in authentication. <br />
<br />
<br />
<br />
This example is Just to cover the CRSF i.e. cross side request forgery . These days bank application and browsers are much more intellient to <br />
<br />
defend against these evils . </form></div><br />
<script type="text/javascript">
google_ad_client = "ca-pub-8470945096737641";
/* seo banner */
google_ad_slot = "3657212241";
google_ad_width = 468;
google_ad_height = 100;
//-->
</script><br />
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>MANOJ KUMARhttp://www.blogger.com/profile/00421517842858762886noreply@blogger.com0tag:blogger.com,1999:blog-3445872732437342114.post-75467992484865842112014-03-20T09:16:00.001-07:002014-03-23T03:08:36.355-07:00Configuring apache mod security -Mod Security rules configuration <br />
<br />
<br />
<script type="text/javascript">
google_ad_client = "ca-pub-8470945096737641";
/* seo banner */
google_ad_slot = "3657212241";
google_ad_width = 468;
google_ad_height = 100;
//-->
</script><br />
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script><br />
<br />
<br />
<div dir="ltr" style="text-align: left;" trbidi="on"><div class="MsoNormal">Below are the detailed around Mod Security configuration on apache server. Please let me know If you need any further details on that . <o:p></o:p></div><div class="MsoNormal"><br />
</div><div class="MsoListParagraph" style="mso-list: l0 level1 lfo1; text-indent: -.25in;"><!--[if !supportLists]--><b>1.<span style="font-size: 7pt; font-weight: normal;"> </span></b><!--[endif]--><b>Add below configuration in httpd.conf file <o:p></o:p></b></div><div class="MsoNormal"><br />
</div><div class="MsoNormal" style="margin-left: .5in;">LoadModule security2_module modules/mod_security2.so<o:p></o:p></div><div class="MsoNormal" style="margin-left: .5in;">LoadModule unique_id_module modules/mod_unique_id.so<o:p></o:p></div><div class="MsoNormal" style="margin-left: .5in;"><ifmodule ssl_module=""><o:p></o:p></ifmodule></div><div class="MsoNormal" style="margin-left: .5in;">SSLRandomSeed startup builtin<o:p></o:p></div><div class="MsoNormal" style="margin-left: .5in;">SSLRandomSeed connect builtin<o:p></o:p></div><div class="MsoNormal" style="margin-left: .5in;"></div></div><o:p></o:p><div class="MsoNormal" style="margin-left: .5in;"><br />
</div><div class="MsoNormal" style="margin-left: .5in;"><ifmodule security2_module=""><o:p></o:p></ifmodule></div><div class="MsoNormal" style="margin-left: .5in;">Include /etc/httpd/modsecurity_crs/*.conf<o:p></o:p></div><div class="MsoNormal" style="margin-left: .5in;">SecAuditEngine On<o:p></o:p></div><div class="MsoNormal" style="margin-left: .5in;">#SecFilterScanPOST On<o:p></o:p></div><div class="MsoNormal" style="margin-left: .5in;">SecAuditLog logs/audit_log<o:p></o:p></div><div class="MsoNormal" style="margin-left: .5in;"></div><o:p></o:p><div class="MsoNormal"><br />
</div><div class="MsoListParagraph" style="mso-list: l0 level1 lfo1; text-indent: -.25in;"><!--[if !supportLists]--><b>2.<span style="font-size: 7pt; font-weight: normal;"> </span></b><!--[endif]--><b>mod_security2.so and mod_unique_id.so are modules that needs to be placed in apache modules folder<o:p></o:p></b></div><div class="MsoNormal" style="margin-left: .5in;"><b><br />
</b></div><div class="MsoNormal" style="margin-left: .5in;"><b>/etc/httpd/modsecurity_crs is the place where rules files exist .</b></div><div class="MsoNormal" style="margin-left: .5in;"><br />
</div><div class="MsoNormal" style="margin-left: .5in;">We have placed below rule file at this location <o:p></o:p></div><div class="MsoNormal" style="margin-left: .5in;"><br />
</div><br />
<script type="text/javascript">
google_ad_client = "ca-pub-8470945096737641";
/* 200x200, created 6/23/09 */
google_ad_slot = "8930436823";
google_ad_width = 200;
google_ad_height = 200;
</script><br />
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script><br />
<br />
<div class="MsoNormal" style="margin-left: .5in;"><b>Mod_security_rules.conf<o:p></o:p></b></div><div class="MsoNormal" style="margin-left: .5in;"><b>--------------------------------------------------------------------------------------------------------------</b></div><div class="MsoNormal" style="margin-left: .5in;">SecDefaultAction "phase:1,phase:2,auditlog,logdata:'%{MATCHED_VAR_NAME}=%{MATCHED_VAR}',deny,redirect:/errorpage.html"<o:p></o:p></div><div class="MsoNormal" style="margin-left: .5in;"><br />
</div><div class="MsoNormal" style="margin-left: .5in;">SecRule ARGS_NAMES "!^(post-name_)+$" "id:'1000010'"<o:p></o:p></div><div class="MsoNormal" style="margin-left: .5in;"><br />
</div><div class="MsoNormal" style="margin-left: .5in;">SecRule ARGS:post-name "!^[a-zA-Z0-9_]{0,4096}$" "id:'1000237'"<o:p></o:p></div><div class="MsoNormal" style="margin-left: .5in;"><o:p> -----------------------------------------------------------------------------------------</o:p></div><div class="MsoNormal" style="margin-left: .5in;"><br />
</div><div class="MsoNormal" style="margin-left: .5in;">This configuration will allow only post-name attribute with alphanumeric and _ characters allowed in the value . Every other request parameter will be rejected and user will be redirected to errorpage.html<o:p></o:p></div><div class="MsoNormal" style="margin-left: .5in;"><br />
</div><div class="MsoNormal" style="margin-left: .5in;">Logs captured by mod security can be viewed in logs/audit_log file. </div><div class="MsoNormal"><br />
</div><div class="MsoNormal"><br />
</div><div class="MsoListParagraph" style="mso-list: l0 level1 lfo1; text-indent: -.25in;"><!--[if !supportLists]--><b>3.<span style="font-size: 7pt; font-weight: normal;"> </span></b><b>I have created simple Form with GET and POST request on apache server <o:p></o:p></b></div><div class="MsoNormal"><br />
</div><pre style="margin-left: .5in;"><span class="error"><</span><span class="start-tag">html</span><span class="error">></span><o:p></o:p></pre><pre style="margin-left: .5in;"><<span class="start-tag">body</span>><o:p></o:p></pre><pre style="margin-left: .5in;"><<span class="start-tag">h1</span>>GET!! Test Apache Redirection</<span class="end-tag">h1</span>><o:p></o:p></pre><pre style="margin-left: .5in;"><<span class="start-tag">form</span> <span class="attribute-name">name</span>='f1' <span class="attribute-name">method</span>="GET" <span class="attribute-name">action</span>="<a href="view-source:http://10.203.146.75/gs/crm/orderupdate">/</a><u>getService</u>"><o:p></o:p></pre><pre style="margin-left: .5in;">Enter Your Name : <<span class="start-tag">input</span> <span class="attribute-name">type</span>="text" <span class="attribute-name">name</span>="<b>name</b>" <span class="attribute-name">value</span>=""/><o:p></o:p></pre><pre style="margin-left: .5in;"><<span class="start-tag">input</span> <span class="attribute-name">type</span>="submit" <span class="attribute-name">id</span>="Go" <span class="attribute-name">value</span>="GET Submit"/><o:p></o:p></pre><pre style="margin-left: .5in;"></<span class="end-tag">form</span>><o:p></o:p></pre><pre style="margin-left: .5in;"><o:p> </o:p></pre><pre style="margin-left: .5in;"><o:p> </o:p></pre><pre style="margin-left: .5in;"><<span class="start-tag">h1</span>>POST !! Test Apache Redirection</<span class="end-tag">h1</span>><o:p></o:p></pre><pre style="margin-left: .5in;"><<span class="start-tag">form</span> <span class="attribute-name">name</span>='f2' <span class="attribute-name">method</span>="POST" <span class="attribute-name">action</span>="<a href="view-source:http://10.203.146.75/gs/crm/orderupdate-post">/</a><u>postService</u>"><o:p></o:p></pre><pre style="margin-left: .5in;">Enter Your Name : <<span class="start-tag">input</span> <span class="attribute-name">type</span>="text" <span class="attribute-name">name</span>="<b>post-name</b>" <span class="attribute-name">value</span>=""/><o:p></o:p></pre><pre style="margin-left: .5in;"><<span class="start-tag">input</span> <span class="attribute-name">type</span>="submit" <span class="attribute-name">id</span>="submit" <span class="attribute-name">value</span>="Post Submit"/><o:p></o:p></pre><pre style="margin-left: .5in;"></<span class="end-tag">form</span>><o:p></o:p></pre><pre style="margin-left: .5in;"></<span class="end-tag">body</span>><o:p></o:p></pre><pre style="margin-left: .5in;"></<span class="end-tag">html</span>><o:p></o:p></pre><div class="MsoNormal"><br />
</div><div class="MsoListParagraph" style="mso-list: l0 level1 lfo1; text-indent: -.25in;"><!--[if !supportLists]--><b>4.<span style="font-size: 7pt; font-weight: normal;"> </span></b><!--[endif]--><b>So in above form through GET request we are submitting form with request attribute name and through post request attribute is post-name.<o:p></o:p></b></div><div class="MsoListParagraph" style="mso-list: l0 level1 lfo1; text-indent: -.25in;"><b><br />
</b></div><br />
<div class="MsoNormal" style="text-indent: .5in;"><b>post-name will pass and name will fail as name is not configured as allowed parameter in mod security rules configuration file.<o:p></o:p></b></div><br />
<br />
<br />
<script type="text/javascript">
google_ad_client = "ca-pub-8470945096737641";
/* seo banner */
google_ad_slot = "3657212241";
google_ad_width = 468;
google_ad_height = 300;
//-->
</script><br />
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script><br />
MANOJ KUMARhttp://www.blogger.com/profile/00421517842858762886noreply@blogger.com0tag:blogger.com,1999:blog-3445872732437342114.post-2597408217075398672014-03-19T08:56:00.003-07:002014-03-19T08:56:40.801-07:00Grizzly jax-ws file upload service and client<script type="text/javascript">
google_ad_client = "ca-pub-8470945096737641";
/* 160x600, created 6/23/09 */
google_ad_slot = "3027217057";
google_ad_width = 160;
google_ad_height =200 ;
//
</script><br />
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script><br />
<br />
<br />
<div dir="ltr" style="text-align: left;" trbidi="on"><br />
<b>Server Side code : </b><br />
<br />
<br />
<b>Below file start the Grizzly server and register the uploadService class as jax-ws web service </b><br />
<br />
<span style="color: #444444; font-family: Courier New, Courier, monospace;"><br />
</span> <span style="color: #444444; font-family: Courier New, Courier, monospace;">package com.sap;</span><br />
<span style="color: #444444; font-family: Courier New, Courier, monospace;"><br />
</span> <span style="color: #444444; font-family: Courier New, Courier, monospace;">import com.sun.grizzly.http.embed.GrizzlyWebServer;</span><br />
<span style="color: #444444; font-family: Courier New, Courier, monospace;"><br />
</span> <span style="color: #444444; font-family: Courier New, Courier, monospace;">import java.io.IOException;</span><br />
<span style="color: #444444; font-family: Courier New, Courier, monospace;"><br />
</span> <span style="color: #444444; font-family: Courier New, Courier, monospace;">import javax.xml.ws.Endpoint;</span><br />
<span style="color: #444444; font-family: Courier New, Courier, monospace;">import javax.xml.ws.spi.http.HttpContext;</span><br />
<span style="color: #444444; font-family: Courier New, Courier, monospace;"><br />
</span> <span style="color: #444444; font-family: Courier New, Courier, monospace;">import org.jvnet.jax_ws_commons.transport.grizzly_httpspi.GrizzlyHttpContextFactory;</span><br />
<span style="color: #444444; font-family: Courier New, Courier, monospace;"><br />
</span> <span style="color: #444444; font-family: Courier New, Courier, monospace;">public class JaxwsMain {</span><br />
<span style="color: #444444; font-family: Courier New, Courier, monospace;"><br />
</span> <span style="color: #444444; font-family: Courier New, Courier, monospace;"> /**</span><br />
<span style="color: #444444; font-family: Courier New, Courier, monospace;"> * @param args</span><br />
<span style="color: #444444; font-family: Courier New, Courier, monospace;"> */</span><br />
<span style="color: #444444; font-family: Courier New, Courier, monospace;"> public static void main(String[] args) {</span><br />
<span style="color: #444444; font-family: Courier New, Courier, monospace;"> </span><br />
<span style="color: #444444; font-family: Courier New, Courier, monospace;"> String contextPath = "/ws";</span><br />
<span style="color: #444444; font-family: Courier New, Courier, monospace;"> String path = "/test";</span><br />
<span style="color: #444444; font-family: Courier New, Courier, monospace;"> int port = 8081;</span><br />
<span style="color: #444444; font-family: Courier New, Courier, monospace;"><br />
</span> <span style="color: #444444; font-family: Courier New, Courier, monospace;"> String address = "http://localhost:"+port+contextPath+path;</span><br />
<span style="color: #444444; font-family: Courier New, Courier, monospace;"><br />
</span> <span style="color: #444444; font-family: Courier New, Courier, monospace;"> GrizzlyWebServer server = new GrizzlyWebServer(port);</span><br />
<span style="color: #444444; font-family: Courier New, Courier, monospace;"> HttpContext context = GrizzlyHttpContextFactory.createHttpContext(server, contextPath, path);</span><br />
<span style="color: #444444; font-family: Courier New, Courier, monospace;"><br />
</span> <span style="color: #444444; font-family: Courier New, Courier, monospace;"> Endpoint endpoint = Endpoint.create(new UploadService());</span><br />
<span style="color: #444444; font-family: Courier New, Courier, monospace;"> //endpoint.create(new UploadService());</span><br />
<span style="color: #444444; font-family: Courier New, Courier, monospace;"> endpoint.publish(context); </span><br />
<span style="color: #444444; font-family: Courier New, Courier, monospace;"> </span><br />
<span style="color: #444444; font-family: Courier New, Courier, monospace;"> try {</span><br />
<span style="color: #444444; font-family: Courier New, Courier, monospace;"> server.start();</span><br />
<span style="color: #444444; font-family: Courier New, Courier, monospace;"> </span><br />
<span style="color: #444444; font-family: Courier New, Courier, monospace;"> System.out.println(12121);</span><br />
<span style="color: #444444; font-family: Courier New, Courier, monospace;"> } catch (IOException e) {</span><br />
<span style="color: #444444; font-family: Courier New, Courier, monospace;"> // TODO Auto-generated catch block</span><br />
<span style="color: #444444; font-family: Courier New, Courier, monospace;"> e.printStackTrace();</span><br />
<span style="color: #444444; font-family: Courier New, Courier, monospace;"> }</span><br />
<span style="color: #444444; font-family: Courier New, Courier, monospace;"><br />
</span> <span style="color: #444444; font-family: Courier New, Courier, monospace;"> </span><br />
<span style="color: #444444; font-family: Courier New, Courier, monospace;"> </span><br />
<span style="color: #444444; font-family: Courier New, Courier, monospace;"> </span><br />
<span style="color: #444444; font-family: Courier New, Courier, monospace;"> }</span><br />
<span style="color: #444444; font-family: Courier New, Courier, monospace;"><br />
</span> <span style="color: #444444; font-family: Courier New, Courier, monospace;">}</span><br />
<br />
<br />
<br />
<br />
<script type="text/javascript">
google_ad_client = "ca-pub-8470945096737641";
/* 200x200, created 6/23/09 */
google_ad_slot = "8930436823";
google_ad_width = 200;
google_ad_height = 200;
</script><br />
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script><br />
<br />
<br />
<b>below is uploadService class that basically upload the file </b><br />
<br />
<br />
<span style="color: #444444; font-family: Courier New, Courier, monospace;">package com.sap;</span><br />
<span style="color: #444444; font-family: Courier New, Courier, monospace;"><br />
</span> <span style="color: #444444; font-family: Courier New, Courier, monospace;">import java.io.BufferedOutputStream;</span><br />
<span style="color: #444444; font-family: Courier New, Courier, monospace;">import java.io.FileOutputStream;</span><br />
<span style="color: #444444; font-family: Courier New, Courier, monospace;">import java.io.IOException;</span><br />
<span style="color: #444444; font-family: Courier New, Courier, monospace;"><br />
</span> <span style="color: #444444; font-family: Courier New, Courier, monospace;">import javax.jws.WebMethod;</span><br />
<span style="color: #444444; font-family: Courier New, Courier, monospace;">import javax.jws.WebParam;</span><br />
<span style="color: #444444; font-family: Courier New, Courier, monospace;">import javax.jws.WebService;</span><br />
<span style="color: #444444; font-family: Courier New, Courier, monospace;">import javax.xml.ws.WebServiceException;</span><br />
<span style="color: #444444; font-family: Courier New, Courier, monospace;"><br />
</span> <span style="color: #444444; font-family: Courier New, Courier, monospace;">@WebService</span><br />
<span style="color: #444444; font-family: Courier New, Courier, monospace;">public class UploadService {</span><br />
<span style="color: #444444; font-family: Courier New, Courier, monospace;"> /* @WebMethod</span><br />
<span style="color: #444444; font-family: Courier New, Courier, monospace;"> public int up(@WebParam(name="value1") int value1, @WebParam(name="value2") int value2) {</span><br />
<span style="color: #444444; font-family: Courier New, Courier, monospace;"> return value1 + value2;</span><br />
<span style="color: #444444; font-family: Courier New, Courier, monospace;"> }</span><br />
<span style="color: #444444; font-family: Courier New, Courier, monospace;"> */ </span><br />
<span style="color: #444444; font-family: Courier New, Courier, monospace;"> @WebMethod</span><br />
<span style="color: #444444; font-family: Courier New, Courier, monospace;">public void upload(String fileName, byte[] imageBytes) {</span><br />
<span style="color: #444444; font-family: Courier New, Courier, monospace;"> </span><br />
<span style="color: #444444; font-family: Courier New, Courier, monospace;"> String filePath = "D:/desktops/12march2014/uploads/" + fileName;</span><br />
<span style="color: #444444; font-family: Courier New, Courier, monospace;"> </span><br />
<span style="color: #444444; font-family: Courier New, Courier, monospace;"> try {</span><br />
<span style="color: #444444; font-family: Courier New, Courier, monospace;"> FileOutputStream fos = new FileOutputStream(filePath);</span><br />
<span style="color: #444444; font-family: Courier New, Courier, monospace;"> BufferedOutputStream outputStream = new BufferedOutputStream(fos);</span><br />
<span style="color: #444444; font-family: Courier New, Courier, monospace;"> outputStream.write(imageBytes);</span><br />
<span style="color: #444444; font-family: Courier New, Courier, monospace;"> outputStream.close();</span><br />
<span style="color: #444444; font-family: Courier New, Courier, monospace;"> </span><br />
<span style="color: #444444; font-family: Courier New, Courier, monospace;"> System.out.println("Received file: " + filePath);</span><br />
<span style="color: #444444; font-family: Courier New, Courier, monospace;"> </span><br />
<span style="color: #444444; font-family: Courier New, Courier, monospace;"> } catch (IOException ex) {</span><br />
<span style="color: #444444; font-family: Courier New, Courier, monospace;"> System.err.println(ex);</span><br />
<span style="color: #444444; font-family: Courier New, Courier, monospace;"> throw new WebServiceException(ex);</span><br />
<span style="color: #444444; font-family: Courier New, Courier, monospace;"> }</span><br />
<span style="color: #444444; font-family: Courier New, Courier, monospace;">}</span><br />
<br />
<span style="color: #444444; font-family: Courier New, Courier, monospace;"><br />
</span> <span style="color: #444444; font-family: Courier New, Courier, monospace;"> </span><br />
<span style="color: #444444; font-family: Courier New, Courier, monospace;">}</span><br />
<br />
<br />
<br />
<b>run JaxwsMain Java class as java application . That will register the uploadService on Grizzly server\</b><br />
<br />
<br />
<br />
<b>use wsimport jax-ws utility from command line to generate the Client artifacts in Client project </b><br />
<br />
<b>This will create below files </b><br />
<br />
<br />
<br />
<ul style="text-align: left;"><li>ObjectFactory.java</li>
<li>package-info.java</li>
<li>Upload.java</li>
<li>UploadResponse.java</li>
<li>UploadService.java</li>
<li>UploadServiceService.java </li>
</ul><br />
<br />
<br />
<script type="text/javascript">
google_ad_client = "ca-pub-8470945096737641";
/* seo banner */
google_ad_slot = "3657212241";
google_ad_width = 468;
google_ad_height = 300;
//-->
</script><br />
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script><br />
<br />
<b>below the Client code file that will invoke the upload service</b><br />
<br />
<br />
<b>Execute this File and pass the file to be uploaded</b><br />
<br />
<br />
<span style="color: #444444; font-family: Courier New, Courier, monospace;">package com.sa;</span><br />
<span style="color: #444444; font-family: Courier New, Courier, monospace;"><br />
</span> <span style="color: #444444; font-family: Courier New, Courier, monospace;">import java.io.BufferedInputStream;</span><br />
<span style="color: #444444; font-family: Courier New, Courier, monospace;">import java.io.File;</span><br />
<span style="color: #444444; font-family: Courier New, Courier, monospace;">import java.io.FileInputStream;</span><br />
<span style="color: #444444; font-family: Courier New, Courier, monospace;">import java.io.IOException;</span><br />
<span style="color: #444444; font-family: Courier New, Courier, monospace;">import java.util.Scanner;</span><br />
<span style="color: #444444; font-family: Courier New, Courier, monospace;">import java.util.logging.FileHandler;</span><br />
<span style="color: #444444; font-family: Courier New, Courier, monospace;"><br />
</span> <span style="color: #444444; font-family: Courier New, Courier, monospace;">import javax.xml.ws.WebServiceRef;</span><br />
<span style="color: #444444; font-family: Courier New, Courier, monospace;">import javax.xml.ws.soap.MTOMFeature;</span><br />
<span style="color: #444444; font-family: Courier New, Courier, monospace;"><br />
</span> <span style="color: #444444; font-family: Courier New, Courier, monospace;">public class JaxwsClient {</span><br />
<span style="color: #444444; font-family: Courier New, Courier, monospace;"><br />
</span> <span style="color: #444444; font-family: Courier New, Courier, monospace;"> </span><br />
<span style="color: #444444; font-family: Courier New, Courier, monospace;"><br />
</span> <span style="color: #444444; font-family: Courier New, Courier, monospace;"> /**</span><br />
<span style="color: #444444; font-family: Courier New, Courier, monospace;"> * @param args</span><br />
<span style="color: #444444; font-family: Courier New, Courier, monospace;"> */</span><br />
<span style="color: #444444; font-family: Courier New, Courier, monospace;"> public static void main(String[] args) {</span><br />
<span style="color: #444444; font-family: Courier New, Courier, monospace;"> JaxwsClient client =new JaxwsClient();</span><br />
<span style="color: #444444; font-family: Courier New, Courier, monospace;"> client.doTest(args);</span><br />
<span style="color: #444444; font-family: Courier New, Courier, monospace;"><br />
</span> <span style="color: #444444; font-family: Courier New, Courier, monospace;"> }</span><br />
<span style="color: #444444; font-family: Courier New, Courier, monospace;"> </span><br />
<span style="color: #444444; font-family: Courier New, Courier, monospace;"> public void doTest(String[] args) {</span><br />
<span style="color: #444444; font-family: Courier New, Courier, monospace;"> </span><br />
<span style="color: #444444; font-family: Courier New, Courier, monospace;"> UploadServiceService service = new UploadServiceService();</span><br />
<span style="color: #444444; font-family: Courier New, Courier, monospace;"> UploadService port = service.getPort(UploadService.class, new MTOMFeature(10240));</span><br />
<span style="color: #444444; font-family: Courier New, Courier, monospace;"><br />
</span> <span style="color: #444444; font-family: Courier New, Courier, monospace;"> String fileName = "tpd-alert-1.2.0.zip";</span><br />
<span style="color: #444444; font-family: Courier New, Courier, monospace;"> String filePath = "D:/desktops/12march2014/" + fileName;</span><br />
<span style="color: #444444; font-family: Courier New, Courier, monospace;"> File file = new File(filePath);</span><br />
<span style="color: #444444; font-family: Courier New, Courier, monospace;"> </span><br />
<span style="color: #444444; font-family: Courier New, Courier, monospace;"> if (args.length >0 && null != args[0]) {</span><br />
<span style="color: #444444; font-family: Courier New, Courier, monospace;"> file = new File(args[0]);</span><br />
<span style="color: #444444; font-family: Courier New, Courier, monospace;"> } else {</span><br />
<span style="color: #444444; font-family: Courier New, Courier, monospace;"> </span><br />
<span style="color: #444444; font-family: Courier New, Courier, monospace;"> System.out.println("Enter full path of file..");</span><br />
<span style="color: #444444; font-family: Courier New, Courier, monospace;"><br />
</span> <span style="color: #444444; font-family: Courier New, Courier, monospace;"> String path;</span><br />
<span style="color: #444444; font-family: Courier New, Courier, monospace;"><br />
</span> <span style="color: #444444; font-family: Courier New, Courier, monospace;"> Scanner scanIn = new Scanner(System.in);</span><br />
<span style="color: #444444; font-family: Courier New, Courier, monospace;"> path = scanIn.nextLine();</span><br />
<span style="color: #444444; font-family: Courier New, Courier, monospace;"><br />
</span> <span style="color: #444444; font-family: Courier New, Courier, monospace;"> file = new File(path);</span><br />
<span style="color: #444444; font-family: Courier New, Courier, monospace;"><br />
</span> <span style="color: #444444; font-family: Courier New, Courier, monospace;"> }</span><br />
<span style="color: #444444; font-family: Courier New, Courier, monospace;"><br />
</span> <span style="color: #444444; font-family: Courier New, Courier, monospace;"> try {</span><br />
<span style="color: #444444; font-family: Courier New, Courier, monospace;"> filePath=file.getPath();</span><br />
<span style="color: #444444; font-family: Courier New, Courier, monospace;"> FileInputStream fis = new FileInputStream(file);</span><br />
<span style="color: #444444; font-family: Courier New, Courier, monospace;"> BufferedInputStream inputStream = new BufferedInputStream(fis);</span><br />
<span style="color: #444444; font-family: Courier New, Courier, monospace;"> byte[] imageBytes = new byte[(int) file.length()];</span><br />
<span style="color: #444444; font-family: Courier New, Courier, monospace;"> inputStream.read(imageBytes);</span><br />
<span style="color: #444444; font-family: Courier New, Courier, monospace;"><br />
</span> <span style="color: #444444; font-family: Courier New, Courier, monospace;"> port.upload(file.getName(), imageBytes);</span><br />
<span style="color: #444444; font-family: Courier New, Courier, monospace;"> inputStream.close();</span><br />
<span style="color: #444444; font-family: Courier New, Courier, monospace;"> System.out.println("File uploaded: " + filePath);</span><br />
<span style="color: #444444; font-family: Courier New, Courier, monospace;"> } catch (IOException ex) {</span><br />
<span style="color: #444444; font-family: Courier New, Courier, monospace;"> System.err.println(ex);</span><br />
<span style="color: #444444; font-family: Courier New, Courier, monospace;"> }}</span><br />
<span style="color: #444444; font-family: Courier New, Courier, monospace;"><br />
</span> <span style="color: #444444; font-family: Courier New, Courier, monospace;">}</span><br />
<br />
<br />
<b>Done!!!</b></div>MANOJ KUMARhttp://www.blogger.com/profile/00421517842858762886noreply@blogger.com0tag:blogger.com,1999:blog-3445872732437342114.post-75720135016895529272014-03-19T04:01:00.001-07:002014-03-19T04:01:04.116-07:00Composition versus aggregation Java Code example <script type="text/javascript">
google_ad_client = "ca-pub-8470945096737641";
/* 160x600, created 6/23/09 */
google_ad_slot = "3027217057";
google_ad_width = 160;
google_ad_height =200 ;
//
</script><br />
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script><br />
<div dir="ltr" style="text-align: left;" trbidi="on"><span style="color: purple;"><b>Aggregation </b></span><br />
<br />
<br />
Read comments in Test class to understand the scenario / Code flow <br />
<br />
<br />
<span style="font-family: "Courier New",Courier,monospace;">package com.sam;<br />
<br />
<b> class Car {</b><br />
Engine engine;<br />
<br />
public Car() {<br />
<br />
engine = Engine.getEngineInstance();<br />
<br />
}<br />
<br />
Engine getEngine() {<br />
return this.engine;<br />
}<br />
<br />
}<br />
<br />
<b>class Engine {</b><br />
<br />
private Engine() {<br />
<br />
}<br />
<br />
public static Engine getEngineInstance() {<br />
<br />
return new Engine();<br />
}<br />
<br />
public void performAction(String str ) {<br />
<br />
System.out.println("Performed.."+str);<br />
}<br />
}<br />
<br />
<b>public class Test {</b><br />
<br />
public static void main(String args[]) {<br />
<br />
Engine engine = Engine.getEngineInstance(); // can ncreate Engine instance ,<br />
// Engine can exist on its own ,<br />
// It can exist even without car instance<br />
<br />
engine.performAction("With Out Car Instance");<br />
<br />
Car car = new Car(); // Car class has dependency on ENgine class to perform Action<br />
// But Engine Class instance can be created and used even without<br />
// creating Car class instance<br />
<br />
car.getEngine().performAction("With Car Instance");<br />
<br />
}<br />
}</span><br />
<br />
<br />
<br />
<br />
<script type="text/javascript">
google_ad_client = "ca-pub-8470945096737641";
/* 200x200, created 6/23/09 */
google_ad_slot = "8930436823";
google_ad_width = 200;
google_ad_height = 200;
</script><br />
<br />
<br />
<b>composition</b><br />
<span style="color: purple;"><b><br />
</b></span><br />
Read comments in Test class to understand the scenario / Code flow <br />
<br />
<br />
<span style="color: purple;"><span style="font-family: "Courier New",Courier,monospace;">package com.sam;<br />
<b>class Car {</b><br />
Engine engine;<br />
<br />
public Car() {<br />
<br />
engine = new Engine();<br />
<br />
}<br />
<br />
Engine getEngine() {<br />
return this.engine;<br />
}<br />
<br />
<b> class Engine {</b><br />
<br />
private Engine() {<br />
<br />
}<br />
<br />
public Engine getEngineInstance() {<br />
<br />
return new Engine();<br />
}<br />
<br />
public void performAction(String str) {<br />
<br />
System.out.println("Performed.." + str);<br />
}<br />
}<br />
<br />
}<br />
<br />
<b>public class Test {</b><br />
<br />
public static void main(String args[]) {<br />
<br />
Engine engine = Engine.getEngineInstance(); // compilation error / can not create Engine instance ,<br />
// Engine can not exist on its own ,<br />
// It can exist only with car instance<br />
<br />
engine.performAction("With Out Car Instance");<br />
<br />
Car car = new Car(); // Car class has dependency on ENgine class to perform Action<br />
// SO Engine Class instance can be created only with<br />
// Car class instance<br />
<br />
car.getEngine().performAction("With Car Instance");<br />
<br />
}<br />
}</span></span></div><br />
<br />
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script><br />
<br />
<br />
<script type="text/javascript">
google_ad_client = "ca-pub-8470945096737641";
/* seo banner */
google_ad_slot = "3657212241";
google_ad_width = 468;
google_ad_height = 300;
//-->
</script><br />
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>MANOJ KUMARhttp://www.blogger.com/profile/00421517842858762886noreply@blogger.com0tag:blogger.com,1999:blog-3445872732437342114.post-68021435859986575442014-03-17T20:48:00.000-07:002014-03-17T20:48:09.286-07:00File upload Jersey Grizzly example <div dir="ltr" style="text-align: left;" trbidi="on">
<script type="text/javascript">
google_ad_client = "ca-pub-8470945096737641";
/* 160x600, created 6/23/09 */
google_ad_slot = "3027217057";
google_ad_width = 160;
google_ad_height =200 ;
//
</script><br />
<script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript">
</script><br />
<br />
<div dir="ltr" style="text-align: left;" trbidi="on">
1. Below class is required to startup the grizzly embedded container<br />
<br />
<span style="color: #444444;"><span style="font-family: "Courier New",Courier,monospace;">package com.example;<br />
<br />
import org.glassfish.grizzly.http.server.HttpServer;<br />
importorg.glassfish.jersey.grizzly2.httpserver.GrizzlyHttpServerFactory;<br />
import org.glassfish.jersey.server.ResourceConfig;<br />
<br />
import java.io.IOException;<br />
import java.net.URI;<br />
<br />
/**<br />
* Main class.<br />
*<br />
*/<br />
<b>public class Main {</b><br />
// Base URI the Grizzly HTTP server will listen on<br />
public static final String BASE_URI = "http://localhost:8080/myapp/";<br />
<br />
/**<br />
* Starts Grizzly HTTP server exposing JAX-RS resources defined in this application.<br />
* @return Grizzly HTTP server.<br />
*/<br />
public static HttpServer <b>startServer</b>() {<br />
// create a resource config that scans for JAX-RS resources and providers<br />
// in com.example package<br />
<b>final ResourceConfig rc = new ResourceConfig().packages("com.example");</b><br />
<br />
// create and start a new instance of grizzly http server<br />
// exposing the Jersey application at BASE_URI<br />
return GrizzlyHttpServerFactory.createHttpServer(URI.create(BASE_URI), rc);<br />
}<br />
<br />
/**<br />
* Main method.<br />
* @param args<br />
* @throws IOException<br />
*/<br />
<b> public static void main(String[] args) throws IOException {</b><br />
final HttpServer server = startServer();<br />
System.out.println(String.format("Jersey app started with WADL available at "<br />
+ "%sapplication.wadl\nHit enter to stop it...", BASE_URI));<br />
System.in.read();<br />
server.stop();<br />
}<br />
}</span></span><br />
<br />
<b>As highlighted in above code this Main class will register all the web service classes lying under com.example package . SO Let us create our upload service in example package </b><br />
<span style="color: #444444;"><span style="font-family: "Courier New",Courier,monospace;"><br />
</span></span> <span style="color: #444444;"><span style="font-family: "Courier New",Courier,monospace;"><br />
</span></span> <span style="color: #444444;"><span style="font-family: "Courier New",Courier,monospace;"> import com.sun.jersey.multipart.FormDataParam;<br />
<br />
import java.io.File;<br />
import java.io.FileOutputStream;<br />
import java.io.IOException;<br />
import java.io.InputStream;<br />
import java.io.OutputStream;<br />
<br />
import javax.ws.rs.Consumes;<br />
import javax.ws.rs.POST;<br />
import javax.ws.rs.Path;<br />
import javax.ws.rs.PathParam;<br />
import javax.ws.rs.Produces;<br />
import javax.ws.rs.core.MediaType;<br />
import javax.ws.rs.core.Response;<br />
<br />
@Path("/files")<br />
<b> public class JerseyFileUpload {</b><br />
<br />
@POST<br />
@Path("/upload/{filename}")<br />
@Consumes(MediaType.MULTIPART_FORM_DATA)<br />
@Produces(MediaType.TEXT_PLAIN)<br />
<b>public Response uploadFile(<br />
@FormDataParam("file") InputStream uploadedInputStream ,@PathParam("filename") String fileName)</b> {<br />
<br />
System.out.println("fileName"+fileName);<br />
// String uploadedFileLocation = "c://uploadedFiles/" + "fileDetail.getFileName()";<br />
String uploadedFileLocation = "D:/desktops/12march2014/uploads/"+fileName;<br />
// save it<br />
saveToFile(uploadedInputStream, uploadedFileLocation);<br />
<br />
String output = "File uploaded via Jersey based RESTFul Webservice to: " + uploadedFileLocation;<br />
<br />
return Response.status(200).entity(output).build();<br />
<br />
}<br />
<br />
// save uploaded file to new location<br />
<b> private void saveToFile(InputStream uploadedInputStream,<br />
String uploadedFileLocation) {</b><br />
<br />
try {<br />
OutputStream out = null;<br />
int read = 0;<br />
byte[] bytes = new byte[1024];<br />
<br />
out = new FileOutputStream(new File(uploadedFileLocation));<br />
while ((read = uploadedInputStream.read(bytes)) != -1) {<br />
out.write(bytes, 0, read);<br />
}<br />
out.flush();<br />
out.close();<br />
} catch (IOException e) {<br />
<br />
e.printStackTrace();<br />
}<br />
<br />
}<br />
<br />
}<br />
<b><br />
</b></span></span><br />
<b>That was server side Code. Execute the Main.java class as java application. It will start up the Grizzly server and JerseyUpload service will be up and running.</b><br />
<br />
<br />
<script type="text/javascript">
google_ad_client = "ca-pub-8470945096737641";
/* seo banner */
google_ad_slot = "3657212241";
google_ad_width = 468;
google_ad_height = 300;
//</script>
</div>
</div>
--><br /><script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript">
</script><br />
<br />
<br />
<b>Now Lets write Client Code to call this service :</b><br />
<br />
<span style="font-family: "Courier New",Courier,monospace;">package com.sapient;<br />
<br />
import java.io.File;<br />
import java.io.IOException;<br />
import java.io.UnsupportedEncodingException;<br />
import java.util.Scanner;<br />
<br />
import org.apache.http.HttpEntity;<br />
import org.apache.http.HttpResponse;<br />
import org.apache.http.client.HttpClient;<br />
import org.apache.http.client.methods.HttpPost;<br />
import org.apache.http.entity.mime.MultipartEntity;<br />
import org.apache.http.entity.mime.content.FileBody;<br />
import org.apache.http.entity.mime.content.StringBody;<br />
import org.apache.http.impl.client.DefaultHttpClient;<br />
<br />
<b>public class JerseyClient {</b><br />
<br />
/**<br />
* @param args<br />
*/<br />
<b> public static void main(String[] args) {</b><br />
File file = new File("C:/Users/mkum63/Downloads/spring-framework-2.5-with-dependencies.zip");<br />
<br />
if (args.length >0 && null != args[0]) {<br />
file = new File(args[0]);<br />
} else {<br />
<br />
System.out.println("Enter full path of file..");<br />
<br />
String path;<br />
<br />
Scanner scanIn = new Scanner(System.in);<br />
path = scanIn.nextLine();<br />
<br />
file = new File(path);<br />
<br />
}<br />
HttpClient httpclient = new DefaultHttpClient();<br />
HttpPost httppost =<br />
new HttpPost("http://localhost:8080/myapp/files/upload/" + file.getName());<br />
FileBody fileContent = new FileBody(file);<br />
try {<br />
StringBody comment = new StringBody("Filename: " + file.getName());<br />
} catch (UnsupportedEncodingException e) {<br />
// TODO Auto-generated catch block<br />
e.printStackTrace();<br />
}<br />
MultipartEntity reqEntity = new MultipartEntity();<br />
reqEntity.addPart("file", fileContent);<br />
httppost.setEntity(reqEntity);<br />
HttpResponse response = null;<br />
try {<br />
response = httpclient.execute(httppost);<br />
System.out.println(response.getStatusLine().getStatusCode() == 200 ? "successful" : "Failed");<br />
// System.out.println(response.getStatusLine().getStatusCode());<br />
} catch (IOException e) {<br />
// TODO Auto-generated catch block<br />
e.printStackTrace();<br />
}<br />
HttpEntity resEntity = response.getEntity();<br />
<br />
}<br />
<br />
}</span><br />
<br />
<b>This is the client .Execute this class as java application and supply the full path of the file to be uploaded. </b><br />
<b><br />
</b> <b>You can keep your server files and client files on different machines. </b><br />
<br />
<br />
<br />
<br />
<br />
<br />
<script type="text/javascript">
google_ad_client = "ca-pub-8470945096737641";
/* 200x200, created 6/23/09 */
google_ad_slot = "8930436823";
google_ad_width = 200;
google_ad_height = 200;
</script><br />
<script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript">
</script><br />
<br />MANOJ KUMARhttp://www.blogger.com/profile/00421517842858762886noreply@blogger.com1tag:blogger.com,1999:blog-3445872732437342114.post-10953200141892945352014-03-03T19:34:00.000-08:002014-03-03T19:34:21.219-08:00Reading Content from a PDF file <script type="text/javascript">
google_ad_client = "ca-pub-8470945096737641";
/* 160x600, created 6/23/09 */
google_ad_slot = "3027217057";
google_ad_width = 160;
google_ad_height =200 ;
//
</script><br />
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script><br />
<br />
<br />
<br />
<div dir="ltr" style="text-align: left;" trbidi="on">How to extract content from a PDF file in java<br />
<br />
Here I am extreacting last 200 characters of a PDF file.<br />
<br />
<br />
<br />
import java.io.File;<br />
import org.apache.pdfbox.pdmodel.PDDocument;<br />
import org.apache.pdfbox.util.PDFTextStripper;<br />
<br />
public class PDFReader {<br />
<br />
/**<br />
* @param args<br />
*/<br />
public static void main(String[] args) {<br />
<br />
{<br />
try<br />
{<br />
PDDocument pddDocument=PDDocument.load(new File("C:/Users/mkum63/Desktop/vit-strategic-growth-inst-sp.pdf"));<br />
System.out.println(pddDocument.getNumberOfPages());<br />
PDFTextStripper textStripper=new PDFTextStripper();<br />
String text=textStripper.getText(pddDocument);<br />
//System.out.println(textStripper.getEndPage());<br />
System.out.println(text.subSequence(text.length()-200, text.length()));<br />
pddDocument.close();<br />
}<br />
catch(Exception ex)<br />
{<br />
ex.printStackTrace();<br />
}<br />
}<br />
}<br />
<br />
}<br />
<br />
Jar files required :<br />
<br />
commons-logging-api-1.1.1<br />
fontbox-1.2.1<br />
pdfbox-1.3.1<br />
<br />
<br />
</div><br />
<br />
<script type="text/javascript">
google_ad_client = "ca-pub-8470945096737641";
/* 200x200, created 6/23/09 */
google_ad_slot = "8930436823";
google_ad_width = 200;
google_ad_height = 200;
</script><br />
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script><br />
<br />
<br />
<script type="text/javascript">
google_ad_client = "ca-pub-8470945096737641";
/* seo banner */
google_ad_slot = "3657212241";
google_ad_width = 468;
google_ad_height = 300;
//-->
</script><br />
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>MANOJ KUMARhttp://www.blogger.com/profile/00421517842858762886noreply@blogger.com1tag:blogger.com,1999:blog-3445872732437342114.post-27745034396495099582014-03-03T19:18:00.001-08:002014-03-03T19:18:58.868-08:00JCR SQL2 Query to exclude a path<div dir="ltr" style="text-align: left;" trbidi="on">JCR Query to select data from one parent path and at the same time exculding a child path<br />
<br />
<br />
<script type="text/javascript">
google_ad_client = "ca-pub-8470945096737641";
/* seo banner */
google_ad_slot = "3657212241";
google_ad_width = 468;
google_ad_height = 300;
//-->
</script><br />
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script><br />
For example<br />
<br />
I want to select all nt:unstructured PDF nodes under en folder except nodes falling under investor-resource folder<br />
<br />
<br />
<br />
<script type="text/javascript">
google_ad_client = "ca-pub-8470945096737641";
/* 200x200, created 6/23/09 */
google_ad_slot = "8930436823";
google_ad_width = 200;
google_ad_height = 200;
</script><br />
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script><br />
<br />
<br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjHj_HDZLGulAoBI1dUIIsxj8eUhzYYb9_PDiPseWXyU1J28pHe6Ump2qR540PKL4VglWoeDHJeKVzQmHPxoHLfcR-BoBEMjckp6IoydeuJLExaOOj1tvJIODztel01M88hWMCWHEx_Ouw/s1600/1.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjHj_HDZLGulAoBI1dUIIsxj8eUhzYYb9_PDiPseWXyU1J28pHe6Ump2qR540PKL4VglWoeDHJeKVzQmHPxoHLfcR-BoBEMjckp6IoydeuJLExaOOj1tvJIODztel01M88hWMCWHEx_Ouw/s1600/1.png" height="200" width="320" /></a></div><br />
<br />
select * from [nt:unstructured] as p<br />
where<br />
(isdescendantnode (p, [/content/dam/gsam/pdfs/us/en/])<br />
AND NOT isdescendantnode (p, [/content/dam/gsam/pdfs/us/en/investor-resources]))<br />
and contains(p.*, 'application/pdf')<br />
<div><br />
</div></div><script type="text/javascript">
google_ad_client = "ca-pub-8470945096737641";
/* 160x600, created 6/23/09 */
google_ad_slot = "3027217057";
google_ad_width = 160;
google_ad_height =200 ;
//
</script><br />
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script><br />
MANOJ KUMARhttp://www.blogger.com/profile/00421517842858762886noreply@blogger.com0tag:blogger.com,1999:blog-3445872732437342114.post-50779194979391148902014-03-02T19:43:00.000-08:002014-03-02T20:13:07.075-08:00Jersey web service + File Upload + Maven + Tomcat +Java + Rest Web service<div dir="ltr" style="text-align: left;" trbidi="on">
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg2Pr6fy8IYdSAmDMZTLFyNhbF9xtEt9D32C4OPXNJI8BgvrScbindR9GADU31a3-Tx5jau4k-LmwYf-yLfhNGJiBdi8ib4g1DRqxdzrwGftlNu5kXrs_YOlE4zQjT3Xy38q_yY00n6kek/s1600/1.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg2Pr6fy8IYdSAmDMZTLFyNhbF9xtEt9D32C4OPXNJI8BgvrScbindR9GADU31a3-Tx5jau4k-LmwYf-yLfhNGJiBdi8ib4g1DRqxdzrwGftlNu5kXrs_YOlE4zQjT3Xy38q_yY00n6kek/s1600/1.jpg" height="200" width="320" /></a></div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjCpzI3M3_30hBA-yru0IvLBuSR0bZVdfpMrhYsVscBdt1cYGE7KkzJoQpDxgyTFqU2rywOMZTQmybqPgzPeVBX-fJlgbSdsq4F8qfiXPri5ysrA2HYasskCuHIhANu5_bfSl-uuewom5Y/s1600/2.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjCpzI3M3_30hBA-yru0IvLBuSR0bZVdfpMrhYsVscBdt1cYGE7KkzJoQpDxgyTFqU2rywOMZTQmybqPgzPeVBX-fJlgbSdsq4F8qfiXPri5ysrA2HYasskCuHIhANu5_bfSl-uuewom5Y/s1600/2.jpg" height="200" width="320" /></a></div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh5IgnLQ7WG7aMkuhbIYRQ-IGfHDV3_bCXG6hAPCMV7QrgANMxgctrBCHraj9UZfuaQbescycnI2KWJ_LMLP_dAxd1N7rmpTX4UQee6OH4Y9uD_kn4hFgrd496CDMMbxXbPhBD-3VtUI38/s1600/3.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh5IgnLQ7WG7aMkuhbIYRQ-IGfHDV3_bCXG6hAPCMV7QrgANMxgctrBCHraj9UZfuaQbescycnI2KWJ_LMLP_dAxd1N7rmpTX4UQee6OH4Y9uD_kn4hFgrd496CDMMbxXbPhBD-3VtUI38/s1600/3.jpg" height="200" width="320" /></a></div>
<br />
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgRave5bY1mXNnyod6-EGzGho7ttAHpCndzRoVJUQbnxvYLRaJK9nOKLnMQNPHc8KGwFVC2e7297iUiy5815aggO2P8QWbErpbgOI4ptXTiein594KtAABnBNCNwDTNsUcS97wDNllaLN4/s1600/4.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgRave5bY1mXNnyod6-EGzGho7ttAHpCndzRoVJUQbnxvYLRaJK9nOKLnMQNPHc8KGwFVC2e7297iUiy5815aggO2P8QWbErpbgOI4ptXTiein594KtAABnBNCNwDTNsUcS97wDNllaLN4/s1600/4.jpg" height="200" width="320" /></a></div>
<br />
<div dir="ltr" style="text-align: left;" trbidi="on">
<div class="separator" style="clear: both; text-align: center;">
</div>
</div>
<br />
<br />
<div dir="ltr" style="text-align: left;" trbidi="on">
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://www.blogger.com/blogger.g?blogID=3445872732437342114" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"></a></div>
<br /></div>
<div dir="ltr" style="text-align: left;" trbidi="on">
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
------------------------------------------------------------------------------------------</div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="" style="clear: both; text-align: left;">
package com.gs.gsam.lo.du;<br /><br />import java.io.File;<br />import java.io.FileInputStream;<br />import java.io.FileNotFoundException;<br />import java.io.FileOutputStream;<br />import java.io.IOException;<br />import java.io.InputStream;<br />import java.io.OutputStream;<br /><br />import javax.ws.rs.Consumes;<br />import javax.ws.rs.GET;<br />import javax.ws.rs.POST;<br />import javax.ws.rs.Path;<br />import javax.ws.rs.core.MediaType;<br />import javax.ws.rs.core.Response;<br /><br />import com.sun.jersey.core.header.FormDataContentDisposition;<br />import com.sun.jersey.multipart.FormDataParam;<br /><br />// Plain old Java Object it does not extend as class or implements <br />// an interface<br /><br />// The class registers its methods for the HTTP GET request using the @GET annotation. <br />// Using the @Produces annotation, it defines that it can deliver several MIME types,<br />// text, XML and HTML. <br /><br />// The browser requests per default the HTML MIME type.<br /><br />//Sets the path to base URL + /hello<br />@Path("/upload")<br />public class DocumentUploader {<br /><br /> /*<br /> * // @Produces(MediaType.TEXT_HTML)<br /> * <br /> * @GET public String sayHtmlHello() { return "<html> " + " <title>" + "Hello Jerse y " + "</title>" + "<body><h1>
"<br /> * + "Hello Jersey" + "</h1>
</body></html></div>
</div>
</div>
" + " "; }<br /> */<br /> @POST<br /> @Path("/pdf")<br /> @Consumes(MediaType.MULTIPART_FORM_DATA)<br /> public Response uploadFile(@FormDataParam("file") File file) {<br /> InputStream IS = null;;<br /> String uploadedFileLocation = "d://" + "Test.zip";<br /><br /> try {<br /> IS = new FileInputStream(file);<br /> } catch (FileNotFoundException e) {<br /> // TODO Auto-generated catch block<br /> e.printStackTrace();<br /> } finally {<br /><br /> }<br /><br /> // save it<br /> writeToFile(IS, uploadedFileLocation);<br /><br /> String output = "The PDF File uploaded to : " + uploadedFileLocation;<br /><br /> return Response.status(200).entity(output).build();<br /><br /> }<br /><br /> // save uploaded file to new location<br /> private void writeToFile(InputStream uploadedInputStream, String uploadedFileLocation) {<br /> OutputStream out = null;<br /> try {<br /> out = new FileOutputStream(new File(uploadedFileLocation));<br /> int read = 0;<br /> byte[] bytes = new byte[1024];<br /><br /> out = new FileOutputStream(new File(uploadedFileLocation));<br /> while ((read = uploadedInputStream.read(bytes)) != -1) {<br /> out.write(bytes, 0, read);<br /> }<br /> out.flush();<br /> out.close();<br /> uploadedInputStream.close();<br /> } catch (IOException e) {<br /><br /> e.printStackTrace();<br /> } finally {<br /> try {<br /> if (out != null) {<br /> out.close();<br /><br /> }<br /> if (uploadedInputStream != null) {<br /> uploadedInputStream.close();<br /> }<br /> } catch (IOException e) {<br /> e.printStackTrace();<br /> }<br /> }<br /><br /> }<br /><br />}<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
-------------------------------------------------------------------------</div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
<a href="https://www.blogger.com/blogger.g?blogID=3445872732437342114" imageanchor="1" style="clear: right; float: right; margin-bottom: 1em; margin-left: 1em;"></a><a href="https://www.blogger.com/blogger.g?blogID=3445872732437342114" imageanchor="1" style="clear: right; float: right; margin-bottom: 1em; margin-left: 1em;"></a>package com.gs.gsam.lo.client;<br />import com.sun.jersey.api.client.Client;<br />import com.sun.jersey.api.client.ClientResponse;<br />import com.sun.jersey.api.client.WebResource;<br /><br />import java.io.File;<br />import java.io.FileInputStream;<br />import java.io.FileNotFoundException;<br />import java.io.FileOutputStream;<br />import java.io.IOException;<br />import java.io.InputStream;<br />import java.io.OutputStream;<br /><br />import javax.ws.rs.core.MediaType;<br /><br />public class ClientJ {<br /><br /> public static void main(String[] args) throws IOException {<br /><br /> InputStream is=null;<br /> try {<br /><br /> Client client = Client.create();<br /><br /> WebResource webResource = client<br /> .resource("http://localhost:8080/FileUpload-0.0.1-SNAPSHOT/rest/upload/pdf");<br /><br /> InputStream IS = null;;<br /><br /> File file =new File("D:/file/file.zip");<br /> <br /> String uploadedFileLocation = "d://" + "Test.zip";<br /><br /> try {<br /> IS = new FileInputStream(file);<br /> } catch (FileNotFoundException e) {<br /> // TODO Auto-generated catch block<br /> e.printStackTrace();<br /> } finally {<br /><br /> }<br /><br /> // save it<br /> writeToFile(IS, uploadedFileLocation);<br /><br /> String output = "The PDF File uploaded to : " + uploadedFileLocation;<br /> <br /> // is=new FileInputStream(file);<br /> /* ClientResponse response = webResource.type(MediaType.MULTIPART_FORM_DATA)<br /> .post(ClientResponse.class,file );<br /><br /> if (response.getStatus() != 200) {<br /> throw new RuntimeException("Failed : HTTP error code : "<br /> + response.getStatus());<br /> }<br /><br /> System.out.println("Output from Server .... \n");<br /> String output = response.getEntity(String.class);<br /> System.out.println(output);<br /><br /> */ System.exit(0);<br /> } catch (Exception e) {<br /><br /> e.printStackTrace();<br /><br /> }finally{<br /> if(null!=is){<br /> is.close();<br /> }<br /> }<br /><br /> }<br /> <br />//save uploaded file to new location<br /> private static void writeToFile(InputStream uploadedInputStream, String uploadedFileLocation) {<br /> OutputStream out = null;<br /> try {<br /> out = new FileOutputStream(new File(uploadedFileLocation));<br /> int read = 0;<br /> byte[] bytes = new byte[1024];<br /><br /> out = new FileOutputStream(new File(uploadedFileLocation));<br /> while ((read = uploadedInputStream.read(bytes)) != -1) {<br /> out.write(bytes, 0, read);<br /> }<br /> out.flush();<br /> out.close();<br /> uploadedInputStream.close();<br /> } catch (IOException e) {<br /><br /> e.printStackTrace();<br /> } finally {<br /> try {<br /> if (out != null) {<br /> out.close();<br /><br /> }<br /> if (uploadedInputStream != null) {<br /> uploadedInputStream.close();<br /> }<br /> } catch (IOException e) {<br /> e.printStackTrace();<br /> }<br /> }<br /><br /> }<br /><br />} </div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://www.blogger.com/blogger.g?blogID=3445872732437342114" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"></a></div>
<br />MANOJ KUMARhttp://www.blogger.com/profile/00421517842858762886noreply@blogger.com0tag:blogger.com,1999:blog-3445872732437342114.post-78335806571474258262014-02-21T07:54:00.001-08:002014-02-21T07:54:11.834-08:00Heuristic exceptions<div dir="ltr" style="text-align: left;" trbidi="on">
<script type="text/javascript">
google_ad_client = "ca-pub-8470945096737641";
/* 160x600, created 6/23/09 */
google_ad_slot = "3027217057";
google_ad_width = 160;
google_ad_height =200 ;
//
</script><br />
<script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript">
</script><br />
<br />
<br />
<br />
<div dir="ltr" style="text-align: left;" trbidi="on">
<span style="color: #073763; font-family: Times, Times New Roman, serif;"><i><u>Heuristic exceptions are inconsistent exceptions . These exceptions does not come all the time and May occur suddenly due to some unavoidable condition </u></i></span><br />
<br />
<br />
<script type="text/javascript">
google_ad_client = "ca-pub-8470945096737641";
/* 200x200, created 6/23/09 */
google_ad_slot = "8930436823";
google_ad_width = 200;
google_ad_height = 200;
</script><br />
<script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript">
</script><br />
<br />
<br />
<span style="color: #073763; font-family: Times, Times New Roman, serif;"><i><br />
</i></span> <span style="color: #073763; font-family: Times, Times New Roman, serif;"><i>For example You are calling a service to do some transaction on database and data-source configuration is missing . This happened because last time server got restarted Data-source configuration is removed . So this can be restored by setting the configuration right. </i></span><br />
<span style="color: #073763; font-family: Times, Times New Roman, serif;"><i><br />
</i></span> <span style="color: #073763; font-family: Times, Times New Roman, serif;"><i>For example in distributed system multiple parties taking part in a two phase commit transaction are waiting for transaction manager to get information If all of them should commit their individual transaction or not. Transaction manager took lot of time to response and Participant committed their individual transaction even before that . There could come a situation where some participants commit their transaction while others don't and they rollback it if transaction manager sends information to rollback. Thus in distributed system data becomes highly inconsistent .</i></span><br />
<span style="color: #073763; font-family: Times, Times New Roman, serif;"><i>You put some message in JMS queue But all of a sudden Queue connection breaks and you fail you get any proper response .</i></span><br />
<span style="color: #073763; font-family: Times, Times New Roman, serif;"><i><br />
</i></span> <span style="color: #073763; font-family: Times, Times New Roman, serif;"><i><u>Such kind of strange and inconsistent exception falls under heuristic exceptions.</u></i></span></div>
<br />
<br />
<script type="text/javascript">
google_ad_client = "ca-pub-8470945096737641";
/* seo banner */
google_ad_slot = "3657212241";
google_ad_width = 468;
google_ad_height = 300;
//</script>
</div>
--><br /><script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript">
</script>MANOJ KUMARhttp://www.blogger.com/profile/00421517842858762886noreply@blogger.com0tag:blogger.com,1999:blog-3445872732437342114.post-16388769373628862002014-02-20T19:39:00.001-08:002014-02-20T19:39:03.482-08:00Creating a zip file in java <div dir="ltr" style="text-align: left;" trbidi="on"><span style="color: purple; font-family: Arial, Helvetica, sans-serif;">Creating a zip file in java </span><br />
<br />
<script type="text/javascript">
google_ad_client = "ca-pub-8470945096737641";
/* seo banner */
google_ad_slot = "3657212241";
google_ad_width = 468;
google_ad_height = 300;
//-->
</script><br />
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script><br />
<span style="color: purple; font-family: Arial, Helvetica, sans-serif;"><br />
</span> <span style="color: purple; font-family: Arial, Helvetica, sans-serif;">Converting a String into a test file and putting that in zip file </span><br />
<span style="color: purple; font-family: Arial, Helvetica, sans-serif;"><br />
</span> <br />
<ol style="text-align: left;"><li><span style="color: purple; font-family: Arial, Helvetica, sans-serif;">Here I am creating File.zip file at location D:/file.zip</span></li>
<li><span style="color: purple; font-family: Arial, Helvetica, sans-serif;">Here two text files are using by reading an existing txt file</span></li>
<li><span style="color: purple; font-family: Arial, Helvetica, sans-serif;">One Pdf file is created by reading an existing file</span></li>
<li><span style="color: purple; font-family: Arial, Helvetica, sans-serif;">One txt file is created from a String </span></li>
<script type="text/javascript">
google_ad_client = "ca-pub-8470945096737641";
/* 200x200, created 6/23/09 */
google_ad_slot = "8930436823";
google_ad_width = 200;
google_ad_height = 200;
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
<li><span style="color: purple; font-family: Arial, Helvetica, sans-serif;">All are zipped together and are put in zip file </span></li>
</ol><br />
<br />
<br />
<span style="color: #351c75; font-family: Courier New, Courier, monospace;"><b><br />
</b></span> <span style="color: #351c75; font-family: Courier New, Courier, monospace;"><b>import java.io.BufferedReader;</b></span><br />
<span style="color: #351c75; font-family: Courier New, Courier, monospace;"><b>import java.io.ByteArrayInputStream;</b></span><br />
<span style="color: #351c75; font-family: Courier New, Courier, monospace;"><b>import java.io.FileInputStream;</b></span><br />
<span style="color: #351c75; font-family: Courier New, Courier, monospace;"><b>import java.io.FileOutputStream;</b></span><br />
<span style="color: #351c75; font-family: Courier New, Courier, monospace;"><b>import java.io.IOException;</b></span><br />
<span style="color: #351c75; font-family: Courier New, Courier, monospace;"><b>import java.io.InputStream;</b></span><br />
<span style="color: #351c75; font-family: Courier New, Courier, monospace;"><b>import java.io.InputStreamReader;</b></span><br />
<span style="color: #351c75; font-family: Courier New, Courier, monospace;"><b>import java.util.zip.ZipEntry;</b></span><br />
<span style="color: #351c75; font-family: Courier New, Courier, monospace;"><b>import java.util.zip.ZipOutputStream;</b></span><br />
<span style="color: #351c75; font-family: Courier New, Courier, monospace;"><b><br />
</b></span> <span style="color: #351c75; font-family: Courier New, Courier, monospace;"><b><br />
</b></span> <span style="color: #351c75; font-family: Courier New, Courier, monospace;"><b>public class Zipper {</b></span><br />
<span style="color: #351c75; font-family: Courier New, Courier, monospace;"><b> </b></span><br />
<span style="color: #351c75; font-family: Courier New, Courier, monospace;"><b> public static void main( String[] args )</b></span><br />
<span style="color: #351c75; font-family: Courier New, Courier, monospace;"><b> {</b></span><br />
<span style="color: #351c75; font-family: Courier New, Courier, monospace;"><b> byte[] buffer = new byte[1024];</b></span><br />
<br />
<span style="color: #351c75; font-family: Courier New, Courier, monospace;"><b> try{</b></span><br />
<br />
<span style="color: #351c75; font-family: Courier New, Courier, monospace;"><b> FileOutputStream fos = new FileOutputStream("D:\\File.zip");</b></span><br />
<span style="color: #351c75; font-family: Courier New, Courier, monospace;"><b> ZipOutputStream zos = new ZipOutputStream(fos);</b></span><br />
<span style="color: #351c75; font-family: Courier New, Courier, monospace;"><b> ZipEntry ze= new ZipEntry("spy.txt");</b></span><br />
<span style="color: #351c75; font-family: Courier New, Courier, monospace;"><b> zos.putNextEntry(ze);</b></span><br />
<span style="color: #351c75; font-family: Courier New, Courier, monospace;"><b> FileInputStream in = new FileInputStream("D:\\spy.txt");</b></span><br />
<br />
<span style="color: #351c75; font-family: Courier New, Courier, monospace;"><b> int len;</b></span><br />
<span style="color: #351c75; font-family: Courier New, Courier, monospace;"><b> while ((len = in.read(buffer)) > 0) {</b></span><br />
<span style="color: #351c75; font-family: Courier New, Courier, monospace;"><b> zos.write(buffer, 0, len);</b></span><br />
<span style="color: #351c75; font-family: Courier New, Courier, monospace;"><b> }</b></span><br />
<br />
<span style="color: #351c75; font-family: Courier New, Courier, monospace;"><b> in.close();</b></span><br />
<span style="color: #351c75; font-family: Courier New, Courier, monospace;"><b> </b></span><br />
<span style="color: #351c75; font-family: Courier New, Courier, monospace;"><b> ZipEntry ze1= new ZipEntry("spy1.txt");</b></span><br />
<span style="color: #351c75; font-family: Courier New, Courier, monospace;"><b> zos.putNextEntry(ze1);</b></span><br />
<span style="color: #351c75; font-family: Courier New, Courier, monospace;"><b> FileInputStream in1 = new FileInputStream("D:\\spy.txt");</b></span><br />
<br />
<span style="color: #351c75; font-family: Courier New, Courier, monospace;"><b> int len1;</b></span><br />
<span style="color: #351c75; font-family: Courier New, Courier, monospace;"><b> while ((len1 = in1.read(buffer)) > 0) {</b></span><br />
<span style="color: #351c75; font-family: Courier New, Courier, monospace;"><b> zos.write(buffer, 0, len1);</b></span><br />
<span style="color: #351c75; font-family: Courier New, Courier, monospace;"><b> }</b></span><br />
<br />
<span style="color: #351c75; font-family: Courier New, Courier, monospace;"><b> in1.close();</b></span><br />
<span style="color: #351c75; font-family: Courier New, Courier, monospace;"><b> </b></span><br />
<span style="color: #351c75; font-family: Courier New, Courier, monospace;"><b> ZipEntry ze2= new ZipEntry("Promote PDF.pdf");</b></span><br />
<span style="color: #351c75; font-family: Courier New, Courier, monospace;"><b> zos.putNextEntry(ze2);</b></span><br />
<span style="color: #351c75; font-family: Courier New, Courier, monospace;"><b> FileInputStream in2 = new FileInputStream("C:/Users/mkum63/Desktop/Promote PDF.pdf");</b></span><br />
<br />
<span style="color: #351c75; font-family: Courier New, Courier, monospace;"><b> int len2;</b></span><br />
<span style="color: #351c75; font-family: Courier New, Courier, monospace;"><b> while ((len2 = in2.read(buffer)) > 0) {</b></span><br />
<span style="color: #351c75; font-family: Courier New, Courier, monospace;"><b> zos.write(buffer, 0, len2);</b></span><br />
<span style="color: #351c75; font-family: Courier New, Courier, monospace;"><b> }</b></span><br />
<br />
<span style="color: #351c75; font-family: Courier New, Courier, monospace;"><b> in.close();</b></span><br />
<span style="color: #351c75; font-family: Courier New, Courier, monospace;"><b> </b></span><br />
<span style="color: #351c75; font-family: Courier New, Courier, monospace;"><b> </b></span><br />
<span style="color: #351c75; font-family: Courier New, Courier, monospace;"><b> ZipEntry ze4= new ZipEntry("spy4.txt");</b></span><br />
<span style="color: #351c75; font-family: Courier New, Courier, monospace;"><b> zos.putNextEntry(ze4);</b></span><br />
<span style="color: #351c75; font-family: Courier New, Courier, monospace;"><b> StringBuilder sb=new StringBuilder();</b></span><br />
<span style="color: #351c75; font-family: Courier New, Courier, monospace;"><b> sb.append("dfdgfdgf");</b></span><br />
<span style="color: #351c75; font-family: Courier New, Courier, monospace;"><b> sb.append("\n");</b></span><br />
<span style="color: #351c75; font-family: Courier New, Courier, monospace;"><b> sb.append("dsfsdfs");</b></span><br />
<span style="color: #351c75; font-family: Courier New, Courier, monospace;"><b> sb.append("/n");</b></span><br />
<span style="color: #351c75; font-family: Courier New, Courier, monospace;"><b> sb.append("dsfsfsdfdffdf");</b></span><br />
<span style="color: #351c75; font-family: Courier New, Courier, monospace;"><b><br />
</b></span> <span style="color: #351c75; font-family: Courier New, Courier, monospace;"><b> InputStream in4 = new ByteArrayInputStream(sb.toString().getBytes());</b></span><br />
<span style="color: #351c75; font-family: Courier New, Courier, monospace;"><b> </b></span><br />
<span style="color: #351c75; font-family: Courier New, Courier, monospace;"><b> int len4;</b></span><br />
<span style="color: #351c75; font-family: Courier New, Courier, monospace;"><b> while ((len4 = in4.read(buffer))>0) {</b></span><br />
<span style="color: #351c75; font-family: Courier New, Courier, monospace;"><b> zos.write(buffer, 0, len4);</b></span><br />
<span style="color: #351c75; font-family: Courier New, Courier, monospace;"><b> }</b></span><br />
<span style="color: #351c75; font-family: Courier New, Courier, monospace;"><b> </b></span><br />
<span style="color: #351c75; font-family: Courier New, Courier, monospace;"><b> in4.close();</b></span><br />
<span style="color: #351c75; font-family: Courier New, Courier, monospace;"><b> </b></span><br />
<span style="color: #351c75; font-family: Courier New, Courier, monospace;"><b> zos.closeEntry();</b></span><br />
<br />
<span style="color: #351c75; font-family: Courier New, Courier, monospace;"><b> zos.close();</b></span><br />
<br />
<span style="color: #351c75; font-family: Courier New, Courier, monospace;"><b> System.out.println("Done");</b></span><br />
<br />
<span style="color: #351c75; font-family: Courier New, Courier, monospace;"><b> }catch(IOException ex){</b></span><br />
<span style="color: #351c75; font-family: Courier New, Courier, monospace;"><b> ex.printStackTrace();</b></span><br />
<span style="color: #351c75; font-family: Courier New, Courier, monospace;"><b> }</b></span><br />
<span style="color: #351c75; font-family: Courier New, Courier, monospace;"><b> }</b></span><br />
<span style="color: #351c75; font-family: Courier New, Courier, monospace;"><b>}</b></span></div><br />
<br />
<script type="text/javascript">
google_ad_client = "ca-pub-8470945096737641";
/* 160x600, created 6/23/09 */
google_ad_slot = "3027217057";
google_ad_width = 160;
google_ad_height =200 ;
//
</script><br />
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script><br />
MANOJ KUMARhttp://www.blogger.com/profile/00421517842858762886noreply@blogger.com0tag:blogger.com,1999:blog-3445872732437342114.post-57033707864761177762013-12-04T02:55:00.001-08:002013-12-04T02:55:15.841-08:00Iterator Design Pattern<div dir="ltr" style="text-align: left;" trbidi="on"><span style="color: purple;"><b>Iterator design pattern in java </b><br />
<br />
Lets write an class that has method <u>next() and hasNext() </u>which basically are backbone for iterator design pattern <br />
<br />
This Iterator will be iterating over a collection represented by <u>Collection </u>class<br />
<br />
Collection class consist of an array of elements that Iterator will be iterating over. <br />
<br />
Additionally methods<u> to add and remove elements from array</u> are also available in Collection class<br />
<br />
IteratorTestor class consist of all the scenarios where in <br />
</span><br />
<br />
<script type="text/javascript">
google_ad_client = "ca-pub-8470945096737641";
/* 160x600, created 6/23/09 */
google_ad_slot = "3027217057";
google_ad_width = 160;
google_ad_height =200 ;
//
</script><br />
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script><br />
<ol><li><span style="color: purple;">First we are iterating over existing list of elements </span></li>
<li><span style="color: purple;">Then few elements are added to the array and It is again iterated over </span></li>
<li><span style="color: purple;">Then few elements are removed from the array and then It is again iterated over </span></li>
</ol><span style="color: purple;"><br />
<b>Here is the Well compiled code to try this via java code</b><br />
<br />
-=========================================================<br />
<br />
<br />
<span style="color: blue;"><span style="font-family: "Courier New",Courier,monospace;"><b>public interface Iterator {</b><br />
<br />
public Object next();<br />
public boolean hasNext();<br />
<br />
}</span></span><br />
<br />
=========================================================<br />
<br />
<span style="color: blue;"><span style="font-family: "Courier New",Courier,monospace;"><br />
<b>public interface Container {</b><br />
<br />
public Iterator getIterator();<br />
<br />
}</span></span><br />
=======================================================<br />
<br />
<u>This class consist of an inner class <b>MyIterator </b>which basically becomes the part of collection class and <br />
thus it becomes easy for MyIterator class to work on variables of enclosing class. </u><br />
<br />
<span style="color: blue;"><span style="font-family: "Courier New",Courier,monospace;">import java.lang.reflect.Array;<br />
<br />
<b>public class Collection implements Container {</b><br />
<br />
public <br />
String[] list = {"element1", "element2", "element3", "element4" };<br />
<br />
public int index;<br />
<br />
@Override<br />
public Iterator getIterator() {<br />
// TODO Auto-generated method stub<br />
return new MyIterator();<br />
}<br />
<br />
public void addElement(Object obj){<br />
int arrLength=list.length;<br />
arrLength++;<br />
String[] newArr =new String[arrLength];<br />
newArr[arrLength-1]=obj.toString();<br />
System.arraycopy(list, 0, newArr, 0, list.length);<br />
list=new String[newArr.length];<br />
System.arraycopy(newArr, 0, list, 0, newArr.length);<br />
<br />
<br />
}<br />
<br />
public void removeElement(Object obj){<br />
int arrLength=list.length;<br />
arrLength--;<br />
String[] newArr =new String[arrLength];<br />
System.arraycopy(list, 0, newArr, 0, list.length-1);<br />
list=new String[newArr.length];<br />
System.arraycopy(newArr, 0, list, 0, newArr.length);<br />
<br />
<br />
}<br />
<br />
<br />
<b> private class MyIterator implements Iterator {</b><br />
<br />
@Override<br />
public Object next() {<br />
// TODO Auto-generated method stub<br />
if (hasNext()) {<br />
return list[index++];<br />
}<br />
return null;<br />
}<br />
<br />
@Override<br />
public boolean hasNext() {<br />
// TODO Auto-generated method stub<br />
if (list.length > index) {<br />
return true;<br />
}<br />
return false;<br />
}<br />
<br />
}<br />
<br />
}</span></span><br />
============================================================<br />
<br />
<br />
<br />
<script type="text/javascript">
google_ad_client = "ca-pub-8470945096737641";
/* 200x200, created 6/23/09 */
google_ad_slot = "8930436823";
google_ad_width = 200;
google_ad_height = 200;
</script><br />
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script><br />
<br />
<br />
<br />
<span style="font-family: "Courier New",Courier,monospace;"><span style="color: blue;"><b>public class IteratorTester {</b><br />
<br />
/**<br />
* @param args<br />
*/<br />
public static void main(String[] args) {<br />
Collection repo = new Collection();<br />
<br />
while (repo.getIterator().hasNext()) {<br />
System.out.println(repo.getIterator().next());<br />
}<br />
<br />
<b> System.out.println("=================Lets Add Few More Elements========================");</b><br />
<br />
repo.index=0;<br />
repo.addElement("NewElemen1");<br />
repo.addElement("NewElemen2");<br />
repo.addElement("NewElemen3");<br />
while (repo.getIterator().hasNext()) {<br />
System.out.println(repo.getIterator().next());<br />
<br />
}<br />
<b> System.out.println("===============Lets Remove few elements==========================");</b><br />
<br />
repo.index=0;<br />
repo.removeElement("Elemen1");<br />
repo.removeElement("Elemen2");<br />
while (repo.getIterator().hasNext()) {<br />
System.out.println(repo.getIterator().next());<br />
<br />
}<br />
<br />
<br />
}<br />
}<br />
</span></span>===================================================<br />
<br />
<br />
<br />
<script type="text/javascript">
google_ad_client = "ca-pub-8470945096737641";
/* seo banner */
google_ad_slot = "3657212241";
google_ad_width = 468;
google_ad_height = 300;
//-->
</script><br />
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script><br />
<br />
<b>And this program will print below logs on console :</b><br />
<br />
<br />
++++++++++++++++++++++++++++++++++++++++</span><br />
<span style="color: purple;">element1<br />
element2<br />
element3<br />
element4<br />
=================Lets Add Few More Elements========================<br />
element1<br />
element2<br />
element3<br />
element4<br />
NewElemen1<br />
NewElemen2<br />
NewElemen3<br />
===============Lets Remove few elements==========================<br />
element1<br />
element2<br />
element3<br />
element4<br />
NewElemen1</span><br />
<span style="color: purple;"><b>+++++++++++++++++++++++++++++++++++++++</b></span></div>MANOJ KUMARhttp://www.blogger.com/profile/00421517842858762886noreply@blogger.com0tag:blogger.com,1999:blog-3445872732437342114.post-60080964166534381562013-12-02T03:14:00.000-08:002013-12-02T03:14:35.916-08:00Coding Practice to avoid error while using Object references <div dir="ltr" style="text-align: left;" trbidi="on">
<br />
<script type="text/javascript">
google_ad_client = "ca-pub-8470945096737641";
/* 160x600, created 6/23/09 */
google_ad_slot = "3027217057";
google_ad_width = 160;
google_ad_height =200 ;
//
</script><br />
<script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript">
</script><br />
<br />
<br />
<div dir="ltr" style="text-align: left;" trbidi="on">
Let's understand this by example <br />
<br />
<span style="color: blue;"><span style="font-family: "Courier New",Courier,monospace;"><br />
import java.util.Date;<br />
<br />
import java.util.Date;<br />
<br />
public class Refree {<br />
<br />
public static void main(String args[]) {<br />
<br />
Date date = new Date();<br />
Dater coach = new Dater(date);<br />
System.out.println(coach.date);<br />
date.setYear(1111);<br />
System.out.println(coach.date);<br />
<br />
}<br />
<br />
}<br />
<br />
class Dater {<br />
public Date date;<br />
<br />
Dater(Date date) {<br />
this.date = date;<br />
}<br />
}</span></span><br />
<br />
<br />
<br />
<script type="text/javascript">
google_ad_client = "ca-pub-8470945096737641";
/* 200x200, created 6/23/09 */
google_ad_slot = "8930436823";
google_ad_width = 200;
google_ad_height = 200;
</script><br />
<script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript">
</script><br />
<br />
<br />
This program will print<br />
<b><br />
Mon Dec 02 16:33:48 IST 2013<br />
Mon Dec 02 16:33:48 IST 3011</b><br />
<br />
<u>But in line date.setYear(1111); we only want to change the value of date and not coach instance But this code is changing values of date as well as coach. </u><br />
<br />
So how can we avoid that : <br />
<br />
Let's see another version of same program <br />
<br />
<span style="color: blue;"><br />
<span style="font-family: "Courier New",Courier,monospace;">import java.util.Date;<br />
<br />
public class Refree {<br />
<br />
public static void main(String args[]) {<br />
<br />
Date date = new Date();<br />
Dater coach = new Dater(date);<br />
System.out.println(coach.date);<br />
date.setYear(1111);<br />
System.out.println(coach.date);<br />
<br />
}<br />
<br />
}<br />
<br />
class Dater {<br />
public Date date;<br />
<br />
Dater(Date date) {<br />
this.date = new Date(date.getTime());<br />
}<br />
}</span></span><br />
<br />
<br />
<br />
<script type="text/javascript">
google_ad_client = "ca-pub-8470945096737641";
/* seo banner */
google_ad_slot = "3657212241";
google_ad_width = 468;
google_ad_height = 300;
//</script>
</div>
</div>
--><br /><script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript">
</script><br />
This program will print<br />
<br />
<b>Mon Dec 02 16:36:36 IST 2013<br />
Mon Dec 02 16:36:36 IST 2013</b><br />
<br />
<br />
<u><b>So that's what we wanted..</b></u>MANOJ KUMARhttp://www.blogger.com/profile/00421517842858762886noreply@blogger.com0tag:blogger.com,1999:blog-3445872732437342114.post-39640336729634825222013-12-02T02:11:00.001-08:002013-12-02T02:11:31.191-08:00Command Design Pattern<div dir="ltr" style="text-align: left;" trbidi="on">
Consider yourself a referee of a race where you need to give below commands to athletes<br />
<br />
<b>Ready -- </b>Athlete to get ready for race<b><br />
Set --- </b>Athletes to all set to run<b><br />
Go --- </b>Athletes to run the race<br />
<br />
<b>How can we automate this in java using command design pattern .</b><br />
<br />
<script type="text/javascript">
google_ad_client = "ca-pub-8470945096737641";
/* 160x600, created 6/23/09 */
google_ad_slot = "3027217057";
google_ad_width = 160;
google_ad_height =200 ;
//
</script><br />
<script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript">
</script><br />
<br />
<br />
Lets consider there is a Race class which defines there action <br />
<br />
<br />
<span style="color: blue;"><span style="font-family: "Courier New",Courier,monospace;">public class Race {<br />
<br />
public void getReady() {<br />
<br />
System.out.println("getting ready");<br />
}<br />
<br />
public void set() {<br />
System.out.println("setting running position");<br />
<br />
}<br />
<br />
public void go() {<br />
System.out.println("running");<br />
<br />
}<br />
}</span></span><br />
<br />
<br />
Now we need to create there command classes for these three actions <br />
<br />
Let's create an interface first which <u>basically will be uniformly implemented by all there command classes</u><br />
<br />
Interface name is <b>Position</b>. It is declaring single method <b>execute</b>()<br />
<br />
<br />
<span style="color: blue;"><span style="font-family: "Courier New",Courier,monospace;">public interface Position {<br />
<br />
public void execute();<br />
}</span></span><br />
<br />
<script type="text/javascript">
google_ad_client = "ca-pub-8470945096737641";
/* 200x200, created 6/23/09 */
google_ad_slot = "8930436823";
google_ad_width = 200;
google_ad_height = 200;
</script><br />
<script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript">
</script><br />
<br />
<br />
<br />
Next there command classes<br />
<br />
<b>Ready , Set and Go</b><br />
<br />
<br />
<span style="color: blue;"><span style="font-family: "Courier New",Courier,monospace;"><b>public class Ready implements Position {</b><br />
<br />
Race race; <br />
public Ready(Race race){<br />
this.race=race;<br />
}<br />
@Override<br />
public void execute() {<br />
<br />
race.getReady();<br />
<br />
}<br />
}<br />
<br />
<br />
<br />
<b>public class Set implements Position {</b><br />
<br />
Race race; <br />
public Set(Race race){<br />
this.race=race;<br />
}<br />
<br />
@Override<br />
public void execute() {<br />
race.set();<br />
}<br />
<br />
}<br />
<br />
<br />
<b>public class Go implements Position {</b><br />
<br />
Race race; <br />
public Go(Race race){<br />
this.race=race;<br />
}<br />
<br />
@Override<br />
public void execute() {<br />
race.go();<br />
<br />
}<br />
<br />
}</span></span><br />
<br />
<br />
<script type="text/javascript">
google_ad_client = "ca-pub-8470945096737641";
/* seo banner */
google_ad_slot = "3657212241";
google_ad_width = 468;
google_ad_height = 300;
//</script>
</div>
--><br /><script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript">
</script><br />
<br />
Every command class has one argument constructor which allows Command instances set Race class instance to execute the method on Race class.<br />
<br />
Now it is duty of Referee to pass instance of Race class to Commands and Commands will execute() the method invoked inside execute() method.<br />
<br />
<b>Here is Referee class</b><br />
<br />
<br />
<span style="color: blue;"><span style="font-family: "Courier New",Courier,monospace;"><b>public class Referee {</b><br />
<br />
public static void main(String args[]){<br />
Race race=new Race();<br />
<br />
Position position1=new Ready(race);<br />
Position position2=new Set(race);<br />
Position position3=new Go(race);<br />
<br />
position1.execute();<br />
position2.execute();<br />
position3.execute();<br />
<br />
<br />
}<br />
<br />
}</span></span><br />
<u><br />
Put together all these classes and execute program as java application. That will print below logs on console :</u><br />
<br />
<span style="color: purple;"><br />
getting ready<br />
setting running position<br />
running</span><br />
<br />
<br />MANOJ KUMARhttp://www.blogger.com/profile/00421517842858762886noreply@blogger.com0tag:blogger.com,1999:blog-3445872732437342114.post-90760544698291413822013-12-01T21:58:00.000-08:002013-12-01T21:58:06.191-08:00Memento Design Pattern <div dir="ltr" style="text-align: left;" trbidi="on">
<span style="font-size: small;"><span style="font-family: Times,"Times New Roman",serif;"><span style="color: #741b47;">This pattern talks about restoring the original state at any point of time . For example <br />
<br />
I start with knowing the mileage of bike <b>around reference value 80KM/h</b><br />
<br />
I store this value in an string instance say : <b>mileage </b><br />
<br />
My <b>reference value / Origina</b>l value is 80KM/h<br />
<br />
Now I start knowing mileage of various bikes and keep updating the the latest known mileage in same <b>string instace : mileage</b><br />
<br />
current value might change from 80 to 70 to 50 to 40 to 100 and so on depending upon the mileage of bikes.<br />
<br />
So at any point of time If i want to know the reference value <u>, It's no more there is mileage string.</u> <br />
<br />
So how do I make sure that <u>I keep on working on current value as well as be able to retrieve the original value at any point of time. </u><br />
<br />
There might be many ways you ca think across , Memento design pattern suggest a standard way to do that. <br />
<br />
<b>Pattern revolves around two contributors </b><br />
<br />
Originator <br />
Care Taker <br />
<br />
<b>Originator </b>stores the original value in a non-modified way.<br />
<b>Care Taker</b> takes care of returing current or original value at any point of time<br />
Client directly interacts with Care taker to get current or original value <br />
<br />
<br />
Now lets see how simple is it to implement it in java : <br />
<br />
<br />
<b>Originator class stores the original value and it can't be modified .</b><br />
<br />
<script type="text/javascript">
google_ad_client = "ca-pub-8470945096737641";
/* 160x600, created 6/23/09 */
google_ad_slot = "3027217057";
google_ad_width = 160;
google_ad_height =200 ;
//
</script><br />
<script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript">
</script><br />
<br />
<br />
<br />
<br />
<span style="font-family: "Courier New",Courier,monospace;">public class Originator {<br />
<br />
private final String mileage ="80";<br />
<br />
public String getFinalInstance(){<br />
return mileage;<br />
}<br />
<br />
}</span><b>CareTaker provides method to get to current or original mileage at any point of time</b><br />
<br />
<br />
<span style="font-family: "Courier New",Courier,monospace;">public class CareTaker {<br />
<br />
private String mileage;<br />
public CareTaker(String instance) {<br />
this.mileage=instance;<br />
}<br />
<br />
public String saveCurrentInstance(String instance){<br />
this.mileage=instance;<br />
return this.mileage;<br />
}<br />
<br />
public String restoreDefaultInstance(){<br />
Originator finalInstance=new Originator(); <br />
return finalInstance.getFinalInstance();<br />
}<br />
public String getCurrentValue(){<br />
return mileage;<br />
}<br />
}</span><br />
<br />
<br />
<script type="text/javascript">
google_ad_client = "ca-pub-8470945096737641";
/* seo banner */
google_ad_slot = "3657212241";
google_ad_width = 468;
google_ad_height = 300;
//</script>
</span></span></span></div>
--><br />
<script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript">
</script><br />
<br />
<b>And here is our Client who interacts with CareTaker to play with current value and reach original value at any point of time.</b><br />
<br />
<br />
<span style="font-family: "Courier New",Courier,monospace;">public class MementoClient {<br />
<br />
public MementoClient() {<br />
// TODO Auto-generated constructor stub<br />
}<br />
<br />
public static void main(String args[]){<br />
<br />
System.out.println("Some original reference value is already set .......");<br />
CareTaker instance =new CareTaker("50");<br />
System.out.println("Let us create an instance with current value ::: 50");<br />
System.out.println("Lets find out the original reference value ");<br />
System.out.println("it is :::" + instance.restoreDefaultInstance());<br />
System.out.println("and the current value is :: ");<br />
System.out.println(instance.getCurrentValue());<br />
System.out.println("Lets change the value to 40");<br />
instance.saveCurrentInstance("40");<br />
System.out.println("Now current value is ::: " + instance.getCurrentValue());<br />
System.out.println("Let's again change the value to :::100");<br />
instance.saveCurrentInstance("100");<br />
System.out.println("Now current value is : " + instance.getCurrentValue());<br />
System.out.println("Now I want to get to the original value");<br />
System.out.println("it is ::: " + instance.restoreDefaultInstance());</span><span style="font-size: small;"><span style="font-family: Times,"Times New Roman",serif;"><span style="color: #741b47;"><span style="font-family: "Courier New",Courier,monospace;"><br />
}<br />
<br />
}</span></span></span></span><br />
<br />
<script type="text/javascript">
google_ad_client = "ca-pub-8470945096737641";
/* 200x200, created 6/23/09 */
google_ad_slot = "8930436823";
google_ad_width = 200;
google_ad_height = 200;
</script><br />
<script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript">
</script><br />
<br />
<br />
<br />
<span style="font-family: Arial,Helvetica,sans-serif;"><b><span style="font-size: small;"><span style="color: #741b47;">Executing this application as java application will print below logs on console :</span></span></b></span><br />
<br />
<span style="font-family: Arial,Helvetica,sans-serif;"><b><span style="font-size: small;"><span style="color: #741b47;">===============================</span></span></b></span><br />
<span style="font-family: Arial,Helvetica,sans-serif;"><span style="font-size: small;"><span style="color: #741b47;">Some original reference value is already set .......<br />
Let us create an instance with current value ::: 50<br />
Lets find out the original reference value <br />
it is :::80<br />
and the current value is :: <br />
50<br />
Lets change the value to 40<br />
Now current value is ::: 40<br />
Let's again change the value to :::100<br />
Now current value is : 100<br />
Now I want to get to the original value<br />
it is ::: 80</span></span><b><span style="font-size: small;"><span style="color: #741b47;"><br />
================================ </span></span></b></span><br />
<br />
<span style="font-size: small;"><span style="font-family: Times,"Times New Roman",serif;"><span style="color: #741b47;"><span style="font-family: "Courier New",Courier,monospace;"> </span><br />
</span></span></span>MANOJ KUMARhttp://www.blogger.com/profile/00421517842858762886noreply@blogger.com0tag:blogger.com,1999:blog-3445872732437342114.post-62531922395599779042013-11-29T05:31:00.001-08:002013-11-29T05:33:58.333-08:00Observer design pattern in java <div dir="ltr" style="text-align: left;" trbidi="on">
<span style="color: #4c1130; font-family: Times, Times New Roman, serif;">Lets talk about observer design pattern today--</span><br />
<span style="color: #4c1130; font-family: Times, Times New Roman, serif;"><br />
</span> <span style="color: #4c1130; font-family: Times, Times New Roman, serif;">Lets take in consideration a real time scenarion </span><br />
<span style="color: #4c1130; font-family: Times, Times New Roman, serif;"><br />
</span> <span style="color: #4c1130; font-family: Times, Times New Roman, serif;"><u>There is a News Control Center that controls current news and subscribers . </u></span><br />
<span style="color: #4c1130; font-family: Times, Times New Roman, serif;"><br />
</span> <span style="color: #4c1130; font-family: Times, Times New Roman, serif;">Lets say there are two subscribers <b>Ching and Chong</b></span><br />
<span style="color: #4c1130; font-family: Times, Times New Roman, serif;"><br />
</span> <span style="color: #4c1130; font-family: Times, Times New Roman, serif;">Ching and Chong are registered by News Control center for current news </span><br />
<span style="color: #4c1130; font-family: Times, Times New Roman, serif;"><br />
</span> <span style="color: #4c1130; font-family: Times, Times New Roman, serif;">If at any point of time current news are updated News needs to be informed to its all subscribers. </span><br />
<span style="color: #4c1130; font-family: Times, Times New Roman, serif;"><br />
</span> <span style="color: #4c1130; font-family: Times, Times New Roman, serif;">Subscriber will not keep on checking news all the time If any current news is updated. They will register once for all and News</span><br />
<span style="color: #4c1130; font-family: Times, Times New Roman, serif;"><br />
</span> <span style="color: #4c1130; font-family: Times, Times New Roman, serif;">will ensure that they are timely informed about every new news. So how will that hapend</span><br />
<br />
<script type="text/javascript">
google_ad_client = "ca-pub-8470945096737641";
/* 160x600, created 6/23/09 */
google_ad_slot = "3027217057";
google_ad_width = 160;
google_ad_height =200 ;
//
</script><br />
<script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript">
</script><br />
<br />
<span style="color: #4c1130; font-family: Times, Times New Roman, serif;"><br />
</span> <span style="color: #4c1130; font-family: Times, Times New Roman, serif;"><b>Ching and Chong will act as observers / listener . News will see If any new news is updated it is informed to its subscribers </b></span><br />
<span style="color: #4c1130; font-family: Times, Times New Roman, serif;"><br />
</span> <span style="color: #4c1130; font-family: Times, Times New Roman, serif;"><br />
</span> <span style="color: #4c1130; font-family: Times, Times New Roman, serif;"><u>Below Code details this and implement the scenario in java code .</u></span><br />
<span style="color: #4c1130; font-family: Times, Times New Roman, serif;"><br />
</span> <span style="color: #4c1130; font-family: Times, Times New Roman, serif;">NewsControlCenter Class will hold the main control to apply for subscriber registeration and bring in new news to the agency</span><br />
<span style="color: #4c1130; font-family: Times, Times New Roman, serif;"><br />
</span> <span style="color: #4c1130; font-family: Times, Times New Roman, serif;"><br />
</span> <span style="color: #4c1130; font-family: Times, Times New Roman, serif;">==================</span><br />
<span style="color: #4c1130; font-family: Times, Times New Roman, serif;"><br />
</span> <span style="color: #4c1130; font-family: Times, Times New Roman, serif;"><br />
</span> <span style="color: #4c1130; font-family: Times, Times New Roman, serif;"><b><br />
</b></span> <span style="color: #4c1130; font-family: Courier New, Courier, monospace;"><b>public class NewsControlCenter {</b></span><br />
<span style="color: #4c1130; font-family: Courier New, Courier, monospace;"><br />
</span> <span style="color: #4c1130; font-family: Courier New, Courier, monospace;"> /**</span><br />
<span style="color: #4c1130; font-family: Courier New, Courier, monospace;"> * @param args</span><br />
<span style="color: #4c1130; font-family: Courier New, Courier, monospace;"> */</span><br />
<span style="color: #4c1130; font-family: Courier New, Courier, monospace;"> public static void <b>main</b>(String[] args) {</span><br />
<span style="color: #4c1130; font-family: Courier New, Courier, monospace;"><br />
</span> <span style="color: #4c1130; font-family: Courier New, Courier, monospace;"> Subscriber sub1=new Subscriber("ching");</span><br />
<span style="color: #4c1130; font-family: Courier New, Courier, monospace;"> Subscriber sub2=new Subscriber("chong");</span><br />
<span style="color: #4c1130; font-family: Courier New, Courier, monospace;"> News news=new TimesNews();</span><br />
<span style="color: #4c1130; font-family: Courier New, Courier, monospace;"> news.registerSubscriber(sub1);</span><br />
<span style="color: #4c1130; font-family: Courier New, Courier, monospace;"> news.registerSubscriber(sub2);</span><br />
<span style="color: #4c1130; font-family: Courier New, Courier, monospace;"> </span><br />
<span style="color: #4c1130; font-family: Courier New, Courier, monospace;"> </span><span style="color: #4c1130; font-family: 'Courier New', Courier, monospace;"> System.out.println("==========news changed======");</span><br />
<span style="color: #4c1130; font-family: Courier New, Courier, monospace;"><br />
</span> <span style="color: #4c1130; font-family: Courier New, Courier, monospace;"> news.updateNews("Narayan traced");</span><br />
<span style="color: #4c1130; font-family: Courier New, Courier, monospace;"> </span><br />
<span style="color: #4c1130; font-family: Courier New, Courier, monospace;"> System.out.println("==========news changed again ======");</span><br />
<span style="color: #4c1130; font-family: Courier New, Courier, monospace;"><br />
</span> <span style="color: #4c1130; font-family: Courier New, Courier, monospace;"> news.updateNews("Govt declared prize money on informing Narayan's whereabout.");</span><br />
<span style="color: #4c1130; font-family: Courier New, Courier, monospace;"><br />
</span> <span style="color: #4c1130; font-family: Courier New, Courier, monospace;"> </span><br />
<span style="color: #4c1130; font-family: Courier New, Courier, monospace;"> </span><br />
<span style="color: #4c1130; font-family: Courier New, Courier, monospace;"> }</span><br />
<span style="color: #4c1130; font-family: Courier New, Courier, monospace;"><br />
</span> <span style="color: #4c1130; font-family: Courier New, Courier, monospace;">}</span><br />
<div>
<span style="font-family: Courier New, Courier, monospace;"><br />
</span></div>
<span style="color: #4c1130; font-family: Courier New, Courier, monospace;">==================</span><br />
<span style="color: #4c1130; font-family: Courier New, Courier, monospace;"><br />
</span> <span style="color: #4c1130; font-family: Courier New, Courier, monospace;"><br />
</span> <span style="color: #4c1130; font-family: Courier New, Courier, monospace;">import java.util.List;</span><br />
<span style="color: #4c1130; font-family: Courier New, Courier, monospace;"><br />
</span> <span style="color: #4c1130; font-family: Courier New, Courier, monospace;"><b>public interface News {</b></span><br />
<span style="color: #4c1130; font-family: Courier New, Courier, monospace;"> void registerSubscriber(Subscriber sub);</span><br />
<span style="color: #4c1130; font-family: Courier New, Courier, monospace;"><br />
</span> <span style="color: #4c1130; font-family: Courier New, Courier, monospace;"> void unRegisterSubscriber(Subscriber sub);</span><br />
<span style="color: #4c1130; font-family: Courier New, Courier, monospace;"><br />
</span> <span style="color: #4c1130; font-family: Courier New, Courier, monospace;"> void updateNews(String news);</span><br />
<span style="color: #4c1130; font-family: Courier New, Courier, monospace;"> void inform(Subscriber sub);</span><br />
<span style="color: #4c1130; font-family: Courier New, Courier, monospace;"> void inform(List<subscriber> subs);</subscriber></span><br />
<span style="color: #4c1130; font-family: Courier New, Courier, monospace;"> void readCurrentNews();</span><br />
<span style="color: #4c1130; font-family: Courier New, Courier, monospace;">}</span><br />
<span style="color: #4c1130; font-family: Courier New, Courier, monospace;"><br />
</span> <span style="color: #4c1130; font-family: Courier New, Courier, monospace;"><br />
</span> <span style="color: #4c1130; font-family: Courier New, Courier, monospace;">==================</span><br />
<br />
<br />
<br />
<script type="text/javascript">
google_ad_client = "ca-pub-8470945096737641";
/* 200x200, created 6/23/09 */
google_ad_slot = "8930436823";
google_ad_width = 200;
google_ad_height = 200;
</script><br />
<script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript">
</script><br />
<br />
<br />
<span style="color: #4c1130; font-family: Courier New, Courier, monospace;"><br />
</span> <span style="color: #4c1130; font-family: Courier New, Courier, monospace;">import java.util.ArrayList;</span><br />
<span style="color: #4c1130; font-family: Courier New, Courier, monospace;">import java.util.Iterator;</span><br />
<span style="color: #4c1130; font-family: Courier New, Courier, monospace;">import java.util.List;</span><br />
<span style="color: #4c1130; font-family: Courier New, Courier, monospace;"><br />
</span> <span style="color: #4c1130; font-family: Courier New, Courier, monospace;"><b>public class TimesNews implements News {</b></span><br />
<span style="color: #4c1130; font-family: Courier New, Courier, monospace;"><br />
</span> <span style="color: #4c1130; font-family: Courier New, Courier, monospace;"> String currentNews = "Asharam in Jail";</span><br />
<span style="color: #4c1130; font-family: Courier New, Courier, monospace;"><br />
</span> <span style="color: blue; font-family: Courier New, Courier, monospace;"> List<subscriber> subscribers = new ArrayList<subscriber>();</subscriber></subscriber></span><br />
<span style="color: #4c1130; font-family: Courier New, Courier, monospace;"><br />
</span> <span style="color: #4c1130; font-family: Courier New, Courier, monospace;"> @Override</span><br />
<span style="color: #4c1130; font-family: Courier New, Courier, monospace;"> public void <b>registerSubscriber</b>(Subscriber sub) {</span><br />
<span style="color: #4c1130; font-family: Courier New, Courier, monospace;"> subscribers.add(sub);</span><br />
<span style="color: #4c1130; font-family: Courier New, Courier, monospace;"> }</span><br />
<span style="color: #4c1130; font-family: Courier New, Courier, monospace;"><br />
</span> <span style="color: #4c1130; font-family: Courier New, Courier, monospace;"> @Override</span><br />
<span style="color: #4c1130; font-family: Courier New, Courier, monospace;"> public void <b>unRegisterSubscriber</b>(Subscriber sub) {</span><br />
<span style="color: #4c1130; font-family: Courier New, Courier, monospace;"> subscribers.remove(sub);</span><br />
<span style="color: #4c1130; font-family: Courier New, Courier, monospace;"> }</span><br />
<span style="color: #4c1130; font-family: Courier New, Courier, monospace;"><br />
</span> <span style="color: #4c1130; font-family: Courier New, Courier, monospace;"> @Override</span><br />
<span style="color: #4c1130; font-family: Courier New, Courier, monospace;"> public void <b>updateNews</b>(String news) {</span><br />
<span style="color: #4c1130; font-family: Courier New, Courier, monospace;"><br />
</span> <span style="color: #4c1130; font-family: Courier New, Courier, monospace;"> this.currentNews = news;</span><br />
<span style="color: #4c1130; font-family: Courier New, Courier, monospace;"> inform(subscribers);</span><br />
<span style="color: #4c1130; font-family: Courier New, Courier, monospace;"><br />
</span> <span style="color: #4c1130; font-family: Courier New, Courier, monospace;"> }</span><br />
<span style="color: #4c1130; font-family: Courier New, Courier, monospace;"><br />
</span> <span style="color: #4c1130; font-family: Courier New, Courier, monospace;"> public void <b>inform</b>(Subscriber sub) {</span><br />
<span style="color: #4c1130; font-family: Courier New, Courier, monospace;"><br />
</span> <span style="color: #4c1130; font-family: Courier New, Courier, monospace;"> }</span><br />
<span style="color: #4c1130; font-family: Courier New, Courier, monospace;"><br />
</span> <span style="color: #4c1130; font-family: Courier New, Courier, monospace;"> public void <b>inform</b>(List<subscriber> subs) {</subscriber></span><br />
<span style="color: #4c1130; font-family: Courier New, Courier, monospace;"><br />
</span> <span style="color: #4c1130; font-family: Courier New, Courier, monospace;"> for (Iterator iterator = subs.iterator(); iterator.hasNext();) {</span><br />
<span style="color: #4c1130; font-family: Courier New, Courier, monospace;"> Subscriber subscriber = (Subscriber) iterator.next();</span><br />
<span style="color: #4c1130; font-family: Courier New, Courier, monospace;"> inform(subscriber);</span><br />
<span style="color: #4c1130; font-family: Courier New, Courier, monospace;"> }</span><br />
<span style="color: #4c1130; font-family: Courier New, Courier, monospace;"><br />
</span> <span style="color: #4c1130; font-family: Courier New, Courier, monospace;"> }</span><br />
<span style="color: #4c1130; font-family: Courier New, Courier, monospace;"><br />
</span> <span style="color: #4c1130; font-family: Courier New, Courier, monospace;"> public void <b>readCurrentNews</b>() {</span><br />
<span style="color: #4c1130; font-family: Courier New, Courier, monospace;"> System.out.println(this.currentNews);</span><br />
<span style="color: #4c1130; font-family: Courier New, Courier, monospace;"> }</span><br />
<span style="color: #4c1130; font-family: Courier New, Courier, monospace;"><br />
</span> <span style="color: #4c1130; font-family: Courier New, Courier, monospace;">}</span><br />
<span style="color: #4c1130; font-family: Courier New, Courier, monospace;"><br />
</span> <span style="color: #4c1130; font-family: Courier New, Courier, monospace;"><br />
</span> <span style="color: #4c1130; font-family: Courier New, Courier, monospace;">=====================</span><br />
<br />
<br />
<script type="text/javascript">
google_ad_client = "ca-pub-8470945096737641";
/* seo banner */
google_ad_slot = "3657212241";
google_ad_width = 468;
google_ad_height = 300;
//</script>
</div>
--><br /><script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript">
</script><br />
<span style="color: #4c1130; font-family: Courier New, Courier, monospace;"><br />
</span> <span style="color: #4c1130; font-family: Courier New, Courier, monospace;"><b>public class Subscriber {</b></span><br />
<span style="color: #4c1130; font-family: Courier New, Courier, monospace;"><br />
</span> <span style="color: #4c1130; font-family: Courier New, Courier, monospace;"> String name;</span><br />
<span style="color: #4c1130; font-family: Courier New, Courier, monospace;"><br />
</span> <span style="color: #4c1130; font-family: Courier New, Courier, monospace;"> public <b>Subscriber</b>(String name) {</span><br />
<span style="color: #4c1130; font-family: Courier New, Courier, monospace;"> this.name = name;</span><br />
<span style="color: #4c1130; font-family: Courier New, Courier, monospace;"> }</span><br />
<span style="color: #4c1130; font-family: Courier New, Courier, monospace;"><br />
</span> <span style="color: #4c1130; font-family: Courier New, Courier, monospace;"> public void <b>readNews</b>(News news) {</span><br />
<span style="color: #4c1130; font-family: Courier New, Courier, monospace;"><br />
</span> <span style="color: #4c1130; font-family: Courier New, Courier, monospace;"> System.out.println("Mr. " +name+ ": got this news:::");</span><br />
<span style="color: #4c1130; font-family: Courier New, Courier, monospace;"> news.readCurrentNews();</span><br />
<span style="color: #4c1130; font-family: Courier New, Courier, monospace;">}</span><br />
<span style="color: #4c1130; font-family: Courier New, Courier, monospace;">}</span><br />
<span style="color: #4c1130; font-family: Courier New, Courier, monospace;"><br />
</span> <span style="color: #4c1130; font-family: Courier New, Courier, monospace;"><br />
</span> <span style="color: #4c1130; font-family: Courier New, Courier, monospace;">=================</span><br />
<span style="color: #4c1130; font-family: Courier New, Courier, monospace;"><br />
</span> <span style="color: #4c1130; font-family: Courier New, Courier, monospace;"><br /><br />On executing this program as java application . Below logs will be written on console</span><br />
<span style="color: #4c1130; font-family: Courier New, Courier, monospace;"><br /></span>
<span style="color: #4c1130; font-family: Courier New, Courier, monospace;">----------------------------------------------------------</span><br />
<span style="color: #4c1130; font-family: Courier New, Courier, monospace;"><br /></span>
<span style="color: #4c1130; font-family: Courier New, Courier, monospace;"><b>opening news for ::: ching</b></span><br />
<span style="color: #4c1130; font-family: Courier New, Courier, monospace;"><b>Asharam in Jail</b></span><br />
<span style="color: #4c1130; font-family: Courier New, Courier, monospace;"><b>opening news for ::: chong</b></span><br />
<span style="color: #4c1130; font-family: Courier New, Courier, monospace;"><b>Asharam in Jail</b></span><br />
<span style="color: #4c1130; font-family: Courier New, Courier, monospace;">==========news changed======</span><br />
<span style="color: #4c1130; font-family: Courier New, Courier, monospace;"><b>Mr. ching: got this news:::</b></span><br />
<span style="color: #4c1130; font-family: Courier New, Courier, monospace;"><b>Narayan traced</b></span><br />
<span style="color: #4c1130; font-family: Courier New, Courier, monospace;"><b>Mr. chong: got this news:::</b></span><br />
<span style="color: #4c1130; font-family: Courier New, Courier, monospace;"><b>Narayan traced</b></span><br />
<span style="color: #4c1130; font-family: Courier New, Courier, monospace;">==========news changed again ======</span><br />
<span style="color: #4c1130; font-family: Courier New, Courier, monospace;"><b>Mr. ching: got this news:::</b></span><br />
<span style="color: #4c1130; font-family: Courier New, Courier, monospace;"><b>Govt declared prize money on informing Narayan's whereabout.</b></span><br />
<span style="color: #4c1130; font-family: Courier New, Courier, monospace;"><b>Mr. chong: got this news:::</b></span><br />
<span style="color: #4c1130; font-family: Courier New, Courier, monospace;"><b>Govt declared prize money on informing Narayan's whereabout.</b></span><br />
<div>
<br /></div>
<div>
-------------------------------------------------------------------------------------</div>
<span style="color: #4c1130; font-family: Courier New, Courier, monospace;">
</span> <span style="color: #4c1130; font-family: Courier New, Courier, monospace;"><br />
</span> MANOJ KUMARhttp://www.blogger.com/profile/00421517842858762886noreply@blogger.com0tag:blogger.com,1999:blog-3445872732437342114.post-83949419364313699052013-11-20T05:06:00.000-08:002013-11-20T05:06:02.097-08:00Once again on visitor's design pattern<div dir="ltr" style="text-align: left;" trbidi="on">I have two employees in my organization : Manoj and Kumar<br />
<br />
I wish to have Manoj's employee data in text format and Kumar's employee data in HTML format<br />
<br />
What I would do to get it done :<br />
<br />
1. I will create Employee instance called Manoj<br />
2. I will ask Manoj to accept Textformatter as it's formatter<br />
3. Once Manoj accept it , it will ask it's Formatter to apply text formatter on it's data<br />
<br />
Code for this is as below :<br />
<br />
------------------------------------------<br />
<br />
package com;<br />
<br />
public class Employee {<br />
<br />
/**<br />
* @return the name<br />
*/<br />
public String getName() {<br />
return name;<br />
}<br />
<br />
/**<br />
* @param name<br />
* the name to set<br />
*/<br />
public void setName(String name) {<br />
this.name = name;<br />
}<br />
<br />
String name;<br />
<br />
public Employee() {<br />
// TODO Auto-generated constructor stub<br />
}<br />
<br />
public void accept(Formatter visitor) {<br />
<br />
visitor.visit(this);<br />
}<br />
<br />
}<br />
<div>--------------------------------------------</div><div><br />
<br />
<script type="text/javascript">
google_ad_client = "ca-pub-8470945096737641";
/* 160x600, created 6/23/09 */
google_ad_slot = "3027217057";
google_ad_width = 160;
google_ad_height =200 ;
//
</script><br />
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script><br />
<br />
<br />
<br />
</div><div><div>package com;</div><div><br />
</div><div>public interface Formatter {</div><div> </div><div> void visit(Employee emp);</div><div> </div><div> String getResult();</div><div>}</div></div><div><br />
</div><div>------------------------------------------</div><div><br />
</div><div><div>package com;</div><div><br />
</div><div><br />
</div><div>public class TextFormat implements Formatter {</div><div> </div><div> String formatting;</div><div><br />
</div><div> public TextFormat() {</div><div> // TODO Auto-generated constructor stub</div><div> }</div><div><br />
</div><div> @Override</div><div> public void visit(Employee emp) {</div><div> </div><div> formatting= "formatted the "+ emp.getName()+ " employee data in text format";</div><div> }</div><div><br />
</div><div> public String getResult(){</div><div> </div><div> return formatting;</div><div> }</div><div><br />
</div><div>}</div></div><div><br />
</div><div>--------------------------------------------</div><div><br />
<br />
<br />
<script type="text/javascript">
google_ad_client = "ca-pub-8470945096737641";
/* 200x200, created 6/23/09 */
google_ad_slot = "8930436823";
google_ad_width = 200;
google_ad_height = 200;
</script><br />
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script><br />
<br />
<br />
</div><div><br />
</div><div><div>package com;</div><div><br />
</div><div>public class Test {</div><div><br />
</div><div> public Test() {</div><div> // TODO Auto-generated constructor stub</div><div> }</div><div><br />
</div><div> /**</div><div> * @param args</div><div> */</div><div> public static void main(String[] args) {</div><div><br />
</div><div> Employee emp =new Employee();</div><div> </div><div> Formatter visitor =new TextFormat();</div><div> </div><div> emp.setName("Manoj");</div><div> emp.accept(visitor);</div><div> </div><div> System.out.println(visitor.getResult());</div><div> </div><div> </div><div> </div><div> }</div><div><br />
</div><div>}</div></div><div><br />
</div><div>----------------------------------------------</div><div><br />
</div><div><br />
</div><div><div>Similarly for Kumar to have it's data formatted in HTML format </div><div><br />
</div><div>1. I will create Employee instance called Kumar</div><div>2. I will ask Kumar to accept HTMLformatter as it's formatter</div><div>3. Once KUMAR accept it , it will ask it's Formatter to apply HTML formatter on it's data </div><div><br />
</div><div><br />
</div><div>Code for this is : </div></div><div><br />
</div><div><br />
</div><div><br />
</div><div>---------------------------------------</div><div><br />
<br />
<script type="text/javascript">
google_ad_client = "ca-pub-8470945096737641";
/* seo banner */
google_ad_slot = "3657212241";
google_ad_width = 468;
google_ad_height = 300;
//-->
</script><br />
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script><br />
<br />
<br />
</div><div><div>package com;</div><div><br />
</div><div>public class HTMLFormat implements Formatter {</div><div><br />
</div><div> String formatting;</div><div> </div><div> public HTMLFormat() {</div><div> // TODO Auto-generated constructor stub</div><div> }</div><div><br />
</div><div> @Override</div><div> public void visit(Employee emp) {</div><div> formatting= "formatted the "+ emp.getName()+ " empolyee data in HTML format";</div><div> }</div><div> </div><div> public String getResult(){</div><div> return formatting;</div><div> }</div><div><br />
</div><div>}</div></div><div><br />
</div><div>-----------------------------------</div><div><br />
</div><div><div>package com;</div><div><br />
</div><div>public class Test {</div><div><br />
</div><div> public Test() {</div><div> // TODO Auto-generated constructor stub</div><div> }</div><div><br />
</div><div> /**</div><div> * @param args</div><div> */</div><div> public static void main(String[] args) {</div><div><br />
</div><div> Employee emp =new Employee();</div><div> </div><div> Formatter visitor =new TextFormat();</div><div> </div><div> </div><div> </div><div> visitor =new HTMLFormat();</div><div> emp.setName("Kumar");</div><div><br />
</div><div> emp.accept(visitor);</div><div> </div><div> System.out.println(visitor.getResult());</div><div> </div><div> }</div><div><br />
</div><div>}</div></div><div><br />
</div><div><br />
</div><div>-----------------------------------------</div><div><br />
</div><div><br />
</div><div><br />
</div><div><div>Test class to collectively apply formatters on Manoj and Kumar below Code could be used in single Test class:</div><div><br />
</div></div><div><br />
</div><div>----------------------------------------</div><div><br />
</div><div><div>package com;</div><div><br />
</div><div>public class Test {</div><div><br />
</div><div> public Test() {</div><div> // TODO Auto-generated constructor stub</div><div> }</div><div><br />
</div><div> /**</div><div> * @param args</div><div> */</div><div> public static void main(String[] args) {</div><div><br />
</div><div> Employee emp =new Employee();</div><div> </div><div> Formatter visitor =new TextFormat();</div><div> </div><div> emp.setName("Manoj");</div><div> emp.accept(visitor);</div><div> </div><div> System.out.println(visitor.getResult());</div><div> </div><div> visitor =new HTMLFormat();</div><div> emp.setName("Kumar");</div><div><br />
</div><div> emp.accept(visitor);</div><div> </div><div> System.out.println(visitor.getResult());</div><div> </div><div> }</div><div><br />
</div><div>}</div></div><div><br />
</div><div>-------------------------------</div><div><br />
</div></div>MANOJ KUMARhttp://www.blogger.com/profile/00421517842858762886noreply@blogger.com0tag:blogger.com,1999:blog-3445872732437342114.post-67279966750475385942013-10-08T11:36:00.002-07:002013-10-18T06:54:34.904-07:00Website Crawler with fork and Join Framework <div dir="ltr" style="text-align: left;" trbidi="on">
<div dir="ltr" style="text-align: left;" trbidi="on">
<div dir="ltr" style="text-align: left;" trbidi="on">
<span style="font-family: Verdana,sans-serif;"><span style="color: #4c1130;"><a href="http://efectivejava.blogspot.in/2013/10/website-crawler-with-for-and-join.html?utm_source=BP_recent" target="_blank"> Website Crawler with fork and Join Framework </a></span></span><br />
<span style="font-family: Verdana,sans-serif;"><span style="color: #4c1130;">Here are the classes involved in writing code for this exercise . It can be directly copied and executed using java 7 as fork and Join libraries are available in java only version 1.7 onwards.</span></span><br />
<br />
<i><span style="font-family: Verdana,sans-serif;"><span style="color: #4c1130;">Along with these classes you would need HTMLParser jar file , which is used to retrieve links available in a page linked to a particular link. </span></span></i><br />
<br />
<b>Please download htmlparser-1.6.jar file and include in the class path to execute below code </b><br />
<br />
<br />
<span style="font-family: "Courier New",Courier,monospace;"><span style="color: blue;">====================================================================<br />
</span></span> <b><span style="font-family: Verdana,sans-serif;"><span style="color: #4c1130;"><br />
</span></span></b> <span style="font-family: "Courier New",Courier,monospace;"><span style="color: blue;"><b><span style="font-family: Verdana,sans-serif;"><span style="color: #4c1130;">WebsiteCrawler class initiates the logic . It create ForkJoinPool which is used to contain the threads to take up and execute the work stealing algorithm.total work is divided among these threads and is executed is parallel . Thus overall processing is executed faster and multiple processor/core hardware is effectively utilized</span></span></b><br />
<br />
<script type="text/javascript">
google_ad_client = "ca-pub-8470945096737641";
/* 160x600, created 6/23/09 */
google_ad_slot = "3027217057";
google_ad_width = 160;
google_ad_height =200 ;
//
</script><br />
<script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript">
</script><br />
<br />
<br />
<br />
import java.util.Collection;<br />
import java.util.Collections;<br />
import java.util.HashSet;<br />
import java.util.concurrent.ForkJoinPool;<br />
<br />
/**<br />
*<br />
* @author Manoj</span></span><br />
<span style="font-family: "Courier New",Courier,monospace;"><span style="color: blue;"> */<br />
public class WebsiteCrawler implements LinkTracker {<br />
<br />
private final Collection<string> linksCrawled = Collections.synchronizedSet(new HashSet<string>());<br />
private String inputUrl;<br />
private ForkJoinPool pool;<br />
<br />
public WebsiteCrawler(String inputUrl, int maxThreadCoulnt) {<br />
this.inputUrl = inputUrl;<br />
pool = new ForkJoinPool(maxThreadCoulnt);<br />
}<br />
<br />
private void init() {<br />
pool.invoke(new LinkSearcher(this.inputUrl, this));<br />
}<br />
<br />
<br />
<br />
<br />
public void addVisited(String s) {<br />
linksCrawled.add(s);<br />
}<br />
<br />
<br />
public boolean visited(String s) {<br />
return linksCrawled.contains(s);<br />
}<br />
<br />
public static void main(String[] args) throws Exception {<br />
new WebsiteCrawler("http://efectivejava.blogspot.in", 50).init();<br />
}<br />
}</string></string></span></span><br />
<br />
<br />
<br />
<script type="text/javascript">
google_ad_client = "ca-pub-8470945096737641";
/* seo banner */
google_ad_slot = "3657212241";
google_ad_width = 468;
google_ad_height = 300;
//</script> </div>
</div>
--><br />
<script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript">
</script><br />
<br />
<span style="font-family: "Courier New",Courier,monospace;"><span style="color: blue;">===================================================================<br />
</span></span> <span style="font-family: "Courier New",Courier,monospace;"><span style="color: blue;"><br />
</span></span> <span style="font-family: "Courier New",Courier,monospace;"><span style="color: blue;"><span style="font-family: "Courier New",Courier,monospace;"><span style="color: blue;"><b><span style="font-family: Verdana,sans-serif;"><span style="color: #4c1130;">LinkTracker interface provides the basic methods required to execute the link search logic </span></span></b></span></span><br />
/**<br />
*<br />
* @author Manoj<br />
*/<br />
public interface LinkTracker {<br />
<br />
<br />
boolean visited(String link);<br />
<br />
void addVisited(String link);<br />
}<br />
<br />
import java.net.URL;<br />
import java.util.ArrayList;<br />
import java.util.List;<br />
import java.util.concurrent.RecursiveAction;<br />
<br />
import org.htmlparser.Parser;<br />
import org.htmlparser.filters.NodeClassFilter;<br />
import org.htmlparser.tags.LinkTag;<br />
import org.htmlparser.util.NodeList;</span></span><br />
<span style="font-family: "Courier New",Courier,monospace;"><span style="color: blue;"></span></span><br />
<span style="font-family: "Courier New",Courier,monospace;"><span style="color: blue;"></span></span><br />
<span style="font-family: "Courier New",Courier,monospace;"><span style="color: blue;"><br />
</span></span><span style="font-family: "Courier New",Courier,monospace;"><span style="color: blue;"><span style="font-family: "Courier New",Courier,monospace;"><span style="color: blue;"><span style="font-family: "Courier New",Courier,monospace;"><span style="color: blue;"><b><span style="font-family: Verdana,sans-serif;"><span style="color: #4c1130;">================================================== </span></span></b></span></span></span></span></span></span><br />
<br />
<br />
<br />
<script type="text/javascript">
google_ad_client = "ca-pub-8470945096737641";
/* 200x200, created 6/23/09 */
google_ad_slot = "8930436823";
google_ad_width = 200;
google_ad_height = 200;
</script><br />
<script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript">
</script><br />
<br />
<span style="font-family: "Courier New",Courier,monospace;"><span style="color: blue;"><span style="font-family: "Courier New",Courier,monospace;"><span style="color: blue;"><span style="font-family: "Courier New",Courier,monospace;"><span style="color: blue;"><b><span style="font-family: Verdana,sans-serif;"><span style="color: #4c1130;">This is the class where core recursive logic is executed . To divide ,assign and execute the logic recursively this class extends RecursiveAction class and overrides compute() method. compute method is invoked recursively and execute the logic for every link . After visit ,visited link is added to the set and all child URLS found for current URL are added as recursiveAction in the list to be executed by compute() method. </span></span></b></span></span></span></span></span></span><br />
<span style="font-family: "Courier New",Courier,monospace;"><span style="color: blue;"><span style="font-family: "Courier New",Courier,monospace;"><span style="color: blue;"><span style="font-family: "Courier New",Courier,monospace;"><span style="color: blue;"><b><span style="font-family: Verdana,sans-serif;"><span style="color: #4c1130;"><br />
</span></span></b></span></span></span></span></span></span> <span style="font-family: "Courier New",Courier,monospace;"><span style="color: blue;"><span style="font-family: "Courier New",Courier,monospace;"><span style="color: blue;"><span style="font-family: "Courier New",Courier,monospace;"><span style="color: blue;"><b><span style="font-family: Verdana,sans-serif;"><span style="color: #4c1130;"><br />
<br />
To understand the code further Please execute this code in debug mode and walk through the flow.</span></span></b></span></span></span></span></span></span><br />
<br />
<span style="font-family: "Courier New",Courier,monospace;"><span style="color: blue;"><span style="font-family: "Courier New",Courier,monospace;"><span style="color: blue;"><span style="font-family: "Courier New",Courier,monospace;"><span style="color: blue;"><b><span style="font-family: Verdana,sans-serif;"><span style="color: #4c1130;"><br />
</span></span></b></span></span></span></span></span></span> <span style="font-family: "Courier New",Courier,monospace;"><span style="color: blue;"><span style="font-family: "Courier New",Courier,monospace;"><span style="color: blue;"><span style="font-family: "Courier New",Courier,monospace;"><span style="color: blue;"><b><span style="font-family: Verdana,sans-serif;"><span style="color: #4c1130;"> </span></span></b></span></span></span></span>public class LinkSearcher extends RecursiveAction {<br />
<br />
private String url;<br />
private LinkTracker tracker;<br />
<br />
<br />
public LinkSearcher(String url, LinkTracker tracker) {<br />
this.url = url;<br />
this.tracker = tracker;<br />
}<br />
<br />
@Override<br />
public void compute() {<br />
if (!tracker.visited(url)) {<br />
try {<br />
List<recursiveaction> actions = new ArrayList<recursiveaction>();<br />
URL uriLink = new URL(url);<br />
Parser parser = new Parser(uriLink.openConnection());<br />
NodeList list = parser.extractAllNodesThatMatch(new NodeClassFilter(LinkTag.class));<br />
<br />
for (int i = 0; i < list.size(); i++) {<br />
LinkTag extracted = (LinkTag) list.elementAt(i);<br />
<br />
if (!extracted.extractLink().isEmpty() && !tracker.visited(extracted.extractLink())) {<br />
<br />
actions.add(new LinkSearcher(extracted.extractLink(), tracker));<br />
}<br />
}<br />
tracker.addVisited(url);<br />
System.out.println(url);<br />
<br />
invokeAll(actions);<br />
} catch (Exception e) {<br />
}<br />
}<br />
}<br />
}</recursiveaction></recursiveaction></span></span><br />
<span style="font-family: "Courier New",Courier,monospace;"><span style="color: blue;"><br />
</span></span> <span style="font-family: "Courier New",Courier,monospace;"><span style="color: blue;"><br />
</span></span><br />
<br />
<script type="text/javascript">
google_ad_client = "ca-pub-8470945096737641";
/* 160x600, created 6/23/09 */
google_ad_slot = "3027217057";
google_ad_width = 160;
google_ad_height =200 ;
//
</script><br />
<script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript">
</script><br />
<br />
<br /></div>
MANOJ KUMARhttp://www.blogger.com/profile/00421517842858762886noreply@blogger.com0tag:blogger.com,1999:blog-3445872732437342114.post-79418684446864104742013-10-08T10:11:00.000-07:002013-10-18T06:57:36.810-07:00Why should override hashcode method while overriding equals method<div dir="ltr" style="text-align: left;" trbidi="on">
<div dir="ltr" style="text-align: left;" trbidi="on">
<div dir="ltr" style="text-align: left;" trbidi="on">
<a href="http://efectivejava.blogspot.in/2013/10/why-should-override-hashcode-method.html" target="_blank"><span style="font-size: small;"><b><span style="color: #4c1130;"><span style="font-family: Verdana,sans-serif;"> Why should override hashcode method while overriding equals method</span></span></b></span></a><br />
<br />
<b><span style="color: #4c1130;"><span style="font-family: Verdana,sans-serif;">How do we compare two instances of a class in java </span></span></b><br />
<span style="color: #4c1130;"><span style="font-family: Verdana,sans-serif;"><br />
</span></span> <span style="color: #4c1130;"><span style="font-family: Verdana,sans-serif;">Lets say there is a class </span></span><br />
<span style="color: #4c1130;"><span style="font-family: Verdana,sans-serif;"><br />
</span></span> <span style="color: blue;"><span style="font-family: "Courier New",Courier,monospace;">public class Employee {<br />
<br />
int age;<br />
<br />
Employee(int age) {<br />
<br />
this.age = age;<br />
<br />
}<br />
<br />
public static void main(String args[]) {<br />
<br />
Employee emp1 = new Employee(10);<br />
Employee emp2 = new Employee(10);<br />
<br />
System.out.println("Are two instances equal? :" +emp1.equals(emp2));<br />
<br />
}<br />
<br />
}</span></span><br />
<br />
<b><span style="color: #4c1130;"><span style="font-family: Verdana,sans-serif;">On executing above program , It prints :</span></span></b><br />
<span style="color: blue;"><span style="font-family: Verdana,sans-serif;">Are two instances equal? :false</span></span><br />
<br />
<span style="color: #4c1130;"><span style="font-family: Verdana,sans-serif;">Why equals method says that two instances are different although they are instances of same class and have same age?</span></span><br />
<br />
<span style="color: #4c1130;"><span style="font-family: Verdana,sans-serif;"><b>Reason </b>: While invoking equals method first hashcode() method is executed . If hashcode() method returns different hashcode value for instances being compared equals() method is not called. Different hashcode declares that instances are different and no further comparison takes place.</span></span><br />
<br />
<b><span style="color: #4c1130;"><span style="font-family: Verdana,sans-serif;">So Is hashcode values for above tow instances are different ?</span></span></b><br />
<br />
<u><i><span style="color: #4c1130;"><span style="font-family: Verdana,sans-serif;">Lets see that </span></span></i></u><br />
<br />
<span style="color: blue;"><span style="font-family: "Courier New",Courier,monospace;">public static void main(String args[]) {<br />
<br />
Employee emp1 = new Employee(10);<br />
Employee emp2 = new Employee(10);<br />
<br />
System.out.println("hashcode value for emp1 " + emp1.hashCode());<br />
System.out.println("hashcode value for emp2 "+emp2.hashCode());<br />
<br />
<br />
}</span></span><br />
<br />
<br />
<br />
<script type="text/javascript">
google_ad_client = "ca-pub-8470945096737641";
/* seo banner */
google_ad_slot = "3657212241";
google_ad_width = 468;
google_ad_height = 300;
//</script>
</div>
</div>
--><br />
<script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript">
</script><br />
<br />
<b><span style="color: #4c1130;"><span style="font-family: Verdana,sans-serif;">Executing above method prints </span></span></b><br />
<br />
<span style="color: blue;"><span style="font-family: Verdana,sans-serif;">hashcode value for emp1 327325694<br />
hashcode value for emp2 1657319091</span></span><br />
<span style="color: #4c1130;"><span style="font-family: Verdana,sans-serif;"><br />
</span></span><br />
<span style="color: #4c1130;"><span style="font-family: Verdana,sans-serif;">So hashcode value returned is different for two instances . Actually hashcode() method works on its inherent algorithm to generate hashcode value of instances . Executing above program again might generate different hashcode values </span></span><br />
<br />
<span style="color: #4c1130;"><span style="font-family: Verdana,sans-serif;">Let me execute the above program again and see what values it prints on console </span></span><br />
<br />
<span style="color: #4c1130;"><span style="font-family: Verdana,sans-serif;">It prints </span></span><br />
<br />
<span style="color: #4c1130;"><span style="font-family: Verdana,sans-serif;"><span style="color: blue;">hashcode value for emp1 1025601370<br />
hashcode value for emp2 1578474768</span><br />
</span></span><br />
<br />
<span style="color: #4c1130;"><span style="font-family: Verdana,sans-serif;">So it has it's internal algorithm to generate hashcode value which dynamically generates the hashcode value and we have no control on that..</span></span><br />
<br />
<u><span style="color: red;"><span style="font-family: Verdana,sans-serif;">So how do we make equals method return true flag when comparing two instances of Employee class</span></span></u><br />
<br />
<span style="color: #4c1130;"><span style="font-family: Verdana,sans-serif;">let's override equals method as below </span></span><br />
<br />
<span style="color: #4c1130;"><span style="font-family: Verdana,sans-serif;"> <span style="color: blue;"><span style="font-family: "Courier New",Courier,monospace;"> public boolean equals(Object obj){<br />
<br />
return this.age==((Employee)obj).age ; <br />
}<br />
</span></span></span></span><br />
<span style="color: #4c1130;"><span style="font-family: Verdana,sans-serif;">Here Object class equals method is overridden . Now equals method is customized so it will declare two instances equal if their ages are equal . So emp1.equals(emp2) should return true </span></span><br />
<br />
<br />
<br />
<script type="text/javascript">
google_ad_client = "ca-pub-8470945096737641";
/* 200x200, created 6/23/09 */
google_ad_slot = "8930436823";
google_ad_width = 200;
google_ad_height = 200;
</script><br />
<script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript">
</script><br />
<br />
<br />
<b><span style="color: #4c1130;"><span style="font-family: Verdana,sans-serif;">But bigger barrier is hashcode() method . This method does not let the call go to equals() method . It returns false based of different hashcode value for two instances . </span></span></b><br />
<br />
<b><i><span style="color: #4c1130;"><span style="font-family: Verdana,sans-serif;">So what do we do to make the call reach equals() method?</span></span></i></b><br />
<br />
<span style="color: #4c1130;"><span style="font-family: Verdana,sans-serif;"> <u>Equals() method can be invoked only if hashcode value for two instances being compared are equal</u> . So can we customize hashcode() method to make it happen . Let's try doing that </span></span><br />
<br />
<pre class="indent" style="text-align: left;"><span style="color: #4c1130;"><span style="font-family: Verdana,sans-serif;"> <span style="color: blue;"> public int hashCode() {
return this.age;
}</span></span></span></pre>
<pre class="indent" style="text-align: left;"><span style="color: blue;"><span style="font-family: Verdana,sans-serif;"> </span></span></pre>
<pre class="indent" style="text-align: left;"><span style="font-family: Verdana,sans-serif;"><span style="color: #4c1130;">Now executing hashcode value will print </span></span></pre>
<pre class="indent" style="text-align: left;"><span style="font-family: Verdana,sans-serif;"><span style="color: #4c1130;"> </span></span></pre>
<pre class="indent" style="text-align: left;"><span style="color: blue;"><span style="font-family: Verdana,sans-serif;">hashcode value for emp1 10
hashcode value for emp2 10</span></span></pre>
<pre class="indent" style="text-align: left;"></pre>
<pre class="indent" style="text-align: left;"><span style="font-family: Verdana,sans-serif;"><span style="color: #4c1130;">So hashcode values are equal. Hashcode method itsself can't decide in this case If </span></span></pre>
<pre class="indent" style="text-align: left;"><span style="font-family: Verdana,sans-serif;"><span style="color: #4c1130;">two instance are equal and to decide that equals() method is invoked. </span></span></pre>
<pre class="indent" style="text-align: left;"><span style="font-family: Verdana,sans-serif;"><span style="color: #4c1130;"> </span></span></pre>
<pre class="indent" style="text-align: left;"><u><b><span style="font-family: Verdana,sans-serif;"><span style="color: #4c1130;">Thus It is must to override hashcode() method to make equals() method invoked. </span></span></b></u></pre>
<pre class="indent" style="text-align: left;"><span style="font-family: Verdana,sans-serif;"><span style="color: #4c1130;"> </span></span></pre>
<pre class="indent" style="text-align: left;"><span style="font-family: Verdana,sans-serif;"><span style="color: #4c1130;">So we can conclude </span></span></pre>
<pre class="indent" style="text-align: left;"><span style="font-family: Verdana,sans-serif;"><span style="color: #4c1130;"> </span></span></pre>
<pre class="indent" style="text-align: left;"><b><i><u><span style="font-family: Verdana,sans-serif;"><span style="color: #4c1130;">If equals() method is customized and overridden then it make it work as we expect It is </span></span></u></i></b></pre>
<pre class="indent" style="text-align: left;"><span style="font-family: Verdana,sans-serif;"><span style="color: #4c1130;"><b><i><u>must to override hashcode method in a way to make call to equals() possible. </u></i></b></span></span></pre>
<pre class="indent" style="text-align: left;"><span style="color: #4c1130;"><span style="font-family: Verdana,sans-serif;">
</span></span></pre>
<br />
<span style="color: #4c1130;"><span style="font-family: Verdana,sans-serif;"><br />
</span></span><br />
<br />
<script type="text/javascript">
google_ad_client = "ca-pub-8470945096737641";
/* 160x600, created 6/23/09 */
google_ad_slot = "3027217057";
google_ad_width = 160;
google_ad_height =200 ;
//
</script><br />
<script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript">
</script><br />
<br /></div>
MANOJ KUMARhttp://www.blogger.com/profile/00421517842858762886noreply@blogger.com0tag:blogger.com,1999:blog-3445872732437342114.post-53464841286898111892013-10-06T23:59:00.000-07:002013-10-18T06:58:34.923-07:00How to make a website SEO friendly , Search engine optimization<div dir="ltr" style="text-align: left;" trbidi="on">
<div dir="ltr" style="text-align: left;" trbidi="on">
<!--[if gte mso 9]><xml> <o:OfficeDocumentSettings> <o:AllowPNG/> </o:OfficeDocumentSettings> </xml><![endif]--><a href="http://efectivejava.blogspot.in/2013/10/how-to-make-website-seo-friendly-search.html" target="_blank"> How to make a website SEO friendly , Search engine optimization</a><br />
<!--[if gte mso 9]><xml> <o:OfficeDocumentSettings> <o:AllowPNG/> </o:OfficeDocumentSettings> </xml><![endif]--><br />
<!--[if gte mso 9]><xml> <w:WordDocument> <w:View>Normal</w:View> <w:Zoom>0</w:Zoom> <w:TrackMoves/> <w:TrackFormatting/> <w:PunctuationKerning/> <w:ValidateAgainstSchemas/> <w:SaveIfXMLInvalid>false</w:SaveIfXMLInvalid> <w:IgnoreMixedContent>false</w:IgnoreMixedContent> <w:AlwaysShowPlaceholderText>false</w:AlwaysShowPlaceholderText> <w:DoNotPromoteQF/> <w:LidThemeOther>EN-US</w:LidThemeOther> <w:LidThemeAsian>X-NONE</w:LidThemeAsian> <w:LidThemeComplexScript>X-NONE</w:LidThemeComplexScript> <w:Compatibility> <w:BreakWrappedTables/> <w:SnapToGridInCell/> <w:WrapTextWithPunct/> <w:UseAsianBreakRules/> <w:DontGrowAutofit/> <w:SplitPgBreakAndParaMark/> <w:EnableOpenTypeKerning/> <w:DontFlipMirrorIndents/> <w:OverrideTableStyleHps/> </w:Compatibility> <m:mathPr> <m:mathFont m:val="Cambria Math"/> <m:brkBin m:val="before"/> <m:brkBinSub m:val="--"/> <m:smallFrac m:val="off"/> <m:dispDef/> <m:lMargin m:val="0"/> <m:rMargin m:val="0"/> <m:defJc m:val="centerGroup"/> <m:wrapIndent m:val="1440"/> <m:intLim m:val="subSup"/> <m:naryLim m:val="undOvr"/> </m:mathPr></w:WordDocument> </xml><![endif]--><!--[if gte mso 9]><xml> <w:LatentStyles DefLockedState="false" DefUnhideWhenUsed="true"
DefSemiHidden="true" DefQFormat="false" DefPriority="99"
LatentStyleCount="267"> <w:LsdException Locked="false" Priority="0" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Normal"/> <w:LsdException Locked="false" Priority="9" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="heading 1"/> <w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 2"/> <w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 3"/> <w:LsdException Locked="false" Priority="0" QFormat="true" Name="heading 4"/> <w:LsdException Locked="false" Priority="0" QFormat="true" Name="heading 5"/> <w:LsdException Locked="false" Priority="0" QFormat="true" Name="heading 6"/> <w:LsdException Locked="false" Priority="0" QFormat="true" Name="heading 7"/> <w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 8"/> <w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 9"/> <w:LsdException Locked="false" Priority="39" Name="toc 1"/> <w:LsdException Locked="false" Priority="39" Name="toc 2"/> <w:LsdException Locked="false" Priority="39" Name="toc 3"/> <w:LsdException Locked="false" Priority="39" Name="toc 4"/> <w:LsdException Locked="false" Priority="39" Name="toc 5"/> <w:LsdException Locked="false" Priority="39" Name="toc 6"/> <w:LsdException Locked="false" Priority="39" Name="toc 7"/> <w:LsdException Locked="false" Priority="39" Name="toc 8"/> <w:LsdException Locked="false" Priority="39" Name="toc 9"/> <w:LsdException Locked="false" Priority="35" QFormat="true" Name="caption"/> <w:LsdException Locked="false" Priority="10" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Title"/> <w:LsdException Locked="false" Priority="1" Name="Default Paragraph Font"/> <w:LsdException Locked="false" Priority="11" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Subtitle"/> <w:LsdException Locked="false" Priority="22" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Strong"/> <w:LsdException Locked="false" Priority="20" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Emphasis"/> <w:LsdException Locked="false" Priority="59" SemiHidden="false"
UnhideWhenUsed="false" Name="Table Grid"/> <w:LsdException Locked="false" UnhideWhenUsed="false" Name="Placeholder Text"/> <w:LsdException Locked="false" Priority="1" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="No Spacing"/> <w:LsdException Locked="false" Priority="60" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Shading"/> <w:LsdException Locked="false" Priority="61" SemiHidden="false"
UnhideWhenUsed="false" Name="Light List"/> <w:LsdException Locked="false" Priority="62" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Grid"/> <w:LsdException Locked="false" Priority="63" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 1"/> <w:LsdException Locked="false" Priority="64" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 2"/> <w:LsdException Locked="false" Priority="65" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 1"/> <w:LsdException Locked="false" Priority="66" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 2"/> <w:LsdException Locked="false" Priority="67" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 1"/> <w:LsdException Locked="false" Priority="68" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 2"/> <w:LsdException Locked="false" Priority="69" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 3"/> <w:LsdException Locked="false" Priority="70" SemiHidden="false"
UnhideWhenUsed="false" Name="Dark List"/> <w:LsdException Locked="false" Priority="71" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Shading"/> <w:LsdException Locked="false" Priority="72" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful List"/> <w:LsdException Locked="false" Priority="73" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Grid"/> <w:LsdException Locked="false" Priority="60" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Shading Accent 1"/> <w:LsdException Locked="false" Priority="61" SemiHidden="false"
UnhideWhenUsed="false" Name="Light List Accent 1"/> <w:LsdException Locked="false" Priority="62" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Grid Accent 1"/> <w:LsdException Locked="false" Priority="63" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 1 Accent 1"/> <w:LsdException Locked="false" Priority="64" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 2 Accent 1"/> <w:LsdException Locked="false" Priority="65" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 1 Accent 1"/> <w:LsdException Locked="false" UnhideWhenUsed="false" Name="Revision"/> <w:LsdException Locked="false" Priority="34" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="List Paragraph"/> <w:LsdException Locked="false" Priority="29" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Quote"/> <w:LsdException Locked="false" Priority="30" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Intense Quote"/> <w:LsdException Locked="false" Priority="66" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 2 Accent 1"/> <w:LsdException Locked="false" Priority="67" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 1 Accent 1"/> <w:LsdException Locked="false" Priority="68" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 2 Accent 1"/> <w:LsdException Locked="false" Priority="69" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 3 Accent 1"/> <w:LsdException Locked="false" Priority="70" SemiHidden="false"
UnhideWhenUsed="false" Name="Dark List Accent 1"/> <w:LsdException Locked="false" Priority="71" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Shading Accent 1"/> <w:LsdException Locked="false" Priority="72" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful List Accent 1"/> <w:LsdException Locked="false" Priority="73" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Grid Accent 1"/> <w:LsdException Locked="false" Priority="60" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Shading Accent 2"/> <w:LsdException Locked="false" Priority="61" SemiHidden="false"
UnhideWhenUsed="false" Name="Light List Accent 2"/> <w:LsdException Locked="false" Priority="62" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Grid Accent 2"/> <w:LsdException Locked="false" Priority="63" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 1 Accent 2"/> <w:LsdException Locked="false" Priority="64" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 2 Accent 2"/> <w:LsdException Locked="false" Priority="65" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 1 Accent 2"/> <w:LsdException Locked="false" Priority="66" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 2 Accent 2"/> <w:LsdException Locked="false" Priority="67" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 1 Accent 2"/> <w:LsdException Locked="false" Priority="68" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 2 Accent 2"/> <w:LsdException Locked="false" Priority="69" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 3 Accent 2"/> <w:LsdException Locked="false" Priority="70" SemiHidden="false"
UnhideWhenUsed="false" Name="Dark List Accent 2"/> <w:LsdException Locked="false" Priority="71" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Shading Accent 2"/> <w:LsdException Locked="false" Priority="72" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful List Accent 2"/> <w:LsdException Locked="false" Priority="73" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Grid Accent 2"/> <w:LsdException Locked="false" Priority="60" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Shading Accent 3"/> <w:LsdException Locked="false" Priority="61" SemiHidden="false"
UnhideWhenUsed="false" Name="Light List Accent 3"/> <w:LsdException Locked="false" Priority="62" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Grid Accent 3"/> <w:LsdException Locked="false" Priority="63" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 1 Accent 3"/> <w:LsdException Locked="false" Priority="64" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 2 Accent 3"/> <w:LsdException Locked="false" Priority="65" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 1 Accent 3"/> <w:LsdException Locked="false" Priority="66" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 2 Accent 3"/> <w:LsdException Locked="false" Priority="67" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 1 Accent 3"/> <w:LsdException Locked="false" Priority="68" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 2 Accent 3"/> <w:LsdException Locked="false" Priority="69" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 3 Accent 3"/> <w:LsdException Locked="false" Priority="70" SemiHidden="false"
UnhideWhenUsed="false" Name="Dark List Accent 3"/> <w:LsdException Locked="false" Priority="71" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Shading Accent 3"/> <w:LsdException Locked="false" Priority="72" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful List Accent 3"/> <w:LsdException Locked="false" Priority="73" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Grid Accent 3"/> <w:LsdException Locked="false" Priority="60" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Shading Accent 4"/> <w:LsdException Locked="false" Priority="61" SemiHidden="false"
UnhideWhenUsed="false" Name="Light List Accent 4"/> <w:LsdException Locked="false" Priority="62" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Grid Accent 4"/> <w:LsdException Locked="false" Priority="63" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 1 Accent 4"/> <w:LsdException Locked="false" Priority="64" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 2 Accent 4"/> <w:LsdException Locked="false" Priority="65" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 1 Accent 4"/> <w:LsdException Locked="false" Priority="66" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 2 Accent 4"/> <w:LsdException Locked="false" Priority="67" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 1 Accent 4"/> <w:LsdException Locked="false" Priority="68" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 2 Accent 4"/> <w:LsdException Locked="false" Priority="69" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 3 Accent 4"/> <w:LsdException Locked="false" Priority="70" SemiHidden="false"
UnhideWhenUsed="false" Name="Dark List Accent 4"/> <w:LsdException Locked="false" Priority="71" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Shading Accent 4"/> <w:LsdException Locked="false" Priority="72" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful List Accent 4"/> <w:LsdException Locked="false" Priority="73" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Grid Accent 4"/> <w:LsdException Locked="false" Priority="60" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Shading Accent 5"/> <w:LsdException Locked="false" Priority="61" SemiHidden="false"
UnhideWhenUsed="false" Name="Light List Accent 5"/> <w:LsdException Locked="false" Priority="62" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Grid Accent 5"/> <w:LsdException Locked="false" Priority="63" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 1 Accent 5"/> <w:LsdException Locked="false" Priority="64" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 2 Accent 5"/> <w:LsdException Locked="false" Priority="65" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 1 Accent 5"/> <w:LsdException Locked="false" Priority="66" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 2 Accent 5"/> <w:LsdException Locked="false" Priority="67" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 1 Accent 5"/> <w:LsdException Locked="false" Priority="68" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 2 Accent 5"/> <w:LsdException Locked="false" Priority="69" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 3 Accent 5"/> <w:LsdException Locked="false" Priority="70" SemiHidden="false"
UnhideWhenUsed="false" Name="Dark List Accent 5"/> <w:LsdException Locked="false" Priority="71" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Shading Accent 5"/> <w:LsdException Locked="false" Priority="72" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful List Accent 5"/> <w:LsdException Locked="false" Priority="73" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Grid Accent 5"/> <w:LsdException Locked="false" Priority="60" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Shading Accent 6"/> <w:LsdException Locked="false" Priority="61" SemiHidden="false"
UnhideWhenUsed="false" Name="Light List Accent 6"/> <w:LsdException Locked="false" Priority="62" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Grid Accent 6"/> <w:LsdException Locked="false" Priority="63" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 1 Accent 6"/> <w:LsdException Locked="false" Priority="64" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 2 Accent 6"/> <w:LsdException Locked="false" Priority="65" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 1 Accent 6"/> <w:LsdException Locked="false" Priority="66" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 2 Accent 6"/> <w:LsdException Locked="false" Priority="67" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 1 Accent 6"/> <w:LsdException Locked="false" Priority="68" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 2 Accent 6"/> <w:LsdException Locked="false" Priority="69" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 3 Accent 6"/> <w:LsdException Locked="false" Priority="70" SemiHidden="false"
UnhideWhenUsed="false" Name="Dark List Accent 6"/> <w:LsdException Locked="false" Priority="71" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Shading Accent 6"/> <w:LsdException Locked="false" Priority="72" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful List Accent 6"/> <w:LsdException Locked="false" Priority="73" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Grid Accent 6"/> <w:LsdException Locked="false" Priority="19" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Subtle Emphasis"/> <w:LsdException Locked="false" Priority="21" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Intense Emphasis"/> <w:LsdException Locked="false" Priority="31" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Subtle Reference"/> <w:LsdException Locked="false" Priority="32" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Intense Reference"/> <w:LsdException Locked="false" Priority="33" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Book Title"/> <w:LsdException Locked="false" Priority="37" Name="Bibliography"/> <w:LsdException Locked="false" Priority="39" QFormat="true" Name="TOC Heading"/> </w:LatentStyles> </xml><![endif]--><!--[if gte mso 10]> <style>
/* Style Definitions */
table.MsoNormalTable
{mso-style-name:"Table Normal";
mso-tstyle-rowband-size:0;
mso-tstyle-colband-size:0;
mso-style-noshow:yes;
mso-style-priority:99;
mso-style-parent:"";
mso-padding-alt:0in 5.4pt 0in 5.4pt;
mso-para-margin:0in;
mso-para-margin-bottom:.0001pt;
mso-pagination:widow-orphan;
font-size:10.0pt;
font-family:"Times New Roman","serif";}
</style> <![endif]--> <br />
<div class="MsoNormal">
<span style="color: #4c1130;"><b style="mso-bidi-font-weight: normal;">Page Title</b></span></div>
<div class="MsoNormal" style="tab-stops: 208.5pt;">
<span style="color: #4c1130;">Your title should be from 20 to 70 characters length. However up to 120 characters can be considered as correct. <br />
Make sure that title is correct and includes most important keyword. <br />
Each page should have it's own, unique title.</span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<span style="color: #4c1130;"><b style="mso-bidi-font-weight: normal;">Meta Description</b></span></div>
<div class="MsoNormal">
<span style="color: #4c1130;">Meta description should be from 100 to 160 characters length. However up to 200 characters can be considered as correct.<br />
Use all characters to describe your page using most important keyword. <br />
Each page should have it’s own, unique description. <br />
Meta description usually shows in search engine results as a description of page and it should encourage to visit your site.</span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<span style="color: #4c1130;"><b style="mso-bidi-font-weight: normal;">Meta Keywords</b></span></div>
<div class="MsoNormal">
<span style="color: #4c1130;">Meta keywords has no influence on website positioning. <br />
You can remove all meta keywords or limit them to only few describing your content.</span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<span style="color: #4c1130;"><b style="mso-bidi-font-weight: normal;">Meta Robots</b></span></div>
<div class="MsoNormal">
<span style="color: #4c1130;">Meta tag robots has crucial impact on page indexing by search engine robots. <br />
Value "noindex" prevents from indexing of page. Value "nofollow" prevents robots from following all links at page. <br />
Most common and default (if empty) values are index, </span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<span style="color: #4c1130;"><b style="mso-bidi-font-weight: normal;">Encoding</b></span></div>
<div class="MsoNormal">
<span style="color: #4c1130;"><span style="mso-spacerun: yes;"> </span>Encoding has an impact on the correct display of special characters. <br />
Popular encodings are UTF-8, Latin1, ISO-8859-2 etc. <br />
Encoding has no influence on website positioning, but incorrect encoding can cause problems with display special characters.</span></div>
<div class="MsoNormal" style="mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; mso-outline-level: 2;">
<span style="color: #4c1130;"><b><span style="font-size: 18.0pt;">Body Content</span></b></span></div>
<div class="MsoNormal" style="mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; mso-outline-level: 2;">
<br /></div>
<div class="MsoNormal">
<span style="color: #4c1130;"><b style="mso-bidi-font-weight: normal;">Words and Chars</b></span></div>
<div class="MsoNormal">
<span style="color: #4c1130;"> </span><span style="color: #4c1130;">Make sure that the text on page was not less than 250 words.</span></div>
<div class="MsoNormal">
<span style="color: #4c1130;"> </span> </div>
<div class="MsoNormal">
<span style="color: #4c1130;"><b style="mso-bidi-font-weight: normal;">Text / HTML Ratio</b></span></div>
<div class="MsoNormal">
<span style="color: #4c1130;">The TEXT / HTML ratio is the ratio of the number of characters of plain text to the page's HTML code, expressed as a percentage. <br />
The higher the number, the greater amount of content is on your site, and lesser HTML code. <br />
A value below 10% means that there is too little text or that the HTML code is "littered" or negligent. <br />
Make sure that the TEXT / HTML ratio is not below 10%.</span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<span style="color: #4c1130;"><b style="mso-bidi-font-weight: normal;">Headers</b></span></div>
<table border="0" cellpadding="0" class="MsoNormalTable" style="mso-cellspacing: 1.5pt; mso-yfti-tbllook: 1184;"><tbody>
<tr style="mso-yfti-firstrow: yes; mso-yfti-irow: 0; mso-yfti-lastrow: yes;"> <td style="padding: .75pt .75pt .75pt .75pt;"><div align="center" class="MsoNormal" style="text-align: center;">
<span style="color: #4c1130;"><b>H1</b></span></div>
</td> <td style="padding: .75pt .75pt .75pt .75pt;"><div align="center" class="MsoNormal" style="text-align: center;">
<span style="color: #4c1130;"><b>H2</b></span></div>
</td> <td style="padding: .75pt .75pt .75pt .75pt;"><div align="center" class="MsoNormal" style="text-align: center;">
<span style="color: #4c1130;"><b>H3</b></span></div>
</td> <td style="padding: .75pt .75pt .75pt .75pt;"><div align="center" class="MsoNormal" style="text-align: center;">
<span style="color: #4c1130;"><b>H4</b></span></div>
</td> <td style="padding: .75pt .75pt .75pt .75pt;"><div align="center" class="MsoNormal" style="text-align: center;">
<span style="color: #4c1130;"><b>H5</b></span></div>
</td> <td style="padding: .75pt .75pt .75pt .75pt;"><div align="center" class="MsoNormal" style="text-align: center;">
<span style="color: #4c1130;"><b>H6</b></span></div>
</td> </tr>
</tbody></table>
<div class="MsoNormal">
<span style="color: #4c1130;">Headers are very important factor of on-page optimization. <br />
Correct document should contain most important </span><br />
<h1>
<span style="color: #4c1130;"> and second-level <h2>
. <br />
Remember to insert important keyword in header.</h2>
</span></h1>
</div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<span style="color: #4c1130;"><b style="mso-bidi-font-weight: normal;">Bolds</b></span></div>
<div class="MsoNormal">
<span style="color: #4c1130;"><span style="mso-spacerun: yes;"> </span></span>The <b> and <b> bold type indicate the important keywords on the page. </b></b></div>
<div class="MsoNormal">
<span style="color: #4c1130;"> Search engines take into account emphasized keywords that are in the text.</span></div>
<div class="MsoNormal">
<br /></div>
<br />
<br />
<script type="text/javascript">
google_ad_client = "ca-pub-8470945096737641";
/* seo banner */
google_ad_slot = "3657212241";
google_ad_width = 468;
google_ad_height = 300;
//</script>
</div>
</div>
--><br /><script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript">
</script><br />
<br />
<div class="MsoNormal">
<span style="color: #4c1130;"><b style="mso-bidi-font-weight: normal;">Images</b></span></div>
<div class="MsoNormal">
<span style="color: #4c1130;"><span style="mso-spacerun: yes;"> </span>Images enrich the content of the website. <br />
No images on the page may be a warning signal against spam, or the page is of low quality. <br />
Publish interesting pictures, photos or diagrams related to the content of the page. <br />
Using the ALT attribute describe accurately each picture.</span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<span style="color: #4c1130;"><b style="mso-bidi-font-weight: normal;">Frames</b></span></div>
<div class="MsoNormal">
<span style="color: #4c1130;"><span style="mso-spacerun: yes;"> </span>Frames can cause problems to search engines and make your website works slow. <br />
Avoid use of frames on websites.</span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal" style="mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; mso-outline-level: 2;">
<span style="color: #4c1130;"><b><span style="font-size: 18.0pt;">Internal and External Links</span></b></span></div>
<div class="MsoNormal">
<span style="color: #4c1130;"><b style="mso-bidi-font-weight: normal;">External Links</b></span></div>
<div class="MsoNormal" style="margin-left: 0in; mso-list: l0 level1 lfo1; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; mso-outline-level: 3; text-indent: 0in;">
<span style="color: #4c1130;"><b><span style="font-size: 13.5pt;"><span style="mso-list: Ignore;">1<span style="font: 7.0pt "Times New Roman";"> </span></span></span></b><b><span style="font-size: 13.5pt;">External Links </span></b></span></div>
<div class="MsoNormal">
<span style="color: #4c1130;">Outbound links (external links) are all links leading outside your website. <br />
It is worth to link to other sites that contain high quality content related to the theme of your site. <br />
Do not link to sites which you do not trust, in particular the spam pages. <br />
Limit the number of outbound links to a maximum of 15 links.</span></div>
<div class="MsoNormal">
<span style="color: #4c1130;">Internal Links</span></div>
<div class="MsoNormal" style="margin-left: 0in; mso-list: l0 level1 lfo1; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; mso-outline-level: 3; text-indent: 0in;">
<span style="color: #4c1130;"><b><span style="font-size: 13.5pt;"><span style="mso-list: Ignore;">2<span style="font: 7.0pt "Times New Roman";"> </span></span></span></b><b><span style="font-size: 13.5pt;">Internal Links </span></b></span></div>
<div class="MsoNormal">
<span style="color: #4c1130;">Internal links are any links pointing to the other pages of your website. <br />
By placing links to other pages you are reinforcing internal linking and strengthening the usability of your website. <br />
Always link to the most important pages of your website.</span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal" style="mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; mso-outline-level: 2;">
<span style="color: #4c1130;"><b><span style="font-size: 18.0pt;">Additional Files</span></b></span></div>
<div class="MsoNormal">
<span style="color: #4c1130;"><b style="mso-bidi-font-weight: normal;">Robots.txt</b></span></div>
<div class="MsoNormal">
<span style="color: #4c1130;">The robots.txt file instructs search engine robots by allowing or restricting access to selected folders and pages of your website. <br />
The robots.txt file has a huge impact on the correct page indexing in search engine results. <br />
Make sure your website has a valid robots.txt file.</span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<span style="color: #4c1130;"><b style="mso-bidi-font-weight: normal;">Sitemap.xml</b></span></div>
<div class="MsoNormal">
<span style="color: #4c1130;">The sitemap.xml file should contain a list of all pages of your website that need to be indexed by search engines. <br />
Sitemap.xml file informs the search engine about relevant pages on your site, their latest update and significance in the context of the entire site. <br />
Ensure the correctness of sitemap.xml</span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal" style="mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; mso-outline-level: 2;">
<span style="color: #4c1130;"><b><span style="font-size: 18.0pt;">Social Media Signals</span></b></span></div>
<div class="MsoNormal">
<span style="color: #4c1130;"><b style="mso-bidi-font-weight: normal;">Facebook Likes</b></span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<span style="color: #4c1130;">The number of gained "Likes" can have a positive impact on the position of your site in search results. <br />
Install the <a href="http://developers.facebook.com/docs/reference/plugins/like/">Facebook Like button</a> on your website and encourage your users to like your site.</span></div>
<div class="MsoNormal">
<span style="color: #4c1130;"><b style="mso-bidi-font-weight: normal;">Facebook Shares</b></span></div>
<div class="MsoNormal">
<br />
<script type="text/javascript">
google_ad_client = "ca-pub-8470945096737641";
/* 200x200, created 6/23/09 */
google_ad_slot = "8930436823";
google_ad_width = 200;
google_ad_height = 200;
</script><br />
<script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript">
</script><br />
<br />
<br />
<br /></div>
<div class="MsoNormal">
<span style="color: #4c1130;">By sharing your site with friends on Facebook you have a chance to gain new visitors. A large number of "shares" may have a positive impact on the position of your site in search engines.</span></div>
<div class="MsoNormal">
<span style="color: #4c1130;"><b style="mso-bidi-font-weight: normal;">Google +1</b></span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<span style="color: #4c1130;">The number of gained Google +1 has a positive impact on the position of your site in search results. <br />
Install <a href="http://www.google.com/intl/pl/webmasters/+1/button/">Google +1 button</a> on your website and encourage your users to click on +1.</span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal" style="mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; mso-outline-level: 2;">
<span style="color: #4c1130;"><b><span style="font-size: 18.0pt;">HTTP Headers</span></b></span></div>
<div class="MsoNormal">
<span style="color: #4c1130;">HTTP headers is the server return information, not visible on the website. <br />
SEO audit can be performed only on sites that have an HTTP 200 OK header, which indicates proper functioning of the page. <br />
Any other value of the HTTP code prevents from page positioning.</span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal" style="mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; mso-outline-level: 2;">
<span style="color: #4c1130;"><b><span style="font-size: 18.0pt;">Domain and Server</span></b></span></div>
<div class="MsoNormal">
<span style="color: #4c1130;"><b style="mso-bidi-font-weight: normal;">IP Address</b></span></div>
<div class="MsoNormal">
<span style="color: #4c1130;">IP Address has no influence on website positioning. <br />
On one IP address can work hundreds of different websites. <br />
Avoid sharing IP address with spam websites. </span></div>
<div class="MsoNormal">
<span style="color: #4c1130;"><b style="mso-bidi-font-weight: normal;">Name Servers</b></span></div>
<div class="MsoNormal">
<span style="color: #4c1130;">DNS servers has no influence on website positioning. <br />
Like IP address, many websites can use the same DNS servers. <br />
Avoid sharing DNS names with spam websites. </span></div>
<div class="MsoNormal">
<span style="color: #4c1130;"><b style="mso-bidi-font-weight: normal;">Server Geolocation</b></span></div>
<div class="MsoNormal">
<span style="color: #4c1130;"><span style="mso-spacerun: yes;"> </span>Geographical localization of server has no direct influence on website positioning. <br />
Use hosting companies located in regions where you are making your business.</span></div>
<div class="MsoNormal">
<br /></div>
<br />
<script type="text/javascript">
google_ad_client = "ca-pub-8470945096737641";
/* 160x600, created 6/23/09 */
google_ad_slot = "3027217057";
google_ad_width = 160;
google_ad_height =200 ;
//
</script><br />
<script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript">
</script><br />
<br />
<br />
<br />MANOJ KUMARhttp://www.blogger.com/profile/00421517842858762886noreply@blogger.com0tag:blogger.com,1999:blog-3445872732437342114.post-56814985782293408112013-10-06T10:07:00.001-07:002013-10-18T06:59:22.034-07:00'javac' is not recognized as an internal or external command, operable program or batch file.<div dir="ltr" style="text-align: left;" trbidi="on">
<div dir="ltr" style="text-align: left;" trbidi="on">
<a href="http://efectivejava.blogspot.in/2013/10/javac-is-not-recognized-as-internal-or.html" target="_blank"><b>'javac' is not recognized as an internal or external command, operable program or batch file.</b></a><br />
<br />
This error might occur as JDK is not set in path System variable in environment variable<br />
<br />
<br />
<script type="text/javascript">
google_ad_client = "ca-pub-8470945096737641";
/* seo banner */
google_ad_slot = "3657212241";
google_ad_width = 468;
google_ad_height = 300;
//</script>
</div>
</div>
--><br /><script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript">
</script><br />
<br />
To set this find out where Java is installed on your system<br />
<br />
Let's say you have Java 7 installed on your system , copy bin directory path as below :<br />
<br />
<b><java directoy="" installation="">\jdk1.7.0\bin</java></b><br />
<br />
Now access the path variable in environment variable from :<br />
<br />
Control Panel\System and Security\System<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgAi8LsQyAXHjxmtuxTTq2hDqVb8-v5-0z1VsoC162aojqxe8C4mZjXEVEPFJjZavvJ620mwUfJttRKvyqtUsRme8PnbyXvSesAr9oxUK39OwGubSDe9__aCIAJMq_nsncIisVsjBw6bbk/s1600/Untitled.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgAi8LsQyAXHjxmtuxTTq2hDqVb8-v5-0z1VsoC162aojqxe8C4mZjXEVEPFJjZavvJ620mwUfJttRKvyqtUsRme8PnbyXvSesAr9oxUK39OwGubSDe9__aCIAJMq_nsncIisVsjBw6bbk/s1600/Untitled.png" height="200" width="320" /></a></div>
<br />
<br />
<b>Set Java_Home as </b><br />
<b><java directoy="" installation="">\jdk1.7.0\bin</java></b><br />
<br />
<b>then set path variable value as : %Java_Home%;(current value in path)</b><br />
<b><br />
</b> <b>OR</b><br />
<b><br />
</b> <b>set path directly as </b><br />
<b><java directoy="" installation="">\jdk1.7.0\bin;(current value in path)</java></b><br />
<br />
<br />
<b>If Still it does not work and throw same error , Access command line </b><br />
<br />
<b>and check the path with path command </b><br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEitAQD_xH6V0SNIMVdYap5XhbkypDy524fUQONjLSVbDv1hRjy_XQqoL9E6gBuMP9JbDIym9kvKgsCPMFd3yXPK4pxD2-_jwRpmbLvliaSZW6LoLZHHTcxLvAWt918d7rjn2v5TkgkjITE/s1600/Untitled1.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEitAQD_xH6V0SNIMVdYap5XhbkypDy524fUQONjLSVbDv1hRjy_XQqoL9E6gBuMP9JbDIym9kvKgsCPMFd3yXPK4pxD2-_jwRpmbLvliaSZW6LoLZHHTcxLvAWt918d7rjn2v5TkgkjITE/s1600/Untitled1.png" height="200" width="320" /></a></div>
Now see if <b><java directoy="" installation="">\jdk1.7.0\bin is there in the output ..</java></b><br />
<b><br />
</b> <b>If it is not there then set path from command line using command </b><br />
<b><br />
</b> <b>set path =%path%;</b><b><java directoy="" installation="">\jdk1.7.0\bin</java></b><br />
<br />
<b>Now check again the value of path variable , </b><b><b><java directoy="" installation="">\jdk1.7.0\bin should be there </java></b></b><br />
<br />
<b><b>Try executing program again , it should work now.. </b> </b><br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjzguECEoLPEES3qgtk8U-kPCmmmM5wTylwlOBgBNh8Gk4zTIA4w9Qd9ZnS0nTOUSok9dF4J2yc7VHlHdHqotf7lv8YR7MyhaUsGS7Mqsg1rruL4BDtvHKBQnz75VH7Tax4Pse8T19BIEU/s1600/Untitled1.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><br />
</a></div>
<br />
<br />
<br />
<br />
<script type="text/javascript">
google_ad_client = "ca-pub-8470945096737641";
/* 160x600, created 6/23/09 */
google_ad_slot = "3027217057";
google_ad_width = 160;
google_ad_height =200 ;
//
</script><br />
<script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript">
</script><br />
<br />
<br />
<script type="text/javascript">
google_ad_client = "ca-pub-8470945096737641";
/* 200x200, created 6/23/09 */
google_ad_slot = "8930436823";
google_ad_width = 200;
google_ad_height = 200;
</script><br />
<script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript">
</script><br />
<br />
<br />MANOJ KUMARhttp://www.blogger.com/profile/00421517842858762886noreply@blogger.com0tag:blogger.com,1999:blog-3445872732437342114.post-28943715627260499442013-10-06T07:24:00.000-07:002013-10-18T07:00:14.719-07:00Builder Design Pattern<div dir="ltr" style="text-align: left;" trbidi="on">
<div dir="ltr" style="text-align: left;" trbidi="on">
<b><span style="color: #4c1130;">What is <a href="http://efectivejava.blogspot.in/2013/10/builder-design-pattern.html" target="_blank">builder design pattern</a> ?</span></b><br />
<span style="color: #4c1130;"><br />
</span> <span style="color: #4c1130;">This is used to segregate the logic for creation of complex objects. </span><br />
<span style="color: #4c1130;"><br />
</span> <u><b><span style="color: #4c1130;">For example</span></b></u><br />
<br />
<span style="color: #4c1130;"> If we want to create an object of class representing real Estate residential project . We need to take into account lot of factors in building full fledged object . Object will consist of features like </span><br />
<span style="color: #4c1130;"> payment plan </span><br />
<span style="color: #4c1130;">layout </span><br />
<span style="color: #4c1130;">construction plan </span><br />
<span style="color: #4c1130;">builder information </span><br />
<span style="color: #4c1130;">land details </span><br />
<span style="color: #4c1130;">finance details </span><br />
<span style="color: #4c1130;">location details</span><br />
<span style="color: #4c1130;">salient features </span><br />
<br />
<span style="color: #4c1130;">and so on.....</span><br />
<br />
<script type="text/javascript">
google_ad_client = "ca-pub-8470945096737641";
/* 160x600, created 6/23/09 */
google_ad_slot = "3027217057";
google_ad_width = 160;
google_ad_height =200 ;
//
</script><br />
<script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript">
</script><br />
<br />
<span style="color: #4c1130;">So we won't prefer to embed the logic of creation of this instance in actual business logic and unnecessarily clutter the business logic flow Instead It would be good to have a dedicated service which can build up this object and once prepared can return it to business logic . Thus actual business logic remains agnostic of all object creation complexities..</span><br />
<br />
<u><i><span style="color: #4c1130;">So how do we achieve that in Object oriented language . </span></i></u><br />
<br />
<br />
<span style="color: #4c1130;">Let us try to understand this with code. As usual I have written lot of System.out.println statements in the code to bring are execution flow steps in print statements . This code can be directly copied and executed .All steps of design pattern will be clearly written on console.</span><br />
<br />
<br />
<span style="color: #4c1130;">-----------------------------------------------------------------------------------------------</span><br />
<br />
<b><span style="color: #4c1130;"><u>//This is the Client class which basically place an order. Here this client first place an order of //commercial project and after it's successful delivery It approaches for residential project and //place an order for that. </u></span></b><br />
<!--[if gte mso 9]><xml> <o:OfficeDocumentSettings> <o:AllowPNG/> </o:OfficeDocumentSettings> </xml><![endif]--><br />
<!--[if gte mso 9]><xml> <w:WordDocument> <w:View>Normal</w:View> <w:Zoom>0</w:Zoom> <w:TrackMoves/> <w:TrackFormatting/> <w:PunctuationKerning/> <w:ValidateAgainstSchemas/> <w:SaveIfXMLInvalid>false</w:SaveIfXMLInvalid> <w:IgnoreMixedContent>false</w:IgnoreMixedContent> <w:AlwaysShowPlaceholderText>false</w:AlwaysShowPlaceholderText> <w:DoNotPromoteQF/> <w:LidThemeOther>EN-US</w:LidThemeOther> <w:LidThemeAsian>X-NONE</w:LidThemeAsian> <w:LidThemeComplexScript>X-NONE</w:LidThemeComplexScript> <w:Compatibility> <w:BreakWrappedTables/> <w:SnapToGridInCell/> <w:WrapTextWithPunct/> <w:UseAsianBreakRules/> <w:DontGrowAutofit/> <w:SplitPgBreakAndParaMark/> <w:EnableOpenTypeKerning/> <w:DontFlipMirrorIndents/> <w:OverrideTableStyleHps/> </w:Compatibility> <w:BrowserLevel>MicrosoftInternetExplorer4</w:BrowserLevel> <m:mathPr> <m:mathFont m:val="Cambria Math"/> <m:brkBin m:val="before"/> <m:brkBinSub m:val="--"/> <m:smallFrac m:val="off"/> <m:dispDef/> <m:lMargin m:val="0"/> <m:rMargin m:val="0"/> <m:defJc m:val="centerGroup"/> <m:wrapIndent m:val="1440"/> <m:intLim m:val="subSup"/> <m:naryLim m:val="undOvr"/> </m:mathPr></w:WordDocument> </xml><![endif]--><!--[if gte mso 9]><xml> <w:LatentStyles DefLockedState="false" DefUnhideWhenUsed="true"
DefSemiHidden="true" DefQFormat="false" DefPriority="99"
LatentStyleCount="267"> <w:LsdException Locked="false" Priority="0" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Normal"/> <w:LsdException Locked="false" Priority="9" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="heading 1"/> <w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 2"/> <w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 3"/> <w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 4"/> <w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 5"/> <w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 6"/> <w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 7"/> <w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 8"/> <w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 9"/> <w:LsdException Locked="false" Priority="39" Name="toc 1"/> <w:LsdException Locked="false" Priority="39" Name="toc 2"/> <w:LsdException Locked="false" Priority="39" Name="toc 3"/> <w:LsdException Locked="false" Priority="39" Name="toc 4"/> <w:LsdException Locked="false" Priority="39" Name="toc 5"/> <w:LsdException Locked="false" Priority="39" Name="toc 6"/> <w:LsdException Locked="false" Priority="39" Name="toc 7"/> <w:LsdException Locked="false" Priority="39" Name="toc 8"/> <w:LsdException Locked="false" Priority="39" Name="toc 9"/> <w:LsdException Locked="false" Priority="35" QFormat="true" Name="caption"/> <w:LsdException Locked="false" Priority="10" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Title"/> <w:LsdException Locked="false" Priority="1" Name="Default Paragraph Font"/> <w:LsdException Locked="false" Priority="11" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Subtitle"/> <w:LsdException Locked="false" Priority="22" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Strong"/> <w:LsdException Locked="false" Priority="20" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Emphasis"/> <w:LsdException Locked="false" Priority="59" SemiHidden="false"
UnhideWhenUsed="false" Name="Table Grid"/> <w:LsdException Locked="false" UnhideWhenUsed="false" Name="Placeholder Text"/> <w:LsdException Locked="false" Priority="1" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="No Spacing"/> <w:LsdException Locked="false" Priority="60" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Shading"/> <w:LsdException Locked="false" Priority="61" SemiHidden="false"
UnhideWhenUsed="false" Name="Light List"/> <w:LsdException Locked="false" Priority="62" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Grid"/> <w:LsdException Locked="false" Priority="63" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 1"/> <w:LsdException Locked="false" Priority="64" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 2"/> <w:LsdException Locked="false" Priority="65" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 1"/> <w:LsdException Locked="false" Priority="66" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 2"/> <w:LsdException Locked="false" Priority="67" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 1"/> <w:LsdException Locked="false" Priority="68" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 2"/> <w:LsdException Locked="false" Priority="69" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 3"/> <w:LsdException Locked="false" Priority="70" SemiHidden="false"
UnhideWhenUsed="false" Name="Dark List"/> <w:LsdException Locked="false" Priority="71" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Shading"/> <w:LsdException Locked="false" Priority="72" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful List"/> <w:LsdException Locked="false" Priority="73" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Grid"/> <w:LsdException Locked="false" Priority="60" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Shading Accent 1"/> <w:LsdException Locked="false" Priority="61" SemiHidden="false"
UnhideWhenUsed="false" Name="Light List Accent 1"/> <w:LsdException Locked="false" Priority="62" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Grid Accent 1"/> <w:LsdException Locked="false" Priority="63" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 1 Accent 1"/> <w:LsdException Locked="false" Priority="64" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 2 Accent 1"/> <w:LsdException Locked="false" Priority="65" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 1 Accent 1"/> <w:LsdException Locked="false" UnhideWhenUsed="false" Name="Revision"/> <w:LsdException Locked="false" Priority="34" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="List Paragraph"/> <w:LsdException Locked="false" Priority="29" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Quote"/> <w:LsdException Locked="false" Priority="30" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Intense Quote"/> <w:LsdException Locked="false" Priority="66" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 2 Accent 1"/> <w:LsdException Locked="false" Priority="67" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 1 Accent 1"/> <w:LsdException Locked="false" Priority="68" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 2 Accent 1"/> <w:LsdException Locked="false" Priority="69" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 3 Accent 1"/> <w:LsdException Locked="false" Priority="70" SemiHidden="false"
UnhideWhenUsed="false" Name="Dark List Accent 1"/> <w:LsdException Locked="false" Priority="71" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Shading Accent 1"/> <w:LsdException Locked="false" Priority="72" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful List Accent 1"/> <w:LsdException Locked="false" Priority="73" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Grid Accent 1"/> <w:LsdException Locked="false" Priority="60" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Shading Accent 2"/> <w:LsdException Locked="false" Priority="61" SemiHidden="false"
UnhideWhenUsed="false" Name="Light List Accent 2"/> <w:LsdException Locked="false" Priority="62" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Grid Accent 2"/> <w:LsdException Locked="false" Priority="63" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 1 Accent 2"/> <w:LsdException Locked="false" Priority="64" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 2 Accent 2"/> <w:LsdException Locked="false" Priority="65" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 1 Accent 2"/> <w:LsdException Locked="false" Priority="66" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 2 Accent 2"/> <w:LsdException Locked="false" Priority="67" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 1 Accent 2"/> <w:LsdException Locked="false" Priority="68" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 2 Accent 2"/> <w:LsdException Locked="false" Priority="69" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 3 Accent 2"/> <w:LsdException Locked="false" Priority="70" SemiHidden="false"
UnhideWhenUsed="false" Name="Dark List Accent 2"/> <w:LsdException Locked="false" Priority="71" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Shading Accent 2"/> <w:LsdException Locked="false" Priority="72" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful List Accent 2"/> <w:LsdException Locked="false" Priority="73" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Grid Accent 2"/> <w:LsdException Locked="false" Priority="60" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Shading Accent 3"/> <w:LsdException Locked="false" Priority="61" SemiHidden="false"
UnhideWhenUsed="false" Name="Light List Accent 3"/> <w:LsdException Locked="false" Priority="62" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Grid Accent 3"/> <w:LsdException Locked="false" Priority="63" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 1 Accent 3"/> <w:LsdException Locked="false" Priority="64" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 2 Accent 3"/> <w:LsdException Locked="false" Priority="65" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 1 Accent 3"/> <w:LsdException Locked="false" Priority="66" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 2 Accent 3"/> <w:LsdException Locked="false" Priority="67" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 1 Accent 3"/> <w:LsdException Locked="false" Priority="68" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 2 Accent 3"/> <w:LsdException Locked="false" Priority="69" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 3 Accent 3"/> <w:LsdException Locked="false" Priority="70" SemiHidden="false"
UnhideWhenUsed="false" Name="Dark List Accent 3"/> <w:LsdException Locked="false" Priority="71" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Shading Accent 3"/> <w:LsdException Locked="false" Priority="72" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful List Accent 3"/> <w:LsdException Locked="false" Priority="73" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Grid Accent 3"/> <w:LsdException Locked="false" Priority="60" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Shading Accent 4"/> <w:LsdException Locked="false" Priority="61" SemiHidden="false"
UnhideWhenUsed="false" Name="Light List Accent 4"/> <w:LsdException Locked="false" Priority="62" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Grid Accent 4"/> <w:LsdException Locked="false" Priority="63" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 1 Accent 4"/> <w:LsdException Locked="false" Priority="64" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 2 Accent 4"/> <w:LsdException Locked="false" Priority="65" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 1 Accent 4"/> <w:LsdException Locked="false" Priority="66" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 2 Accent 4"/> <w:LsdException Locked="false" Priority="67" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 1 Accent 4"/> <w:LsdException Locked="false" Priority="68" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 2 Accent 4"/> <w:LsdException Locked="false" Priority="69" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 3 Accent 4"/> <w:LsdException Locked="false" Priority="70" SemiHidden="false"
UnhideWhenUsed="false" Name="Dark List Accent 4"/> <w:LsdException Locked="false" Priority="71" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Shading Accent 4"/> <w:LsdException Locked="false" Priority="72" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful List Accent 4"/> <w:LsdException Locked="false" Priority="73" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Grid Accent 4"/> <w:LsdException Locked="false" Priority="60" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Shading Accent 5"/> <w:LsdException Locked="false" Priority="61" SemiHidden="false"
UnhideWhenUsed="false" Name="Light List Accent 5"/> <w:LsdException Locked="false" Priority="62" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Grid Accent 5"/> <w:LsdException Locked="false" Priority="63" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 1 Accent 5"/> <w:LsdException Locked="false" Priority="64" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 2 Accent 5"/> <w:LsdException Locked="false" Priority="65" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 1 Accent 5"/> <w:LsdException Locked="false" Priority="66" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 2 Accent 5"/> <w:LsdException Locked="false" Priority="67" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 1 Accent 5"/> <w:LsdException Locked="false" Priority="68" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 2 Accent 5"/> <w:LsdException Locked="false" Priority="69" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 3 Accent 5"/> <w:LsdException Locked="false" Priority="70" SemiHidden="false"
UnhideWhenUsed="false" Name="Dark List Accent 5"/> <w:LsdException Locked="false" Priority="71" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Shading Accent 5"/> <w:LsdException Locked="false" Priority="72" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful List Accent 5"/> <w:LsdException Locked="false" Priority="73" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Grid Accent 5"/> <w:LsdException Locked="false" Priority="60" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Shading Accent 6"/> <w:LsdException Locked="false" Priority="61" SemiHidden="false"
UnhideWhenUsed="false" Name="Light List Accent 6"/> <w:LsdException Locked="false" Priority="62" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Grid Accent 6"/> <w:LsdException Locked="false" Priority="63" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 1 Accent 6"/> <w:LsdException Locked="false" Priority="64" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 2 Accent 6"/> <w:LsdException Locked="false" Priority="65" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 1 Accent 6"/> <w:LsdException Locked="false" Priority="66" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 2 Accent 6"/> <w:LsdException Locked="false" Priority="67" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 1 Accent 6"/> <w:LsdException Locked="false" Priority="68" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 2 Accent 6"/> <w:LsdException Locked="false" Priority="69" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 3 Accent 6"/> <w:LsdException Locked="false" Priority="70" SemiHidden="false"
UnhideWhenUsed="false" Name="Dark List Accent 6"/> <w:LsdException Locked="false" Priority="71" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Shading Accent 6"/> <w:LsdException Locked="false" Priority="72" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful List Accent 6"/> <w:LsdException Locked="false" Priority="73" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Grid Accent 6"/> <w:LsdException Locked="false" Priority="19" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Subtle Emphasis"/> <w:LsdException Locked="false" Priority="21" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Intense Emphasis"/> <w:LsdException Locked="false" Priority="31" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Subtle Reference"/> <w:LsdException Locked="false" Priority="32" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Intense Reference"/> <w:LsdException Locked="false" Priority="33" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Book Title"/> <w:LsdException Locked="false" Priority="37" Name="Bibliography"/> <w:LsdException Locked="false" Priority="39" QFormat="true" Name="TOC Heading"/> </w:LatentStyles> </xml><![endif]--><!--[if gte mso 10]> <style>
/* Style Definitions */
table.MsoNormalTable
{mso-style-name:"Table Normal";
mso-tstyle-rowband-size:0;
mso-tstyle-colband-size:0;
mso-style-noshow:yes;
mso-style-priority:99;
mso-style-parent:"";
mso-padding-alt:0in 5.4pt 0in 5.4pt;
mso-para-margin:0in;
mso-para-margin-bottom:.0001pt;
mso-pagination:widow-orphan;
font-size:10.0pt;
font-family:"Calibri","sans-serif";
mso-ascii-font-family:Calibri;
mso-ascii-theme-font:minor-latin;
mso-hansi-font-family:Calibri;
mso-hansi-theme-font:minor-latin;
mso-bidi-font-family:"Times New Roman";
mso-bidi-theme-font:minor-bidi;}
</style> <![endif]--><b><span style="color: #4c1130;"> </span></b><br />
<div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;">
<br /></div>
<div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;">
<b><span style="color: #7f0055; font-family: Consolas; font-size: 10.0pt;">package</span></b><span style="color: black; font-family: Consolas; font-size: 10.0pt;"> realEstate;</span><span style="font-family: Consolas; font-size: 10.0pt;"></span></div>
<div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;">
<br /></div>
<div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;">
<b><span style="color: #7f0055; font-family: Consolas; font-size: 10.0pt;">public</span></b><span style="color: black; font-family: Consolas; font-size: 10.0pt;"> </span><b><span style="color: #7f0055; font-family: Consolas; font-size: 10.0pt;">class</span></b><span style="color: black; font-family: Consolas; font-size: 10.0pt;"> Client {</span><span style="font-family: Consolas; font-size: 10.0pt;"></span></div>
<div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;">
<br /></div>
<div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;">
<span style="color: black; font-family: Consolas; font-size: 10.0pt;"><span style="mso-spacerun: yes;"> </span></span><span style="color: #3f5fbf; font-family: Consolas; font-size: 10.0pt;">/**</span><span style="font-family: Consolas; font-size: 10.0pt;"></span></div>
<div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;">
<span style="color: #3f5fbf; font-family: Consolas; font-size: 10.0pt;"><span style="mso-spacerun: yes;"> </span>* </span><b><span style="color: #7f9fbf; font-family: Consolas; font-size: 10.0pt;">@param</span></b><span style="color: #3f5fbf; font-family: Consolas; font-size: 10.0pt;"> args</span><span style="font-family: Consolas; font-size: 10.0pt;"></span></div>
<div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;">
<span style="color: #3f5fbf; font-family: Consolas; font-size: 10.0pt;"><span style="mso-spacerun: yes;"> </span>*/</span><span style="font-family: Consolas; font-size: 10.0pt;"></span></div>
<div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;">
<span style="color: black; font-family: Consolas; font-size: 10.0pt;"><span style="mso-spacerun: yes;"> </span></span><b><span style="color: #7f0055; font-family: Consolas; font-size: 10.0pt;">public</span></b><span style="color: black; font-family: Consolas; font-size: 10.0pt;"> </span><b><span style="color: #7f0055; font-family: Consolas; font-size: 10.0pt;">static</span></b><span style="color: black; font-family: Consolas; font-size: 10.0pt;"> </span><b><span style="color: #7f0055; font-family: Consolas; font-size: 10.0pt;">void</span></b><span style="color: black; font-family: Consolas; font-size: 10.0pt;"> main(String[] args) {</span><span style="font-family: Consolas; font-size: 10.0pt;"></span></div>
<div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;">
<span style="color: black; font-family: Consolas; font-size: 10.0pt;"><span style="mso-spacerun: yes;"> </span></span><span style="font-family: Consolas; font-size: 10.0pt;"></span></div>
<div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;">
<span style="color: black; font-family: Consolas; font-size: 10.0pt;"><span style="mso-spacerun: yes;"> </span>projectOwner owner=</span><b><span style="color: #7f0055; font-family: Consolas; font-size: 10.0pt;">new</span></b><span style="color: black; font-family: Consolas; font-size: 10.0pt;"> projectOwner(</span><b><span style="color: #7f0055; font-family: Consolas; font-size: 10.0pt;">new</span></b><span style="color: black; font-family: Consolas; font-size: 10.0pt;"> CommercialProjectBuilder());</span><span style="font-family: Consolas; font-size: 10.0pt;"></span></div>
<div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;">
<span style="color: black; font-family: Consolas; font-size: 10.0pt;"><span style="mso-spacerun: yes;"> </span>owner.placeRoder();</span><span style="font-family: Consolas; font-size: 10.0pt;"></span></div>
<div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;">
<span style="color: black; font-family: Consolas; font-size: 10.0pt;"><span style="mso-spacerun: yes;"> </span>owner.getProject();</span><span style="font-family: Consolas; font-size: 10.0pt;"></span></div>
<div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;">
<span style="color: black; font-family: Consolas; font-size: 10.0pt;"><span style="mso-spacerun: yes;"> </span>System.</span><i><span style="color: #0000c0; font-family: Consolas; font-size: 10.0pt;">out</span></i><span style="color: black; font-family: Consolas; font-size: 10.0pt;">.println(</span><span style="color: #2a00ff; font-family: Consolas; font-size: 10.0pt;">"CLIENT :::: Thank you for timely delivry of commerical project"</span><span style="color: black; font-family: Consolas; font-size: 10.0pt;">);</span><span style="font-family: Consolas; font-size: 10.0pt;"></span></div>
<div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;">
<span style="color: black; font-family: Consolas; font-size: 10.0pt;"><span style="mso-spacerun: yes;"> </span>System.</span><i><span style="color: #0000c0; font-family: Consolas; font-size: 10.0pt;">out</span></i><span style="color: black; font-family: Consolas; font-size: 10.0pt;">.println(</span><span style="color: #2a00ff; font-family: Consolas; font-size: 10.0pt;">"==============================================================="</span><span style="color: black; font-family: Consolas; font-size: 10.0pt;">);</span><span style="font-family: Consolas; font-size: 10.0pt;"></span></div>
<div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;">
<span style="color: black; font-family: Consolas; font-size: 10.0pt;"><span style="mso-spacerun: yes;"> </span>System.</span><i><span style="color: #0000c0; font-family: Consolas; font-size: 10.0pt;">out</span></i><span style="color: black; font-family: Consolas; font-size: 10.0pt;">.println(</span><span style="color: #2a00ff; font-family: Consolas; font-size: 10.0pt;">"CLIENT :::: Now let's deal in residenrial"</span><span style="color: black; font-family: Consolas; font-size: 10.0pt;">);</span><span style="font-family: Consolas; font-size: 10.0pt;"></span></div>
<div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;">
<span style="color: black; font-family: Consolas; font-size: 10.0pt;"><span style="mso-spacerun: yes;"> </span>owner=</span><b><span style="color: #7f0055; font-family: Consolas; font-size: 10.0pt;">new</span></b><span style="color: black; font-family: Consolas; font-size: 10.0pt;"> projectOwner(</span><b><span style="color: #7f0055; font-family: Consolas; font-size: 10.0pt;">new</span></b><span style="color: black; font-family: Consolas; font-size: 10.0pt;"> ResidentialProjectBuilder());</span><span style="font-family: Consolas; font-size: 10.0pt;"></span></div>
<div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;">
<span style="color: black; font-family: Consolas; font-size: 10.0pt;"><span style="mso-spacerun: yes;"> </span>owner.placeRoder();</span><span style="font-family: Consolas; font-size: 10.0pt;"></span></div>
<div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;">
<span style="color: black; font-family: Consolas; font-size: 10.0pt;"><span style="mso-spacerun: yes;"> </span>owner.getProject();</span><span style="font-family: Consolas; font-size: 10.0pt;"></span></div>
<div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;">
<span style="color: black; font-family: Consolas; font-size: 10.0pt;"><span style="mso-spacerun: yes;"> </span>System.</span><i><span style="color: #0000c0; font-family: Consolas; font-size: 10.0pt;">out</span></i><span style="color: black; font-family: Consolas; font-size: 10.0pt;">.println(</span><span style="color: #2a00ff; font-family: Consolas; font-size: 10.0pt;">"CLIENT :::: Thank you for timely delivry of Residential project.. Rocking performance"</span><span style="color: black; font-family: Consolas; font-size: 10.0pt;">);</span><span style="font-family: Consolas; font-size: 10.0pt;"></span></div>
<div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;">
<span style="color: black; font-family: Consolas; font-size: 10.0pt;"><span style="mso-spacerun: yes;"> </span>}</span><span style="font-family: Consolas; font-size: 10.0pt;"></span></div>
<div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;">
<br /></div>
<div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;">
<span style="color: black; font-family: Consolas; font-size: 10.0pt;">}</span><span style="font-family: Consolas; font-size: 10.0pt;"></span></div>
<div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;">
<br /></div>
<div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: Consolas; font-size: 10.0pt;"><u><span style="font-family: Arial,Helvetica,sans-serif;"><b>// This is project Owner . Client passes the type of project It is looking for : commercial or residential //and creates Project Owner instance . Owner will further place order of construction to Commercial //or Residential department based of which object is passed by client </b></span></u></span></div>
<div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;">
</div>
<div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;">
<b><span style="color: #7f0055; font-family: Consolas; font-size: 10.0pt;">class</span></b><span style="color: black; font-family: Consolas; font-size: 10.0pt;"> projectOwner{</span><span style="font-family: Consolas; font-size: 10.0pt;"></span></div>
<div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;">
<span style="color: black; font-family: Consolas; font-size: 10.0pt;"><span style="mso-spacerun: yes;"> </span>ProjectBuiding </span><span style="color: #0000c0; font-family: Consolas; font-size: 10.0pt;">building</span><span style="color: black; font-family: Consolas; font-size: 10.0pt;">;</span><span style="font-family: Consolas; font-size: 10.0pt;"></span></div>
<div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;">
<span style="color: black; font-family: Consolas; font-size: 10.0pt;"><span style="mso-spacerun: yes;"> </span>projectOwner(ProjectBuiding building){</span><span style="font-family: Consolas; font-size: 10.0pt;"></span></div>
<div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;">
<span style="color: black; font-family: Consolas; font-size: 10.0pt;"><span style="mso-spacerun: yes;"> </span></span><b><span style="color: #7f0055; font-family: Consolas; font-size: 10.0pt;">this</span></b><span style="color: black; font-family: Consolas; font-size: 10.0pt;">.</span><span style="color: #0000c0; font-family: Consolas; font-size: 10.0pt;">building</span><span style="color: black; font-family: Consolas; font-size: 10.0pt;">=building;</span><span style="font-family: Consolas; font-size: 10.0pt;"></span></div>
<div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;">
<span style="color: black; font-family: Consolas; font-size: 10.0pt;"><span style="mso-spacerun: yes;"> </span>}</span><span style="font-family: Consolas; font-size: 10.0pt;"></span></div>
<div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;">
<span style="color: black; font-family: Consolas; font-size: 10.0pt;"><span style="mso-spacerun: yes;"> </span></span><span style="font-family: Consolas; font-size: 10.0pt;"></span></div>
<div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;">
<span style="color: black; font-family: Consolas; font-size: 10.0pt;"><span style="mso-spacerun: yes;"> </span></span><b><span style="color: #7f0055; font-family: Consolas; font-size: 10.0pt;">void</span></b><span style="color: black; font-family: Consolas; font-size: 10.0pt;"><span style="mso-spacerun: yes;"> </span>placeRoder(){</span><span style="font-family: Consolas; font-size: 10.0pt;"></span></div>
<div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;">
<span style="color: black; font-family: Consolas; font-size: 10.0pt;"><span style="mso-spacerun: yes;"> </span></span><span style="color: #0000c0; font-family: Consolas; font-size: 10.0pt;">building</span><span style="color: black; font-family: Consolas; font-size: 10.0pt;">.constructBase();</span><span style="font-family: Consolas; font-size: 10.0pt;"></span></div>
<div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;">
<span style="color: black; font-family: Consolas; font-size: 10.0pt;"><span style="mso-spacerun: yes;"> </span></span><span style="color: #0000c0; font-family: Consolas; font-size: 10.0pt;">building</span><span style="color: black; font-family: Consolas; font-size: 10.0pt;">.constructFloors();</span><span style="font-family: Consolas; font-size: 10.0pt;"></span></div>
<div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;">
<span style="color: black; font-family: Consolas; font-size: 10.0pt;"><span style="mso-spacerun: yes;"> </span></span><span style="color: #0000c0; font-family: Consolas; font-size: 10.0pt;">building</span><span style="color: black; font-family: Consolas; font-size: 10.0pt;">.doFinishing();</span><span style="font-family: Consolas; font-size: 10.0pt;"></span></div>
<div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;">
<span style="color: black; font-family: Consolas; font-size: 10.0pt;"><span style="mso-spacerun: yes;"> </span></span><span style="color: #0000c0; font-family: Consolas; font-size: 10.0pt;">building</span><span style="color: black; font-family: Consolas; font-size: 10.0pt;">.decorate();</span><span style="font-family: Consolas; font-size: 10.0pt;"></span></div>
<div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;">
<br /></div>
<div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;">
<span style="color: black; font-family: Consolas; font-size: 10.0pt;"><span style="mso-spacerun: yes;"> </span>}</span><span style="font-family: Consolas; font-size: 10.0pt;"></span></div>
<div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;">
<span style="color: black; font-family: Consolas; font-size: 10.0pt;"><span style="mso-spacerun: yes;"> </span></span><span style="font-family: Consolas; font-size: 10.0pt;"></span></div>
<div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;">
<span style="color: black; font-family: Consolas; font-size: 10.0pt;"><span style="mso-spacerun: yes;"> </span>ProjectBuiding<span style="mso-spacerun: yes;"> </span>getProject(){</span><span style="font-family: Consolas; font-size: 10.0pt;"></span></div>
<div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;">
<span style="color: black; font-family: Consolas; font-size: 10.0pt;"><span style="mso-spacerun: yes;"> </span></span><b><span style="color: #7f0055; font-family: Consolas; font-size: 10.0pt;">return</span></b><span style="color: black; font-family: Consolas; font-size: 10.0pt;"> </span><span style="color: #0000c0; font-family: Consolas; font-size: 10.0pt;">building</span><span style="color: black; font-family: Consolas; font-size: 10.0pt;">;</span><span style="font-family: Consolas; font-size: 10.0pt;"></span></div>
<div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;">
<span style="color: black; font-family: Consolas; font-size: 10.0pt;"><span style="mso-spacerun: yes;"> </span>}</span><span style="font-family: Consolas; font-size: 10.0pt;"></span></div>
<div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;">
<span style="color: black; font-family: Consolas; font-size: 10.0pt;"><span style="mso-spacerun: yes;"> </span></span><span style="font-family: Consolas; font-size: 10.0pt;"></span></div>
<div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;">
<span style="color: black; font-family: Consolas; font-size: 10.0pt;"><span style="mso-spacerun: yes;"> </span></span><span style="font-family: Consolas; font-size: 10.0pt;"></span></div>
<div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;">
<span style="color: black; font-family: Consolas; font-size: 10.0pt;">}</span><span style="font-family: Consolas; font-size: 10.0pt;"></span></div>
<div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;">
<br /></div>
<div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: Arial,Helvetica,sans-serif;"><u><b><span style="font-size: 10pt;">// Interface for Residential and commercial project builder classes </span></b></u></span></div>
<div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;">
</div>
<div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;">
<b><span style="color: #7f0055; font-family: Consolas; font-size: 10.0pt;">interface</span></b><span style="color: black; font-family: Consolas; font-size: 10.0pt;"> ProjectBuiding{</span><span style="font-family: Consolas; font-size: 10.0pt;"></span></div>
<div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;">
<span style="color: black; font-family: Consolas; font-size: 10.0pt;"><span style="mso-spacerun: yes;"> </span></span><span style="font-family: Consolas; font-size: 10.0pt;"></span></div>
<div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;">
<span style="color: black; font-family: Consolas; font-size: 10.0pt;"><span style="mso-spacerun: yes;"> </span></span><span style="font-family: Consolas; font-size: 10.0pt;"></span></div>
<div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;">
<span style="color: black; font-family: Consolas; font-size: 10.0pt;"><span style="mso-spacerun: yes;"> </span></span><span style="font-family: Consolas; font-size: 10.0pt;"></span></div>
<div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;">
<span style="color: black; font-family: Consolas; font-size: 10.0pt;"><span style="mso-spacerun: yes;"> </span></span><b><span style="color: #7f0055; font-family: Consolas; font-size: 10.0pt;">void</span></b><span style="color: black; font-family: Consolas; font-size: 10.0pt;"> constructBase();</span><span style="font-family: Consolas; font-size: 10.0pt;"></span></div>
<div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;">
<span style="color: black; font-family: Consolas; font-size: 10.0pt;"><span style="mso-spacerun: yes;"> </span></span><span style="font-family: Consolas; font-size: 10.0pt;"></span></div>
<div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;">
<span style="color: black; font-family: Consolas; font-size: 10.0pt;"><span style="mso-spacerun: yes;"> </span></span><b><span style="color: #7f0055; font-family: Consolas; font-size: 10.0pt;">void</span></b><span style="color: black; font-family: Consolas; font-size: 10.0pt;"> constructFloors();</span><span style="font-family: Consolas; font-size: 10.0pt;"></span></div>
<div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;">
<span style="color: black; font-family: Consolas; font-size: 10.0pt;"><span style="mso-spacerun: yes;"> </span></span><span style="font-family: Consolas; font-size: 10.0pt;"></span></div>
<div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;">
<span style="color: black; font-family: Consolas; font-size: 10.0pt;"><span style="mso-spacerun: yes;"> </span></span><b><span style="color: #7f0055; font-family: Consolas; font-size: 10.0pt;">void</span></b><span style="color: black; font-family: Consolas; font-size: 10.0pt;"> doFinishing();</span><span style="font-family: Consolas; font-size: 10.0pt;"></span></div>
<div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;">
<span style="color: black; font-family: Consolas; font-size: 10.0pt;"><span style="mso-spacerun: yes;"> </span></span><span style="font-family: Consolas; font-size: 10.0pt;"></span></div>
<div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;">
<span style="color: black; font-family: Consolas; font-size: 10.0pt;"><span style="mso-spacerun: yes;"> </span></span><b><span style="color: #7f0055; font-family: Consolas; font-size: 10.0pt;">void</span></b><span style="color: black; font-family: Consolas; font-size: 10.0pt;"> decorate();</span><span style="font-family: Consolas; font-size: 10.0pt;"></span></div>
<div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;">
<span style="color: black; font-family: Consolas; font-size: 10.0pt;"><span style="mso-spacerun: yes;"> </span></span><span style="font-family: Consolas; font-size: 10.0pt;"></span></div>
<div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;">
<span style="color: black; font-family: Consolas; font-size: 10.0pt;"><span style="mso-spacerun: yes;"> </span></span><span style="font-family: Consolas; font-size: 10.0pt;"></span></div>
<div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;">
<span style="color: black; font-family: Consolas; font-size: 10.0pt;">}</span><span style="font-family: Consolas; font-size: 10.0pt;"></span></div>
<div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;">
<br /></div>
<div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: Arial,Helvetica,sans-serif;"><u><b><span style="font-size: 10pt;">// entire process and logic of building a residential project is encapsulated in this class</span></b></u></span></div>
<div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;">
</div>
<div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;">
<b><span style="color: #7f0055; font-family: Consolas; font-size: 10.0pt;">class</span></b><span style="color: black; font-family: Consolas; font-size: 10.0pt;"> ResidentialProjectBuilder </span><b><span style="color: #7f0055; font-family: Consolas; font-size: 10.0pt;">implements</span></b><span style="color: black; font-family: Consolas; font-size: 10.0pt;"> ProjectBuiding {</span><span style="font-family: Consolas; font-size: 10.0pt;"></span></div>
<div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;">
<span style="color: black; font-family: Consolas; font-size: 10.0pt;"><span style="mso-spacerun: yes;"> </span></span><span style="font-family: Consolas; font-size: 10.0pt;"></span></div>
<div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;">
<span style="color: black; font-family: Consolas; font-size: 10.0pt;"><span style="mso-spacerun: yes;"> </span>ResidentialProjectBuilder(){</span><span style="font-family: Consolas; font-size: 10.0pt;"></span></div>
<div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;">
<span style="color: black; font-family: Consolas; font-size: 10.0pt;"><span style="mso-spacerun: yes;"> </span>System.</span><i><span style="color: #0000c0; font-family: Consolas; font-size: 10.0pt;">out</span></i><span style="color: black; font-family: Consolas; font-size: 10.0pt;">.println(</span><span style="color: #2a00ff; font-family: Consolas; font-size: 10.0pt;">"ResidentialProjectBuilder:::Thank you for reaching us..We deal in Residential Projects.."</span><span style="color: black; font-family: Consolas; font-size: 10.0pt;">);</span><span style="font-family: Consolas; font-size: 10.0pt;"></span></div>
<div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;">
<span style="color: black; font-family: Consolas; font-size: 10.0pt;"><span style="mso-spacerun: yes;"> </span>}</span><span style="font-family: Consolas; font-size: 10.0pt;"></span></div>
<div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;">
<br /></div>
<div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;">
<span style="color: black; font-family: Consolas; font-size: 10.0pt;"><span style="mso-spacerun: yes;"> </span></span><b><span style="color: #7f0055; font-family: Consolas; font-size: 10.0pt;">public</span></b><span style="color: black; font-family: Consolas; font-size: 10.0pt;"> </span><b><span style="color: #7f0055; font-family: Consolas; font-size: 10.0pt;">void</span></b><span style="color: black; font-family: Consolas; font-size: 10.0pt;"> constructBase() {</span><span style="font-family: Consolas; font-size: 10.0pt;"></span></div>
<div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;">
<span style="color: black; font-family: Consolas; font-size: 10.0pt;"><span style="mso-spacerun: yes;"> </span></span><span style="font-family: Consolas; font-size: 10.0pt;"></span></div>
<div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;">
<span style="color: black; font-family: Consolas; font-size: 10.0pt;"><span style="mso-spacerun: yes;"> </span>System.</span><i><span style="color: #0000c0; font-family: Consolas; font-size: 10.0pt;">out</span></i><span style="color: black; font-family: Consolas; font-size: 10.0pt;">.println(</span><span style="color: #2a00ff; font-family: Consolas; font-size: 10.0pt;">"ResidentialProjectBuilder:::Construction is already started.. Promise to deliver on time "</span><span style="color: black; font-family: Consolas; font-size: 10.0pt;">);</span><span style="font-family: Consolas; font-size: 10.0pt;"></span></div>
<div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;">
<span style="color: black; font-family: Consolas; font-size: 10.0pt;"><span style="mso-spacerun: yes;"> </span>}</span><span style="font-family: Consolas; font-size: 10.0pt;"></span></div>
<div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;">
<br /></div>
<div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;">
<span style="color: black; font-family: Consolas; font-size: 10.0pt;"><span style="mso-spacerun: yes;"> </span></span><b><span style="color: #7f0055; font-family: Consolas; font-size: 10.0pt;">public</span></b><span style="color: black; font-family: Consolas; font-size: 10.0pt;"> </span><b><span style="color: #7f0055; font-family: Consolas; font-size: 10.0pt;">void</span></b><span style="color: black; font-family: Consolas; font-size: 10.0pt;"> constructFloors() {</span><span style="font-family: Consolas; font-size: 10.0pt;"></span></div>
<div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;">
<span style="color: black; font-family: Consolas; font-size: 10.0pt;"><span style="mso-spacerun: yes;"> </span>System.</span><i><span style="color: #0000c0; font-family: Consolas; font-size: 10.0pt;">out</span></i><span style="color: black; font-family: Consolas; font-size: 10.0pt;">.println(</span><span style="color: #2a00ff; font-family: Consolas; font-size: 10.0pt;">"ResidentialProjectBuilder::::Construction is on full Swing.. Pay installments timely "</span><span style="color: black; font-family: Consolas; font-size: 10.0pt;">);</span><span style="font-family: Consolas; font-size: 10.0pt;"></span></div>
<div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;">
<span style="color: black; font-family: Consolas; font-size: 10.0pt;"><span style="mso-spacerun: yes;"> </span></span><span style="font-family: Consolas; font-size: 10.0pt;"></span></div>
<div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;">
<span style="color: black; font-family: Consolas; font-size: 10.0pt;"><span style="mso-spacerun: yes;"> </span>}</span><span style="font-family: Consolas; font-size: 10.0pt;"></span></div>
<div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;">
<br /></div>
<div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;">
<span style="color: black; font-family: Consolas; font-size: 10.0pt;"><span style="mso-spacerun: yes;"> </span></span><b><span style="color: #7f0055; font-family: Consolas; font-size: 10.0pt;">public</span></b><span style="color: black; font-family: Consolas; font-size: 10.0pt;"> </span><b><span style="color: #7f0055; font-family: Consolas; font-size: 10.0pt;">void</span></b><span style="color: black; font-family: Consolas; font-size: 10.0pt;"> doFinishing() {</span><span style="font-family: Consolas; font-size: 10.0pt;"></span></div>
<div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;">
<span style="color: black; font-family: Consolas; font-size: 10.0pt;"><span style="mso-spacerun: yes;"> </span>System.</span><i><span style="color: #0000c0; font-family: Consolas; font-size: 10.0pt;">out</span></i><span style="color: black; font-family: Consolas; font-size: 10.0pt;">.println(</span><span style="color: #2a00ff; font-family: Consolas; font-size: 10.0pt;">"ResidentialProjectBuilder::::About to deliver .. Have litte more Patience "</span><span style="color: black; font-family: Consolas; font-size: 10.0pt;">);</span><span style="font-family: Consolas; font-size: 10.0pt;"></span></div>
<div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;">
<span style="color: black; font-family: Consolas; font-size: 10.0pt;"><span style="mso-spacerun: yes;"> </span></span><span style="font-family: Consolas; font-size: 10.0pt;"></span></div>
<div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;">
<span style="color: black; font-family: Consolas; font-size: 10.0pt;"><span style="mso-spacerun: yes;"> </span>}</span><span style="font-family: Consolas; font-size: 10.0pt;"></span></div>
<div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;">
<br /></div>
<div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;">
<span style="color: black; font-family: Consolas; font-size: 10.0pt;"><span style="mso-spacerun: yes;"> </span></span><b><span style="color: #7f0055; font-family: Consolas; font-size: 10.0pt;">public</span></b><span style="color: black; font-family: Consolas; font-size: 10.0pt;"> </span><b><span style="color: #7f0055; font-family: Consolas; font-size: 10.0pt;">void</span></b><span style="color: black; font-family: Consolas; font-size: 10.0pt;"> decorate() {</span><span style="font-family: Consolas; font-size: 10.0pt;"></span></div>
<div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;">
<span style="color: black; font-family: Consolas; font-size: 10.0pt;"><span style="mso-spacerun: yes;"> </span>System.</span><i><span style="color: #0000c0; font-family: Consolas; font-size: 10.0pt;">out</span></i><span style="color: black; font-family: Consolas; font-size: 10.0pt;">.println(</span><span style="color: #2a00ff; font-family: Consolas; font-size: 10.0pt;">"ResidentialProjectBuilder:::IT is well decorated.. Ready to move"</span><span style="color: black; font-family: Consolas; font-size: 10.0pt;">);</span><span style="font-family: Consolas; font-size: 10.0pt;"></span></div>
<div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;">
<span style="color: black; font-family: Consolas; font-size: 10.0pt;"><span style="mso-spacerun: yes;"> </span></span><span style="font-family: Consolas; font-size: 10.0pt;"></span></div>
<div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;">
<span style="color: black; font-family: Consolas; font-size: 10.0pt;"><span style="mso-spacerun: yes;"> </span>}</span><span style="font-family: Consolas; font-size: 10.0pt;"></span></div>
<div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;">
<span style="color: black; font-family: Consolas; font-size: 10.0pt;"><span style="mso-spacerun: yes;"> </span></span><span style="font-family: Consolas; font-size: 10.0pt;"></span></div>
<div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;">
<span style="color: black; font-family: Consolas; font-size: 10.0pt;">}</span></div>
<div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;">
<br /></div>
<br />
<div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: Arial,Helvetica,sans-serif;"><b><span style="font-size: 10pt;">// entire process and logic of building a Commercial project is encapsulated in this class</span></b></span></div>
<br />
<div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;">
<br /></div>
<div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;">
<b><span style="color: #7f0055; font-family: Consolas; font-size: 10.0pt;">class</span></b><span style="color: black; font-family: Consolas; font-size: 10.0pt;"> CommercialProjectBuilder </span><b><span style="color: #7f0055; font-family: Consolas; font-size: 10.0pt;">implements</span></b><span style="color: black; font-family: Consolas; font-size: 10.0pt;"> ProjectBuiding{</span><span style="font-family: Consolas; font-size: 10.0pt;"></span></div>
<div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;">
<br /></div>
<div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;">
<span style="color: black; font-family: Consolas; font-size: 10.0pt;"><span style="mso-spacerun: yes;"> </span>CommercialProjectBuilder(){</span><span style="font-family: Consolas; font-size: 10.0pt;"></span></div>
<div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;">
<span style="color: black; font-family: Consolas; font-size: 10.0pt;"><span style="mso-spacerun: yes;"> </span>System.</span><i><span style="color: #0000c0; font-family: Consolas; font-size: 10.0pt;">out</span></i><span style="color: black; font-family: Consolas; font-size: 10.0pt;">.println(</span><span style="color: #2a00ff; font-family: Consolas; font-size: 10.0pt;">"CommercialProjectBuilder ::: Thank you for reaching us..We deal in Commercial Projects.."</span><span style="color: black; font-family: Consolas; font-size: 10.0pt;">);</span><span style="font-family: Consolas; font-size: 10.0pt;"></span></div>
<div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;">
<span style="color: black; font-family: Consolas; font-size: 10.0pt;"><span style="mso-spacerun: yes;"> </span>}</span><span style="font-family: Consolas; font-size: 10.0pt;"></span></div>
<div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;">
<span style="color: black; font-family: Consolas; font-size: 10.0pt;"><span style="mso-spacerun: yes;"> </span></span><span style="font-family: Consolas; font-size: 10.0pt;"></span></div>
<div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;">
<span style="color: black; font-family: Consolas; font-size: 10.0pt;"><span style="mso-spacerun: yes;"> </span></span><b><span style="color: #7f0055; font-family: Consolas; font-size: 10.0pt;">public</span></b><span style="color: black; font-family: Consolas; font-size: 10.0pt;"> </span><b><span style="color: #7f0055; font-family: Consolas; font-size: 10.0pt;">void</span></b><span style="color: black; font-family: Consolas; font-size: 10.0pt;"> constructBase() {</span><span style="font-family: Consolas; font-size: 10.0pt;"></span></div>
<div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;">
<span style="color: black; font-family: Consolas; font-size: 10.0pt;"><span style="mso-spacerun: yes;"> </span>System.</span><i><span style="color: #0000c0; font-family: Consolas; font-size: 10.0pt;">out</span></i><span style="color: black; font-family: Consolas; font-size: 10.0pt;">.println(</span><span style="color: #2a00ff; font-family: Consolas; font-size: 10.0pt;">"CommercialProjectBuilder :::Construction is already started.. Promise to deliver on time .."</span><span style="color: black; font-family: Consolas; font-size: 10.0pt;">);</span><span style="font-family: Consolas; font-size: 10.0pt;"></span></div>
<div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;">
<span style="color: black; font-family: Consolas; font-size: 10.0pt;"><span style="mso-spacerun: yes;"> </span></span><span style="font-family: Consolas; font-size: 10.0pt;"></span></div>
<div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;">
<span style="color: black; font-family: Consolas; font-size: 10.0pt;"><span style="mso-spacerun: yes;"> </span>}</span><span style="font-family: Consolas; font-size: 10.0pt;"></span></div>
<div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;">
<br /></div>
<div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;">
<span style="color: black; font-family: Consolas; font-size: 10.0pt;"><span style="mso-spacerun: yes;"> </span></span><b><span style="color: #7f0055; font-family: Consolas; font-size: 10.0pt;">public</span></b><span style="color: black; font-family: Consolas; font-size: 10.0pt;"> </span><b><span style="color: #7f0055; font-family: Consolas; font-size: 10.0pt;">void</span></b><span style="color: black; font-family: Consolas; font-size: 10.0pt;"> constructFloors() {</span><span style="font-family: Consolas; font-size: 10.0pt;"></span></div>
<div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;">
<span style="color: black; font-family: Consolas; font-size: 10.0pt;"><span style="mso-spacerun: yes;"> </span>System.</span><i><span style="color: #0000c0; font-family: Consolas; font-size: 10.0pt;">out</span></i><span style="color: black; font-family: Consolas; font-size: 10.0pt;">.println(</span><span style="color: #2a00ff; font-family: Consolas; font-size: 10.0pt;">"CommercialProjectBuilder :::Construction is on full Swing.. Pay installments timely "</span><span style="color: black; font-family: Consolas; font-size: 10.0pt;">);</span><span style="font-family: Consolas; font-size: 10.0pt;"></span></div>
<div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;">
<span style="color: black; font-family: Consolas; font-size: 10.0pt;"><span style="mso-spacerun: yes;"> </span></span><span style="font-family: Consolas; font-size: 10.0pt;"></span></div>
<div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;">
<span style="color: black; font-family: Consolas; font-size: 10.0pt;"><span style="mso-spacerun: yes;"> </span>}</span><span style="font-family: Consolas; font-size: 10.0pt;"></span></div>
<div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;">
<br /></div>
<div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;">
<span style="color: black; font-family: Consolas; font-size: 10.0pt;"><span style="mso-spacerun: yes;"> </span></span><b><span style="color: #7f0055; font-family: Consolas; font-size: 10.0pt;">public</span></b><span style="color: black; font-family: Consolas; font-size: 10.0pt;"> </span><b><span style="color: #7f0055; font-family: Consolas; font-size: 10.0pt;">void</span></b><span style="color: black; font-family: Consolas; font-size: 10.0pt;"> doFinishing() {</span><span style="font-family: Consolas; font-size: 10.0pt;"></span></div>
<div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;">
<span style="color: black; font-family: Consolas; font-size: 10.0pt;"><span style="mso-spacerun: yes;"> </span>System.</span><i><span style="color: #0000c0; font-family: Consolas; font-size: 10.0pt;">out</span></i><span style="color: black; font-family: Consolas; font-size: 10.0pt;">.println(</span><span style="color: #2a00ff; font-family: Consolas; font-size: 10.0pt;">"CommercialProjectBuilder :::About to deliver .. Have litte more Patience "</span><span style="color: black; font-family: Consolas; font-size: 10.0pt;">);</span><span style="font-family: Consolas; font-size: 10.0pt;"></span></div>
<div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;">
<span style="color: black; font-family: Consolas; font-size: 10.0pt;"><span style="mso-spacerun: yes;"> </span></span><span style="font-family: Consolas; font-size: 10.0pt;"></span></div>
<div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;">
<span style="color: black; font-family: Consolas; font-size: 10.0pt;"><span style="mso-spacerun: yes;"> </span>}</span><span style="font-family: Consolas; font-size: 10.0pt;"></span></div>
<div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;">
<br /></div>
<div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;">
<span style="color: black; font-family: Consolas; font-size: 10.0pt;"><span style="mso-spacerun: yes;"> </span></span><b><span style="color: #7f0055; font-family: Consolas; font-size: 10.0pt;">public</span></b><span style="color: black; font-family: Consolas; font-size: 10.0pt;"> </span><b><span style="color: #7f0055; font-family: Consolas; font-size: 10.0pt;">void</span></b><span style="color: black; font-family: Consolas; font-size: 10.0pt;"> decorate() {</span><span style="font-family: Consolas; font-size: 10.0pt;"></span></div>
<div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;">
<span style="color: black; font-family: Consolas; font-size: 10.0pt;"><span style="mso-spacerun: yes;"> </span>System.</span><i><span style="color: #0000c0; font-family: Consolas; font-size: 10.0pt;">out</span></i><span style="color: black; font-family: Consolas; font-size: 10.0pt;">.println(</span><span style="color: #2a00ff; font-family: Consolas; font-size: 10.0pt;">"CommercialProjectBuilder :::IT is well decorated.. Ready to move"</span><span style="color: black; font-family: Consolas; font-size: 10.0pt;">);</span><span style="font-family: Consolas; font-size: 10.0pt;"></span></div>
<div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;">
<span style="color: black; font-family: Consolas; font-size: 10.0pt;"><span style="mso-spacerun: yes;"> </span></span><span style="font-family: Consolas; font-size: 10.0pt;"></span></div>
<div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;">
<span style="color: black; font-family: Consolas; font-size: 10.0pt;"><span style="mso-spacerun: yes;"> </span>}</span><span style="font-family: Consolas; font-size: 10.0pt;"></span></div>
<div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;">
<span style="color: black; font-family: Consolas; font-size: 10.0pt;"><span style="mso-spacerun: yes;"> </span></span><span style="font-family: Consolas; font-size: 10.0pt;"></span></div>
<div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;">
<span style="color: black; font-family: Consolas; font-size: 10.0pt;">}</span><span style="font-family: Consolas; font-size: 10.0pt;"></span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<b> Below would be the output of console on program execution </b></div>
<div class="MsoNormal">
------------------------------------------------------------------------------------------- </div>
<br />
<br />
<br />
<br />
<script type="text/javascript">
google_ad_client = "ca-pub-8470945096737641";
/* 200x200, created 6/23/09 */
google_ad_slot = "8930436823";
google_ad_width = 200;
google_ad_height = 200;
</script><br />
<br />
<script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript">
</script><br />
<br />
<br />
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;">
<span style="color: black; font-family: Consolas; font-size: 10.0pt;">CommercialProjectBuilder ::: Thank you for reaching us..We deal in Commercial Projects..</span><span style="font-family: Consolas; font-size: 10.0pt;"></span></div>
<div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;">
<span style="color: black; font-family: Consolas; font-size: 10.0pt;">CommercialProjectBuilder :::Construction is already started.. Promise to deliver on time ..</span><span style="font-family: Consolas; font-size: 10.0pt;"></span></div>
<div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;">
<span style="color: black; font-family: Consolas; font-size: 10.0pt;">CommercialProjectBuilder :::Construction is on full Swing.. Pay installments timely </span><span style="font-family: Consolas; font-size: 10.0pt;"></span></div>
<div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;">
<span style="color: black; font-family: Consolas; font-size: 10.0pt;">CommercialProjectBuilder :::About to deliver .. Have litte more Patience </span><span style="font-family: Consolas; font-size: 10.0pt;"></span></div>
<div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;">
<span style="color: black; font-family: Consolas; font-size: 10.0pt;">CommercialProjectBuilder :::IT is well decorated.. Ready to move</span><span style="font-family: Consolas; font-size: 10.0pt;"></span></div>
<div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;">
<span style="color: black; font-family: Consolas; font-size: 10.0pt;">CLIENT :::: Thank you for timely delivry of commerical project</span></div>
<div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;">
<br /></div>
<div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;">
<b><span style="color: black; font-family: Consolas; font-size: 10.0pt;">===============================================================</span></b></div>
<br />
<br />
<div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;">
<br /></div>
<div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;">
<span style="color: black; font-family: Consolas; font-size: 10.0pt;">CLIENT :::: Now let's deal in residenrial</span><span style="font-family: Consolas; font-size: 10.0pt;"></span></div>
<div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;">
<span style="color: black; font-family: Consolas; font-size: 10.0pt;">ResidentialProjectBuilder:::Thank you for reaching us..We deal in Residential Projects..</span><span style="font-family: Consolas; font-size: 10.0pt;"></span></div>
<div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;">
<span style="color: black; font-family: Consolas; font-size: 10.0pt;">ResidentialProjectBuilder:::Construction is already started.. Promise to deliver on time </span><span style="font-family: Consolas; font-size: 10.0pt;"></span></div>
<div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;">
<span style="color: black; font-family: Consolas; font-size: 10.0pt;">ResidentialProjectBuilder::::Construction is on full Swing.. Pay installments timely </span><span style="font-family: Consolas; font-size: 10.0pt;"></span></div>
<div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;">
<span style="color: black; font-family: Consolas; font-size: 10.0pt;">ResidentialProjectBuilder::::About to deliver .. Have litte more Patience </span><span style="font-family: Consolas; font-size: 10.0pt;"></span></div>
<div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;">
<span style="color: black; font-family: Consolas; font-size: 10.0pt;">ResidentialProjectBuilder:::IT is well decorated.. Ready to move</span><span style="font-family: Consolas; font-size: 10.0pt;"></span></div>
<div class="MsoNormal" style="mso-layout-grid-align: none; text-autospace: none;">
<span style="color: black; font-family: Consolas; font-size: 10.0pt;">CLIENT :::: Thank you for timely delivry of Residential project.. Rocking performance</span><span style="font-family: Consolas; font-size: 10.0pt;"></span></div>
<div class="MsoNormal">
<br /></div>
</div>
<br />
<br />
<script type="text/javascript">
google_ad_client = "ca-pub-8470945096737641";
/* seo banner */
google_ad_slot = "3657212241";
google_ad_width = 468;
google_ad_height = 300;
//</script>
</div>
--><br /><script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript">
</script><br />MANOJ KUMARhttp://www.blogger.com/profile/00421517842858762886noreply@blogger.com0tag:blogger.com,1999:blog-3445872732437342114.post-85484943467736847572013-10-04T11:27:00.000-07:002013-10-18T07:01:29.609-07:00Blocking Queue and Consumer pattern for fixed resources<div dir="ltr" style="text-align: left;" trbidi="on">
<div dir="ltr" style="text-align: left;" trbidi="on">
<a href="http://efectivejava.blogspot.in/2013/10/blocking-queue-and-consumer-pattern-for.html" target="_blank"> Blocking Queue and Consumer pattern for fixed resources</a><br />
<br />
<div dir="ltr" style="text-align: left;" trbidi="on">
<a href="http://efectivejava.blogspot.in/2013/10/blocking-queue-and-consumer-pattern-for.html" target="_blank"><span style="color: #4c1130;"><b>What is blocking Queue </b></span></a><br />
<span style="color: #4c1130;"><br />
</span> <span style="color: #4c1130;">Blocking Queue is a collection introduced in java 1.6 . It provides lot of useful methods to write efficient mutithreaded and concurrent program . </span><br />
<span style="color: #4c1130;"><br />
</span> <span style="color: #4c1130;">We will discuss here two very important methods of blocking Queue here </span><br />
<span style="color: #4c1130;"><br />
</span> <span style="color: #4c1130;">1. <b>put() </b>: this method put an object in the queue only If there is capacity to add. In blocking queue ,we can define the maximum possible size of the queue at Queue instance construction time. </span><br />
<span style="color: #4c1130;"><br />
</span> <span style="color: #4c1130;">So If we say : </span><br />
<span style="color: #4c1130;"><br />
</span> <span style="color: #4c1130;"><b> BlockingQueue<token> tokensQueue = new LinkedBlockingQueue<token>(10);</token></token></b></span><br />
<span style="color: #4c1130;"><br />
</span> <span style="color: #4c1130;">maximum allowed Token objects in queue is 10 . </span><br />
<span style="color: #4c1130;"><br />
</span> <span style="color: #4c1130;"><b>Blocking Queue is interface and LinkedBlockingQueue is one of it's implementation. </b></span><br />
<span style="color: #4c1130;"><br />
</span> <span style="color: #4c1130;">So if current size of queue is 10 and we call put method like queue.put(Object) , this call will be blocked until an object is consumed from the queue by one of the consumer . After consumption , current size will reduce and queue will have capacity to add more objects. Then queue.put(Object) cal will succeed . </span><br />
<span style="color: #4c1130;"><br />
</span> <span style="color: #4c1130;">2. <b>take() </b>: This method retrieves the Object from Queue. This is also blocking call If there is no object available in the queue and queue is empty . It will continue waiting until and object is inserted in the queue by some other thread . Once at least once object is available in queue , queue.take() method will succeed and blocking will break.</span><br />
<span style="color: #4c1130;"><br />
</span> <span style="color: #4c1130;">One more method I would like to discuss is <b>offer()</b> . <b>offer()</b> is method that puts object in the queue But that is not a blocking call. It simply returns false If object is not added due to capacity and does not wait for Queue getting space for another object. </span><br />
<br />
<br />
<script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript">
</script><br />
<br />
<br />
<script type="text/javascript">
google_ad_client = "ca-pub-8470945096737641";
/* seo banner */
google_ad_slot = "3657212241";
google_ad_width = 468;
google_ad_height = 300;
//</script>
</div>
</div>
--><br />
<script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript">
</script><br />
<span style="color: #4c1130;"><br />
</span> <span style="color: #4c1130;"><br />
</span> <span style="color: #4c1130;">Before starting my code example I would like to touch upon one more thing : </span><br />
<span style="color: #4c1130;"><br />
</span> <span style="color: #4c1130;"><b>AtomicInteger </b>: this is class available in java now to provide atomic operations while accessing and modifying value of a primitive type. It provides certain methods to provide synchronization and atomicity . Will see in the example How to use that ..</span><br />
<span style="color: #4c1130;"><br />
</span> <span style="color: #4c1130;"><b> So now lets move to our code example :</b></span><br />
<span style="color: #4c1130;"><br />
</span> <span style="color: #4c1130;">Consider there is a class of 1000 odd students. Now being summer season students keep of going out of class to take water . Teacher can not send a lot of students together So a rule is maintained that at one time maximum of only 10 students can stay outside . </span><br />
<br />
<span style="color: #4c1130;"><b>So implement this practically , 10 tokens are created. Every time student goes outside has to carry a token . After returning will put the token back in pool for someone else to use. </b></span><br />
<br />
<br />
<br />
<script type="text/javascript">
google_ad_client = "ca-pub-8470945096737641";
/* 200x200, created 6/23/09 */
google_ad_slot = "8930436823";
google_ad_width = 200;
google_ad_height = 200;
</script><br />
<br />
<u><span style="color: #4c1130;">So how can we implement this using Blocking Queue : </span></u><br />
<br />
<span style="color: #4c1130;"><b>As usual below code has lot of System.out.println statements . Executing this program will print them on console and they will take you through all the steps followed. </b></span><br />
<br />
<span style="color: #4c1130;">------------------------------------</span><br />
<br />
<span style="color: #4c1130;"><br />
import java.util.concurrent.BlockingQueue;<br />
import java.util.concurrent.LinkedBlockingQueue;<br />
import java.util.concurrent.atomic.AtomicInteger;</span><br />
<span style="color: #4c1130;"><br /><u>
</u></span><u> <span style="color: #4c1130;"><b>// This is the class where tokens are created . It interact with other classes to create and overall //flow.</b></span></u><br />
<span style="color: blue;"><span style="font-family: "Courier New",Courier,monospace;"><b> </b><br />
<b>public class Class {</b></span></span><br />
<span style="color: blue;"><span style="font-family: "Courier New",Courier,monospace;"><br />
BlockingQueue<token> tokensQueue = new LinkedBlockingQueue<token>(10);<br />
<br />
public static void main(String[] args) {<br />
<br />
Class Class = new Class();<br />
Class.generateTokens();<br />
<br />
}<br />
// this method is doing nothing but adding 10 instances of Token //class in queue<br />
public void generateTokens() {<br />
<br />
for (int i = 0; i &lt; 10; i++) {<br />
<b> System.out.println("generating token no" + i);</b><br />
<br />
try {<br />
tokensQueue.put(new Token());<br />
} catch (InterruptedException e) {<br />
e.printStackTrace();<br />
}<br />
<br />
}<br />
<br />
<b> System.out.println("Now all 10 tokens are created and are stored in blocking queue ");</b></token></token></span></span><br />
<br />
<span style="color: blue;"><span style="font-family: "Courier New",Courier,monospace;"><token><token><b>// Here consumer thread is started to start using tokens </b><br />
Thread BCC = new Thread(new Student(tokensQueue));<br />
BCC.start();<br />
<br />
}<br />
<br />
}<br />
<b>// This is Token class . These tokens are allotted to students </b></token></token></span></span><br />
<span style="color: blue;"><span style="font-family: "Courier New",Courier,monospace;"><b> </b><br />
<b>class Token {</b><br />
<br />
public static AtomicInteger tokenNumber = new AtomicInteger(0);<br />
<br />
public int number_Of_Token_Assigned;<br />
<br />
void useToken(Token token) {<br />
<b> System.out.println("Student is using token " + token.number_Of_Token_Assigned);<br />
</b>}<br />
<br />
Token() {<br />
this.number_Of_Token_Assigned = tokenNumber.incrementAndGet();<br />
}<br />
<br />
}</span></span><br />
<span style="color: blue;"><span style="font-family: "Courier New",Courier,monospace;"><b>// Students are continuously using the tokens So infinite while loop is executed... </b></span></span><br />
<span style="color: blue;"><span style="font-family: "Courier New",Courier,monospace;"><b> </b><br />
<b>class Student implements Runnable {</b><br />
BlockingQueue<token> tokenQueue;<br />
<br />
Student(BlockingQueue<token> tokenQueue) {<br />
this.tokenQueue = tokenQueue;<br />
}<br />
<br />
public void run() {<br />
<br />
try {<br />
while (true) {<br />
<b> System.out.println("student request for a token..");</b><br />
Token token = tokenQueue.take();<br />
<b> System.out.println(token.number_Of_Token_Assigned + " is the token no alloted ...");</b><br />
token.useToken(token);<br />
<b>System.out.println("token" + token.number_Of_Token_Assigned<br />
+ "is used .Now putting that back into tokenQueue");</b><br />
<br />
tokenQueue.offer(token);<br />
}<br />
} catch (InterruptedException e) {<br />
<br />
e.printStackTrace();<br />
}<br />
<br />
}<br />
<br />
}<br />
</token></token></span></span><br />
<br />
<span style="color: #4c1130;"><b>This will print on console something like :</b></span><br />
<br />
<script type="text/javascript">
google_ad_client = "ca-pub-8470945096737641";
/* 160x600, created 6/23/09 */
google_ad_slot = "3027217057";
google_ad_width = 160;
google_ad_height =200 ;
//
</script><br />
<script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript">
</script><br />
<br />
<br />
<span style="color: #4c1130;"><b>-----------------------------</b></span><br />
<span style="color: #4c1130;">2 is the token no alloted ...<br />
Student is currently using token <br />
token2is used .Now putting that back into tokenQueue<br />
student request for a token..<br />
3 is the token no alloted ...<br />
Student is currently using token <br />
token3is used .Now putting that back into tokenQueue<br />
student request for a token..<br />
4 is the token no alloted ...<br />
Student is currently using token <br />
token4is used .Now putting that back into tokenQueue<br />
student request for a token..<br />
5 is the token no alloted ...<br />
Student is currently using token <br />
token5is used .Now putting that back into tokenQueue<br />
student request for a token..<br />
6 is the token no alloted ...<br />
Student is currently using token <br />
token6is used .Now putting that back into tokenQueue<br />
student request for a token..<br />
7 is the token no alloted ...<br />
Student is currently using token <br />
token7is used .Now putting that back into tokenQueue<br />
student request for a token..<br />
8 is the token no alloted ...<br />
Student is currently using token <br />
token8is used .Now putting that back into tokenQueue<br />
student request for a token..<br />
9 is the token no alloted ...<br />
Student is currently using token <br />
token9is used .Now putting that back into tokenQueue<br />
student request for a token..<br />
10 is the token no alloted ...<br />
Student is currently using token <br />
token10is used .Now putting that back into tokenQueue<br />
student request for a token..<br />
1 is the token no alloted ...<br />
Student is currently using token <br />
token1is used .Now putting that back into tokenQueue<br />
student request for a token..<br />
2 is the token no alloted ...<br />
Student is currently using token <br />
token2is used .Now putting that back into tokenQueue<br />
student request for a token..<br />
3 is the token no alloted ...<br />
Student is currently using token <br />
token3is used .Now putting that back into tokenQueue<br />
student request for a token..<br />
4 is the token no alloted ...<br />
Student is currently using token <br />
token4is used .Now putting that back into tokenQueue<br />
student request for a token..<br />
5 is the token no alloted ...<br />
Student is currently using token <br />
token5is used .Now putting that back into tokenQueue<br />
------------</span><br />
<span style="color: #4c1130;">----------</span><br />
<span style="color: #4c1130;">--------</span><br />
<br />
<span style="color: #4c1130;"> You can repeat tis example with more consumer by creating more consumer classes as below and see how output comes </span><br />
<span style="color: #4c1130;"><br />
</span> <span style="color: #4c1130;"> public void generateTokens() {<br />
<br />
for (int i = 0; i &lt; 10; i++) {<br />
<b> System.out.println("generating token no" + i);</b><br />
<br />
try {<br />
tokensQueue.put(new Token());<br />
} catch (InterruptedException e) {<br />
e.printStackTrace();<br />
}<br />
<br />
}<br />
<br />
<b> System.out.println("Now all 10 tokens are created and are stored in blocking queue ");</b><br />
<br />
Thread BCC = new Thread(new Student(tokensQueue));<br />
BCC.start();</span><br />
<b><span style="color: red;"> Thread BCC1 = new Thread(new Student(tokensQueue));<br />
BCC1.start();</span></b><br />
<span style="color: #4c1130;"><b><span style="color: red;"> Thread BCC2 = new Thread(new Student(tokensQueue));<br />
BCC2.start();</span></b><br />
<br />
}</span><br />
<br />
<span style="color: #4c1130;"><br />
</span></div>
MANOJ KUMARhttp://www.blogger.com/profile/00421517842858762886noreply@blogger.com0tag:blogger.com,1999:blog-3445872732437342114.post-8384683310520588552013-09-30T08:38:00.000-07:002013-10-18T07:02:06.083-07:00error:Class names are only accepted if annotation processing is explicitly requested <div dir="ltr" style="text-align: left;" trbidi="on">
<div dir="ltr" style="text-align: left;" trbidi="on">
<!--[if gte mso 9]><xml> <o:OfficeDocumentSettings> <o:AllowPNG/> </o:OfficeDocumentSettings> </xml><![endif]--><br />
<!--[if gte mso 9]><xml> <w:WordDocument> <w:View>Normal</w:View> <w:Zoom>0</w:Zoom> <w:TrackMoves/> <w:TrackFormatting/> <w:PunctuationKerning/> <w:ValidateAgainstSchemas/> <w:SaveIfXMLInvalid>false</w:SaveIfXMLInvalid> <w:IgnoreMixedContent>false</w:IgnoreMixedContent> <w:AlwaysShowPlaceholderText>false</w:AlwaysShowPlaceholderText> <w:DoNotPromoteQF/> <w:LidThemeOther>EN-US</w:LidThemeOther> <w:LidThemeAsian>X-NONE</w:LidThemeAsian> <w:LidThemeComplexScript>X-NONE</w:LidThemeComplexScript> <w:Compatibility> <w:BreakWrappedTables/> <w:SnapToGridInCell/> <w:WrapTextWithPunct/> <w:UseAsianBreakRules/> <w:DontGrowAutofit/> <w:SplitPgBreakAndParaMark/> <w:EnableOpenTypeKerning/> <w:DontFlipMirrorIndents/> <w:OverrideTableStyleHps/> </w:Compatibility> <w:BrowserLevel>MicrosoftInternetExplorer4</w:BrowserLevel> <m:mathPr> <m:mathFont m:val="Cambria Math"/> <m:brkBin m:val="before"/> <m:brkBinSub m:val="--"/> <m:smallFrac m:val="off"/> <m:dispDef/> <m:lMargin m:val="0"/> <m:rMargin m:val="0"/> <m:defJc m:val="centerGroup"/> <m:wrapIndent m:val="1440"/> <m:intLim m:val="subSup"/> <m:naryLim m:val="undOvr"/> </m:mathPr></w:WordDocument> </xml><![endif]--><!--[if gte mso 9]><xml> <w:LatentStyles DefLockedState="false" DefUnhideWhenUsed="true"
DefSemiHidden="true" DefQFormat="false" DefPriority="99"
LatentStyleCount="267"> <w:LsdException Locked="false" Priority="0" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Normal"/> <w:LsdException Locked="false" Priority="9" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="heading 1"/> <w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 2"/> <w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 3"/> <w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 4"/> <w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 5"/> <w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 6"/> <w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 7"/> <w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 8"/> <w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 9"/> <w:LsdException Locked="false" Priority="39" Name="toc 1"/> <w:LsdException Locked="false" Priority="39" Name="toc 2"/> <w:LsdException Locked="false" Priority="39" Name="toc 3"/> <w:LsdException Locked="false" Priority="39" Name="toc 4"/> <w:LsdException Locked="false" Priority="39" Name="toc 5"/> <w:LsdException Locked="false" Priority="39" Name="toc 6"/> <w:LsdException Locked="false" Priority="39" Name="toc 7"/> <w:LsdException Locked="false" Priority="39" Name="toc 8"/> <w:LsdException Locked="false" Priority="39" Name="toc 9"/> <w:LsdException Locked="false" Priority="35" QFormat="true" Name="caption"/> <w:LsdException Locked="false" Priority="10" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Title"/> <w:LsdException Locked="false" Priority="1" Name="Default Paragraph Font"/> <w:LsdException Locked="false" Priority="11" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Subtitle"/> <w:LsdException Locked="false" Priority="22" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Strong"/> <w:LsdException Locked="false" Priority="20" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Emphasis"/> <w:LsdException Locked="false" Priority="59" SemiHidden="false"
UnhideWhenUsed="false" Name="Table Grid"/> <w:LsdException Locked="false" UnhideWhenUsed="false" Name="Placeholder Text"/> <w:LsdException Locked="false" Priority="1" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="No Spacing"/> <w:LsdException Locked="false" Priority="60" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Shading"/> <w:LsdException Locked="false" Priority="61" SemiHidden="false"
UnhideWhenUsed="false" Name="Light List"/> <w:LsdException Locked="false" Priority="62" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Grid"/> <w:LsdException Locked="false" Priority="63" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 1"/> <w:LsdException Locked="false" Priority="64" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 2"/> <w:LsdException Locked="false" Priority="65" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 1"/> <w:LsdException Locked="false" Priority="66" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 2"/> <w:LsdException Locked="false" Priority="67" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 1"/> <w:LsdException Locked="false" Priority="68" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 2"/> <w:LsdException Locked="false" Priority="69" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 3"/> <w:LsdException Locked="false" Priority="70" SemiHidden="false"
UnhideWhenUsed="false" Name="Dark List"/> <w:LsdException Locked="false" Priority="71" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Shading"/> <w:LsdException Locked="false" Priority="72" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful List"/> <w:LsdException Locked="false" Priority="73" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Grid"/> <w:LsdException Locked="false" Priority="60" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Shading Accent 1"/> <w:LsdException Locked="false" Priority="61" SemiHidden="false"
UnhideWhenUsed="false" Name="Light List Accent 1"/> <w:LsdException Locked="false" Priority="62" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Grid Accent 1"/> <w:LsdException Locked="false" Priority="63" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 1 Accent 1"/> <w:LsdException Locked="false" Priority="64" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 2 Accent 1"/> <w:LsdException Locked="false" Priority="65" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 1 Accent 1"/> <w:LsdException Locked="false" UnhideWhenUsed="false" Name="Revision"/> <w:LsdException Locked="false" Priority="34" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="List Paragraph"/> <w:LsdException Locked="false" Priority="29" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Quote"/> <w:LsdException Locked="false" Priority="30" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Intense Quote"/> <w:LsdException Locked="false" Priority="66" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 2 Accent 1"/> <w:LsdException Locked="false" Priority="67" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 1 Accent 1"/> <w:LsdException Locked="false" Priority="68" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 2 Accent 1"/> <w:LsdException Locked="false" Priority="69" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 3 Accent 1"/> <w:LsdException Locked="false" Priority="70" SemiHidden="false"
UnhideWhenUsed="false" Name="Dark List Accent 1"/> <w:LsdException Locked="false" Priority="71" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Shading Accent 1"/> <w:LsdException Locked="false" Priority="72" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful List Accent 1"/> <w:LsdException Locked="false" Priority="73" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Grid Accent 1"/> <w:LsdException Locked="false" Priority="60" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Shading Accent 2"/> <w:LsdException Locked="false" Priority="61" SemiHidden="false"
UnhideWhenUsed="false" Name="Light List Accent 2"/> <w:LsdException Locked="false" Priority="62" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Grid Accent 2"/> <w:LsdException Locked="false" Priority="63" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 1 Accent 2"/> <w:LsdException Locked="false" Priority="64" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 2 Accent 2"/> <w:LsdException Locked="false" Priority="65" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 1 Accent 2"/> <w:LsdException Locked="false" Priority="66" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 2 Accent 2"/> <w:LsdException Locked="false" Priority="67" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 1 Accent 2"/> <w:LsdException Locked="false" Priority="68" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 2 Accent 2"/> <w:LsdException Locked="false" Priority="69" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 3 Accent 2"/> <w:LsdException Locked="false" Priority="70" SemiHidden="false"
UnhideWhenUsed="false" Name="Dark List Accent 2"/> <w:LsdException Locked="false" Priority="71" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Shading Accent 2"/> <w:LsdException Locked="false" Priority="72" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful List Accent 2"/> <w:LsdException Locked="false" Priority="73" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Grid Accent 2"/> <w:LsdException Locked="false" Priority="60" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Shading Accent 3"/> <w:LsdException Locked="false" Priority="61" SemiHidden="false"
UnhideWhenUsed="false" Name="Light List Accent 3"/> <w:LsdException Locked="false" Priority="62" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Grid Accent 3"/> <w:LsdException Locked="false" Priority="63" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 1 Accent 3"/> <w:LsdException Locked="false" Priority="64" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 2 Accent 3"/> <w:LsdException Locked="false" Priority="65" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 1 Accent 3"/> <w:LsdException Locked="false" Priority="66" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 2 Accent 3"/> <w:LsdException Locked="false" Priority="67" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 1 Accent 3"/> <w:LsdException Locked="false" Priority="68" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 2 Accent 3"/> <w:LsdException Locked="false" Priority="69" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 3 Accent 3"/> <w:LsdException Locked="false" Priority="70" SemiHidden="false"
UnhideWhenUsed="false" Name="Dark List Accent 3"/> <w:LsdException Locked="false" Priority="71" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Shading Accent 3"/> <w:LsdException Locked="false" Priority="72" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful List Accent 3"/> <w:LsdException Locked="false" Priority="73" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Grid Accent 3"/> <w:LsdException Locked="false" Priority="60" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Shading Accent 4"/> <w:LsdException Locked="false" Priority="61" SemiHidden="false"
UnhideWhenUsed="false" Name="Light List Accent 4"/> <w:LsdException Locked="false" Priority="62" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Grid Accent 4"/> <w:LsdException Locked="false" Priority="63" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 1 Accent 4"/> <w:LsdException Locked="false" Priority="64" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 2 Accent 4"/> <w:LsdException Locked="false" Priority="65" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 1 Accent 4"/> <w:LsdException Locked="false" Priority="66" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 2 Accent 4"/> <w:LsdException Locked="false" Priority="67" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 1 Accent 4"/> <w:LsdException Locked="false" Priority="68" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 2 Accent 4"/> <w:LsdException Locked="false" Priority="69" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 3 Accent 4"/> <w:LsdException Locked="false" Priority="70" SemiHidden="false"
UnhideWhenUsed="false" Name="Dark List Accent 4"/> <w:LsdException Locked="false" Priority="71" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Shading Accent 4"/> <w:LsdException Locked="false" Priority="72" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful List Accent 4"/> <w:LsdException Locked="false" Priority="73" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Grid Accent 4"/> <w:LsdException Locked="false" Priority="60" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Shading Accent 5"/> <w:LsdException Locked="false" Priority="61" SemiHidden="false"
UnhideWhenUsed="false" Name="Light List Accent 5"/> <w:LsdException Locked="false" Priority="62" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Grid Accent 5"/> <w:LsdException Locked="false" Priority="63" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 1 Accent 5"/> <w:LsdException Locked="false" Priority="64" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 2 Accent 5"/> <w:LsdException Locked="false" Priority="65" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 1 Accent 5"/> <w:LsdException Locked="false" Priority="66" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 2 Accent 5"/> <w:LsdException Locked="false" Priority="67" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 1 Accent 5"/> <w:LsdException Locked="false" Priority="68" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 2 Accent 5"/> <w:LsdException Locked="false" Priority="69" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 3 Accent 5"/> <w:LsdException Locked="false" Priority="70" SemiHidden="false"
UnhideWhenUsed="false" Name="Dark List Accent 5"/> <w:LsdException Locked="false" Priority="71" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Shading Accent 5"/> <w:LsdException Locked="false" Priority="72" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful List Accent 5"/> <w:LsdException Locked="false" Priority="73" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Grid Accent 5"/> <w:LsdException Locked="false" Priority="60" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Shading Accent 6"/> <w:LsdException Locked="false" Priority="61" SemiHidden="false"
UnhideWhenUsed="false" Name="Light List Accent 6"/> <w:LsdException Locked="false" Priority="62" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Grid Accent 6"/> <w:LsdException Locked="false" Priority="63" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 1 Accent 6"/> <w:LsdException Locked="false" Priority="64" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 2 Accent 6"/> <w:LsdException Locked="false" Priority="65" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 1 Accent 6"/> <w:LsdException Locked="false" Priority="66" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 2 Accent 6"/> <w:LsdException Locked="false" Priority="67" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 1 Accent 6"/> <w:LsdException Locked="false" Priority="68" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 2 Accent 6"/> <w:LsdException Locked="false" Priority="69" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 3 Accent 6"/> <w:LsdException Locked="false" Priority="70" SemiHidden="false"
UnhideWhenUsed="false" Name="Dark List Accent 6"/> <w:LsdException Locked="false" Priority="71" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Shading Accent 6"/> <w:LsdException Locked="false" Priority="72" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful List Accent 6"/> <w:LsdException Locked="false" Priority="73" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Grid Accent 6"/> <w:LsdException Locked="false" Priority="19" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Subtle Emphasis"/> <w:LsdException Locked="false" Priority="21" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Intense Emphasis"/> <w:LsdException Locked="false" Priority="31" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Subtle Reference"/> <w:LsdException Locked="false" Priority="32" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Intense Reference"/> <w:LsdException Locked="false" Priority="33" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Book Title"/> <w:LsdException Locked="false" Priority="37" Name="Bibliography"/> <w:LsdException Locked="false" Priority="39" QFormat="true" Name="TOC Heading"/> </w:LatentStyles> </xml><![endif]--><!--[if gte mso 10]> <style>
/* Style Definitions */
table.MsoNormalTable
{mso-style-name:"Table Normal";
mso-tstyle-rowband-size:0;
mso-tstyle-colband-size:0;
mso-style-noshow:yes;
mso-style-priority:99;
mso-style-parent:"";
mso-padding-alt:0in 5.4pt 0in 5.4pt;
mso-para-margin:0in;
mso-para-margin-bottom:.0001pt;
mso-pagination:widow-orphan;
font-size:10.0pt;
font-family:"Calibri","sans-serif";
mso-ascii-font-family:Calibri;
mso-ascii-theme-font:minor-latin;
mso-hansi-font-family:Calibri;
mso-hansi-theme-font:minor-latin;
mso-bidi-font-family:"Times New Roman";
mso-bidi-theme-font:minor-bidi;}
</style> <![endif]--> <br />
<div class="MsoNormal">
<a href="http://efectivejava.blogspot.in/2013/09/errorclass-names-are-only-accepted-if.html" target="_blank"><b><span style="color: #4c1130;">Error: Class names are only accepted if annotation processing is explicitly requested </span></b></a></div>
<div class="MsoNormal">
<br /></div>
<br />
<br />
<script type="text/javascript">
google_ad_client = "ca-pub-8470945096737641";
/* seo banner */
google_ad_slot = "3657212241";
google_ad_width = 468;
google_ad_height = 300;
//</script>
</div>
</div>
--><br /><script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript">
</script><br />
<div class="MsoNormal">
<span style="color: #4c1130;">This error generally occurs when one try to compile a java file without appending .java extension in file name ..</span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<u><span style="color: #4c1130;">For example </span></u></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<b><span style="color: #4c1130;">I have below class at location C:\Users\mkum\Desktop\java</span></b></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<span style="color: #4c1130;">public class Test{</span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<span style="color: #4c1130;"><span style="mso-tab-count: 1;"> </span></span></div>
<div class="MsoNormal">
<span style="color: #4c1130;"><span style="mso-tab-count: 1;"> </span>public String result() {</span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<span style="color: #4c1130;"><span style="mso-tab-count: 2;"> </span>return "abc";</span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<span style="color: #4c1130;"><span style="mso-tab-count: 1;"> </span>}</span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<span style="color: #4c1130;">}</span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<span style="color: #4c1130;">On compiling this as below : </span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<span style="color: #4c1130;">C:\Users\mkum\Desktop\java>javac Test</span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<b><span style="color: #4c1130;">error: Class names, 'Test', are only accepted if annotation processing is explicitly requested</span></b></div>
<div class="MsoNormal">
<b><span style="color: #4c1130;">1 error</span></b></div>
<div class="MsoNormal">
<br /></div>
<br />
<br />
<br />
<script type="text/javascript">
google_ad_client = "ca-pub-8470945096737641";
/* 200x200, created 6/23/09 */
google_ad_slot = "8930436823";
google_ad_width = 200;
google_ad_height = 200;
</script><br />
<script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript">
</script><br />
<br />
<br />
<div class="MsoNormal">
<span style="color: #4c1130;">So correct way to compile class from command line would be </span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<b><span style="color: #4c1130;">C:\Users\mkum\Desktop\java>javac Test.<span style="color: #e06666;">java</span></span></b></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<span style="color: #4c1130;">Now it will compile well and will generate the binary file.</span></div>
<br />
<script type="text/javascript">
google_ad_client = "ca-pub-8470945096737641";
/* 160x600, created 6/23/09 */
google_ad_slot = "3027217057";
google_ad_width = 160;
google_ad_height =200 ;
//
</script><br />
<script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript">
</script><br />
<br />MANOJ KUMARhttp://www.blogger.com/profile/00421517842858762886noreply@blogger.com0tag:blogger.com,1999:blog-3445872732437342114.post-67187961041506178942013-09-28T11:20:00.001-07:002013-10-18T07:03:11.205-07:00Visitor Design pattern in java<div dir="ltr" style="text-align: left;" trbidi="on">
<b><span style="font-family: Arial,Helvetica,sans-serif;"><span style="color: #4c1130;"> <a href="http://efectivejava.blogspot.in/2013/09/visitor-design-pattern-in-java.html" target="_blank">Visitor Design pattern in java</a></span></span></b><br />
<br />
<b><span style="font-family: Arial,Helvetica,sans-serif;"><span style="color: #4c1130;">Think from a visitors perspective for a while ---</span></span></b><br />
<span style="font-family: Arial,Helvetica,sans-serif;"><span style="color: #4c1130;"><br />
</span></span> <span style="font-family: Arial,Helvetica,sans-serif;"><span style="color: #4c1130;">A person comes from US to visit India ... </span></span><br />
<span style="font-family: Arial,Helvetica,sans-serif;"><span style="color: #4c1130;"><br />
</span></span> <span style="font-family: Arial,Helvetica,sans-serif;"><span style="color: #4c1130;">Visitor want to visit certain places .. He has the list of places he want to visit . </span></span><br />
<span style="font-family: Arial,Helvetica,sans-serif;"><span style="color: #4c1130;"><br />
</span></span> <b><span style="font-family: Arial,Helvetica,sans-serif;"><span style="color: #4c1130;">So he provide the same list to his travel organizer and ask him to prepare a suitable plan for him to make him travel all the places available in the list.</span></span></b><br />
<span style="font-family: Arial,Helvetica,sans-serif;"><span style="color: #4c1130;"><br />
</span></span> <span style="font-family: Arial,Helvetica,sans-serif;"><span style="color: #4c1130;">Organizer takes the list and start contacting his site contact persons . He ask his agents at all places visitor want to visit to accept and welcome the visitor and make him Visit the place. </span></span><br />
<span style="font-family: Arial,Helvetica,sans-serif;"><span style="color: #4c1130;"><br />
</span></span> <span style="font-family: Arial,Helvetica,sans-serif;"><span style="color: #4c1130;">So here entire task is divided in to few sub tasks :</span></span><br />
<span style="font-family: Arial,Helvetica,sans-serif;"><span style="color: #4c1130;"><br />
</span></span> <b><span style="font-family: Arial,Helvetica,sans-serif;"><span style="color: #4c1130;">1. Visitor -- Ask visitor to plan . Visit the places.</span></span></b><br />
<b><span style="font-family: Arial,Helvetica,sans-serif;"><span style="color: #4c1130;">2. Organizer -- activate his place specific agents </span></span></b><br />
<b><span style="font-family: Arial,Helvetica,sans-serif;"><span style="color: #4c1130;">3. Place agents --- Accept the visitor and make him Visit. </span></span></b><br />
<span style="font-family: Arial,Helvetica,sans-serif;"><span style="color: #4c1130;"><br />
</span></span><br />
<script type="text/javascript">
google_ad_client = "ca-pub-8470945096737641";
/* 160x600, created 6/23/09 */
google_ad_slot = "3027217057";
google_ad_width = 160;
google_ad_height =200 ;
//
</script><br />
<script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript">
</script><br />
<br />
<span style="font-family: Arial,Helvetica,sans-serif;"><span style="color: #4c1130;">Now lets understand this scenario in Object oriented world of java technology . How design pattern deals with this situation.</span></span><br />
<span style="font-family: Arial,Helvetica,sans-serif;"><span style="color: #4c1130;"><br />
</span></span> <span style="font-family: Arial,Helvetica,sans-serif;"><span style="color: #4c1130;">As usual , I would be providing all steps involved in the process in system.out.println statements. Code below can be copied as it is and executed in any java environment . System.out,print statements will print all the steps involved in process on console as well</span></span><br />
<span style="font-family: Arial,Helvetica,sans-serif;"><span style="color: #4c1130;"><br />
</span></span> <span style="font-family: Arial,Helvetica,sans-serif;"><span style="color: #4c1130;"><br />
</span></span> <span style="font-family: Arial,Helvetica,sans-serif;"><span style="color: #4c1130;">==============================================</span></span><br />
<span style="font-family: Arial,Helvetica,sans-serif;"><span style="color: #4c1130;"><br />
</span></span> <b><span style="font-family: Arial,Helvetica,sans-serif;"><span style="color: #4c1130;">Visitor class represents the visitor . He creates the list of places to be visited and invoke schedule method on organizer . Before invoking schedule method Visitor creates instance of Organizer and while constructing instance it uses one argument constructor to initiate Organizer instance with a state having list of Place instances.</span></span></b><br />
<br />
<!--[if gte mso 9]><xml> <w:WordDocument> <w:View>Normal</w:View> <w:Zoom>0</w:Zoom> <w:TrackMoves/> <w:TrackFormatting/> <w:PunctuationKerning/> <w:ValidateAgainstSchemas/> <w:SaveIfXMLInvalid>false</w:SaveIfXMLInvalid> <w:IgnoreMixedContent>false</w:IgnoreMixedContent> <w:AlwaysShowPlaceholderText>false</w:AlwaysShowPlaceholderText> <w:DoNotPromoteQF/> <w:LidThemeOther>EN-US</w:LidThemeOther> <w:LidThemeAsian>X-NONE</w:LidThemeAsian> <w:LidThemeComplexScript>X-NONE</w:LidThemeComplexScript> <w:Compatibility> <w:BreakWrappedTables/> <w:SnapToGridInCell/> <w:WrapTextWithPunct/> <w:UseAsianBreakRules/> <w:DontGrowAutofit/> <w:SplitPgBreakAndParaMark/> <w:EnableOpenTypeKerning/> <w:DontFlipMirrorIndents/> <w:OverrideTableStyleHps/> </w:Compatibility> <w:BrowserLevel>MicrosoftInternetExplorer4</w:BrowserLevel> <m:mathPr> <m:mathFont m:val="Cambria Math"/> <m:brkBin m:val="before"/> <m:brkBinSub m:val="--"/> <m:smallFrac m:val="off"/> <m:dispDef/> <m:lMargin m:val="0"/> <m:rMargin m:val="0"/> <m:defJc m:val="centerGroup"/> <m:wrapIndent m:val="1440"/> <m:intLim m:val="subSup"/> <m:naryLim m:val="undOvr"/> </m:mathPr></w:WordDocument> </xml><![endif]--><br />
<!--[if gte mso 9]><xml> <w:LatentStyles DefLockedState="false" DefUnhideWhenUsed="true"
DefSemiHidden="true" DefQFormat="false" DefPriority="99"
LatentStyleCount="267"> <w:LsdException Locked="false" Priority="0" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Normal"/> <w:LsdException Locked="false" Priority="9" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="heading 1"/> <w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 2"/> <w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 3"/> <w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 4"/> <w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 5"/> <w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 6"/> <w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 7"/> <w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 8"/> <w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 9"/> <w:LsdException Locked="false" Priority="39" Name="toc 1"/> <w:LsdException Locked="false" Priority="39" Name="toc 2"/> <w:LsdException Locked="false" Priority="39" Name="toc 3"/> <w:LsdException Locked="false" Priority="39" Name="toc 4"/> <w:LsdException Locked="false" Priority="39" Name="toc 5"/> <w:LsdException Locked="false" Priority="39" Name="toc 6"/> <w:LsdException Locked="false" Priority="39" Name="toc 7"/> <w:LsdException Locked="false" Priority="39" Name="toc 8"/> <w:LsdException Locked="false" Priority="39" Name="toc 9"/> <w:LsdException Locked="false" Priority="35" QFormat="true" Name="caption"/> <w:LsdException Locked="false" Priority="10" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Title"/> <w:LsdException Locked="false" Priority="1" Name="Default Paragraph Font"/> <w:LsdException Locked="false" Priority="11" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Subtitle"/> <w:LsdException Locked="false" Priority="22" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Strong"/> <w:LsdException Locked="false" Priority="20" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Emphasis"/> <w:LsdException Locked="false" Priority="59" SemiHidden="false"
UnhideWhenUsed="false" Name="Table Grid"/> <w:LsdException Locked="false" UnhideWhenUsed="false" Name="Placeholder Text"/> <w:LsdException Locked="false" Priority="1" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="No Spacing"/> <w:LsdException Locked="false" Priority="60" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Shading"/> <w:LsdException Locked="false" Priority="61" SemiHidden="false"
UnhideWhenUsed="false" Name="Light List"/> <w:LsdException Locked="false" Priority="62" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Grid"/> <w:LsdException Locked="false" Priority="63" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 1"/> <w:LsdException Locked="false" Priority="64" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 2"/> <w:LsdException Locked="false" Priority="65" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 1"/> <w:LsdException Locked="false" Priority="66" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 2"/> <w:LsdException Locked="false" Priority="67" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 1"/> <w:LsdException Locked="false" Priority="68" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 2"/> <w:LsdException Locked="false" Priority="69" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 3"/> <w:LsdException Locked="false" Priority="70" SemiHidden="false"
UnhideWhenUsed="false" Name="Dark List"/> <w:LsdException Locked="false" Priority="71" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Shading"/> <w:LsdException Locked="false" Priority="72" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful List"/> <w:LsdException Locked="false" Priority="73" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Grid"/> <w:LsdException Locked="false" Priority="60" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Shading Accent 1"/> <w:LsdException Locked="false" Priority="61" SemiHidden="false"
UnhideWhenUsed="false" Name="Light List Accent 1"/> <w:LsdException Locked="false" Priority="62" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Grid Accent 1"/> <w:LsdException Locked="false" Priority="63" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 1 Accent 1"/> <w:LsdException Locked="false" Priority="64" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 2 Accent 1"/> <w:LsdException Locked="false" Priority="65" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 1 Accent 1"/> <w:LsdException Locked="false" UnhideWhenUsed="false" Name="Revision"/> <w:LsdException Locked="false" Priority="34" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="List Paragraph"/> <w:LsdException Locked="false" Priority="29" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Quote"/> <w:LsdException Locked="false" Priority="30" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Intense Quote"/> <w:LsdException Locked="false" Priority="66" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 2 Accent 1"/> <w:LsdException Locked="false" Priority="67" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 1 Accent 1"/> <w:LsdException Locked="false" Priority="68" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 2 Accent 1"/> <w:LsdException Locked="false" Priority="69" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 3 Accent 1"/> <w:LsdException Locked="false" Priority="70" SemiHidden="false"
UnhideWhenUsed="false" Name="Dark List Accent 1"/> <w:LsdException Locked="false" Priority="71" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Shading Accent 1"/> <w:LsdException Locked="false" Priority="72" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful List Accent 1"/> <w:LsdException Locked="false" Priority="73" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Grid Accent 1"/> <w:LsdException Locked="false" Priority="60" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Shading Accent 2"/> <w:LsdException Locked="false" Priority="61" SemiHidden="false"
UnhideWhenUsed="false" Name="Light List Accent 2"/> <w:LsdException Locked="false" Priority="62" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Grid Accent 2"/> <w:LsdException Locked="false" Priority="63" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 1 Accent 2"/> <w:LsdException Locked="false" Priority="64" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 2 Accent 2"/> <w:LsdException Locked="false" Priority="65" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 1 Accent 2"/> <w:LsdException Locked="false" Priority="66" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 2 Accent 2"/> <w:LsdException Locked="false" Priority="67" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 1 Accent 2"/> <w:LsdException Locked="false" Priority="68" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 2 Accent 2"/> <w:LsdException Locked="false" Priority="69" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 3 Accent 2"/> <w:LsdException Locked="false" Priority="70" SemiHidden="false"
UnhideWhenUsed="false" Name="Dark List Accent 2"/> <w:LsdException Locked="false" Priority="71" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Shading Accent 2"/> <w:LsdException Locked="false" Priority="72" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful List Accent 2"/> <w:LsdException Locked="false" Priority="73" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Grid Accent 2"/> <w:LsdException Locked="false" Priority="60" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Shading Accent 3"/> <w:LsdException Locked="false" Priority="61" SemiHidden="false"
UnhideWhenUsed="false" Name="Light List Accent 3"/> <w:LsdException Locked="false" Priority="62" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Grid Accent 3"/> <w:LsdException Locked="false" Priority="63" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 1 Accent 3"/> <w:LsdException Locked="false" Priority="64" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 2 Accent 3"/> <w:LsdException Locked="false" Priority="65" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 1 Accent 3"/> <w:LsdException Locked="false" Priority="66" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 2 Accent 3"/> <w:LsdException Locked="false" Priority="67" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 1 Accent 3"/> <w:LsdException Locked="false" Priority="68" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 2 Accent 3"/> <w:LsdException Locked="false" Priority="69" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 3 Accent 3"/> <w:LsdException Locked="false" Priority="70" SemiHidden="false"
UnhideWhenUsed="false" Name="Dark List Accent 3"/> <w:LsdException Locked="false" Priority="71" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Shading Accent 3"/> <w:LsdException Locked="false" Priority="72" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful List Accent 3"/> <w:LsdException Locked="false" Priority="73" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Grid Accent 3"/> <w:LsdException Locked="false" Priority="60" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Shading Accent 4"/> <w:LsdException Locked="false" Priority="61" SemiHidden="false"
UnhideWhenUsed="false" Name="Light List Accent 4"/> <w:LsdException Locked="false" Priority="62" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Grid Accent 4"/> <w:LsdException Locked="false" Priority="63" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 1 Accent 4"/> <w:LsdException Locked="false" Priority="64" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 2 Accent 4"/> <w:LsdException Locked="false" Priority="65" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 1 Accent 4"/> <w:LsdException Locked="false" Priority="66" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 2 Accent 4"/> <w:LsdException Locked="false" Priority="67" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 1 Accent 4"/> <w:LsdException Locked="false" Priority="68" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 2 Accent 4"/> <w:LsdException Locked="false" Priority="69" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 3 Accent 4"/> <w:LsdException Locked="false" Priority="70" SemiHidden="false"
UnhideWhenUsed="false" Name="Dark List Accent 4"/> <w:LsdException Locked="false" Priority="71" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Shading Accent 4"/> <w:LsdException Locked="false" Priority="72" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful List Accent 4"/> <w:LsdException Locked="false" Priority="73" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Grid Accent 4"/> <w:LsdException Locked="false" Priority="60" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Shading Accent 5"/> <w:LsdException Locked="false" Priority="61" SemiHidden="false"
UnhideWhenUsed="false" Name="Light List Accent 5"/> <w:LsdException Locked="false" Priority="62" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Grid Accent 5"/> <w:LsdException Locked="false" Priority="63" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 1 Accent 5"/> <w:LsdException Locked="false" Priority="64" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 2 Accent 5"/> <w:LsdException Locked="false" Priority="65" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 1 Accent 5"/> <w:LsdException Locked="false" Priority="66" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 2 Accent 5"/> <w:LsdException Locked="false" Priority="67" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 1 Accent 5"/> <w:LsdException Locked="false" Priority="68" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 2 Accent 5"/> <w:LsdException Locked="false" Priority="69" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 3 Accent 5"/> <w:LsdException Locked="false" Priority="70" SemiHidden="false"
UnhideWhenUsed="false" Name="Dark List Accent 5"/> <w:LsdException Locked="false" Priority="71" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Shading Accent 5"/> <w:LsdException Locked="false" Priority="72" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful List Accent 5"/> <w:LsdException Locked="false" Priority="73" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Grid Accent 5"/> <w:LsdException Locked="false" Priority="60" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Shading Accent 6"/> <w:LsdException Locked="false" Priority="61" SemiHidden="false"
UnhideWhenUsed="false" Name="Light List Accent 6"/> <w:LsdException Locked="false" Priority="62" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Grid Accent 6"/> <w:LsdException Locked="false" Priority="63" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 1 Accent 6"/> <w:LsdException Locked="false" Priority="64" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 2 Accent 6"/> <w:LsdException Locked="false" Priority="65" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 1 Accent 6"/> <w:LsdException Locked="false" Priority="66" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 2 Accent 6"/> <w:LsdException Locked="false" Priority="67" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 1 Accent 6"/> <w:LsdException Locked="false" Priority="68" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 2 Accent 6"/> <w:LsdException Locked="false" Priority="69" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 3 Accent 6"/> <w:LsdException Locked="false" Priority="70" SemiHidden="false"
UnhideWhenUsed="false" Name="Dark List Accent 6"/> <w:LsdException Locked="false" Priority="71" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Shading Accent 6"/> <w:LsdException Locked="false" Priority="72" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful List Accent 6"/> <w:LsdException Locked="false" Priority="73" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Grid Accent 6"/> <w:LsdException Locked="false" Priority="19" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Subtle Emphasis"/> <w:LsdException Locked="false" Priority="21" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Intense Emphasis"/> <w:LsdException Locked="false" Priority="31" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Subtle Reference"/> <w:LsdException Locked="false" Priority="32" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Intense Reference"/> <w:LsdException Locked="false" Priority="33" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Book Title"/> <w:LsdException Locked="false" Priority="37" Name="Bibliography"/> <w:LsdException Locked="false" Priority="39" QFormat="true" Name="TOC Heading"/> </w:LatentStyles> </xml><![endif]--><!--[if gte mso 10]> <style>
/* Style Definitions */
table.MsoNormalTable
{mso-style-name:"Table Normal";
mso-tstyle-rowband-size:0;
mso-tstyle-colband-size:0;
mso-style-noshow:yes;
mso-style-priority:99;
mso-style-parent:"";
mso-padding-alt:0in 5.4pt 0in 5.4pt;
mso-para-margin:0in;
mso-para-margin-bottom:.0001pt;
mso-pagination:widow-orphan;
font-size:10.0pt;
font-family:"Times New Roman","serif";}
</style> <![endif]--> <br />
<div class="MsoNormal" style="text-autospace: none;">
<b><span style="color: #7f0055; font-family: Consolas; font-size: 10.0pt;">package</span></b><span style="color: black; font-family: Consolas; font-size: 10.0pt;"> incredibleIndia;</span><span style="font-family: Consolas; font-size: 10.0pt;"></span></div>
<div class="MsoNormal" style="text-autospace: none;">
<br /></div>
<div class="MsoNormal" style="text-autospace: none;">
<b><span style="color: #7f0055; font-family: Consolas; font-size: 10.0pt;">import</span></b><span style="color: black; font-family: Consolas; font-size: 10.0pt;"> java.util.ArrayList;</span><span style="font-family: Consolas; font-size: 10.0pt;"></span></div>
<div class="MsoNormal" style="text-autospace: none;">
<b><span style="color: #7f0055; font-family: Consolas; font-size: 10.0pt;">import</span></b><span style="color: black; font-family: Consolas; font-size: 10.0pt;"> java.util.List;</span><span style="font-family: Consolas; font-size: 10.0pt;"></span></div>
<div class="MsoNormal" style="text-autospace: none;">
<br /></div>
<div class="MsoNormal" style="text-autospace: none;">
<b><span style="color: #7f0055; font-family: Consolas; font-size: 10.0pt;">public</span></b><span style="color: black; font-family: Consolas; font-size: 10.0pt;"> </span><b><span style="color: #7f0055; font-family: Consolas; font-size: 10.0pt;">class</span></b><span style="color: black; font-family: Consolas; font-size: 10.0pt;"> Visitor </span><b><span style="color: #7f0055; font-family: Consolas; font-size: 10.0pt;">implements</span></b><span style="color: black; font-family: Consolas; font-size: 10.0pt;"> IVisotor {</span><span style="font-family: Consolas; font-size: 10.0pt;"></span></div>
<div class="MsoNormal" style="text-autospace: none;">
<br /></div>
<div class="MsoNormal" style="text-autospace: none;">
<span style="color: black; font-family: Consolas; font-size: 10.0pt;"> </span><span style="color: #3f5fbf; font-family: Consolas; font-size: 10.0pt;">/**</span><span style="font-family: Consolas; font-size: 10.0pt;"></span></div>
<div class="MsoNormal" style="text-autospace: none;">
<span style="color: #3f5fbf; font-family: Consolas; font-size: 10.0pt;"> * </span><b><span style="color: #7f9fbf; font-family: Consolas; font-size: 10.0pt;">@param</span></b><span style="color: #3f5fbf; font-family: Consolas; font-size: 10.0pt;"> args</span><span style="font-family: Consolas; font-size: 10.0pt;"></span></div>
<div class="MsoNormal" style="text-autospace: none;">
<span style="color: #3f5fbf; font-family: Consolas; font-size: 10.0pt;"> */</span><span style="font-family: Consolas; font-size: 10.0pt;"></span></div>
<div class="MsoNormal" style="text-autospace: none;">
<span style="color: black; font-family: Consolas; font-size: 10.0pt;"> </span><b><span style="color: #7f0055; font-family: Consolas; font-size: 10.0pt;">public</span></b><span style="color: black; font-family: Consolas; font-size: 10.0pt;"> </span><b><span style="color: #7f0055; font-family: Consolas; font-size: 10.0pt;">static</span></b><span style="color: black; font-family: Consolas; font-size: 10.0pt;"> </span><b><span style="color: #7f0055; font-family: Consolas; font-size: 10.0pt;">void</span></b><span style="color: black; font-family: Consolas; font-size: 10.0pt;"> main(String[] args) {</span><span style="font-family: Consolas; font-size: 10.0pt;"></span></div>
<div class="MsoNormal" style="text-autospace: none;">
<span style="color: black; font-family: Consolas; font-size: 10.0pt;"> List<place> places = </place></span><b><span style="color: #7f0055; font-family: Consolas; font-size: 10.0pt;">new</span></b><span style="color: black; font-family: Consolas; font-size: 10.0pt;"> ArrayList<place>();</place></span><span style="font-family: Consolas; font-size: 10.0pt;"></span></div>
<div class="MsoNormal" style="text-autospace: none;">
<span style="color: black; font-family: Consolas; font-size: 10.0pt;"> places.add(</span><b><span style="color: #7f0055; font-family: Consolas; font-size: 10.0pt;">new</span></b><span style="color: black; font-family: Consolas; font-size: 10.0pt;"> IndiaGate());</span><span style="font-family: Consolas; font-size: 10.0pt;"></span></div>
<div class="MsoNormal" style="text-autospace: none;">
<span style="color: black; font-family: Consolas; font-size: 10.0pt;"> places.add(</span><b><span style="color: #7f0055; font-family: Consolas; font-size: 10.0pt;">new</span></b><span style="color: black; font-family: Consolas; font-size: 10.0pt;"> Tajmahal());</span><span style="font-family: Consolas; font-size: 10.0pt;"></span></div>
<div class="MsoNormal" style="text-autospace: none;">
<span style="color: black; font-family: Consolas; font-size: 10.0pt;"> places.add(</span><b><span style="color: #7f0055; font-family: Consolas; font-size: 10.0pt;">new</span></b><span style="color: black; font-family: Consolas; font-size: 10.0pt;"> BirSujra());</span><span style="font-family: Consolas; font-size: 10.0pt;"></span></div>
<div class="MsoNormal" style="text-autospace: none;">
<span style="color: black; font-family: Consolas; font-size: 10.0pt;"> places.add(</span><b><span style="color: #7f0055; font-family: Consolas; font-size: 10.0pt;">new</span></b><span style="color: black; font-family: Consolas; font-size: 10.0pt;"> RedFort());</span><span style="font-family: Consolas; font-size: 10.0pt;"></span></div>
<div class="MsoNormal" style="text-autospace: none;">
<span style="color: black; font-family: Consolas; font-size: 10.0pt;"> places.add(</span><b><span style="color: #7f0055; font-family: Consolas; font-size: 10.0pt;">new</span></b><span style="color: black; font-family: Consolas; font-size: 10.0pt;"> JamaMasjid());</span><span style="font-family: Consolas; font-size: 10.0pt;"></span></div>
<div class="MsoNormal" style="text-autospace: none;">
<span style="color: black; font-family: Consolas; font-size: 10.0pt;"> Organizer org = </span><b><span style="color: #7f0055; font-family: Consolas; font-size: 10.0pt;">new</span></b><span style="color: black; font-family: Consolas; font-size: 10.0pt;"> Organizer(places);</span><span style="font-family: Consolas; font-size: 10.0pt;"></span></div>
<div class="MsoNormal" style="text-autospace: none;">
<span style="color: black; font-family: Consolas; font-size: 10.0pt;"> System.</span><i><span style="color: #0000c0; font-family: Consolas; font-size: 10.0pt;">out</span></i><span style="font-family: Consolas; font-size: 10.0pt;"></span></div>
<div class="MsoNormal" style="text-autospace: none;">
<span style="color: black; font-family: Consolas; font-size: 10.0pt;"> .println(</span><span style="color: #2a00ff; font-family: Consolas; font-size: 10.0pt;">"Visitor ask Organizer to plan for his visit. Visitor provides Organizer the list of places he is interested in "</span><span style="color: black; font-family: Consolas; font-size: 10.0pt;">);</span><span style="font-family: Consolas; font-size: 10.0pt;"></span></div>
<div class="MsoNormal" style="text-autospace: none;">
<span style="color: black; font-family: Consolas; font-size: 10.0pt;"> org.schedule(</span><b><span style="color: #7f0055; font-family: Consolas; font-size: 10.0pt;">new</span></b><span style="color: black; font-family: Consolas; font-size: 10.0pt;"> Visitor());</span><span style="font-family: Consolas; font-size: 10.0pt;"></span></div>
<div class="MsoNormal" style="text-autospace: none;">
<span style="color: black; font-family: Consolas; font-size: 10.0pt;"> </span><span style="font-family: Consolas; font-size: 10.0pt;"></span></div>
<div class="MsoNormal" style="text-autospace: none;">
<span style="color: black; font-family: Consolas; font-size: 10.0pt;"> System.</span><i><span style="color: #0000c0; font-family: Consolas; font-size: 10.0pt;">out</span></i><span style="color: black; font-family: Consolas; font-size: 10.0pt;">.println(</span><span style="color: #2a00ff; font-family: Consolas; font-size: 10.0pt;">"Visotor Thanks all .. It wwas wondeful experience... truely incredible India"</span><span style="color: black; font-family: Consolas; font-size: 10.0pt;">);</span><span style="font-family: Consolas; font-size: 10.0pt;"></span></div>
<div class="MsoNormal" style="text-autospace: none;">
<br /></div>
<div class="MsoNormal" style="text-autospace: none;">
<span style="color: black; font-family: Consolas; font-size: 10.0pt;"> }</span><span style="font-family: Consolas; font-size: 10.0pt;"></span></div>
<div class="MsoNormal" style="text-autospace: none;">
<br /></div>
<div class="MsoNormal" style="text-autospace: none;">
<span style="color: black; font-family: Consolas; font-size: 10.0pt;"> </span><b><span style="color: #7f0055; font-family: Consolas; font-size: 10.0pt;">public</span></b><span style="color: black; font-family: Consolas; font-size: 10.0pt;"> </span><b><span style="color: #7f0055; font-family: Consolas; font-size: 10.0pt;">void</span></b><span style="color: black; font-family: Consolas; font-size: 10.0pt;"> visit(IndiaGate india) {</span><span style="font-family: Consolas; font-size: 10.0pt;"></span></div>
<div class="MsoNormal" style="text-autospace: none;">
<span style="color: black; font-family: Consolas; font-size: 10.0pt;"> System.</span><i><span style="color: #0000c0; font-family: Consolas; font-size: 10.0pt;">out</span></i><span style="color: black; font-family: Consolas; font-size: 10.0pt;">.println(</span><span style="color: #2a00ff; font-family: Consolas; font-size: 10.0pt;">"visitng india gate....."</span><span style="color: black; font-family: Consolas; font-size: 10.0pt;">);</span><span style="font-family: Consolas; font-size: 10.0pt;"></span></div>
<div class="MsoNormal" style="text-autospace: none;">
<br /></div>
<div class="MsoNormal" style="text-autospace: none;">
<span style="color: black; font-family: Consolas; font-size: 10.0pt;"> }</span><span style="font-family: Consolas; font-size: 10.0pt;"></span></div>
<div class="MsoNormal" style="text-autospace: none;">
<br /></div>
<div class="MsoNormal" style="text-autospace: none;">
<span style="color: black; font-family: Consolas; font-size: 10.0pt;"> </span><b><span style="color: #7f0055; font-family: Consolas; font-size: 10.0pt;">public</span></b><span style="color: black; font-family: Consolas; font-size: 10.0pt;"> </span><b><span style="color: #7f0055; font-family: Consolas; font-size: 10.0pt;">void</span></b><span style="color: black; font-family: Consolas; font-size: 10.0pt;"> visit(Tajmahal india) {</span><span style="font-family: Consolas; font-size: 10.0pt;"></span></div>
<div class="MsoNormal" style="text-autospace: none;">
<span style="color: black; font-family: Consolas; font-size: 10.0pt;"> System.</span><i><span style="color: #0000c0; font-family: Consolas; font-size: 10.0pt;">out</span></i><span style="color: black; font-family: Consolas; font-size: 10.0pt;">.println(</span><span style="color: #2a00ff; font-family: Consolas; font-size: 10.0pt;">"visitng Tajmahal....."</span><span style="color: black; font-family: Consolas; font-size: 10.0pt;">);</span><span style="font-family: Consolas; font-size: 10.0pt;"></span></div>
<div class="MsoNormal" style="text-autospace: none;">
<br /></div>
<div class="MsoNormal" style="text-autospace: none;">
<span style="color: black; font-family: Consolas; font-size: 10.0pt;"> }</span><span style="font-family: Consolas; font-size: 10.0pt;"></span></div>
<div class="MsoNormal" style="text-autospace: none;">
<br /></div>
<div class="MsoNormal" style="text-autospace: none;">
<span style="color: black; font-family: Consolas; font-size: 10.0pt;"> </span><b><span style="color: #7f0055; font-family: Consolas; font-size: 10.0pt;">public</span></b><span style="color: black; font-family: Consolas; font-size: 10.0pt;"> </span><b><span style="color: #7f0055; font-family: Consolas; font-size: 10.0pt;">void</span></b><span style="color: black; font-family: Consolas; font-size: 10.0pt;"> visit(BirSujra birSujra) {</span><span style="font-family: Consolas; font-size: 10.0pt;"></span></div>
<div class="MsoNormal" style="text-autospace: none;">
<span style="color: black; font-family: Consolas; font-size: 10.0pt;"> System.</span><i><span style="color: #0000c0; font-family: Consolas; font-size: 10.0pt;">out</span></i><span style="color: black; font-family: Consolas; font-size: 10.0pt;">.println(</span><span style="color: #2a00ff; font-family: Consolas; font-size: 10.0pt;">"visitng birSujra....."</span><span style="color: black; font-family: Consolas; font-size: 10.0pt;">);</span><span style="font-family: Consolas; font-size: 10.0pt;"></span></div>
<div class="MsoNormal" style="text-autospace: none;">
<br /></div>
<div class="MsoNormal" style="text-autospace: none;">
<span style="color: black; font-family: Consolas; font-size: 10.0pt;"> }</span><span style="font-family: Consolas; font-size: 10.0pt;"></span></div>
<div class="MsoNormal" style="text-autospace: none;">
<br /></div>
<div class="MsoNormal" style="text-autospace: none;">
<span style="color: black; font-family: Consolas; font-size: 10.0pt;"> </span><b><span style="color: #7f0055; font-family: Consolas; font-size: 10.0pt;">public</span></b><span style="color: black; font-family: Consolas; font-size: 10.0pt;"> </span><b><span style="color: #7f0055; font-family: Consolas; font-size: 10.0pt;">void</span></b><span style="color: black; font-family: Consolas; font-size: 10.0pt;"> visit(RedFort redFort) {</span><span style="font-family: Consolas; font-size: 10.0pt;"></span></div>
<div class="MsoNormal" style="text-autospace: none;">
<span style="color: black; font-family: Consolas; font-size: 10.0pt;"> System.</span><i><span style="color: #0000c0; font-family: Consolas; font-size: 10.0pt;">out</span></i><span style="color: black; font-family: Consolas; font-size: 10.0pt;">.println(</span><span style="color: #2a00ff; font-family: Consolas; font-size: 10.0pt;">"visitng RedFort...."</span><span style="color: black; font-family: Consolas; font-size: 10.0pt;">);</span><span style="font-family: Consolas; font-size: 10.0pt;"></span></div>
<div class="MsoNormal" style="text-autospace: none;">
<br /></div>
<div class="MsoNormal" style="text-autospace: none;">
<span style="color: black; font-family: Consolas; font-size: 10.0pt;"> }</span><span style="font-family: Consolas; font-size: 10.0pt;"></span></div>
<div class="MsoNormal" style="text-autospace: none;">
<br /></div>
<div class="MsoNormal" style="text-autospace: none;">
<span style="color: black; font-family: Consolas; font-size: 10.0pt;"> </span><b><span style="color: #7f0055; font-family: Consolas; font-size: 10.0pt;">public</span></b><span style="color: black; font-family: Consolas; font-size: 10.0pt;"> </span><b><span style="color: #7f0055; font-family: Consolas; font-size: 10.0pt;">void</span></b><span style="color: black; font-family: Consolas; font-size: 10.0pt;"> visit(JamaMasjid jamaMasjid) {</span><span style="font-family: Consolas; font-size: 10.0pt;"></span></div>
<div class="MsoNormal" style="text-autospace: none;">
<span style="color: black; font-family: Consolas; font-size: 10.0pt;"> System.</span><i><span style="color: #0000c0; font-family: Consolas; font-size: 10.0pt;">out</span></i><span style="color: black; font-family: Consolas; font-size: 10.0pt;">.println(</span><span style="color: #2a00ff; font-family: Consolas; font-size: 10.0pt;">"visitng JamaMasjid...."</span><span style="color: black; font-family: Consolas; font-size: 10.0pt;">);</span><span style="font-family: Consolas; font-size: 10.0pt;"></span></div>
<div class="MsoNormal" style="text-autospace: none;">
<br /></div>
<div class="MsoNormal" style="text-autospace: none;">
<span style="color: black; font-family: Consolas; font-size: 10.0pt;"> }</span><span style="font-family: Consolas; font-size: 10.0pt;"></span></div>
<div class="MsoNormal" style="text-autospace: none;">
<br /></div>
<div class="MsoNormal" style="text-autospace: none;">
<span style="color: black; font-family: Consolas; font-size: 10.0pt;">}</span><span style="font-family: Consolas; font-size: 10.0pt;"></span></div>
<div class="MsoNormal" style="text-autospace: none;">
<br /></div>
<div class="MsoNormal" style="text-autospace: none;">
<span style="font-family: Consolas; font-size: 10.0pt;"><span style="font-size: small;"><span style="font-family: Arial,Helvetica,sans-serif;"><b><span style="color: #4c1130;">This is contract interface which is helping Visitor to visit the places available in the list. Visitor implements this interface and implement are overloaded methods each referring to one single element /place </span></b></span></span></span></div>
<div class="MsoNormal" style="text-autospace: none;">
</div>
<div class="MsoNormal" style="text-autospace: none;">
<b><span style="color: #7f0055; font-family: Consolas; font-size: 10.0pt;">interface</span></b><span style="color: black; font-family: Consolas; font-size: 10.0pt;"> IVisotor {</span><span style="font-family: Consolas; font-size: 10.0pt;"></span></div>
<div class="MsoNormal" style="text-autospace: none;">
<br /></div>
<div class="MsoNormal" style="text-autospace: none;">
<span style="color: black; font-family: Consolas; font-size: 10.0pt;"> </span><b><span style="color: #7f0055; font-family: Consolas; font-size: 10.0pt;">void</span></b><span style="color: black; font-family: Consolas; font-size: 10.0pt;"> visit(IndiaGate indiaGate);</span><span style="font-family: Consolas; font-size: 10.0pt;"></span></div>
<div class="MsoNormal" style="text-autospace: none;">
<br /></div>
<div class="MsoNormal" style="text-autospace: none;">
<span style="color: black; font-family: Consolas; font-size: 10.0pt;"> </span><b><span style="color: #7f0055; font-family: Consolas; font-size: 10.0pt;">void</span></b><span style="color: black; font-family: Consolas; font-size: 10.0pt;"> visit(Tajmahal tajMahal);</span><span style="font-family: Consolas; font-size: 10.0pt;"></span></div>
<div class="MsoNormal" style="text-autospace: none;">
<br /></div>
<div class="MsoNormal" style="text-autospace: none;">
<span style="color: black; font-family: Consolas; font-size: 10.0pt;"> </span><b><span style="color: #7f0055; font-family: Consolas; font-size: 10.0pt;">void</span></b><span style="color: black; font-family: Consolas; font-size: 10.0pt;"> visit(BirSujra birsujra);</span><span style="font-family: Consolas; font-size: 10.0pt;"></span></div>
<div class="MsoNormal" style="text-autospace: none;">
<br /></div>
<div class="MsoNormal" style="text-autospace: none;">
<span style="color: black; font-family: Consolas; font-size: 10.0pt;"> </span><b><span style="color: #7f0055; font-family: Consolas; font-size: 10.0pt;">void</span></b><span style="color: black; font-family: Consolas; font-size: 10.0pt;"> visit(RedFort redFort);</span><span style="font-family: Consolas; font-size: 10.0pt;"></span></div>
<div class="MsoNormal" style="text-autospace: none;">
<br /></div>
<div class="MsoNormal" style="text-autospace: none;">
<span style="color: black; font-family: Consolas; font-size: 10.0pt;"> </span><b><span style="color: #7f0055; font-family: Consolas; font-size: 10.0pt;">void</span></b><span style="color: black; font-family: Consolas; font-size: 10.0pt;"> visit(JamaMasjid jamaMasjid);</span><span style="font-family: Consolas; font-size: 10.0pt;"></span></div>
<div class="MsoNormal" style="text-autospace: none;">
<span style="color: black; font-family: Consolas; font-size: 10.0pt;">}</span></div>
<div class="MsoNormal" style="text-autospace: none;">
<br /></div>
<div class="MsoNormal">
<span style="font-size: small;"><span style="font-family: Arial,Helvetica,sans-serif;"><span style="color: #741b47;"><b>This is interface for Organizer to implement . It has only schedule method </b></span></span></span></div>
<div class="MsoNormal" style="text-autospace: none;">
<br /></div>
<div class="MsoNormal" style="text-autospace: none;">
<b><span style="color: #7f0055; font-family: Consolas; font-size: 10.0pt;">interface</span></b><span style="color: black; font-family: Consolas; font-size: 10.0pt;"> IOrganize {</span><span style="font-family: Consolas; font-size: 10.0pt;"></span></div>
<div class="MsoNormal" style="text-autospace: none;">
<br /></div>
<div class="MsoNormal" style="text-autospace: none;">
<span style="color: black; font-family: Consolas; font-size: 10.0pt;"> </span><b><span style="color: #7f0055; font-family: Consolas; font-size: 10.0pt;">public</span></b><span style="color: black; font-family: Consolas; font-size: 10.0pt;"> </span><b><span style="color: #7f0055; font-family: Consolas; font-size: 10.0pt;">void</span></b><span style="color: black; font-family: Consolas; font-size: 10.0pt;"> schedule(IVisotor visitor);</span><span style="font-family: Consolas; font-size: 10.0pt;"></span></div>
<div class="MsoNormal" style="text-autospace: none;">
<br /></div>
<div class="MsoNormal" style="text-autospace: none;">
<span style="color: black; font-family: Consolas; font-size: 10.0pt;">}</span><span style="font-family: Consolas; font-size: 10.0pt;"></span></div>
<div class="MsoNormal" style="text-autospace: none;">
<br /></div>
<div class="MsoNormal">
<b><span style="color: #990000;"><span style="font-size: small;"><span style="font-family: Arial,Helvetica,sans-serif;">Organizer takes the list of places in constructor . In schedule method It iterates over Place instances and invoke their accept method to make the places accept the visitor . in accept() method it passes the Visitor as parameter. Each Place instance being iterated here refer to once actual Place / class implementing Place interface</span></span></span></b></div>
<div class="MsoNormal" style="text-autospace: none;">
</div>
<div class="MsoNormal" style="text-autospace: none;">
<b><span style="color: #7f0055; font-family: Consolas; font-size: 10.0pt;">class</span></b><span style="color: black; font-family: Consolas; font-size: 10.0pt;"> Organizer </span><b><span style="color: #7f0055; font-family: Consolas; font-size: 10.0pt;">implements</span></b><span style="color: black; font-family: Consolas; font-size: 10.0pt;"> IOrganize {</span><span style="font-family: Consolas; font-size: 10.0pt;"></span></div>
<div class="MsoNormal" style="text-autospace: none;">
<span style="color: black; font-family: Consolas; font-size: 10.0pt;"> List<place> </place></span><span style="color: #0000c0; font-family: Consolas; font-size: 10.0pt;">places</span><span style="color: black; font-family: Consolas; font-size: 10.0pt;"> = </span><b><span style="color: #7f0055; font-family: Consolas; font-size: 10.0pt;">new</span></b><span style="color: black; font-family: Consolas; font-size: 10.0pt;"> ArrayList<place>();</place></span><span style="font-family: Consolas; font-size: 10.0pt;"></span></div>
<div class="MsoNormal" style="text-autospace: none;">
<br /></div>
<div class="MsoNormal" style="text-autospace: none;">
<span style="color: black; font-family: Consolas; font-size: 10.0pt;"> </span><b><span style="color: #7f0055; font-family: Consolas; font-size: 10.0pt;">public</span></b><span style="color: black; font-family: Consolas; font-size: 10.0pt;"> Organizer(<u>List</u> places) {</span><span style="font-family: Consolas; font-size: 10.0pt;"></span></div>
<div class="MsoNormal" style="text-autospace: none;">
<span style="color: black; font-family: Consolas; font-size: 10.0pt;"> </span><b><span style="color: #7f0055; font-family: Consolas; font-size: 10.0pt;">this</span></b><span style="color: black; font-family: Consolas; font-size: 10.0pt;">.</span><span style="color: #0000c0; font-family: Consolas; font-size: 10.0pt;">places</span><span style="color: black; font-family: Consolas; font-size: 10.0pt;"> = <u>places</u>;</span><span style="font-family: Consolas; font-size: 10.0pt;"></span></div>
<div class="MsoNormal" style="text-autospace: none;">
<span style="color: black; font-family: Consolas; font-size: 10.0pt;"> }</span><span style="font-family: Consolas; font-size: 10.0pt;"></span></div>
<div class="MsoNormal" style="text-autospace: none;">
<br /></div>
<div class="MsoNormal" style="text-autospace: none;">
<span style="color: black; font-family: Consolas; font-size: 10.0pt;"> </span><b><span style="color: #7f0055; font-family: Consolas; font-size: 10.0pt;">public</span></b><span style="color: black; font-family: Consolas; font-size: 10.0pt;"> </span><b><span style="color: #7f0055; font-family: Consolas; font-size: 10.0pt;">void</span></b><span style="color: black; font-family: Consolas; font-size: 10.0pt;"> schedule(IVisotor visitor) {</span><span style="font-family: Consolas; font-size: 10.0pt;"></span></div>
<div class="MsoNormal" style="text-autospace: none;">
<br /></div>
<div class="MsoNormal" style="text-autospace: none;">
<span style="color: black; font-family: Consolas; font-size: 10.0pt;"> System.</span><i><span style="color: #0000c0; font-family: Consolas; font-size: 10.0pt;">out</span></i><span style="font-family: Consolas; font-size: 10.0pt;"></span></div>
<div class="MsoNormal" style="text-autospace: none;">
<span style="color: black; font-family: Consolas; font-size: 10.0pt;"> .println(</span><span style="color: #2a00ff; font-family: Consolas; font-size: 10.0pt;">"Organizer get through the process to initiate the visit and ask place coordinators to welcomes the visitor "</span><span style="color: black; font-family: Consolas; font-size: 10.0pt;">);</span><span style="font-family: Consolas; font-size: 10.0pt;"></span></div>
<div class="MsoNormal" style="text-autospace: none;">
<br /></div>
<div class="MsoNormal" style="text-autospace: none;">
<span style="color: black; font-family: Consolas; font-size: 10.0pt;"> </span><b><span style="color: #7f0055; font-family: Consolas; font-size: 10.0pt;">for</span></b><span style="color: black; font-family: Consolas; font-size: 10.0pt;"> (Place place : </span><span style="color: #0000c0; font-family: Consolas; font-size: 10.0pt;">places</span><span style="color: black; font-family: Consolas; font-size: 10.0pt;">) {</span><span style="font-family: Consolas; font-size: 10.0pt;"></span></div>
<div class="MsoNormal" style="text-autospace: none;">
<span style="color: black; font-family: Consolas; font-size: 10.0pt;"> place.accept(visitor);</span><span style="font-family: Consolas; font-size: 10.0pt;"></span></div>
<div class="MsoNormal" style="text-autospace: none;">
<span style="color: black; font-family: Consolas; font-size: 10.0pt;"> }</span><span style="font-family: Consolas; font-size: 10.0pt;"></span></div>
<div class="MsoNormal" style="text-autospace: none;">
<br /></div>
<div class="MsoNormal" style="text-autospace: none;">
<span style="color: black; font-family: Consolas; font-size: 10.0pt;"> }</span><span style="font-family: Consolas; font-size: 10.0pt;"></span></div>
<div class="MsoNormal" style="text-autospace: none;">
<br /></div>
<div class="MsoNormal" style="text-autospace: none;">
<span style="color: black; font-family: Consolas; font-size: 10.0pt;">}</span><span style="font-family: Consolas; font-size: 10.0pt;"></span></div>
<div class="MsoNormal" style="text-autospace: none;">
<br /></div>
<div class="MsoNormal">
<span style="font-family: Arial,Helvetica,sans-serif;"><span style="font-size: small;"><b><span style="color: #990000;">Interface for place . Has only one method . Accept . This needs to be implemented by all Place classes</span></b></span></span></div>
<div class="MsoNormal" style="text-autospace: none;">
</div>
<div class="MsoNormal" style="text-autospace: none;">
<b><span style="color: #7f0055; font-family: Consolas; font-size: 10.0pt;">interface</span></b><span style="color: black; font-family: Consolas; font-size: 10.0pt;"> Place {</span><span style="font-family: Consolas; font-size: 10.0pt;"></span></div>
<div class="MsoNormal" style="text-autospace: none;">
<br /></div>
<div class="MsoNormal" style="text-autospace: none;">
<span style="color: black; font-family: Consolas; font-size: 10.0pt;"> </span><b><span style="color: #7f0055; font-family: Consolas; font-size: 10.0pt;">void</span></b><span style="color: black; font-family: Consolas; font-size: 10.0pt;"> accept(IVisotor visitor);</span></div>
<div class="MsoNormal" style="text-autospace: none;">
<br /></div>
<div class="MsoNormal" style="text-autospace: none;">
<span style="color: black; font-family: Consolas; font-size: 10.0pt;">}</span></div>
<div class="MsoNormal" style="text-autospace: none;">
<br /></div>
<div class="MsoNormal">
<span style="color: #990000;"><b><span style="font-size: small;"><span style="font-family: Arial,Helvetica,sans-serif;">One of the class implementing Place interface and defining the logic of accept method . Accept method will accept the visitor and then on visitor instance invoke visit method and pass the current place instance to the visitor . Visitor can use this instance to visit the place </span></span></b></span></div>
<div class="MsoNormal" style="text-autospace: none;">
<br /></div>
<div class="MsoNormal" style="text-autospace: none;">
<b><span style="color: #7f0055; font-family: Consolas; font-size: 10.0pt;">class</span></b><span style="color: black; font-family: Consolas; font-size: 10.0pt;"> IndiaGate </span><b><span style="color: #7f0055; font-family: Consolas; font-size: 10.0pt;">implements</span></b><span style="color: black; font-family: Consolas; font-size: 10.0pt;"> Place {</span><span style="font-family: Consolas; font-size: 10.0pt;"></span></div>
<div class="MsoNormal" style="text-autospace: none;">
<br /></div>
<div class="MsoNormal" style="text-autospace: none;">
<span style="color: black; font-family: Consolas; font-size: 10.0pt;"> </span><b><span style="color: #7f0055; font-family: Consolas; font-size: 10.0pt;">public</span></b><span style="color: black; font-family: Consolas; font-size: 10.0pt;"> </span><b><span style="color: #7f0055; font-family: Consolas; font-size: 10.0pt;">void</span></b><span style="color: black; font-family: Consolas; font-size: 10.0pt;"> accept(IVisotor visitor) {</span><span style="font-family: Consolas; font-size: 10.0pt;"></span></div>
<div class="MsoNormal" style="text-autospace: none;">
<br /></div>
<div class="MsoNormal" style="text-autospace: none;">
<span style="color: black; font-family: Consolas; font-size: 10.0pt;"> System.</span><i><span style="color: #0000c0; font-family: Consolas; font-size: 10.0pt;">out</span></i><span style="color: black; font-family: Consolas; font-size: 10.0pt;">.println(</span><span style="color: #2a00ff; font-family: Consolas; font-size: 10.0pt;">"IndiaGate accept the visotr and welcomes him"</span><span style="color: black; font-family: Consolas; font-size: 10.0pt;">);</span><span style="font-family: Consolas; font-size: 10.0pt;"></span></div>
<div class="MsoNormal" style="text-autospace: none;">
<br /></div>
<div class="MsoNormal" style="text-autospace: none;">
<span style="color: black; font-family: Consolas; font-size: 10.0pt;"> System.</span><i><span style="color: #0000c0; font-family: Consolas; font-size: 10.0pt;">out</span></i><span style="color: black; font-family: Consolas; font-size: 10.0pt;">.println(</span><span style="color: #2a00ff; font-family: Consolas; font-size: 10.0pt;">"IndiaGate visit is started"</span><span style="color: black; font-family: Consolas; font-size: 10.0pt;">);</span><span style="font-family: Consolas; font-size: 10.0pt;"></span></div>
<div class="MsoNormal" style="text-autospace: none;">
<span style="color: black; font-family: Consolas; font-size: 10.0pt;"> visitor.visit(</span><b><span style="color: #7f0055; font-family: Consolas; font-size: 10.0pt;">this</span></b><span style="color: black; font-family: Consolas; font-size: 10.0pt;">);</span><span style="font-family: Consolas; font-size: 10.0pt;"></span></div>
<div class="MsoNormal" style="text-autospace: none;">
<span style="color: black; font-family: Consolas; font-size: 10.0pt;"> }</span><span style="font-family: Consolas; font-size: 10.0pt;"></span></div>
<div class="MsoNormal" style="text-autospace: none;">
<br /></div>
<div class="MsoNormal" style="text-autospace: none;">
<span style="color: black; font-family: Consolas; font-size: 10.0pt;">}</span><span style="font-family: Consolas; font-size: 10.0pt;"></span></div>
<div class="MsoNormal" style="text-autospace: none;">
<br /></div>
<br />
<div class="MsoNormal">
<span style="color: #990000;"><b><span style="font-size: small;"><span style="font-family: Arial,Helvetica,sans-serif;">One of the class implementing Place interface and defining the logic of accept method . Accept method will accept the visitor and then on visitor instance invoke visit method and pass the current place instance to the visitor . Visitor can use this instance to visit the place </span></span></b></span></div>
<br />
<div class="MsoNormal" style="text-autospace: none;">
<br /></div>
<div class="MsoNormal" style="text-autospace: none;">
<b><span style="color: #7f0055; font-family: Consolas; font-size: 10.0pt;">class</span></b><span style="color: black; font-family: Consolas; font-size: 10.0pt;"> Tajmahal </span><b><span style="color: #7f0055; font-family: Consolas; font-size: 10.0pt;">implements</span></b><span style="color: black; font-family: Consolas; font-size: 10.0pt;"> Place {</span><span style="font-family: Consolas; font-size: 10.0pt;"></span></div>
<div class="MsoNormal" style="text-autospace: none;">
<br /></div>
<div class="MsoNormal" style="text-autospace: none;">
<span style="color: black; font-family: Consolas; font-size: 10.0pt;"> </span><b><span style="color: #7f0055; font-family: Consolas; font-size: 10.0pt;">public</span></b><span style="color: black; font-family: Consolas; font-size: 10.0pt;"> </span><b><span style="color: #7f0055; font-family: Consolas; font-size: 10.0pt;">void</span></b><span style="color: black; font-family: Consolas; font-size: 10.0pt;"> accept(IVisotor visitor) {</span><span style="font-family: Consolas; font-size: 10.0pt;"></span></div>
<div class="MsoNormal" style="text-autospace: none;">
<br /></div>
<div class="MsoNormal" style="text-autospace: none;">
<span style="color: black; font-family: Consolas; font-size: 10.0pt;"> System.</span><i><span style="color: #0000c0; font-family: Consolas; font-size: 10.0pt;">out</span></i><span style="color: black; font-family: Consolas; font-size: 10.0pt;">.println(</span><span style="color: #2a00ff; font-family: Consolas; font-size: 10.0pt;">"Tajmahal accept the visotr and welcomes him"</span><span style="color: black; font-family: Consolas; font-size: 10.0pt;">);</span><span style="font-family: Consolas; font-size: 10.0pt;"></span></div>
<div class="MsoNormal" style="text-autospace: none;">
<br /></div>
<div class="MsoNormal" style="text-autospace: none;">
<span style="color: black; font-family: Consolas; font-size: 10.0pt;"> System.</span><i><span style="color: #0000c0; font-family: Consolas; font-size: 10.0pt;">out</span></i><span style="color: black; font-family: Consolas; font-size: 10.0pt;">.println(</span><span style="color: #2a00ff; font-family: Consolas; font-size: 10.0pt;">"Tajmahal visit is started"</span><span style="color: black; font-family: Consolas; font-size: 10.0pt;">);</span><span style="font-family: Consolas; font-size: 10.0pt;"></span></div>
<div class="MsoNormal" style="text-autospace: none;">
<span style="color: black; font-family: Consolas; font-size: 10.0pt;"> visitor.visit(</span><b><span style="color: #7f0055; font-family: Consolas; font-size: 10.0pt;">this</span></b><span style="color: black; font-family: Consolas; font-size: 10.0pt;">);</span><span style="font-family: Consolas; font-size: 10.0pt;"></span></div>
<div class="MsoNormal" style="text-autospace: none;">
<span style="color: black; font-family: Consolas; font-size: 10.0pt;"> }</span><span style="font-family: Consolas; font-size: 10.0pt;"></span></div>
<div class="MsoNormal" style="text-autospace: none;">
<br /></div>
<div class="MsoNormal" style="text-autospace: none;">
<span style="color: black; font-family: Consolas; font-size: 10.0pt;">}</span><span style="font-family: Consolas; font-size: 10.0pt;"></span></div>
<div class="MsoNormal" style="text-autospace: none;">
<br /></div>
<br />
<div class="MsoNormal">
<span style="color: #990000;"><b><span style="font-size: small;"><span style="font-family: Arial,Helvetica,sans-serif;">One of the class implementing Place interface and defining the logic of accept method . Accept method will accept the visitor and then on visitor instance invoke visit method and pass the current place instance to the visitor . Visitor can use this instance to visit the place </span></span></b></span></div>
<br />
<div class="MsoNormal" style="text-autospace: none;">
<br /></div>
<div class="MsoNormal" style="text-autospace: none;">
<b><span style="color: #7f0055; font-family: Consolas; font-size: 10.0pt;">class</span></b><span style="color: black; font-family: Consolas; font-size: 10.0pt;"> RedFort </span><b><span style="color: #7f0055; font-family: Consolas; font-size: 10.0pt;">implements</span></b><span style="color: black; font-family: Consolas; font-size: 10.0pt;"> Place {</span><span style="font-family: Consolas; font-size: 10.0pt;"></span></div>
<div class="MsoNormal" style="text-autospace: none;">
<br /></div>
<div class="MsoNormal" style="text-autospace: none;">
<span style="color: black; font-family: Consolas; font-size: 10.0pt;"> </span><b><span style="color: #7f0055; font-family: Consolas; font-size: 10.0pt;">public</span></b><span style="color: black; font-family: Consolas; font-size: 10.0pt;"> </span><b><span style="color: #7f0055; font-family: Consolas; font-size: 10.0pt;">void</span></b><span style="color: black; font-family: Consolas; font-size: 10.0pt;"> accept(IVisotor visitor) {</span><span style="font-family: Consolas; font-size: 10.0pt;"></span></div>
<div class="MsoNormal" style="text-autospace: none;">
<span style="color: black; font-family: Consolas; font-size: 10.0pt;"> System.</span><i><span style="color: #0000c0; font-family: Consolas; font-size: 10.0pt;">out</span></i><span style="color: black; font-family: Consolas; font-size: 10.0pt;">.println(</span><span style="color: #2a00ff; font-family: Consolas; font-size: 10.0pt;">"RedFort accept the visotr and welcomes him"</span><span style="color: black; font-family: Consolas; font-size: 10.0pt;">);</span><span style="font-family: Consolas; font-size: 10.0pt;"></span></div>
<div class="MsoNormal" style="text-autospace: none;">
<br /></div>
<div class="MsoNormal" style="text-autospace: none;">
<span style="color: black; font-family: Consolas; font-size: 10.0pt;"> System.</span><i><span style="color: #0000c0; font-family: Consolas; font-size: 10.0pt;">out</span></i><span style="color: black; font-family: Consolas; font-size: 10.0pt;">.println(</span><span style="color: #2a00ff; font-family: Consolas; font-size: 10.0pt;">"RedFort visit is started"</span><span style="color: black; font-family: Consolas; font-size: 10.0pt;">);</span><span style="font-family: Consolas; font-size: 10.0pt;"></span></div>
<div class="MsoNormal" style="text-autospace: none;">
<span style="color: black; font-family: Consolas; font-size: 10.0pt;"> visitor.visit(</span><b><span style="color: #7f0055; font-family: Consolas; font-size: 10.0pt;">this</span></b><span style="color: black; font-family: Consolas; font-size: 10.0pt;">);</span><span style="font-family: Consolas; font-size: 10.0pt;"></span></div>
<div class="MsoNormal" style="text-autospace: none;">
<span style="color: black; font-family: Consolas; font-size: 10.0pt;"> }</span><span style="font-family: Consolas; font-size: 10.0pt;"></span></div>
<div class="MsoNormal" style="text-autospace: none;">
<br /></div>
<div class="MsoNormal" style="text-autospace: none;">
<span style="color: black; font-family: Consolas; font-size: 10.0pt;">}</span><span style="font-family: Consolas; font-size: 10.0pt;"></span></div>
<div class="MsoNormal" style="text-autospace: none;">
<br /></div>
<br />
<br />
<script type="text/javascript">
google_ad_client = "ca-pub-8470945096737641";
/* seo banner */
google_ad_slot = "3657212241";
google_ad_width = 468;
google_ad_height = 300;
//</script>
</div>
--><br /><script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript">
</script><br />
<br />
<div class="MsoNormal">
<span style="color: #990000;"><b><span style="font-size: small;"><span style="font-family: Arial,Helvetica,sans-serif;">One of the class implementing Place interface and defining the logic of accept method . Accept method will accept the visitor and then on visitor instance invoke visit method and pass the current place instance to the visitor . Visitor can use this instance to visit the place </span></span></b></span></div>
<br />
<div class="MsoNormal" style="text-autospace: none;">
<br /></div>
<div class="MsoNormal" style="text-autospace: none;">
<b><span style="color: #7f0055; font-family: Consolas; font-size: 10.0pt;">class</span></b><span style="color: black; font-family: Consolas; font-size: 10.0pt;"> JamaMasjid </span><b><span style="color: #7f0055; font-family: Consolas; font-size: 10.0pt;">implements</span></b><span style="color: black; font-family: Consolas; font-size: 10.0pt;"> Place {</span><span style="font-family: Consolas; font-size: 10.0pt;"></span></div>
<div class="MsoNormal" style="text-autospace: none;">
<br /></div>
<div class="MsoNormal" style="text-autospace: none;">
<span style="color: black; font-family: Consolas; font-size: 10.0pt;"> </span><b><span style="color: #7f0055; font-family: Consolas; font-size: 10.0pt;">public</span></b><span style="color: black; font-family: Consolas; font-size: 10.0pt;"> </span><b><span style="color: #7f0055; font-family: Consolas; font-size: 10.0pt;">void</span></b><span style="color: black; font-family: Consolas; font-size: 10.0pt;"> accept(IVisotor visitor) {</span><span style="font-family: Consolas; font-size: 10.0pt;"></span></div>
<div class="MsoNormal" style="text-autospace: none;">
<span style="color: black; font-family: Consolas; font-size: 10.0pt;"> System.</span><i><span style="color: #0000c0; font-family: Consolas; font-size: 10.0pt;">out</span></i><span style="color: black; font-family: Consolas; font-size: 10.0pt;">.println(</span><span style="color: #2a00ff; font-family: Consolas; font-size: 10.0pt;">"JamaMasjid accept the visotr and welcomes him"</span><span style="color: black; font-family: Consolas; font-size: 10.0pt;">);</span><span style="font-family: Consolas; font-size: 10.0pt;"></span></div>
<div class="MsoNormal" style="text-autospace: none;">
<br /></div>
<div class="MsoNormal" style="text-autospace: none;">
<span style="color: black; font-family: Consolas; font-size: 10.0pt;"> System.</span><i><span style="color: #0000c0; font-family: Consolas; font-size: 10.0pt;">out</span></i><span style="color: black; font-family: Consolas; font-size: 10.0pt;">.println(</span><span style="color: #2a00ff; font-family: Consolas; font-size: 10.0pt;">"JamaMasjid visit is started"</span><span style="color: black; font-family: Consolas; font-size: 10.0pt;">);</span><span style="font-family: Consolas; font-size: 10.0pt;"></span></div>
<div class="MsoNormal" style="text-autospace: none;">
<span style="color: black; font-family: Consolas; font-size: 10.0pt;"> visitor.visit(</span><b><span style="color: #7f0055; font-family: Consolas; font-size: 10.0pt;">this</span></b><span style="color: black; font-family: Consolas; font-size: 10.0pt;">);</span><span style="font-family: Consolas; font-size: 10.0pt;"></span></div>
<div class="MsoNormal" style="text-autospace: none;">
<span style="color: black; font-family: Consolas; font-size: 10.0pt;"> }</span><span style="font-family: Consolas; font-size: 10.0pt;"></span></div>
<div class="MsoNormal" style="text-autospace: none;">
<br /></div>
<div class="MsoNormal" style="text-autospace: none;">
<span style="color: black; font-family: Consolas; font-size: 10.0pt;">}</span><span style="font-family: Consolas; font-size: 10.0pt;"></span></div>
<div class="MsoNormal" style="text-autospace: none;">
<br /></div>
<br />
<div class="MsoNormal">
<span style="color: #990000;"><b><span style="font-size: small;"><span style="font-family: Arial,Helvetica,sans-serif;">One of the class implementing Place interface and defining the logic of accept method . Accept method will accept the visitor and then on visitor instance invoke visit method and pass the current place instance to the visitor . Visitor can use this instance to visit the place </span></span></b></span></div>
<br />
<div class="MsoNormal" style="text-autospace: none;">
<br /></div>
<div class="MsoNormal" style="text-autospace: none;">
<b><span style="color: #7f0055; font-family: Consolas; font-size: 10.0pt;">class</span></b><span style="color: black; font-family: Consolas; font-size: 10.0pt;"> BirSujra </span><b><span style="color: #7f0055; font-family: Consolas; font-size: 10.0pt;">implements</span></b><span style="color: black; font-family: Consolas; font-size: 10.0pt;"> Place {</span><span style="font-family: Consolas; font-size: 10.0pt;"></span></div>
<div class="MsoNormal" style="text-autospace: none;">
<br /></div>
<div class="MsoNormal" style="text-autospace: none;">
<span style="color: black; font-family: Consolas; font-size: 10.0pt;"> </span><b><span style="color: #7f0055; font-family: Consolas; font-size: 10.0pt;">public</span></b><span style="color: black; font-family: Consolas; font-size: 10.0pt;"> </span><b><span style="color: #7f0055; font-family: Consolas; font-size: 10.0pt;">void</span></b><span style="color: black; font-family: Consolas; font-size: 10.0pt;"> accept(IVisotor visitor) {</span><span style="font-family: Consolas; font-size: 10.0pt;"></span></div>
<div class="MsoNormal" style="text-autospace: none;">
<span style="color: black; font-family: Consolas; font-size: 10.0pt;"> System.</span><i><span style="color: #0000c0; font-family: Consolas; font-size: 10.0pt;">out</span></i><span style="color: black; font-family: Consolas; font-size: 10.0pt;">.println(</span><span style="color: #2a00ff; font-family: Consolas; font-size: 10.0pt;">"BirSujra accept the visotr and welcomes him"</span><span style="color: black; font-family: Consolas; font-size: 10.0pt;">);</span><span style="font-family: Consolas; font-size: 10.0pt;"></span></div>
<div class="MsoNormal" style="text-autospace: none;">
<br /></div>
<div class="MsoNormal" style="text-autospace: none;">
<span style="color: black; font-family: Consolas; font-size: 10.0pt;"> System.</span><i><span style="color: #0000c0; font-family: Consolas; font-size: 10.0pt;">out</span></i><span style="color: black; font-family: Consolas; font-size: 10.0pt;">.println(</span><span style="color: #2a00ff; font-family: Consolas; font-size: 10.0pt;">"BirSujra visit is started"</span><span style="color: black; font-family: Consolas; font-size: 10.0pt;">);</span><span style="font-family: Consolas; font-size: 10.0pt;"></span></div>
<div class="MsoNormal" style="text-autospace: none;">
<br /></div>
<div class="MsoNormal" style="text-autospace: none;">
<span style="color: black; font-family: Consolas; font-size: 10.0pt;"> visitor.visit(</span><b><span style="color: #7f0055; font-family: Consolas; font-size: 10.0pt;">this</span></b><span style="color: black; font-family: Consolas; font-size: 10.0pt;">);</span><span style="font-family: Consolas; font-size: 10.0pt;"></span></div>
<div class="MsoNormal" style="text-autospace: none;">
<span style="color: black; font-family: Consolas; font-size: 10.0pt;"> }</span><span style="font-family: Consolas; font-size: 10.0pt;"></span></div>
<div class="MsoNormal" style="text-autospace: none;">
<br /></div>
<div class="MsoNormal" style="text-autospace: none;">
<span style="color: black; font-family: Consolas; font-size: 10.0pt;">}</span><span style="font-family: Consolas; font-size: 10.0pt;"></span></div>
<div class="MsoNormal">
<br /></div>
<br />
<br />
<br />
<script type="text/javascript">
google_ad_client = "ca-pub-8470945096737641";
/* 200x200, created 6/23/09 */
google_ad_slot = "8930436823";
google_ad_width = 200;
google_ad_height = 200;
</script><br />
<script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript">
</script><br />
<br />
<br />
<div class="MsoNormal">
<span style="font-size: small;"><span style="font-family: Arial,Helvetica,sans-serif;"><span style="color: #990000;"><b> Now let us see the output of console</b></span></span></span></div>
<div class="MsoNormal">
-------------------------------------------------------------------------------</div>
<div class="MsoNormal" style="text-autospace: none;">
<span style="color: red;"><b><span style="font-family: "Helvetica Neue",Arial,Helvetica,sans-serif;"><span style="font-size: 10pt;">Visitor ask Organizer to plan for his visit. Visitor provides Organizer the list of places he is interested in </span></span></b></span></div>
<div class="MsoNormal" style="text-autospace: none;">
<br /></div>
<span style="color: red;"><b><span style="font-family: "Helvetica Neue",Arial,Helvetica,sans-serif;"> </span></b></span><br />
<div class="MsoNormal" style="text-autospace: none;">
<span style="color: red;"><b><span style="font-family: "Helvetica Neue",Arial,Helvetica,sans-serif;"><span style="font-size: 10pt;">Organizer get through the process to initiate the visit and ask place coordinators to welcomes the visitor </span></span></b></span></div>
<div class="MsoNormal" style="text-autospace: none;">
<br /></div>
<span style="color: red;"><b><span style="font-family: "Helvetica Neue",Arial,Helvetica,sans-serif;"> </span></b></span><br />
<div class="MsoNormal" style="text-autospace: none;">
<span style="color: red;"><b><span style="font-family: "Helvetica Neue",Arial,Helvetica,sans-serif;"><span style="font-size: 10pt;">IndiaGate accept the visotr and welcomes him</span></span></b></span></div>
<div class="MsoNormal" style="text-autospace: none;">
<span style="color: red;"><b><span style="font-family: "Helvetica Neue",Arial,Helvetica,sans-serif;"><span style="font-size: 10pt;"> </span><span style="font-size: 10pt;"></span></span></b></span><span style="color: red;"><b><span style="font-family: "Helvetica Neue",Arial,Helvetica,sans-serif;"></span></b></span><span style="color: red;"><b><span style="font-family: "Helvetica Neue",Arial,Helvetica,sans-serif;"><span style="font-size: 10pt;">IndiaGate visit is started</span></span></b></span><span style="font-family: "Helvetica Neue",Arial,Helvetica,sans-serif;"></span></div>
<span style="color: red;"><b></b></span><br />
<div class="MsoNormal" style="text-autospace: none;">
<span style="color: red;"><b><span style="font-family: "Helvetica Neue",Arial,Helvetica,sans-serif;"><span style="font-size: 10pt;"> </span><span style="font-size: 10pt;"></span></span></b></span><span style="color: red;"><b><span style="font-family: "Helvetica Neue",Arial,Helvetica,sans-serif;"></span></b></span><span style="color: red;"><b><span style="font-family: "Helvetica Neue",Arial,Helvetica,sans-serif;"><span style="font-size: 10pt;">visiting india gate.....</span><span style="font-size: 10pt;"></span></span></b></span><span style="color: red;"><b><span style="font-family: "Helvetica Neue",Arial,Helvetica,sans-serif;"></span></b></span> </div>
<span style="color: red;"><b><span style="font-family: "Helvetica Neue",Arial,Helvetica,sans-serif;"></span></b></span><br />
<div class="MsoNormal" style="text-autospace: none;">
<br /></div>
<div class="MsoNormal" style="text-autospace: none;">
<span style="color: red;"><b><span style="font-family: "Helvetica Neue",Arial,Helvetica,sans-serif;"><span style="font-size: 10pt;">Tajmahal accept the visotr and welcomes him</span><span style="font-size: 10pt;"></span></span></b></span></div>
<span style="color: red;"><b><span style="font-family: "Helvetica Neue",Arial,Helvetica,sans-serif;"> </span></b></span><br />
<div class="MsoNormal" style="text-autospace: none;">
<span style="color: red;"><b><span style="font-family: "Helvetica Neue",Arial,Helvetica,sans-serif;"><span style="font-size: 10pt;">Tajmahal visit is started</span></span></b></span></div>
<div class="MsoNormal" style="text-autospace: none;">
<span style="color: red;"><b><span style="font-family: "Helvetica Neue",Arial,Helvetica,sans-serif;"><span style="font-size: 10pt;"> </span><span style="font-size: 10pt;"></span></span></b></span><span style="color: red;"><b><span style="font-family: "Helvetica Neue",Arial,Helvetica,sans-serif;"></span></b></span><span style="color: red;"><b><span style="font-family: "Helvetica Neue",Arial,Helvetica,sans-serif;"><span style="font-size: 10pt;">visiting Tajmahal.....</span><span style="font-size: 10pt;"></span></span></b></span><span style="color: red;"><b><span style="font-family: "Helvetica Neue",Arial,Helvetica,sans-serif;"></span></b></span> </div>
<span style="color: red;"><b><span style="font-family: "Helvetica Neue",Arial,Helvetica,sans-serif;"></span></b></span><br />
<div class="MsoNormal" style="text-autospace: none;">
<br /></div>
<div class="MsoNormal" style="text-autospace: none;">
<span style="color: red;"><b><span style="font-family: "Helvetica Neue",Arial,Helvetica,sans-serif;"><span style="font-size: 10pt;">BirSujra accept the visotr and welcomes him</span><span style="font-size: 10pt;"></span></span></b></span></div>
<span style="color: red;"><b><span style="font-family: "Helvetica Neue",Arial,Helvetica,sans-serif;"> </span></b></span><br />
<div class="MsoNormal" style="text-autospace: none;">
<span style="color: red;"><b><span style="font-family: "Helvetica Neue",Arial,Helvetica,sans-serif;"><span style="font-size: 10pt;">BirSujra visit is started</span></span></b></span></div>
<div class="MsoNormal" style="text-autospace: none;">
<span style="color: red;"><b><span style="font-family: "Helvetica Neue",Arial,Helvetica,sans-serif;"><span style="font-size: 10pt;"> </span><span style="font-size: 10pt;"></span></span></b></span><span style="color: red;"><b><span style="font-family: "Helvetica Neue",Arial,Helvetica,sans-serif;"></span></b></span><span style="color: red;"><b><span style="font-family: "Helvetica Neue",Arial,Helvetica,sans-serif;"><span style="font-size: 10pt;">visitng birSujra.....</span><span style="font-size: 10pt;"></span></span></b></span><span style="color: red;"><b><span style="font-family: "Helvetica Neue",Arial,Helvetica,sans-serif;"></span></b></span> </div>
<span style="color: red;"><b><span style="font-family: "Helvetica Neue",Arial,Helvetica,sans-serif;"></span></b></span><br />
<div class="MsoNormal" style="text-autospace: none;">
<br /></div>
<div class="MsoNormal" style="text-autospace: none;">
<span style="color: red;"><b><span style="font-family: "Helvetica Neue",Arial,Helvetica,sans-serif;"><span style="font-size: 10pt;">RedFort accept the visotr and welcomes him</span><span style="font-size: 10pt;"></span></span></b></span></div>
<span style="color: red;"><b><span style="font-family: "Helvetica Neue",Arial,Helvetica,sans-serif;"> </span></b></span><br />
<div class="MsoNormal" style="text-autospace: none;">
<span style="color: red;"><b><span style="font-family: "Helvetica Neue",Arial,Helvetica,sans-serif;"><span style="font-size: 10pt;">RedFort visit is started</span></span></b></span></div>
<div class="MsoNormal" style="text-autospace: none;">
<span style="color: red;"><b><span style="font-family: "Helvetica Neue",Arial,Helvetica,sans-serif;"><span style="font-size: 10pt;"> </span><span style="font-size: 10pt;"></span></span></b></span><span style="color: red;"><b><span style="font-family: "Helvetica Neue",Arial,Helvetica,sans-serif;"></span></b></span><span style="color: red;"><b><span style="font-family: "Helvetica Neue",Arial,Helvetica,sans-serif;"><span style="font-size: 10pt;">visitng RedFort....</span><span style="font-size: 10pt;"></span></span></b></span><span style="color: red;"><b><span style="font-family: "Helvetica Neue",Arial,Helvetica,sans-serif;"></span></b></span> </div>
<span style="color: red;"><b><span style="font-family: "Helvetica Neue",Arial,Helvetica,sans-serif;"></span></b></span><br />
<div class="MsoNormal" style="text-autospace: none;">
<br /></div>
<div class="MsoNormal" style="text-autospace: none;">
<span style="color: red;"><b><span style="font-family: "Helvetica Neue",Arial,Helvetica,sans-serif;"><span style="font-size: 10pt;">JamaMasjid accept the visotr and welcomes him</span><span style="font-size: 10pt;"></span></span></b></span></div>
<span style="color: red;"><b><span style="font-family: "Helvetica Neue",Arial,Helvetica,sans-serif;"> </span></b></span><br />
<div class="MsoNormal" style="text-autospace: none;">
<span style="color: red;"><b><span style="font-family: "Helvetica Neue",Arial,Helvetica,sans-serif;"><span style="font-size: 10pt;">JamaMasjid visit is started</span></span></b></span></div>
<div class="MsoNormal" style="text-autospace: none;">
<span style="color: red;"><b><span style="font-family: "Helvetica Neue",Arial,Helvetica,sans-serif;"><span style="font-size: 10pt;"> </span><span style="font-size: 10pt;"></span></span></b></span><span style="color: red;"><b><span style="font-family: "Helvetica Neue",Arial,Helvetica,sans-serif;"></span></b></span><span style="color: red;"><b><span style="font-family: "Helvetica Neue",Arial,Helvetica,sans-serif;"><span style="font-size: 10pt;">visitng JamaMasjid....</span><span style="font-size: 10pt;"></span></span></b></span><span style="color: red;"><b><span style="font-family: "Helvetica Neue",Arial,Helvetica,sans-serif;"></span></b></span> </div>
<span style="color: red;"><b><span style="font-family: "Helvetica Neue",Arial,Helvetica,sans-serif;"></span></b></span><br />
<div class="MsoNormal" style="text-autospace: none;">
<br /></div>
<div class="MsoNormal" style="text-autospace: none;">
<span style="color: red;"><b><span style="font-family: "Helvetica Neue",Arial,Helvetica,sans-serif;"><span style="font-size: 10pt;">Visotor Thanks all .. It wwas wondeful experience... truly incredible India</span><span style="font-size: 10pt;"></span></span></b></span></div>
<span style="color: red;"><b><span style="font-family: "Helvetica Neue",Arial,Helvetica,sans-serif;"> </span></b></span><br />
<div class="MsoNormal">
<br /></div>
MANOJ KUMARhttp://www.blogger.com/profile/00421517842858762886noreply@blogger.com0