<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:blogger='http://schemas.google.com/blogger/2008' xmlns:georss='http://www.georss.org/georss' xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-4625702208935784578</id><updated>2024-11-01T01:53:06.273-07:00</updated><category term="java"/><category term="gwt"/><category term="gwt . dialogbox"/><category term="url"/><category term="serialization"/><category term="bigdecimal"/><category term="browser-agent"/><category term="classloader"/><category term="datebox"/><category term="events"/><category term="integer"/><category term="javamail"/><category term="javascript"/><category term="operators"/><category term="profanity filter"/><category term="proxy"/><category term="reflection"/><category term="strings"/><category term="suggestbox"/><title type='text'>Zone 817</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://zone817.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4625702208935784578/posts/default?redirect=false'/><link rel='alternate' type='text/html' href='http://zone817.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>19</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-4625702208935784578.post-7525224253240212804</id><published>2010-08-29T20:27:00.000-07:00</published><updated>2010-08-29T20:27:10.855-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="gwt . dialogbox"/><title type='text'>Close Button in the caption bar of a GWT DialogBox</title><content type='html'>The following code demonstrates how a &#39;close button&#39; can be placed in the caption bar of a DialogBox . Note that the example uses a HTML object as the close button , it can be replaced by an &lt;a href=&quot;http://google-web-toolkit.googlecode.com/svn/javadoc/1.5/com/google/gwt/user/client/ui/Image.html&quot;&gt;Image&lt;/a&gt; to make it more eye-candy.&lt;br /&gt;
&lt;br /&gt;
&lt;div id=&quot;iframeDive2690351-8132-44d1-8aea-53dd4921714e&quot; style=&quot;display: none; margin: 0px;&quot;&gt;&lt;iframe frameborder=&quot;0&quot; id=&quot;iframee2690351-8132-44d1-8aea-53dd4921714e&quot; src=&quot;http://www.blogtrog.com/code.aspx?id=e2690351-8132-44d1-8aea-53dd4921714e&quot; style=&quot;border: 1px solid #e0e0e0; height: 400px; margin: 0px; width: 550px;&quot;&gt;&lt;/iframe&gt;&lt;/div&gt;&lt;div id=&quot;noIframeDive2690351-8132-44d1-8aea-53dd4921714e&quot; style=&quot;display: block; margin: 0px;&quot;&gt;&lt;pre&gt;&lt;div&gt;&lt;span style=&quot;color: green;&quot;&gt;/**&lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;
 *PUBLIC SOFTWARE
 *
 *This source code has been placed in the public domain. You can use, modify, and distribute
 *the source code and executable programs based on the source code.
 *
 *However, note the following:
 *
 *DISCLAIMER OF WARRANTY
 *
 * This source code is provided &quot;as is&quot; and without warranties as to performance
 * or merchantability. The author and/or distributors of this source code may
 * have made statements about this source code. Any such statements do not constitute
 * warranties and shall not be relied on by the user in deciding whether to use
 * this source code.This source code is provided without any express or implied
 * warranties whatsoever. Because of the diversity of conditions and hardware
 * under which this source code may be used, no warranty of fitness for a
 * particular purpose is offered. The user is advised to test the source code
 * thoroughly before relying on it. The user must assume the entire risk of
 * using the source code.
 * 
 &lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;*/&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;

&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;import&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; com.google.gwt.user.client.Element;
&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;import&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; com.google.gwt.dom.client.NativeEvent;
&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;import&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; com.google.gwt.user.client.DOM;
&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;import&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; com.google.gwt.user.client.Event;
&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;import&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; com.google.gwt.user.client.Event.NativePreviewEvent;
&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;import&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; com.google.gwt.user.client.ui.DialogBox;
&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;import&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; com.google.gwt.user.client.ui.HTML;
&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;import&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; com.google.gwt.user.client.ui.HorizontalPanel;

&lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;/**&lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;
 * &lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;@author&lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt; amal
 * &lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;@version&lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt; 1.0
 &lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;*/&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;
&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;public&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;class&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; MyDialog &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;extends&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; DialogBox
  {

    HTML close &lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;new&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; HTML(&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;[X]&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;);
    HTML title &lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;new&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; HTML(&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&quot;&quot;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;);
    HorizontalPanel captionPanel &lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;new&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; HorizontalPanel();

    &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;public&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; MyDialog(&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;boolean&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; autoHide, &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;boolean&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; modal)
      {
        &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;super&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(autoHide, modal);
        Element td &lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; getCellElement(&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;);
        DOM.removeChild(td, (Element) td.getFirstChildElement());
        DOM.appendChild(td, captionPanel.getElement());
        captionPanel.setStyleName(&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;Caption&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;);&lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;//&lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;width-100%&lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;
&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;        captionPanel.add(title);
        close.addStyleName(&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;CloseButton&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;);&lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;//&lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;float:right&lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;
&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;        captionPanel.add(close);
        &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;super&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;.setGlassEnabled(&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;true&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;);
        &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;super&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;.setAnimationEnabled(&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;true&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;);
      }
    &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;public&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; MyDialog(&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;boolean&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; autoHide)
      {
        &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;this&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(autoHide, &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;true&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;);
      }
    &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;public&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; MyDialog()
      {
        &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;this&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;false&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;);
      }

     @Override
    &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;public&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; String getHTML()
      {
        &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;return&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;this&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;.title.getHTML();
      }

    @Override
    &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;public&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; String getText()
      {
        &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;return&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;this&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;.title.getText();
      }

    @Override
    &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;public&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;void&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; setHTML(String html)
      {
        &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;this&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;.title.setHTML(html);
      }

    @Override
    &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;public&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;void&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; setText(String text)
      {
        &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;this&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;.title.setText(text);
      }

    @Override
    &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;protected&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;void&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; onPreviewNativeEvent(NativePreviewEvent event)
      {
        NativeEvent nativeEvent &lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; event.getNativeEvent();

        &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;if&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;!&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;event.isCanceled()
          &lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; (event.getTypeInt() &lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;==&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; Event.ONCLICK)
          &lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; isCloseEvent(nativeEvent))
          {
            &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;this&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;.hide();
          }
        &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;super&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;.onPreviewNativeEvent(event);
      }

    &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;private&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;boolean&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; isCloseEvent(NativeEvent event)
      {
        &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;return&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; event.getEventTarget().equals(close.getElement());&lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;//&lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;compares equality of the underlying DOM elements&lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;
&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;      }
  }&lt;/span&gt;&lt;/div&gt;&lt;/pre&gt;&lt;/div&gt;&lt;script language=&quot;javascript&quot; src=&quot;http://www.blogtrog.com/scripts/bt_code.js&quot; type=&quot;text/javascript&quot;&gt;
&lt;/script&gt;&lt;script language=&quot;javascript&quot; type=&quot;text/javascript&quot;&gt;
bt_code_init(&#39;e2690351-8132-44d1-8aea-53dd4921714e&#39;);
&lt;/script&gt;</content><link rel='replies' type='application/atom+xml' href='http://zone817.blogspot.com/feeds/7525224253240212804/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://zone817.blogspot.com/2010/08/close-button-in-caption-bar-of-gwt.html#comment-form' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4625702208935784578/posts/default/7525224253240212804'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4625702208935784578/posts/default/7525224253240212804'/><link rel='alternate' type='text/html' href='http://zone817.blogspot.com/2010/08/close-button-in-caption-bar-of-gwt.html' title='Close Button in the caption bar of a GWT DialogBox'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4625702208935784578.post-3031078573026342220</id><published>2010-08-29T20:00:00.000-07:00</published><updated>2010-08-29T20:00:13.184-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="gwt . dialogbox"/><title type='text'>Closing a GWT DialogBox on &#39;Esc&#39; keypress</title><content type='html'>To have a DialogBox do something on a keyboard event , its &lt;a href=&quot;http://google-web-toolkit.googlecode.com/svn/javadoc/2.1/com/google/gwt/user/client/ui/DialogBox.html#onPreviewNativeEvent(com.google.gwt.user.client.Event.NativePreviewEvent)&quot;&gt;onPreviewNativeEvent&lt;/a&gt;&amp;nbsp;should be overridden . A DialogBox can be made to hide itself on the &#39;Esc&#39; key event by overriding it&#39;s OnPreviewNativeEvent method as follows&lt;br /&gt;
&lt;br /&gt;
&lt;div id=&quot;iframeDivb79d300d-c5f4-480e-ac5d-f18869964a20&quot; style=&quot;display: none; margin: 0px;&quot;&gt;&lt;iframe frameborder=&quot;0&quot; id=&quot;iframeb79d300d-c5f4-480e-ac5d-f18869964a20&quot; src=&quot;http://www.blogtrog.com/code.aspx?id=b79d300d-c5f4-480e-ac5d-f18869964a20&quot; style=&quot;border: 1px solid #e0e0e0; height: 220px; margin: 0px; width: 550px;&quot;&gt;&lt;/iframe&gt;&lt;/div&gt;&lt;div id=&quot;noIframeDivb79d300d-c5f4-480e-ac5d-f18869964a20&quot; style=&quot;display: block; margin: 0px;&quot;&gt;&lt;pre&gt;&lt;div&gt;&lt;span style=&quot;color: black;&quot;&gt;@Override
      &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;protected&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;void&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; onPreviewNativeEvent(NativePreviewEvent event)
      {
         &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;if&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;!&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;event.isCanceled() &lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; 
             event.getTypeInt() &lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;==&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; Event.ONKEYDOWN &lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; 
             event.getNativeEvent().getKeyCode() &lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;==&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; KeyCodes.KEY_ESCAPE)
        {
             &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;this&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;.hide();
        }
       &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;super&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;.onPreviewNativeEvent(event);
     }&lt;/span&gt;&lt;/div&gt;&lt;/pre&gt;&lt;/div&gt;&lt;script language=&quot;javascript&quot; src=&quot;http://www.blogtrog.com/scripts/bt_code.js&quot; type=&quot;text/javascript&quot;&gt;
&lt;/script&gt;&lt;script language=&quot;javascript&quot; type=&quot;text/javascript&quot;&gt;
bt_code_init(&#39;b79d300d-c5f4-480e-ac5d-f18869964a20&#39;);
&lt;/script&gt;</content><link rel='replies' type='application/atom+xml' href='http://zone817.blogspot.com/feeds/3031078573026342220/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://zone817.blogspot.com/2010/08/closing-gwt-dialogbox-on-esc-keypress.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4625702208935784578/posts/default/3031078573026342220'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4625702208935784578/posts/default/3031078573026342220'/><link rel='alternate' type='text/html' href='http://zone817.blogspot.com/2010/08/closing-gwt-dialogbox-on-esc-keypress.html' title='Closing a GWT DialogBox on &#39;Esc&#39; keypress'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4625702208935784578.post-9054394510280092709</id><published>2010-08-29T19:48:00.000-07:00</published><updated>2010-08-29T20:33:16.293-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="java"/><category scheme="http://www.blogger.com/atom/ns#" term="serialization"/><title type='text'>Serializing and De-serializing a Java object to XML</title><content type='html'>A Java object can be serialized as XML using the &lt;a href=&quot;http://download-llnw.oracle.com/javase/6/docs/api/java/beans/XMLEncoder.html&quot;&gt;XMLEncoder&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div id=&quot;iframeDiv35030104-3b08-48fd-8e0b-55d2bec279a8&quot; style=&quot;display: none; margin: 0px;&quot;&gt;&lt;iframe frameborder=&quot;0&quot; id=&quot;iframe35030104-3b08-48fd-8e0b-55d2bec279a8&quot; src=&quot;http://www.blogtrog.com/code.aspx?id=35030104-3b08-48fd-8e0b-55d2bec279a8&quot; style=&quot;border: 1px solid #e0e0e0; height: 220px; margin: 0px; width: 550px;&quot;&gt;&lt;/iframe&gt;&lt;/div&gt;&lt;div id=&quot;noIframeDiv35030104-3b08-48fd-8e0b-55d2bec279a8&quot; style=&quot;display: block; margin: 0px;&quot;&gt;&lt;pre&gt;&lt;div&gt;&lt;span style=&quot;color: blue;&quot;&gt;try&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; 
{
    XMLEncoder enc&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;new&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; XMLEncoder(&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;new&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; BufferedOutputStream(
        &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;new&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; FileOutputStream(&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&amp;lt;output xml file&amp;gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)));
    enc.writeObject(instance);&lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;//&lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;instance is the bean object to be serialized&lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;
&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;    enc.close();
} 
&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;catch&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; (FileNotFoundException e) 
{
}&lt;/span&gt;
&lt;span style=&quot;color: black;&quot;&gt;
&lt;/span&gt;


&lt;/div&gt;&lt;/pre&gt;&lt;/div&gt;&lt;script language=&quot;javascript&quot; src=&quot;http://www.blogtrog.com/scripts/bt_code.js&quot; type=&quot;text/javascript&quot;&gt;
&lt;/script&gt;&lt;script language=&quot;javascript&quot; type=&quot;text/javascript&quot;&gt;
bt_code_init(&#39;35030104-3b08-48fd-8e0b-55d2bec279a8&#39;);
&lt;/script&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div apple-style-span&quot;=&quot;&quot; style=&quot;clear: both&amp;gt;&amp;lt;/div&amp;gt;&amp;lt;br&amp;gt;&amp;lt;/br&amp;gt;&amp;lt;br /&amp;gt; &amp;lt;span class=;&quot;&gt;De-serializing the XML file can be done as follows using the &lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: monospace; white-space: pre;&quot;&gt;&lt;a href=&quot;http://download-llnw.oracle.com/javase/6/docs/api/java/beans/XMLDecoder.html&quot;&gt;XMLDecoder&lt;/a&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div iframedivb911db0c-3dc5-4080-a0be-d765934e49fc&quot;=&quot;&quot; style=&quot;clear: both&amp;gt;&amp;lt;/div&amp;gt;&amp;lt;br /&amp;gt; &amp;lt;br /&amp;gt; &amp;lt;div id=;&quot;&gt;&lt;iframe frameborder=&quot;0&quot; id=&quot;iframeb911db0c-3dc5-4080-a0be-d765934e49fc&quot; src=&quot;http://www.blogtrog.com/code.aspx?id=b911db0c-3dc5-4080-a0be-d765934e49fc&quot; style=&quot;border: 1px solid #e0e0e0; height: 200px; margin: 0px; width: 550px;&quot;&gt;&lt;/iframe&gt;&lt;/div&gt;&lt;div id=&quot;noIframeDivb911db0c-3dc5-4080-a0be-d765934e49fc&quot; style=&quot;display: block; margin: 0px;&quot;&gt;&lt;pre&gt;&lt;div&gt;&lt;span style=&quot;color: blue;&quot;&gt;try&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;
 {
    XMLDecoder dec&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;new&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; XMLDecoder(&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;new&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; BufferedInputStream(
        &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;new&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; FileInputStream(&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&amp;lt;input xml file&amp;gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)));
    MyClass o &lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; (MyClass)dec.readObject();
    dec.close();
 } 
&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;catch&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; (FileNotFoundException e)
 {
 }&lt;/span&gt;
&lt;span style=&quot;color: black;&quot;&gt;
&lt;/span&gt;
&lt;span style=&quot;color: black;&quot;&gt;
&lt;/span&gt;
&lt;/div&gt;&lt;/pre&gt;&lt;/div&gt;&lt;script language=&quot;javascript&quot; src=&quot;http://www.blogtrog.com/scripts/bt_code.js&quot; type=&quot;text/javascript&quot;&gt;
&lt;/script&gt;&lt;script language=&quot;javascript&quot; type=&quot;text/javascript&quot;&gt;
bt_code_init(&#39;b911db0c-3dc5-4080-a0be-d765934e49fc&#39;);
&lt;/script&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://zone817.blogspot.com/feeds/9054394510280092709/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://zone817.blogspot.com/2010/08/serializing-and-de-serializing-java.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4625702208935784578/posts/default/9054394510280092709'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4625702208935784578/posts/default/9054394510280092709'/><link rel='alternate' type='text/html' href='http://zone817.blogspot.com/2010/08/serializing-and-de-serializing-java.html' title='Serializing and De-serializing a Java object to XML'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4625702208935784578.post-385648127597115886</id><published>2010-08-19T06:58:00.000-07:00</published><updated>2010-08-26T22:48:12.463-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="classloader"/><category scheme="http://www.blogger.com/atom/ns#" term="java"/><title type='text'>Loading a class using the URLClassLoader</title><content type='html'>&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #31331f; font-family: Arial, Helvetica, sans-serif; font-size: 14px; line-height: 17px;&quot;&gt;&lt;span class=&quot;exd_c&quot;&gt;The&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;exd_c&quot; style=&quot;font-family: &#39;Lucida Console&#39;, Monaco, monospace;&quot;&gt;URLClassLoader&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #31331f; font-family: Arial, Helvetica, sans-serif; font-size: 14px; line-height: 17px;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #31331f; font-family: Arial, Helvetica, sans-serif; font-size: 14px; line-height: 17px;&quot;&gt;can be used dynamically load classes from a directory , not&amp;nbsp;necessarily&amp;nbsp;on the classpath. The following code demonstrates how&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div id=&quot;iframeDivc988b892-af18-4210-8a69-cbef3016e871&quot; style=&quot;display: none; margin: 0px;&quot;&gt;&lt;iframe frameborder=&quot;0&quot; id=&quot;iframec988b892-af18-4210-8a69-cbef3016e871&quot; src=&quot;http://www.blogtrog.com/code.aspx?id=c988b892-af18-4210-8a69-cbef3016e871&quot; style=&quot;border: 1px solid #e0e0e0; height: 300px; margin: 0px; width: 550px;&quot;&gt;&lt;/iframe&gt;&lt;/div&gt;&lt;div id=&quot;noIframeDivc988b892-af18-4210-8a69-cbef3016e871&quot; style=&quot;display: block; margin: 0px;&quot;&gt;&lt;pre&gt;&lt;div&gt;&lt;span style=&quot;color: black;&quot;&gt;File file &lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;new&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; File(&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&amp;lt;directory path&amp;gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;);
&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;try&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; 
{
    URL url &lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; file.toURL();    
    ClassLoader loader&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;new&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; URLClassLoader(&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;new&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; URL[]{url});
    Class &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;class&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; loader.loadClass(&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&amp;lt;class name&amp;gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;);
} 
&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;catch&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; (MalformedURLException e) 
{
}
 &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;catch&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; (ClassNotFoundException e)
{
 }&lt;/span&gt;&lt;/div&gt;&lt;/pre&gt;&lt;/div&gt;&lt;script language=&quot;javascript&quot; src=&quot;http://www.blogtrog.com/scripts/bt_code.js&quot; type=&quot;text/javascript&quot;&gt;
&lt;/script&gt;&lt;script language=&quot;javascript&quot; type=&quot;text/javascript&quot;&gt;
bt_code_init(&#39;c988b892-af18-4210-8a69-cbef3016e871&#39;);
&lt;/script&gt;</content><link rel='replies' type='application/atom+xml' href='http://zone817.blogspot.com/feeds/385648127597115886/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://zone817.blogspot.com/2010/08/loading-class-using-urlclassloader.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4625702208935784578/posts/default/385648127597115886'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4625702208935784578/posts/default/385648127597115886'/><link rel='alternate' type='text/html' href='http://zone817.blogspot.com/2010/08/loading-class-using-urlclassloader.html' title='Loading a class using the URLClassLoader'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4625702208935784578.post-5641149405244742763</id><published>2010-08-19T06:50:00.000-07:00</published><updated>2010-08-26T22:47:48.438-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="javascript"/><category scheme="http://www.blogger.com/atom/ns#" term="operators"/><title type='text'>Javascript equality(==) and identity(===) operators</title><content type='html'>The identity operator(===) compares the type and value of the&amp;nbsp;operands&amp;nbsp;, while the equality operator(==) compares just the values .&lt;br /&gt;
&lt;br /&gt;
So , given var i=1&lt;br /&gt;
&lt;br /&gt;
i==&#39;1&#39; will return true , while i===&#39;1&#39; will return false .&lt;br /&gt;
&lt;br /&gt;
Quote from &amp;nbsp;&lt;a href=&quot;http://oreilly.com/catalog/9780596517748&quot;&gt;Javascript : The good parts&lt;/a&gt;&lt;br /&gt;
&lt;blockquote&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, &#39;Liberation Sans&#39;, &#39;DejaVu Sans&#39;, sans-serif; font-size: medium;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;border-collapse: collapse; font-size: 14px; line-height: 18px;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, &#39;Liberation Sans&#39;, &#39;DejaVu Sans&#39;, sans-serif; font-size: medium;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;border-collapse: collapse; font-size: 14px; line-height: 18px;&quot;&gt;&lt;blockquote&gt;JavaScript has two sets of equality operators: === and !==, and their evil twins == and !=. The good ones work the way you would expect. If the two operands are of the same type and have the same value, then === produces true and !== produces false. The evil twins do the right thing when the operands are of the same type, but if they are of different types, they attempt to coerce the values. the rules by which they do that are complicated and unmemorable.&amp;nbsp;&lt;/blockquote&gt;&lt;blockquote&gt;My advice is to never use the evil twins. Instead, always use === and !==.&lt;/blockquote&gt;&lt;/span&gt;&lt;/span&gt;&lt;/blockquote&gt;</content><link rel='replies' type='application/atom+xml' href='http://zone817.blogspot.com/feeds/5641149405244742763/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://zone817.blogspot.com/2010/08/javascript-equality-and-identity.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4625702208935784578/posts/default/5641149405244742763'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4625702208935784578/posts/default/5641149405244742763'/><link rel='alternate' type='text/html' href='http://zone817.blogspot.com/2010/08/javascript-equality-and-identity.html' title='Javascript equality(==) and identity(===) operators'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4625702208935784578.post-4208109042810432578</id><published>2010-08-19T06:42:00.000-07:00</published><updated>2010-08-26T22:47:27.957-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="java"/><category scheme="http://www.blogger.com/atom/ns#" term="serialization"/><title type='text'>Using readResolve method to create a Serializable Singleton</title><content type='html'>The &lt;a href=&quot;http://download.oracle.com/javase/1.5.0/docs/guide/serialization/spec/input.html#5903&quot;&gt;readResolve&lt;/a&gt;&amp;nbsp;method&amp;nbsp;allows a class to replace/resolve the object read from the stream before it is returned to the caller. The following code&amp;nbsp;demonstrates&amp;nbsp;how to create a serializable singleton , using the method.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div id=&quot;iframeDiv797f1512-f6bf-40f6-8c65-e1c27bcf1f4d&quot; style=&quot;display: none; margin: 0px;&quot;&gt;&lt;iframe frameborder=&quot;0&quot; id=&quot;iframe797f1512-f6bf-40f6-8c65-e1c27bcf1f4d&quot; src=&quot;http://www.blogtrog.com/code.aspx?id=797f1512-f6bf-40f6-8c65-e1c27bcf1f4d&quot; style=&quot;border: 1px solid #e0e0e0; height: 200px; margin: 0px; width: 550px;&quot;&gt;&lt;/iframe&gt;&lt;/div&gt;&lt;div id=&quot;noIframeDiv797f1512-f6bf-40f6-8c65-e1c27bcf1f4d&quot; style=&quot;display: block; margin: 0px;&quot;&gt;&lt;pre&gt;&lt;div&gt;&lt;span style=&quot;color: blue;&quot;&gt;public&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;class&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; Singleton &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;implements&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; Serializable
{
&amp;nbsp;&lt;span style=&quot;color: blue;&quot;&gt;static&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; Singleton instance&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;new&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; Singleton ();&lt;/span&gt;

&lt;span style=&quot;color: blue;&quot;&gt;private&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; Singleton ()&lt;/span&gt;
&amp;nbsp;{
&amp;nbsp;}

&lt;span style=&quot;color: blue;&quot;&gt;protected&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; Object readResolve()&amp;nbsp;&lt;/span&gt;
&amp;nbsp;{
&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: blue;&quot;&gt;return&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; instance;&lt;/span&gt;
&amp;nbsp;}

}&lt;/span&gt;&lt;/div&gt;&lt;/pre&gt;&lt;/div&gt;&lt;script language=&quot;javascript&quot; src=&quot;http://www.blogtrog.com/scripts/bt_code.js&quot; type=&quot;text/javascript&quot;&gt;
&lt;/script&gt;&lt;script language=&quot;javascript&quot; type=&quot;text/javascript&quot;&gt;
bt_code_init(&#39;797f1512-f6bf-40f6-8c65-e1c27bcf1f4d&#39;);
&lt;/script&gt;</content><link rel='replies' type='application/atom+xml' href='http://zone817.blogspot.com/feeds/4208109042810432578/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://zone817.blogspot.com/2010/08/using-readresolve-method-to-create.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4625702208935784578/posts/default/4208109042810432578'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4625702208935784578/posts/default/4208109042810432578'/><link rel='alternate' type='text/html' href='http://zone817.blogspot.com/2010/08/using-readresolve-method-to-create.html' title='Using readResolve method to create a Serializable Singleton'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4625702208935784578.post-2755693409812590733</id><published>2010-08-19T06:32:00.000-07:00</published><updated>2010-08-26T22:47:06.865-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="integer"/><category scheme="http://www.blogger.com/atom/ns#" term="java"/><title type='text'>Integer constant pool</title><content type='html'>Java uses a caching mechanism for Integer , similar to the &lt;a href=&quot;http://zone817.blogspot.com/2010/08/strings-in-java-immutablility-interning.html&quot;&gt;String Pool&lt;/a&gt;&amp;nbsp;. It caches the Integer values from -128 to 127 , meaning &#39;==&#39; comparisons for values in this range returns true .&lt;br /&gt;
&lt;br /&gt;
&lt;div id=&quot;iframeDiv65c3f637-6e3b-4893-912f-d0f084eb3f22&quot; style=&quot;display: none; margin: 0px;&quot;&gt;&lt;iframe frameborder=&quot;0&quot; id=&quot;iframe65c3f637-6e3b-4893-912f-d0f084eb3f22&quot; src=&quot;http://www.blogtrog.com/code.aspx?id=65c3f637-6e3b-4893-912f-d0f084eb3f22&quot; style=&quot;border: 1px solid #e0e0e0; height: 150px; margin: 0px; width: 550px;&quot;&gt;&lt;/iframe&gt;&lt;/div&gt;&lt;div id=&quot;noIframeDiv65c3f637-6e3b-4893-912f-d0f084eb3f22&quot; style=&quot;display: block; margin: 0px;&quot;&gt;&lt;pre&gt;&lt;div&gt;&lt;span style=&quot;color: black;&quot;&gt;Integer a&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;127&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;
Integer b&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;127&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;
System.out.println(a&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;==&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;b);//prints true
a&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;128&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;
b&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;128&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;
System.out.println(a&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;==&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;b);//prints false&lt;/span&gt;&lt;/div&gt;&lt;/pre&gt;&lt;/div&gt;&lt;script language=&quot;javascript&quot; src=&quot;http://www.blogtrog.com/scripts/bt_code.js&quot; type=&quot;text/javascript&quot;&gt;
&lt;/script&gt;&lt;script language=&quot;javascript&quot; type=&quot;text/javascript&quot;&gt;
bt_code_init(&#39;65c3f637-6e3b-4893-912f-d0f084eb3f22&#39;);
&lt;/script&gt;</content><link rel='replies' type='application/atom+xml' href='http://zone817.blogspot.com/feeds/2755693409812590733/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://zone817.blogspot.com/2010/08/integer-constant-pool.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4625702208935784578/posts/default/2755693409812590733'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4625702208935784578/posts/default/2755693409812590733'/><link rel='alternate' type='text/html' href='http://zone817.blogspot.com/2010/08/integer-constant-pool.html' title='Integer constant pool'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4625702208935784578.post-3718788835971099803</id><published>2010-08-17T06:36:00.000-07:00</published><updated>2010-08-26T22:46:50.090-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="events"/><category scheme="http://www.blogger.com/atom/ns#" term="gwt"/><title type='text'>Creating and Firing events with GWT</title><content type='html'>The following code demonstrates how to  programmatically create an event using GWT.&lt;br /&gt;
&lt;br /&gt;
&lt;div id=&quot;iframeDiv3cf07572-8e43-44f0-b839-313b5f2a6c73&quot; style=&quot;display: none; margin: 0px;&quot;&gt;&lt;iframe frameborder=&quot;0&quot; id=&quot;iframe3cf07572-8e43-44f0-b839-313b5f2a6c73&quot; src=&quot;http://www.blogtrog.com/code.aspx?id=3cf07572-8e43-44f0-b839-313b5f2a6c73&quot; style=&quot;border: 1px solid #e0e0e0; height: 120px; margin: 0px; width: 550px;&quot;&gt;&lt;/iframe&gt;&lt;/div&gt;&lt;div id=&quot;noIframeDiv3cf07572-8e43-44f0-b839-313b5f2a6c73&quot; style=&quot;display: block; margin: 0px;&quot;&gt;&lt;pre&gt;&lt;div&gt;&lt;span style=&quot;color: black;&quot;&gt;Document doc&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;Document.get();
NativeEvent clickEvent&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;doc.createClickEvent(&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;false&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;false&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;false&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;false&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;);
NativeEvent changeEvent&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;doc.createChangeEvent();
NativeEvent keyDownEvent&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;doc.createKeyDownEvent(&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;false&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;false&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;false&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;false&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;,KeyCodes.KEY_ENTER);

.........
&lt;/span&gt;&lt;/div&gt;&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;
The events created can be programmatically fired using the &lt;a href=&quot;http://google-web-toolkit.googlecode.com/svn/javadoc/2.1/com/google/gwt/event/dom/client/DomEvent.html#fireNativeEvent(com.google.gwt.dom.client.NativeEvent, com.google.gwt.event.shared.HasHandlers)&quot;&gt;DomEvent.fireNativeEvent&lt;/a&gt; method .&lt;br /&gt;
&lt;span style=&quot;font-size: xx-small;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;</content><link rel='replies' type='application/atom+xml' href='http://zone817.blogspot.com/feeds/3718788835971099803/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://zone817.blogspot.com/2010/08/creating-and-firing-events-with-gwt.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4625702208935784578/posts/default/3718788835971099803'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4625702208935784578/posts/default/3718788835971099803'/><link rel='alternate' type='text/html' href='http://zone817.blogspot.com/2010/08/creating-and-firing-events-with-gwt.html' title='Creating and Firing events with GWT'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4625702208935784578.post-2601963480866891347</id><published>2010-08-11T02:41:00.000-07:00</published><updated>2010-08-26T22:46:31.518-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="java"/><category scheme="http://www.blogger.com/atom/ns#" term="reflection"/><title type='text'>Invoking a method by name using Reflection</title><content type='html'>It is possible to use reflection to invoke a method using its name , which is known only at runtime . The following code demonstrates the usage of the &lt;a href=&quot;http://download-llnw.oracle.com/javase/6/docs/api/java/lang/reflect/Method.html#invoke(java.lang.Object, java.lang.Object...)&quot;&gt;invoke&lt;/a&gt; method . Note that reflection may be used to override the java access checks , allowing the caller to invoke methods that are declared private .&lt;br /&gt;
&lt;div&gt;&lt;br /&gt;
&lt;div id=&quot;iframeDive87c97fb-d87b-4b13-81bc-a49dc2385049&quot; style=&quot;display: none; margin: 0px;&quot;&gt;&lt;iframe frameborder=&quot;0&quot; id=&quot;iframee87c97fb-d87b-4b13-81bc-a49dc2385049&quot; src=&quot;http://www.blogtrog.com/code.aspx?id=e87c97fb-d87b-4b13-81bc-a49dc2385049&quot; style=&quot;border: 1px solid #e0e0e0; height: 400px; margin: 0px; width: 550px;&quot;&gt;&lt;/iframe&gt;&lt;/div&gt;&lt;div id=&quot;noIframeDive87c97fb-d87b-4b13-81bc-a49dc2385049&quot; style=&quot;display: block; margin: 0px;&quot;&gt;&lt;pre&gt;&lt;div&gt;&lt;span style=&quot;color: green;&quot;&gt;/**&lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;
*PUBLIC SOFTWARE
*
*This source code has been placed in the public domain. You can use, modify, and distribute
*the source code and executable programs based on the source code.
*
*However, note the following:
*
*DISCLAIMER OF WARRANTY
*
* This source code is provided &quot;as is&quot; and without warranties as to performance
* or merchantability. The author and/or distributors of this source code may
* have made statements about this source code. Any such statements do not constitute
* warranties and shall not be relied on by the user in deciding whether to use
* this source code.This source code is provided without any express or implied
* warranties whatsoever. Because of the diversity of conditions and hardware
* under which this source code may be used, no warranty of fitness for a
* particular purpose is offered. The user is advised to test the source code
* thoroughly before relying on it. The user must assume the entire risk of
* using the source code.
*
&lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;*/&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;

&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;import&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; java.lang.reflect.&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;*&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;

&lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;/**&lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;
*
* &lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;@author&lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt; amal
* version 1.0
&lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;*/&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;
&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;public&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;class&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; InvokeTest
{


&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;public&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;static&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;void&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; main(String[] args) &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;throws&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; Exception
{
Class c &lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; Class.forName(&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;X&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;);
Object instance &lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; c.newInstance();
Method m &lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; c.getDeclaredMethod(&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;A&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;new&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; Class[]{});
m.invoke(instance, &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;new&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; Object[]{});
m &lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; c.getDeclaredMethod(&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;A&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;new&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; Class[]{&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;int&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;class&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;});&lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;//&lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;or INTEGER.TYPE&lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;
&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;         m.invoke(instance, &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;new&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; Object[]{&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;});
m &lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; c.getDeclaredMethod(&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;A&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;new&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; Class[]{String.&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;class&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;});
m.invoke(instance, &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;new&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; Object[]{&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;arg&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;});
m &lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; c.getDeclaredMethod(&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;A&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;new&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; Class[]{String.&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;class&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;,String.&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;class&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;});
m.setAccessible(&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;true&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;);&lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;//&lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;supress the java access check&lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;
&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;         m.invoke(instance, &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;new&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; Object[]{&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;arg1&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;arg2&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;});

}


}
&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;class&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; X
{
&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;void&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; A()
{
System.out.println(&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;In method A , with no arguments&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;);
}
&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;void&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; A(&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;int&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; i)
{
System.out.println(&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;In method A , with an integer argument &lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;i);
}
&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;void&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; A(String s)
{
System.out.println(&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;In method A , with a string argument &lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;s);
}
&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;private&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;void&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; A(String s,String t)
{
System.out.println(&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;In the private method A , with two string arguments &lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;s&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; , &lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;t);
}
}
&lt;/span&gt;&lt;/div&gt;&lt;/pre&gt;&lt;/div&gt;&lt;script language=&quot;javascript&quot; src=&quot;http://www.blogtrog.com/scripts/bt_code.js&quot; type=&quot;text/javascript&quot;&gt;
&lt;/script&gt;&lt;script language=&quot;javascript&quot; type=&quot;text/javascript&quot;&gt;
bt_code_init(&#39;e87c97fb-d87b-4b13-81bc-a49dc2385049&#39;);
&lt;/script&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://zone817.blogspot.com/feeds/2601963480866891347/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://zone817.blogspot.com/2010/08/invoking-method-by-name-using.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4625702208935784578/posts/default/2601963480866891347'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4625702208935784578/posts/default/2601963480866891347'/><link rel='alternate' type='text/html' href='http://zone817.blogspot.com/2010/08/invoking-method-by-name-using.html' title='&lt;span style=&quot;color:#ff0000;&quot;&gt;Invoking a method by name using Reflection&lt;/span&gt;'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4625702208935784578.post-7629575831503807563</id><published>2010-08-07T03:28:00.000-07:00</published><updated>2010-08-26T22:46:09.948-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="java"/><category scheme="http://www.blogger.com/atom/ns#" term="profanity filter"/><title type='text'>Simple Profanity Filter</title><content type='html'>&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: small;&quot;&gt;A simple Java program demonstrating the use of &lt;/span&gt;&lt;a href=&quot;http://wiki.cdyne.com/wiki/index.php?title=Profanity_Filter&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: small;&quot;&gt;CDYNE&#39;s FREE Profanity Filter API&lt;/span&gt;&lt;/a&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: small;&quot;&gt; . Note that the code just demonstrates the setting up of a simple profanity filter , the API includes much more functionalities . Check out the &lt;/span&gt;&lt;a href=&quot;http://wiki.cdyne.com/wiki/index.php?title=Profanity_Filter&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: small;&quot;&gt;CDYNE Wiki&lt;/span&gt;&lt;/a&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: small;&quot;&gt; for how to implement a profanity filter suited to your needs .&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;div id=&quot;iframeDiv6386bd86-6d78-46d0-b17b-0e332d6df4f6&quot; style=&quot;display: none; margin: 0px;&quot;&gt;&lt;iframe frameborder=&quot;0&quot; id=&quot;iframe6386bd86-6d78-46d0-b17b-0e332d6df4f6&quot; src=&quot;http://www.blogtrog.com/code.aspx?id=6386bd86-6d78-46d0-b17b-0e332d6df4f6&quot; style=&quot;border: 1px solid #e0e0e0; height: 400px; margin: 0px; width: 550px;&quot;&gt;&lt;/iframe&gt;&lt;/div&gt;&lt;div id=&quot;noIframeDiv6386bd86-6d78-46d0-b17b-0e332d6df4f6&quot; style=&quot;display: block; margin: 0px;&quot;&gt;&lt;pre&gt;&lt;div&gt;&lt;span style=&quot;color: green;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;/**&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;
*PUBLIC SOFTWARE
*
*This source code has been placed in the public domain. You can use, modify, and distribute
*the source code and executable programs based on the source code.
*
*However, note the following:
*
*DISCLAIMER OF WARRANTY
*
* This source code is provided &quot;as is&quot; and without warranties as to performance
* or merchantability. The author and/or distributors of this source code may
* have made statements about this source code. Any such statements do not constitute
* warranties and shall not be relied on by the user in deciding whether to use
* this source code.This source code is provided without any express or implied
* warranties whatsoever. Because of the diversity of conditions and hardware
* under which this source code may be used, no warranty of fitness for a
* particular purpose is offered. The user is advised to test the source code
* thoroughly before relying on it. The user must assume the entire risk of
* using the source code.
*
&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;*/&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;import&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; java.io.&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;*&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;import&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; java.net.&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;*&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;/**&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;
*
* &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;@author&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; amal
* version 1.0
&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;*/&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;public&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;class&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; CDYNEFilterDemo {

&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;public&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;static&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;void&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; main(String[] args)
{
BufferedReader in &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;=&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;null&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;try&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;
{
String text &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;=&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;test profanity bullshit&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;;
URL url &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;=&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;new&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; URL(&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;http://ws.cdyne.com/ProfanityWS/Profanity.asmx/SimpleProfanityFilter?Text=&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;+&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;URLEncoder.encode(text,&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;UTF-8&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;));
in &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;=&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;new&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; BufferedReader(&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;new&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; InputStreamReader(url.openStream()));
String inputLine;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;while&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; ((inputLine &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;=&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; in.readLine()) &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;!=&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;null&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;)
{
System.out.println(inputLine);
}
}
&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;catch&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; (MalformedURLException e)
{
e.printStackTrace();
}
&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;catch&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; (IOException e)
{
e.printStackTrace();
}
&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;finally&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;
{
&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;try&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;
{
&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;if&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; (&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;null&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;!=&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; in)
{
in.close();
}
}
&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;catch&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; (IOException e)
{
&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;//&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; ignore&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;              }
}
}
}&lt;/span&gt;
&lt;/span&gt;&lt;/div&gt;&lt;/pre&gt;&lt;/div&gt;&lt;script language=&quot;javascript&quot; src=&quot;http://www.blogtrog.com/scripts/bt_code.js&quot; type=&quot;text/javascript&quot;&gt;
&lt;/script&gt;&lt;script language=&quot;javascript&quot; type=&quot;text/javascript&quot;&gt;
bt_code_init(&#39;6386bd86-6d78-46d0-b17b-0e332d6df4f6&#39;);
&lt;/script&gt;</content><link rel='replies' type='application/atom+xml' href='http://zone817.blogspot.com/feeds/7629575831503807563/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://zone817.blogspot.com/2010/08/simple-profanity-filter.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4625702208935784578/posts/default/7629575831503807563'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4625702208935784578/posts/default/7629575831503807563'/><link rel='alternate' type='text/html' href='http://zone817.blogspot.com/2010/08/simple-profanity-filter.html' title='Simple Profanity Filter'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4625702208935784578.post-666380473989463720</id><published>2010-08-03T09:40:00.000-07:00</published><updated>2010-08-26T22:45:48.526-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="java"/><category scheme="http://www.blogger.com/atom/ns#" term="strings"/><title type='text'>Strings in Java - Immutablility , Interning and the String pool</title><content type='html'>&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: small;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: small;&quot;&gt;Immutability&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: small;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: small;&quot;&gt;Strings in Java are immutable .An immutable object is one whose state cannot be modified once it is created . In Java , Strings are immutable . An interesting side-effect of the immutability of Strings is that methods like toLowerCase() in the String class doesn&#39;t affect the state of the original String , rather returns a new String.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: small;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: small;&quot;&gt;Interning &amp;amp; The String pool&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: small;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: small;&quot;&gt;String interning is a method of storing only one copy of each distinct string value, which must be immutable. Interning strings makes some string processing tasks more time- or space-efficient at the cost of requiring more time when the string is created or interned. In Java , strings are interned using a String literal pool .&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: small;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: small;&quot;&gt;Each time your code create a string literal, the JVM checks the string literal pool first. If the string already exists in the pool, a reference to the pooled instance returns. If the string does not exist in the pool, a new String object is created and placed in the pool. Java can make this optimization since strings are immutable and can be shared without fear of data corruption.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: small;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: small;&quot;&gt;A side-effect of String interning in Java can be demonstrated by this code snippet.&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;
&lt;div id=&quot;iframeDive119901d-869b-4871-b18e-c2f91001e57a&quot; style=&quot;display: none; margin: 0px;&quot;&gt;&lt;iframe frameborder=&quot;0&quot; id=&quot;iframee119901d-869b-4871-b18e-c2f91001e57a&quot; src=&quot;http://www.blogtrog.com/code.aspx?id=e119901d-869b-4871-b18e-c2f91001e57a&quot; style=&quot;border: 1px solid #e0e0e0; height: 100px; margin: 0px; width: 550px;&quot;&gt;&lt;/iframe&gt;&lt;/div&gt;&lt;div id=&quot;noIframeDive119901d-869b-4871-b18e-c2f91001e57a&quot; style=&quot;display: block; margin: 0px;&quot;&gt;&lt;pre&gt;&lt;div&gt;&lt;span style=&quot;color: black;&quot;&gt;String s1&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;aaaaa&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;
String s2&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;aaaaa&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;
System.out.println(s1&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;==&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;s2);&lt;/span&gt;&lt;/div&gt;&lt;/pre&gt;&lt;/div&gt;&lt;script language=&quot;javascript&quot; src=&quot;http://www.blogtrog.com/scripts/bt_code.js&quot; type=&quot;text/javascript&quot;&gt;
&lt;/script&gt;&lt;script language=&quot;javascript&quot; type=&quot;text/javascript&quot;&gt;
bt_code_init(&#39;e119901d-869b-4871-b18e-c2f91001e57a&#39;);
&lt;/script&gt;&lt;br /&gt;
&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: small;&quot;&gt;The above code snippet prints true because the two Strings are interned , and refers to the same pool instance.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: small;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: small;&quot;&gt;Literal Strings , including those that can be computed by constant expressions at compile time are interned . &lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: small;&quot;&gt;Strings explicitly created by the constructor or by concatenation at runtime are not interned.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: small;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: small;&quot;&gt;The intern() method&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: small;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: small;&quot;&gt;The docs state When the intern method is invoked, if the pool already contains a&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: small;&quot;&gt;string equal to the String\ object as determined by&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: small;&quot;&gt;the method, then the string from the pool is&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: small;&quot;&gt;returned. Otherwise, the String object is added to the&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: small;&quot;&gt;pool and a reference to the String object is returned.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: small;&quot;&gt;The below code snippet demonstrates the behaviour of the intern() method.&lt;/span&gt;&lt;/div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;div id=&quot;iframeDivfe401092-0aa7-4d8c-9f3d-d709a8903f6d&quot; style=&quot;display: none; margin: 0px;&quot;&gt;&lt;iframe frameborder=&quot;0&quot; id=&quot;iframefe401092-0aa7-4d8c-9f3d-d709a8903f6d&quot; src=&quot;http://www.blogtrog.com/code.aspx?id=fe401092-0aa7-4d8c-9f3d-d709a8903f6d&quot; style=&quot;border: 1px solid #e0e0e0; height: 120px; margin: 0px; width: 550px;&quot;&gt;&lt;/iframe&gt;&lt;/div&gt;&lt;div id=&quot;noIframeDivfe401092-0aa7-4d8c-9f3d-d709a8903f6d&quot; style=&quot;display: block; margin: 0px;&quot;&gt;&lt;pre&gt;&lt;div&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;String s1 &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;=&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;Zone817&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;;
String s2 &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;=&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;new&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; StringBuffer(&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;Zone&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;).append(&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;817&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;).toString();
String s3 &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;=&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; s2.intern();
System.out.println(s1 &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;==&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; s2);&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;//&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;prints false&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;System.out.println(s1 &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;==&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; s3);&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;//&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;prints true&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/pre&gt;&lt;/div&gt;&lt;script language=&quot;javascript&quot; src=&quot;http://www.blogtrog.com/scripts/bt_code.js&quot; type=&quot;text/javascript&quot;&gt;
&lt;/script&gt;&lt;script language=&quot;javascript&quot; type=&quot;text/javascript&quot;&gt;
bt_code_init(&#39;fe401092-0aa7-4d8c-9f3d-d709a8903f6d&#39;);
&lt;/script&gt;</content><link rel='replies' type='application/atom+xml' href='http://zone817.blogspot.com/feeds/666380473989463720/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://zone817.blogspot.com/2010/08/strings-in-java-immutablility-interning.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4625702208935784578/posts/default/666380473989463720'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4625702208935784578/posts/default/666380473989463720'/><link rel='alternate' type='text/html' href='http://zone817.blogspot.com/2010/08/strings-in-java-immutablility-interning.html' title='Strings in Java - Immutablility , Interning and the String pool'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4625702208935784578.post-5370403034017285187</id><published>2010-08-02T08:47:00.000-07:00</published><updated>2010-08-26T22:45:25.441-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="browser-agent"/><category scheme="http://www.blogger.com/atom/ns#" term="java"/><category scheme="http://www.blogger.com/atom/ns#" term="url"/><title type='text'>Mimicking a browser user-agent in a request</title><content type='html'>&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: small;&quot;&gt;The following code demonstrates how to &#39;forge&#39; the user-agent string in a request , making the request seem like it originated from a browser.&lt;br /&gt;
&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;div id=&quot;iframeDivfe546475-72a2-48bc-81c5-41fbfc98238d&quot; style=&quot;display: none; margin: 0px;&quot;&gt;&lt;iframe frameborder=&quot;0&quot; id=&quot;iframefe546475-72a2-48bc-81c5-41fbfc98238d&quot; src=&quot;http://www.blogtrog.com/code.aspx?id=fe546475-72a2-48bc-81c5-41fbfc98238d&quot; style=&quot;border: 1px solid #e0e0e0; height: 400px; margin: 0px; width: 550px;&quot;&gt;&lt;/iframe&gt;&lt;/div&gt;&lt;div id=&quot;noIframeDivfe546475-72a2-48bc-81c5-41fbfc98238d&quot; style=&quot;display: block; margin: 0px;&quot;&gt;&lt;pre&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: green;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: green;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: green;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;/**&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;
*PUBLIC SOFTWARE
*
*This source code has been placed in the public domain. You can use, modify, and distribute
*the source code and executable programs based on the source code.
*
*However, note the following:
*
*DISCLAIMER OF WARRANTY
*
* This source code is provided &quot;as is&quot; and without warranties as to performance
* or merchantability. The author and/or distributors of this source code may
* have made statements about this source code. Any such statements do not constitute
* warranties and shall not be relied on by the user in deciding whether to use
* this source code.This source code is provided without any express or implied
* warranties whatsoever. Because of the diversity of conditions and hardware
* under which this source code may be used, no warranty of fitness for a
* particular purpose is offered. The user is advised to test the source code
* thoroughly before relying on it. The user must assume the entire risk of
* using the source code.
*
&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;*/&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;import&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; java.io.&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;*&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;import&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; java.net.&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;*&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;/**&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;
*
* &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;@author&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; amal
* version 1.0
&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;*/&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;



&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;public&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;class&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; UrlConB
{

&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;public&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;static&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;void&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; main(String[] args)
{
InputStreamReader in &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;=&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;null&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;try&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;
{
String query &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;=&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;web&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;;
Socket s &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;=&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;new&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; Socket(&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;bing.com&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;, &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;80&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;);
PrintStream p &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;=&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;new&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; PrintStream(s.getOutputStream());
p.print(&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;GET /search?q=&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;+&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; query &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;+&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; HTTP/1.0\r\n&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;);
p.print(&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US) AppleWebKit/533.2 (KHTML, like Gecko) Chrome/6.0\r\n&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;);
p.print(&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;Connection: close\r\n\r\n&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;);
in &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;=&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;new&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; InputStreamReader(s.getInputStream());
BufferedReader buffer &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;=&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;new&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; BufferedReader(in);
String line;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;while&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; ((line &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;=&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; buffer.readLine()) &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;!=&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;null&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;)
{
System.out.println(line);
}
in.close();
}
&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;catch&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; (UnknownHostException e)
{
e.printStackTrace();
}
&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;catch&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; (IOException e)
{
e.printStackTrace();
}
&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;finally&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;
{
&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;try&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;
{
&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;if&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; (&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;null&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;!=&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; in)
in.close();
}
&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;catch&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; (IOException e)
{
&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;//&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; ignore&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;              }
}
}
}&lt;/span&gt;
&lt;/span&gt;&lt;/div&gt;&lt;/pre&gt;&lt;/div&gt;&lt;script language=&quot;javascript&quot; src=&quot;http://www.blogtrog.com/scripts/bt_code.js&quot; type=&quot;text/javascript&quot;&gt;
&lt;/script&gt;&lt;script language=&quot;javascript&quot; type=&quot;text/javascript&quot;&gt;
bt_code_init(&#39;fe546475-72a2-48bc-81c5-41fbfc98238d&#39;);
&lt;/script&gt;</content><link rel='replies' type='application/atom+xml' href='http://zone817.blogspot.com/feeds/5370403034017285187/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://zone817.blogspot.com/2010/08/mimicking-browser-user-agent-in-request.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4625702208935784578/posts/default/5370403034017285187'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4625702208935784578/posts/default/5370403034017285187'/><link rel='alternate' type='text/html' href='http://zone817.blogspot.com/2010/08/mimicking-browser-user-agent-in-request.html' title='Mimicking a browser user-agent in a request'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4625702208935784578.post-7325866588845273764</id><published>2010-08-02T08:27:00.000-07:00</published><updated>2010-08-26T22:45:03.897-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="java"/><category scheme="http://www.blogger.com/atom/ns#" term="proxy"/><category scheme="http://www.blogger.com/atom/ns#" term="url"/><title type='text'>Connecting to an Url using a Java program - Connecting through a proxy</title><content type='html'>&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: small;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: arial;&quot;&gt;The following code demonstartes how to connect to an url through a proxy . The code uses the default system proxy.&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: small;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: arial;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: small;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: arial;&quot;&gt;In case you want to use a different proxy than the default system proxy , you need to set &lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;line-height: 16px; white-space: pre;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: small;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: arial;&quot;&gt;the &lt;i&gt;http.proxyHost&lt;/i&gt; and &lt;i&gt;http.proxyPort&lt;/i&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;line-height: 16px; white-space: pre;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: small;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: arial;&quot;&gt;properties from your code using setProperty method of the System class , &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;line-height: 16px; white-space: pre;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: small;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: arial;&quot;&gt;or you can provide the values as command line arguments when starting your java program , like &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;line-height: 16px; white-space: pre;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: small;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: arial;&quot;&gt;&lt;i&gt;java -Dhttp.proxyHost=hostname -Dhttp.proxyPort=portNumber foo &lt;/i&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;line-height: 16px; white-space: pre;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: small;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: arial;&quot;&gt;, where foo is the name of the class . You may also create an instance of the &lt;/span&gt;&lt;/span&gt;&lt;a href=&quot;http://download-llnw.oracle.com/javase/6/docs/api/java/net/Proxy.html&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: small;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: arial;&quot;&gt;Proxy&lt;/span&gt;&lt;/span&gt;&lt;/a&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: small;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: arial;&quot;&gt; class ,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;line-height: 16px; white-space: pre;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: small;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: arial;&quot;&gt;and pass it to the openConnection() method of the URL class.   &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: small;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: arial;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;  &lt;br /&gt;
&lt;div id=&quot;iframeDiv050e4a04-7642-4bd8-8e3f-5f586a151d7a&quot; style=&quot;display: none; margin: 0px;&quot;&gt;&lt;iframe frameborder=&quot;0&quot; id=&quot;iframe050e4a04-7642-4bd8-8e3f-5f586a151d7a&quot; src=&quot;http://www.blogtrog.com/code.aspx?id=050e4a04-7642-4bd8-8e3f-5f586a151d7a&quot; style=&quot;border: 1px solid #e0e0e0; height: 400px; margin: 0px; width: 550px;&quot;&gt;&lt;/iframe&gt;&lt;/div&gt;&lt;div id=&quot;noIframeDiv050e4a04-7642-4bd8-8e3f-5f586a151d7a&quot; style=&quot;display: block; margin: 0px;&quot;&gt;&lt;pre&gt;&lt;div&gt;&lt;span style=&quot;color: green;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;/**&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;
*PUBLIC SOFTWARE
*
*This source code has been placed in the public domain. You can use, modify, and distribute
*the source code and executable programs based on the source code.
*
*However, note the following:
*
*DISCLAIMER OF WARRANTY
*
* This source code is provided &quot;as is&quot; and without warranties as to performance
* or merchantability. The author and/or distributors of this source code may
* have made statements about this source code. Any such statements do not constitute
* warranties and shall not be relied on by the user in deciding whether to use
* this source code.This source code is provided without any express or implied
* warranties whatsoever. Because of the diversity of conditions and hardware
* under which this source code may be used, no warranty of fitness for a
* particular purpose is offered. The user is advised to test the source code
* thoroughly before relying on it. The user must assume the entire risk of
* using the source code.
*
&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;*/&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;import&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; java.io.&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;*&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;import&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; java.net.&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;*&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;import&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; com.sun.org.apache.xml.internal.security.utils.Base64;

&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;/**&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;
*
* &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;@author&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; amal
* version 1.0
&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;*/&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;



&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;public&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;class&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; UrlConA
{

&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;public&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;static&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;void&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; main(String[] args)
{
System.setProperty(&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;java.net.useSystemProxies&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;, &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;true&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;);
BufferedReader in &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;=&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;null&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;try&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;
{
URL url &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;=&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;new&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; URL(&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;http://www.w3schools.com&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;);
URLConnection uc &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;=&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; url.openConnection();
String encoded &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;=&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;new&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; String(Base64.encode(&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;new&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; String(
&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;username:password&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;).getBytes()));
uc.setRequestProperty(&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;Proxy-Authorization&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;, &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;Basic &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;+&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; encoded);
uc.connect();
in &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;=&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;new&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; BufferedReader(&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;new&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; InputStreamReader(uc.getInputStream()));
String inputLine;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;while&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; ((inputLine &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;=&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; in.readLine()) &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;!=&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;null&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;)
{
System.out.println(inputLine);
}
}
&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;catch&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; (MalformedURLException e)
{
e.printStackTrace();
}
&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;catch&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; (IOException e)
{
e.printStackTrace();
}
&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;finally&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;
{
&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;try&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;
{
&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;if&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; (&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;null&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;!=&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; in)
{
in.close();
}
}
&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;catch&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; (IOException e)
{
&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;//&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; ignore&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;              }
}
}
}&lt;/span&gt;
&lt;/span&gt;&lt;/div&gt;&lt;/pre&gt;&lt;/div&gt;&lt;script language=&quot;javascript&quot; src=&quot;http://www.blogtrog.com/scripts/bt_code.js&quot; type=&quot;text/javascript&quot;&gt;
&lt;/script&gt;&lt;script language=&quot;javascript&quot; type=&quot;text/javascript&quot;&gt;
bt_code_init(&#39;050e4a04-7642-4bd8-8e3f-5f586a151d7a&#39;);
&lt;/script&gt;</content><link rel='replies' type='application/atom+xml' href='http://zone817.blogspot.com/feeds/7325866588845273764/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://zone817.blogspot.com/2010/08/reading-from-url-using-java-program_02.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4625702208935784578/posts/default/7325866588845273764'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4625702208935784578/posts/default/7325866588845273764'/><link rel='alternate' type='text/html' href='http://zone817.blogspot.com/2010/08/reading-from-url-using-java-program_02.html' title='Connecting to an Url using a Java program - Connecting through a proxy'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4625702208935784578.post-2340706362330196503</id><published>2010-08-02T08:25:00.000-07:00</published><updated>2010-08-26T22:44:45.903-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="java"/><category scheme="http://www.blogger.com/atom/ns#" term="url"/><title type='text'>Connecting to an Url using a Java program</title><content type='html'>&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: small;&quot;&gt;The following code demonstrates how to read from a url using java.&lt;/span&gt;&lt;br /&gt;
&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: small;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: small;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;div id=&quot;iframeDivb37dc036-dbe4-481b-a4dc-c0d1f3d5cc26&quot; style=&quot;display: none; margin: 0px;&quot;&gt;&lt;iframe frameborder=&quot;0&quot; id=&quot;iframeb37dc036-dbe4-481b-a4dc-c0d1f3d5cc26&quot; src=&quot;http://www.blogtrog.com/code.aspx?id=b37dc036-dbe4-481b-a4dc-c0d1f3d5cc26&quot; style=&quot;border: 1px solid #e0e0e0; height: 400px; margin: 0px; width: 550px;&quot;&gt;&lt;/iframe&gt;&lt;/div&gt;&lt;div id=&quot;noIframeDivb37dc036-dbe4-481b-a4dc-c0d1f3d5cc26&quot; style=&quot;display: block; margin: 0px;&quot;&gt;&lt;pre&gt;&lt;div&gt;&lt;span style=&quot;color: green;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;/**&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;
*PUBLIC SOFTWARE
*
*This source code has been placed in the public domain. You can use, modify, and distribute
*the source code and executable programs based on the source code.
*
*However, note the following:
*
*DISCLAIMER OF WARRANTY
*
* This source code is provided &quot;as is&quot; and without warranties as to performance
* or merchantability. The author and/or distributors of this source code may
* have made statements about this source code. Any such statements do not constitute
* warranties and shall not be relied on by the user in deciding whether to use
* this source code.This source code is provided without any express or implied
* warranties whatsoever. Because of the diversity of conditions and hardware
* under which this source code may be used, no warranty of fitness for a
* particular purpose is offered. The user is advised to test the source code
* thoroughly before relying on it. The user must assume the entire risk of
* using the source code.
*
&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;*/&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;import&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; java.io.&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;*&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;import&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; java.net.&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;*&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;;

&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;/**&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;
*
* &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;@author&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; amal
* version 1.0
&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;*/&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;



&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;public&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;class&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; UrlCon
{

&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;public&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;static&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;void&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; main(String[] args)
{
BufferedReader in &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;=&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;null&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;try&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;
{
URL url &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;=&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;new&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; URL(&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;http://www.bing.com/&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;);
in &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;=&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;new&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; BufferedReader(&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;new&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; InputStreamReader(url.openStream()));
String inputLine;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;while&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; ((inputLine &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;=&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; in.readLine()) &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;!=&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;null&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;)
{
System.out.println(inputLine);
}
}
&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;catch&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; (MalformedURLException e)
{
e.printStackTrace();
}
&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;catch&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; (IOException e)
{
e.printStackTrace();
}
&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;finally&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;
{
&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;try&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;
{
&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;if&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; (&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;null&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;!=&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; in)
{
in.close();
}
}
&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;catch&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; (IOException e)
{
&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;//&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; ignore&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;              }
}
}
}&lt;/span&gt;
&lt;/span&gt;&lt;/div&gt;&lt;/pre&gt;&lt;/div&gt;&lt;script language=&quot;javascript&quot; src=&quot;http://www.blogtrog.com/scripts/bt_code.js&quot; type=&quot;text/javascript&quot;&gt;
&lt;/script&gt;&lt;script language=&quot;javascript&quot; type=&quot;text/javascript&quot;&gt;
bt_code_init(&#39;b37dc036-dbe4-481b-a4dc-c0d1f3d5cc26&#39;);
&lt;/script&gt;</content><link rel='replies' type='application/atom+xml' href='http://zone817.blogspot.com/feeds/2340706362330196503/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://zone817.blogspot.com/2010/08/reading-from-url-using-java-program.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4625702208935784578/posts/default/2340706362330196503'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4625702208935784578/posts/default/2340706362330196503'/><link rel='alternate' type='text/html' href='http://zone817.blogspot.com/2010/08/reading-from-url-using-java-program.html' title='Connecting to an Url using a Java program'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4625702208935784578.post-3611976076122000483</id><published>2010-08-01T07:22:00.000-07:00</published><updated>2010-08-26T22:44:22.687-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="java"/><category scheme="http://www.blogger.com/atom/ns#" term="javamail"/><title type='text'>Example code for sending mail with attachments using Java</title><content type='html'>The following code demonstrates how to send a mail with &lt;a href=&quot;http://www.oracle.com/technetwork/java/index-jsp-139225.html&quot;&gt;JavaMail&lt;/a&gt; . The example code uses the mail.jar file , which is included in the &lt;a href=&quot;http://www.oracle.com/technetwork/java/index-138643.html&quot;&gt;JavaMail download&lt;/a&gt; .&lt;br /&gt;
&lt;br /&gt;
&lt;div id=&quot;iframeDiv0aa39ecd-4615-43ff-8176-2fee29240c27&quot; style=&quot;display: none; margin: 0px;&quot;&gt;&lt;iframe frameborder=&quot;0&quot; id=&quot;iframe0aa39ecd-4615-43ff-8176-2fee29240c27&quot; src=&quot;http://www.blogtrog.com/code.aspx?id=0aa39ecd-4615-43ff-8176-2fee29240c27&quot; style=&quot;border: 1px solid #e0e0e0; height: 400px; margin: 0px; width: 550px;&quot;&gt;&lt;/iframe&gt;&lt;/div&gt;&lt;div id=&quot;noIframeDiv0aa39ecd-4615-43ff-8176-2fee29240c27&quot; style=&quot;display: block; margin: 0px;&quot;&gt;&lt;pre&gt;&lt;div&gt;&lt;span style=&quot;color: black;&quot;&gt;

&lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;/**&lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;
*PUBLIC SOFTWARE
*
*This source code has been placed in the public domain. You can use, modify, and distribute
*the source code and executable programs based on the source code.
*
*However, note the following:
*
*DISCLAIMER OF WARRANTY
*
* This source code is provided &quot;as is&quot; and without warranties as to performance
* or merchantability. The author and/or distributors of this source code may
* have made statements about this source code. Any such statements do not constitute
* warranties and shall not be relied on by the user in deciding whether to use
* this source code.This source code is provided without any express or implied
* warranties whatsoever. Because of the diversity of conditions and hardware
* under which this source code may be used, no warranty of fitness for a
* particular purpose is offered. The user is advised to test the source code
* thoroughly before relying on it. The user must assume the entire risk of
* using the source code.
*
&lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;*/&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;

&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;import&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; java.util.&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;*&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;
&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;import&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; javax.activation.&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;*&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;
&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;import&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; javax.mail.&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;*&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;
&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;import&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; javax.mail.internet.&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;*&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;

&lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;/**&lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;
*
* &lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;@author&lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt; amal
* version 1.0
&lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;*/&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;
&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;public&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;class&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; Mailer {
&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;public&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;static&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;void&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; main(String[] args) &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;throws&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; Exception{
Properties properties &lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;new&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; Properties();
properties.setProperty(&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;mail.transport.protocol&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;smtp&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;);
properties.setProperty(&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;mail.host&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;mailServer&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;);
properties.setProperty(&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;mail.user&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;emailUser&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;);
properties.setProperty(&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;mail.password&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;emailPassword&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;);
Session sess &lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; Session.getDefaultInstance(properties, &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;null&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;);
Transport transport &lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; sess.getTransport();
MimeMessage message &lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;new&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; MimeMessage(sess);
message.setSubject(&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;Mail Subject&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;);
MimeBodyPart textPart &lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;new&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; MimeBodyPart();
textPart.setContent(&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;Mail Content&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;text/html&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;);
MimeBodyPart attachmentPart &lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;new&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; MimeBodyPart();
FileDataSource fileDS &lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;new&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; FileDataSource(&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;FileToBeAttached&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;);
attachmentPart.setDataHandler(&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;new&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; DataHandler(fileDS));
attachmentPart.setFileName(fileDS.getName());
Multipart multipart &lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;new&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; MimeMultipart();
multipart.addBodyPart(textPart);
multipart.addBodyPart(attachmentPart);
message.setContent(multipart);
message.addRecipient(Message.RecipientType.TO,
&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;new&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; InternetAddress(&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;recepient@domain.com&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;));
transport.connect();
transport.sendMessage(message,
message.getRecipients(Message.RecipientType.TO));
transport.close();
}
}
&lt;/span&gt;&lt;/div&gt;&lt;/pre&gt;&lt;/div&gt;&lt;script language=&quot;javascript&quot; src=&quot;http://www.blogtrog.com/scripts/bt_code.js&quot; type=&quot;text/javascript&quot;&gt;
&lt;/script&gt;&lt;script language=&quot;javascript&quot; type=&quot;text/javascript&quot;&gt;
bt_code_init(&#39;0aa39ecd-4615-43ff-8176-2fee29240c27&#39;);
&lt;/script&gt;</content><link rel='replies' type='application/atom+xml' href='http://zone817.blogspot.com/feeds/3611976076122000483/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://zone817.blogspot.com/2010/08/example-code-for-sending-mail-with.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4625702208935784578/posts/default/3611976076122000483'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4625702208935784578/posts/default/3611976076122000483'/><link rel='alternate' type='text/html' href='http://zone817.blogspot.com/2010/08/example-code-for-sending-mail-with.html' title='Example code for sending mail with attachments using Java'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4625702208935784578.post-863335973954789618</id><published>2010-07-31T11:50:00.000-07:00</published><updated>2010-08-26T22:44:04.171-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="bigdecimal"/><category scheme="http://www.blogger.com/atom/ns#" term="java"/><title type='text'>Comparing BigDecimals using equals</title><content type='html'>&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: small;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: arial;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: small;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: arial;&quot;&gt;One important thing to know when you are comparing BigDecimals in Java is that the equals method returns true only if the objects being compared are equal in value and scale . So 3.14 not equals 3.140 if you are using the equals method . &lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: small;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: arial;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: arial;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: medium;&quot;&gt;&lt;b&gt;Alternatives that can be used . &lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: small;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: arial;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: small;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: arial;&quot;&gt;The compareTo method in BigDecimal is the obvious alternative to overcome the issue mentioned above . Another way would be to use the &lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: small; white-space: pre;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: arial;&quot;&gt;stripTrailingZeros methods on both objects before comparing them with equals .&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;white-space: pre;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: small;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: arial;&quot;&gt;However ,the &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;white-space: pre;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: small;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: arial;&quot;&gt;stripTrailingZeros method does create a new object , and so might have&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;white-space: pre;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: small;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: arial;&quot;&gt;an performance overhead . &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div id=&quot;iframeDiv6bde099c-fcc3-4736-9dbc-23da53b07851&quot; style=&quot;display: none; margin: 0px;&quot;&gt;&lt;iframe frameborder=&quot;0&quot; id=&quot;iframe6bde099c-fcc3-4736-9dbc-23da53b07851&quot; src=&quot;http://www.blogtrog.com/code.aspx?id=6bde099c-fcc3-4736-9dbc-23da53b07851&quot; style=&quot;border: 1px solid rgb(224, 224, 224); height: 150px; margin: 0px; width: 550px;&quot;&gt;&lt;/iframe&gt;&lt;/div&gt;&lt;div id=&quot;noIframeDiv6bde099c-fcc3-4736-9dbc-23da53b07851&quot; style=&quot;display: block; margin: 0px;&quot;&gt;&lt;pre&gt;&lt;div&gt;&lt;span style=&quot;color: black;&quot;&gt;   &lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; BigDecimal d1&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;=&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;new&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; BigDecimal(&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;3.14&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;);
BigDecimal d2&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;=&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;new&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; BigDecimal(&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;3.140&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;);
System.out.println(d1.equals(d2));
System.out.println(d1.compareTo(d2)&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;==&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;0&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;);
System.out.println(d1.stripTrailingZeros().equals(d2.stripTrailingZeros()));&lt;/span&gt;
&lt;/span&gt;&lt;/div&gt;&lt;/pre&gt;&lt;/div&gt;&lt;script language=&quot;javascript&quot; src=&quot;http://www.blogtrog.com/scripts/bt_code.js&quot; type=&quot;text/javascript&quot;&gt;
&lt;/script&gt;&lt;script language=&quot;javascript&quot; type=&quot;text/javascript&quot;&gt;
bt_code_init(&#39;6bde099c-fcc3-4736-9dbc-23da53b07851&#39;);
&lt;/script&gt;</content><link rel='replies' type='application/atom+xml' href='http://zone817.blogspot.com/feeds/863335973954789618/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://zone817.blogspot.com/2010/07/comparing-bigdecimals-using-equals.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4625702208935784578/posts/default/863335973954789618'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4625702208935784578/posts/default/863335973954789618'/><link rel='alternate' type='text/html' href='http://zone817.blogspot.com/2010/07/comparing-bigdecimals-using-equals.html' title='Comparing BigDecimals using equals'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4625702208935784578.post-965391496620411364</id><published>2010-07-28T11:02:00.000-07:00</published><updated>2010-08-26T22:43:44.535-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="gwt"/><category scheme="http://www.blogger.com/atom/ns#" term="suggestbox"/><title type='text'>Customizing a SuggestBox to simulate a Selection Box.</title><content type='html'>&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: small;&quot;&gt;This class attempts to combine the features of a SuggestBox and a ListBox .&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;div id=&quot;iframeDiva69ffc59-b480-47fe-87dd-c732d3ab1c29&quot; style=&quot;display: none; margin: 0px;&quot;&gt;&lt;iframe frameborder=&quot;0&quot; id=&quot;iframea69ffc59-b480-47fe-87dd-c732d3ab1c29&quot; src=&quot;http://www.blogtrog.com/code.aspx?id=a69ffc59-b480-47fe-87dd-c732d3ab1c29&quot; style=&quot;border: 1px solid #e0e0e0; height: 400px; margin: 0px; width: 550px;&quot;&gt;&lt;/iframe&gt;&lt;/div&gt;&lt;div id=&quot;noIframeDiva69ffc59-b480-47fe-87dd-c732d3ab1c29&quot; style=&quot;display: block; margin: 0px;&quot;&gt;&lt;pre&gt;&lt;div&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;/**&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;
*PUBLIC SOFTWARE
*
*This source code has been placed in the public domain. You can use, modify, and distribute
*the source code and executable programs based on the source code.
*
*However, note the following:
*
*DISCLAIMER OF WARRANTY
*
* This source code is provided &quot;as is&quot; and without warranties as to performance
* or merchantability. The author and/or distributors of this source code may
* have made statements about this source code. Any such statements do not constitute
* warranties and shall not be relied on by the user in deciding whether to use
* this source code.This source code is provided without any express or implied
* warranties whatsoever. Because of the diversity of conditions and hardware
* under which this source code may be used, no warranty of fitness for a
* particular purpose is offered. The user is advised to test the source code
* thoroughly before relying on it. The user must assume the entire risk of
* using the source code.
*
&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;*/&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;

&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;import&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; com.google.gwt.event.dom.client.ChangeEvent;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;import&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; com.google.gwt.event.dom.client.ChangeHandler;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;import&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; com.google.gwt.event.dom.client.KeyUpEvent;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;import&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; com.google.gwt.event.dom.client.KeyUpHandler;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;import&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; com.google.gwt.event.logical.shared.SelectionEvent;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;import&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; com.google.gwt.event.logical.shared.SelectionHandler;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;import&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; com.google.gwt.event.shared.HandlerRegistration;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;import&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; com.google.gwt.user.client.ui.MultiWordSuggestOracle;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;import&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; com.google.gwt.user.client.ui.SuggestBox;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;import&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; com.google.gwt.user.client.ui.SuggestOracle;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;import&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; com.google.gwt.user.client.ui.SuggestOracle.Suggestion;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;import&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; com.google.gwt.user.client.ui.TextBox;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;import&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; com.google.gwt.user.client.ui.TextBoxBase;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;import&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; java.util.HashMap;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;import&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; java.util.List;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;import&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; java.util.Map;

&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;/**&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;
* Extension of suggestBox simulating a traditional single-select list .
* &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;@author amal&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;
* &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;@version&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; 1.0
&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;*/&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;public&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;final&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;class&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; MyGwtSuggestBox &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;extends&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; SuggestBox
{

&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;private&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; String value;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;private&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; HashMap&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;String, String&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; itemValues;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;private&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; HashMap&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;String, String&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; valueItems;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;private&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; MultiWordSuggestOracle oracle;

&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;public&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; MyGwtSuggestBox(String value,
HashMap&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;String, String&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; itemValues,
HashMap&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;String, String&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; valueItems,
MultiWordSuggestOracle oracle)
{
&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;this&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;.value &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;=&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; value;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;this&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;.itemValues &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;=&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; itemValues;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;this&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;.valueItems &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;=&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; valueItems;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;this&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;.oracle &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;=&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; oracle;
}
&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;private&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; ChangeHandler changeHandler &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;=&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;new&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; ChangeHandler()
{

&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;/**&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;
* check if the current value is in set of possible values , else rollback
&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;*/&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;public&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;void&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; onChange(ChangeEvent event)
{
TextBox x &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;=&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; (TextBox) event.getSource();
String text &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;=&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; x.getText().trim();
&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;if&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; (value &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;==&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;null&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;)
{
value &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;=&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;&quot;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;;
}
&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;if&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; (itemValues.keySet().contains(text))
{
value &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;=&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; text;
}
&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;else&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;
{
x.setText(value);
}
}
};
&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;private&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; KeyUpHandler keyUpHandler &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;=&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;new&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; KeyUpHandler()
{

&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;public&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;void&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; onKeyUp(KeyUpEvent event)
{
MyGwtSuggestBox x &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;=&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; (MyGwtSuggestBox) event.getSource();
&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;if&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; (x.getText().trim().equals(&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;&quot;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;) &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; event.isDownArrow() &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;!&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;((DefaultSuggestionDisplay) x.
getSuggestionDisplay()).isSuggestionListShowing())
{
x.showSuggestionList();
}
}
};
&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;private&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; SelectionHandler&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;SuggestOracle.Suggestion&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; selectionHandler &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;=&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;new&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; SelectionHandler&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;SuggestOracle.Suggestion&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;()
{

&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;public&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;void&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; onSelection(SelectionEvent&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;Suggestion&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; event)
{
SuggestBox x &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;=&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; (SuggestBox) event.getSource();
String text &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;=&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; x.getText().trim();
&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;if&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; (value &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;==&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;null&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;)
{
value &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;=&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;&quot;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;;
}
&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;if&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; (itemValues.keySet().contains(text))
{
value &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;=&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; text;
}
&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;else&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;
{
x.setText(value);
}
}
};
&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;private&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; HandlerRegistration regChange &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;=&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;null&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;private&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; HandlerRegistration regFocus &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;=&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;null&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;;

;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;private&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; HandlerRegistration regKeyPress &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;=&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;null&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;private&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; HandlerRegistration regSelection &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;=&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;null&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;;

&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;public&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; MyGwtSuggestBox()
{
&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;this&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;false&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;);
}

&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;public&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; MyGwtSuggestBox(&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;boolean&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; enforceInputValidation)
{
&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;super&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;();
itemValues &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;=&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;new&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; HashMap&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;String, String&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;();
valueItems &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;=&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;new&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; HashMap&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;String, String&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;();
oracle &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;=&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; (MultiWordSuggestOracle) &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;super&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;.getSuggestOracle();
regKeyPress &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;=&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;super&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;.addKeyUpHandler(keyUpHandler);
&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;if&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; (&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;!&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;enforceInputValidation)
{
regChange &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;=&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;super&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;.getTextBox().addChangeHandler(changeHandler);
regSelection &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;=&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;super&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;.addSelectionHandler(selectionHandler);
}
}

&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;public&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;void&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; removeInputValidation()
{
&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;if&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; (&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;null&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;!=&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; regChange)
{
regChange.removeHandler();
regChange &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;=&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;null&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;;
}
&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;if&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; (&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;null&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;!=&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; regFocus)
{
regFocus.removeHandler();
regFocus &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;=&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;null&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;;
}
}

&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;public&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; MyGwtSuggestBox(SuggestOracle oracle, TextBoxBase box,
SuggestionDisplay suggestDisplay)
{
&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;throw&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;new&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; UnsupportedOperationException(&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;Not Supported.Yet.&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;);
}

&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;public&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; MyGwtSuggestBox(SuggestOracle oracle, TextBoxBase box)
{
&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;throw&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;new&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; UnsupportedOperationException(&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;Not Supported.Yet.&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;);
}

&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;public&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; MyGwtSuggestBox(SuggestOracle oracle)
{
&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;throw&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;new&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; UnsupportedOperationException(&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;Not Supported.Yet.&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;);
}

&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;public&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;void&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; removeAllItems()
{
itemValues &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;=&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;new&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; HashMap&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;String, String&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;();
valueItems &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;=&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;new&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; HashMap&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;String, String&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;();
oracle.clear();

}

&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;public&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;void&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; addItems(List&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;String&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; items)
{
&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;for&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; (String item : items)
{
addItem(item);
}
}

&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;public&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;void&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; addItems(String[] items)
{
&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;for&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; (String item : items)
{
addItem(item);
}

}

&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;public&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;void&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; addItems(Map&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;String, String&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; keyItems)
{
&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;for&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; (String key : keyItems.keySet())
{
addItem(keyItems.get(key), key);
}
}

&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;public&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;void&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; addItem(String item)
{
&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;if&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; (itemValues.containsKey(item))
{
&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;throw&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;new&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; RuntimeException(&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;Duplicate item in list : &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;+&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; item);
}
&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;if&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; (valueItems.containsKey(item))
{
&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;throw&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;new&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; RuntimeException(&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;Duplicate value in list : &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;+&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; item);
}
itemValues.put(item, item);
valueItems.put(item, item);
oracle.add(item);
oracle.setDefaultSuggestionsFromText(itemValues.keySet());
}

&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;public&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;void&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; addItem(String item, String key)
{
&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;if&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; (itemValues.containsKey(item))
{
&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;throw&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;new&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; RuntimeException(&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;Duplicate item in list : &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;+&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; item);
}
&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;if&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; (valueItems.containsKey(key))
{
&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;throw&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;new&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; RuntimeException(&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;Duplicate value in list : &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;+&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; key);
}
itemValues.put(item, key);
valueItems.put(key, item);
oracle.add(item);
oracle.setDefaultSuggestionsFromText(itemValues.keySet());
}

&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;public&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; String getSelectedValue()
{
&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;return&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; itemValues.get(&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;super&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;.getText());
}

&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;public&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;void&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; setSelectedValue(String key)
{
&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;super&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;.setText(valueItems.get(key));
}

&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;public&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;void&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; clear()
{
&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;super&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;.setText(&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;&quot;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;);
}
}
&lt;/span&gt;
&lt;/span&gt;&lt;/div&gt;&lt;/pre&gt;&lt;/div&gt;&lt;script language=&quot;javascript&quot; src=&quot;http://www.blogtrog.com/scripts/bt_code.js&quot; type=&quot;text/javascript&quot;&gt;
&lt;/script&gt;&lt;script language=&quot;javascript&quot; type=&quot;text/javascript&quot;&gt;
bt_code_init(&#39;a69ffc59-b480-47fe-87dd-c732d3ab1c29&#39;);
&lt;/script&gt;</content><link rel='replies' type='application/atom+xml' href='http://zone817.blogspot.com/feeds/965391496620411364/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://zone817.blogspot.com/2010/07/customizing-suggestbox-to-simulate.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4625702208935784578/posts/default/965391496620411364'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4625702208935784578/posts/default/965391496620411364'/><link rel='alternate' type='text/html' href='http://zone817.blogspot.com/2010/07/customizing-suggestbox-to-simulate.html' title='Customizing a SuggestBox to simulate a Selection Box.'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4625702208935784578.post-2656834853356206085</id><published>2010-07-28T10:56:00.000-07:00</published><updated>2010-08-26T22:43:20.753-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="gwt . dialogbox"/><title type='text'>A custom confirm dialog using GWT</title><content type='html'>&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: small;&quot;&gt;Ever grew frustrated by the lack of customizations available of the window.confirm() dialog ? Here&#39;s a customizable confirm dialog for gwt apps.&lt;br /&gt;
&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;div id=&quot;iframeDiv9e42077b-bdbf-4381-864e-51991ab3ada6&quot; style=&quot;display: none; margin: 0px;&quot;&gt;&lt;iframe frameborder=&quot;0&quot; id=&quot;iframe9e42077b-bdbf-4381-864e-51991ab3ada6&quot; src=&quot;http://www.blogtrog.com/code.aspx?id=9e42077b-bdbf-4381-864e-51991ab3ada6&quot; style=&quot;border: 1px solid #e0e0e0; height: 400px; margin: 0px; width: 550px;&quot;&gt;&lt;/iframe&gt;&lt;/div&gt;&lt;div id=&quot;noIframeDiv9e42077b-bdbf-4381-864e-51991ab3ada6&quot; style=&quot;display: block; margin: 0px;&quot;&gt;&lt;pre&gt;&lt;div&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;/**&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;
*PUBLIC SOFTWARE
*
*This source code has been placedin the public domain. You can use, modify, and distribute
*the source code and executable programs based on the source code.
*
*However, note the following:
*
*DISCLAIMER OF WARRANTY
*
* This source code is provided &quot;as is&quot; and without warranties as to performance
* or merchantability. The author and/or distributors of this source code may
* have made statements about this source code. Any such statements do not constitute
* warranties and shall not be relied on by the user in deciding whether to use
* this source code.This source code is provided without any express or implied
* warranties whatsoever. Because of the diversity of conditions and hardware
* under which this source code may be used, no warranty of fitness for a
* particular purpose is offered. The user is advised to test the source code
* thoroughly before relying on it. The user must assume the entire risk of
* using the source code.
*
&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;*/&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;import&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; com.google.gwt.event.dom.client.ClickEvent;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;import&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; com.google.gwt.event.dom.client.ClickHandler;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;import&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; com.google.gwt.event.logical.shared.CloseHandler;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;import&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; com.google.gwt.user.client.ui.&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;*&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;;

&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;/**&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;
* &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;@author&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; amal
* &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;@version&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; 1.0
&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;*/&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;public&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;final&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;class&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; MyGwtConfirmDialog &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;extends&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; DialogBox
{

&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;private&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; Button primaryBtn;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;private&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; Button secondaryBtn;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;private&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; VerticalPanel mainPanel;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;private&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; HorizontalPanel btnPanel;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;private&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; HTML messageLbl;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;private&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;boolean&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; primaryActionFired &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;=&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;false&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;private&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;boolean&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; secondaryActionFired &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;=&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;false&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;;

&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;public&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;boolean&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; primaryActionFired()
{
&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;return&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; primaryActionFired;
}

&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;public&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;boolean&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; secondaryActionFired()
{
&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;return&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; secondaryActionFired;
}

&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;/**&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;
*
* &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;@param&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; title
* &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;@param&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; message
* &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;@param&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; primaryActionText
* &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;@param&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; secondaryActionText
* &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;@param&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; closeHandler
*
* sample usage - retrieving the confirmation status
* &amp;lt;pre&amp;gt;
* CloseHandler&amp;lt;PopupPanel&amp;gt; closeHandler=new CloseHandler&amp;lt;PopupPanel&amp;gt;()
*          {
*
*               public void onClose(CloseEvent&amp;lt;PopupPanel&amp;gt; event)
*                 {
*                  MyGwtConfirmDialog x=(MyGwtConfirmDialog)event.getSource();
*                  Window.alert(&quot;primary &quot;+x.primaryActionFired()+&quot; ; secondary &quot;+x.secondaryActionFired());
*                 }
*           };
*         MyGwtConfirmDialog dia=new MyGwtConfirmDialog(&amp;lt;title&amp;gt;,&amp;lt;message&amp;gt;,&amp;lt;okText&amp;gt;,&amp;lt;cancelText&amp;gt;,closeHandler);
* &amp;lt;/pre&amp;gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;*/&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;public&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; MyGwtConfirmDialog(String title, String message,
String primaryActionText,
String secondaryActionText,
CloseHandler&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;PopupPanel&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; closeHandler)
{
&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;super&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;false&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;, &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;true&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;);
&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;super&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;.addCloseHandler(closeHandler);
&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;super&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;.setText(title);
mainPanel &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;=&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;new&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; VerticalPanel();
messageLbl &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;=&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;new&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; HTML(message);
btnPanel &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;=&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;new&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; HorizontalPanel();
mainPanel.add(messageLbl);
mainPanel.add(btnPanel);
primaryBtn &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;=&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;new&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; Button(primaryActionText, &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;new&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; ClickHandler()
{

&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;public&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;void&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; onClick(ClickEvent event)
{
primaryActionFired &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;=&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;true&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;;
MyGwtConfirmDialog.&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;this&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;.hide();
}
});
secondaryBtn &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;=&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;new&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; Button(secondaryActionText, &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;new&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; ClickHandler()
{

&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;public&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;void&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; onClick(ClickEvent event)
{
secondaryActionFired &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;=&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;true&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;;
MyGwtConfirmDialog.&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;this&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;.hide();
}
});
btnPanel.add(primaryBtn);
btnPanel.add(secondaryBtn);
btnPanel.setCellHorizontalAlignment(primaryBtn,
HorizontalPanel.ALIGN_RIGHT);
btnPanel.setCellHorizontalAlignment(secondaryBtn,
HorizontalPanel.ALIGN_LEFT);
&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;super&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;.setWidget(mainPanel);
mainPanel.setHeight(&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;100px&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;);
mainPanel.setWidth(&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;300px&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;);
btnPanel.setHeight(&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;30px&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;);
btnPanel.setVerticalAlignment(HorizontalPanel.ALIGN_BOTTOM);
btnPanel.addStyleName(&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;dia-btnPanel&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;);
primaryBtn.addStyleName(&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;dia-primaryBtn&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;);
secondaryBtn.addStyleName(&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;dia-secondaryBtn&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;);
messageLbl.addStyleName(&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;dia-message&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;);
&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;super&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;.setGlassEnabled(&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;true&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;);
&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;super&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;.setAnimationEnabled(&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;true&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;);
}

&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;/**&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;
*
* &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;@param&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; message
* &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;@param&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; closeHandler
* &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;@see&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; MyGwtConfirmDialog#MyGwtConfirmDialog(java.lang.String, java.lang.String, java.lang.String, java.lang.String, com.google.gwt.event.logical.shared.CloseHandler)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;*/&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;public&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; MyGwtConfirmDialog(String message,
CloseHandler&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;PopupPanel&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; closeHandler)
{
&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;this&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;Confirmation&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;, message, &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;Ok&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;, &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;Cancel&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;, closeHandler);
}

&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;/**&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;
* should be used for displaying the dialog .
&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;*/&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;public&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;void&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; paint()
{
primaryActionFired &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;=&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;false&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;;
secondaryActionFired &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;=&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;false&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;super&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;.center();
primaryBtn.setFocus(&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;true&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;);
}

&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;/**&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;
*
* &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;@param&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; width
&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;*/&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;public&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;void&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt; setMainPanelWidth(String width)
{
mainPanel.setWidth(width);
}
}
&lt;/span&gt;
&lt;/span&gt;&lt;/div&gt;&lt;/pre&gt;&lt;/div&gt;&lt;script language=&quot;javascript&quot; src=&quot;http://www.blogtrog.com/scripts/bt_code.js&quot; type=&quot;text/javascript&quot;&gt;
&lt;/script&gt;&lt;script language=&quot;javascript&quot; type=&quot;text/javascript&quot;&gt;
bt_code_init(&#39;9e42077b-bdbf-4381-864e-51991ab3ada6&#39;);
&lt;/script&gt;</content><link rel='replies' type='application/atom+xml' href='http://zone817.blogspot.com/feeds/2656834853356206085/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://zone817.blogspot.com/2010/07/custom-confirm-dialog-using-gwt.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4625702208935784578/posts/default/2656834853356206085'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4625702208935784578/posts/default/2656834853356206085'/><link rel='alternate' type='text/html' href='http://zone817.blogspot.com/2010/07/custom-confirm-dialog-using-gwt.html' title='A custom confirm dialog using GWT'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4625702208935784578.post-4728466889157724609</id><published>2010-07-28T08:28:00.000-07:00</published><updated>2010-08-26T22:42:39.059-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="datebox"/><category scheme="http://www.blogger.com/atom/ns#" term="gwt"/><title type='text'>GWT Custom Datebox</title><content type='html'>&lt;span style=&quot;font-size: 85%;&quot;&gt;Here&#39;s an implemenation of a DateBox in GWT , specially designed for keyboard users . Like the ones who cant bother to maneuver a mouse  .&lt;br /&gt;
&lt;br /&gt;
The field recognizes multiple date formats , and even some real shorthands - like type in 010203 , and the date is set to Jan 01,2003 .&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div id=&quot;iframeDiv8c26772c-f883-4eba-9fe8-1cfc48d6bc32&quot; style=&quot;display: none; margin: 0px;&quot;&gt;&lt;iframe frameborder=&quot;0&quot; id=&quot;iframe8c26772c-f883-4eba-9fe8-1cfc48d6bc32&quot; src=&quot;http://www.blogtrog.com/code.aspx?id=8c26772c-f883-4eba-9fe8-1cfc48d6bc32&quot; style=&quot;border: 1px solid rgb(224, 224, 224); height: 400px; margin: 0px; width: 550px;&quot;&gt;&lt;/iframe&gt;&lt;/div&gt;&lt;div id=&quot;noIframeDiv8c26772c-f883-4eba-9fe8-1cfc48d6bc32&quot; style=&quot;display: block; margin: 0px;&quot;&gt;&lt;pre&gt;&lt;div&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;
&lt;/span&gt;&lt;span style=&quot;color: green; font-size: 78%;&quot;&gt;/**&lt;/span&gt;&lt;span style=&quot;color: green; font-size: 78%;&quot;&gt;
*PUBLIC SOFTWARE
*
*This source code has been placed in the public domain. You can use, modify, and distribute
*the source code and executable programs based on the source code.
*
*However, note the following:
*
*DISCLAIMER OF WARRANTY
*
* This source code is provided &quot;as is&quot; and without warranties as to performance
* or merchantability. The author and/or distributors of this source code may
* have made statements about this source code. Any such statements do not constitute
* warranties and shall not be relied on by the user in deciding whether to use
* this source code.This source code is provided without any express or implied
* warranties whatsoever. Because of the diversity of conditions and hardware
* under which this source code may be used, no warranty of fitness for a
* particular purpose is offered. The user is advised to test the source code
* thoroughly before relying on it. The user must assume the entire risk of
* using the source code.
*
&lt;/span&gt;&lt;span style=&quot;color: green; font-size: 78%;&quot;&gt;*/&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;
&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: 78%;&quot;&gt;import&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt; com.google.gwt.event.dom.client.ChangeEvent;
&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: 78%;&quot;&gt;import&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt; com.google.gwt.event.dom.client.ChangeHandler;
&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: 78%;&quot;&gt;import&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt; com.google.gwt.event.shared.HandlerRegistration;
&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: 78%;&quot;&gt;import&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt; com.google.gwt.i18n.client.DateTimeFormat;
&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: 78%;&quot;&gt;import&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt; com.google.gwt.user.client.ui.&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;*&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;;
&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: 78%;&quot;&gt;import&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt; java.util.Date;

&lt;/span&gt;&lt;span style=&quot;color: green; font-size: 78%;&quot;&gt;/**&lt;/span&gt;&lt;span style=&quot;color: green; font-size: 78%;&quot;&gt;
* DateBox implemenation for keyboard power users.
* &lt;/span&gt;&lt;span style=&quot;color: grey; font-size: 78%;&quot;&gt;@author&lt;/span&gt;&lt;span style=&quot;color: green; font-size: 78%;&quot;&gt;
* &lt;/span&gt;&lt;span style=&quot;color: grey; font-size: 78%;&quot;&gt;@version&lt;/span&gt;&lt;span style=&quot;color: green; font-size: 78%;&quot;&gt; 1.0
&lt;/span&gt;&lt;span style=&quot;color: green; font-size: 78%;&quot;&gt;*/&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;
&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: 78%;&quot;&gt;public&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: blue; font-size: 78%;&quot;&gt;final&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: blue; font-size: 78%;&quot;&gt;class&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt; MyGwtDateBox &lt;/span&gt;&lt;span style=&quot;color: blue; font-size: 78%;&quot;&gt;extends&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt; TextBox
{

&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: 78%;&quot;&gt;private&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: blue; font-size: 78%;&quot;&gt;static&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: blue; font-size: 78%;&quot;&gt;final&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: blue; font-size: 78%;&quot;&gt;long&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt; MS_PER_SEC &lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;1000&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;;
&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: 78%;&quot;&gt;private&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: blue; font-size: 78%;&quot;&gt;static&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: blue; font-size: 78%;&quot;&gt;final&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: blue; font-size: 78%;&quot;&gt;long&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt; MS_PER_MIN &lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt; MS_PER_SEC &lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;*&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;60&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;;
&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: 78%;&quot;&gt;private&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: blue; font-size: 78%;&quot;&gt;static&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: blue; font-size: 78%;&quot;&gt;final&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: blue; font-size: 78%;&quot;&gt;long&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt; MS_PER_HOUR &lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt; MS_PER_MIN &lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;*&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;60&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;;
&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: 78%;&quot;&gt;private&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: blue; font-size: 78%;&quot;&gt;static&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: blue; font-size: 78%;&quot;&gt;final&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: blue; font-size: 78%;&quot;&gt;long&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt; MS_PER_DAY &lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt; MS_PER_HOUR &lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;*&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;24&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;;
&lt;/span&gt;&lt;span style=&quot;color: green; font-size: 78%;&quot;&gt;/**&lt;/span&gt;&lt;span style=&quot;color: green; font-size: 78%;&quot;&gt;
* date formats recognized .
&lt;/span&gt;&lt;span style=&quot;color: green; font-size: 78%;&quot;&gt;*/&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;
&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: 78%;&quot;&gt;private&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: blue; font-size: 78%;&quot;&gt;static&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt; String[] formats &lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: blue; font-size: 78%;&quot;&gt;new&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt; String[]
{
&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;dd-MM-yyyy&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;,
&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;dd-MMM-yyyy&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;,
&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;dd.MM.yyyy&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;,
&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;dd.MMM.yyyy&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;,
&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;dd/MM/yyyy&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;,
&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;dd/MMM/yyyy&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;,
&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;dd MM yyyy&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;,
&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;dd MMM yyyy&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;,
&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;dd-MMMM-yyyy&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;,
&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;dd.MMMM.yyyy&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;,
&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;dd/MMMM/yyyy&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;,
&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;dd MMMM yyyy&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;,
&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;MMM dd yyyy&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;,
&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;MMMM dd yyyy&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;,
&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;MMM dd,yyyy&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;,
&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;MMMM dd,yyyy&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;
};
&lt;/span&gt;&lt;span style=&quot;color: green; font-size: 78%;&quot;&gt;/**&lt;/span&gt;&lt;span style=&quot;color: green; font-size: 78%;&quot;&gt;
* output dateFormat
&lt;/span&gt;&lt;span style=&quot;color: green; font-size: 78%;&quot;&gt;*/&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;
&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: 78%;&quot;&gt;private&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: blue; font-size: 78%;&quot;&gt;static&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt; DateTimeFormat dtf &lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt; DateTimeFormat.getFormat(&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;dd-MMM-yyyy&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;);

&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: 78%;&quot;&gt;public&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: blue; font-size: 78%;&quot;&gt;static&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt; DateTimeFormat getDateTimeFormat()
{
&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: 78%;&quot;&gt;return&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt; dtf;
}
&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: 78%;&quot;&gt;private&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt; DateTimeFormat fullWeekDay &lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt; DateTimeFormat.getFormat(&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;EEEE&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;);
&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: 78%;&quot;&gt;private&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt; DateTimeFormat shortWeekDay &lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt; DateTimeFormat.getFormat(&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;EEE&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;);
&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: 78%;&quot;&gt;private&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt; Date today &lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt; today();
&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: 78%;&quot;&gt;private&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt; Date yesterday &lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt; yesterday();
&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: 78%;&quot;&gt;private&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt; Date tommorrow &lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt; tommorrow();
&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: 78%;&quot;&gt;private&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt; Date value;
&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: 78%;&quot;&gt;boolean&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt; nullAllowed &lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: blue; font-size: 78%;&quot;&gt;false&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;;
&lt;/span&gt;&lt;span style=&quot;color: green; font-size: 78%;&quot;&gt;/**&lt;/span&gt;&lt;span style=&quot;color: green; font-size: 78%;&quot;&gt;
*
&lt;/span&gt;&lt;span style=&quot;color: green; font-size: 78%;&quot;&gt;*/&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;
&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: 78%;&quot;&gt;private&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt; ChangeHandler changeHandler &lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: blue; font-size: 78%;&quot;&gt;new&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt; ChangeHandler()
{

&lt;/span&gt;&lt;span style=&quot;color: green; font-size: 78%;&quot;&gt;/**&lt;/span&gt;&lt;span style=&quot;color: green; font-size: 78%;&quot;&gt;
* try inferring the date from the enterd String , if not possible rollback to previous value.
&lt;/span&gt;&lt;span style=&quot;color: green; font-size: 78%;&quot;&gt;*/&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;
&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: 78%;&quot;&gt;public&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: blue; font-size: 78%;&quot;&gt;void&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt; onChange(ChangeEvent event)
{
MyGwtDateBox x &lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt; (MyGwtDateBox) event.getSource();
String text &lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt; x.getText();
&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: 78%;&quot;&gt;if&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt; (nullAllowed)
{
&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: 78%;&quot;&gt;if&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: 78%;&quot;&gt;null&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;==&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt; text &lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;||&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt; text.trim().equals(&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;&quot;&quot;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;))
{
&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: 78%;&quot;&gt;return&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;;
}
}
&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: 78%;&quot;&gt;if&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt; (text &lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;==&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: blue; font-size: 78%;&quot;&gt;null&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;)
{
text &lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt; dtf.format(&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: 78%;&quot;&gt;new&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt; Date());
}
text &lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt; text.trim();
text.replaceAll(&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;\\s+&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;\\s&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;);
text &lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt; handleNoSpacesString(text);
&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: 78%;&quot;&gt;try&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;
{
text &lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt; handleShortHands(text);
text &lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt; adjustYear(text);
text &lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt; dtf.format(DateTimeFormat.getFormat(inferFormat(text)).
parse(text));
value &lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt; dtf.parse(text);
x.setText(text);
}
&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: 78%;&quot;&gt;catch&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt; (Exception e)
{
x.setText(dtf.format(value));
}
}
};
&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: 78%;&quot;&gt;private&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt; HandlerRegistration regChange;

&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: 78%;&quot;&gt;public&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt; MyGwtDateBox(&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: 78%;&quot;&gt;int&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt; maxLength, &lt;/span&gt;&lt;span style=&quot;color: blue; font-size: 78%;&quot;&gt;int&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt; visibleLength)
{
&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: 78%;&quot;&gt;throw&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: blue; font-size: 78%;&quot;&gt;new&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt; UnsupportedOperationException(&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;not supported&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;);
}

&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: 78%;&quot;&gt;public&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt; MyGwtDateBox(String text, &lt;/span&gt;&lt;span style=&quot;color: blue; font-size: 78%;&quot;&gt;int&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt; maxLength, &lt;/span&gt;&lt;span style=&quot;color: blue; font-size: 78%;&quot;&gt;int&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt; visibleLength)
{
&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: 78%;&quot;&gt;throw&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: blue; font-size: 78%;&quot;&gt;new&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt; UnsupportedOperationException(&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;not supported&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;);
}

&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: 78%;&quot;&gt;public&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt; MyGwtDateBox(&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: 78%;&quot;&gt;int&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt; maxLength)
{
&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: 78%;&quot;&gt;throw&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: blue; font-size: 78%;&quot;&gt;new&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt; UnsupportedOperationException(&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;not supported&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;);
}

&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: 78%;&quot;&gt;public&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt; MyGwtDateBox(String text, &lt;/span&gt;&lt;span style=&quot;color: blue; font-size: 78%;&quot;&gt;int&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt; maxLength)
{
&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: 78%;&quot;&gt;throw&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: blue; font-size: 78%;&quot;&gt;new&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt; UnsupportedOperationException(&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;not supported&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;);
}

&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: 78%;&quot;&gt;public&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt; MyGwtDateBox(String text)
{
&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: 78%;&quot;&gt;throw&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: blue; font-size: 78%;&quot;&gt;new&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt; UnsupportedOperationException(&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;not supported&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;);
}

&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: 78%;&quot;&gt;public&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt; MyGwtDateBox()
{
&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: 78%;&quot;&gt;this&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: 78%;&quot;&gt;new&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt; Date());
}

&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: 78%;&quot;&gt;public&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt; MyGwtDateBox(Date d)
{
&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: 78%;&quot;&gt;super&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;();
&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: 78%;&quot;&gt;super&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;.setText(dtf.format(d));
value &lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt; d;
regChange &lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: blue; font-size: 78%;&quot;&gt;super&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;.addChangeHandler(changeHandler);
}

&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: 78%;&quot;&gt;public&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: blue; font-size: 78%;&quot;&gt;void&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt; setNullAllowed(&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: 78%;&quot;&gt;boolean&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt; nullAllowed)
{
&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: 78%;&quot;&gt;this&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;.nullAllowed &lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt; nullAllowed;
}

String handleNoSpacesString(String x)
{
&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: 78%;&quot;&gt;if&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt; (x.matches(&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;^\\d+$&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;))
{
&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: 78%;&quot;&gt;if&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt; (x.length() &lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;==&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;6&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;||&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt; x.length() &lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;==&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;8&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;)
{
&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: 78%;&quot;&gt;return&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt; x.substring(&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;2&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt; x.substring(&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;2&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;4&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt; x.
substring(&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;4&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;);
}
}
&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: 78%;&quot;&gt;return&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt; x;
}

&lt;/span&gt;&lt;span style=&quot;color: green; font-size: 78%;&quot;&gt;/**&lt;/span&gt;&lt;span style=&quot;color: green; font-size: 78%;&quot;&gt;
* the short-hand evaluation done in accordance with the values entered in AppMessages.properties
* &lt;/span&gt;&lt;span style=&quot;color: grey; font-size: 78%;&quot;&gt;@param&lt;/span&gt;&lt;span style=&quot;color: green; font-size: 78%;&quot;&gt; x
* &lt;/span&gt;&lt;span style=&quot;color: grey; font-size: 78%;&quot;&gt;@return&lt;/span&gt;&lt;span style=&quot;color: green; font-size: 78%;&quot;&gt;
&lt;/span&gt;&lt;span style=&quot;color: green; font-size: 78%;&quot;&gt;*/&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;
String handleShortHands(String x)
{
&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: 78%;&quot;&gt;boolean&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt; previousFlag &lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: blue; font-size: 78%;&quot;&gt;false&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;;
&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: 78%;&quot;&gt;if&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt; (x.equalsIgnoreCase(MESSAGES.today()))
{
&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: 78%;&quot;&gt;return&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt; dtf.format(today);
}
&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: 78%;&quot;&gt;if&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt; (x.equalsIgnoreCase(MESSAGES.tommorrow()))
{
&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: 78%;&quot;&gt;return&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt; dtf.format(tommorrow);
}
&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: 78%;&quot;&gt;if&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt; (x.equalsIgnoreCase(MESSAGES.yesterday()))
{
&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: 78%;&quot;&gt;return&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt; dtf.format(yesterday);
}
&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: 78%;&quot;&gt;if&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt; (x.startsWith(MESSAGES.previous()))
{
previousFlag &lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: blue; font-size: 78%;&quot;&gt;true&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;;
x &lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt; x.split(&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;\\s&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;)[&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;];
}
&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: 78%;&quot;&gt;if&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt; (x.startsWith(MESSAGES.next()))
{
x &lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt; x.split(&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;\\s&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;)[&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;];
}
&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: 78%;&quot;&gt;if&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;!&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;x.trim().equals(&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;&quot;&quot;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt; MESSAGES.weekdaysString().
contains(x &lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;))
{
Date dt &lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt; previousFlag &lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;?&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: blue; font-size: 78%;&quot;&gt;new&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt; Date(yesterday.getTime()) : &lt;/span&gt;&lt;span style=&quot;color: blue; font-size: 78%;&quot;&gt;new&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt; Date(tommorrow.
getTime());
&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: 78%;&quot;&gt;long&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt; increment &lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt; previousFlag &lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;?&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt; MS_PER_DAY &lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;*&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt; : MS_PER_DAY;
&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: 78%;&quot;&gt;while&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;!&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;fullWeekDay.format(dt).equalsIgnoreCase(x))
{
dt.setTime(dt.getTime() &lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt; increment);
}
&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: 78%;&quot;&gt;return&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt; dtf.format(dt);
}
&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: 78%;&quot;&gt;if&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;!&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;x.trim().equals(&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;&quot;&quot;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt; MESSAGES.weekdaysStringShort().
contains(x &lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;))
{
Date dt &lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt; previousFlag &lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;?&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: blue; font-size: 78%;&quot;&gt;new&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt; Date(yesterday.getTime()) : &lt;/span&gt;&lt;span style=&quot;color: blue; font-size: 78%;&quot;&gt;new&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt; Date(tommorrow.
getTime());
&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: 78%;&quot;&gt;long&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt; increment &lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt; previousFlag &lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;?&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt; MS_PER_DAY &lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;*&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt; : MS_PER_DAY;
&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: 78%;&quot;&gt;while&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;!&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;shortWeekDay.format(dt).equalsIgnoreCase(x))
{
dt.setTime(dt.getTime() &lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt; increment);
}
&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: 78%;&quot;&gt;return&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt; dtf.format(dt);
}
&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: 78%;&quot;&gt;return&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt; x;
}

&lt;/span&gt;&lt;span style=&quot;color: green; font-size: 78%;&quot;&gt;/**&lt;/span&gt;&lt;span style=&quot;color: green; font-size: 78%;&quot;&gt;
* example transformations
* 19 -&amp;gt; 2019
* 20 -&amp;gt; 2020
* 21 -&amp;gt; 1921
* &lt;/span&gt;&lt;span style=&quot;color: grey; font-size: 78%;&quot;&gt;@param&lt;/span&gt;&lt;span style=&quot;color: green; font-size: 78%;&quot;&gt; x
* &lt;/span&gt;&lt;span style=&quot;color: grey; font-size: 78%;&quot;&gt;@return&lt;/span&gt;&lt;span style=&quot;color: green; font-size: 78%;&quot;&gt;
&lt;/span&gt;&lt;span style=&quot;color: green; font-size: 78%;&quot;&gt;*/&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;
String adjustYear(String x)
{
&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: 78%;&quot;&gt;if&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt; (x.matches(&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;^.*\\D\\d\\d$&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;))
{
&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: 78%;&quot;&gt;int&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt; year &lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt; Integer.parseInt(x.substring(x.length() &lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;2&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;, x.length()));
x &lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt; x.substring(&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;, x.length() &lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;2&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt; (year &lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;21&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;?&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;20&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt; : &lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;19&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt; x.
substring(x.length() &lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;2&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;, x.length());
}
&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: 78%;&quot;&gt;return&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt; x;
}

String inferFormat(String x)
{
&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: 78%;&quot;&gt;for&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt; (String format : formats)
{
&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: 78%;&quot;&gt;try&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;
{
DateTimeFormat.getFormat(format).parse(x);
&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: 78%;&quot;&gt;return&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt; format;
}
&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: 78%;&quot;&gt;catch&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt; (Exception e)
{
&lt;/span&gt;&lt;span style=&quot;color: green; font-size: 78%;&quot;&gt;//&lt;/span&gt;&lt;span style=&quot;color: green; font-size: 78%;&quot;&gt;ignore&lt;/span&gt;&lt;span style=&quot;color: green; font-size: 78%;&quot;&gt;
&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;              }
}
&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: 78%;&quot;&gt;throw&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: blue; font-size: 78%;&quot;&gt;new&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt; RuntimeException(&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;Unparseable date , &lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt; x);
}

&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: 78%;&quot;&gt;static&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt; Date today()
{
&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: 78%;&quot;&gt;return&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: blue; font-size: 78%;&quot;&gt;new&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt; Date();
}

&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: 78%;&quot;&gt;static&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt; Date yesterday()
{
Date tmp &lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: blue; font-size: 78%;&quot;&gt;new&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt; Date();
tmp.setTime(tmp.getTime() &lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt; MS_PER_DAY);
&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: 78%;&quot;&gt;return&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: blue; font-size: 78%;&quot;&gt;new&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt; Date(tmp.getTime());
}

&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: 78%;&quot;&gt;static&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt; Date tommorrow()
{
Date tmp &lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: blue; font-size: 78%;&quot;&gt;new&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt; Date();
tmp.setTime(tmp.getTime() &lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt; MS_PER_DAY);
&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: 78%;&quot;&gt;return&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: blue; font-size: 78%;&quot;&gt;new&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt; Date(tmp.getTime());
}

&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: 78%;&quot;&gt;public&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt; Date getDate()
{
&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: 78%;&quot;&gt;return&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt; dtf.parse(&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: 78%;&quot;&gt;super&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;.getText());
}

&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: 78%;&quot;&gt;public&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: blue; font-size: 78%;&quot;&gt;void&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt; setDate(Date x)
{
&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: 78%;&quot;&gt;super&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;.setText(dtf.format(x));
}
}

&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: 78%;&quot;&gt;class&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt; MESSAGES
{

&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: 78%;&quot;&gt;static&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt; String today()
{
&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: 78%;&quot;&gt;return&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;today&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;;
}

&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: 78%;&quot;&gt;static&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt; String tommorrow()
{
&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: 78%;&quot;&gt;return&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;tomm&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;;
}

&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: 78%;&quot;&gt;static&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt; String yesterday()
{
&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: 78%;&quot;&gt;return&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;yesterday&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;;
}

&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: 78%;&quot;&gt;static&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt; String next()
{
&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: 78%;&quot;&gt;return&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;next&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;;
}

&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: 78%;&quot;&gt;static&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt; String previous()
{
&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: 78%;&quot;&gt;return&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;previous&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;;
}

&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: 78%;&quot;&gt;static&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt; String weekdaysString()
{
&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: 78%;&quot;&gt;return&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;sunday;monday;tuesday;wednesday;thursday;friday;saturday;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;;
}

&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: 78%;&quot;&gt;static&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt; String weekdaysStringShort()
{
&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: 78%;&quot;&gt;return&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;sun;mon;tue;wed;thu;fri;sat;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 78%;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;font-size: 78%;&quot;&gt;;
}
}
&lt;/span&gt;
&lt;/span&gt;&lt;/div&gt;&lt;/pre&gt;&lt;/div&gt;&lt;script language=&quot;javascript&quot; src=&quot;http://www.blogtrog.com/scripts/bt_code.js&quot; type=&quot;text/javascript&quot;&gt;
&lt;/script&gt;&lt;script language=&quot;javascript&quot; type=&quot;text/javascript&quot;&gt;
bt_code_init(&#39;8c26772c-f883-4eba-9fe8-1cfc48d6bc32&#39;);
&lt;/script&gt;</content><link rel='replies' type='application/atom+xml' href='http://zone817.blogspot.com/feeds/4728466889157724609/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://zone817.blogspot.com/2010/07/gwt-custom-datebox.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4625702208935784578/posts/default/4728466889157724609'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4625702208935784578/posts/default/4728466889157724609'/><link rel='alternate' type='text/html' href='http://zone817.blogspot.com/2010/07/gwt-custom-datebox.html' title='GWT Custom Datebox'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry></feed>