<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="ru">
		<id>http://jexp.ru/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Admin</id>
		<title>Java эксперт - Вклад участника [ru]</title>
		<link rel="self" type="application/atom+xml" href="http://jexp.ru/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Admin"/>
		<link rel="alternate" type="text/html" href="http://jexp.ru/index.php/%D0%A1%D0%BB%D1%83%D0%B6%D0%B5%D0%B1%D0%BD%D0%B0%D1%8F:%D0%92%D0%BA%D0%BB%D0%B0%D0%B4/Admin"/>
		<updated>2026-04-14T23:10:47Z</updated>
		<subtitle>Вклад участника</subtitle>
		<generator>MediaWiki 1.30.0</generator>

	<entry>
		<id>http://jexp.ru/index.php?title=Java_%D1%8D%D0%BA%D1%81%D0%BF%D0%B5%D1%80%D1%82:%D0%9E%D1%82%D0%BA%D0%B0%D0%B7_%D0%BE%D1%82_%D0%BE%D1%82%D0%B2%D0%B5%D1%82%D1%81%D1%82%D0%B2%D0%B5%D0%BD%D0%BD%D0%BE%D1%81%D1%82%D0%B8&amp;diff=9257</id>
		<title>Java эксперт:Отказ от ответственности</title>
		<link rel="alternate" type="text/html" href="http://jexp.ru/index.php?title=Java_%D1%8D%D0%BA%D1%81%D0%BF%D0%B5%D1%80%D1%82:%D0%9E%D1%82%D0%BA%D0%B0%D0%B7_%D0%BE%D1%82_%D0%BE%D1%82%D0%B2%D0%B5%D1%82%D1%81%D1%82%D0%B2%D0%B5%D0%BD%D0%BD%D0%BE%D1%81%D1%82%D0%B8&amp;diff=9257"/>
				<updated>2010-06-01T15:02:03Z</updated>
		
		<summary type="html">&lt;p&gt;Admin: Новая страница: «JEXP.RU, Интернет-энциклопедия с открытым содержимым, является добровольным сообществом лич…»&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;JEXP.RU, Интернет-энциклопедия с открытым содержимым, является добровольным сообществом личностей и групп, создающих общее хранилище человеческих знаний. Её строение позволяет любому, кто имеет доступ к Интернету и браузер, изменять её содержание. Поэтому, пожалуйста, примите во внимание, что приведённые здесь сведения могут быть не проверенными профессионалами, обладающими знаниями в соответствующих областях, необходимыми для предоставления вам полной, точной или заслуживающей доверия информации о любом понятии в JEXP.RU.&lt;br /&gt;
&lt;br /&gt;
Нельзя сказать, что в JEXP.RU не так уж много полезной и точной информации, однако вы должны сознавать, что JEXP.RU не может никаким способом гарантировать правильность приведённых в ней данных. Во время прочтения они могли быть только что изменены, испорчены, либо написаны тем, чьё мнение отличается от общепринятого в области знаний, интересующей вас.&lt;br /&gt;
&lt;br /&gt;
Мы ищем пути проверки и отбора вызывающих наибольшее доверие версий статей, но мы не можем ничего гарантировать. Наше наибольшее достижение — это избранные участниками статьи, но даже они могли быть испорчены или искажены кем-то за несколько мгновений до прочтения вами.&lt;br /&gt;
&lt;br /&gt;
Никто из авторов, участников, спонсоров, администраторов, операторов и лиц, как-либо ещё связанных с JEXP.RU, не несёт ответственность за появление неточной или ложной информации, а также за использование вами данных, содержащихся на этих веб-страницах либо найденных по ссылкам с них.&lt;br /&gt;
Пожалуйста, примите во внимание, что вся информация, находящаяся здесь, предоставлена свободно, как акт доброй воли, без заключения каких-либо договорённостей или договоров между вами и владельцами или пользователями данного сайта, владельцами серверов, на которых он размещён, авторами JEXP.RU, администраторами проекта, операторами либо кем-то ещё, любым образом связанными с этим или родственными ему проектами, которые [договора] могут стать предметом прямых претензий. Вам предоставляется ограниченное право копировать содержимое этого сайта — данное право не предусматривает и не подразумевает никакой договорной или иной ответственности за любую часть JEXP.RU или её агентов, участников, организаторов или других пользователей.&lt;br /&gt;
&lt;br /&gt;
Любые торговые марки, знаки и названия товаров, служб и организаций, права на дизайн, авторские и смежные права, которые упоминаются, используются или цитируются в статьях, принадлежат их законным владельцам. Их использование здесь не даёт вам право на любое другое использование, кроме предусмотренного авторами статей JEXP.RU в соответствии со схемой лицензирования GFDL. Если не указано иное, JEXP.RU никак не связан с правообладателями, и поэтому JEXP.RU не может распоряжаться правами на использование материалов, защищённых авторским правом. Вы несёте ответственность за использование этих и подобных материалов.&lt;br /&gt;
&lt;br /&gt;
Обратите внимание, что чтение, распространение или изменение информации, размещённой в JEXP.RU, может являться нарушением законов той страны, в которой вы просматриваете этот сайт. JEXP.RU не призывает к нарушению никаких законов. Законы вашей страны могут трактовать защиту свободы слова не так широко, как законы России — в этом случае JEXP.RU не несёт ответственности за любые потенциальные нарушения этих законов вами при создании ссылок на этот сайт или другом использовании любой содержащейся здесь информации.&lt;br /&gt;
&lt;br /&gt;
Несмотря на то, что пользователи могут исправлять ошибки или убирать ошибочные суждения, они не обязаны этого делать. Поэтому вся информация предоставляется без гарантии полезности для любой цели либо пригодности к какому-либо использованию.&lt;br /&gt;
&lt;br /&gt;
JEXP.RU не может нести ответственность за любой нанесённый ущерб, так как является добровольным сообществом, свободно организованным для создания открытых образовательных, культурных и информационных ресурсов. Информация предоставляется как акт доброй воли и не существует соглашения или акта о намерениях между вами и JEXP.RU относительно использования или изменения информации, не предусмотренного GNU Free Documentation License. Также никто в JEXP.RU не несёт ответственности за изменение, редактирование или удаление любой информации, добавленной вами в JEXP.RU или другие связанные с ней проекты.&lt;br /&gt;
&lt;br /&gt;
Спасибо, что потратили своё время на чтение этой страницы. Желаем вам получить только приятные впечатления от пользования JEXP.RU.&lt;/div&gt;</summary>
		<author><name>Admin</name></author>	</entry>

	<entry>
		<id>http://jexp.ru/index.php?title=Java_%D1%8D%D0%BA%D1%81%D0%BF%D0%B5%D1%80%D1%82:%D0%90%D0%B2%D1%82%D0%BE%D1%80%D1%81%D0%BA%D0%BE%D0%B5_%D0%BF%D1%80%D0%B0%D0%B2%D0%BE&amp;diff=9256</id>
		<title>Java эксперт:Авторское право</title>
		<link rel="alternate" type="text/html" href="http://jexp.ru/index.php?title=Java_%D1%8D%D0%BA%D1%81%D0%BF%D0%B5%D1%80%D1%82:%D0%90%D0%B2%D1%82%D0%BE%D1%80%D1%81%D0%BA%D0%BE%D0%B5_%D0%BF%D1%80%D0%B0%D0%B2%D0%BE&amp;diff=9256"/>
				<updated>2010-06-01T14:55:27Z</updated>
		
		<summary type="html">&lt;p&gt;Admin: Защищена страница «Java эксперт:Авторское право» ([edit=sysop] (бессрочно) [move=sysop] (бессрочно))&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;JEXP.RU, Интернет-энциклопедия с открытым содержимым, является добровольным сообществом личностей и групп, создающих общее хранилище человеческих знаний. Её строение позволяет любому, кто имеет доступ к Интернету и браузер, изменять её содержание. Поэтому, пожалуйста, примите во внимание, что приведённые здесь сведения могут быть не проверенными профессионалами, обладающими знаниями в соответствующих областях, необходимыми для предоставления вам полной, точной или заслуживающей доверия информации о любом понятии в JEXP.RU.&lt;br /&gt;
&lt;br /&gt;
Нельзя сказать, что в JEXP.RU не так уж много полезной и точной информации, однако вы должны сознавать, что JEXP.RU не может никаким способом гарантировать правильность приведённых в ней данных. Во время прочтения они могли быть только что изменены, испорчены, либо написаны тем, чьё мнение отличается от общепринятого в области знаний, интересующей вас.&lt;br /&gt;
&lt;br /&gt;
Мы ищем пути проверки и отбора вызывающих наибольшее доверие версий статей, но мы не можем ничего гарантировать. Наше наибольшее достижение — это избранные участниками статьи, но даже они могли быть испорчены или искажены кем-то за несколько мгновений до прочтения вами.&lt;br /&gt;
&lt;br /&gt;
Никто из авторов, участников, спонсоров, администраторов, операторов и лиц, как-либо ещё связанных с JEXP.RU, не несёт ответственность за появление неточной или ложной информации, а также за использование вами данных, содержащихся на этих веб-страницах либо найденных по ссылкам с них.&lt;br /&gt;
Пожалуйста, примите во внимание, что вся информация, находящаяся здесь, предоставлена свободно, как акт доброй воли, без заключения каких-либо договорённостей или договоров между вами и владельцами или пользователями данного сайта, владельцами серверов, на которых он размещён, авторами JEXP.RU, администраторами проекта, операторами либо кем-то ещё, любым образом связанными с этим или родственными ему проектами, которые [договора] могут стать предметом прямых претензий. Вам предоставляется ограниченное право копировать содержимое этого сайта — данное право не предусматривает и не подразумевает никакой договорной или иной ответственности за любую часть JEXP.RU или её агентов, участников, организаторов или других пользователей.&lt;br /&gt;
&lt;br /&gt;
Любые торговые марки, знаки и названия товаров, служб и организаций, права на дизайн, авторские и смежные права, которые упоминаются, используются или цитируются в статьях, принадлежат их законным владельцам. Их использование здесь не даёт вам право на любое другое использование, кроме предусмотренного авторами статей JEXP.RU в соответствии со схемой лицензирования GFDL. Если не указано иное, JEXP.RU никак не связан с правообладателями, и поэтому JEXP.RU не может распоряжаться правами на использование материалов, защищённых авторским правом. Вы несёте ответственность за использование этих и подобных материалов.&lt;br /&gt;
&lt;br /&gt;
Обратите внимание, что чтение, распространение или изменение информации, размещённой в JEXP.RU, может являться нарушением законов той страны, в которой вы просматриваете этот сайт. JEXP.RU не призывает к нарушению никаких законов. Законы вашей страны могут трактовать защиту свободы слова не так широко, как законы России — в этом случае JEXP.RU не несёт ответственности за любые потенциальные нарушения этих законов вами при создании ссылок на этот сайт или другом использовании любой содержащейся здесь информации.&lt;br /&gt;
&lt;br /&gt;
Несмотря на то, что пользователи могут исправлять ошибки или убирать ошибочные суждения, они не обязаны этого делать. Поэтому вся информация предоставляется без гарантии полезности для любой цели либо пригодности к какому-либо использованию.&lt;br /&gt;
&lt;br /&gt;
JEXP.RU не может нести ответственность за любой нанесённый ущерб, так как является добровольным сообществом, свободно организованным для создания открытых образовательных, культурных и информационных ресурсов. Информация предоставляется как акт доброй воли и не существует соглашения или акта о намерениях между вами и JEXP.RU относительно использования или изменения информации, не предусмотренного GNU Free Documentation License. Также никто в JEXP.RU не несёт ответственности за изменение, редактирование или удаление любой информации, добавленной вами в JEXP.RU или другие связанные с ней проекты.&lt;br /&gt;
&lt;br /&gt;
Спасибо, что потратили своё время на чтение этой страницы. Желаем вам получить только приятные впечатления от пользования JEXP.RU.&lt;/div&gt;</summary>
		<author><name>Admin</name></author>	</entry>

	<entry>
		<id>http://jexp.ru/index.php?title=Java_%D1%8D%D0%BA%D1%81%D0%BF%D0%B5%D1%80%D1%82:%D0%90%D0%B2%D1%82%D0%BE%D1%80%D1%81%D0%BA%D0%BE%D0%B5_%D0%BF%D1%80%D0%B0%D0%B2%D0%BE&amp;diff=9255</id>
		<title>Java эксперт:Авторское право</title>
		<link rel="alternate" type="text/html" href="http://jexp.ru/index.php?title=Java_%D1%8D%D0%BA%D1%81%D0%BF%D0%B5%D1%80%D1%82:%D0%90%D0%B2%D1%82%D0%BE%D1%80%D1%81%D0%BA%D0%BE%D0%B5_%D0%BF%D1%80%D0%B0%D0%B2%D0%BE&amp;diff=9255"/>
				<updated>2010-06-01T14:54:57Z</updated>
		
		<summary type="html">&lt;p&gt;Admin: Новая страница: «JEXP.RU, Интернет-энциклопедия с открытым содержимым, является добровольным сообществом лич…»&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;JEXP.RU, Интернет-энциклопедия с открытым содержимым, является добровольным сообществом личностей и групп, создающих общее хранилище человеческих знаний. Её строение позволяет любому, кто имеет доступ к Интернету и браузер, изменять её содержание. Поэтому, пожалуйста, примите во внимание, что приведённые здесь сведения могут быть не проверенными профессионалами, обладающими знаниями в соответствующих областях, необходимыми для предоставления вам полной, точной или заслуживающей доверия информации о любом понятии в JEXP.RU.&lt;br /&gt;
&lt;br /&gt;
Нельзя сказать, что в JEXP.RU не так уж много полезной и точной информации, однако вы должны сознавать, что JEXP.RU не может никаким способом гарантировать правильность приведённых в ней данных. Во время прочтения они могли быть только что изменены, испорчены, либо написаны тем, чьё мнение отличается от общепринятого в области знаний, интересующей вас.&lt;br /&gt;
&lt;br /&gt;
Мы ищем пути проверки и отбора вызывающих наибольшее доверие версий статей, но мы не можем ничего гарантировать. Наше наибольшее достижение — это избранные участниками статьи, но даже они могли быть испорчены или искажены кем-то за несколько мгновений до прочтения вами.&lt;br /&gt;
&lt;br /&gt;
Никто из авторов, участников, спонсоров, администраторов, операторов и лиц, как-либо ещё связанных с JEXP.RU, не несёт ответственность за появление неточной или ложной информации, а также за использование вами данных, содержащихся на этих веб-страницах либо найденных по ссылкам с них.&lt;br /&gt;
Пожалуйста, примите во внимание, что вся информация, находящаяся здесь, предоставлена свободно, как акт доброй воли, без заключения каких-либо договорённостей или договоров между вами и владельцами или пользователями данного сайта, владельцами серверов, на которых он размещён, авторами JEXP.RU, администраторами проекта, операторами либо кем-то ещё, любым образом связанными с этим или родственными ему проектами, которые [договора] могут стать предметом прямых претензий. Вам предоставляется ограниченное право копировать содержимое этого сайта — данное право не предусматривает и не подразумевает никакой договорной или иной ответственности за любую часть JEXP.RU или её агентов, участников, организаторов или других пользователей.&lt;br /&gt;
&lt;br /&gt;
Любые торговые марки, знаки и названия товаров, служб и организаций, права на дизайн, авторские и смежные права, которые упоминаются, используются или цитируются в статьях, принадлежат их законным владельцам. Их использование здесь не даёт вам право на любое другое использование, кроме предусмотренного авторами статей JEXP.RU в соответствии со схемой лицензирования GFDL. Если не указано иное, JEXP.RU никак не связан с правообладателями, и поэтому JEXP.RU не может распоряжаться правами на использование материалов, защищённых авторским правом. Вы несёте ответственность за использование этих и подобных материалов.&lt;br /&gt;
&lt;br /&gt;
Обратите внимание, что чтение, распространение или изменение информации, размещённой в JEXP.RU, может являться нарушением законов той страны, в которой вы просматриваете этот сайт. JEXP.RU не призывает к нарушению никаких законов. Законы вашей страны могут трактовать защиту свободы слова не так широко, как законы России — в этом случае JEXP.RU не несёт ответственности за любые потенциальные нарушения этих законов вами при создании ссылок на этот сайт или другом использовании любой содержащейся здесь информации.&lt;br /&gt;
&lt;br /&gt;
Несмотря на то, что пользователи могут исправлять ошибки или убирать ошибочные суждения, они не обязаны этого делать. Поэтому вся информация предоставляется без гарантии полезности для любой цели либо пригодности к какому-либо использованию.&lt;br /&gt;
&lt;br /&gt;
JEXP.RU не может нести ответственность за любой нанесённый ущерб, так как является добровольным сообществом, свободно организованным для создания открытых образовательных, культурных и информационных ресурсов. Информация предоставляется как акт доброй воли и не существует соглашения или акта о намерениях между вами и JEXP.RU относительно использования или изменения информации, не предусмотренного GNU Free Documentation License. Также никто в JEXP.RU не несёт ответственности за изменение, редактирование или удаление любой информации, добавленной вами в JEXP.RU или другие связанные с ней проекты.&lt;br /&gt;
&lt;br /&gt;
Спасибо, что потратили своё время на чтение этой страницы. Желаем вам получить только приятные впечатления от пользования JEXP.RU.&lt;/div&gt;</summary>
		<author><name>Admin</name></author>	</entry>

	<entry>
		<id>http://jexp.ru/index.php?title=Java/2D_Graphics_GUI/Font&amp;diff=9254</id>
		<title>Java/2D Graphics GUI/Font</title>
		<link rel="alternate" type="text/html" href="http://jexp.ru/index.php?title=Java/2D_Graphics_GUI/Font&amp;diff=9254"/>
				<updated>2010-06-01T14:33:40Z</updated>
		
		<summary type="html">&lt;p&gt;Admin: Новая страница: «== A cache of the dynamically loaded fonts found in the fonts directory ==     &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;     /*  * @(#)DemoFonts.java 1.17 06/08/29  *   * Copyright (c) 2…»&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== A cache of the dynamically loaded fonts found in the fonts directory ==&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;    &lt;br /&gt;
/*&lt;br /&gt;
 * @(#)DemoFonts.java 1.17 06/08/29&lt;br /&gt;
 * &lt;br /&gt;
 * Copyright (c) 2006 Sun Microsystems, Inc. All Rights Reserved.&lt;br /&gt;
 * &lt;br /&gt;
 * Redistribution and use in source and binary forms, with or without&lt;br /&gt;
 * modification, are permitted provided that the following conditions are met:&lt;br /&gt;
 * &lt;br /&gt;
 * -Redistribution of source code must retain the above copyright notice, this&lt;br /&gt;
 *  list of conditions and the following disclaimer.&lt;br /&gt;
 * &lt;br /&gt;
 * -Redistribution in binary form must reproduce the above copyright notice, &lt;br /&gt;
 *  this list of conditions and the following disclaimer in the documentation&lt;br /&gt;
 *  and/or other materials provided with the distribution.&lt;br /&gt;
 * &lt;br /&gt;
 * Neither the name of Sun Microsystems, Inc. or the names of contributors may &lt;br /&gt;
 * be used to endorse or promote products derived from this software without &lt;br /&gt;
 * specific prior written permission.&lt;br /&gt;
 * &lt;br /&gt;
 * This software is provided &amp;quot;AS IS,&amp;quot; without a warranty of any kind. ALL &lt;br /&gt;
 * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING&lt;br /&gt;
 * ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE&lt;br /&gt;
 * OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN MIDROSYSTEMS, INC. (&amp;quot;SUN&amp;quot;)&lt;br /&gt;
 * AND ITS LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE&lt;br /&gt;
 * AS A RESULT OF USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS&lt;br /&gt;
 * DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR ANY LOST &lt;br /&gt;
 * REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, &lt;br /&gt;
 * INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY &lt;br /&gt;
 * OF LIABILITY, ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, &lt;br /&gt;
 * EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.&lt;br /&gt;
 * &lt;br /&gt;
 * You acknowledge that this software is not designed, licensed or intended&lt;br /&gt;
 * for use in the design, construction, operation or maintenance of any&lt;br /&gt;
 * nuclear facility.&lt;br /&gt;
 */&lt;br /&gt;
/*&lt;br /&gt;
 * @(#)DemoFonts.java 1.17 06/08/29&lt;br /&gt;
 */&lt;br /&gt;
import java.awt.Font;&lt;br /&gt;
import java.io.InputStream;&lt;br /&gt;
import java.util.Map;&lt;br /&gt;
import java.util.concurrent.ConcurrentHashMap;&lt;br /&gt;
/**&lt;br /&gt;
 * A cache of the dynamically loaded fonts found in the fonts directory.&lt;br /&gt;
 */&lt;br /&gt;
public class DemoFonts {&lt;br /&gt;
  // Prepare a static &amp;quot;cache&amp;quot; mapping font names to Font objects.&lt;br /&gt;
  private static String[] names = { &amp;quot;A.ttf&amp;quot; };&lt;br /&gt;
  private static Map&amp;lt;String, Font&amp;gt; cache = new ConcurrentHashMap&amp;lt;String, Font&amp;gt;(names.length);&lt;br /&gt;
  static {&lt;br /&gt;
    for (String name : names) {&lt;br /&gt;
      cache.put(name, getFont(name));&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
  public static Font getFont(String name) {&lt;br /&gt;
    Font font = null;&lt;br /&gt;
    if (cache != null) {&lt;br /&gt;
      if ((font = cache.get(name)) != null) {&lt;br /&gt;
        return font;&lt;br /&gt;
      }&lt;br /&gt;
    }&lt;br /&gt;
    String fName = &amp;quot;/fonts/&amp;quot; + name;&lt;br /&gt;
    try {&lt;br /&gt;
      InputStream is = DemoFonts.class.getResourceAsStream(fName);&lt;br /&gt;
      font = Font.createFont(Font.TRUETYPE_FONT, is);&lt;br /&gt;
    } catch (Exception ex) {&lt;br /&gt;
      ex.printStackTrace();&lt;br /&gt;
      System.err.println(fName + &amp;quot; not loaded.  Using serif font.&amp;quot;);&lt;br /&gt;
      font = new Font(&amp;quot;serif&amp;quot;, Font.PLAIN, 24);&lt;br /&gt;
    }&lt;br /&gt;
    return font;&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
          &lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
  &amp;lt;/source&amp;gt;   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Create font from true type font ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;  &lt;br /&gt;
import java.awt.Font;&lt;br /&gt;
import java.io.File;&lt;br /&gt;
import java.io.FileInputStream;&lt;br /&gt;
import javax.swing.JFrame;&lt;br /&gt;
import javax.swing.JLabel;&lt;br /&gt;
public class Main {&lt;br /&gt;
  public static void main(String[] args) throws Exception {&lt;br /&gt;
    File f = new File(&amp;quot;your.ttf&amp;quot;);&lt;br /&gt;
    FileInputStream in = new FileInputStream(f);&lt;br /&gt;
    Font dynamicFont = Font.createFont(Font.TRUETYPE_FONT, in);&lt;br /&gt;
    Font dynamicFont32Pt = dynamicFont.deriveFont(32f);&lt;br /&gt;
    JLabel testLabel = new JLabel(dynamicFont.getName());&lt;br /&gt;
    testLabel.setFont(dynamicFont32Pt);&lt;br /&gt;
    JFrame frame = new JFrame(&amp;quot;Font Loading Demo&amp;quot;);&lt;br /&gt;
    frame.getContentPane().add(testLabel);&lt;br /&gt;
    frame.pack();&lt;br /&gt;
    frame.setVisible(true);&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
   &lt;br /&gt;
    &lt;br /&gt;
  &amp;lt;/source&amp;gt;   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Display font in a grid ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;  &lt;br /&gt;
import java.awt.Font;&lt;br /&gt;
import java.awt.Graphics;&lt;br /&gt;
import javax.swing.JFrame;&lt;br /&gt;
import javax.swing.JPanel;&lt;br /&gt;
public class Main {&lt;br /&gt;
  public static void main(String[] args) {&lt;br /&gt;
    final int columnCount = 10;&lt;br /&gt;
    final int side = 25;&lt;br /&gt;
    final int[][] grid = new int[50][columnCount];&lt;br /&gt;
    JPanel panel = new JPanel() {&lt;br /&gt;
      public void paintComponent(Graphics g) {&lt;br /&gt;
        Font font = new Font(&amp;quot;WingDings&amp;quot;, Font.PLAIN, 14);&lt;br /&gt;
        g.setFont(font);&lt;br /&gt;
        int off = 0;&lt;br /&gt;
        for (int i = 0; i &amp;lt; 256 * 256; i++) {&lt;br /&gt;
          if (font.canDisplay((char) i) == false) {&lt;br /&gt;
            continue;&lt;br /&gt;
          }&lt;br /&gt;
          off++;&lt;br /&gt;
          grid[off / columnCount][off % columnCount] = i;&lt;br /&gt;
          int x = off % columnCount * side;&lt;br /&gt;
          int y = (off / columnCount) * side + side;&lt;br /&gt;
          g.drawString(Character.toString((char)i), x, y);&lt;br /&gt;
        }&lt;br /&gt;
      }&lt;br /&gt;
    };&lt;br /&gt;
    JFrame frame = new JFrame();&lt;br /&gt;
    panel.setSize(300, 300);&lt;br /&gt;
    frame.getContentPane().add(panel);&lt;br /&gt;
    frame.setSize(300, 300);&lt;br /&gt;
    frame.setVisible(true);&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
   &lt;br /&gt;
    &lt;br /&gt;
  &amp;lt;/source&amp;gt;   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Draw font inside a Rectangle ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;    &lt;br /&gt;
import java.awt.Font;&lt;br /&gt;
import java.awt.FontMetrics;&lt;br /&gt;
import java.awt.Graphics;&lt;br /&gt;
import javax.swing.JFrame;&lt;br /&gt;
import javax.swing.JPanel;&lt;br /&gt;
public class StringRectPaintPanel extends JPanel {&lt;br /&gt;
  public void paint(Graphics g) {&lt;br /&gt;
    g.setFont(new Font(&amp;quot;&amp;quot;,0,100));&lt;br /&gt;
    FontMetrics fm = getFontMetrics(new Font(&amp;quot;&amp;quot;,0,100));&lt;br /&gt;
    String s = &amp;quot;jexp&amp;quot;;&lt;br /&gt;
    int x = 5;&lt;br /&gt;
    int y = 5;&lt;br /&gt;
    &lt;br /&gt;
    for (int i = 0; i &amp;lt; s.length(); i++) {&lt;br /&gt;
      char c = s.charAt(i);&lt;br /&gt;
      int h = fm.getHeight();&lt;br /&gt;
      int w = fm.charWidth(c);&lt;br /&gt;
      g.drawRect(x, y, w, h);&lt;br /&gt;
      g.drawString(String.valueOf(c), x, y + h);&lt;br /&gt;
      x = x + w;&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
  public static void main(String[] args) {&lt;br /&gt;
    JFrame frame = new JFrame();&lt;br /&gt;
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);&lt;br /&gt;
    frame.setContentPane(new StringRectPaintPanel());&lt;br /&gt;
    frame.setSize(500, 300);&lt;br /&gt;
    frame.setVisible(true);&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
           &lt;br /&gt;
         &lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
  &amp;lt;/source&amp;gt;   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Finds and displays available fonts ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;   &lt;br /&gt;
/*&lt;br /&gt;
 * Copyright (c) Ian F. Darwin, http://www.darwinsys.ru/, 1996-2002.&lt;br /&gt;
 * All rights reserved. Software written by Ian F. Darwin and others.&lt;br /&gt;
 * $Id: LICENSE,v 1.8 2004/02/09 03:33:38 ian Exp $&lt;br /&gt;
 *&lt;br /&gt;
 * Redistribution and use in source and binary forms, with or without&lt;br /&gt;
 * modification, are permitted provided that the following conditions&lt;br /&gt;
 * are met:&lt;br /&gt;
 * 1. Redistributions of source code must retain the above copyright&lt;br /&gt;
 *    notice, this list of conditions and the following disclaimer.&lt;br /&gt;
 * 2. Redistributions in binary form must reproduce the above copyright&lt;br /&gt;
 *    notice, this list of conditions and the following disclaimer in the&lt;br /&gt;
 *    documentation and/or other materials provided with the distribution.&lt;br /&gt;
 *&lt;br /&gt;
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS&amp;quot;&amp;quot;&lt;br /&gt;
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED&lt;br /&gt;
 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR&lt;br /&gt;
 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS&lt;br /&gt;
 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR&lt;br /&gt;
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF&lt;br /&gt;
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS&lt;br /&gt;
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN&lt;br /&gt;
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)&lt;br /&gt;
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE&lt;br /&gt;
 * POSSIBILITY OF SUCH DAMAGE.&lt;br /&gt;
 * &lt;br /&gt;
 * Java, the Duke mascot, and all variants of Sun&amp;quot;s Java &amp;quot;steaming coffee&lt;br /&gt;
 * cup&amp;quot; logo are trademarks of Sun Microsystems. Sun&amp;quot;s, and James Gosling&amp;quot;s,&lt;br /&gt;
 * pioneering role in inventing and promulgating (and standardizing) the Java &lt;br /&gt;
 * language and environment is gratefully acknowledged.&lt;br /&gt;
 * &lt;br /&gt;
 * The pioneering role of Dennis Ritchie and Bjarne Stroustrup, of AT&amp;amp;T, for&lt;br /&gt;
 * inventing predecessor languages C and C++ is also gratefully acknowledged.&lt;br /&gt;
 */&lt;br /&gt;
import java.awt.Dimension;&lt;br /&gt;
import java.awt.Font;&lt;br /&gt;
import java.awt.Graphics;&lt;br /&gt;
import java.awt.GraphicsEnvironment;&lt;br /&gt;
import java.awt.Toolkit;&lt;br /&gt;
import javax.swing.JComponent;&lt;br /&gt;
import javax.swing.JFrame;&lt;br /&gt;
import javax.swing.JScrollPane;&lt;br /&gt;
/**&lt;br /&gt;
 * Finds and displays available fonts&lt;br /&gt;
 * &amp;lt;p&amp;gt;&lt;br /&gt;
 * TODO: should be a JTable with the text name in one column and the demo in a&lt;br /&gt;
 * JLabel in the other.&lt;br /&gt;
 * &lt;br /&gt;
 * @author Ian Darwin (original)&lt;br /&gt;
 */&lt;br /&gt;
public class FontDemo extends JComponent {&lt;br /&gt;
  /** The list of Fonts */&lt;br /&gt;
  protected String[] fontNames;&lt;br /&gt;
  /** The fonts themselves */&lt;br /&gt;
  protected Font[] fonts;&lt;br /&gt;
  /** How much space between each name */&lt;br /&gt;
  static final int YINCR = 20;&lt;br /&gt;
  /**&lt;br /&gt;
   * Construct a FontDemo -- Sets title and gets array of fonts on the system&lt;br /&gt;
   */&lt;br /&gt;
  public FontDemo() {&lt;br /&gt;
    Toolkit toolkit = Toolkit.getDefaultToolkit();&lt;br /&gt;
    // For JDK 1.1: returns about 10 names (Serif, SansSerif, etc.)&lt;br /&gt;
    // fontNames = toolkit.getFontList();&lt;br /&gt;
    // For JDK 1.2: a much longer list; most of the names that come&lt;br /&gt;
    // with your OS (e.g., Arial, Lucida, Lucida Bright, Lucida Sans...)&lt;br /&gt;
    fontNames = GraphicsEnvironment.getLocalGraphicsEnvironment()&lt;br /&gt;
        .getAvailableFontFamilyNames();&lt;br /&gt;
    fonts = new Font[fontNames.length];&lt;br /&gt;
  }&lt;br /&gt;
  public Dimension getPreferredSize() {&lt;br /&gt;
    return new Dimension(500, fontNames.length * YINCR);&lt;br /&gt;
  }&lt;br /&gt;
  /**&lt;br /&gt;
   * Draws the font names in its font. Called by AWT when painting is needed&lt;br /&gt;
   * Does lazy evaluation of Font creation, caching the results (without this,&lt;br /&gt;
   * scrolling performance suffers even on a P3-750).&lt;br /&gt;
   */&lt;br /&gt;
  public void paint(Graphics g) {&lt;br /&gt;
    for (int i = 0; i &amp;lt; fontNames.length; i += 1) {&lt;br /&gt;
      if (fonts[i] == null) {&lt;br /&gt;
        fonts[i] = new Font(fontNames[i], Font.BOLD, 14);&lt;br /&gt;
      }&lt;br /&gt;
      g.setFont(fonts[i]);&lt;br /&gt;
      int x = 20;&lt;br /&gt;
      int y = 20 + (YINCR * i);&lt;br /&gt;
      g.drawString(fontNames[i], x, y);&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
  /** Simple main program to start it running */&lt;br /&gt;
  public static void main(String[] args) {&lt;br /&gt;
    JFrame f = new JFrame(&amp;quot;Font Demo&amp;quot;);&lt;br /&gt;
    f.getContentPane().add(new JScrollPane(new FontDemo()));&lt;br /&gt;
    f.setSize(600, 700);&lt;br /&gt;
    f.setVisible(true);&lt;br /&gt;
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
           &lt;br /&gt;
         &lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
  &amp;lt;/source&amp;gt;   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Font centered ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;   &lt;br /&gt;
import java.awt.Font;&lt;br /&gt;
import java.awt.Graphics;&lt;br /&gt;
import java.awt.Graphics2D;&lt;br /&gt;
import java.awt.RenderingHints;&lt;br /&gt;
import java.awt.font.FontRenderContext;&lt;br /&gt;
import java.awt.geom.Rectangle2D;&lt;br /&gt;
import javax.swing.JFrame;&lt;br /&gt;
import javax.swing.JPanel;&lt;br /&gt;
public class HorizontallyCenteredText extends JPanel {&lt;br /&gt;
  public void paint(Graphics g) {&lt;br /&gt;
    Graphics2D g2 = (Graphics2D) g;&lt;br /&gt;
    g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,&lt;br /&gt;
        RenderingHints.VALUE_ANTIALIAS_ON);&lt;br /&gt;
    g2.setFont(new Font(&amp;quot;Serif&amp;quot;, Font.PLAIN, 48));&lt;br /&gt;
    paintHorizontallyCenteredText(g2, &amp;quot;Java Source&amp;quot;, 200, 75);&lt;br /&gt;
    paintHorizontallyCenteredText(g2, &amp;quot;and&amp;quot;, 200, 125);&lt;br /&gt;
    paintHorizontallyCenteredText(g2, &amp;quot;Support&amp;quot;, 200, 175);&lt;br /&gt;
  }&lt;br /&gt;
  protected void paintHorizontallyCenteredText(Graphics2D g2, String s,&lt;br /&gt;
      float centerX, float baselineY) {&lt;br /&gt;
    FontRenderContext frc = g2.getFontRenderContext();&lt;br /&gt;
    Rectangle2D bounds = g2.getFont().getStringBounds(s, frc);&lt;br /&gt;
    float width = (float) bounds.getWidth();&lt;br /&gt;
    g2.drawString(s, centerX - width / 2, baselineY);&lt;br /&gt;
  }&lt;br /&gt;
  public static void main(String[] args) {&lt;br /&gt;
    JFrame f = new JFrame();&lt;br /&gt;
    f.getContentPane().add(new HorizontallyCenteredText());&lt;br /&gt;
    f.setSize(450, 350);&lt;br /&gt;
    f.show();&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
           &lt;br /&gt;
         &lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
  &amp;lt;/source&amp;gt;   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== FontDemo lists the system fonts and provides a sample of each one(Have some problems) ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;   &lt;br /&gt;
/*&lt;br /&gt;
 * Copyright (c) Ian F. Darwin, http://www.darwinsys.ru/, 1996-2002.&lt;br /&gt;
 * All rights reserved. Software written by Ian F. Darwin and others.&lt;br /&gt;
 * $Id: LICENSE,v 1.8 2004/02/09 03:33:38 ian Exp $&lt;br /&gt;
 *&lt;br /&gt;
 * Redistribution and use in source and binary forms, with or without&lt;br /&gt;
 * modification, are permitted provided that the following conditions&lt;br /&gt;
 * are met:&lt;br /&gt;
 * 1. Redistributions of source code must retain the above copyright&lt;br /&gt;
 *    notice, this list of conditions and the following disclaimer.&lt;br /&gt;
 * 2. Redistributions in binary form must reproduce the above copyright&lt;br /&gt;
 *    notice, this list of conditions and the following disclaimer in the&lt;br /&gt;
 *    documentation and/or other materials provided with the distribution.&lt;br /&gt;
 *&lt;br /&gt;
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS&amp;quot;&amp;quot;&lt;br /&gt;
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED&lt;br /&gt;
 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR&lt;br /&gt;
 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS&lt;br /&gt;
 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR&lt;br /&gt;
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF&lt;br /&gt;
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS&lt;br /&gt;
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN&lt;br /&gt;
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)&lt;br /&gt;
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE&lt;br /&gt;
 * POSSIBILITY OF SUCH DAMAGE.&lt;br /&gt;
 * &lt;br /&gt;
 * Java, the Duke mascot, and all variants of Sun&amp;quot;s Java &amp;quot;steaming coffee&lt;br /&gt;
 * cup&amp;quot; logo are trademarks of Sun Microsystems. Sun&amp;quot;s, and James Gosling&amp;quot;s,&lt;br /&gt;
 * pioneering role in inventing and promulgating (and standardizing) the Java &lt;br /&gt;
 * language and environment is gratefully acknowledged.&lt;br /&gt;
 * &lt;br /&gt;
 * The pioneering role of Dennis Ritchie and Bjarne Stroustrup, of AT&amp;amp;T, for&lt;br /&gt;
 * inventing predecessor languages C and C++ is also gratefully acknowledged.&lt;br /&gt;
 */&lt;br /&gt;
////&lt;br /&gt;
import java.awt.BorderLayout;&lt;br /&gt;
import java.awt.Container;&lt;br /&gt;
import java.awt.Font;&lt;br /&gt;
import java.awt.GraphicsEnvironment;&lt;br /&gt;
import java.awt.GridLayout;&lt;br /&gt;
import java.awt.Label;&lt;br /&gt;
import javax.swing.JFrame;&lt;br /&gt;
import javax.swing.JLabel;&lt;br /&gt;
import javax.swing.JPanel;&lt;br /&gt;
/** FontDemo lists the system fonts and provides a sample of each one */&lt;br /&gt;
public class FontDemoLabel extends JFrame {&lt;br /&gt;
  String fl[];&lt;br /&gt;
  JPanel p;&lt;br /&gt;
  public FontDemoLabel() {&lt;br /&gt;
    super(&amp;quot;Font Demo - Label&amp;quot;);&lt;br /&gt;
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);&lt;br /&gt;
    Container cp = getContentPane();&lt;br /&gt;
    // get font name list&lt;br /&gt;
    fl = GraphicsEnvironment.getLocalGraphicsEnvironment()&lt;br /&gt;
        .getAvailableFontFamilyNames();&lt;br /&gt;
    // IGNORE the setLayout and North/South stuff...&lt;br /&gt;
    // we will discuss it in a few pages!&lt;br /&gt;
    cp.setLayout(new BorderLayout());&lt;br /&gt;
    cp.add(BorderLayout.NORTH, new Label(&amp;quot;Number of Fonts = &amp;quot; + fl.length,&lt;br /&gt;
        Label.CENTER));&lt;br /&gt;
    cp.add(BorderLayout.CENTER, p = new JPanel());&lt;br /&gt;
    p.setLayout(new GridLayout(5, 0, 5, 5));&lt;br /&gt;
    for (int i = 0; i &amp;lt; fl.length; i++) {&lt;br /&gt;
      JLabel lab;&lt;br /&gt;
      // The crux of the matter: for each font name,&lt;br /&gt;
      // create a label using the name as the text,&lt;br /&gt;
      // AND set the font to be the named font!&lt;br /&gt;
      p.add(lab = new JLabel(fl[i]));&lt;br /&gt;
      lab.setFont(new Font(fl[i], Font.ITALIC | Font.BOLD, 14));&lt;br /&gt;
    }&lt;br /&gt;
    pack();&lt;br /&gt;
  }&lt;br /&gt;
  public static void main(String[] av) {&lt;br /&gt;
    new FontDemoLabel().setVisible(true);&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
           &lt;br /&gt;
         &lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
  &amp;lt;/source&amp;gt;   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Font Derivation ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;   &lt;br /&gt;
import java.awt.Font;&lt;br /&gt;
import java.awt.Graphics;&lt;br /&gt;
import java.awt.Graphics2D;&lt;br /&gt;
import java.awt.RenderingHints;&lt;br /&gt;
import java.awt.font.TextAttribute;&lt;br /&gt;
import java.awt.geom.AffineTransform;&lt;br /&gt;
import java.util.Hashtable;&lt;br /&gt;
import javax.swing.JFrame;&lt;br /&gt;
import javax.swing.JPanel;&lt;br /&gt;
public class FontDerivation extends JPanel {&lt;br /&gt;
  public void paint(Graphics g) {&lt;br /&gt;
    Graphics2D g2 = (Graphics2D) g;&lt;br /&gt;
    g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,&lt;br /&gt;
        RenderingHints.VALUE_ANTIALIAS_ON);&lt;br /&gt;
    // Create a 1-point font.&lt;br /&gt;
    Font font = new Font(&amp;quot;Serif&amp;quot;, Font.PLAIN, 1);&lt;br /&gt;
    float x = 20, y = 20;&lt;br /&gt;
    Font font24 = font.deriveFont(24.0f);&lt;br /&gt;
    g2.setFont(font24);&lt;br /&gt;
    g2.drawString(&amp;quot;font.deriveFont(24.0f)&amp;quot;, x, y += 30);&lt;br /&gt;
    Font font24italic = font24.deriveFont(Font.ITALIC);&lt;br /&gt;
    g2.setFont(font24italic);&lt;br /&gt;
    g2.drawString(&amp;quot;font24.deriveFont(Font.ITALIC)&amp;quot;, x, y += 30);&lt;br /&gt;
    AffineTransform at = new AffineTransform();&lt;br /&gt;
    at.shear(.2, 0);&lt;br /&gt;
    Font font24shear = font24.deriveFont(at);&lt;br /&gt;
    g2.setFont(font24shear);&lt;br /&gt;
    g2.drawString(&amp;quot;font24.deriveFont(at)&amp;quot;, x, y += 30);&lt;br /&gt;
    Hashtable attributes = new Hashtable();&lt;br /&gt;
    attributes.put(TextAttribute.WEIGHT, TextAttribute.WEIGHT_BOLD);&lt;br /&gt;
    Font font24bold = font24.deriveFont(attributes);&lt;br /&gt;
    g2.setFont(font24bold);&lt;br /&gt;
    g2.drawString(&amp;quot;font24.deriveFont(attributes)&amp;quot;, x, y += 30);&lt;br /&gt;
  }&lt;br /&gt;
  public static void main(String[] args) {&lt;br /&gt;
    JFrame f = new JFrame();&lt;br /&gt;
    f.getContentPane().add(new FontDerivation());&lt;br /&gt;
    f.setSize(350, 250);&lt;br /&gt;
    f.show();&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
           &lt;br /&gt;
         &lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
  &amp;lt;/source&amp;gt;   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Font List ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;   &lt;br /&gt;
/*&lt;br /&gt;
 * Copyright (c) 2000 David Flanagan.  All rights reserved.&lt;br /&gt;
 * This code is from the book Java Examples in a Nutshell, 2nd Edition.&lt;br /&gt;
 * It is provided AS-IS, WITHOUT ANY WARRANTY either expressed or implied.&lt;br /&gt;
 * You may study, use, and modify it for any non-commercial purpose.&lt;br /&gt;
 * You may distribute it non-commercially as long as you retain this notice.&lt;br /&gt;
 * For a commercial use license, or to purchase the book (recommended),&lt;br /&gt;
 * visit http://www.davidflanagan.ru/javaexamples2.&lt;br /&gt;
 */&lt;br /&gt;
import java.awt.Font;&lt;br /&gt;
import java.awt.Graphics;&lt;br /&gt;
import java.awt.event.WindowAdapter;&lt;br /&gt;
import java.awt.event.WindowEvent;&lt;br /&gt;
import javax.swing.JFrame;&lt;br /&gt;
import javax.swing.JPanel;&lt;br /&gt;
/**&lt;br /&gt;
 * An applet that displays the standard fonts and styles available in Java 1.1&lt;br /&gt;
 */&lt;br /&gt;
public class FontList extends JPanel {&lt;br /&gt;
  // The available font families&lt;br /&gt;
  String[] families = { &amp;quot;Serif&amp;quot;, // &amp;quot;TimesRoman&amp;quot; in Java 1.0&lt;br /&gt;
      &amp;quot;SansSerif&amp;quot;, // &amp;quot;Helvetica&amp;quot; in Java 1.0&lt;br /&gt;
      &amp;quot;Monospaced&amp;quot; }; // &amp;quot;Courier&amp;quot; in Java 1.0&lt;br /&gt;
  // The available font styles and names for each one&lt;br /&gt;
  int[] styles = { Font.PLAIN, Font.ITALIC, Font.BOLD,&lt;br /&gt;
      Font.ITALIC + Font.BOLD };&lt;br /&gt;
  String[] stylenames = { &amp;quot;Plain&amp;quot;, &amp;quot;Italic&amp;quot;, &amp;quot;Bold&amp;quot;, &amp;quot;Bold Italic&amp;quot; };&lt;br /&gt;
  // Draw the applet.&lt;br /&gt;
  public void paint(Graphics g) {&lt;br /&gt;
    for (int f = 0; f &amp;lt; families.length; f++) { // for each family&lt;br /&gt;
      for (int s = 0; s &amp;lt; styles.length; s++) { // for each style&lt;br /&gt;
        Font font = new Font(families[f], styles[s], 18); // create font&lt;br /&gt;
        g.setFont(font); // set font&lt;br /&gt;
        String name = families[f] + &amp;quot; &amp;quot; + stylenames[s]; // create name&lt;br /&gt;
        g.drawString(name, 20, (f * 4 + s + 1) * 20); // display name&lt;br /&gt;
      }&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
  public static void main(String[] a) {&lt;br /&gt;
    JFrame f = new JFrame();&lt;br /&gt;
    f.addWindowListener(new WindowAdapter() {&lt;br /&gt;
      public void windowClosing(WindowEvent e) {&lt;br /&gt;
        System.exit(0);&lt;br /&gt;
      }&lt;br /&gt;
    });&lt;br /&gt;
    f.setContentPane(new FontList());&lt;br /&gt;
    f.setSize(300,300);&lt;br /&gt;
    f.setVisible(true);&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
           &lt;br /&gt;
         &lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
  &amp;lt;/source&amp;gt;   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Font paint ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;   &lt;br /&gt;
import java.awt.Font;&lt;br /&gt;
import java.awt.Graphics;&lt;br /&gt;
import java.awt.Graphics2D;&lt;br /&gt;
import java.awt.RenderingHints;&lt;br /&gt;
import java.awt.font.FontRenderContext;&lt;br /&gt;
import java.awt.font.GlyphVector;&lt;br /&gt;
import javax.swing.JFrame;&lt;br /&gt;
import javax.swing.JPanel;&lt;br /&gt;
public class SimpleFont extends JPanel{&lt;br /&gt;
    public void paint(Graphics g) {&lt;br /&gt;
        Graphics2D g2 = (Graphics2D)g;&lt;br /&gt;
        g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,&lt;br /&gt;
            RenderingHints.VALUE_ANTIALIAS_ON);&lt;br /&gt;
        &lt;br /&gt;
        String s = &amp;quot;Java Source and Support&amp;quot;;&lt;br /&gt;
        Font font = new Font(&amp;quot;Serif&amp;quot;, Font.PLAIN, 24);&lt;br /&gt;
        FontRenderContext frc = g2.getFontRenderContext();&lt;br /&gt;
        GlyphVector gv = font.createGlyphVector(frc, s);&lt;br /&gt;
        g2.drawGlyphVector(gv, 40, 60);&lt;br /&gt;
      }&lt;br /&gt;
  public static void main(String[] args) {&lt;br /&gt;
    JFrame f = new JFrame();&lt;br /&gt;
    f.getContentPane().add(new SimpleFont());&lt;br /&gt;
    f.setSize(350, 250);&lt;br /&gt;
    f.show();&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
           &lt;br /&gt;
         &lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
  &amp;lt;/source&amp;gt;   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Load font from ttf file ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;    &lt;br /&gt;
/*&lt;br /&gt;
 * @(#)DemoFonts.java 1.17 06/08/29&lt;br /&gt;
 * &lt;br /&gt;
 * Copyright (c) 2006 Sun Microsystems, Inc. All Rights Reserved.&lt;br /&gt;
 * &lt;br /&gt;
 * Redistribution and use in source and binary forms, with or without&lt;br /&gt;
 * modification, are permitted provided that the following conditions are met:&lt;br /&gt;
 * &lt;br /&gt;
 * -Redistribution of source code must retain the above copyright notice, this&lt;br /&gt;
 *  list of conditions and the following disclaimer.&lt;br /&gt;
 * &lt;br /&gt;
 * -Redistribution in binary form must reproduce the above copyright notice, &lt;br /&gt;
 *  this list of conditions and the following disclaimer in the documentation&lt;br /&gt;
 *  and/or other materials provided with the distribution.&lt;br /&gt;
 * &lt;br /&gt;
 * Neither the name of Sun Microsystems, Inc. or the names of contributors may &lt;br /&gt;
 * be used to endorse or promote products derived from this software without &lt;br /&gt;
 * specific prior written permission.&lt;br /&gt;
 * &lt;br /&gt;
 * This software is provided &amp;quot;AS IS,&amp;quot; without a warranty of any kind. ALL &lt;br /&gt;
 * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING&lt;br /&gt;
 * ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE&lt;br /&gt;
 * OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN MIDROSYSTEMS, INC. (&amp;quot;SUN&amp;quot;)&lt;br /&gt;
 * AND ITS LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE&lt;br /&gt;
 * AS A RESULT OF USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS&lt;br /&gt;
 * DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR ANY LOST &lt;br /&gt;
 * REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, &lt;br /&gt;
 * INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY &lt;br /&gt;
 * OF LIABILITY, ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, &lt;br /&gt;
 * EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.&lt;br /&gt;
 * &lt;br /&gt;
 * You acknowledge that this software is not designed, licensed or intended&lt;br /&gt;
 * for use in the design, construction, operation or maintenance of any&lt;br /&gt;
 * nuclear facility.&lt;br /&gt;
 */&lt;br /&gt;
/*&lt;br /&gt;
 * @(#)DemoFonts.java 1.17 06/08/29&lt;br /&gt;
 */&lt;br /&gt;
import java.awt.Font;&lt;br /&gt;
import java.io.InputStream;&lt;br /&gt;
import java.util.Map;&lt;br /&gt;
import java.util.concurrent.ConcurrentHashMap;&lt;br /&gt;
/**&lt;br /&gt;
 * A cache of the dynamically loaded fonts found in the fonts directory.&lt;br /&gt;
 */&lt;br /&gt;
public class DemoFonts {&lt;br /&gt;
  // Prepare a static &amp;quot;cache&amp;quot; mapping font names to Font objects.&lt;br /&gt;
  private static String[] names = { &amp;quot;A.ttf&amp;quot; };&lt;br /&gt;
  private static Map&amp;lt;String, Font&amp;gt; cache = new ConcurrentHashMap&amp;lt;String, Font&amp;gt;(names.length);&lt;br /&gt;
  static {&lt;br /&gt;
    for (String name : names) {&lt;br /&gt;
      cache.put(name, getFont(name));&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
  public static Font getFont(String name) {&lt;br /&gt;
    Font font = null;&lt;br /&gt;
    if (cache != null) {&lt;br /&gt;
      if ((font = cache.get(name)) != null) {&lt;br /&gt;
        return font;&lt;br /&gt;
      }&lt;br /&gt;
    }&lt;br /&gt;
    String fName = &amp;quot;/fonts/&amp;quot; + name;&lt;br /&gt;
    try {&lt;br /&gt;
      InputStream is = DemoFonts.class.getResourceAsStream(fName);&lt;br /&gt;
      font = Font.createFont(Font.TRUETYPE_FONT, is);&lt;br /&gt;
    } catch (Exception ex) {&lt;br /&gt;
      ex.printStackTrace();&lt;br /&gt;
      System.err.println(fName + &amp;quot; not loaded.  Using serif font.&amp;quot;);&lt;br /&gt;
      font = new Font(&amp;quot;serif&amp;quot;, Font.PLAIN, 24);&lt;br /&gt;
    }&lt;br /&gt;
    return font;&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
          &lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
  &amp;lt;/source&amp;gt;   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Obtain FontMetrics of different fonts ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;   &lt;br /&gt;
import java.awt.Font;&lt;br /&gt;
import java.awt.FontMetrics;&lt;br /&gt;
import java.awt.Graphics;&lt;br /&gt;
import java.awt.event.WindowAdapter;&lt;br /&gt;
import java.awt.event.WindowEvent;&lt;br /&gt;
import javax.swing.JFrame;&lt;br /&gt;
public class Main extends JFrame {&lt;br /&gt;
  public Main() {&lt;br /&gt;
    super(&amp;quot;Demonstrating FontMetrics&amp;quot;);&lt;br /&gt;
    setSize(510, 210);&lt;br /&gt;
    setVisible(true);&lt;br /&gt;
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);&lt;br /&gt;
  }&lt;br /&gt;
  public void paint(Graphics g) {&lt;br /&gt;
    g.setFont(new Font(&amp;quot;SansSerif&amp;quot;, Font.BOLD, 12));&lt;br /&gt;
    FontMetrics fm = g.getFontMetrics();&lt;br /&gt;
    g.drawString(&amp;quot;Current font: &amp;quot; + g.getFont(), 10, 40);&lt;br /&gt;
    g.drawString(&amp;quot;Ascent: &amp;quot; + fm.getAscent(), 10, 55);&lt;br /&gt;
    g.drawString(&amp;quot;Descent: &amp;quot; + fm.getDescent(), 10, 70);&lt;br /&gt;
    g.drawString(&amp;quot;Height: &amp;quot; + fm.getHeight(), 10, 85);&lt;br /&gt;
    g.drawString(&amp;quot;Leading: &amp;quot; + fm.getLeading(), 10, 100);&lt;br /&gt;
    Font font = new Font(&amp;quot;Serif&amp;quot;, Font.ITALIC, 14);&lt;br /&gt;
    fm = g.getFontMetrics(font);&lt;br /&gt;
    g.setFont(font);&lt;br /&gt;
    g.drawString(&amp;quot;Current font: &amp;quot; + font, 10, 130);&lt;br /&gt;
    g.drawString(&amp;quot;Ascent: &amp;quot; + fm.getAscent(), 10, 145);&lt;br /&gt;
    g.drawString(&amp;quot;Descent: &amp;quot; + fm.getDescent(), 10, 160);&lt;br /&gt;
    g.drawString(&amp;quot;Height: &amp;quot; + fm.getHeight(), 10, 175);&lt;br /&gt;
    g.drawString(&amp;quot;Leading: &amp;quot; + fm.getLeading(), 10, 190);&lt;br /&gt;
  }&lt;br /&gt;
  public static void main(String args[]) {&lt;br /&gt;
    Main app = new Main();&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
   &lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
  &amp;lt;/source&amp;gt;   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Outline Font paint ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;   &lt;br /&gt;
import java.awt.BorderLayout;&lt;br /&gt;
import java.awt.Color;&lt;br /&gt;
import java.awt.Dimension;&lt;br /&gt;
import java.awt.Font;&lt;br /&gt;
import java.awt.Graphics;&lt;br /&gt;
import java.awt.Graphics2D;&lt;br /&gt;
import java.awt.Rectangle;&lt;br /&gt;
import java.awt.RenderingHints;&lt;br /&gt;
import java.awt.Shape;&lt;br /&gt;
import java.awt.event.WindowAdapter;&lt;br /&gt;
import java.awt.event.WindowEvent;&lt;br /&gt;
import java.awt.font.FontRenderContext;&lt;br /&gt;
import java.awt.font.TextLayout;&lt;br /&gt;
import java.awt.geom.AffineTransform;&lt;br /&gt;
import java.net.URL;&lt;br /&gt;
import javax.swing.JApplet;&lt;br /&gt;
import javax.swing.JFrame;&lt;br /&gt;
import javax.swing.JPanel;&lt;br /&gt;
public class FontPaint extends JApplet {&lt;br /&gt;
  public void init() {&lt;br /&gt;
    FontPanel fontPanel = new FontPanel();&lt;br /&gt;
    getContentPane().add(fontPanel, BorderLayout.CENTER);&lt;br /&gt;
  }&lt;br /&gt;
  public static void main(String[] args) {&lt;br /&gt;
    FontPanel starPanel = new FontPanel();&lt;br /&gt;
    JFrame f = new JFrame(&amp;quot;Font&amp;quot;);&lt;br /&gt;
    f.addWindowListener(new WindowAdapter() {&lt;br /&gt;
      public void windowClosing(WindowEvent e) {&lt;br /&gt;
        System.exit(0);&lt;br /&gt;
      }&lt;br /&gt;
    });&lt;br /&gt;
    f.getContentPane().add(starPanel, BorderLayout.CENTER);&lt;br /&gt;
    f.setSize(new Dimension(550, 200));&lt;br /&gt;
    f.setVisible(true);&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
class FontPanel extends JPanel {&lt;br /&gt;
  public void paintComponent(Graphics g) {&lt;br /&gt;
    super.paintComponent(g);&lt;br /&gt;
    setBackground(Color.white);&lt;br /&gt;
    int width = getSize().width;&lt;br /&gt;
    int height = getSize().height;&lt;br /&gt;
    Graphics2D g2 = (Graphics2D) g;&lt;br /&gt;
    g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,&lt;br /&gt;
        RenderingHints.VALUE_ANTIALIAS_ON);&lt;br /&gt;
    g2.setRenderingHint(RenderingHints.KEY_RENDERING,&lt;br /&gt;
        RenderingHints.VALUE_RENDER_QUALITY);&lt;br /&gt;
    FontRenderContext frc = g2.getFontRenderContext();&lt;br /&gt;
    Font f = new Font(&amp;quot;Helvetica&amp;quot;, 1, 60);&lt;br /&gt;
    String s = new String(&amp;quot;Java Source and Support.&amp;quot;);&lt;br /&gt;
    TextLayout textTl = new TextLayout(s, f, frc);&lt;br /&gt;
    AffineTransform transform = new AffineTransform();&lt;br /&gt;
    Shape outline = textTl.getOutline(null);&lt;br /&gt;
    Rectangle outlineBounds = outline.getBounds();&lt;br /&gt;
    transform = g2.getTransform();&lt;br /&gt;
    transform.translate(width / 2 - (outlineBounds.width / 2), height / 2&lt;br /&gt;
        + (outlineBounds.height / 2));&lt;br /&gt;
    g2.transform(transform);&lt;br /&gt;
    g2.setColor(Color.blue);&lt;br /&gt;
    g2.draw(outline);&lt;br /&gt;
    g2.setClip(outline);&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
           &lt;br /&gt;
         &lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
  &amp;lt;/source&amp;gt;   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Wrap string according to FontMetrics ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;   &lt;br /&gt;
import java.awt.FontMetrics;&lt;br /&gt;
import java.util.ArrayList;&lt;br /&gt;
import java.util.Collection;&lt;br /&gt;
import java.util.Iterator;&lt;br /&gt;
import java.util.List;&lt;br /&gt;
/**&lt;br /&gt;
 * Globally available utility classes, mostly for string manipulation.&lt;br /&gt;
 * &lt;br /&gt;
 * @author Jim Menard, &lt;br /&gt;
 */&lt;br /&gt;
public class StringUtils {&lt;br /&gt;
  /**&lt;br /&gt;
   * Returns an array of strings, one for each line in the string after it has&lt;br /&gt;
   * been wrapped to fit lines of &amp;lt;var&amp;gt;maxWidth&amp;lt;/var&amp;gt;. Lines end with any of&lt;br /&gt;
   * cr, lf, or cr lf. A line ending at the end of the string will not output a&lt;br /&gt;
   * further, empty string.&lt;br /&gt;
   * &amp;lt;p&amp;gt;&lt;br /&gt;
   * This code assumes &amp;lt;var&amp;gt;str&amp;lt;/var&amp;gt; is not &amp;lt;code&amp;gt;null&amp;lt;/code&amp;gt;.&lt;br /&gt;
   * &lt;br /&gt;
   * @param str&lt;br /&gt;
   *          the string to split&lt;br /&gt;
   * @param fm&lt;br /&gt;
   *          needed for string width calculations&lt;br /&gt;
   * @param maxWidth&lt;br /&gt;
   *          the max line width, in points&lt;br /&gt;
   * @return a non-empty list of strings&lt;br /&gt;
   */&lt;br /&gt;
  public static List wrap(String str, FontMetrics fm, int maxWidth) {&lt;br /&gt;
    List lines = splitIntoLines(str);&lt;br /&gt;
    if (lines.size() == 0)&lt;br /&gt;
      return lines;&lt;br /&gt;
    ArrayList strings = new ArrayList();&lt;br /&gt;
    for (Iterator iter = lines.iterator(); iter.hasNext();)&lt;br /&gt;
      wrapLineInto((String) iter.next(), strings, fm, maxWidth);&lt;br /&gt;
    return strings;&lt;br /&gt;
  }&lt;br /&gt;
  /**&lt;br /&gt;
   * Given a line of text and font metrics information, wrap the line and add&lt;br /&gt;
   * the new line(s) to &amp;lt;var&amp;gt;list&amp;lt;/var&amp;gt;.&lt;br /&gt;
   * &lt;br /&gt;
   * @param line&lt;br /&gt;
   *          a line of text&lt;br /&gt;
   * @param list&lt;br /&gt;
   *          an output list of strings&lt;br /&gt;
   * @param fm&lt;br /&gt;
   *          font metrics&lt;br /&gt;
   * @param maxWidth&lt;br /&gt;
   *          maximum width of the line(s)&lt;br /&gt;
   */&lt;br /&gt;
  public static void wrapLineInto(String line, List list, FontMetrics fm, int maxWidth) {&lt;br /&gt;
    int len = line.length();&lt;br /&gt;
    int width;&lt;br /&gt;
    while (len &amp;gt; 0 &amp;amp;&amp;amp; (width = fm.stringWidth(line)) &amp;gt; maxWidth) {&lt;br /&gt;
      // Guess where to split the line. Look for the next space before&lt;br /&gt;
      // or after the guess.&lt;br /&gt;
      int guess = len * maxWidth / width;&lt;br /&gt;
      String before = line.substring(0, guess).trim();&lt;br /&gt;
      width = fm.stringWidth(before);&lt;br /&gt;
      int pos;&lt;br /&gt;
      if (width &amp;gt; maxWidth) // Too long&lt;br /&gt;
        pos = findBreakBefore(line, guess);&lt;br /&gt;
      else { // Too short or possibly just right&lt;br /&gt;
        pos = findBreakAfter(line, guess);&lt;br /&gt;
        if (pos != -1) { // Make sure this doesn&amp;quot;t make us too long&lt;br /&gt;
          before = line.substring(0, pos).trim();&lt;br /&gt;
          if (fm.stringWidth(before) &amp;gt; maxWidth)&lt;br /&gt;
            pos = findBreakBefore(line, guess);&lt;br /&gt;
        }&lt;br /&gt;
      }&lt;br /&gt;
      if (pos == -1)&lt;br /&gt;
        pos = guess; // Split in the middle of the word&lt;br /&gt;
      list.add(line.substring(0, pos).trim());&lt;br /&gt;
      line = line.substring(pos).trim();&lt;br /&gt;
      len = line.length();&lt;br /&gt;
    }&lt;br /&gt;
    if (len &amp;gt; 0)&lt;br /&gt;
      list.add(line);&lt;br /&gt;
  }&lt;br /&gt;
  /**&lt;br /&gt;
   * Returns the index of the first whitespace character or &amp;quot;-&amp;quot; in &amp;lt;var&amp;gt;line&amp;lt;/var&amp;gt;&lt;br /&gt;
   * that is at or before &amp;lt;var&amp;gt;start&amp;lt;/var&amp;gt;. Returns -1 if no such character is&lt;br /&gt;
   * found.&lt;br /&gt;
   * &lt;br /&gt;
   * @param line&lt;br /&gt;
   *          a string&lt;br /&gt;
   * @param start&lt;br /&gt;
   *          where to star looking&lt;br /&gt;
   */&lt;br /&gt;
  public static int findBreakBefore(String line, int start) {&lt;br /&gt;
    for (int i = start; i &amp;gt;= 0; --i) {&lt;br /&gt;
      char c = line.charAt(i);&lt;br /&gt;
      if (Character.isWhitespace(c) || c == &amp;quot;-&amp;quot;)&lt;br /&gt;
        return i;&lt;br /&gt;
    }&lt;br /&gt;
    return -1;&lt;br /&gt;
  }&lt;br /&gt;
  /**&lt;br /&gt;
   * Returns the index of the first whitespace character or &amp;quot;-&amp;quot; in &amp;lt;var&amp;gt;line&amp;lt;/var&amp;gt;&lt;br /&gt;
   * that is at or after &amp;lt;var&amp;gt;start&amp;lt;/var&amp;gt;. Returns -1 if no such character is&lt;br /&gt;
   * found.&lt;br /&gt;
   * &lt;br /&gt;
   * @param line&lt;br /&gt;
   *          a string&lt;br /&gt;
   * @param start&lt;br /&gt;
   *          where to star looking&lt;br /&gt;
   */&lt;br /&gt;
  public static int findBreakAfter(String line, int start) {&lt;br /&gt;
    int len = line.length();&lt;br /&gt;
    for (int i = start; i &amp;lt; len; ++i) {&lt;br /&gt;
      char c = line.charAt(i);&lt;br /&gt;
      if (Character.isWhitespace(c) || c == &amp;quot;-&amp;quot;)&lt;br /&gt;
        return i;&lt;br /&gt;
    }&lt;br /&gt;
    return -1;&lt;br /&gt;
  }&lt;br /&gt;
  /**&lt;br /&gt;
   * Returns an array of strings, one for each line in the string. Lines end&lt;br /&gt;
   * with any of cr, lf, or cr lf. A line ending at the end of the string will&lt;br /&gt;
   * not output a further, empty string.&lt;br /&gt;
   * &amp;lt;p&amp;gt;&lt;br /&gt;
   * This code assumes &amp;lt;var&amp;gt;str&amp;lt;/var&amp;gt; is not &amp;lt;code&amp;gt;null&amp;lt;/code&amp;gt;.&lt;br /&gt;
   * &lt;br /&gt;
   * @param str&lt;br /&gt;
   *          the string to split&lt;br /&gt;
   * @return a non-empty list of strings&lt;br /&gt;
   */&lt;br /&gt;
  public static List splitIntoLines(String str) {&lt;br /&gt;
    ArrayList strings = new ArrayList();&lt;br /&gt;
    int len = str.length();&lt;br /&gt;
    if (len == 0) {&lt;br /&gt;
      strings.add(&amp;quot;&amp;quot;);&lt;br /&gt;
      return strings;&lt;br /&gt;
    }&lt;br /&gt;
    int lineStart = 0;&lt;br /&gt;
    for (int i = 0; i &amp;lt; len; ++i) {&lt;br /&gt;
      char c = str.charAt(i);&lt;br /&gt;
      if (c == &amp;quot;\r&amp;quot;) {&lt;br /&gt;
        int newlineLength = 1;&lt;br /&gt;
        if ((i + 1) &amp;lt; len &amp;amp;&amp;amp; str.charAt(i + 1) == &amp;quot;\n&amp;quot;)&lt;br /&gt;
          newlineLength = 2;&lt;br /&gt;
        strings.add(str.substring(lineStart, i));&lt;br /&gt;
        lineStart = i + newlineLength;&lt;br /&gt;
        if (newlineLength == 2) // skip \n next time through loop&lt;br /&gt;
          ++i;&lt;br /&gt;
      } else if (c == &amp;quot;\n&amp;quot;) {&lt;br /&gt;
        strings.add(str.substring(lineStart, i));&lt;br /&gt;
        lineStart = i + 1;&lt;br /&gt;
      }&lt;br /&gt;
    }&lt;br /&gt;
    if (lineStart &amp;lt; len)&lt;br /&gt;
      strings.add(str.substring(lineStart));&lt;br /&gt;
    return strings;&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
   &lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Admin</name></author>	</entry>

	<entry>
		<id>http://jexp.ru/index.php?title=Java/2D_Graphics_GUI&amp;diff=9253</id>
		<title>Java/2D Graphics GUI</title>
		<link rel="alternate" type="text/html" href="http://jexp.ru/index.php?title=Java/2D_Graphics_GUI&amp;diff=9253"/>
				<updated>2010-06-01T14:32:33Z</updated>
		
		<summary type="html">&lt;p&gt;Admin: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;* [[Java/2D Graphics GUI/Animation | Animation]]&lt;br /&gt;
* [[Java/2D Graphics GUI/AntiAliasing | AntiAliasing]]&lt;br /&gt;
* [[Java/2D Graphics GUI/Arc | Arc]]&lt;br /&gt;
* [[Java/2D Graphics GUI/Area Calculation | Area Calculation]]&lt;br /&gt;
* [[Java/2D Graphics GUI/BMP | BMP]]&lt;br /&gt;
* [[Java/2D Graphics GUI/Buffer Paint | Buffer Paint]]&lt;br /&gt;
* [[Java/2D Graphics GUI/BufferedImage | BufferedImage]]&lt;br /&gt;
* [[Java/2D Graphics GUI/Chart | Chart]]&lt;br /&gt;
* [[Java/2D Graphics GUI/Clip | Clip]]&lt;br /&gt;
* [[Java/2D Graphics GUI/Color | Color]]&lt;br /&gt;
* [[Java/2D Graphics GUI/Color Model | Color Model]]&lt;br /&gt;
* [[Java/2D Graphics GUI/Composite | Composite]]&lt;br /&gt;
* [[Java/2D Graphics GUI/Curve | Curve]]&lt;br /&gt;
* [[Java/2D Graphics GUI/FilteredImageSource | FilteredImageSource]]&lt;br /&gt;
* [[Java/2D Graphics GUI/Font | Font]]&lt;br /&gt;
* [[Java/2D Graphics GUI/Full Screen | Full Screen]]&lt;br /&gt;
* [[Java/2D Graphics GUI/GIF | GIF]]&lt;br /&gt;
* [[Java/2D Graphics GUI/Geometry | Geometry]]&lt;br /&gt;
* [[Java/2D Graphics GUI/Gradient Paint | Gradient Paint]]&lt;br /&gt;
* [[Java/2D Graphics GUI/Graphic Environment | Graphic Environment]]&lt;br /&gt;
* [[Java/2D Graphics GUI/Icon | Icon]]&lt;br /&gt;
* [[Java/2D Graphics GUI/Image | Image]]&lt;br /&gt;
* [[Java/2D Graphics GUI/Image Filter | Image Filter]]&lt;br /&gt;
* [[Java/2D Graphics GUI/Image IO | Image IO]]&lt;br /&gt;
* [[Java/2D Graphics GUI/ImageReader | ImageReader]]&lt;br /&gt;
* [[Java/2D Graphics GUI/ImageWriter | ImageWriter]]&lt;br /&gt;
* [[Java/2D Graphics GUI/JAI | JAI]]&lt;br /&gt;
* [[Java/2D Graphics GUI/JMF | JMF]]&lt;br /&gt;
* [[Java/2D Graphics GUI/JPEG | JPEG]]&lt;br /&gt;
* [[Java/2D Graphics GUI/Line | Line]]&lt;br /&gt;
* [[Java/2D Graphics GUI/Matrix | Matrix]]&lt;br /&gt;
* [[Java/2D Graphics GUI/Media | Media]]&lt;br /&gt;
* [[Java/2D Graphics GUI/MemoryImageSource | MemoryImageSource]]&lt;br /&gt;
* [[Java/2D Graphics GUI/PDF PostScript | PDF PostScript]]&lt;br /&gt;
* [[Java/2D Graphics GUI/PNG File | PNG File]]&lt;br /&gt;
* [[Java/2D Graphics GUI/Paint | Paint]]&lt;br /&gt;
* [[Java/2D Graphics GUI/Path | Path]]&lt;br /&gt;
* [[Java/2D Graphics GUI/Print | Print]]&lt;br /&gt;
* [[Java/2D Graphics GUI/Print Job | Print Job]]&lt;br /&gt;
* [[Java/2D Graphics GUI/Print Service | Print Service]]&lt;br /&gt;
* [[Java/2D Graphics GUI/Psd | Psd]]&lt;br /&gt;
* [[Java/2D Graphics GUI/RGBImageFilter | RGBImageFilter]]&lt;br /&gt;
* [[Java/2D Graphics GUI/Screen Capture | Screen Capture]]&lt;br /&gt;
* [[Java/2D Graphics GUI/Shape | Shape]]&lt;br /&gt;
* [[Java/2D Graphics GUI/Stroke | Stroke]]&lt;br /&gt;
* [[Java/2D Graphics GUI/Text | Text]]&lt;br /&gt;
* [[Java/2D Graphics GUI/Text Layout | Text Layout]]&lt;br /&gt;
* [[Java/2D Graphics GUI/TextAttribute | TextAttribute]]&lt;br /&gt;
* [[Java/2D Graphics GUI/Texture | Texture]]&lt;br /&gt;
* [[Java/2D Graphics GUI/Transform | Transform]]&lt;br /&gt;
* [[Java/2D Graphics GUI/Transparent | Transparent]]&lt;br /&gt;
* [[Java/2D Graphics GUI/XOR | XOR]]&lt;/div&gt;</summary>
		<author><name>Admin</name></author>	</entry>

	<entry>
		<id>http://jexp.ru/index.php?title=MediaWiki:Sidebar&amp;diff=9252</id>
		<title>MediaWiki:Sidebar</title>
		<link rel="alternate" type="text/html" href="http://jexp.ru/index.php?title=MediaWiki:Sidebar&amp;diff=9252"/>
				<updated>2010-06-01T10:35:42Z</updated>
		
		<summary type="html">&lt;p&gt;Admin: Новая страница: «* Разделы ** Java | Java ** Java by API | Java API ** Java_Tutorial | Учебник по Java  * navigation ** mainpage|mainpage-description ** portal-url|po…»&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;* Разделы&lt;br /&gt;
** Java | Java&lt;br /&gt;
** Java by API | Java API&lt;br /&gt;
** Java_Tutorial | Учебник по Java&lt;br /&gt;
&lt;br /&gt;
* navigation&lt;br /&gt;
** mainpage|mainpage-description&lt;br /&gt;
** portal-url|portal&lt;br /&gt;
** currentevents-url|currentevents&lt;br /&gt;
** recentchanges-url|recentchanges&lt;br /&gt;
** randompage-url|randompage&lt;br /&gt;
** helppage|help&lt;br /&gt;
* TOOLBOX&lt;br /&gt;
* SEARCH&lt;br /&gt;
* LANGUAGES&lt;/div&gt;</summary>
		<author><name>Admin</name></author>	</entry>

	<entry>
		<id>http://jexp.ru/index.php?title=Java/Swing_Components/Font_Chooser&amp;diff=9251</id>
		<title>Java/Swing Components/Font Chooser</title>
		<link rel="alternate" type="text/html" href="http://jexp.ru/index.php?title=Java/Swing_Components/Font_Chooser&amp;diff=9251"/>
				<updated>2010-06-01T07:45:39Z</updated>
		
		<summary type="html">&lt;p&gt;Admin: Новая страница: «== A dialog allow selection and a font and its associated info. ==       &amp;lt;!-- start source code --&amp;gt;         &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;     /*  * Copyright (C) 2001-2004 Co…»&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== A dialog allow selection and a font and its associated info. ==&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
/*&lt;br /&gt;
 * Copyright (C) 2001-2004 Colin Bell&lt;br /&gt;
 * colbell@users.sourceforge.net&lt;br /&gt;
 *&lt;br /&gt;
 * This library is free software; you can redistribute it and/or&lt;br /&gt;
 * modify it under the terms of the GNU Lesser General Public&lt;br /&gt;
 * License as published by the Free Software Foundation; either&lt;br /&gt;
 * version 2.1 of the License, or (at your option) any later version.&lt;br /&gt;
 *&lt;br /&gt;
 * This library is distributed in the hope that it will be useful,&lt;br /&gt;
 * but WITHOUT ANY WARRANTY; without even the implied warranty of&lt;br /&gt;
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU&lt;br /&gt;
 * Lesser General Public License for more details.&lt;br /&gt;
 *&lt;br /&gt;
 * You should have received a copy of the GNU Lesser General Public&lt;br /&gt;
 * License along with this library; if not, write to the Free Software&lt;br /&gt;
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA&lt;br /&gt;
 */&lt;br /&gt;
import java.awt.BorderLayout;&lt;br /&gt;
import java.awt.Dialog;&lt;br /&gt;
import java.awt.Dimension;&lt;br /&gt;
import java.awt.Font;&lt;br /&gt;
import java.awt.Frame;&lt;br /&gt;
import java.awt.GraphicsEnvironment;&lt;br /&gt;
import java.awt.GridBagConstraints;&lt;br /&gt;
import java.awt.GridBagLayout;&lt;br /&gt;
import java.awt.Insets;&lt;br /&gt;
import java.awt.event.ActionEvent;&lt;br /&gt;
import java.awt.event.ActionListener;&lt;br /&gt;
import java.io.Serializable;&lt;br /&gt;
import javax.swing.BorderFactory;&lt;br /&gt;
import javax.swing.JButton;&lt;br /&gt;
import javax.swing.JCheckBox;&lt;br /&gt;
import javax.swing.JComboBox;&lt;br /&gt;
import javax.swing.JDialog;&lt;br /&gt;
import javax.swing.JLabel;&lt;br /&gt;
import javax.swing.JPanel;&lt;br /&gt;
/**&lt;br /&gt;
 * A dialog allow selection and a font and its associated info.&lt;br /&gt;
 *&lt;br /&gt;
 * @author &lt;br /&gt;
 */&lt;br /&gt;
public class FontChooser extends JDialog&lt;br /&gt;
{&lt;br /&gt;
  private final boolean _selectStyles;&lt;br /&gt;
  private JComboBox _fontNamesCmb;&lt;br /&gt;
  private final JComboBox _fontSizesCmb = new JComboBox(new String[]&lt;br /&gt;
                        { &amp;quot;8&amp;quot;, &amp;quot;9&amp;quot;, &amp;quot;10&amp;quot;, &amp;quot;12&amp;quot;, &amp;quot;14&amp;quot; });&lt;br /&gt;
  private final JCheckBox _boldChk = new JCheckBox(&amp;quot;Bold&amp;quot;);&lt;br /&gt;
  private final JCheckBox _italicChk = new JCheckBox(&amp;quot;Italic&amp;quot;);&lt;br /&gt;
  private final JLabel _previewLbl = new JLabel(&amp;quot;PreviewText&amp;quot;);&lt;br /&gt;
  private Font _font;&lt;br /&gt;
  private ActionListener _previewUpdater;&lt;br /&gt;
  /**&lt;br /&gt;
   * Default ctor.&lt;br /&gt;
   */&lt;br /&gt;
  public FontChooser()&lt;br /&gt;
  {&lt;br /&gt;
    this((Frame)null);&lt;br /&gt;
  }&lt;br /&gt;
  /**&lt;br /&gt;
   * ctor specifying whether styles can be selected.&lt;br /&gt;
   *&lt;br /&gt;
   * @param selectStyles  If &amp;lt;TT&amp;gt;true&amp;lt;/TT&amp;gt; bold and italic checkboxes displayed.&lt;br /&gt;
   */&lt;br /&gt;
  public FontChooser(boolean selectStyles)&lt;br /&gt;
  {&lt;br /&gt;
    this((Frame)null, selectStyles);&lt;br /&gt;
  }&lt;br /&gt;
  /**&lt;br /&gt;
   * ctor specifying the parent frame.&lt;br /&gt;
   *&lt;br /&gt;
   * @param owner Parent frame.&lt;br /&gt;
   */&lt;br /&gt;
  public FontChooser(Frame owner)&lt;br /&gt;
  {&lt;br /&gt;
    super(owner, &amp;quot;Font Chooser&amp;quot;, true);&lt;br /&gt;
    _selectStyles = true;&lt;br /&gt;
    createUserInterface();&lt;br /&gt;
  }&lt;br /&gt;
  /**&lt;br /&gt;
   * ctor specifying the parent frame and whether styles can be selected.&lt;br /&gt;
   *&lt;br /&gt;
   * @param owner     Parent frame.&lt;br /&gt;
   * @param selectStyles  If &amp;lt;TT&amp;gt;true&amp;lt;/TT&amp;gt; bold and italic checkboxes displayed.&lt;br /&gt;
   */&lt;br /&gt;
  public FontChooser(Frame owner, boolean selectStyles)&lt;br /&gt;
  {&lt;br /&gt;
    super(owner, &amp;quot;Font Chooser&amp;quot;, true);&lt;br /&gt;
    _selectStyles = selectStyles;&lt;br /&gt;
    createUserInterface();&lt;br /&gt;
  }&lt;br /&gt;
  /**&lt;br /&gt;
   * ctor specifying the parent dialog.&lt;br /&gt;
   *&lt;br /&gt;
   * @param owner Parent frame.&lt;br /&gt;
   */&lt;br /&gt;
  public FontChooser(Dialog owner)&lt;br /&gt;
  {&lt;br /&gt;
    super(owner, &amp;quot;Font Chooser&amp;quot;, true);&lt;br /&gt;
    _selectStyles = true;&lt;br /&gt;
    createUserInterface();&lt;br /&gt;
  }&lt;br /&gt;
  /**&lt;br /&gt;
   * ctor specifying the parent dialog and whether styles can be selected.&lt;br /&gt;
   *&lt;br /&gt;
   * @param owner Parent frame.&lt;br /&gt;
   * @param selectStyles  If &amp;lt;TT&amp;gt;true&amp;lt;/TT&amp;gt; bold and italic checkboxes displayed.&lt;br /&gt;
   */&lt;br /&gt;
  public FontChooser(Dialog owner, boolean selectStyles)&lt;br /&gt;
  {&lt;br /&gt;
    super(owner, &amp;quot;Font Chooser&amp;quot;, true);&lt;br /&gt;
    _selectStyles = selectStyles;&lt;br /&gt;
    createUserInterface();&lt;br /&gt;
  }&lt;br /&gt;
  /**&lt;br /&gt;
   * Component is being added to its parent.&lt;br /&gt;
   */&lt;br /&gt;
  public void addNotify()&lt;br /&gt;
  {&lt;br /&gt;
    super.addNotify();&lt;br /&gt;
    if (_previewUpdater == null)&lt;br /&gt;
    {&lt;br /&gt;
      _previewUpdater = new PreviewLabelUpdater();&lt;br /&gt;
      _fontNamesCmb.addActionListener(_previewUpdater);&lt;br /&gt;
      _fontSizesCmb.addActionListener(_previewUpdater);&lt;br /&gt;
      _boldChk.addActionListener(_previewUpdater);&lt;br /&gt;
      _italicChk.addActionListener(_previewUpdater);&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
  /**&lt;br /&gt;
   * Component is being removed from its parent.&lt;br /&gt;
   */&lt;br /&gt;
  public void removeNotify()&lt;br /&gt;
  {&lt;br /&gt;
    super.removeNotify();&lt;br /&gt;
    if (_previewUpdater != null)&lt;br /&gt;
    {&lt;br /&gt;
      _fontNamesCmb.removeActionListener(_previewUpdater);&lt;br /&gt;
      _fontSizesCmb.removeActionListener(_previewUpdater);&lt;br /&gt;
      _boldChk.removeActionListener(_previewUpdater);&lt;br /&gt;
      _italicChk.removeActionListener(_previewUpdater);&lt;br /&gt;
      _previewUpdater = null;&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
  public Font showDialog()&lt;br /&gt;
  {&lt;br /&gt;
    return showDialog(null);&lt;br /&gt;
  }&lt;br /&gt;
  /**&lt;br /&gt;
   * Show dialog defaulting to the passed font.&lt;br /&gt;
   *&lt;br /&gt;
   * @param font  The font to default to.&lt;br /&gt;
   */&lt;br /&gt;
  public Font showDialog(Font font)&lt;br /&gt;
  {&lt;br /&gt;
    if (font != null)&lt;br /&gt;
    {&lt;br /&gt;
      _fontNamesCmb.setSelectedItem(font.getName());&lt;br /&gt;
      _fontSizesCmb.setSelectedItem(&amp;quot;&amp;quot; + font.getSize());&lt;br /&gt;
      _boldChk.setSelected(_selectStyles &amp;amp;&amp;amp; font.isBold());&lt;br /&gt;
      _italicChk.setSelected(_selectStyles &amp;amp;&amp;amp; font.isItalic());&lt;br /&gt;
    }&lt;br /&gt;
    else&lt;br /&gt;
    {&lt;br /&gt;
      _fontNamesCmb.setSelectedIndex(0);&lt;br /&gt;
      _fontSizesCmb.setSelectedIndex(0);&lt;br /&gt;
      _boldChk.setSelected(false);&lt;br /&gt;
      _italicChk.setSelected(false);&lt;br /&gt;
    }&lt;br /&gt;
    setupPreviewLabel();&lt;br /&gt;
    setVisible(true);&lt;br /&gt;
    return _font;&lt;br /&gt;
  }&lt;br /&gt;
  public Font getSelectedFont()&lt;br /&gt;
  {&lt;br /&gt;
    return _font;&lt;br /&gt;
  }&lt;br /&gt;
  protected void setupFontFromDialog()&lt;br /&gt;
  {&lt;br /&gt;
    int size = 12;&lt;br /&gt;
    try&lt;br /&gt;
    {&lt;br /&gt;
      size = Integer.parseInt((String)_fontSizesCmb.getSelectedItem());&lt;br /&gt;
    }&lt;br /&gt;
    catch (Exception ignore)&lt;br /&gt;
    {&lt;br /&gt;
      // Ignore.&lt;br /&gt;
    }&lt;br /&gt;
    FontInfo fi = new FontInfo();&lt;br /&gt;
    fi.setFamily((String)_fontNamesCmb.getSelectedItem());&lt;br /&gt;
    fi.setSize(size);&lt;br /&gt;
    fi.setIsBold(_boldChk.isSelected());&lt;br /&gt;
    fi.setIsItalic(_italicChk.isSelected());&lt;br /&gt;
    _font = fi.createFont();&lt;br /&gt;
  }&lt;br /&gt;
  private void createUserInterface()&lt;br /&gt;
  {&lt;br /&gt;
    final JPanel content = new JPanel(new GridBagLayout());&lt;br /&gt;
    final GridBagConstraints gbc = new GridBagConstraints();&lt;br /&gt;
    setContentPane(content);&lt;br /&gt;
    content.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));&lt;br /&gt;
    gbc.anchor = GridBagConstraints.WEST;&lt;br /&gt;
    gbc.insets = new Insets(2, 2, 2, 2);&lt;br /&gt;
    gbc.fill = GridBagConstraints.HORIZONTAL;&lt;br /&gt;
    gbc.gridx = gbc.gridy = 0;&lt;br /&gt;
    content.add(new JLabel(&amp;quot;Font&amp;quot;), gbc);&lt;br /&gt;
    ++gbc.gridx;&lt;br /&gt;
    content.add(new JLabel(&amp;quot;Size&amp;quot;), gbc);&lt;br /&gt;
    if (_selectStyles)&lt;br /&gt;
    {&lt;br /&gt;
      ++gbc.gridx;&lt;br /&gt;
      content.add(new JLabel(&amp;quot;Style&amp;quot;), gbc);&lt;br /&gt;
    }&lt;br /&gt;
    ++gbc.gridy;&lt;br /&gt;
    gbc.gridx = 0;&lt;br /&gt;
    _fontNamesCmb = new JComboBox(GraphicsEnvironment.getLocalGraphicsEnvironment().getAvailableFontFamilyNames());&lt;br /&gt;
    content.add(_fontNamesCmb, gbc);&lt;br /&gt;
    ++gbc.gridx;&lt;br /&gt;
    _fontSizesCmb.setEditable(true);&lt;br /&gt;
    content.add(_fontSizesCmb, gbc);&lt;br /&gt;
    if (_selectStyles)&lt;br /&gt;
    {&lt;br /&gt;
      ++gbc.gridx;&lt;br /&gt;
      content.add(_boldChk, gbc);&lt;br /&gt;
      ++gbc.gridy;&lt;br /&gt;
      content.add(_italicChk, gbc);&lt;br /&gt;
    }&lt;br /&gt;
    gbc.gridx = 0;&lt;br /&gt;
    ++gbc.gridy;&lt;br /&gt;
    gbc.gridwidth = GridBagConstraints.REMAINDER;&lt;br /&gt;
    gbc.fill = GridBagConstraints.BOTH;&lt;br /&gt;
    gbc.anchor = GridBagConstraints.CENTER;&lt;br /&gt;
    content.add(createPreviewPanel(), gbc);&lt;br /&gt;
    ++gbc.gridy;&lt;br /&gt;
    gbc.fill = GridBagConstraints.HORIZONTAL;&lt;br /&gt;
    content.add(createButtonsPanel(), gbc);&lt;br /&gt;
    pack();&lt;br /&gt;
    setResizable(true);&lt;br /&gt;
  }&lt;br /&gt;
  private JPanel createPreviewPanel()&lt;br /&gt;
  {&lt;br /&gt;
    final JPanel pnl = new JPanel(new BorderLayout());&lt;br /&gt;
    pnl.setBorder(BorderFactory.createTitledBorder(&amp;quot;PreviewTitle&amp;quot;));&lt;br /&gt;
    Dimension prefSize = _previewLbl.getPreferredSize();&lt;br /&gt;
    prefSize.height = 50;&lt;br /&gt;
    _previewLbl.setPreferredSize(prefSize);&lt;br /&gt;
    pnl.add(_previewLbl, BorderLayout.CENTER);&lt;br /&gt;
    setupPreviewLabel();&lt;br /&gt;
    return pnl;&lt;br /&gt;
  }&lt;br /&gt;
  private JPanel createButtonsPanel()&lt;br /&gt;
  {&lt;br /&gt;
    JPanel pnl = new JPanel();&lt;br /&gt;
    JButton okBtn = new JButton(&amp;quot;OK&amp;quot;);&lt;br /&gt;
    okBtn.addActionListener(new ActionListener()&lt;br /&gt;
    {&lt;br /&gt;
      public void actionPerformed(ActionEvent evt)&lt;br /&gt;
      {&lt;br /&gt;
        setupFontFromDialog();&lt;br /&gt;
        dispose();&lt;br /&gt;
      }&lt;br /&gt;
    });&lt;br /&gt;
    JButton cancelBtn = new JButton(&amp;quot;Cancel&amp;quot;);&lt;br /&gt;
    cancelBtn.addActionListener(new ActionListener()&lt;br /&gt;
    {&lt;br /&gt;
      public void actionPerformed(ActionEvent evt)&lt;br /&gt;
      {&lt;br /&gt;
        FontChooser.this._font = null;&lt;br /&gt;
        dispose();&lt;br /&gt;
      }&lt;br /&gt;
    });&lt;br /&gt;
    pnl.add(okBtn);&lt;br /&gt;
    pnl.add(cancelBtn);&lt;br /&gt;
    getRootPane().setDefaultButton(okBtn);&lt;br /&gt;
    return pnl;&lt;br /&gt;
  }&lt;br /&gt;
  private void setupPreviewLabel()&lt;br /&gt;
  {&lt;br /&gt;
    setupFontFromDialog();&lt;br /&gt;
    _previewLbl.setFont(_font);&lt;br /&gt;
  }&lt;br /&gt;
  private final class PreviewLabelUpdater implements ActionListener&lt;br /&gt;
  {&lt;br /&gt;
    public void actionPerformed(ActionEvent evt)&lt;br /&gt;
    {&lt;br /&gt;
      setupPreviewLabel();&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
/*&lt;br /&gt;
 * Copyright (C) 2001-2003 Colin Bell&lt;br /&gt;
 * colbell@users.sourceforge.net&lt;br /&gt;
 *&lt;br /&gt;
 * This library is free software; you can redistribute it and/or&lt;br /&gt;
 * modify it under the terms of the GNU Lesser General Public&lt;br /&gt;
 * License as published by the Free Software Foundation; either&lt;br /&gt;
 * version 2.1 of the License, or (at your option) any later version.&lt;br /&gt;
 *&lt;br /&gt;
 * This library is distributed in the hope that it will be useful,&lt;br /&gt;
 * but WITHOUT ANY WARRANTY; without even the implied warranty of&lt;br /&gt;
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU&lt;br /&gt;
 * Lesser General Public License for more details.&lt;br /&gt;
 *&lt;br /&gt;
 * You should have received a copy of the GNU Lesser General Public&lt;br /&gt;
 * License along with this library; if not, write to the Free Software&lt;br /&gt;
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA&lt;br /&gt;
 */&lt;br /&gt;
 class FontInfo implements Cloneable, Serializable&lt;br /&gt;
{&lt;br /&gt;
    private static final long serialVersionUID = 1L;&lt;br /&gt;
    public interface IPropertyNames&lt;br /&gt;
  {&lt;br /&gt;
    String FAMILY = &amp;quot;family&amp;quot;;&lt;br /&gt;
    String IS_BOLD = &amp;quot;isBold&amp;quot;;&lt;br /&gt;
    String IS_ITALIC = &amp;quot;isItalic&amp;quot;;&lt;br /&gt;
    String SIZE = &amp;quot;size&amp;quot;;&lt;br /&gt;
  }&lt;br /&gt;
  private static String DEFAULT_FAMILY = &amp;quot;Monospaced&amp;quot;;&lt;br /&gt;
  private String _familyName;&lt;br /&gt;
  private boolean _isBold;&lt;br /&gt;
  private boolean _isItalic;&lt;br /&gt;
  private int _size;&lt;br /&gt;
  public FontInfo()&lt;br /&gt;
  {&lt;br /&gt;
    super();&lt;br /&gt;
    setFamily(DEFAULT_FAMILY);&lt;br /&gt;
    setSize(12);&lt;br /&gt;
  }&lt;br /&gt;
  public FontInfo(Font font)&lt;br /&gt;
  {&lt;br /&gt;
    super();&lt;br /&gt;
    if (font == null)&lt;br /&gt;
    {&lt;br /&gt;
      throw new IllegalArgumentException(&amp;quot;Null Font passed&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
    setFont(font);&lt;br /&gt;
  }&lt;br /&gt;
  /**&lt;br /&gt;
   * Return a copy of this object.&lt;br /&gt;
   */&lt;br /&gt;
  public Object clone()&lt;br /&gt;
  {&lt;br /&gt;
    try&lt;br /&gt;
    {&lt;br /&gt;
      return super.clone();&lt;br /&gt;
    }&lt;br /&gt;
    catch (CloneNotSupportedException ex)&lt;br /&gt;
    {&lt;br /&gt;
      throw new InternalError(ex.getMessage()); // Impossible.&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
  public String getFamily()&lt;br /&gt;
  {&lt;br /&gt;
    return _familyName;&lt;br /&gt;
  }&lt;br /&gt;
  public void setFamily(String value)&lt;br /&gt;
  {&lt;br /&gt;
    _familyName = value != null ? value : DEFAULT_FAMILY;&lt;br /&gt;
  }&lt;br /&gt;
  public boolean isBold()&lt;br /&gt;
  {&lt;br /&gt;
    return _isBold;&lt;br /&gt;
  }&lt;br /&gt;
  public void setIsBold(boolean value)&lt;br /&gt;
  {&lt;br /&gt;
    _isBold = value;&lt;br /&gt;
  }&lt;br /&gt;
  public boolean isItalic()&lt;br /&gt;
  {&lt;br /&gt;
    return _isItalic;&lt;br /&gt;
  }&lt;br /&gt;
  public void setIsItalic(boolean value)&lt;br /&gt;
  {&lt;br /&gt;
    _isItalic = value;&lt;br /&gt;
  }&lt;br /&gt;
  public int getSize()&lt;br /&gt;
  {&lt;br /&gt;
    return _size;&lt;br /&gt;
  }&lt;br /&gt;
  public void setSize(int value)&lt;br /&gt;
  {&lt;br /&gt;
    _size = value;&lt;br /&gt;
  }&lt;br /&gt;
  public void setFont(Font font) throws IllegalArgumentException&lt;br /&gt;
  {&lt;br /&gt;
    if (font == null)&lt;br /&gt;
    {&lt;br /&gt;
      throw new IllegalArgumentException(&amp;quot;Null Font passed&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
    _familyName = font.getFamily();&lt;br /&gt;
    _isBold = font.isBold();&lt;br /&gt;
    _isItalic = font.isItalic();&lt;br /&gt;
    _size = font.getSize();&lt;br /&gt;
  }&lt;br /&gt;
  public boolean doesFontMatch(Font font)&lt;br /&gt;
  {&lt;br /&gt;
    if (font == null)&lt;br /&gt;
    {&lt;br /&gt;
      return false;&lt;br /&gt;
    }&lt;br /&gt;
    return font.getFamily().equals(_familyName)&lt;br /&gt;
      &amp;amp;&amp;amp; font.getSize() == getSize()&lt;br /&gt;
      &amp;amp;&amp;amp; font.getStyle() == generateStyle();&lt;br /&gt;
  }&lt;br /&gt;
  public int generateStyle()&lt;br /&gt;
  {&lt;br /&gt;
    int style = 0;&lt;br /&gt;
    if (!_isBold &amp;amp;&amp;amp; !_isItalic)&lt;br /&gt;
    {&lt;br /&gt;
      style = Font.PLAIN;&lt;br /&gt;
    }&lt;br /&gt;
    else&lt;br /&gt;
    {&lt;br /&gt;
      if (_isBold)&lt;br /&gt;
      {&lt;br /&gt;
        style |= Font.BOLD;&lt;br /&gt;
      }&lt;br /&gt;
      if (_isItalic)&lt;br /&gt;
      {&lt;br /&gt;
        style |= Font.ITALIC;&lt;br /&gt;
      }&lt;br /&gt;
    }&lt;br /&gt;
    return style;&lt;br /&gt;
  }&lt;br /&gt;
  public Font createFont()&lt;br /&gt;
  {&lt;br /&gt;
    return new Font(_familyName, generateStyle(), _size);&lt;br /&gt;
  }&lt;br /&gt;
  // i18n ? What is this used for?&lt;br /&gt;
  public String toString()&lt;br /&gt;
  {&lt;br /&gt;
    StringBuffer buf = new StringBuffer();&lt;br /&gt;
    buf.append(_familyName).append(&amp;quot;, &amp;quot; + _size);&lt;br /&gt;
    if (_isBold)&lt;br /&gt;
    {&lt;br /&gt;
      buf.append(&amp;quot;, bold&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
    if (_isItalic)&lt;br /&gt;
    {&lt;br /&gt;
      buf.append(&amp;quot;, italic&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
    return buf.toString();&lt;br /&gt;
  }&lt;br /&gt;
    /**&lt;br /&gt;
     * @see java.lang.Object#hashCode()&lt;br /&gt;
     */&lt;br /&gt;
    @Override&lt;br /&gt;
    public int hashCode() {&lt;br /&gt;
        final int PRIME = 31;&lt;br /&gt;
        int result = 1;&lt;br /&gt;
        result = PRIME * result + ((_familyName == null) ? 0 : _familyName.hashCode());&lt;br /&gt;
        result = PRIME * result + (_isBold ? 1231 : 1237);&lt;br /&gt;
        result = PRIME * result + (_isItalic ? 1231 : 1237);&lt;br /&gt;
        result = PRIME * result + _size;&lt;br /&gt;
        return result;&lt;br /&gt;
    }&lt;br /&gt;
    /**&lt;br /&gt;
     * @see java.lang.Object#equals(java.lang.Object)&lt;br /&gt;
     */&lt;br /&gt;
    @Override&lt;br /&gt;
    public boolean equals(Object obj) {&lt;br /&gt;
        if (this == obj)&lt;br /&gt;
            return true;&lt;br /&gt;
        if (obj == null)&lt;br /&gt;
            return false;&lt;br /&gt;
        if (getClass() != obj.getClass())&lt;br /&gt;
            return false;&lt;br /&gt;
        final FontInfo other = (FontInfo) obj;&lt;br /&gt;
        if (_familyName == null) {&lt;br /&gt;
            if (other._familyName != null)&lt;br /&gt;
                return false;&lt;br /&gt;
        } else if (!_familyName.equals(other._familyName))&lt;br /&gt;
            return false;&lt;br /&gt;
        if (_isBold != other._isBold)&lt;br /&gt;
            return false;&lt;br /&gt;
        if (_isItalic != other._isItalic)&lt;br /&gt;
            return false;&lt;br /&gt;
        if (_size != other._size)&lt;br /&gt;
            return false;&lt;br /&gt;
        return true;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
   &lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== FontChooser, adapted from NwFontChooserS by Noah Wairauch ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
/*BEGIN_COPYRIGHT_BLOCK&lt;br /&gt;
 *&lt;br /&gt;
 * Copyright (c) 2001-2008, JavaPLT group at Rice University (drjava@rice.edu)&lt;br /&gt;
 * All rights reserved.&lt;br /&gt;
 * &lt;br /&gt;
 * Redistribution and use in source and binary forms, with or without&lt;br /&gt;
 * modification, are permitted provided that the following conditions are met:&lt;br /&gt;
 *    * Redistributions of source code must retain the above copyright&lt;br /&gt;
 *      notice, this list of conditions and the following disclaimer.&lt;br /&gt;
 *    * Redistributions in binary form must reproduce the above copyright&lt;br /&gt;
 *      notice, this list of conditions and the following disclaimer in the&lt;br /&gt;
 *      documentation and/or other materials provided with the distribution.&lt;br /&gt;
 *    * Neither the names of DrJava, the JavaPLT group, Rice University, nor the&lt;br /&gt;
 *      names of its contributors may be used to endorse or promote products&lt;br /&gt;
 *      derived from this software without specific prior written permission.&lt;br /&gt;
 * &lt;br /&gt;
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS&lt;br /&gt;
 * &amp;quot;AS IS&amp;quot; AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT&lt;br /&gt;
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR&lt;br /&gt;
 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR&lt;br /&gt;
 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,&lt;br /&gt;
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,&lt;br /&gt;
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR&lt;br /&gt;
 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF&lt;br /&gt;
 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING&lt;br /&gt;
 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS&lt;br /&gt;
 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.&lt;br /&gt;
 *&lt;br /&gt;
 * This software is Open Source Initiative approved Open Source Software.&lt;br /&gt;
 * Open Source Initative Approved is a trademark of the Open Source Initiative.&lt;br /&gt;
 * &lt;br /&gt;
 * This file is part of DrJava.  Download the current version of this project&lt;br /&gt;
 * from http://www.drjava.org/ or http://sourceforge.net/projects/drjava/&lt;br /&gt;
 * &lt;br /&gt;
 * END_COPYRIGHT_BLOCK*/&lt;br /&gt;
&lt;br /&gt;
import javax.swing.*;&lt;br /&gt;
import javax.swing.event.ListSelectionEvent;&lt;br /&gt;
import javax.swing.event.ListSelectionListener;&lt;br /&gt;
import java.awt.*;&lt;br /&gt;
import java.awt.event.*;&lt;br /&gt;
/**&lt;br /&gt;
 * FontChooser, adapted from NwFontChooserS by Noah Wairauch.&lt;br /&gt;
 * (see http:///forum.java.sun.ru/thread.jsp?forum=57&amp;amp;thread=195067)&lt;br /&gt;
 *&lt;br /&gt;
 * @version $Id: FontChooser.java 4872 2009-04-06 21:37:28Z mgricken $&lt;br /&gt;
 */&lt;br /&gt;
public class FontChooser extends JDialog {&lt;br /&gt;
  /** Available font styles.&lt;br /&gt;
   */&lt;br /&gt;
  private static final String[] STYLES =&lt;br /&gt;
      new String[] { &amp;quot;Plain&amp;quot;, &amp;quot;Bold&amp;quot;, &amp;quot;Italic&amp;quot;, &amp;quot;Bold Italic&amp;quot; };&lt;br /&gt;
  /** Available font sizes.&lt;br /&gt;
   */&lt;br /&gt;
  private static final String[] SIZES =&lt;br /&gt;
      new String[] { &amp;quot;3&amp;quot;, &amp;quot;4&amp;quot;, &amp;quot;5&amp;quot;, &amp;quot;6&amp;quot;, &amp;quot;7&amp;quot;, &amp;quot;8&amp;quot;, &amp;quot;9&amp;quot;, &amp;quot;10&amp;quot;, &amp;quot;11&amp;quot;, &amp;quot;12&amp;quot;,&lt;br /&gt;
                     &amp;quot;13&amp;quot;, &amp;quot;14&amp;quot;, &amp;quot;15&amp;quot;, &amp;quot;16&amp;quot;, &amp;quot;17&amp;quot;, &amp;quot;18&amp;quot;, &amp;quot;19&amp;quot;, &amp;quot;20&amp;quot;, &amp;quot;22&amp;quot;,&lt;br /&gt;
                     &amp;quot;24&amp;quot;, &amp;quot;27&amp;quot;, &amp;quot;30&amp;quot;, &amp;quot;34&amp;quot;, &amp;quot;39&amp;quot;, &amp;quot;45&amp;quot;, &amp;quot;51&amp;quot;, &amp;quot;60&amp;quot;};&lt;br /&gt;
  // Lists to display&lt;br /&gt;
  private NwList _styleList;&lt;br /&gt;
  private NwList _fontList;&lt;br /&gt;
  private NwList _sizeList;&lt;br /&gt;
  // Swing elements&lt;br /&gt;
  private JButton _okButton;&lt;br /&gt;
  private JButton _cancelButton;&lt;br /&gt;
  private JLabel _sampleText = new JLabel();&lt;br /&gt;
  private boolean _clickedOK = false;&lt;br /&gt;
  /** Constructs a new modal FontChooser for the given frame,&lt;br /&gt;
   * using the specified font.&lt;br /&gt;
   */&lt;br /&gt;
  private FontChooser(Frame parent, Font font) {&lt;br /&gt;
    super(parent, true);&lt;br /&gt;
    initAll();&lt;br /&gt;
    if (font == null) font = _sampleText.getFont();&lt;br /&gt;
    _fontList.setSelectedItem(font.getName());&lt;br /&gt;
    _sizeList.setSelectedItem(font.getSize() + &amp;quot;&amp;quot;);&lt;br /&gt;
    _styleList.setSelectedItem(STYLES[font.getStyle()]);&lt;br /&gt;
    //this.setResizable(false);&lt;br /&gt;
    resize();&lt;br /&gt;
  }&lt;br /&gt;
  /** Method used to show the font chooser, and select a new font.&lt;br /&gt;
   *&lt;br /&gt;
   * @param parent The parent frame.&lt;br /&gt;
   * @param title  The title for this window.&lt;br /&gt;
   * @param font   The previously chosen font.&lt;br /&gt;
   * @return the newly chosen font.&lt;br /&gt;
   */&lt;br /&gt;
  public static Font showDialog(Frame parent, String title, Font font) {&lt;br /&gt;
    FontChooser fd = new FontChooser(parent, font);&lt;br /&gt;
    fd.setTitle(title);&lt;br /&gt;
    &lt;br /&gt;
    fd.setVisible(true);&lt;br /&gt;
    Font chosenFont = null;&lt;br /&gt;
    if (fd.clickedOK()) {&lt;br /&gt;
      chosenFont = fd.getFont();&lt;br /&gt;
    }&lt;br /&gt;
    fd.dispose();&lt;br /&gt;
    return (chosenFont);&lt;br /&gt;
  }&lt;br /&gt;
  /** Shows the font chooser with a standard title (&amp;quot;Font Chooser&amp;quot;).&lt;br /&gt;
   */&lt;br /&gt;
  public static Font showDialog(Frame parent, Font font) {&lt;br /&gt;
    return showDialog(parent, &amp;quot;Font Chooser&amp;quot;, font);&lt;br /&gt;
  }&lt;br /&gt;
  private void initAll() {&lt;br /&gt;
    getContentPane().setLayout(null);&lt;br /&gt;
    setBounds(50, 50, 425, 400);&lt;br /&gt;
    _sampleText = new JLabel();&lt;br /&gt;
    addLists();&lt;br /&gt;
    addButtons();&lt;br /&gt;
    _sampleText.setForeground(Color.black);&lt;br /&gt;
    getContentPane().add(_sampleText);&lt;br /&gt;
    addWindowListener(new WindowAdapter() {&lt;br /&gt;
      public void windowClosing(java.awt.event.WindowEvent e) {&lt;br /&gt;
        setVisible(false);&lt;br /&gt;
      }&lt;br /&gt;
    });&lt;br /&gt;
    addComponentListener(new ComponentAdapter() {&lt;br /&gt;
      public void componentResized(ComponentEvent evt) {&lt;br /&gt;
        resize();&lt;br /&gt;
      }&lt;br /&gt;
    });&lt;br /&gt;
  }&lt;br /&gt;
  private void resize() {&lt;br /&gt;
    int w = getWidth();&lt;br /&gt;
    int h = getHeight();&lt;br /&gt;
    double wf = (double) w / 425;&lt;br /&gt;
    int w2 = (int) (80 * wf);&lt;br /&gt;
    int w3 = (int) (50 * wf);&lt;br /&gt;
    if (w3 &amp;lt; 30) w3 = 30;&lt;br /&gt;
    int w1 = w - w2 - w3 - 25;&lt;br /&gt;
    _fontList.setBounds(5, 5, w1, h - 91);&lt;br /&gt;
    _styleList.setBounds(w1 + 10, 5, w2, h - 91);&lt;br /&gt;
    _sizeList.setBounds(w1 + w2 + 15, 5, w3, h - 91);&lt;br /&gt;
    _sampleText.setBounds(10, h - 78, w - 20, 45);&lt;br /&gt;
    _okButton.setBounds(w - 165, h - 55, 70, 20);&lt;br /&gt;
    _cancelButton.setBounds(w - 81, h - 55, 70, 20);&lt;br /&gt;
    validate();&lt;br /&gt;
  }&lt;br /&gt;
  private void addLists() {&lt;br /&gt;
    _fontList = new NwList(GraphicsEnvironment.getLocalGraphicsEnvironment().getAvailableFontFamilyNames());&lt;br /&gt;
    _styleList = new NwList(STYLES);&lt;br /&gt;
    _sizeList = new NwList(SIZES);&lt;br /&gt;
    getContentPane().add(_fontList);&lt;br /&gt;
    getContentPane().add(_styleList);&lt;br /&gt;
    getContentPane().add(_sizeList);&lt;br /&gt;
  }&lt;br /&gt;
  private void addButtons() {&lt;br /&gt;
    _okButton = new JButton(&amp;quot;OK&amp;quot;);&lt;br /&gt;
    _okButton.setMargin(new Insets(0, 0, 0, 0));&lt;br /&gt;
    _cancelButton = new JButton(&amp;quot;Cancel&amp;quot;);&lt;br /&gt;
    _cancelButton.setMargin(new Insets(0, 0, 0, 0));&lt;br /&gt;
    _okButton.setFont(new Font(&amp;quot; &amp;quot;, 1, 11));&lt;br /&gt;
    _cancelButton.setFont(new Font(&amp;quot; &amp;quot;, 1, 12));&lt;br /&gt;
    getContentPane().add(_okButton);&lt;br /&gt;
    getContentPane().add(_cancelButton);&lt;br /&gt;
    _okButton.addActionListener(new ActionListener() {&lt;br /&gt;
      public void actionPerformed(ActionEvent e) {&lt;br /&gt;
        setVisible(false);&lt;br /&gt;
        _clickedOK = true;&lt;br /&gt;
      }&lt;br /&gt;
    });&lt;br /&gt;
    _cancelButton.addActionListener(new ActionListener() {&lt;br /&gt;
      public void actionPerformed(ActionEvent e) {&lt;br /&gt;
        setVisible(false);&lt;br /&gt;
        _clickedOK = false;&lt;br /&gt;
      }&lt;br /&gt;
    });&lt;br /&gt;
  }&lt;br /&gt;
  private void showSample() {&lt;br /&gt;
    int g = 0;&lt;br /&gt;
    try { g = Integer.parseInt(_sizeList.getSelectedValue()); }&lt;br /&gt;
    catch (NumberFormatException nfe) { /* do nothing */ }&lt;br /&gt;
    String st = _styleList.getSelectedValue();&lt;br /&gt;
    int s = Font.PLAIN;&lt;br /&gt;
    if (st.equalsIgnoreCase(&amp;quot;Bold&amp;quot;)) s = Font.BOLD;&lt;br /&gt;
    if (st.equalsIgnoreCase(&amp;quot;Italic&amp;quot;)) s = Font.ITALIC;&lt;br /&gt;
    if (st.equalsIgnoreCase(&amp;quot;Bold Italic&amp;quot;)) s = Font.BOLD | Font.ITALIC;&lt;br /&gt;
    _sampleText.setFont(new Font(_fontList.getSelectedValue(), s, g));&lt;br /&gt;
    _sampleText.setText(&amp;quot;The quick brown fox jumped over the lazy dog.&amp;quot;);&lt;br /&gt;
    _sampleText.setVerticalAlignment(SwingConstants.TOP);&lt;br /&gt;
  }&lt;br /&gt;
  /** Returns whether the user clicked OK when the dialog was closed. (If false, the user clicked cancel.) */&lt;br /&gt;
  public boolean clickedOK() { return _clickedOK; }&lt;br /&gt;
  /** Returns the currently selected Font. */&lt;br /&gt;
  public Font getFont() { return _sampleText.getFont(); }&lt;br /&gt;
  /** Private inner class for a list which displays a list of options in addition to a label indicating the currently&lt;br /&gt;
    * selected item.&lt;br /&gt;
    */&lt;br /&gt;
  public class NwList extends JPanel {&lt;br /&gt;
    JList jl;&lt;br /&gt;
    JScrollPane sp;&lt;br /&gt;
    JLabel jt;&lt;br /&gt;
    String si = &amp;quot; &amp;quot;;&lt;br /&gt;
    public NwList(String[] values) {&lt;br /&gt;
      setLayout(null);&lt;br /&gt;
      jl = new JList(values);&lt;br /&gt;
      sp = new JScrollPane(jl);&lt;br /&gt;
      jt = new JLabel();&lt;br /&gt;
      jt.setBackground(Color.white);&lt;br /&gt;
      jt.setForeground(Color.black);&lt;br /&gt;
      jt.setOpaque(true);&lt;br /&gt;
      jt.setBorder(new JTextField().getBorder());&lt;br /&gt;
      jt.setFont(getFont());&lt;br /&gt;
      jl.addListSelectionListener(new ListSelectionListener() {&lt;br /&gt;
        public void valueChanged(ListSelectionEvent e) {&lt;br /&gt;
          jt.setText((String) jl.getSelectedValue());&lt;br /&gt;
          si = (String) jl.getSelectedValue();&lt;br /&gt;
          showSample();&lt;br /&gt;
        }&lt;br /&gt;
      });&lt;br /&gt;
      add(sp);&lt;br /&gt;
      add(jt);&lt;br /&gt;
    }&lt;br /&gt;
    public void setBounds(int x, int y, int w, int h) {&lt;br /&gt;
      super.setBounds(x, y, w, h);&lt;br /&gt;
      sp.setBounds(0, y + 16, w, h - 23);&lt;br /&gt;
      sp.revalidate();&lt;br /&gt;
      jt.setBounds(0, 0, w, 20);&lt;br /&gt;
    }&lt;br /&gt;
    public String getSelectedValue() { return (si); }&lt;br /&gt;
    public void setSelectedItem(String s) { jl.setSelectedValue(s, true);}&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
   &lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== FontChooser by Noah w ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
/* This code was found posted on a forum without any copyright&lt;br /&gt;
 * restrictions. It was written by someone named Noah W.&lt;br /&gt;
 * That&amp;quot;s all I know */&lt;br /&gt;
/* I have modified the original code but claim no copyright on it of any kind */&lt;br /&gt;
&lt;br /&gt;
/*&lt;br /&gt;
This file is part of BORG.&lt;br /&gt;
    BORG is free software; you can redistribute it and/or modify&lt;br /&gt;
    it under the terms of the GNU General Public License as published by&lt;br /&gt;
    the Free Software Foundation; either version 2 of the License, or&lt;br /&gt;
    (at your option) any later version.&lt;br /&gt;
    BORG is distributed in the hope that it will be useful,&lt;br /&gt;
    but WITHOUT ANY WARRANTY; without even the implied warranty of&lt;br /&gt;
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the&lt;br /&gt;
    GNU General Public License for more details.&lt;br /&gt;
    You should have received a copy of the GNU General Public License&lt;br /&gt;
    along with BORG; if not, write to the Free Software&lt;br /&gt;
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA&lt;br /&gt;
Copyright 2003 by Mike Berger&lt;br /&gt;
 */&lt;br /&gt;
&lt;br /&gt;
import java.awt.Color;&lt;br /&gt;
import java.awt.Font;&lt;br /&gt;
import java.awt.Frame;&lt;br /&gt;
import java.awt.GraphicsEnvironment;&lt;br /&gt;
import java.awt.Insets;&lt;br /&gt;
import java.awt.event.ActionEvent;&lt;br /&gt;
import java.awt.event.ActionListener;&lt;br /&gt;
import java.awt.event.WindowAdapter;&lt;br /&gt;
import java.awt.event.WindowEvent;&lt;br /&gt;
import java.util.Enumeration;&lt;br /&gt;
import javax.swing.JButton;&lt;br /&gt;
import javax.swing.JDialog;&lt;br /&gt;
import javax.swing.JLabel;&lt;br /&gt;
import javax.swing.JList;&lt;br /&gt;
import javax.swing.JPanel;&lt;br /&gt;
import javax.swing.JScrollPane;&lt;br /&gt;
import javax.swing.JTextField;&lt;br /&gt;
import javax.swing.UIManager;&lt;br /&gt;
import javax.swing.event.ListSelectionEvent;&lt;br /&gt;
import javax.swing.event.ListSelectionListener;&lt;br /&gt;
import javax.swing.plaf.FontUIResource;&lt;br /&gt;
&lt;br /&gt;
//&lt;br /&gt;
// FontChooser by Noah w.&lt;br /&gt;
//&lt;br /&gt;
public class NwFontChooserS extends JDialog {&lt;br /&gt;
    String[] styleList = new String[] { &amp;quot;Plain&amp;quot;, &amp;quot;Bold&amp;quot;, &amp;quot;Italic&amp;quot; };&lt;br /&gt;
    String[] sizeList =&lt;br /&gt;
    new String[] {&lt;br /&gt;
        &amp;quot;3&amp;quot;,&lt;br /&gt;
        &amp;quot;4&amp;quot;,&lt;br /&gt;
        &amp;quot;5&amp;quot;,&lt;br /&gt;
        &amp;quot;6&amp;quot;,&lt;br /&gt;
        &amp;quot;7&amp;quot;,&lt;br /&gt;
        &amp;quot;8&amp;quot;,&lt;br /&gt;
        &amp;quot;9&amp;quot;,&lt;br /&gt;
        &amp;quot;10&amp;quot;,&lt;br /&gt;
        &amp;quot;11&amp;quot;,&lt;br /&gt;
        &amp;quot;12&amp;quot;,&lt;br /&gt;
        &amp;quot;13&amp;quot;,&lt;br /&gt;
        &amp;quot;14&amp;quot;,&lt;br /&gt;
        &amp;quot;15&amp;quot;,&lt;br /&gt;
        &amp;quot;16&amp;quot;,&lt;br /&gt;
        &amp;quot;17&amp;quot;,&lt;br /&gt;
        &amp;quot;18&amp;quot;,&lt;br /&gt;
        &amp;quot;19&amp;quot;,&lt;br /&gt;
        &amp;quot;20&amp;quot;,&lt;br /&gt;
        &amp;quot;22&amp;quot;,&lt;br /&gt;
        &amp;quot;24&amp;quot;,&lt;br /&gt;
        &amp;quot;27&amp;quot;,&lt;br /&gt;
        &amp;quot;30&amp;quot;,&lt;br /&gt;
        &amp;quot;34&amp;quot;,&lt;br /&gt;
        &amp;quot;39&amp;quot;,&lt;br /&gt;
        &amp;quot;45&amp;quot;,&lt;br /&gt;
        &amp;quot;51&amp;quot;,&lt;br /&gt;
        &amp;quot;60&amp;quot; };&lt;br /&gt;
        NwList StyleList;&lt;br /&gt;
        NwList FontList;&lt;br /&gt;
        NwList SizeList;&lt;br /&gt;
        static JLabel Sample = new JLabel();&lt;br /&gt;
        boolean ob = false;&lt;br /&gt;
        &lt;br /&gt;
        private NwFontChooserS(Frame parent, boolean modal, Font font) {&lt;br /&gt;
            super(parent, modal);&lt;br /&gt;
            initAll();&lt;br /&gt;
            setTitle(&amp;quot;Font Choosr&amp;quot;);&lt;br /&gt;
            if (font == null)&lt;br /&gt;
                font = Sample.getFont();&lt;br /&gt;
            FontList.setSelectedItem(font.getName());&lt;br /&gt;
            SizeList.setSelectedItem(font.getSize() + &amp;quot;&amp;quot;);&lt;br /&gt;
            StyleList.setSelectedItem(styleList[font.getStyle()]);&lt;br /&gt;
            &lt;br /&gt;
        }&lt;br /&gt;
        public static Font showDialog(Frame parent, String s, Font font) {&lt;br /&gt;
            NwFontChooserS fd = new NwFontChooserS(parent, true, font);&lt;br /&gt;
            if (s != null)&lt;br /&gt;
                fd.setTitle(s);&lt;br /&gt;
            fd.setVisible(true);&lt;br /&gt;
            Font fo = null;&lt;br /&gt;
            if (fd.ob)&lt;br /&gt;
                fo = Sample.getFont();&lt;br /&gt;
            fd.dispose();&lt;br /&gt;
            return (fo);&lt;br /&gt;
        }&lt;br /&gt;
        private void initAll() {&lt;br /&gt;
            getContentPane().setLayout(null);&lt;br /&gt;
            setBounds(50, 50, 450, 450);&lt;br /&gt;
            addLists();&lt;br /&gt;
            addButtons();&lt;br /&gt;
            Sample.setBounds(10, 320, 415, 25);&lt;br /&gt;
            Sample.setForeground(Color.black);&lt;br /&gt;
            getContentPane().add(Sample);&lt;br /&gt;
            addWindowListener(new WindowAdapter() {&lt;br /&gt;
                public void windowClosing(WindowEvent e) {&lt;br /&gt;
                    setVisible(false);&lt;br /&gt;
                }&lt;br /&gt;
            });&lt;br /&gt;
        }&lt;br /&gt;
        private void addLists() {&lt;br /&gt;
            FontList =&lt;br /&gt;
            new NwList(&lt;br /&gt;
            GraphicsEnvironment&lt;br /&gt;
            .getLocalGraphicsEnvironment()&lt;br /&gt;
            .getAvailableFontFamilyNames());&lt;br /&gt;
            StyleList = new NwList(styleList);&lt;br /&gt;
            SizeList = new NwList(sizeList);&lt;br /&gt;
            FontList.setBounds(10, 10, 260, 295);&lt;br /&gt;
            StyleList.setBounds(280, 10, 80, 295);&lt;br /&gt;
            SizeList.setBounds(370, 10, 40, 295);&lt;br /&gt;
            getContentPane().add(FontList);&lt;br /&gt;
            getContentPane().add(StyleList);&lt;br /&gt;
            getContentPane().add(SizeList);&lt;br /&gt;
        }&lt;br /&gt;
        private void addButtons() {&lt;br /&gt;
            JButton ok = new JButton(&amp;quot;OK&amp;quot;);&lt;br /&gt;
            ok.setMargin(new Insets(0, 0, 0, 0));&lt;br /&gt;
            JButton ca = new JButton(&amp;quot;Cancel&amp;quot;);&lt;br /&gt;
            ca.setMargin(new Insets(0, 0, 0, 0));&lt;br /&gt;
            ok.setBounds(260, 350, 70, 20);&lt;br /&gt;
            ok.setFont(new Font(&amp;quot; &amp;quot;, 1, 11));&lt;br /&gt;
            ca.setBounds(340, 350, 70, 20);&lt;br /&gt;
            ca.setFont(new Font(&amp;quot; &amp;quot;, 1, 12));&lt;br /&gt;
            getContentPane().add(ok);&lt;br /&gt;
            getContentPane().add(ca);&lt;br /&gt;
            ok.addActionListener(new ActionListener() {&lt;br /&gt;
                public void actionPerformed(ActionEvent e) {&lt;br /&gt;
                    setVisible(false);&lt;br /&gt;
                    ob = true;&lt;br /&gt;
                }&lt;br /&gt;
            });&lt;br /&gt;
            ca.addActionListener(new ActionListener() {&lt;br /&gt;
                public void actionPerformed(ActionEvent e) {&lt;br /&gt;
                    setVisible(false);&lt;br /&gt;
                    ob = false;&lt;br /&gt;
                }&lt;br /&gt;
            });&lt;br /&gt;
        }&lt;br /&gt;
        private void showSample() {&lt;br /&gt;
            int g = 0;&lt;br /&gt;
            try {&lt;br /&gt;
                g = Integer.parseInt(SizeList.getSelectedValue());&lt;br /&gt;
            }&lt;br /&gt;
            catch (NumberFormatException nfe) {&lt;br /&gt;
            }&lt;br /&gt;
            String st = StyleList.getSelectedValue();&lt;br /&gt;
            int s = Font.PLAIN;&lt;br /&gt;
            if (st.equalsIgnoreCase(&amp;quot;Bold&amp;quot;))&lt;br /&gt;
                s = Font.BOLD;&lt;br /&gt;
            if (st.equalsIgnoreCase(&amp;quot;Italic&amp;quot;))&lt;br /&gt;
                s = Font.ITALIC;&lt;br /&gt;
            Sample.setFont(new Font(FontList.getSelectedValue(), s, g));&lt;br /&gt;
            Sample.setText(&amp;quot;The quick brown fox jumped over the lazy dog.&amp;quot;);&lt;br /&gt;
        }&lt;br /&gt;
        //////////////////////////////////////////////////////////////////////&lt;br /&gt;
        private class NwList extends JPanel {&lt;br /&gt;
            JList jl;&lt;br /&gt;
            JScrollPane sp;&lt;br /&gt;
            JLabel jt;&lt;br /&gt;
            String si = &amp;quot; &amp;quot;;&lt;br /&gt;
            &lt;br /&gt;
            public NwList(String[] values) {&lt;br /&gt;
                setLayout(null);&lt;br /&gt;
                jl = new JList(values);&lt;br /&gt;
                sp = new JScrollPane(jl);&lt;br /&gt;
                jt = new JLabel();&lt;br /&gt;
                jt.setBackground(Color.white);&lt;br /&gt;
                jt.setForeground(Color.black);&lt;br /&gt;
                jt.setOpaque(true);&lt;br /&gt;
                jt.setBorder(new JTextField().getBorder());&lt;br /&gt;
                jt.setFont(getFont());&lt;br /&gt;
                jl.setBounds(0, 0, 100, 1000);&lt;br /&gt;
                jl.setBackground(Color.white);&lt;br /&gt;
                jl.addListSelectionListener(new ListSelectionListener() {&lt;br /&gt;
                    public void valueChanged(ListSelectionEvent e) {&lt;br /&gt;
                        jt.setText((String) jl.getSelectedValue());&lt;br /&gt;
                        si = (String) jl.getSelectedValue();&lt;br /&gt;
                        showSample();&lt;br /&gt;
                    }&lt;br /&gt;
                });&lt;br /&gt;
                add(sp);&lt;br /&gt;
                add(jt);&lt;br /&gt;
            }&lt;br /&gt;
            public String getSelectedValue() {&lt;br /&gt;
                return (si);&lt;br /&gt;
            }&lt;br /&gt;
            public void setSelectedItem(String s) {&lt;br /&gt;
                jl.setSelectedValue(s, true);&lt;br /&gt;
            }&lt;br /&gt;
            public void setBounds(int x, int y, int w, int h) {&lt;br /&gt;
                super.setBounds(x, y, w, h);&lt;br /&gt;
                sp.setBounds(0, y + 12, w, h - 23);&lt;br /&gt;
                sp.revalidate();&lt;br /&gt;
                jt.setBounds(0, 0, w, 20);&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
        &lt;br /&gt;
        static public String fontString(Font font) {&lt;br /&gt;
            String fs = font.getFamily();&lt;br /&gt;
            if( !font.isPlain() ) {&lt;br /&gt;
                fs += &amp;quot;-&amp;quot;;&lt;br /&gt;
                if( font.isBold()) {&lt;br /&gt;
                    fs += &amp;quot;BOLD&amp;quot;;&lt;br /&gt;
                }&lt;br /&gt;
                if( font.isItalic()) {&lt;br /&gt;
                    fs += &amp;quot;ITALIC&amp;quot;;&lt;br /&gt;
                }&lt;br /&gt;
            }&lt;br /&gt;
            fs += &amp;quot;-&amp;quot; + font.getSize();&lt;br /&gt;
            return(fs);&lt;br /&gt;
        }&lt;br /&gt;
        &lt;br /&gt;
        static public void setDefaultFont(Font f ) {&lt;br /&gt;
            FontUIResource fui = new FontUIResource(f);&lt;br /&gt;
            Enumeration&amp;lt;Object&amp;gt; keys = UIManager.getDefaults().keys();&lt;br /&gt;
            while (keys.hasMoreElements()) {&lt;br /&gt;
                Object key = keys.nextElement();&lt;br /&gt;
                Object value = UIManager.get(key);&lt;br /&gt;
                if (value instanceof FontUIResource)&lt;br /&gt;
                    UIManager.put(key, fui);&lt;br /&gt;
            }&lt;br /&gt;
            &lt;br /&gt;
        }&lt;br /&gt;
        &lt;br /&gt;
        public static void main(String args[]) {&lt;br /&gt;
            Font font = null;&lt;br /&gt;
            font = NwFontChooserS.showDialog(null, null, null);&lt;br /&gt;
            &lt;br /&gt;
            System.out.println(fontString(font));&lt;br /&gt;
        }&lt;br /&gt;
}&lt;br /&gt;
   &lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Font Chooser extends javax.swing.JDialog ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
/*&lt;br /&gt;
Atlantida is an open source (GPL) multilingual dictionary written in Java.&lt;br /&gt;
It can translate words from one language to another and pronounce them.&lt;br /&gt;
Copyright (C) 2006 Sergey S. http://atla.revdanica.ru/&lt;br /&gt;
This program is free software; you can redistribute it and/or&lt;br /&gt;
modify it under the terms of the GNU General Public License&lt;br /&gt;
as published by the Free Software Foundation; either version 2&lt;br /&gt;
of the License, or (at your option) any later version.&lt;br /&gt;
This program is distributed in the hope that it will be useful,&lt;br /&gt;
but WITHOUT ANY WARRANTY; without even the implied warranty of&lt;br /&gt;
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the&lt;br /&gt;
GNU General Public License for more details.&lt;br /&gt;
You should have received a copy of the GNU General Public License&lt;br /&gt;
along with this program; if not, write to the Free Software&lt;br /&gt;
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.&lt;br /&gt;
*/&lt;br /&gt;
/**&lt;br /&gt;
* FontChooser&lt;br /&gt;
* @author Janos Szatmary, Sergei S.&lt;br /&gt;
* @version 003&lt;br /&gt;
*/&lt;br /&gt;
/*&lt;br /&gt;
 * http://forum.java.sun.ru/thread.jsp?forum=57&amp;amp;thread=124810&lt;br /&gt;
 * For those who asked where&amp;quot;s the constructor, have in mind that the constructor provided&lt;br /&gt;
 * is private. As the author of the code says, the use of this class is as&lt;br /&gt;
 * follows (supposing we are in a Frame class):&lt;br /&gt;
 * FontChooser.showDialog(this,&amp;quot;FontChooser&amp;quot;,new Font(&amp;quot;Dialog&amp;quot;, 0, 12));&lt;br /&gt;
 * This file originally writter by Janos Szatmary, then modifyed by Sergei S. for&lt;br /&gt;
 * Atlantida Multilingual Dictionary http://atla.sf.net&lt;br /&gt;
*/&lt;br /&gt;
&lt;br /&gt;
import java.awt.*;&lt;br /&gt;
import java.awt.event.*;&lt;br /&gt;
import java.util.*;&lt;br /&gt;
import javax.swing.*;&lt;br /&gt;
&lt;br /&gt;
public class FontChooser extends javax.swing.JDialog&lt;br /&gt;
{&lt;br /&gt;
  String[] styleList = new String[]&lt;br /&gt;
  { &amp;quot;Plain&amp;quot;,&amp;quot;Bold&amp;quot;,&amp;quot;Italic&amp;quot;};&lt;br /&gt;
  String[] sizeList = new String[]&lt;br /&gt;
  { &amp;quot;2&amp;quot;,&amp;quot;4&amp;quot;,&amp;quot;6&amp;quot;,&amp;quot;8&amp;quot;,&amp;quot;10&amp;quot;,&amp;quot;12&amp;quot;,&amp;quot;14&amp;quot;,&amp;quot;16&amp;quot;,&amp;quot;18&amp;quot;,&amp;quot;20&amp;quot;,&amp;quot;22&amp;quot;,&amp;quot;24&amp;quot;,&amp;quot;30&amp;quot;,&amp;quot;36&amp;quot;,&amp;quot;48&amp;quot;,&amp;quot;72&amp;quot;};&lt;br /&gt;
  String currentFont = null;&lt;br /&gt;
  int currentStyle = -1;&lt;br /&gt;
  int currentSize = -1;&lt;br /&gt;
  public boolean ok = false;&lt;br /&gt;
  /* ------------------------------------------------------------- */&lt;br /&gt;
  private FontChooser(java.awt.Frame parent,boolean modal)&lt;br /&gt;
  {&lt;br /&gt;
    super (parent,modal);&lt;br /&gt;
    initComponents();&lt;br /&gt;
    setListValues(jFontList,GraphicsEnvironment.getLocalGraphicsEnvironment().getAvailableFontFamilyNames());&lt;br /&gt;
    setListValues(jStyleList,styleList);&lt;br /&gt;
    setListValues(jSizeList,sizeList);&lt;br /&gt;
    setCurrentFont(jSample.getFont());&lt;br /&gt;
    pack();&lt;br /&gt;
  }&lt;br /&gt;
  private FontChooser(java.awt.Frame parent,boolean modal,Font font)&lt;br /&gt;
  {&lt;br /&gt;
    this(parent,modal);&lt;br /&gt;
    setCurrentFont(font);&lt;br /&gt;
  }&lt;br /&gt;
  /* ------------------------------------------------------------- */&lt;br /&gt;
  private void setListValues(JList list,String[] values)&lt;br /&gt;
  {&lt;br /&gt;
    if(list.getModel() instanceof DefaultListModel)&lt;br /&gt;
    {&lt;br /&gt;
      DefaultListModel model = (DefaultListModel)&lt;br /&gt;
                               list.getModel();&lt;br /&gt;
      model.removeAllElements();&lt;br /&gt;
      for( String value : values )&lt;br /&gt;
      {&lt;br /&gt;
        model.addElement( value );&lt;br /&gt;
      }&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
  /* ------------------------------------------------------------- */&lt;br /&gt;
  private void setSampleFont()&lt;br /&gt;
  {&lt;br /&gt;
    if(currentFont != null &amp;amp;&amp;amp; currentStyle &amp;gt;= 0 &amp;amp;&amp;amp; currentSize &amp;gt; 0)&lt;br /&gt;
    {&lt;br /&gt;
      jSample.setFont(new Font&lt;br /&gt;
                      (currentFont,currentStyle,currentSize));&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
  private String styleToString(int style)&lt;br /&gt;
  {&lt;br /&gt;
    String str = &amp;quot;&amp;quot;;&lt;br /&gt;
    if((style&amp;amp;Font.BOLD) == Font.BOLD)&lt;br /&gt;
    {&lt;br /&gt;
      if(str.length() &amp;gt; 0)&lt;br /&gt;
      {&lt;br /&gt;
        str += &amp;quot;,&amp;quot;;&lt;br /&gt;
      }&lt;br /&gt;
      str += &amp;quot;Bold&amp;quot;;&lt;br /&gt;
    }&lt;br /&gt;
    if((style&amp;amp;Font.ITALIC) == Font.ITALIC)&lt;br /&gt;
    {&lt;br /&gt;
      if(str.length() &amp;gt; 0)&lt;br /&gt;
      {&lt;br /&gt;
        str += &amp;quot;,&amp;quot;;&lt;br /&gt;
      }&lt;br /&gt;
      str += &amp;quot;Italic&amp;quot;;&lt;br /&gt;
    }&lt;br /&gt;
    if( str.length() &amp;lt;= 0 )&lt;br /&gt;
    {&lt;br /&gt;
      str = &amp;quot;Plain&amp;quot;;&lt;br /&gt;
    }&lt;br /&gt;
    return str;&lt;br /&gt;
  }&lt;br /&gt;
  /* ------------------------------------------------------------- */&lt;br /&gt;
  public Font getCurrentFont()&lt;br /&gt;
  {&lt;br /&gt;
    return jSample.getFont();&lt;br /&gt;
  }&lt;br /&gt;
  /* ------------------------------------------------------------- */&lt;br /&gt;
  public void setCurrentFont(Font font)&lt;br /&gt;
  {&lt;br /&gt;
    if(font==null)&lt;br /&gt;
    {&lt;br /&gt;
      font = jSample.getFont();&lt;br /&gt;
    }&lt;br /&gt;
    jFont.setText(font.getName());&lt;br /&gt;
    jFontActionPerformed(null);&lt;br /&gt;
    jStyle.setText(styleToString(font.getStyle()));&lt;br /&gt;
    jStyleActionPerformed(null);&lt;br /&gt;
    jSize.setText(Integer.toString(font.getSize()));&lt;br /&gt;
    jSizeActionPerformed(null);&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  // Create font chooser dialog.&lt;br /&gt;
  // If user selected a font (i.e. clicked OK button) - return the font that user has selected.&lt;br /&gt;
  // If user didn&amp;quot;t click OK button - return &amp;quot;null&amp;quot;.&lt;br /&gt;
  public static Font showDialog( Frame parent, String title, Font font)&lt;br /&gt;
  {&lt;br /&gt;
    FontChooser dialog = new FontChooser(parent,true,font);&lt;br /&gt;
    Point p1 = parent.getLocation();&lt;br /&gt;
    Dimension d1 = parent.getSize();&lt;br /&gt;
    Dimension d2 = dialog.getSize();&lt;br /&gt;
    int x = p1.x+(d1.width-d2.width)/2;&lt;br /&gt;
    int y = p1.y+(d1.height-d2.height)/2;&lt;br /&gt;
    if(x &amp;lt; 0)&lt;br /&gt;
    {&lt;br /&gt;
      x = 0;&lt;br /&gt;
    }&lt;br /&gt;
    if(y &amp;lt; 0)&lt;br /&gt;
    {&lt;br /&gt;
      y = 0;&lt;br /&gt;
    }&lt;br /&gt;
    if(title!=null)&lt;br /&gt;
    {&lt;br /&gt;
      dialog.setTitle(title);&lt;br /&gt;
    }&lt;br /&gt;
    dialog.setLocation(x,y);&lt;br /&gt;
    dialog.setVisible(true);&lt;br /&gt;
    Font newfont = null;&lt;br /&gt;
    if(dialog.ok)&lt;br /&gt;
    {&lt;br /&gt;
      newfont = dialog.getCurrentFont();&lt;br /&gt;
    }&lt;br /&gt;
    dialog.dispose();&lt;br /&gt;
    return newfont;&lt;br /&gt;
  }&lt;br /&gt;
  /** This method is called from within the constructor to&lt;br /&gt;
  * initialize the form.&lt;br /&gt;
  * WARNING: Do NOT modify this code. The content of this method is&lt;br /&gt;
  * always regenerated by the FormEditor.&lt;br /&gt;
  */&lt;br /&gt;
  private void initComponents()&lt;br /&gt;
  {&lt;br /&gt;
    jPanel3 = new javax.swing.JPanel();&lt;br /&gt;
    jFont = new javax.swing.JTextField();&lt;br /&gt;
    jScrollPane1 = new javax.swing.JScrollPane();&lt;br /&gt;
    jFontList = new javax.swing.JList();&lt;br /&gt;
    jPanel4 = new javax.swing.JPanel();&lt;br /&gt;
    jStyle = new javax.swing.JTextField();&lt;br /&gt;
    jScrollPane2 = new javax.swing.JScrollPane();&lt;br /&gt;
    jStyleList = new javax.swing.JList();&lt;br /&gt;
    jPanel5 = new javax.swing.JPanel();&lt;br /&gt;
    jSize = new javax.swing.JTextField();&lt;br /&gt;
    jScrollPane3 = new javax.swing.JScrollPane();&lt;br /&gt;
    jSizeList = new javax.swing.JList();&lt;br /&gt;
    jPanel1 = new javax.swing.JPanel();&lt;br /&gt;
    jScrollPane4 = new javax.swing.JScrollPane();&lt;br /&gt;
    jSample = new javax.swing.JTextArea();&lt;br /&gt;
    jButtons = new javax.swing.JPanel();&lt;br /&gt;
    jOk = new javax.swing.JButton();&lt;br /&gt;
    jCancel = new javax.swing.JButton();&lt;br /&gt;
    jLabel6 = new javax.swing.JLabel();&lt;br /&gt;
    getContentPane().setLayout(new java.awt.GridBagLayout());&lt;br /&gt;
    java.awt.GridBagConstraints gridBagConstraints1;&lt;br /&gt;
    setTitle(&amp;quot;Font Chooser&amp;quot;);&lt;br /&gt;
    addWindowListener(new java.awt.event.WindowAdapter()&lt;br /&gt;
                      {&lt;br /&gt;
                        public void windowClosing(java.awt.event.WindowEvent evt)&lt;br /&gt;
                        {&lt;br /&gt;
                          closeDialog(evt);&lt;br /&gt;
                        }&lt;br /&gt;
                      }&lt;br /&gt;
                     );&lt;br /&gt;
    jPanel3.setLayout(new java.awt.GridBagLayout());&lt;br /&gt;
    java.awt.GridBagConstraints gridBagConstraints2;&lt;br /&gt;
    jPanel3.setBorder(new javax.swing.border.TitledBorder(new javax.swing.border.EtchedBorder(), &amp;quot; Font &amp;quot;));&lt;br /&gt;
    jFont.setColumns(24);&lt;br /&gt;
    jFont.addActionListener(new java.awt.event.ActionListener()&lt;br /&gt;
                            {&lt;br /&gt;
                              public void actionPerformed(java.awt.event.ActionEvent evt)&lt;br /&gt;
                              {&lt;br /&gt;
                                jFontActionPerformed(evt);&lt;br /&gt;
                              }&lt;br /&gt;
                            }&lt;br /&gt;
                           );&lt;br /&gt;
    gridBagConstraints2 = new java.awt.GridBagConstraints();&lt;br /&gt;
    gridBagConstraints2.gridwidth = 0;&lt;br /&gt;
    gridBagConstraints2.fill =&lt;br /&gt;
    java.awt.GridBagConstraints.HORIZONTAL;&lt;br /&gt;
    gridBagConstraints2.insets = new java.awt.Insets(0, 3, 0, 3);&lt;br /&gt;
    gridBagConstraints2.anchor = java.awt.GridBagConstraints.NORTHWEST;&lt;br /&gt;
    gridBagConstraints2.weightx = 1.0;&lt;br /&gt;
    jPanel3.add(jFont, gridBagConstraints2);&lt;br /&gt;
&lt;br /&gt;
    jFontList.setModel(new DefaultListModel());&lt;br /&gt;
    jFontList.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);&lt;br /&gt;
    jFontList.addListSelectionListener(new javax.swing.event.ListSelectionListener()&lt;br /&gt;
                                       {&lt;br /&gt;
                                         public void valueChanged(javax.swing.event.ListSelectionEvent evt)&lt;br /&gt;
                                         {&lt;br /&gt;
                                           jFontListValueChanged(evt);&lt;br /&gt;
                                         }&lt;br /&gt;
                                       }&lt;br /&gt;
                                      );&lt;br /&gt;
    jScrollPane1.setViewportView(jFontList);&lt;br /&gt;
    gridBagConstraints2 = new java.awt.GridBagConstraints();&lt;br /&gt;
    gridBagConstraints2.fill = java.awt.GridBagConstraints.BOTH;&lt;br /&gt;
    gridBagConstraints2.insets = new java.awt.Insets(3, 3, 3, 3);&lt;br /&gt;
    gridBagConstraints2.anchor = java.awt.GridBagConstraints.NORTHWEST;&lt;br /&gt;
    gridBagConstraints2.weightx = 1.0;&lt;br /&gt;
    gridBagConstraints2.weighty = 1.0;&lt;br /&gt;
    jPanel3.add(jScrollPane1, gridBagConstraints2);&lt;br /&gt;
&lt;br /&gt;
    gridBagConstraints1 = new java.awt.GridBagConstraints();&lt;br /&gt;
    gridBagConstraints1.fill = java.awt.GridBagConstraints.BOTH;&lt;br /&gt;
    gridBagConstraints1.insets = new java.awt.Insets(5, 5, 0, 0);&lt;br /&gt;
    gridBagConstraints1.weightx = 0.5;&lt;br /&gt;
    gridBagConstraints1.weighty = 1.0;&lt;br /&gt;
    getContentPane().add(jPanel3, gridBagConstraints1);&lt;br /&gt;
&lt;br /&gt;
    jPanel4.setLayout(new java.awt.GridBagLayout());&lt;br /&gt;
    java.awt.GridBagConstraints gridBagConstraints3;&lt;br /&gt;
    jPanel4.setBorder(new javax.swing.border.TitledBorder(new javax.swing.border.EtchedBorder(), &amp;quot; Style &amp;quot;));&lt;br /&gt;
    jStyle.setColumns(18);&lt;br /&gt;
    jStyle.addActionListener(new java.awt.event.ActionListener()&lt;br /&gt;
                             {&lt;br /&gt;
                               public void actionPerformed(java.awt.event.ActionEvent evt)&lt;br /&gt;
                               {&lt;br /&gt;
                                 jStyleActionPerformed(evt);&lt;br /&gt;
                               }&lt;br /&gt;
                             }&lt;br /&gt;
                            );&lt;br /&gt;
    gridBagConstraints3 = new java.awt.GridBagConstraints();&lt;br /&gt;
    gridBagConstraints3.gridwidth = 0;&lt;br /&gt;
    gridBagConstraints3.fill =&lt;br /&gt;
    java.awt.GridBagConstraints.HORIZONTAL;&lt;br /&gt;
    gridBagConstraints3.insets = new java.awt.Insets(0, 3, 0, 3);&lt;br /&gt;
    gridBagConstraints3.anchor = java.awt.GridBagConstraints.NORTHWEST;&lt;br /&gt;
    gridBagConstraints3.weightx = 1.0;&lt;br /&gt;
    jPanel4.add(jStyle, gridBagConstraints3);&lt;br /&gt;
    jStyleList.setModel(new DefaultListModel());&lt;br /&gt;
    jStyleList.setVisibleRowCount(4);&lt;br /&gt;
    jStyleList.addListSelectionListener(new javax.swing.event.ListSelectionListener()&lt;br /&gt;
                                        {&lt;br /&gt;
                                          public void valueChanged(javax.swing.event.ListSelectionEvent evt)&lt;br /&gt;
                                          {&lt;br /&gt;
                                            jStyleListValueChanged(evt);&lt;br /&gt;
                                          }&lt;br /&gt;
                                        }&lt;br /&gt;
                                       );&lt;br /&gt;
    jScrollPane2.setViewportView(jStyleList);&lt;br /&gt;
    gridBagConstraints3 = new java.awt.GridBagConstraints();&lt;br /&gt;
    gridBagConstraints3.fill = java.awt.GridBagConstraints.BOTH;&lt;br /&gt;
    gridBagConstraints3.insets = new java.awt.Insets(3, 3, 3, 3);&lt;br /&gt;
    gridBagConstraints3.anchor = java.awt.GridBagConstraints.NORTHWEST;&lt;br /&gt;
    gridBagConstraints3.weightx = 0.5;&lt;br /&gt;
    gridBagConstraints3.weighty = 1.0;&lt;br /&gt;
    jPanel4.add(jScrollPane2, gridBagConstraints3);&lt;br /&gt;
    gridBagConstraints1 = new java.awt.GridBagConstraints();&lt;br /&gt;
    gridBagConstraints1.fill = java.awt.GridBagConstraints.BOTH;&lt;br /&gt;
    gridBagConstraints1.insets = new java.awt.Insets(5, 5, 0, 0);&lt;br /&gt;
    gridBagConstraints1.weightx = 0.375;&lt;br /&gt;
    gridBagConstraints1.weighty = 1.0;&lt;br /&gt;
    getContentPane().add(jPanel4, gridBagConstraints1);&lt;br /&gt;
    jPanel5.setLayout(new java.awt.GridBagLayout());&lt;br /&gt;
    java.awt.GridBagConstraints gridBagConstraints4;&lt;br /&gt;
    jPanel5.setBorder(new javax.swing.border.TitledBorder(new javax.swing.border.EtchedBorder(), &amp;quot; Size &amp;quot;));&lt;br /&gt;
    jSize.setColumns(6);&lt;br /&gt;
    jSize.addActionListener(new&lt;br /&gt;
                            java.awt.event.ActionListener()&lt;br /&gt;
                            {&lt;br /&gt;
                              public void actionPerformed(java.awt.event.ActionEvent evt)&lt;br /&gt;
                              {&lt;br /&gt;
                                jSizeActionPerformed(evt);&lt;br /&gt;
                              }&lt;br /&gt;
                            }&lt;br /&gt;
                           );&lt;br /&gt;
    gridBagConstraints4 = new java.awt.GridBagConstraints();&lt;br /&gt;
    gridBagConstraints4.gridwidth = 0;&lt;br /&gt;
    gridBagConstraints4.fill = java.awt.GridBagConstraints.HORIZONTAL;&lt;br /&gt;
    gridBagConstraints4.insets = new java.awt.Insets(0, 3, 0, 3);&lt;br /&gt;
    gridBagConstraints4.anchor = java.awt.GridBagConstraints.NORTHWEST;&lt;br /&gt;
    gridBagConstraints4.weightx = 1.0;&lt;br /&gt;
    jPanel5.add(jSize, gridBagConstraints4);&lt;br /&gt;
    jSizeList.setModel(new DefaultListModel());&lt;br /&gt;
    jSizeList.setVisibleRowCount(4);&lt;br /&gt;
    jSizeList.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);&lt;br /&gt;
    jSizeList.addListSelectionListener(new javax.swing.event.ListSelectionListener()&lt;br /&gt;
                                       {&lt;br /&gt;
                                         public void valueChanged(javax.swing.event.ListSelectionEvent evt)&lt;br /&gt;
                                         {&lt;br /&gt;
                                           jSizeListValueChanged(evt);&lt;br /&gt;
                                         }&lt;br /&gt;
                                       }&lt;br /&gt;
                                      );&lt;br /&gt;
    jScrollPane3.setViewportView(jSizeList);&lt;br /&gt;
    gridBagConstraints4 = new java.awt.GridBagConstraints();&lt;br /&gt;
    gridBagConstraints4.fill = java.awt.GridBagConstraints.BOTH;&lt;br /&gt;
    gridBagConstraints4.insets = new java.awt.Insets(3, 3, 3, 3);&lt;br /&gt;
    gridBagConstraints4.anchor = java.awt.GridBagConstraints.NORTHWEST;&lt;br /&gt;
    gridBagConstraints4.weightx = 0.25;&lt;br /&gt;
    gridBagConstraints4.weighty = 1.0;&lt;br /&gt;
    jPanel5.add(jScrollPane3, gridBagConstraints4);&lt;br /&gt;
    gridBagConstraints1 = new java.awt.GridBagConstraints();&lt;br /&gt;
    gridBagConstraints1.gridwidth = 0;&lt;br /&gt;
    gridBagConstraints1.fill = java.awt.GridBagConstraints.BOTH;&lt;br /&gt;
    gridBagConstraints1.insets = new java.awt.Insets(5, 5, 0, 5);&lt;br /&gt;
    gridBagConstraints1.weightx = 0.125;&lt;br /&gt;
    gridBagConstraints1.weighty = 1.0;&lt;br /&gt;
    getContentPane().add(jPanel5, gridBagConstraints1);&lt;br /&gt;
    jPanel1.setLayout(new java.awt.GridBagLayout());&lt;br /&gt;
    java.awt.GridBagConstraints gridBagConstraints5;&lt;br /&gt;
    jPanel1.setBorder(new javax.swing.border.TitledBorder(new javax.swing.border.EtchedBorder(), &amp;quot; Sample &amp;quot;));&lt;br /&gt;
    jSample.setWrapStyleWord(true);&lt;br /&gt;
    jSample.setLineWrap(true);&lt;br /&gt;
    jSample.setColumns(20);&lt;br /&gt;
    jSample.setRows(3);&lt;br /&gt;
    jSample.setText(&amp;quot;The quick brown fox jumped over the lazy dog.&amp;quot;);&lt;br /&gt;
    jScrollPane4.setViewportView(jSample);&lt;br /&gt;
    gridBagConstraints5 = new java.awt.GridBagConstraints();&lt;br /&gt;
    gridBagConstraints5.fill = java.awt.GridBagConstraints.BOTH;&lt;br /&gt;
    gridBagConstraints5.insets = new java.awt.Insets(0, 3, 3, 3);&lt;br /&gt;
    gridBagConstraints5.weightx = 1.0;&lt;br /&gt;
    gridBagConstraints5.weighty = 1.0;&lt;br /&gt;
    jPanel1.add(jScrollPane4, gridBagConstraints5);&lt;br /&gt;
    gridBagConstraints1 = new java.awt.GridBagConstraints();&lt;br /&gt;
    gridBagConstraints1.gridwidth = 0;&lt;br /&gt;
    gridBagConstraints1.fill = java.awt.GridBagConstraints.BOTH;&lt;br /&gt;
    gridBagConstraints1.insets = new java.awt.Insets(0, 5, 0, 5);&lt;br /&gt;
    gridBagConstraints1.anchor = java.awt.GridBagConstraints.NORTHWEST;&lt;br /&gt;
    gridBagConstraints1.weightx = 1.0;&lt;br /&gt;
    getContentPane().add(jPanel1, gridBagConstraints1);&lt;br /&gt;
    jButtons.setLayout(new java.awt.GridBagLayout());&lt;br /&gt;
    java.awt.GridBagConstraints gridBagConstraints6;&lt;br /&gt;
    jOk.setMnemonic(KeyEvent.VK_O);&lt;br /&gt;
    jOk.setText(&amp;quot;OK&amp;quot;);&lt;br /&gt;
    jOk.setRequestFocusEnabled(false);&lt;br /&gt;
    jOk.addActionListener(new java.awt.event.ActionListener()&lt;br /&gt;
                          {&lt;br /&gt;
                            public void actionPerformed(java.awt.event.ActionEvent evt)&lt;br /&gt;
                            {&lt;br /&gt;
                              jOkActionPerformed(evt);&lt;br /&gt;
                            }&lt;br /&gt;
                          }&lt;br /&gt;
                         );&lt;br /&gt;
    gridBagConstraints6 = new java.awt.GridBagConstraints();&lt;br /&gt;
    gridBagConstraints6.insets = new java.awt.Insets(5, 5, 5, 0);&lt;br /&gt;
    gridBagConstraints6.anchor = java.awt.GridBagConstraints.WEST;&lt;br /&gt;
    jButtons.add(jOk, gridBagConstraints6);&lt;br /&gt;
&lt;br /&gt;
    jCancel.setMnemonic(KeyEvent.VK_C);&lt;br /&gt;
    jCancel.setText(&amp;quot;Cancel&amp;quot;);&lt;br /&gt;
    jCancel.setRequestFocusEnabled(false);&lt;br /&gt;
    jCancel.addActionListener(new&lt;br /&gt;
                              java.awt.event.ActionListener()&lt;br /&gt;
                              {&lt;br /&gt;
                                public void actionPerformed(java.awt.event.ActionEvent evt)&lt;br /&gt;
                                {&lt;br /&gt;
                                  jCancelActionPerformed(evt);&lt;br /&gt;
                                }&lt;br /&gt;
                              }&lt;br /&gt;
                             );&lt;br /&gt;
    gridBagConstraints6 = new java.awt.GridBagConstraints();&lt;br /&gt;
    gridBagConstraints6.gridwidth = 0;&lt;br /&gt;
    gridBagConstraints6.insets = new java.awt.Insets(5, 5, 5, 5);&lt;br /&gt;
    gridBagConstraints6.anchor = java.awt.GridBagConstraints.WEST;&lt;br /&gt;
    gridBagConstraints6.weightx = 1.0;&lt;br /&gt;
    jButtons.add(jCancel, gridBagConstraints6);&lt;br /&gt;
    gridBagConstraints6 = new java.awt.GridBagConstraints();&lt;br /&gt;
    gridBagConstraints6.weightx = 1.0;&lt;br /&gt;
    jButtons.add(jLabel6, gridBagConstraints6);&lt;br /&gt;
    gridBagConstraints1 = new java.awt.GridBagConstraints();&lt;br /&gt;
    gridBagConstraints1.gridwidth = 0;&lt;br /&gt;
    gridBagConstraints1.anchor = java.awt.GridBagConstraints.SOUTHWEST;&lt;br /&gt;
    gridBagConstraints1.weightx = 1.0;&lt;br /&gt;
    getContentPane().add(jButtons, gridBagConstraints1);&lt;br /&gt;
  }&lt;br /&gt;
  private void jCancelActionPerformed(java.awt.event.ActionEvent evt)&lt;br /&gt;
  {&lt;br /&gt;
    // Add your handling code here:&lt;br /&gt;
    setVisible(false);&lt;br /&gt;
  }&lt;br /&gt;
  private void jOkActionPerformed (java.awt.event.ActionEvent evt)&lt;br /&gt;
  {&lt;br /&gt;
    // Add your handling code here:&lt;br /&gt;
    ok = true;&lt;br /&gt;
    setVisible(false);&lt;br /&gt;
  }&lt;br /&gt;
  private void jSizeActionPerformed (java.awt.event.ActionEvent evt)&lt;br /&gt;
  {&lt;br /&gt;
    // Add your handling code here:&lt;br /&gt;
    int size = Integer.parseInt(jSize.getText());&lt;br /&gt;
    if(size &amp;gt; 0)&lt;br /&gt;
    {&lt;br /&gt;
      currentSize = size;&lt;br /&gt;
      setSampleFont();&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
  private void jStyleActionPerformed (java.awt.event.ActionEvent evt)&lt;br /&gt;
  {&lt;br /&gt;
    // Add your handling code here:&lt;br /&gt;
    StringTokenizer st = new StringTokenizer(jStyle.getText(),&amp;quot;,&amp;quot;);&lt;br /&gt;
    int style = 0;&lt;br /&gt;
    while(st.hasMoreTokens())&lt;br /&gt;
    {&lt;br /&gt;
      String str = st.nextToken().trim();&lt;br /&gt;
      if(str.equalsIgnoreCase(&amp;quot;Plain&amp;quot;))&lt;br /&gt;
      {&lt;br /&gt;
        style |= Font.PLAIN;&lt;br /&gt;
      }&lt;br /&gt;
      else&lt;br /&gt;
        if(str.equalsIgnoreCase(&amp;quot;Bold&amp;quot;))&lt;br /&gt;
      {&lt;br /&gt;
        style |= Font.BOLD;&lt;br /&gt;
      }&lt;br /&gt;
      else&lt;br /&gt;
        if(str.equalsIgnoreCase(&amp;quot;Italic&amp;quot;))&lt;br /&gt;
      {&lt;br /&gt;
        style |= Font.ITALIC;&lt;br /&gt;
      }&lt;br /&gt;
    }&lt;br /&gt;
    if(style &amp;gt;= 0)&lt;br /&gt;
    {&lt;br /&gt;
      currentStyle = style;&lt;br /&gt;
      setSampleFont();&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
  private void jFontActionPerformed (java.awt.event.ActionEvent evt)&lt;br /&gt;
  {&lt;br /&gt;
    // Add your handling code here:&lt;br /&gt;
    DefaultListModel model = (DefaultListModel)&lt;br /&gt;
                             jFontList.getModel();&lt;br /&gt;
    if(model.indexOf(jFont.getText()) &amp;gt;= 0)&lt;br /&gt;
    {&lt;br /&gt;
      currentFont = jFont.getText();&lt;br /&gt;
      setSampleFont();&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
  private void jStyleListValueChanged(javax.swing.event.ListSelectionEvent evt)&lt;br /&gt;
  {&lt;br /&gt;
    // Add your handling code here:&lt;br /&gt;
    String str = &amp;quot;&amp;quot;;&lt;br /&gt;
    Object[] values = jStyleList.getSelectedValues();&lt;br /&gt;
    if(values.length &amp;gt; 0)&lt;br /&gt;
    {&lt;br /&gt;
      int j;&lt;br /&gt;
      for(j=0; j &amp;lt; values.length; j++)&lt;br /&gt;
      {&lt;br /&gt;
        String s = (String) values[j];&lt;br /&gt;
        if(s.equalsIgnoreCase(&amp;quot;Plain&amp;quot;))&lt;br /&gt;
        {&lt;br /&gt;
          str = &amp;quot;Plain&amp;quot;;  break;&lt;br /&gt;
        }&lt;br /&gt;
        if(str.length() &amp;gt; 0)&lt;br /&gt;
        {&lt;br /&gt;
          str += &amp;quot;,&amp;quot;;&lt;br /&gt;
        }&lt;br /&gt;
        str += (String) values[j];&lt;br /&gt;
      }&lt;br /&gt;
    }&lt;br /&gt;
    else&lt;br /&gt;
    {&lt;br /&gt;
      str = styleToString(currentStyle);&lt;br /&gt;
    }&lt;br /&gt;
    jStyle.setText(str);&lt;br /&gt;
    jStyleActionPerformed(null);&lt;br /&gt;
  }&lt;br /&gt;
  private void jSizeListValueChanged(javax.swing.event.ListSelectionEvent evt)&lt;br /&gt;
  {&lt;br /&gt;
    // Add your handling code here:&lt;br /&gt;
    String str = (String) jSizeList.getSelectedValue();&lt;br /&gt;
    if(str==null || str.length() &amp;lt;= 0)&lt;br /&gt;
    {&lt;br /&gt;
      str = Integer.toString(currentSize);&lt;br /&gt;
    }&lt;br /&gt;
    jSize.setText(str);&lt;br /&gt;
    jSizeActionPerformed(null);&lt;br /&gt;
  }&lt;br /&gt;
  private void jFontListValueChanged(javax.swing.event.ListSelectionEvent evt)&lt;br /&gt;
  {&lt;br /&gt;
    // Add your handling code here:&lt;br /&gt;
    String str = (String) jFontList.getSelectedValue();&lt;br /&gt;
    if(str==null || str.length() &amp;lt;= 0)&lt;br /&gt;
    {&lt;br /&gt;
      str = currentFont;&lt;br /&gt;
    }&lt;br /&gt;
    jFont.setText(str);&lt;br /&gt;
    jFontActionPerformed(null);&lt;br /&gt;
  }&lt;br /&gt;
  /** Closes the dialog */&lt;br /&gt;
  private void closeDialog(java.awt.event.WindowEvent evt)&lt;br /&gt;
  {&lt;br /&gt;
    setVisible (false);&lt;br /&gt;
  }&lt;br /&gt;
  // Variables declaration - do not modify&lt;br /&gt;
  private javax.swing.JPanel jPanel3;&lt;br /&gt;
  private javax.swing.JTextField jFont;&lt;br /&gt;
  private javax.swing.JScrollPane jScrollPane1;&lt;br /&gt;
  private javax.swing.JList jFontList;&lt;br /&gt;
  private javax.swing.JPanel jPanel4;&lt;br /&gt;
  private javax.swing.JTextField jStyle;&lt;br /&gt;
  private javax.swing.JScrollPane jScrollPane2;&lt;br /&gt;
  private javax.swing.JList jStyleList;&lt;br /&gt;
  private javax.swing.JPanel jPanel5;&lt;br /&gt;
  private javax.swing.JTextField jSize;&lt;br /&gt;
  private javax.swing.JScrollPane jScrollPane3;&lt;br /&gt;
  private javax.swing.JList jSizeList;&lt;br /&gt;
  private javax.swing.JPanel jPanel1;&lt;br /&gt;
  private javax.swing.JScrollPane jScrollPane4;&lt;br /&gt;
  private javax.swing.JTextArea jSample;&lt;br /&gt;
  private javax.swing.JPanel jButtons;&lt;br /&gt;
  private javax.swing.JButton jOk;&lt;br /&gt;
  private javax.swing.JButton jCancel;&lt;br /&gt;
  private javax.swing.JLabel jLabel6;&lt;br /&gt;
  // End of variables declaration&lt;br /&gt;
}&lt;br /&gt;
   &lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Font Chooser Source Code ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Font dialog ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
/* &lt;br /&gt;
 * JCommon : a free general purpose class library for the Java(tm) platform&lt;br /&gt;
 * &lt;br /&gt;
 *&lt;br /&gt;
 * (C) Copyright 2000-2005, by Object Refinery Limited and Contributors.&lt;br /&gt;
 * &lt;br /&gt;
 * Project Info:  http://www.jfree.org/jcommon/index.html&lt;br /&gt;
 *&lt;br /&gt;
 * This library is free software; you can redistribute it and/or modify it &lt;br /&gt;
 * under the terms of the GNU Lesser General Public License as published by &lt;br /&gt;
 * the Free Software Foundation; either version 2.1 of the License, or &lt;br /&gt;
 * (at your option) any later version.&lt;br /&gt;
 *&lt;br /&gt;
 * This library is distributed in the hope that it will be useful, but &lt;br /&gt;
 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY &lt;br /&gt;
 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public &lt;br /&gt;
 * License for more details.&lt;br /&gt;
 *&lt;br /&gt;
 * You should have received a copy of the GNU Lesser General Public&lt;br /&gt;
 * License along with this library; if not, write to the Free Software&lt;br /&gt;
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, &lt;br /&gt;
 * USA.  &lt;br /&gt;
 *&lt;br /&gt;
 * [Java is a trademark or registered trademark of Sun Microsystems, Inc. &lt;br /&gt;
 * in the United States and other countries.]&lt;br /&gt;
 * &lt;br /&gt;
 * ----------------------&lt;br /&gt;
 * FontChooserDialog.java&lt;br /&gt;
 * ----------------------&lt;br /&gt;
 * (C) Copyright 2000-2004, by Object Refinery Limited.&lt;br /&gt;
 *&lt;br /&gt;
 * Original Author:  David Gilbert (for Object Refinery Limited);&lt;br /&gt;
 * Contributor(s):   -;&lt;br /&gt;
 *&lt;br /&gt;
 * $Id: FontChooserDialog.java,v 1.5 2007/11/02 17:50:36 taqua Exp $&lt;br /&gt;
 *&lt;br /&gt;
 * Changes (from 26-Oct-2001)&lt;br /&gt;
 * --------------------------&lt;br /&gt;
 * 26-Oct-2001 : Changed package to com.jrefinery.ui.*;&lt;br /&gt;
 * 14-Oct-2002 : Fixed errors reported by Checkstyle (DG);&lt;br /&gt;
 *&lt;br /&gt;
 */&lt;br /&gt;
import java.awt.BorderLayout;&lt;br /&gt;
import java.awt.Dialog;&lt;br /&gt;
import java.awt.Font;&lt;br /&gt;
import java.awt.Frame;&lt;br /&gt;
import java.awt.GraphicsEnvironment;&lt;br /&gt;
import java.awt.GridLayout;&lt;br /&gt;
import java.awt.event.ActionEvent;&lt;br /&gt;
import java.awt.event.ActionListener;&lt;br /&gt;
import javax.swing.BorderFactory;&lt;br /&gt;
import javax.swing.JButton;&lt;br /&gt;
import javax.swing.JCheckBox;&lt;br /&gt;
import javax.swing.JDialog;&lt;br /&gt;
import javax.swing.JList;&lt;br /&gt;
import javax.swing.JPanel;&lt;br /&gt;
import javax.swing.JScrollPane;&lt;br /&gt;
import javax.swing.JTextField;&lt;br /&gt;
import javax.swing.ListModel;&lt;br /&gt;
/**&lt;br /&gt;
 * A dialog for choosing a font from the available system fonts.&lt;br /&gt;
 *&lt;br /&gt;
 * @author David Gilbert&lt;br /&gt;
 */&lt;br /&gt;
public class FontChooserDialog extends StandardDialog {&lt;br /&gt;
    /** The panel within the dialog that contains the font selection controls. */&lt;br /&gt;
    private FontChooserPanel fontChooserPanel;&lt;br /&gt;
    /**&lt;br /&gt;
     * Standard constructor - builds a font chooser dialog owned by another dialog.&lt;br /&gt;
     *&lt;br /&gt;
     * @param owner  the dialog that &amp;quot;owns&amp;quot; this dialog.&lt;br /&gt;
     * @param title  the title for the dialog.&lt;br /&gt;
     * @param modal  a boolean that indicates whether or not the dialog is modal.&lt;br /&gt;
     * @param font  the initial font displayed.&lt;br /&gt;
     */&lt;br /&gt;
    public FontChooserDialog(final Dialog owner, final String title, final boolean modal, final Font font) {&lt;br /&gt;
        super(owner, title, modal);&lt;br /&gt;
        setContentPane(createContent(font));&lt;br /&gt;
    }&lt;br /&gt;
    /**&lt;br /&gt;
     * Standard constructor - builds a font chooser dialog owned by a frame.&lt;br /&gt;
     *&lt;br /&gt;
     * @param owner  the frame that &amp;quot;owns&amp;quot; this dialog.&lt;br /&gt;
     * @param title  the title for the dialog.&lt;br /&gt;
     * @param modal  a boolean that indicates whether or not the dialog is modal.&lt;br /&gt;
     * @param font  the initial font displayed.&lt;br /&gt;
     */&lt;br /&gt;
    public FontChooserDialog(final Frame owner, final String title, final boolean modal, final Font font) {&lt;br /&gt;
        super(owner, title, modal);&lt;br /&gt;
        setContentPane(createContent(font));&lt;br /&gt;
    }&lt;br /&gt;
    /**&lt;br /&gt;
     * Returns the selected font.&lt;br /&gt;
     *&lt;br /&gt;
     * @return the font.&lt;br /&gt;
     */&lt;br /&gt;
    public Font getSelectedFont() {&lt;br /&gt;
        return this.fontChooserPanel.getSelectedFont();&lt;br /&gt;
    }&lt;br /&gt;
    /**&lt;br /&gt;
     * Returns the panel that is the user interface.&lt;br /&gt;
     *&lt;br /&gt;
     * @param font  the font.&lt;br /&gt;
     *&lt;br /&gt;
     * @return the panel.&lt;br /&gt;
     */&lt;br /&gt;
    private JPanel createContent(Font font) {&lt;br /&gt;
        final JPanel content = new JPanel(new BorderLayout());&lt;br /&gt;
        content.setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4));&lt;br /&gt;
        if (font == null) {&lt;br /&gt;
            font = new Font(&amp;quot;Dialog&amp;quot;, 10, Font.PLAIN);&lt;br /&gt;
        }&lt;br /&gt;
        this.fontChooserPanel = new FontChooserPanel(font);&lt;br /&gt;
        content.add(this.fontChooserPanel);&lt;br /&gt;
        final JPanel buttons = createButtonPanel();&lt;br /&gt;
        buttons.setBorder(BorderFactory.createEmptyBorder(4, 0, 0, 0));&lt;br /&gt;
        content.add(buttons, BorderLayout.SOUTH);&lt;br /&gt;
        return content;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
/* &lt;br /&gt;
 * JCommon : a free general purpose class library for the Java(tm) platform&lt;br /&gt;
 * s&lt;br /&gt;
 *&lt;br /&gt;
 * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors.&lt;br /&gt;
 *&lt;br /&gt;
 * Project Info:  http://www.jfree.org/jcommon/index.html&lt;br /&gt;
 *&lt;br /&gt;
 * This library is free software; you can redistribute it and/or modify it&lt;br /&gt;
 * under the terms of the GNU Lesser General Public License as published by&lt;br /&gt;
 * the Free Software Foundation; either version 2.1 of the License, or&lt;br /&gt;
 * (at your option) any later version.&lt;br /&gt;
 *&lt;br /&gt;
 * This library is distributed in the hope that it will be useful, but&lt;br /&gt;
 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY&lt;br /&gt;
 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public&lt;br /&gt;
 * License for more details.&lt;br /&gt;
 *&lt;br /&gt;
 * You should have received a copy of the GNU Lesser General Public&lt;br /&gt;
 * License along with this library; if not, write to the Free Software&lt;br /&gt;
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301,&lt;br /&gt;
 * USA.&lt;br /&gt;
 *&lt;br /&gt;
 * [Java is a trademark or registered trademark of Sun Microsystems, Inc.&lt;br /&gt;
 * in the United States and other countries.]&lt;br /&gt;
 *&lt;br /&gt;
 * ---------------------&lt;br /&gt;
 * FontChooserPanel.java&lt;br /&gt;
 * ---------------------&lt;br /&gt;
 * (C) Copyright 2000-2008, by Object Refinery Limited.&lt;br /&gt;
 *&lt;br /&gt;
 * Original Author:  David Gilbert (for Object Refinery Limited);&lt;br /&gt;
 * Contributor(s):   Arnaud Lelievre;&lt;br /&gt;
 *&lt;br /&gt;
 * $Id: FontChooserPanel.java,v 1.6 2008/12/18 09:57:32 mungady Exp $&lt;br /&gt;
 *&lt;br /&gt;
 * Changes (from 26-Oct-2001)&lt;br /&gt;
 * --------------------------&lt;br /&gt;
 * 26-Oct-2001 : Changed package to com.jrefinery.ui.*;&lt;br /&gt;
 * 14-Oct-2002 : Fixed errors reported by Checkstyle (DG);&lt;br /&gt;
 * 08-Sep-2003 : Added internationalization via use of properties resourceBundle (RFE 690236) (AL);&lt;br /&gt;
 * 21-Feb-2004 : The FontParameter of the constructor was never used (TM);&lt;br /&gt;
 * 18-Dec-2008 : Use ResourceBundleWrapper - see JFreeChart patch 1607918 by&lt;br /&gt;
 *               Jess Thrysoee (DG);&lt;br /&gt;
 *&lt;br /&gt;
 */&lt;br /&gt;
/**&lt;br /&gt;
 * A panel for choosing a font from the available system fonts - still a bit of&lt;br /&gt;
 * a hack at the moment, but good enough for demonstration applications.&lt;br /&gt;
 *&lt;br /&gt;
 * @author David Gilbert&lt;br /&gt;
 */&lt;br /&gt;
class FontChooserPanel extends JPanel {&lt;br /&gt;
    /** The font sizes that can be selected. */&lt;br /&gt;
    public static final String[] SIZES = {&amp;quot;9&amp;quot;, &amp;quot;10&amp;quot;, &amp;quot;11&amp;quot;, &amp;quot;12&amp;quot;, &amp;quot;14&amp;quot;, &amp;quot;16&amp;quot;,&lt;br /&gt;
            &amp;quot;18&amp;quot;, &amp;quot;20&amp;quot;, &amp;quot;22&amp;quot;, &amp;quot;24&amp;quot;, &amp;quot;28&amp;quot;, &amp;quot;36&amp;quot;, &amp;quot;48&amp;quot;, &amp;quot;72&amp;quot;};&lt;br /&gt;
    /** The list of fonts. */&lt;br /&gt;
    private JList fontlist;&lt;br /&gt;
    /** The list of sizes. */&lt;br /&gt;
    private JList sizelist;&lt;br /&gt;
    /** The checkbox that indicates whether the font is bold. */&lt;br /&gt;
    private JCheckBox bold;&lt;br /&gt;
    /** The checkbox that indicates whether or not the font is italic. */&lt;br /&gt;
    private JCheckBox italic;&lt;br /&gt;
&lt;br /&gt;
    /**&lt;br /&gt;
     * Standard constructor - builds a FontChooserPanel initialised with the&lt;br /&gt;
     * specified font.&lt;br /&gt;
     *&lt;br /&gt;
     * @param font  the initial font to display.&lt;br /&gt;
     */&lt;br /&gt;
    public FontChooserPanel(final Font font) {&lt;br /&gt;
        final GraphicsEnvironment g&lt;br /&gt;
                = GraphicsEnvironment.getLocalGraphicsEnvironment();&lt;br /&gt;
        final String[] fonts = g.getAvailableFontFamilyNames();&lt;br /&gt;
        setLayout(new BorderLayout());&lt;br /&gt;
        final JPanel right = new JPanel(new BorderLayout());&lt;br /&gt;
        final JPanel fontPanel = new JPanel(new BorderLayout());&lt;br /&gt;
        fontPanel.setBorder(BorderFactory.createTitledBorder(&lt;br /&gt;
                            BorderFactory.createEtchedBorder(),&lt;br /&gt;
                            &amp;quot;Font&amp;quot;));&lt;br /&gt;
        this.fontlist = new JList(fonts);&lt;br /&gt;
        final JScrollPane fontpane = new JScrollPane(this.fontlist);&lt;br /&gt;
        fontpane.setBorder(BorderFactory.createEtchedBorder());&lt;br /&gt;
        fontPanel.add(fontpane);&lt;br /&gt;
        add(fontPanel);&lt;br /&gt;
        final JPanel sizePanel = new JPanel(new BorderLayout());&lt;br /&gt;
        sizePanel.setBorder(BorderFactory.createTitledBorder(&lt;br /&gt;
                            BorderFactory.createEtchedBorder(),&lt;br /&gt;
                            &amp;quot;Size&amp;quot;));&lt;br /&gt;
        this.sizelist = new JList(SIZES);&lt;br /&gt;
        final JScrollPane sizepane = new JScrollPane(this.sizelist);&lt;br /&gt;
        sizepane.setBorder(BorderFactory.createEtchedBorder());&lt;br /&gt;
        sizePanel.add(sizepane);&lt;br /&gt;
        final JPanel attributes = new JPanel(new GridLayout(1, 2));&lt;br /&gt;
        this.bold = new JCheckBox(&amp;quot;Bold&amp;quot;);&lt;br /&gt;
        this.italic = new JCheckBox(&amp;quot;Italic&amp;quot;);&lt;br /&gt;
        attributes.add(this.bold);&lt;br /&gt;
        attributes.add(this.italic);&lt;br /&gt;
        attributes.setBorder(BorderFactory.createTitledBorder(&lt;br /&gt;
                BorderFactory.createEtchedBorder(),&lt;br /&gt;
                &amp;quot;Attributes&amp;quot;));&lt;br /&gt;
        right.add(sizePanel, BorderLayout.CENTER);&lt;br /&gt;
        right.add(attributes, BorderLayout.SOUTH);&lt;br /&gt;
        add(right, BorderLayout.EAST);&lt;br /&gt;
        setSelectedFont(font);&lt;br /&gt;
    }&lt;br /&gt;
    /**&lt;br /&gt;
     * Returns a Font object representing the selection in the panel.&lt;br /&gt;
     *&lt;br /&gt;
     * @return the font.&lt;br /&gt;
     */&lt;br /&gt;
    public Font getSelectedFont() {&lt;br /&gt;
        return new Font(getSelectedName(), getSelectedStyle(),&lt;br /&gt;
                getSelectedSize());&lt;br /&gt;
    }&lt;br /&gt;
    /**&lt;br /&gt;
     * Returns the selected name.&lt;br /&gt;
     *&lt;br /&gt;
     * @return the name.&lt;br /&gt;
     */&lt;br /&gt;
    public String getSelectedName() {&lt;br /&gt;
        return (String) this.fontlist.getSelectedValue();&lt;br /&gt;
    }&lt;br /&gt;
    /**&lt;br /&gt;
     * Returns the selected style.&lt;br /&gt;
     *&lt;br /&gt;
     * @return the style.&lt;br /&gt;
     */&lt;br /&gt;
    public int getSelectedStyle() {&lt;br /&gt;
        if (this.bold.isSelected() &amp;amp;&amp;amp; this.italic.isSelected()) {&lt;br /&gt;
            return Font.BOLD + Font.ITALIC;&lt;br /&gt;
        }&lt;br /&gt;
        if (this.bold.isSelected()) {&lt;br /&gt;
            return Font.BOLD;&lt;br /&gt;
        }&lt;br /&gt;
        if (this.italic.isSelected()) {&lt;br /&gt;
            return Font.ITALIC;&lt;br /&gt;
        }&lt;br /&gt;
        else {&lt;br /&gt;
            return Font.PLAIN;&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
    /**&lt;br /&gt;
     * Returns the selected size.&lt;br /&gt;
     *&lt;br /&gt;
     * @return the size.&lt;br /&gt;
     */&lt;br /&gt;
    public int getSelectedSize() {&lt;br /&gt;
        final String selected = (String) this.sizelist.getSelectedValue();&lt;br /&gt;
        if (selected != null) {&lt;br /&gt;
            return Integer.parseInt(selected);&lt;br /&gt;
        }&lt;br /&gt;
        else {&lt;br /&gt;
            return 10;&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
    /**&lt;br /&gt;
     * Initializes the contents of the dialog from the given font&lt;br /&gt;
     * object.&lt;br /&gt;
     *&lt;br /&gt;
     * @param font the font from which to read the properties.&lt;br /&gt;
     */&lt;br /&gt;
    public void setSelectedFont (final Font font) {&lt;br /&gt;
        if (font == null) {&lt;br /&gt;
            throw new NullPointerException();&lt;br /&gt;
        }&lt;br /&gt;
        this.bold.setSelected(font.isBold());&lt;br /&gt;
        this.italic.setSelected(font.isItalic());&lt;br /&gt;
        final String fontName = font.getName();&lt;br /&gt;
        ListModel model = this.fontlist.getModel();&lt;br /&gt;
        this.fontlist.clearSelection();&lt;br /&gt;
        for (int i = 0; i &amp;lt; model.getSize(); i++) {&lt;br /&gt;
            if (fontName.equals(model.getElementAt(i))) {&lt;br /&gt;
                this.fontlist.setSelectedIndex(i);&lt;br /&gt;
                break;&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
        final String fontSize = String.valueOf(font.getSize());&lt;br /&gt;
        model = this.sizelist.getModel();&lt;br /&gt;
        this.sizelist.clearSelection();&lt;br /&gt;
        for (int i = 0; i &amp;lt; model.getSize(); i++) {&lt;br /&gt;
            if (fontSize.equals(model.getElementAt(i))) {&lt;br /&gt;
                this.sizelist.setSelectedIndex(i);&lt;br /&gt;
                break;&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
/* &lt;br /&gt;
 * JCommon : a free general purpose class library for the Java(tm) platform&lt;br /&gt;
 * &lt;br /&gt;
 *&lt;br /&gt;
 * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors.&lt;br /&gt;
 *&lt;br /&gt;
 * Project Info:  http://www.jfree.org/jcommon/index.html&lt;br /&gt;
 *&lt;br /&gt;
 * This library is free software; you can redistribute it and/or modify it&lt;br /&gt;
 * under the terms of the GNU Lesser General Public License as published by&lt;br /&gt;
 * the Free Software Foundation; either version 2.1 of the License, or&lt;br /&gt;
 * (at your option) any later version.&lt;br /&gt;
 *&lt;br /&gt;
 * This library is distributed in the hope that it will be useful, but&lt;br /&gt;
 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY&lt;br /&gt;
 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public&lt;br /&gt;
 * License for more details.&lt;br /&gt;
 *&lt;br /&gt;
 * You should have received a copy of the GNU Lesser General Public&lt;br /&gt;
 * License along with this library; if not, write to the Free Software&lt;br /&gt;
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301,&lt;br /&gt;
 * USA.&lt;br /&gt;
 *&lt;br /&gt;
 * [Java is a trademark or registered trademark of Sun Microsystems, Inc.&lt;br /&gt;
 * in the United States and other countries.]&lt;br /&gt;
 *&lt;br /&gt;
 * -------------------&lt;br /&gt;
 * StandardDialog.java&lt;br /&gt;
 * -------------------&lt;br /&gt;
 * (C) Copyright 2000-2008, by Object Refinery Limited.&lt;br /&gt;
 *&lt;br /&gt;
 * Original Author:  David Gilbert (for Object Refinery Limited);&lt;br /&gt;
 * Contributor(s):   Arnaud Lelievre;&lt;br /&gt;
 *&lt;br /&gt;
 * $Id: StandardDialog.java,v 1.7 2008/12/18 09:57:32 mungady Exp $&lt;br /&gt;
 *&lt;br /&gt;
 * Changes (from 26-Oct-2001)&lt;br /&gt;
 * --------------------------&lt;br /&gt;
 * 26-Oct-2001 : Changed package to com.jrefinery.ui.*;&lt;br /&gt;
 * 08-Sep-2003 : Added internationalization via use of properties&lt;br /&gt;
 *               resourceBundle (RFE 690236) (AL);&lt;br /&gt;
 * 18-Dec-2008 : Use ResourceBundleWrapper - see JFreeChart patch 1607918 by&lt;br /&gt;
 *               Jess Thrysoee (DG);&lt;br /&gt;
 *&lt;br /&gt;
 */&lt;br /&gt;
&lt;br /&gt;
/**&lt;br /&gt;
 * The base class for standard dialogs.&lt;br /&gt;
 *&lt;br /&gt;
 * @author David Gilbert&lt;br /&gt;
 */&lt;br /&gt;
class StandardDialog extends JDialog implements ActionListener {&lt;br /&gt;
    /** Flag that indicates whether or not the dialog was cancelled. */&lt;br /&gt;
    private boolean cancelled;&lt;br /&gt;
&lt;br /&gt;
    /**&lt;br /&gt;
     * Standard constructor - builds a dialog...&lt;br /&gt;
     *&lt;br /&gt;
     * @param owner  the owner.&lt;br /&gt;
     * @param title  the title.&lt;br /&gt;
     * @param modal  modal?&lt;br /&gt;
     */&lt;br /&gt;
    public StandardDialog(final Frame owner, final String title,&lt;br /&gt;
            final boolean modal) {&lt;br /&gt;
        super(owner, title, modal);&lt;br /&gt;
        this.cancelled = false;&lt;br /&gt;
    }&lt;br /&gt;
    /**&lt;br /&gt;
     * Standard constructor - builds a dialog...&lt;br /&gt;
     *&lt;br /&gt;
     * @param owner  the owner.&lt;br /&gt;
     * @param title  the title.&lt;br /&gt;
     * @param modal  modal?&lt;br /&gt;
     */&lt;br /&gt;
    public StandardDialog(final Dialog owner, final String title,&lt;br /&gt;
            final boolean modal) {&lt;br /&gt;
        super(owner, title, modal);&lt;br /&gt;
        this.cancelled = false;&lt;br /&gt;
    }&lt;br /&gt;
    /**&lt;br /&gt;
     * Returns a flag that indicates whether or not the dialog has been&lt;br /&gt;
     * cancelled.&lt;br /&gt;
     *&lt;br /&gt;
     * @return boolean.&lt;br /&gt;
     */&lt;br /&gt;
    public boolean isCancelled() {&lt;br /&gt;
        return this.cancelled;&lt;br /&gt;
    }&lt;br /&gt;
    /**&lt;br /&gt;
     * Handles clicks on the standard buttons.&lt;br /&gt;
     *&lt;br /&gt;
     * @param event  the event.&lt;br /&gt;
     */&lt;br /&gt;
    public void actionPerformed(final ActionEvent event) {&lt;br /&gt;
        final String command = event.getActionCommand();&lt;br /&gt;
        if (command.equals(&amp;quot;helpButton&amp;quot;)) {&lt;br /&gt;
            // display help information&lt;br /&gt;
        }&lt;br /&gt;
        else if (command.equals(&amp;quot;okButton&amp;quot;)) {&lt;br /&gt;
            this.cancelled = false;&lt;br /&gt;
            setVisible(false);&lt;br /&gt;
        }&lt;br /&gt;
        else if (command.equals(&amp;quot;cancelButton&amp;quot;)) {&lt;br /&gt;
            this.cancelled = true;&lt;br /&gt;
            setVisible(false);&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
    /**&lt;br /&gt;
     * Builds and returns the user interface for the dialog.  This method is&lt;br /&gt;
     * shared among the constructors.&lt;br /&gt;
     *&lt;br /&gt;
     * @return the button panel.&lt;br /&gt;
     */&lt;br /&gt;
    protected JPanel createButtonPanel() {&lt;br /&gt;
        final L1R2ButtonPanel buttons = new L1R2ButtonPanel(&lt;br /&gt;
                &amp;quot;Help&amp;quot;,&lt;br /&gt;
                &amp;quot;OK&amp;quot;,&lt;br /&gt;
                &amp;quot;Cancel&amp;quot;);&lt;br /&gt;
        final JButton helpButton = buttons.getLeftButton();&lt;br /&gt;
        helpButton.setActionCommand(&amp;quot;helpButton&amp;quot;);&lt;br /&gt;
        helpButton.addActionListener(this);&lt;br /&gt;
        final JButton okButton = buttons.getRightButton1();&lt;br /&gt;
        okButton.setActionCommand(&amp;quot;okButton&amp;quot;);&lt;br /&gt;
        okButton.addActionListener(this);&lt;br /&gt;
        final JButton cancelButton = buttons.getRightButton2();&lt;br /&gt;
        cancelButton.setActionCommand(&amp;quot;cancelButton&amp;quot;);&lt;br /&gt;
        cancelButton.addActionListener(this);&lt;br /&gt;
        buttons.setBorder(BorderFactory.createEmptyBorder(4, 0, 0, 0));&lt;br /&gt;
        return buttons;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
/* &lt;br /&gt;
 * JCommon : a free general purpose class library for the Java(tm) platform&lt;br /&gt;
 * &lt;br /&gt;
 *&lt;br /&gt;
 * (C) Copyright 2000-2005, by Object Refinery Limited and Contributors.&lt;br /&gt;
 * &lt;br /&gt;
 * Project Info:  http://www.jfree.org/jcommon/index.html&lt;br /&gt;
 *&lt;br /&gt;
 * This library is free software; you can redistribute it and/or modify it &lt;br /&gt;
 * under the terms of the GNU Lesser General Public License as published by &lt;br /&gt;
 * the Free Software Foundation; either version 2.1 of the License, or &lt;br /&gt;
 * (at your option) any later version.&lt;br /&gt;
 *&lt;br /&gt;
 * This library is distributed in the hope that it will be useful, but &lt;br /&gt;
 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY &lt;br /&gt;
 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public &lt;br /&gt;
 * License for more details.&lt;br /&gt;
 *&lt;br /&gt;
 * You should have received a copy of the GNU Lesser General Public&lt;br /&gt;
 * License along with this library; if not, write to the Free Software&lt;br /&gt;
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, &lt;br /&gt;
 * USA.  &lt;br /&gt;
 *&lt;br /&gt;
 * [Java is a trademark or registered trademark of Sun Microsystems, Inc. &lt;br /&gt;
 * in the United States and other countries.]&lt;br /&gt;
 * &lt;br /&gt;
 * --------------------&lt;br /&gt;
 * L1R2ButtonPanel.java&lt;br /&gt;
 * --------------------&lt;br /&gt;
 * (C) Copyright 2000-2004, by Object Refinery Limited.&lt;br /&gt;
 *&lt;br /&gt;
 * Original Author:  David Gilbert (for Object Refinery Limited);&lt;br /&gt;
 * Contributor(s):   -;&lt;br /&gt;
 *&lt;br /&gt;
 * $Id: L1R2ButtonPanel.java,v 1.4 2007/11/02 17:50:36 taqua Exp $&lt;br /&gt;
 *&lt;br /&gt;
 * Changes (from 26-Oct-2001)&lt;br /&gt;
 * --------------------------&lt;br /&gt;
 * 26-Oct-2001 : Changed package to com.jrefinery.ui.*;&lt;br /&gt;
 * 26-Jun-2002 : Removed unnecessary import (DG);&lt;br /&gt;
 * 14-Oct-2002 : Fixed errors reported by Checkstyle (DG);&lt;br /&gt;
 *&lt;br /&gt;
 */&lt;br /&gt;
&lt;br /&gt;
/**&lt;br /&gt;
 * A &amp;quot;ready-made&amp;quot; panel that has one button on the left and two buttons on the right - nested&lt;br /&gt;
 * panels and layout managers take care of resizing.&lt;br /&gt;
 *&lt;br /&gt;
 * @author David Gilbert&lt;br /&gt;
 */&lt;br /&gt;
class L1R2ButtonPanel extends JPanel {&lt;br /&gt;
    /** The left button. */&lt;br /&gt;
    private JButton left;&lt;br /&gt;
    /** The first button on the right of the panel. */&lt;br /&gt;
    private JButton right1;&lt;br /&gt;
    /** The second button on the right of the panel. */&lt;br /&gt;
    private JButton right2;&lt;br /&gt;
    /**&lt;br /&gt;
     * Standard constructor - creates a three button panel with the specified button labels.&lt;br /&gt;
     *&lt;br /&gt;
     * @param label1  the label for button 1.&lt;br /&gt;
     * @param label2  the label for button 2.&lt;br /&gt;
     * @param label3  the label for button 3.&lt;br /&gt;
     */&lt;br /&gt;
    public L1R2ButtonPanel(final String label1, final String label2, final String label3) {&lt;br /&gt;
        setLayout(new BorderLayout());&lt;br /&gt;
        // create the pieces...&lt;br /&gt;
        this.left = new JButton(label1);&lt;br /&gt;
        final JPanel rightButtonPanel = new JPanel(new GridLayout(1, 2));&lt;br /&gt;
        this.right1 = new JButton(label2);&lt;br /&gt;
        this.right2 = new JButton(label3);&lt;br /&gt;
        rightButtonPanel.add(this.right1);&lt;br /&gt;
        rightButtonPanel.add(this.right2);&lt;br /&gt;
        // ...and put them together&lt;br /&gt;
        add(this.left, BorderLayout.WEST);&lt;br /&gt;
        add(rightButtonPanel, BorderLayout.EAST);&lt;br /&gt;
    }&lt;br /&gt;
    /**&lt;br /&gt;
     * Returns a reference to button 1, allowing the caller to set labels, action-listeners etc.&lt;br /&gt;
     *&lt;br /&gt;
     * @return the left button.&lt;br /&gt;
     */&lt;br /&gt;
    public JButton getLeftButton() {&lt;br /&gt;
        return this.left;&lt;br /&gt;
    }&lt;br /&gt;
    /**&lt;br /&gt;
     * Returns a reference to button 2, allowing the caller to set labels, action-listeners etc.&lt;br /&gt;
     *&lt;br /&gt;
     * @return the right button 1.&lt;br /&gt;
     */&lt;br /&gt;
    public JButton getRightButton1() {&lt;br /&gt;
        return this.right1;&lt;br /&gt;
    }&lt;br /&gt;
    /**&lt;br /&gt;
     * Returns a reference to button 3, allowing the caller to set labels, action-listeners etc.&lt;br /&gt;
     *&lt;br /&gt;
     * @return  the right button 2.&lt;br /&gt;
     */&lt;br /&gt;
    public JButton getRightButton2() {&lt;br /&gt;
        return this.right2;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
/* &lt;br /&gt;
 * JCommon : a free general purpose class library for the Java(tm) platform&lt;br /&gt;
 * &lt;br /&gt;
 *&lt;br /&gt;
 * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors.&lt;br /&gt;
 *&lt;br /&gt;
 * Project Info:  http://www.jfree.org/jcommon/index.html&lt;br /&gt;
 *&lt;br /&gt;
 * This library is free software; you can redistribute it and/or modify it&lt;br /&gt;
 * under the terms of the GNU Lesser General Public License as published by&lt;br /&gt;
 * the Free Software Foundation; either version 2.1 of the License, or&lt;br /&gt;
 * (at your option) any later version.&lt;br /&gt;
 *&lt;br /&gt;
 * This library is distributed in the hope that it will be useful, but&lt;br /&gt;
 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY&lt;br /&gt;
 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public&lt;br /&gt;
 * License for more details.&lt;br /&gt;
 *&lt;br /&gt;
 * You should have received a copy of the GNU Lesser General Public&lt;br /&gt;
 * License along with this library; if not, write to the Free Software&lt;br /&gt;
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301,&lt;br /&gt;
 * USA.&lt;br /&gt;
 *&lt;br /&gt;
 * [Java is a trademark or registered trademark of Sun Microsystems, Inc.&lt;br /&gt;
 * in the United States and other countries.]&lt;br /&gt;
 *&lt;br /&gt;
 * ---------------------&lt;br /&gt;
 * FontDisplayField.java&lt;br /&gt;
 * ---------------------&lt;br /&gt;
 * (C) Copyright 2000-2008, by Object Refinery Limited.&lt;br /&gt;
 *&lt;br /&gt;
 * Original Author:  David Gilbert (for Object Refinery Limited);&lt;br /&gt;
 * Contributor(s):   Arnaud Lelievre;&lt;br /&gt;
 *&lt;br /&gt;
 * $Id: FontDisplayField.java,v 1.6 2008/12/18 09:57:32 mungady Exp $&lt;br /&gt;
 *&lt;br /&gt;
 * Changes (from 26-Oct-2001)&lt;br /&gt;
 * ----------------------------------&lt;br /&gt;
 * 26-Oct-2001 : Changed package to com.jrefinery.ui.*;&lt;br /&gt;
 * 14-Oct-2002 : Fixed errors reported by Checkstyle (DG);&lt;br /&gt;
 * 08-Sep-2003 : Added internationalization via use of properties&lt;br /&gt;
 *               resourceBundle (RFE 690236) (AL);&lt;br /&gt;
 * 18-Dec-2008 : Use ResourceBundleWrapper - see JFreeChart patch 1607918 by&lt;br /&gt;
 *               Jess Thrysoee (DG);&lt;br /&gt;
 *&lt;br /&gt;
 */&lt;br /&gt;
&lt;br /&gt;
/**&lt;br /&gt;
 * A field for displaying a font selection.  The display field itself is&lt;br /&gt;
 * read-only, to the developer must provide another mechanism to allow the&lt;br /&gt;
 * user to change the font.&lt;br /&gt;
 *&lt;br /&gt;
 * @author David Gilbert&lt;br /&gt;
 */&lt;br /&gt;
class FontDisplayField extends JTextField {&lt;br /&gt;
    /** The current font. */&lt;br /&gt;
    private Font displayFont;&lt;br /&gt;
&lt;br /&gt;
    /**&lt;br /&gt;
     * Standard constructor - builds a FontDescriptionField initialised with&lt;br /&gt;
     * the specified font.&lt;br /&gt;
     *&lt;br /&gt;
     * @param font  the font.&lt;br /&gt;
     */&lt;br /&gt;
    public FontDisplayField(final Font font) {&lt;br /&gt;
        super(&amp;quot;&amp;quot;);&lt;br /&gt;
        setDisplayFont(font);&lt;br /&gt;
        setEnabled(false);&lt;br /&gt;
    }&lt;br /&gt;
    /**&lt;br /&gt;
     * Returns the current font.&lt;br /&gt;
     *&lt;br /&gt;
     * @return the font.&lt;br /&gt;
     */&lt;br /&gt;
    public Font getDisplayFont() {&lt;br /&gt;
        return this.displayFont;&lt;br /&gt;
    }&lt;br /&gt;
    /**&lt;br /&gt;
     * Sets the font.&lt;br /&gt;
     *&lt;br /&gt;
     * @param font  the font.&lt;br /&gt;
     */&lt;br /&gt;
    public void setDisplayFont(final Font font) {&lt;br /&gt;
        this.displayFont = font;&lt;br /&gt;
        setText(fontToString(this.displayFont));&lt;br /&gt;
    }&lt;br /&gt;
    /**&lt;br /&gt;
     * Returns a string representation of the specified font.&lt;br /&gt;
     *&lt;br /&gt;
     * @param font  the font.&lt;br /&gt;
     *&lt;br /&gt;
     * @return a string describing the font.&lt;br /&gt;
     */&lt;br /&gt;
    private String fontToString(final Font font) {&lt;br /&gt;
        if (font != null) {&lt;br /&gt;
            return font.getFontName() + &amp;quot;, &amp;quot; + font.getSize();&lt;br /&gt;
        }&lt;br /&gt;
        else {&lt;br /&gt;
            return &amp;quot;No Font Selected&amp;quot;;&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Font Dialog from claribole ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
/*   FILE: FontDialog.java&lt;br /&gt;
 *   DATE OF CREATION:   Wed Jan 15 17:07:07 2002&lt;br /&gt;
 *   AUTHOR :            Emmanuel Pietriga (emmanuel@w3.org)&lt;br /&gt;
 *   MODIF:              Emmanuel Pietriga (emmanuel.pietriga@inria.fr)&lt;br /&gt;
 *   Copyright (c) Emmanuel Pietriga, 2002. All Rights Reserved&lt;br /&gt;
 *   Copyright (c) INRIA, 2008. All Rights Reserved&lt;br /&gt;
 *   Licensed under the GNU LGPL. For full terms see the file COPYING.&lt;br /&gt;
 *&lt;br /&gt;
 * $Id: FontDialog.java 1207 2008-08-13 16:03:07Z epietrig $&lt;br /&gt;
 */&lt;br /&gt;
&lt;br /&gt;
import java.awt.Container;&lt;br /&gt;
import java.awt.Dialog;&lt;br /&gt;
import java.awt.FlowLayout;&lt;br /&gt;
import java.awt.Font;&lt;br /&gt;
import java.awt.Frame;&lt;br /&gt;
import java.awt.GridBagConstraints;&lt;br /&gt;
import java.awt.GridBagLayout;&lt;br /&gt;
import java.awt.Window;&lt;br /&gt;
import java.awt.event.ActionEvent;&lt;br /&gt;
import java.awt.event.ActionListener;&lt;br /&gt;
import java.awt.event.ruponentAdapter;&lt;br /&gt;
import java.awt.event.ruponentEvent;&lt;br /&gt;
import java.awt.event.WindowAdapter;&lt;br /&gt;
import java.awt.event.WindowEvent;&lt;br /&gt;
import java.util.StringTokenizer;&lt;br /&gt;
import javax.swing.JButton;&lt;br /&gt;
import javax.swing.JDialog;&lt;br /&gt;
import javax.swing.JList;&lt;br /&gt;
import javax.swing.JPanel;&lt;br /&gt;
import javax.swing.JScrollPane;&lt;br /&gt;
public class FontDialog extends JDialog implements ActionListener {&lt;br /&gt;
  static final String ZVTM_FONT_CHOOSER = &amp;quot;ZVTM Font Chooser&amp;quot;;&lt;br /&gt;
    static String DEFAULT_FAMILY=&amp;quot;Dialog&amp;quot;;&lt;br /&gt;
    static int DEFAULT_STYLE=Font.PLAIN;&lt;br /&gt;
    static int DEFAULT_SIZE=10;&lt;br /&gt;
    FontTracker ft;&lt;br /&gt;
    JButton okBt,cancelBt;&lt;br /&gt;
    JList familyList,styleList,sizeList;&lt;br /&gt;
    String[] allFontFamilies=java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment().getAvailableFontFamilyNames();&lt;br /&gt;
    String[] allFontStyles={&amp;quot;Plain&amp;quot;,&amp;quot;Bold&amp;quot;,&amp;quot;Italic&amp;quot;,&amp;quot;BoldItalic&amp;quot;};&lt;br /&gt;
    String[] allFontSizes={&amp;quot;4&amp;quot;,&amp;quot;6&amp;quot;,&amp;quot;8&amp;quot;,&amp;quot;10&amp;quot;,&amp;quot;12&amp;quot;,&amp;quot;14&amp;quot;,&amp;quot;16&amp;quot;,&amp;quot;18&amp;quot;,&amp;quot;20&amp;quot;,&amp;quot;24&amp;quot;};&lt;br /&gt;
    &lt;br /&gt;
    /** Call a FontDialog window that will return  the font selected in the window&lt;br /&gt;
     *@param owner application frame that owns this Modal component&lt;br /&gt;
     */&lt;br /&gt;
    public static Font getFontDialog(Frame owner){&lt;br /&gt;
  FontTracker res=new FontTracker();&lt;br /&gt;
  FontDialog fd=new FontDialog(res,owner);&lt;br /&gt;
  fd.addWindowListener(new FontDialog.Closer());&lt;br /&gt;
        fd.addComponentListener(new FontDialog.DisposeOnClose());&lt;br /&gt;
  fd.setLocationRelativeTo(owner);&lt;br /&gt;
  fd.setVisible(true);  //blocks until the dialog is closed&lt;br /&gt;
  return res.getFont();&lt;br /&gt;
    }&lt;br /&gt;
    /** Call a FontDialog window that will return  the font selected in the window&lt;br /&gt;
     *@param owner application dialog that owns this Modal component&lt;br /&gt;
     */&lt;br /&gt;
    public static Font getFontDialog(Dialog owner){&lt;br /&gt;
  FontTracker res=new FontTracker();&lt;br /&gt;
  FontDialog fd=new FontDialog(res,owner);&lt;br /&gt;
  fd.addWindowListener(new FontDialog.Closer());&lt;br /&gt;
        fd.addComponentListener(new FontDialog.DisposeOnClose());&lt;br /&gt;
  fd.setLocationRelativeTo(owner);&lt;br /&gt;
  fd.setVisible(true);  //blocks until the dialog is closed&lt;br /&gt;
  return res.getFont();&lt;br /&gt;
    }&lt;br /&gt;
    /** Call a FontDialog window that will return  the font selected in the window&lt;br /&gt;
     *@param owner application frame that owns this Modal component&lt;br /&gt;
     *@param f a font giving the default parameters with which the dialog should be initialized (family, size, style)&lt;br /&gt;
     */&lt;br /&gt;
    public static Font getFontDialog(Frame owner,Font f){&lt;br /&gt;
  if (f!=null){&lt;br /&gt;
      DEFAULT_FAMILY=f.getFamily();&lt;br /&gt;
      DEFAULT_STYLE=f.getStyle();&lt;br /&gt;
      DEFAULT_SIZE=f.getSize();&lt;br /&gt;
  }&lt;br /&gt;
  FontTracker res=new FontTracker();&lt;br /&gt;
  FontDialog fd=new FontDialog(res,owner);&lt;br /&gt;
  fd.addWindowListener(new FontDialog.Closer());&lt;br /&gt;
        fd.addComponentListener(new FontDialog.DisposeOnClose());&lt;br /&gt;
  fd.setLocationRelativeTo(owner);&lt;br /&gt;
  fd.setVisible(true);  //blocks until the dialog is closed&lt;br /&gt;
  return res.getFont();&lt;br /&gt;
    }&lt;br /&gt;
    /** Call a FontDialog window that will return  the font selected in the window&lt;br /&gt;
     *@param owner application dialog that owns this Modal component&lt;br /&gt;
     *@param f a font giving the default parameters with which the dialog should be initialized (family, size, style)&lt;br /&gt;
     */&lt;br /&gt;
    public static Font getFontDialog(Dialog owner,Font f){&lt;br /&gt;
  if (f!=null){&lt;br /&gt;
      DEFAULT_FAMILY=f.getFamily();&lt;br /&gt;
      DEFAULT_STYLE=f.getStyle();&lt;br /&gt;
      DEFAULT_SIZE=f.getSize();&lt;br /&gt;
  }&lt;br /&gt;
  FontTracker res=new FontTracker();&lt;br /&gt;
  FontDialog fd=new FontDialog(res,owner);&lt;br /&gt;
  fd.addWindowListener(new FontDialog.Closer());&lt;br /&gt;
        fd.addComponentListener(new FontDialog.DisposeOnClose());&lt;br /&gt;
  fd.setLocationRelativeTo(owner);&lt;br /&gt;
  fd.setVisible(true);  //blocks until the dialog is closed&lt;br /&gt;
  return res.getFont();&lt;br /&gt;
    }&lt;br /&gt;
    /**&lt;br /&gt;
     * Font.decode does not seem to work that well, or I don;t understand how it is supposed to work&lt;br /&gt;
     * Anyway, this one does what I want (decodes family+&amp;quot; &amp;quot;+style+&amp;quot; &amp;quot;+size)&lt;br /&gt;
     */&lt;br /&gt;
    public static Font decode(String fontSpec){&lt;br /&gt;
  if (fontSpec!=null &amp;amp;&amp;amp; fontSpec.length()&amp;gt;0){&lt;br /&gt;
      StringTokenizer st=new StringTokenizer(fontSpec,&amp;quot; &amp;quot;,false);&lt;br /&gt;
      String[] tokens=new String[st.countTokens()];&lt;br /&gt;
      if (tokens.length&amp;gt;=3){&lt;br /&gt;
    int i=0;&lt;br /&gt;
    while (st.hasMoreTokens()) {&lt;br /&gt;
        tokens[i++]=st.nextToken();&lt;br /&gt;
    }&lt;br /&gt;
    String tokenizedFamily=&amp;quot;&amp;quot;;&lt;br /&gt;
    for (int j=0;j&amp;lt;tokens.length-3;j++){&lt;br /&gt;
        tokenizedFamily+=tokens[j]+&amp;quot; &amp;quot;;&lt;br /&gt;
    }&lt;br /&gt;
    tokenizedFamily+=tokens[tokens.length-3];&lt;br /&gt;
    String family=tokenizedFamily;if (family==null){family=DEFAULT_FAMILY;}&lt;br /&gt;
    String tokenizedStyle=tokens[tokens.length-2];&lt;br /&gt;
    String tokenizedSize=tokens[tokens.length-1];&lt;br /&gt;
    int style;&lt;br /&gt;
    if (tokenizedStyle.equals(&amp;quot;Bold&amp;quot;)){style=Font.BOLD;}&lt;br /&gt;
    else if (tokenizedStyle.equals(&amp;quot;Italic&amp;quot;)){style=Font.ITALIC;}&lt;br /&gt;
    else if (tokenizedStyle.equals(&amp;quot;BoldItalic&amp;quot;)){style=Font.BOLD+Font.ITALIC;}&lt;br /&gt;
    else {style=Font.PLAIN;}//&amp;quot;Plain&amp;quot;&lt;br /&gt;
    int size;&lt;br /&gt;
    try {&lt;br /&gt;
        size=Integer.parseInt(tokenizedSize);&lt;br /&gt;
        if (size&amp;lt;=0){size=DEFAULT_SIZE;}&lt;br /&gt;
    }&lt;br /&gt;
    catch (NumberFormatException ex){size=DEFAULT_SIZE;}&lt;br /&gt;
    return new Font(family,style,size);&lt;br /&gt;
      }&lt;br /&gt;
      else {return new Font(DEFAULT_FAMILY,DEFAULT_STYLE,DEFAULT_SIZE);}&lt;br /&gt;
  }&lt;br /&gt;
  else {return new Font(DEFAULT_FAMILY,DEFAULT_STYLE,DEFAULT_SIZE);}&lt;br /&gt;
    }&lt;br /&gt;
    FontDialog(FontTracker ftt,Frame owner){&lt;br /&gt;
  super(owner,ZVTM_FONT_CHOOSER,true);&lt;br /&gt;
  setLocation(owner.getLocation());&lt;br /&gt;
  ft=ftt;&lt;br /&gt;
  initUI();&lt;br /&gt;
    }&lt;br /&gt;
    FontDialog(FontTracker ftt,Dialog owner){&lt;br /&gt;
  super(owner,ZVTM_FONT_CHOOSER,true);&lt;br /&gt;
  setLocation(owner.getLocation());&lt;br /&gt;
  ft=ftt;&lt;br /&gt;
  initUI();&lt;br /&gt;
    }&lt;br /&gt;
    void initUI(){//depending on selected item/default shape type&lt;br /&gt;
  Container cp=this.getContentPane();&lt;br /&gt;
  try {&lt;br /&gt;
     okBt.removeActionListener(this);&lt;br /&gt;
     cancelBt.removeActionListener(this);&lt;br /&gt;
  }&lt;br /&gt;
  catch (NullPointerException ex){/*all these might be null (for instance when poping up a GlyphFactory for the first time)*/}&lt;br /&gt;
  cp.removeAll();&lt;br /&gt;
  //main font panel&lt;br /&gt;
  JPanel mainPanel=new JPanel();&lt;br /&gt;
  GridBagLayout gridBag1=new GridBagLayout();&lt;br /&gt;
  GridBagConstraints constraints1=new GridBagConstraints();&lt;br /&gt;
  mainPanel.setLayout(gridBag1);&lt;br /&gt;
  constraints1.fill=GridBagConstraints.BOTH;&lt;br /&gt;
  constraints1.anchor=GridBagConstraints.CENTER;&lt;br /&gt;
  familyList=new JList(allFontFamilies);&lt;br /&gt;
  JScrollPane sp1=new JScrollPane(familyList);&lt;br /&gt;
  buildConstraints(constraints1,0,0,1,1,30,100);&lt;br /&gt;
  gridBag1.setConstraints(sp1,constraints1);&lt;br /&gt;
  mainPanel.add(sp1);&lt;br /&gt;
  styleList=new JList(allFontStyles);&lt;br /&gt;
  JScrollPane sp2=new JScrollPane(styleList);&lt;br /&gt;
  buildConstraints(constraints1,1,0,1,1,30,0);&lt;br /&gt;
  gridBag1.setConstraints(sp2,constraints1);&lt;br /&gt;
  mainPanel.add(sp2);&lt;br /&gt;
  sizeList=new JList(allFontSizes);&lt;br /&gt;
  JScrollPane sp3=new JScrollPane(sizeList);&lt;br /&gt;
  buildConstraints(constraints1,2,0,1,1,25,0);&lt;br /&gt;
  gridBag1.setConstraints(sp3,constraints1);&lt;br /&gt;
  mainPanel.add(sp3);&lt;br /&gt;
  //ok, cancel, reset buttons&lt;br /&gt;
  JPanel btPanel=new JPanel();&lt;br /&gt;
  btPanel.setLayout(new FlowLayout());&lt;br /&gt;
  okBt=new JButton(&amp;quot;OK&amp;quot;); &lt;br /&gt;
  okBt.addActionListener(this);&lt;br /&gt;
  btPanel.add(okBt);&lt;br /&gt;
  cancelBt=new JButton(&amp;quot;Cancel&amp;quot;); &lt;br /&gt;
  cancelBt.addActionListener(this);&lt;br /&gt;
  btPanel.add(cancelBt);&lt;br /&gt;
  //main components&lt;br /&gt;
  GridBagLayout gridBag=new GridBagLayout();&lt;br /&gt;
  GridBagConstraints constraints=new GridBagConstraints();&lt;br /&gt;
  cp.setLayout(gridBag);&lt;br /&gt;
  constraints.fill=GridBagConstraints.BOTH;&lt;br /&gt;
  constraints.anchor=GridBagConstraints.CENTER;&lt;br /&gt;
  buildConstraints(constraints,0,0,1,1,100,99);&lt;br /&gt;
  gridBag.setConstraints(mainPanel,constraints);&lt;br /&gt;
  cp.add(mainPanel);&lt;br /&gt;
  buildConstraints(constraints,0,1,1,1,100,1);&lt;br /&gt;
  gridBag.setConstraints(btPanel,constraints);&lt;br /&gt;
  cp.add(btPanel);&lt;br /&gt;
  this.setSize(350,200);&lt;br /&gt;
  this.setResizable(false);&lt;br /&gt;
  familyList.setSelectedValue(DEFAULT_FAMILY,true);&lt;br /&gt;
  if (DEFAULT_STYLE==Font.PLAIN){styleList.setSelectedValue(&amp;quot;Plain&amp;quot;,true);}&lt;br /&gt;
  else if (DEFAULT_STYLE==Font.BOLD){styleList.setSelectedValue(&amp;quot;Bold&amp;quot;,true);}&lt;br /&gt;
  else if (DEFAULT_STYLE==Font.ITALIC){styleList.setSelectedValue(&amp;quot;Italic&amp;quot;,true);}&lt;br /&gt;
  else if (DEFAULT_STYLE==Font.BOLD+Font.ITALIC){styleList.setSelectedValue(&amp;quot;BoldItalic&amp;quot;,true);}&lt;br /&gt;
  sizeList.setSelectedValue((new Integer(DEFAULT_SIZE)).toString(),true);&lt;br /&gt;
    }&lt;br /&gt;
    public void actionPerformed(ActionEvent e){&lt;br /&gt;
  Object source=e.getSource();&lt;br /&gt;
  if (source==okBt){&lt;br /&gt;
      ft.setFont(getSelectedFont());&lt;br /&gt;
      this.dispose();&lt;br /&gt;
  }&lt;br /&gt;
  else if (source==cancelBt){&lt;br /&gt;
      ft.setFont(null);&lt;br /&gt;
      this.dispose();&lt;br /&gt;
  }&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    Font getSelectedFont(){&lt;br /&gt;
  String family=(String)familyList.getSelectedValue();if (family==null){family=DEFAULT_FAMILY;}&lt;br /&gt;
  String selectedStyle=(String)styleList.getSelectedValue();&lt;br /&gt;
  int style;&lt;br /&gt;
  if (selectedStyle.equals(&amp;quot;Bold&amp;quot;)){style=Font.BOLD;}&lt;br /&gt;
  else if (selectedStyle.equals(&amp;quot;Italic&amp;quot;)){style=Font.ITALIC;}&lt;br /&gt;
  else if (selectedStyle.equals(&amp;quot;BoldItalic&amp;quot;)){style=Font.BOLD+Font.ITALIC;}&lt;br /&gt;
  else {style=Font.PLAIN;}//&amp;quot;Plain&amp;quot;&lt;br /&gt;
  int size;&lt;br /&gt;
  try {&lt;br /&gt;
      String selectedSize=(String)sizeList.getSelectedValue();&lt;br /&gt;
      size=Integer.parseInt(selectedSize);&lt;br /&gt;
      if (size&amp;lt;=0){size=DEFAULT_SIZE;}&lt;br /&gt;
  }&lt;br /&gt;
  catch (NumberFormatException ex){size=DEFAULT_SIZE;}&lt;br /&gt;
  return new Font(family,style,size);&lt;br /&gt;
    }&lt;br /&gt;
    static void buildConstraints(GridBagConstraints gbc, int gx,int gy,int gw,int gh,int wx,int wy){&lt;br /&gt;
  gbc.gridx=gx;&lt;br /&gt;
  gbc.gridy=gy;&lt;br /&gt;
  gbc.gridwidth=gw;&lt;br /&gt;
  gbc.gridheight=gh;&lt;br /&gt;
  gbc.weightx=wx;&lt;br /&gt;
  gbc.weighty=wy;&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    static class Closer extends WindowAdapter {&lt;br /&gt;
        public void windowClosing(WindowEvent e) {&lt;br /&gt;
            Window w = e.getWindow();&lt;br /&gt;
            w.setVisible(false);&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
    static class DisposeOnClose extends ComponentAdapter {&lt;br /&gt;
        public void componentHidden(ComponentEvent e) {&lt;br /&gt;
            Window w = (Window)e.getComponent();&lt;br /&gt;
            w.dispose();&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
    public static String getFontStyleName(int i){&lt;br /&gt;
  if (i==java.awt.Font.BOLD){return &amp;quot;Bold&amp;quot;;}&lt;br /&gt;
  else if (i==java.awt.Font.ITALIC){return &amp;quot;Italic&amp;quot;;}&lt;br /&gt;
  else if (i==java.awt.Font.BOLD+java.awt.Font.ITALIC){return &amp;quot;BoldItalic&amp;quot;;}&lt;br /&gt;
  else {return &amp;quot;Plain&amp;quot;;}&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
class FontTracker {&lt;br /&gt;
    Font font;&lt;br /&gt;
    public void setFont(Font f){&lt;br /&gt;
  font=f;&lt;br /&gt;
    }&lt;br /&gt;
    public Font getFont() {&lt;br /&gt;
        return font;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
   &lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Font Loader Dialog ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
/*&lt;br /&gt;
 * FontLoaderDialog.java&lt;br /&gt;
 *&lt;br /&gt;
 * Created on November 13, 2006, 8:30 AM&lt;br /&gt;
 */&lt;br /&gt;
&lt;br /&gt;
// Revised from jaspersoft designer&lt;br /&gt;
import java.lang.reflect.InvocationTargetException;&lt;br /&gt;
import javax.swing.SwingUtilities;&lt;br /&gt;
/**&lt;br /&gt;
 *&lt;br /&gt;
 * @author  gtoffoli&lt;br /&gt;
 */&lt;br /&gt;
public class FontLoaderDialog extends javax.swing.JDialog {&lt;br /&gt;
    &lt;br /&gt;
    /** Creates new form FontLoaderDialog */&lt;br /&gt;
    public FontLoaderDialog(java.awt.Frame parent, boolean modal) {&lt;br /&gt;
        super(parent, modal);&lt;br /&gt;
        initComponents();&lt;br /&gt;
        //applyI18n();&lt;br /&gt;
        this.pack();&lt;br /&gt;
        &lt;br /&gt;
        setLocationRelativeTo(null);&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    /** This method is called from within the constructor to&lt;br /&gt;
     * initialize the form.&lt;br /&gt;
     * WARNING: Do NOT modify this code. The content of this method is&lt;br /&gt;
     * always regenerated by the Form Editor.&lt;br /&gt;
     */&lt;br /&gt;
    // &amp;lt;editor-fold defaultstate=&amp;quot;collapsed&amp;quot; desc=&amp;quot;Generated Code&amp;quot;&amp;gt;//GEN-BEGIN:initComponents&lt;br /&gt;
    private void initComponents() {&lt;br /&gt;
        java.awt.GridBagConstraints gridBagConstraints;&lt;br /&gt;
        jLabelStatus = new javax.swing.JLabel();&lt;br /&gt;
        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);&lt;br /&gt;
        getContentPane().setLayout(new java.awt.GridBagLayout());&lt;br /&gt;
        jLabelStatus.setText(&amp;quot;FontLoaderDialog.Label.LoadingStatus&amp;quot;); // NOI18N&lt;br /&gt;
        jLabelStatus.setVerticalAlignment(javax.swing.SwingConstants.TOP);&lt;br /&gt;
        jLabelStatus.setPreferredSize(new java.awt.Dimension(391, 51));&lt;br /&gt;
        gridBagConstraints = new java.awt.GridBagConstraints();&lt;br /&gt;
        gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;&lt;br /&gt;
        gridBagConstraints.weightx = 1.0;&lt;br /&gt;
        gridBagConstraints.weighty = 1.0;&lt;br /&gt;
        gridBagConstraints.insets = new java.awt.Insets(4, 4, 4, 4);&lt;br /&gt;
        getContentPane().add(jLabelStatus, gridBagConstraints);&lt;br /&gt;
        pack();&lt;br /&gt;
    }// &amp;lt;/editor-fold&amp;gt;//GEN-END:initComponents&lt;br /&gt;
    &lt;br /&gt;
    public void setStatus(String s)&lt;br /&gt;
    {&lt;br /&gt;
        jLabelStatus.setText(s);&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    public void fontsLoadingStatusUpdated(String statusMsg) {&lt;br /&gt;
        &lt;br /&gt;
        final String s = statusMsg;&lt;br /&gt;
        try {&lt;br /&gt;
            SwingUtilities.invokeAndWait( new Runnable()&lt;br /&gt;
            {&lt;br /&gt;
                public void run()&lt;br /&gt;
                {&lt;br /&gt;
                    setStatus(s);&lt;br /&gt;
                }&lt;br /&gt;
            }&lt;br /&gt;
            );&lt;br /&gt;
        } catch (InterruptedException ex) {&lt;br /&gt;
            ex.printStackTrace();&lt;br /&gt;
        } catch (InvocationTargetException ex) {&lt;br /&gt;
            ex.printStackTrace();&lt;br /&gt;
        }&lt;br /&gt;
        &lt;br /&gt;
    }&lt;br /&gt;
    public void fontsLoadingStarted() {&lt;br /&gt;
        &lt;br /&gt;
        try {&lt;br /&gt;
            SwingUtilities.invokeAndWait( new Runnable()&lt;br /&gt;
            {&lt;br /&gt;
                public void run()&lt;br /&gt;
                {&lt;br /&gt;
                    setVisible(true);&lt;br /&gt;
                }&lt;br /&gt;
            }&lt;br /&gt;
            );&lt;br /&gt;
        } catch (InterruptedException ex) {&lt;br /&gt;
            ex.printStackTrace();&lt;br /&gt;
        } catch (InvocationTargetException ex) {&lt;br /&gt;
            ex.printStackTrace();&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
    public void fontsLoadingFinished() {&lt;br /&gt;
        try {&lt;br /&gt;
            SwingUtilities.invokeAndWait( new Runnable()&lt;br /&gt;
            {&lt;br /&gt;
                public void run()&lt;br /&gt;
                {&lt;br /&gt;
                    setVisible(false);&lt;br /&gt;
                }&lt;br /&gt;
            }&lt;br /&gt;
            );&lt;br /&gt;
        } catch (InterruptedException ex) {&lt;br /&gt;
            ex.printStackTrace();&lt;br /&gt;
        } catch (InvocationTargetException ex) {&lt;br /&gt;
            ex.printStackTrace();&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    // Variables declaration - do not modify//GEN-BEGIN:variables&lt;br /&gt;
    private javax.swing.JLabel jLabelStatus;&lt;br /&gt;
    // End of variables declaration//GEN-END:variables&lt;br /&gt;
    &lt;br /&gt;
//    public void applyI18n(){&lt;br /&gt;
//                // Start autogenerated code ----------------------&lt;br /&gt;
//                jLabelStatus.setText(I18n.getString(&amp;quot;fontLoaderDialog.labelStatus&amp;quot;,&amp;quot;Loading status&amp;quot;));&lt;br /&gt;
//                // End autogenerated code ----------------------&lt;br /&gt;
//    }&lt;br /&gt;
}&lt;br /&gt;
   &lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== JFont Chooser ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
// revised from greef ui&lt;br /&gt;
import java.awt.BorderLayout;&lt;br /&gt;
import java.awt.ruponent;&lt;br /&gt;
import java.awt.Container;&lt;br /&gt;
import java.awt.FlowLayout;&lt;br /&gt;
import java.awt.Font;&lt;br /&gt;
import java.awt.GraphicsEnvironment;&lt;br /&gt;
import java.awt.GridBagConstraints;&lt;br /&gt;
import java.awt.GridBagLayout;&lt;br /&gt;
import java.awt.HeadlessException;&lt;br /&gt;
import java.awt.Insets;&lt;br /&gt;
import java.awt.Window;&lt;br /&gt;
import java.awt.event.ActionEvent;&lt;br /&gt;
import java.awt.event.ActionListener;&lt;br /&gt;
import java.awt.event.ruponentAdapter;&lt;br /&gt;
import java.awt.event.ruponentEvent;&lt;br /&gt;
import java.awt.event.KeyEvent;&lt;br /&gt;
import java.awt.event.WindowAdapter;&lt;br /&gt;
import java.awt.event.WindowEvent;&lt;br /&gt;
import java.io.Serializable;&lt;br /&gt;
import javax.swing.AbstractAction;&lt;br /&gt;
import javax.swing.Action;&lt;br /&gt;
import javax.swing.ActionMap;&lt;br /&gt;
import javax.swing.InputMap;&lt;br /&gt;
import javax.swing.JButton;&lt;br /&gt;
import javax.swing.JCheckBox;&lt;br /&gt;
import javax.swing.JComponent;&lt;br /&gt;
import javax.swing.JDialog;&lt;br /&gt;
import javax.swing.JLabel;&lt;br /&gt;
import javax.swing.JList;&lt;br /&gt;
import javax.swing.JOptionPane;&lt;br /&gt;
import javax.swing.JPanel;&lt;br /&gt;
import javax.swing.JScrollPane;&lt;br /&gt;
import javax.swing.KeyStroke;&lt;br /&gt;
import javax.swing.ListSelectionModel;&lt;br /&gt;
import javax.swing.UIManager;&lt;br /&gt;
import javax.swing.event.ChangeEvent;&lt;br /&gt;
import javax.swing.event.ChangeListener;&lt;br /&gt;
import javax.swing.event.EventListenerList;&lt;br /&gt;
import javax.swing.event.ListSelectionEvent;&lt;br /&gt;
import javax.swing.event.ListSelectionListener;&lt;br /&gt;
/**&lt;br /&gt;
 * &amp;lt;code&amp;gt;JFontChooser&amp;lt;/code&amp;gt; provides a pane of controls designed to allow&lt;br /&gt;
 * a user to manipulate and select a font.&lt;br /&gt;
 *&lt;br /&gt;
 * This class provides three levels of API:&lt;br /&gt;
 * &amp;lt;ol&amp;gt;&lt;br /&gt;
 * &amp;lt;li&amp;gt;A static convenience method which shows a modal font-chooser&lt;br /&gt;
 * dialog and returns the font selected by the user.&lt;br /&gt;
 * &amp;lt;li&amp;gt;A static convenience method for creating a font-chooser dialog&lt;br /&gt;
 * where &amp;lt;code&amp;gt;ActionListeners&amp;lt;/code&amp;gt; can be specified to be invoked when&lt;br /&gt;
 * the user presses one of the dialog buttons.&lt;br /&gt;
 * &amp;lt;li&amp;gt;The ability to create instances of &amp;lt;code&amp;gt;JFontChooser&amp;lt;/code&amp;gt; panes&lt;br /&gt;
 * directly (within any container). &amp;lt;code&amp;gt;PropertyChange&amp;lt;/code&amp;gt; listeners&lt;br /&gt;
 * can be added to detect when the current &amp;quot;font&amp;quot; property changes.&lt;br /&gt;
 * &amp;lt;/ol&amp;gt;&lt;br /&gt;
 * &amp;lt;p&amp;gt;&lt;br /&gt;
 *&lt;br /&gt;
 * @author Adrian BER&lt;br /&gt;
 */&lt;br /&gt;
public class JFontChooser extends JComponent {&lt;br /&gt;
    /** The list of possible font sizes. */&lt;br /&gt;
    private static final Integer[] SIZES =&lt;br /&gt;
            {8, 9, 10, 11, 12, 13, 14, 16, 18, 20, 24, 26, 28, 32, 36, 40, 48, 56, 64, 72};&lt;br /&gt;
    /** The list of possible fonts. */&lt;br /&gt;
    private static final String[] FONTS = GraphicsEnvironment.getLocalGraphicsEnvironment()&lt;br /&gt;
            .getAvailableFontFamilyNames();&lt;br /&gt;
&lt;br /&gt;
    private FontSelectionModel selectionModel;&lt;br /&gt;
    private JList fontList;&lt;br /&gt;
    private JList sizeList;&lt;br /&gt;
    private JCheckBox boldCheckBox;&lt;br /&gt;
    private JCheckBox italicCheckBox;&lt;br /&gt;
    private JLabel previewLabel;&lt;br /&gt;
    /** The preview text, if null the font name will be the preview text. */&lt;br /&gt;
    private String previewText;&lt;br /&gt;
    /** Listener used to update the font of the selection model. */&lt;br /&gt;
    private SelectionUpdater selectionUpdater = new SelectionUpdater();&lt;br /&gt;
    /** Listener used to update the font in the components. This should be registered&lt;br /&gt;
     * with the selection model. */&lt;br /&gt;
    private LabelUpdater labelUpdater = new LabelUpdater();&lt;br /&gt;
    /** True if the components are being updated and no event should be generated. */&lt;br /&gt;
    private boolean updatingComponents = false;&lt;br /&gt;
    /** Listener class used to update the font in the components. This should be registered&lt;br /&gt;
      * with the selection model. */&lt;br /&gt;
    private class LabelUpdater implements ChangeListener {&lt;br /&gt;
        public void stateChanged(ChangeEvent e) {&lt;br /&gt;
            updateComponents();&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
    /** Listener class used to update the font of the preview label. */&lt;br /&gt;
    private class SelectionUpdater implements ChangeListener, ListSelectionListener {&lt;br /&gt;
        public void stateChanged(ChangeEvent e) {&lt;br /&gt;
            if (!updatingComponents) {&lt;br /&gt;
                setFont(buildFont());&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
        public void valueChanged(ListSelectionEvent e) {&lt;br /&gt;
            if (!updatingComponents) {&lt;br /&gt;
                setFont(buildFont());&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
    /**&lt;br /&gt;
     * Shows a modal font-chooser dialog and blocks until the&lt;br /&gt;
     * dialog is hidden.  If the user presses the &amp;quot;OK&amp;quot; button, then&lt;br /&gt;
     * this method hides/disposes the dialog and returns the selected color.&lt;br /&gt;
     * If the user presses the &amp;quot;Cancel&amp;quot; button or closes the dialog without&lt;br /&gt;
     * pressing &amp;quot;OK&amp;quot;, then this method hides/disposes the dialog and returns&lt;br /&gt;
     * &amp;lt;code&amp;gt;null&amp;lt;/code&amp;gt;.&lt;br /&gt;
     *&lt;br /&gt;
     * @param component    the parent &amp;lt;code&amp;gt;Component&amp;lt;/code&amp;gt; for the dialog&lt;br /&gt;
     * @param title        the String containing the dialog&amp;quot;s title&lt;br /&gt;
     * @return the selected font or &amp;lt;code&amp;gt;null&amp;lt;/code&amp;gt; if the user opted out&lt;br /&gt;
     * @exception HeadlessException if GraphicsEnvironment.isHeadless()&lt;br /&gt;
     * returns true.&lt;br /&gt;
     * @see java.awt.GraphicsEnvironment#isHeadless&lt;br /&gt;
     */&lt;br /&gt;
    public Font showDialog(Component component, String title) {&lt;br /&gt;
        FontTracker ok = new FontTracker(this);&lt;br /&gt;
        JDialog dialog = createDialog(component, title, true, ok, null);&lt;br /&gt;
        dialog.addWindowListener(new FontChooserDialog.Closer());&lt;br /&gt;
        dialog.addComponentListener(new FontChooserDialog.DisposeOnClose());&lt;br /&gt;
        dialog.setVisible(true); // blocks until user brings dialog down...&lt;br /&gt;
        return ok.getFont();&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    /**&lt;br /&gt;
     * Creates and returns a new dialog containing the specified&lt;br /&gt;
     * &amp;lt;code&amp;gt;ColorChooser&amp;lt;/code&amp;gt; pane along with &amp;quot;OK&amp;quot;, &amp;quot;Cancel&amp;quot;, and &amp;quot;Reset&amp;quot;&lt;br /&gt;
     * buttons. If the &amp;quot;OK&amp;quot; or &amp;quot;Cancel&amp;quot; buttons are pressed, the dialog is&lt;br /&gt;
     * automatically hidden (but not disposed).  If the &amp;quot;Reset&amp;quot;&lt;br /&gt;
     * button is pressed, the color-chooser&amp;quot;s color will be reset to the&lt;br /&gt;
     * font which was set the last time &amp;lt;code&amp;gt;show&amp;lt;/code&amp;gt; was invoked on the&lt;br /&gt;
     * dialog and the dialog will remain showing.&lt;br /&gt;
     *&lt;br /&gt;
     * @param c              the parent component for the dialog&lt;br /&gt;
     * @param title          the title for the dialog&lt;br /&gt;
     * @param modal          a boolean. When true, the remainder of the program&lt;br /&gt;
     *                       is inactive until the dialog is closed.&lt;br /&gt;
     * @param okListener     the ActionListener invoked when &amp;quot;OK&amp;quot; is pressed&lt;br /&gt;
     * @param cancelListener the ActionListener invoked when &amp;quot;Cancel&amp;quot; is pressed&lt;br /&gt;
     * @return a new dialog containing the font-chooser pane&lt;br /&gt;
     * @exception HeadlessException if GraphicsEnvironment.isHeadless()&lt;br /&gt;
     * returns true.&lt;br /&gt;
     * @see java.awt.GraphicsEnvironment#isHeadless&lt;br /&gt;
     */&lt;br /&gt;
    public JDialog createDialog(Component c, String title, boolean modal,&lt;br /&gt;
        ActionListener okListener, ActionListener cancelListener) {&lt;br /&gt;
        return new FontChooserDialog(c, title, modal, this,&lt;br /&gt;
                okListener, cancelListener);&lt;br /&gt;
    }&lt;br /&gt;
    /**&lt;br /&gt;
     * Creates a color chooser pane with an initial font which is the same font&lt;br /&gt;
     * as the default font for labels.&lt;br /&gt;
     */&lt;br /&gt;
    public JFontChooser() {&lt;br /&gt;
        this(new DefaultFontSelectionModel());&lt;br /&gt;
    }&lt;br /&gt;
    /**&lt;br /&gt;
     * Creates a font chooser pane with the specified initial font.&lt;br /&gt;
     *&lt;br /&gt;
     * @param initialFont the initial font set in the chooser&lt;br /&gt;
     */&lt;br /&gt;
    public JFontChooser(Font initialFont) {&lt;br /&gt;
        this(new DefaultFontSelectionModel(initialFont));&lt;br /&gt;
    }&lt;br /&gt;
    /**&lt;br /&gt;
     * Creates a font chooser pane with the specified&lt;br /&gt;
     * &amp;lt;code&amp;gt;FontSelectionModel&amp;lt;/code&amp;gt;.&lt;br /&gt;
     *&lt;br /&gt;
     * @param model the font selection model used by this component&lt;br /&gt;
     */&lt;br /&gt;
    public JFontChooser(FontSelectionModel model) {&lt;br /&gt;
        selectionModel = model;&lt;br /&gt;
        init(model.getSelectedFont());&lt;br /&gt;
        selectionModel.addChangeListener(labelUpdater);&lt;br /&gt;
    }&lt;br /&gt;
    private void init(Font font) {&lt;br /&gt;
        setLayout(new GridBagLayout());&lt;br /&gt;
        Insets ins = new Insets(2, 2, 2, 2);&lt;br /&gt;
        fontList = new JList(FONTS);&lt;br /&gt;
        fontList.setVisibleRowCount(10);&lt;br /&gt;
        fontList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);&lt;br /&gt;
        add(new JScrollPane(fontList), new GridBagConstraints(0, 0, 1, 1, 2, 2,&lt;br /&gt;
                GridBagConstraints.CENTER, GridBagConstraints.BOTH,&lt;br /&gt;
                ins, 0, 0));&lt;br /&gt;
        sizeList = new JList(SIZES);&lt;br /&gt;
        ((JLabel)sizeList.getCellRenderer()).setHorizontalAlignment(JLabel.RIGHT);&lt;br /&gt;
        sizeList.setVisibleRowCount(10);&lt;br /&gt;
        sizeList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);&lt;br /&gt;
        add(new JScrollPane(sizeList), new GridBagConstraints(1, 0, 1, 1, 1, 2,&lt;br /&gt;
                GridBagConstraints.CENTER, GridBagConstraints.BOTH,&lt;br /&gt;
                ins, 0, 0));&lt;br /&gt;
        boldCheckBox = new JCheckBox(&amp;quot;Bold&amp;quot;);&lt;br /&gt;
        add(boldCheckBox, new GridBagConstraints(0, 1, 2, 1, 1, 0,&lt;br /&gt;
                GridBagConstraints.WEST, GridBagConstraints.NONE,&lt;br /&gt;
                ins, 0, 0));&lt;br /&gt;
        italicCheckBox = new JCheckBox(&amp;quot;Italic&amp;quot;);&lt;br /&gt;
        add(italicCheckBox, new GridBagConstraints(0, 2, 2, 1, 1, 0,&lt;br /&gt;
                GridBagConstraints.WEST, GridBagConstraints.NONE,&lt;br /&gt;
                ins, 0, 0));&lt;br /&gt;
        previewLabel = new JLabel(&amp;quot;&amp;quot;);&lt;br /&gt;
        previewLabel.setHorizontalAlignment(JLabel.CENTER);&lt;br /&gt;
        previewLabel.setVerticalAlignment(JLabel.CENTER);&lt;br /&gt;
        add(new JScrollPane(previewLabel), new GridBagConstraints(0, 3, 2, 1, 1, 1,&lt;br /&gt;
                GridBagConstraints.CENTER, GridBagConstraints.BOTH,&lt;br /&gt;
                ins, 0, 0));&lt;br /&gt;
        setFont(font == null ? previewLabel.getFont() : font);&lt;br /&gt;
        fontList.addListSelectionListener(selectionUpdater);&lt;br /&gt;
        sizeList.addListSelectionListener(selectionUpdater);&lt;br /&gt;
        boldCheckBox.addChangeListener(selectionUpdater);&lt;br /&gt;
        italicCheckBox.addChangeListener(selectionUpdater);&lt;br /&gt;
    }&lt;br /&gt;
    private Font buildFont() {&lt;br /&gt;
//        Font labelFont = previewLabel.getFont();&lt;br /&gt;
        String fontName = (String)fontList.getSelectedValue();&lt;br /&gt;
        if (fontName == null) {&lt;br /&gt;
            return null;&lt;br /&gt;
//            fontName = labelFont.getName();&lt;br /&gt;
        }&lt;br /&gt;
        Integer sizeInt = (Integer)sizeList.getSelectedValue();&lt;br /&gt;
        if (sizeInt == null) {&lt;br /&gt;
//            size = labelFont.getSize();&lt;br /&gt;
            return null;&lt;br /&gt;
        }&lt;br /&gt;
        // create the font&lt;br /&gt;
//        // first create the font attributes&lt;br /&gt;
//        HashMap map = new HashMap();&lt;br /&gt;
//        map.put(TextAttribute.BACKGROUND, Color.white);&lt;br /&gt;
//        map.put(TextAttribute.FAMILY, fontName);&lt;br /&gt;
//        map.put(TextAttribute.FOREGROUND, Color.black);&lt;br /&gt;
//        map.put(TextAttribute.SIZE , new Float(size));&lt;br /&gt;
//        map.put(TextAttribute.UNDERLINE, italicCheckBox.isSelected() ? TextAttribute.UNDERLINE_LOW_ONE_PIXEL : TextAttribute.UNDERLINE_LOW_TWO_PIXEL);&lt;br /&gt;
//        map.put(TextAttribute.STRIKETHROUGH, italicCheckBox.isSelected() ? TextAttribute.STRIKETHROUGH_ON : Boolean.FALSE);&lt;br /&gt;
//        map.put(TextAttribute.WEIGHT, boldCheckBox.isSelected() ? TextAttribute.WEIGHT_BOLD : TextAttribute.WEIGHT_REGULAR);&lt;br /&gt;
//        map.put(TextAttribute.POSTURE,&lt;br /&gt;
//                italicCheckBox.isSelected() ? TextAttribute.POSTURE_OBLIQUE : TextAttribute.POSTURE_REGULAR);&lt;br /&gt;
//&lt;br /&gt;
//        return new Font(map);&lt;br /&gt;
        return new Font(fontName,&lt;br /&gt;
                (italicCheckBox.isSelected() ? Font.ITALIC : Font.PLAIN)&lt;br /&gt;
                | (boldCheckBox.isSelected() ? Font.BOLD : Font.PLAIN),&lt;br /&gt;
                sizeInt);&lt;br /&gt;
    }&lt;br /&gt;
    /** Updates the font in the preview component according to the selected values. */&lt;br /&gt;
    private void updateComponents() {&lt;br /&gt;
        updatingComponents = true;&lt;br /&gt;
        Font font = getFont();&lt;br /&gt;
        fontList.setSelectedValue(font.getName(), true);&lt;br /&gt;
        sizeList.setSelectedValue(font.getSize(), true);&lt;br /&gt;
        boldCheckBox.setSelected(font.isBold());&lt;br /&gt;
        italicCheckBox.setSelected(font.isItalic());&lt;br /&gt;
        if (previewText == null) {&lt;br /&gt;
            previewLabel.setText(font.getName());&lt;br /&gt;
        }&lt;br /&gt;
        // set the font and fire a property change&lt;br /&gt;
        Font oldValue = previewLabel.getFont();&lt;br /&gt;
        previewLabel.setFont(font);&lt;br /&gt;
        firePropertyChange(&amp;quot;font&amp;quot;, oldValue, font);&lt;br /&gt;
        updatingComponents = false;&lt;br /&gt;
    }&lt;br /&gt;
    /**&lt;br /&gt;
     * Returns the data model that handles font selections.&lt;br /&gt;
     *&lt;br /&gt;
     * @return a FontSelectionModel object&lt;br /&gt;
     */&lt;br /&gt;
    public FontSelectionModel getSelectionModel() {&lt;br /&gt;
        return selectionModel;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    /**&lt;br /&gt;
     * Set the model containing the selected font.&lt;br /&gt;
     *&lt;br /&gt;
     * @param newModel   the new FontSelectionModel object&lt;br /&gt;
     */&lt;br /&gt;
    public void setSelectionModel(FontSelectionModel newModel ) {&lt;br /&gt;
        FontSelectionModel oldModel = selectionModel;&lt;br /&gt;
        selectionModel = newModel;&lt;br /&gt;
        oldModel.removeChangeListener(labelUpdater);&lt;br /&gt;
        newModel.addChangeListener(labelUpdater);&lt;br /&gt;
        firePropertyChange(&amp;quot;selectionModel&amp;quot;, oldModel, newModel);&lt;br /&gt;
    }&lt;br /&gt;
    /**&lt;br /&gt;
     * Gets the current font value from the font chooser.&lt;br /&gt;
     *&lt;br /&gt;
     * @return the current font value of the font chooser&lt;br /&gt;
     */&lt;br /&gt;
    public Font getFont() {&lt;br /&gt;
        return selectionModel.getSelectedFont();&lt;br /&gt;
    }&lt;br /&gt;
    /**&lt;br /&gt;
     * Sets the current font of the font chooser to the specified font.&lt;br /&gt;
     * The &amp;lt;code&amp;gt;ColorSelectionModel&amp;lt;/code&amp;gt; will fire a &amp;lt;code&amp;gt;ChangeEvent&amp;lt;/code&amp;gt;&lt;br /&gt;
     * @param font the font to be set in the font chooser&lt;br /&gt;
     * @see JComponent#addPropertyChangeListener&lt;br /&gt;
     */&lt;br /&gt;
    public void setFont(Font font) {&lt;br /&gt;
        selectionModel.setSelectedFont(font);&lt;br /&gt;
    }&lt;br /&gt;
    /** Returns the preview text displayed in the preview component.&lt;br /&gt;
     * @return the preview text, if null the font name will be displayed&lt;br /&gt;
     */&lt;br /&gt;
    public String getPreviewText() {&lt;br /&gt;
        return previewText;&lt;br /&gt;
    }&lt;br /&gt;
    /** Sets the preview text displayed in the preview component.&lt;br /&gt;
     * @param previewText the preview text, if null the font name will be displayed&lt;br /&gt;
     */&lt;br /&gt;
    public void setPreviewText(String previewText) {&lt;br /&gt;
        this.previewText = previewText;&lt;br /&gt;
        previewLabel.setText(&amp;quot;&amp;quot;);&lt;br /&gt;
        updateComponents();&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
/*&lt;br /&gt;
 * Class which builds a font chooser dialog consisting of&lt;br /&gt;
 * a JFontChooser with &amp;quot;Ok&amp;quot;, &amp;quot;Cancel&amp;quot;, and &amp;quot;Reset&amp;quot; buttons.&lt;br /&gt;
 *&lt;br /&gt;
 * Note: This needs to be fixed to deal with localization!&lt;br /&gt;
 */&lt;br /&gt;
class FontChooserDialog extends JDialog {&lt;br /&gt;
    private Font initialFont;&lt;br /&gt;
    private JFontChooser chooserPane;&lt;br /&gt;
    public FontChooserDialog(Component c, String title, boolean modal,&lt;br /&gt;
              JFontChooser chooserPane,&lt;br /&gt;
              ActionListener okListener, ActionListener cancelListener) {&lt;br /&gt;
        super(JOptionPane.getFrameForComponent(c), title, modal);&lt;br /&gt;
        //setResizable(false);&lt;br /&gt;
        String okString = UIManager.getString(&amp;quot;ColorChooser.okText&amp;quot;);&lt;br /&gt;
        String cancelString = UIManager.getString(&amp;quot;ColorChooser.cancelText&amp;quot;);&lt;br /&gt;
        String resetString = UIManager.getString(&amp;quot;ColorChooser.resetText&amp;quot;);&lt;br /&gt;
        /*&lt;br /&gt;
         * Create Lower button panel&lt;br /&gt;
         */&lt;br /&gt;
        JPanel buttonPane = new JPanel();&lt;br /&gt;
        buttonPane.setLayout(new FlowLayout(FlowLayout.CENTER));&lt;br /&gt;
        JButton okButton = new JButton(okString);&lt;br /&gt;
        getRootPane().setDefaultButton(okButton);&lt;br /&gt;
        okButton.setActionCommand(&amp;quot;OK&amp;quot;);&lt;br /&gt;
        if (okListener != null) {&lt;br /&gt;
            okButton.addActionListener(okListener);&lt;br /&gt;
        }&lt;br /&gt;
        okButton.addActionListener(new ActionListener() {&lt;br /&gt;
            public void actionPerformed(ActionEvent e) {&lt;br /&gt;
                setVisible(false);&lt;br /&gt;
            }&lt;br /&gt;
        });&lt;br /&gt;
        buttonPane.add(okButton);&lt;br /&gt;
        JButton cancelButton = new JButton(cancelString);&lt;br /&gt;
        // The following few lines are used to register esc to close the dialog&lt;br /&gt;
        Action cancelKeyAction = new AbstractAction() {&lt;br /&gt;
            public void actionPerformed(ActionEvent e) {&lt;br /&gt;
                // todo make it in 1.3&lt;br /&gt;
//                ActionListener[] listeners&lt;br /&gt;
//                        = ((AbstractButton) e.getSource()).getActionListeners();&lt;br /&gt;
//                for (int i = 0; i &amp;lt; listeners.length; i++) {&lt;br /&gt;
//                    listeners[i].actionPerformed(e);&lt;br /&gt;
//                }&lt;br /&gt;
            }&lt;br /&gt;
        };&lt;br /&gt;
        KeyStroke cancelKeyStroke = KeyStroke.getKeyStroke((char) KeyEvent.VK_ESCAPE);&lt;br /&gt;
        InputMap inputMap = cancelButton.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);&lt;br /&gt;
        ActionMap actionMap = cancelButton.getActionMap();&lt;br /&gt;
        if (inputMap != null &amp;amp;&amp;amp; actionMap != null) {&lt;br /&gt;
            inputMap.put(cancelKeyStroke, &amp;quot;cancel&amp;quot;);&lt;br /&gt;
            actionMap.put(&amp;quot;cancel&amp;quot;, cancelKeyAction);&lt;br /&gt;
        }&lt;br /&gt;
        // end esc handling&lt;br /&gt;
        cancelButton.setActionCommand(&amp;quot;cancel&amp;quot;);&lt;br /&gt;
        if (cancelListener != null) {&lt;br /&gt;
            cancelButton.addActionListener(cancelListener);&lt;br /&gt;
        }&lt;br /&gt;
        cancelButton.addActionListener(new ActionListener() {&lt;br /&gt;
            public void actionPerformed(ActionEvent e) {&lt;br /&gt;
                setVisible(false);&lt;br /&gt;
            }&lt;br /&gt;
        });&lt;br /&gt;
        buttonPane.add(cancelButton);&lt;br /&gt;
        JButton resetButton = new JButton(resetString);&lt;br /&gt;
        resetButton.addActionListener(new ActionListener() {&lt;br /&gt;
            public void actionPerformed(ActionEvent e) {&lt;br /&gt;
                reset();&lt;br /&gt;
            }&lt;br /&gt;
        });&lt;br /&gt;
        int mnemonic = UIManager.getInt(&amp;quot;ColorChooser.resetMnemonic&amp;quot;);&lt;br /&gt;
        if (mnemonic != -1) {&lt;br /&gt;
            resetButton.setMnemonic(mnemonic);&lt;br /&gt;
        }&lt;br /&gt;
        buttonPane.add(resetButton);&lt;br /&gt;
&lt;br /&gt;
        // initialiase the content pane&lt;br /&gt;
        this.chooserPane = chooserPane;&lt;br /&gt;
        Container contentPane = getContentPane();&lt;br /&gt;
        contentPane.setLayout(new BorderLayout());&lt;br /&gt;
        contentPane.add(chooserPane, BorderLayout.CENTER);&lt;br /&gt;
        contentPane.add(buttonPane, BorderLayout.SOUTH);&lt;br /&gt;
        pack();&lt;br /&gt;
        setLocationRelativeTo(c);&lt;br /&gt;
    }&lt;br /&gt;
    public void setVisible(boolean visible) {&lt;br /&gt;
        if (visible)&lt;br /&gt;
            initialFont = chooserPane.getFont();&lt;br /&gt;
        super.setVisible(visible);&lt;br /&gt;
    }&lt;br /&gt;
    public void reset() {&lt;br /&gt;
        chooserPane.setFont(initialFont);&lt;br /&gt;
    }&lt;br /&gt;
    static class Closer extends WindowAdapter implements Serializable {&lt;br /&gt;
        public void windowClosing(WindowEvent e) {&lt;br /&gt;
            Window w = e.getWindow();&lt;br /&gt;
            w.setVisible(false);&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
    static class DisposeOnClose extends ComponentAdapter implements Serializable {&lt;br /&gt;
        public void componentHidden(ComponentEvent e) {&lt;br /&gt;
            Window w = (Window) e.getComponent();&lt;br /&gt;
            w.dispose();&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
class FontTracker implements ActionListener, Serializable {&lt;br /&gt;
    JFontChooser chooser;&lt;br /&gt;
    Font color;&lt;br /&gt;
    public FontTracker(JFontChooser c) {&lt;br /&gt;
        chooser = c;&lt;br /&gt;
    }&lt;br /&gt;
    public void actionPerformed(ActionEvent e) {&lt;br /&gt;
        color = chooser.getFont();&lt;br /&gt;
    }&lt;br /&gt;
    public Font getFont() {&lt;br /&gt;
        return color;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
/**&lt;br /&gt;
 * A generic implementation of &amp;lt;code&amp;gt;{@link FontSelectionModel}&amp;lt;/code&amp;gt;.&lt;br /&gt;
 *&lt;br /&gt;
 * @author Adrian BER&lt;br /&gt;
 */&lt;br /&gt;
class DefaultFontSelectionModel implements FontSelectionModel {&lt;br /&gt;
    /** The default selected font. */&lt;br /&gt;
    private static final Font DEFAULT_INITIAL_FONT = new Font(&amp;quot;Dialog&amp;quot;, Font.PLAIN, 12);&lt;br /&gt;
    &lt;br /&gt;
    /** The selected font. */&lt;br /&gt;
    private Font selectedFont;&lt;br /&gt;
    /** The change listeners notified by a change in this model. */&lt;br /&gt;
    private EventListenerList listeners = new EventListenerList();&lt;br /&gt;
    /**&lt;br /&gt;
     * Creates a &amp;lt;code&amp;gt;DefaultFontSelectionModel&amp;lt;/code&amp;gt; with the&lt;br /&gt;
     * current font set to &amp;lt;code&amp;gt;Dialog, 12&amp;lt;/code&amp;gt;.  This is&lt;br /&gt;
     * the default constructor.&lt;br /&gt;
     */&lt;br /&gt;
    public DefaultFontSelectionModel() {&lt;br /&gt;
        this(DEFAULT_INITIAL_FONT);&lt;br /&gt;
    }&lt;br /&gt;
    /**&lt;br /&gt;
     * Creates a &amp;lt;code&amp;gt;DefaultFontSelectionModel&amp;lt;/code&amp;gt; with the&lt;br /&gt;
     * current font set to &amp;lt;code&amp;gt;font&amp;lt;/code&amp;gt;, which should be&lt;br /&gt;
     * non-&amp;lt;code&amp;gt;null&amp;lt;/code&amp;gt;.  Note that setting the font to&lt;br /&gt;
     * &amp;lt;code&amp;gt;null&amp;lt;/code&amp;gt; is undefined and may have unpredictable&lt;br /&gt;
     * results.&lt;br /&gt;
     *&lt;br /&gt;
     * @param selectedFont the new &amp;lt;code&amp;gt;Font&amp;lt;/code&amp;gt;&lt;br /&gt;
     */&lt;br /&gt;
    public DefaultFontSelectionModel(Font selectedFont) {&lt;br /&gt;
        if (selectedFont == null) {&lt;br /&gt;
            selectedFont = DEFAULT_INITIAL_FONT;&lt;br /&gt;
        }&lt;br /&gt;
        this.selectedFont = selectedFont;&lt;br /&gt;
    }&lt;br /&gt;
    public Font getSelectedFont() {&lt;br /&gt;
        return selectedFont;&lt;br /&gt;
    }&lt;br /&gt;
    public void setSelectedFont(Font selectedFont) {&lt;br /&gt;
        if (selectedFont != null) {&lt;br /&gt;
            this.selectedFont = selectedFont;&lt;br /&gt;
            fireChangeListeners();&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
    public void addChangeListener(ChangeListener listener) {&lt;br /&gt;
        listeners.add(ChangeListener.class, listener);&lt;br /&gt;
    }&lt;br /&gt;
    public void removeChangeListener(ChangeListener listener) {&lt;br /&gt;
        listeners.remove(ChangeListener.class, listener);&lt;br /&gt;
    }&lt;br /&gt;
    /** Fires the listeners registered with this model. */&lt;br /&gt;
    protected void fireChangeListeners() {&lt;br /&gt;
        ChangeEvent ev = new ChangeEvent(this);&lt;br /&gt;
        Object[] l = listeners.getListeners(ChangeListener.class);&lt;br /&gt;
        for (Object listener : l) {&lt;br /&gt;
            ((ChangeListener) listener).stateChanged(ev);&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
/**&lt;br /&gt;
 * A model that supports selecting a &amp;lt;code&amp;gt;Font&amp;lt;/code&amp;gt;.&lt;br /&gt;
 *&lt;br /&gt;
 * @author Adrian BER&lt;br /&gt;
 *&lt;br /&gt;
 * @see java.awt.Font&lt;br /&gt;
 */&lt;br /&gt;
interface FontSelectionModel {&lt;br /&gt;
    /**&lt;br /&gt;
     * Returns the selected &amp;lt;code&amp;gt;Font&amp;lt;/code&amp;gt; which should be&lt;br /&gt;
     * non-&amp;lt;code&amp;gt;null&amp;lt;/code&amp;gt;.&lt;br /&gt;
     *&lt;br /&gt;
     * @return  the selected &amp;lt;code&amp;gt;Font&amp;lt;/code&amp;gt;&lt;br /&gt;
     * @see     #setSelectedFont&lt;br /&gt;
     */&lt;br /&gt;
    Font getSelectedFont();&lt;br /&gt;
    /**&lt;br /&gt;
     * Sets the selected font to &amp;lt;code&amp;gt;font&amp;lt;/code&amp;gt;.&lt;br /&gt;
     * Note that setting the font to &amp;lt;code&amp;gt;null&amp;lt;/code&amp;gt;&lt;br /&gt;
     * is undefined and may have unpredictable results.&lt;br /&gt;
     * This method fires a state changed event if it sets the&lt;br /&gt;
     * current font to a new non-&amp;lt;code&amp;gt;null&amp;lt;/code&amp;gt; font.&lt;br /&gt;
     *&lt;br /&gt;
     * @param font the new &amp;lt;code&amp;gt;Font&amp;lt;/code&amp;gt;&lt;br /&gt;
     * @see   #getSelectedFont&lt;br /&gt;
     * @see   #addChangeListener&lt;br /&gt;
     */&lt;br /&gt;
    void setSelectedFont(Font font);&lt;br /&gt;
    /**&lt;br /&gt;
     * Adds &amp;lt;code&amp;gt;listener&amp;lt;/code&amp;gt; as a listener to changes in the model.&lt;br /&gt;
     * @param listener the &amp;lt;code&amp;gt;ChangeListener&amp;lt;/code&amp;gt; to be added&lt;br /&gt;
     */&lt;br /&gt;
    void addChangeListener(ChangeListener listener);&lt;br /&gt;
    /**&lt;br /&gt;
     * Removes &amp;lt;code&amp;gt;listener&amp;lt;/code&amp;gt; as a listener to changes in the model.&lt;br /&gt;
     * @param listener the &amp;lt;code&amp;gt;ChangeListener&amp;lt;/code&amp;gt; to be removed&lt;br /&gt;
     */&lt;br /&gt;
    void removeChangeListener(ChangeListener listener);&lt;br /&gt;
}&lt;br /&gt;
//////////////////////////////&lt;br /&gt;
package com.greef.ui.font;&lt;br /&gt;
import com.greef.ui.UIUtilities;&lt;br /&gt;
import javax.swing.*;&lt;br /&gt;
import javax.swing.event.ChangeListener;&lt;br /&gt;
import javax.swing.event.ChangeEvent;&lt;br /&gt;
import javax.swing.event.DocumentListener;&lt;br /&gt;
import javax.swing.event.DocumentEvent;&lt;br /&gt;
import java.awt.*;&lt;br /&gt;
import java.awt.event.ActionListener;&lt;br /&gt;
import java.awt.event.ActionEvent;&lt;br /&gt;
/**&lt;br /&gt;
 * @author Adrian BER (beradrian@yahoo.ru)&lt;br /&gt;
 */&lt;br /&gt;
public class JFontChooserDemo extends JPanel {&lt;br /&gt;
    private static final Insets INSETS = new Insets(5, 5, 5, 5);&lt;br /&gt;
    private JFontChooser fontChooser;&lt;br /&gt;
    private JCheckBox defaultPreviewCheckBox;&lt;br /&gt;
    private JTextField previewTextField;&lt;br /&gt;
    private JLabel previewLabel;&lt;br /&gt;
    private JTextArea codeTextArea;&lt;br /&gt;
    public JFontChooserDemo() {&lt;br /&gt;
        init();&lt;br /&gt;
    }&lt;br /&gt;
    private void init() {&lt;br /&gt;
        setLayout(new GridBagLayout());&lt;br /&gt;
        defaultPreviewCheckBox = new JCheckBox(&amp;quot;Use font name as the preview text&amp;quot;);&lt;br /&gt;
        defaultPreviewCheckBox.addChangeListener(new ChangeListener() {&lt;br /&gt;
            public void stateChanged(ChangeEvent e) {&lt;br /&gt;
                boolean selected = defaultPreviewCheckBox.isSelected();&lt;br /&gt;
                fontChooser.setPreviewText(selected ? null : previewTextField.getText());&lt;br /&gt;
                previewLabel.setEnabled(!selected);&lt;br /&gt;
                previewTextField.setEnabled(!selected);&lt;br /&gt;
                updateCode();&lt;br /&gt;
            }&lt;br /&gt;
        });&lt;br /&gt;
        add(defaultPreviewCheckBox, new GridBagConstraints(0, 0, 2, 1, 0, 0, GridBagConstraints.WEST,&lt;br /&gt;
                GridBagConstraints.NONE, INSETS, 0, 0));&lt;br /&gt;
        previewLabel = new JLabel(&amp;quot;Preview text:&amp;quot;);&lt;br /&gt;
        add(previewLabel, new GridBagConstraints(0, 1, 1, 1, 0, 0, GridBagConstraints.EAST,&lt;br /&gt;
                GridBagConstraints.NONE, INSETS, 0, 0));&lt;br /&gt;
        previewTextField = new JTextField();&lt;br /&gt;
        previewTextField.getDocument().addDocumentListener(new DocumentListener() {&lt;br /&gt;
            private void changePreviewText() {&lt;br /&gt;
                fontChooser.setPreviewText(previewTextField.getText());&lt;br /&gt;
                updateCode();&lt;br /&gt;
            }&lt;br /&gt;
            public void insertUpdate(DocumentEvent e) {&lt;br /&gt;
                changePreviewText();&lt;br /&gt;
            }&lt;br /&gt;
            public void removeUpdate(DocumentEvent e) {&lt;br /&gt;
                changePreviewText();&lt;br /&gt;
            }&lt;br /&gt;
            public void changedUpdate(DocumentEvent e) {&lt;br /&gt;
                changePreviewText();&lt;br /&gt;
            }&lt;br /&gt;
        });&lt;br /&gt;
        add(previewTextField, new GridBagConstraints(1, 1, 1, 1, 1, 0, GridBagConstraints.WEST,&lt;br /&gt;
                GridBagConstraints.HORIZONTAL, INSETS, 0, 0));&lt;br /&gt;
        JButton testButton = new JButton(&amp;quot;Test&amp;quot;);&lt;br /&gt;
        testButton.addActionListener(new ActionListener() {&lt;br /&gt;
            public void actionPerformed(ActionEvent e) {&lt;br /&gt;
                Font font = fontChooser.showDialog(JFontChooserDemo.this, &amp;quot;Choose a font&amp;quot;);&lt;br /&gt;
                JOptionPane.showMessageDialog(JFontChooserDemo.this, font == null ? &amp;quot;You canceled the dialog.&amp;quot;&lt;br /&gt;
                        : &amp;quot;You have selected &amp;quot; + font.getName() + &amp;quot;, &amp;quot; + font.getSize()&lt;br /&gt;
                        + (font.isBold() ? &amp;quot;, Bold&amp;quot; : &amp;quot;&amp;quot;) + (font.isItalic() ? &amp;quot;, Italic&amp;quot; : &amp;quot;&amp;quot;));&lt;br /&gt;
            }&lt;br /&gt;
        });&lt;br /&gt;
        add(testButton, new GridBagConstraints(0, 2, 2, 1, 1, 0, GridBagConstraints.NORTHEAST,&lt;br /&gt;
                GridBagConstraints.NONE, INSETS, 0, 0));&lt;br /&gt;
        codeTextArea = new JTextArea(5, 30);&lt;br /&gt;
        codeTextArea.setOpaque(false);&lt;br /&gt;
        codeTextArea.setEditable(false);&lt;br /&gt;
        codeTextArea.setBorder(BorderFactory.createTitledBorder(&amp;quot;Code&amp;quot;));&lt;br /&gt;
        add(codeTextArea, new GridBagConstraints(0, 3, 2, 1, 1, 1, GridBagConstraints.CENTER,&lt;br /&gt;
                GridBagConstraints.BOTH, INSETS, 0, 0));&lt;br /&gt;
        setFontChooser(new JFontChooser());&lt;br /&gt;
    }&lt;br /&gt;
    private void setFontChooser(JFontChooser fontChooser) {&lt;br /&gt;
        this.fontChooser = fontChooser;&lt;br /&gt;
        String previewText = fontChooser.getPreviewText();&lt;br /&gt;
        defaultPreviewCheckBox.setSelected(previewText == null);&lt;br /&gt;
        previewTextField.setText(previewText);&lt;br /&gt;
        updateCode();&lt;br /&gt;
    }&lt;br /&gt;
    private void updateCode() {&lt;br /&gt;
        codeTextArea.setText(&amp;quot;JFontChooser fontChooser = new JFontChooser();\n&amp;quot;&lt;br /&gt;
                + (defaultPreviewCheckBox.isSelected() ? &amp;quot;&amp;quot; : &amp;quot;fontChooser.setPreviewText(\&amp;quot;&amp;quot;&lt;br /&gt;
                    + previewTextField.getText() + &amp;quot;\&amp;quot;);\n&amp;quot;)&lt;br /&gt;
                + &amp;quot;Font font = fontChooser.showDialog(invokerComponent, \&amp;quot;Choose a font\&amp;quot;);\n&amp;quot;&lt;br /&gt;
                + &amp;quot;System.out.println(font == null ? \&amp;quot;You have canceled the dialog.\&amp;quot; : \&amp;quot;You have selected \&amp;quot; + font);&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
    public void updateUI() {&lt;br /&gt;
        super.updateUI();&lt;br /&gt;
        if (fontChooser != null)&lt;br /&gt;
            SwingUtilities.updateComponentTreeUI(fontChooser);&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
   &lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== JFreeChart: Font Dialog ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Word like special font chooser ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
/*&lt;br /&gt;
 * @(#)Font2DTest.java  1.28 05/11/17&lt;br /&gt;
 * &lt;br /&gt;
 * Copyright (c) 2006 Sun Microsystems, Inc. All Rights Reserved.&lt;br /&gt;
 * &lt;br /&gt;
 * Redistribution and use in source and binary forms, with or without&lt;br /&gt;
 * modification, are permitted provided that the following conditions are met:&lt;br /&gt;
 * &lt;br /&gt;
 * -Redistribution of source code must retain the above copyright notice, this&lt;br /&gt;
 *  list of conditions and the following disclaimer.&lt;br /&gt;
 * &lt;br /&gt;
 * -Redistribution in binary form must reproduce the above copyright notice, &lt;br /&gt;
 *  this list of conditions and the following disclaimer in the documentation&lt;br /&gt;
 *  and/or other materials provided with the distribution.&lt;br /&gt;
 * &lt;br /&gt;
 * Neither the name of Sun Microsystems, Inc. or the names of contributors may &lt;br /&gt;
 * be used to endorse or promote products derived from this software without &lt;br /&gt;
 * specific prior written permission.&lt;br /&gt;
 * &lt;br /&gt;
 * This software is provided &amp;quot;AS IS,&amp;quot; without a warranty of any kind. ALL &lt;br /&gt;
 * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING&lt;br /&gt;
 * ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE&lt;br /&gt;
 * OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN MIDROSYSTEMS, INC. (&amp;quot;SUN&amp;quot;)&lt;br /&gt;
 * AND ITS LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE&lt;br /&gt;
 * AS A RESULT OF USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS&lt;br /&gt;
 * DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR ANY LOST &lt;br /&gt;
 * REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, &lt;br /&gt;
 * INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY &lt;br /&gt;
 * OF LIABILITY, ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, &lt;br /&gt;
 * EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.&lt;br /&gt;
 * &lt;br /&gt;
 * You acknowledge that this software is not designed, licensed or intended&lt;br /&gt;
 * for use in the design, construction, operation or maintenance of any&lt;br /&gt;
 * nuclear facility.&lt;br /&gt;
 */&lt;br /&gt;
/*&lt;br /&gt;
 * @(#)Font2DTest.java  1.28 05/11/17&lt;br /&gt;
 */&lt;br /&gt;
import static java.awt.RenderingHints.KEY_ANTIALIASING;&lt;br /&gt;
import static java.awt.RenderingHints.KEY_FRACTIONALMETRICS;&lt;br /&gt;
import static java.awt.RenderingHints.KEY_TEXT_ANTIALIASING;&lt;br /&gt;
import static java.awt.RenderingHints.KEY_TEXT_LCD_CONTRAST;&lt;br /&gt;
import static java.awt.RenderingHints.VALUE_ANTIALIAS_OFF;&lt;br /&gt;
import static java.awt.RenderingHints.VALUE_ANTIALIAS_ON;&lt;br /&gt;
import static java.awt.RenderingHints.VALUE_FRACTIONALMETRICS_DEFAULT;&lt;br /&gt;
import static java.awt.RenderingHints.VALUE_FRACTIONALMETRICS_OFF;&lt;br /&gt;
import static java.awt.RenderingHints.VALUE_FRACTIONALMETRICS_ON;&lt;br /&gt;
import static java.awt.RenderingHints.VALUE_TEXT_ANTIALIAS_DEFAULT;&lt;br /&gt;
import static java.awt.RenderingHints.VALUE_TEXT_ANTIALIAS_GASP;&lt;br /&gt;
import static java.awt.RenderingHints.VALUE_TEXT_ANTIALIAS_LCD_HBGR;&lt;br /&gt;
import static java.awt.RenderingHints.VALUE_TEXT_ANTIALIAS_LCD_HRGB;&lt;br /&gt;
import static java.awt.RenderingHints.VALUE_TEXT_ANTIALIAS_LCD_VBGR;&lt;br /&gt;
import static java.awt.RenderingHints.VALUE_TEXT_ANTIALIAS_LCD_VRGB;&lt;br /&gt;
import static java.awt.RenderingHints.VALUE_TEXT_ANTIALIAS_OFF;&lt;br /&gt;
import static java.awt.RenderingHints.VALUE_TEXT_ANTIALIAS_ON;&lt;br /&gt;
import java.awt.BorderLayout;&lt;br /&gt;
import java.awt.Color;&lt;br /&gt;
import java.awt.ruponent;&lt;br /&gt;
import java.awt.Container;&lt;br /&gt;
import java.awt.Cursor;&lt;br /&gt;
import java.awt.Dimension;&lt;br /&gt;
import java.awt.Font;&lt;br /&gt;
import java.awt.FontMetrics;&lt;br /&gt;
import java.awt.Graphics;&lt;br /&gt;
import java.awt.Graphics2D;&lt;br /&gt;
import java.awt.GraphicsConfiguration;&lt;br /&gt;
import java.awt.GraphicsEnvironment;&lt;br /&gt;
import java.awt.GridBagConstraints;&lt;br /&gt;
import java.awt.GridBagLayout;&lt;br /&gt;
import java.awt.GridLayout;&lt;br /&gt;
import java.awt.Insets;&lt;br /&gt;
import java.awt.Point;&lt;br /&gt;
import java.awt.RenderingHints;&lt;br /&gt;
import java.awt.Toolkit;&lt;br /&gt;
import java.awt.event.ActionEvent;&lt;br /&gt;
import java.awt.event.ActionListener;&lt;br /&gt;
import java.awt.event.AdjustmentEvent;&lt;br /&gt;
import java.awt.event.AdjustmentListener;&lt;br /&gt;
import java.awt.event.ruponentAdapter;&lt;br /&gt;
import java.awt.event.ruponentEvent;&lt;br /&gt;
import java.awt.event.ItemEvent;&lt;br /&gt;
import java.awt.event.ItemListener;&lt;br /&gt;
import java.awt.event.MouseEvent;&lt;br /&gt;
import java.awt.event.MouseListener;&lt;br /&gt;
import java.awt.event.MouseMotionListener;&lt;br /&gt;
import java.awt.event.WindowAdapter;&lt;br /&gt;
import java.awt.event.WindowEvent;&lt;br /&gt;
import java.awt.font.FontRenderContext;&lt;br /&gt;
import java.awt.font.GlyphVector;&lt;br /&gt;
import java.awt.font.LineBreakMeasurer;&lt;br /&gt;
import java.awt.font.TextLayout;&lt;br /&gt;
import java.awt.geom.AffineTransform;&lt;br /&gt;
import java.awt.geom.NoninvertibleTransformException;&lt;br /&gt;
import java.awt.geom.Rectangle2D;&lt;br /&gt;
import java.awt.image.BufferedImage;&lt;br /&gt;
import java.awt.print.PageFormat;&lt;br /&gt;
import java.awt.print.Printable;&lt;br /&gt;
import java.awt.print.PrinterJob;&lt;br /&gt;
import java.io.BufferedInputStream;&lt;br /&gt;
import java.io.BufferedOutputStream;&lt;br /&gt;
import java.io.File;&lt;br /&gt;
import java.io.FileInputStream;&lt;br /&gt;
import java.io.FileOutputStream;&lt;br /&gt;
import java.text.AttributedString;&lt;br /&gt;
import java.util.BitSet;&lt;br /&gt;
import java.util.EnumSet;&lt;br /&gt;
import java.util.StringTokenizer;&lt;br /&gt;
import java.util.Vector;&lt;br /&gt;
import javax.imageio.ImageIO;&lt;br /&gt;
import javax.swing.ButtonGroup;&lt;br /&gt;
import javax.swing.DefaultListCellRenderer;&lt;br /&gt;
import javax.swing.ImageIcon;&lt;br /&gt;
import javax.swing.JButton;&lt;br /&gt;
import javax.swing.JCheckBoxMenuItem;&lt;br /&gt;
import javax.swing.JComboBox;&lt;br /&gt;
import javax.swing.JComponent;&lt;br /&gt;
import javax.swing.JDialog;&lt;br /&gt;
import javax.swing.JFileChooser;&lt;br /&gt;
import javax.swing.JFrame;&lt;br /&gt;
import javax.swing.JLabel;&lt;br /&gt;
import javax.swing.JList;&lt;br /&gt;
import javax.swing.JMenu;&lt;br /&gt;
import javax.swing.JMenuBar;&lt;br /&gt;
import javax.swing.JMenuItem;&lt;br /&gt;
import javax.swing.JPanel;&lt;br /&gt;
import javax.swing.JRadioButton;&lt;br /&gt;
import javax.swing.JScrollBar;&lt;br /&gt;
import javax.swing.JScrollPane;&lt;br /&gt;
import javax.swing.JSlider;&lt;br /&gt;
import javax.swing.JTextArea;&lt;br /&gt;
import javax.swing.JTextField;&lt;br /&gt;
import javax.swing.JWindow;&lt;br /&gt;
import javax.swing.UIManager;&lt;br /&gt;
import javax.swing.event.ChangeEvent;&lt;br /&gt;
import javax.swing.event.ChangeListener;&lt;br /&gt;
/**&lt;br /&gt;
 * Font2DTest.java&lt;br /&gt;
 * &lt;br /&gt;
 * @version&lt;br /&gt;
 * @(#)Font2DTest.java 1.2 00/08/22&lt;br /&gt;
 * @author Shinsuke Fukuda&lt;br /&gt;
 * @author Ankit Patel [Conversion to Swing - 01/07/30]&lt;br /&gt;
 */&lt;br /&gt;
// / Main Font2DTest Class&lt;br /&gt;
public final class Font2DTest extends JPanel implements ActionListener, ItemListener,&lt;br /&gt;
    ChangeListener {&lt;br /&gt;
  // / JFrame that will contain Font2DTest&lt;br /&gt;
  private final JFrame parent;&lt;br /&gt;
  // / FontPanel class that will contain all graphical output&lt;br /&gt;
  private final FontPanel fp;&lt;br /&gt;
  // / RangeMenu class that contains info about the unicode ranges&lt;br /&gt;
  private final RangeMenu rm;&lt;br /&gt;
  // / Other menus to set parameters for text drawing&lt;br /&gt;
  private final ChoiceV2 fontMenu;&lt;br /&gt;
  private final JTextField sizeField;&lt;br /&gt;
  private final ChoiceV2 styleMenu;&lt;br /&gt;
  private final ChoiceV2 textMenu;&lt;br /&gt;
  private int currentTextChoice = 0;&lt;br /&gt;
  private final ChoiceV2 transformMenu;&lt;br /&gt;
  private final ChoiceV2 transformMenuG2;&lt;br /&gt;
  private final ChoiceV2 methodsMenu;&lt;br /&gt;
  private final JComboBox antiAliasMenu;&lt;br /&gt;
  private final JComboBox fracMetricsMenu;&lt;br /&gt;
  private final JSlider contrastSlider;&lt;br /&gt;
  // / CheckboxMenuItems&lt;br /&gt;
  private CheckboxMenuItemV2 displayGridCBMI;&lt;br /&gt;
  private CheckboxMenuItemV2 force16ColsCBMI;&lt;br /&gt;
  private CheckboxMenuItemV2 showFontInfoCBMI;&lt;br /&gt;
  // / JDialog boxes&lt;br /&gt;
  private JDialog userTextDialog;&lt;br /&gt;
  private JTextArea userTextArea;&lt;br /&gt;
  private JDialog printDialog;&lt;br /&gt;
  private JDialog fontInfoDialog;&lt;br /&gt;
  private LabelV2 fontInfos[] = new LabelV2[2];&lt;br /&gt;
  private JFileChooser filePromptDialog = null;&lt;br /&gt;
  private ButtonGroup printCBGroup;&lt;br /&gt;
  private JRadioButton printModeCBs[] = new JRadioButton[3];&lt;br /&gt;
  // / Status bar&lt;br /&gt;
  private final LabelV2 statusBar;&lt;br /&gt;
  private int fontStyles[] = { Font.PLAIN, Font.BOLD, Font.ITALIC, Font.BOLD | Font.ITALIC };&lt;br /&gt;
  // / Text filename&lt;br /&gt;
  private String tFileName;&lt;br /&gt;
  // Enabled or disabled status of canDisplay check&lt;br /&gt;
  private static boolean canDisplayCheck = true;&lt;br /&gt;
  // / Initialize GUI variables and its layouts&lt;br /&gt;
  public Font2DTest(JFrame f, boolean isApplet) {&lt;br /&gt;
    parent = f;&lt;br /&gt;
    rm = new RangeMenu(this, parent);&lt;br /&gt;
    fp = new FontPanel(this, parent);&lt;br /&gt;
    statusBar = new LabelV2(&amp;quot;&amp;quot;);&lt;br /&gt;
    fontMenu = new ChoiceV2(this, canDisplayCheck);&lt;br /&gt;
    sizeField = new JTextField(&amp;quot;12&amp;quot;, 3);&lt;br /&gt;
    sizeField.addActionListener(this);&lt;br /&gt;
    styleMenu = new ChoiceV2(this);&lt;br /&gt;
    textMenu = new ChoiceV2(); // listener added later&lt;br /&gt;
    transformMenu = new ChoiceV2(this);&lt;br /&gt;
    transformMenuG2 = new ChoiceV2(this);&lt;br /&gt;
    methodsMenu = new ChoiceV2(this);&lt;br /&gt;
    antiAliasMenu = new JComboBox(EnumSet.allOf(FontPanel.AAValues.class).toArray());&lt;br /&gt;
    antiAliasMenu.addActionListener(this);&lt;br /&gt;
    fracMetricsMenu = new JComboBox(EnumSet.allOf(FontPanel.FMValues.class).toArray());&lt;br /&gt;
    fracMetricsMenu.addActionListener(this);&lt;br /&gt;
    contrastSlider = new JSlider(JSlider.HORIZONTAL, 100, 250, FontPanel.getDefaultLCDContrast()&lt;br /&gt;
        .intValue());&lt;br /&gt;
    contrastSlider.setEnabled(false);&lt;br /&gt;
    contrastSlider.setMajorTickSpacing(20);&lt;br /&gt;
    contrastSlider.setMinorTickSpacing(10);&lt;br /&gt;
    contrastSlider.setPaintTicks(true);&lt;br /&gt;
    contrastSlider.setPaintLabels(true);&lt;br /&gt;
    contrastSlider.addChangeListener(this);&lt;br /&gt;
    setupPanel();&lt;br /&gt;
    setupMenu(isApplet);&lt;br /&gt;
    setupDialog(isApplet);&lt;br /&gt;
    if (canDisplayCheck) {&lt;br /&gt;
      fireRangeChanged();&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
  // / Set up the main interface panel&lt;br /&gt;
  private void setupPanel() {&lt;br /&gt;
    GridBagLayout gbl = new GridBagLayout();&lt;br /&gt;
    GridBagConstraints gbc = new GridBagConstraints();&lt;br /&gt;
    gbc.fill = GridBagConstraints.HORIZONTAL;&lt;br /&gt;
    gbc.weightx = 1;&lt;br /&gt;
    gbc.insets = new Insets(2, 0, 2, 2);&lt;br /&gt;
    this.setLayout(gbl);&lt;br /&gt;
    addLabeledComponentToGBL(&amp;quot;Font: &amp;quot;, fontMenu, gbl, gbc, this);&lt;br /&gt;
    addLabeledComponentToGBL(&amp;quot;Size: &amp;quot;, sizeField, gbl, gbc, this);&lt;br /&gt;
    gbc.gridwidth = GridBagConstraints.REMAINDER;&lt;br /&gt;
    addLabeledComponentToGBL(&amp;quot;Font Transform:&amp;quot;, transformMenu, gbl, gbc, this);&lt;br /&gt;
    gbc.gridwidth = 1;&lt;br /&gt;
    addLabeledComponentToGBL(&amp;quot;Range: &amp;quot;, rm, gbl, gbc, this);&lt;br /&gt;
    addLabeledComponentToGBL(&amp;quot;Style: &amp;quot;, styleMenu, gbl, gbc, this);&lt;br /&gt;
    gbc.gridwidth = GridBagConstraints.REMAINDER;&lt;br /&gt;
    addLabeledComponentToGBL(&amp;quot;Graphics Transform: &amp;quot;, transformMenuG2, gbl, gbc, this);&lt;br /&gt;
    gbc.gridwidth = 1;&lt;br /&gt;
    gbc.anchor = GridBagConstraints.WEST;&lt;br /&gt;
    addLabeledComponentToGBL(&amp;quot;Method: &amp;quot;, methodsMenu, gbl, gbc, this);&lt;br /&gt;
    addLabeledComponentToGBL(&amp;quot;&amp;quot;, null, gbl, gbc, this);&lt;br /&gt;
    gbc.anchor = GridBagConstraints.EAST;&lt;br /&gt;
    gbc.gridwidth = GridBagConstraints.REMAINDER;&lt;br /&gt;
    addLabeledComponentToGBL(&amp;quot;Text to use:&amp;quot;, textMenu, gbl, gbc, this);&lt;br /&gt;
    gbc.weightx = 1;&lt;br /&gt;
    gbc.gridwidth = 1;&lt;br /&gt;
    gbc.fill = GridBagConstraints.HORIZONTAL;&lt;br /&gt;
    gbc.anchor = GridBagConstraints.WEST;&lt;br /&gt;
    addLabeledComponentToGBL(&amp;quot;LCD contrast: &amp;quot;, contrastSlider, gbl, gbc, this);&lt;br /&gt;
    gbc.gridwidth = 1;&lt;br /&gt;
    gbc.fill = GridBagConstraints.NONE;&lt;br /&gt;
    addLabeledComponentToGBL(&amp;quot;Antialiasing: &amp;quot;, antiAliasMenu, gbl, gbc, this);&lt;br /&gt;
    gbc.anchor = GridBagConstraints.EAST;&lt;br /&gt;
    gbc.gridwidth = GridBagConstraints.REMAINDER;&lt;br /&gt;
    addLabeledComponentToGBL(&amp;quot;Fractional metrics: &amp;quot;, fracMetricsMenu, gbl, gbc, this);&lt;br /&gt;
    gbc.weightx = 1;&lt;br /&gt;
    gbc.weighty = 1;&lt;br /&gt;
    gbc.anchor = GridBagConstraints.WEST;&lt;br /&gt;
    gbc.insets = new Insets(2, 0, 0, 2);&lt;br /&gt;
    gbc.fill = GridBagConstraints.BOTH;&lt;br /&gt;
    gbl.setConstraints(fp, gbc);&lt;br /&gt;
    this.add(fp);&lt;br /&gt;
    gbc.weighty = 0;&lt;br /&gt;
    gbc.insets = new Insets(0, 2, 0, 0);&lt;br /&gt;
    gbl.setConstraints(statusBar, gbc);&lt;br /&gt;
    this.add(statusBar);&lt;br /&gt;
  }&lt;br /&gt;
  // / Adds a component to a container with a label to its left in GridBagLayout&lt;br /&gt;
  private void addLabeledComponentToGBL(String name, JComponent c, GridBagLayout gbl,&lt;br /&gt;
      GridBagConstraints gbc, Container target) {&lt;br /&gt;
    LabelV2 l = new LabelV2(name);&lt;br /&gt;
    GridBagConstraints gbcLabel = (GridBagConstraints) gbc.clone();&lt;br /&gt;
    gbcLabel.insets = new Insets(2, 2, 2, 0);&lt;br /&gt;
    gbcLabel.gridwidth = 1;&lt;br /&gt;
    gbcLabel.weightx = 0;&lt;br /&gt;
    if (c == null)&lt;br /&gt;
      c = new JLabel(&amp;quot;&amp;quot;);&lt;br /&gt;
    gbl.setConstraints(l, gbcLabel);&lt;br /&gt;
    target.add(l);&lt;br /&gt;
    gbl.setConstraints(c, gbc);&lt;br /&gt;
    target.add(c);&lt;br /&gt;
  }&lt;br /&gt;
  // / Sets up menu entries&lt;br /&gt;
  private void setupMenu(boolean isApplet) {&lt;br /&gt;
    JMenu fileMenu = new JMenu(&amp;quot;File&amp;quot;);&lt;br /&gt;
    JMenu optionMenu = new JMenu(&amp;quot;Option&amp;quot;);&lt;br /&gt;
    fileMenu.add(new MenuItemV2(&amp;quot;Save Selected Options...&amp;quot;, this));&lt;br /&gt;
    fileMenu.add(new MenuItemV2(&amp;quot;Load Options...&amp;quot;, this));&lt;br /&gt;
    fileMenu.addSeparator();&lt;br /&gt;
    fileMenu.add(new MenuItemV2(&amp;quot;Save as PNG...&amp;quot;, this));&lt;br /&gt;
    fileMenu.add(new MenuItemV2(&amp;quot;Load PNG File to Compare...&amp;quot;, this));&lt;br /&gt;
    fileMenu.add(new MenuItemV2(&amp;quot;Page Setup...&amp;quot;, this));&lt;br /&gt;
    fileMenu.add(new MenuItemV2(&amp;quot;Print...&amp;quot;, this));&lt;br /&gt;
    fileMenu.addSeparator();&lt;br /&gt;
    if (!isApplet)&lt;br /&gt;
      fileMenu.add(new MenuItemV2(&amp;quot;Exit&amp;quot;, this));&lt;br /&gt;
    else&lt;br /&gt;
      fileMenu.add(new MenuItemV2(&amp;quot;Close&amp;quot;, this));&lt;br /&gt;
    displayGridCBMI = new CheckboxMenuItemV2(&amp;quot;Display Grid&amp;quot;, true, this);&lt;br /&gt;
    force16ColsCBMI = new CheckboxMenuItemV2(&amp;quot;Force 16 Columns&amp;quot;, false, this);&lt;br /&gt;
    showFontInfoCBMI = new CheckboxMenuItemV2(&amp;quot;Display Font Info&amp;quot;, false, this);&lt;br /&gt;
    optionMenu.add(displayGridCBMI);&lt;br /&gt;
    optionMenu.add(force16ColsCBMI);&lt;br /&gt;
    optionMenu.add(showFontInfoCBMI);&lt;br /&gt;
    JMenuBar mb = parent.getJMenuBar();&lt;br /&gt;
    if (mb == null)&lt;br /&gt;
      mb = new JMenuBar();&lt;br /&gt;
    mb.add(fileMenu);&lt;br /&gt;
    mb.add(optionMenu);&lt;br /&gt;
    parent.setJMenuBar(mb);&lt;br /&gt;
    String fontList[] = GraphicsEnvironment.getLocalGraphicsEnvironment()&lt;br /&gt;
        .getAvailableFontFamilyNames();&lt;br /&gt;
    for (int i = 0; i &amp;lt; fontList.length; i++)&lt;br /&gt;
      fontMenu.addItem(fontList[i]);&lt;br /&gt;
    fontMenu.setSelectedItem(&amp;quot;Dialog&amp;quot;);&lt;br /&gt;
    styleMenu.addItem(&amp;quot;Plain&amp;quot;);&lt;br /&gt;
    styleMenu.addItem(&amp;quot;Bold&amp;quot;);&lt;br /&gt;
    styleMenu.addItem(&amp;quot;Italic&amp;quot;);&lt;br /&gt;
    styleMenu.addItem(&amp;quot;Bold Italic&amp;quot;);&lt;br /&gt;
    transformMenu.addItem(&amp;quot;None&amp;quot;);&lt;br /&gt;
    transformMenu.addItem(&amp;quot;Scale&amp;quot;);&lt;br /&gt;
    transformMenu.addItem(&amp;quot;Shear&amp;quot;);&lt;br /&gt;
    transformMenu.addItem(&amp;quot;Rotate&amp;quot;);&lt;br /&gt;
    transformMenuG2.addItem(&amp;quot;None&amp;quot;);&lt;br /&gt;
    transformMenuG2.addItem(&amp;quot;Scale&amp;quot;);&lt;br /&gt;
    transformMenuG2.addItem(&amp;quot;Shear&amp;quot;);&lt;br /&gt;
    transformMenuG2.addItem(&amp;quot;Rotate&amp;quot;);&lt;br /&gt;
    methodsMenu.addItem(&amp;quot;drawString&amp;quot;);&lt;br /&gt;
    methodsMenu.addItem(&amp;quot;drawChars&amp;quot;);&lt;br /&gt;
    methodsMenu.addItem(&amp;quot;drawBytes&amp;quot;);&lt;br /&gt;
    methodsMenu.addItem(&amp;quot;drawGlyphVector&amp;quot;);&lt;br /&gt;
    methodsMenu.addItem(&amp;quot;TextLayout.draw&amp;quot;);&lt;br /&gt;
    methodsMenu.addItem(&amp;quot;GlyphVector.getOutline + draw&amp;quot;);&lt;br /&gt;
    methodsMenu.addItem(&amp;quot;TextLayout.getOutline + draw&amp;quot;);&lt;br /&gt;
    textMenu.addItem(&amp;quot;Unicode Range&amp;quot;);&lt;br /&gt;
    textMenu.addItem(&amp;quot;All Glyphs&amp;quot;);&lt;br /&gt;
    textMenu.addItem(&amp;quot;User Text&amp;quot;);&lt;br /&gt;
    textMenu.addItem(&amp;quot;Text File&amp;quot;);&lt;br /&gt;
    textMenu.addActionListener(this); // listener added later so unneeded events&lt;br /&gt;
                                      // not thrown&lt;br /&gt;
  }&lt;br /&gt;
  // / Sets up the all dialogs used in Font2DTest...&lt;br /&gt;
  private void setupDialog(boolean isApplet) {&lt;br /&gt;
    if (!isApplet)&lt;br /&gt;
      filePromptDialog = new JFileChooser();&lt;br /&gt;
    else&lt;br /&gt;
      filePromptDialog = null;&lt;br /&gt;
    // / Prepare user text dialog...&lt;br /&gt;
    userTextDialog = new JDialog(parent, &amp;quot;User Text&amp;quot;, false);&lt;br /&gt;
    JPanel dialogTopPanel = new JPanel();&lt;br /&gt;
    JPanel dialogBottomPanel = new JPanel();&lt;br /&gt;
    LabelV2 message1 = new LabelV2(&amp;quot;Enter text below and then press update&amp;quot;);&lt;br /&gt;
    LabelV2 message2 = new LabelV2(&amp;quot;(Unicode char can be denoted by \\uXXXX)&amp;quot;);&lt;br /&gt;
    LabelV2 message3 = new LabelV2(&amp;quot;(Supplementary chars can be denoted by \\UXXXXXX)&amp;quot;);&lt;br /&gt;
    userTextArea = new JTextArea(&amp;quot;Java2D!&amp;quot;);&lt;br /&gt;
    ButtonV2 bUpdate = new ButtonV2(&amp;quot;Update&amp;quot;, this);&lt;br /&gt;
    userTextArea.setFont(new Font(&amp;quot;dialog&amp;quot;, Font.PLAIN, 12));&lt;br /&gt;
    dialogTopPanel.setLayout(new GridLayout(3, 1));&lt;br /&gt;
    dialogTopPanel.add(message1);&lt;br /&gt;
    dialogTopPanel.add(message2);&lt;br /&gt;
    dialogTopPanel.add(message3);&lt;br /&gt;
    dialogBottomPanel.add(bUpdate);&lt;br /&gt;
    // ABP&lt;br /&gt;
    JScrollPane userTextAreaSP = new JScrollPane(userTextArea);&lt;br /&gt;
    userTextAreaSP.setPreferredSize(new Dimension(300, 100));&lt;br /&gt;
    userTextDialog.getContentPane().setLayout(new BorderLayout());&lt;br /&gt;
    userTextDialog.getContentPane().add(&amp;quot;North&amp;quot;, dialogTopPanel);&lt;br /&gt;
    userTextDialog.getContentPane().add(&amp;quot;Center&amp;quot;, userTextAreaSP);&lt;br /&gt;
    userTextDialog.getContentPane().add(&amp;quot;South&amp;quot;, dialogBottomPanel);&lt;br /&gt;
    userTextDialog.pack();&lt;br /&gt;
    userTextDialog.addWindowListener(new WindowAdapter() {&lt;br /&gt;
      public void windowClosing(WindowEvent e) {&lt;br /&gt;
        userTextDialog.hide();&lt;br /&gt;
      }&lt;br /&gt;
    });&lt;br /&gt;
    // / Prepare printing dialog...&lt;br /&gt;
    printCBGroup = new ButtonGroup();&lt;br /&gt;
    printModeCBs[fp.ONE_PAGE] = new JRadioButton(&lt;br /&gt;
        &amp;quot;Print one page from currently displayed character/line&amp;quot;, true);&lt;br /&gt;
    printModeCBs[fp.CUR_RANGE] = new JRadioButton(&lt;br /&gt;
        &amp;quot;Print all characters in currently selected range&amp;quot;, false);&lt;br /&gt;
    printModeCBs[fp.ALL_TEXT] = new JRadioButton(&amp;quot;Print all lines of text&amp;quot;, false);&lt;br /&gt;
    LabelV2 l = new LabelV2(&lt;br /&gt;
        &amp;quot;Note: Page range in native \&amp;quot;Print\&amp;quot; dialog will not affect the result&amp;quot;);&lt;br /&gt;
    JPanel buttonPanel = new JPanel();&lt;br /&gt;
    printModeCBs[fp.ALL_TEXT].setEnabled(false);&lt;br /&gt;
    buttonPanel.add(new ButtonV2(&amp;quot;Print&amp;quot;, this));&lt;br /&gt;
    buttonPanel.add(new ButtonV2(&amp;quot;Cancel&amp;quot;, this));&lt;br /&gt;
    printDialog = new JDialog(parent, &amp;quot;Print...&amp;quot;, true);&lt;br /&gt;
    printDialog.setResizable(false);&lt;br /&gt;
    printDialog.addWindowListener(new WindowAdapter() {&lt;br /&gt;
      public void windowClosing(WindowEvent e) {&lt;br /&gt;
        printDialog.hide();&lt;br /&gt;
      }&lt;br /&gt;
    });&lt;br /&gt;
    printDialog.getContentPane().setLayout(new GridLayout(printModeCBs.length + 2, 1));&lt;br /&gt;
    printDialog.getContentPane().add(l);&lt;br /&gt;
    for (int i = 0; i &amp;lt; printModeCBs.length; i++) {&lt;br /&gt;
      printCBGroup.add(printModeCBs[i]);&lt;br /&gt;
      printDialog.getContentPane().add(printModeCBs[i]);&lt;br /&gt;
    }&lt;br /&gt;
    printDialog.getContentPane().add(buttonPanel);&lt;br /&gt;
    printDialog.pack();&lt;br /&gt;
    // / Prepare font information dialog...&lt;br /&gt;
    fontInfoDialog = new JDialog(parent, &amp;quot;Font info&amp;quot;, false);&lt;br /&gt;
    fontInfoDialog.setResizable(false);&lt;br /&gt;
    fontInfoDialog.addWindowListener(new WindowAdapter() {&lt;br /&gt;
      public void windowClosing(WindowEvent e) {&lt;br /&gt;
        fontInfoDialog.hide();&lt;br /&gt;
        showFontInfoCBMI.setState(false);&lt;br /&gt;
      }&lt;br /&gt;
    });&lt;br /&gt;
    JPanel fontInfoPanel = new JPanel();&lt;br /&gt;
    fontInfoPanel.setLayout(new GridLayout(fontInfos.length, 1));&lt;br /&gt;
    for (int i = 0; i &amp;lt; fontInfos.length; i++) {&lt;br /&gt;
      fontInfos[i] = new LabelV2(&amp;quot;&amp;quot;);&lt;br /&gt;
      fontInfoPanel.add(fontInfos[i]);&lt;br /&gt;
    }&lt;br /&gt;
    fontInfoDialog.getContentPane().add(fontInfoPanel);&lt;br /&gt;
    // / Move the location of the dialog...&lt;br /&gt;
    userTextDialog.setLocation(200, 300);&lt;br /&gt;
    fontInfoDialog.setLocation(0, 400);&lt;br /&gt;
  }&lt;br /&gt;
  // / RangeMenu object signals using this function&lt;br /&gt;
  // / when Unicode range has been changed and text needs to be redrawn&lt;br /&gt;
  public void fireRangeChanged() {&lt;br /&gt;
    int range[] = rm.getSelectedRange();&lt;br /&gt;
    fp.setTextToDraw(fp.RANGE_TEXT, range, null, null);&lt;br /&gt;
    if (canDisplayCheck) {&lt;br /&gt;
      setupFontList(range[0], range[1]);&lt;br /&gt;
    }&lt;br /&gt;
    if (showFontInfoCBMI.getState())&lt;br /&gt;
      fireUpdateFontInfo();&lt;br /&gt;
  }&lt;br /&gt;
  // / Changes the message on the status bar&lt;br /&gt;
  public void fireChangeStatus(String message, boolean error) {&lt;br /&gt;
    // / If this is not ran as an applet, use own status bar,&lt;br /&gt;
    // / Otherwise, use the appletviewer/browser&amp;quot;s status bar&lt;br /&gt;
    statusBar.setText(message);&lt;br /&gt;
    if (error)&lt;br /&gt;
      fp.showingError = true;&lt;br /&gt;
    else&lt;br /&gt;
      fp.showingError = false;&lt;br /&gt;
  }&lt;br /&gt;
  // / Updates the information about the selected font&lt;br /&gt;
  public void fireUpdateFontInfo() {&lt;br /&gt;
    if (showFontInfoCBMI.getState()) {&lt;br /&gt;
      String infos[] = fp.getFontInfo();&lt;br /&gt;
      for (int i = 0; i &amp;lt; fontInfos.length; i++)&lt;br /&gt;
        fontInfos[i].setText(infos[i]);&lt;br /&gt;
      fontInfoDialog.pack();&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
  private void setupFontList(int rangeStart, int rangeEnd) {&lt;br /&gt;
    int listCount = fontMenu.getItemCount();&lt;br /&gt;
    int size = 16;&lt;br /&gt;
    try {&lt;br /&gt;
      size = Float.valueOf(sizeField.getText()).intValue();&lt;br /&gt;
    } catch (Exception e) {&lt;br /&gt;
      System.out.println(&amp;quot;Invalid font size in the size textField. Using default value of 16&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
    int style = fontStyles[styleMenu.getSelectedIndex()];&lt;br /&gt;
    Font f;&lt;br /&gt;
    for (int i = 0; i &amp;lt; listCount; i++) {&lt;br /&gt;
      String fontName = (String) fontMenu.getItemAt(i);&lt;br /&gt;
      f = new Font(fontName, style, size);&lt;br /&gt;
      if ((rm.getSelectedIndex() != RangeMenu.SURROGATES_AREA_INDEX)&lt;br /&gt;
          &amp;amp;&amp;amp; canDisplayRange(f, rangeStart, rangeEnd)) {&lt;br /&gt;
        fontMenu.setBit(i, true);&lt;br /&gt;
      } else {&lt;br /&gt;
        fontMenu.setBit(i, false);&lt;br /&gt;
      }&lt;br /&gt;
    }&lt;br /&gt;
    fontMenu.repaint();&lt;br /&gt;
  }&lt;br /&gt;
  protected boolean canDisplayRange(Font font, int rangeStart, int rangeEnd) {&lt;br /&gt;
    for (int i = rangeStart; i &amp;lt; rangeEnd; i++) {&lt;br /&gt;
      if (font.canDisplay(i)) {&lt;br /&gt;
        return true;&lt;br /&gt;
      }&lt;br /&gt;
    }&lt;br /&gt;
    return false;&lt;br /&gt;
  }&lt;br /&gt;
  // / Displays a file load/save dialog and returns the specified file&lt;br /&gt;
  private String promptFile(boolean isSave, String initFileName) {&lt;br /&gt;
    int retVal;&lt;br /&gt;
    String str;&lt;br /&gt;
    // / ABP&lt;br /&gt;
    if (filePromptDialog == null)&lt;br /&gt;
      return null;&lt;br /&gt;
    if (isSave) {&lt;br /&gt;
      filePromptDialog.setDialogType(JFileChooser.SAVE_DIALOG);&lt;br /&gt;
      filePromptDialog.setDialogTitle(&amp;quot;Save...&amp;quot;);&lt;br /&gt;
      str = &amp;quot;Save&amp;quot;;&lt;br /&gt;
    } else {&lt;br /&gt;
      filePromptDialog.setDialogType(JFileChooser.OPEN_DIALOG);&lt;br /&gt;
      filePromptDialog.setDialogTitle(&amp;quot;Load...&amp;quot;);&lt;br /&gt;
      str = &amp;quot;Load&amp;quot;;&lt;br /&gt;
    }&lt;br /&gt;
    if (initFileName != null)&lt;br /&gt;
      filePromptDialog.setSelectedFile(new File(initFileName));&lt;br /&gt;
    retVal = filePromptDialog.showDialog(this, str);&lt;br /&gt;
    if (retVal == JFileChooser.APPROVE_OPTION) {&lt;br /&gt;
      File file = filePromptDialog.getSelectedFile();&lt;br /&gt;
      String fileName = file.getAbsolutePath();&lt;br /&gt;
      if (fileName != null) {&lt;br /&gt;
        return fileName;&lt;br /&gt;
      }&lt;br /&gt;
    }&lt;br /&gt;
    return null;&lt;br /&gt;
  }&lt;br /&gt;
  // / Converts user text into arrays of String, delimited at newline character&lt;br /&gt;
  // / Also replaces any valid escape sequence with appropriate unicode&lt;br /&gt;
  // character&lt;br /&gt;
  // / Support \\UXXXXXX notation for surrogates&lt;br /&gt;
  private String[] parseUserText(String orig) {&lt;br /&gt;
    int length = orig.length();&lt;br /&gt;
    StringTokenizer perLine = new StringTokenizer(orig, &amp;quot;\n&amp;quot;);&lt;br /&gt;
    String textLines[] = new String[perLine.countTokens()];&lt;br /&gt;
    int lineNumber = 0;&lt;br /&gt;
    while (perLine.hasMoreElements()) {&lt;br /&gt;
      StringBuffer converted = new StringBuffer();&lt;br /&gt;
      String oneLine = perLine.nextToken();&lt;br /&gt;
      int lineLength = oneLine.length();&lt;br /&gt;
      int prevEscapeEnd = 0;&lt;br /&gt;
      int nextEscape = -1;&lt;br /&gt;
      do {&lt;br /&gt;
        int nextBMPEscape = oneLine.indexOf(&amp;quot;\\u&amp;quot;, prevEscapeEnd);&lt;br /&gt;
        int nextSupEscape = oneLine.indexOf(&amp;quot;\\U&amp;quot;, prevEscapeEnd);&lt;br /&gt;
        nextEscape = (nextBMPEscape &amp;lt; 0) ? ((nextSupEscape &amp;lt; 0) ? -1 : nextSupEscape)&lt;br /&gt;
            : ((nextSupEscape &amp;lt; 0) ? nextBMPEscape : Math.min(nextBMPEscape, nextSupEscape));&lt;br /&gt;
        if (nextEscape != -1) {&lt;br /&gt;
          if (prevEscapeEnd &amp;lt; nextEscape)&lt;br /&gt;
            converted.append(oneLine.substring(prevEscapeEnd, nextEscape));&lt;br /&gt;
          prevEscapeEnd = nextEscape + (nextEscape == nextBMPEscape ? 6 : 8);&lt;br /&gt;
          try {&lt;br /&gt;
            String hex = oneLine.substring(nextEscape + 2, prevEscapeEnd);&lt;br /&gt;
            if (nextEscape == nextBMPEscape) {&lt;br /&gt;
              converted.append((char) Integer.parseInt(hex, 16));&lt;br /&gt;
            } else {&lt;br /&gt;
              converted.append(new String(Character.toChars(Integer.parseInt(hex, 16))));&lt;br /&gt;
            }&lt;br /&gt;
          } catch (Exception e) {&lt;br /&gt;
            int copyLimit = Math.min(lineLength, prevEscapeEnd);&lt;br /&gt;
            converted.append(oneLine.substring(nextEscape, copyLimit));&lt;br /&gt;
          }&lt;br /&gt;
        }&lt;br /&gt;
      } while (nextEscape != -1);&lt;br /&gt;
      if (prevEscapeEnd &amp;lt; lineLength)&lt;br /&gt;
        converted.append(oneLine.substring(prevEscapeEnd, lineLength));&lt;br /&gt;
      textLines[lineNumber++] = converted.toString();&lt;br /&gt;
    }&lt;br /&gt;
    return textLines;&lt;br /&gt;
  }&lt;br /&gt;
  // / Reads the text from specified file, detecting UTF-16 encoding&lt;br /&gt;
  // / Then breaks the text into String array, delimited at every line break&lt;br /&gt;
  private void readTextFile(String fileName) {&lt;br /&gt;
    try {&lt;br /&gt;
      String fileText, textLines[];&lt;br /&gt;
      BufferedInputStream bis = new BufferedInputStream(new FileInputStream(fileName));&lt;br /&gt;
      int numBytes = bis.available();&lt;br /&gt;
      if (numBytes == 0) {&lt;br /&gt;
        throw new Exception(&amp;quot;Text file &amp;quot; + fileName + &amp;quot; is empty&amp;quot;);&lt;br /&gt;
      }&lt;br /&gt;
      byte byteData[] = new byte[numBytes];&lt;br /&gt;
      bis.read(byteData, 0, numBytes);&lt;br /&gt;
      bis.close();&lt;br /&gt;
      // / If byte mark is found, then use UTF-16 encoding to convert bytes...&lt;br /&gt;
      if (numBytes &amp;gt;= 2&lt;br /&gt;
          &amp;amp;&amp;amp; ((byteData[0] == (byte) 0xFF &amp;amp;&amp;amp; byteData[1] == (byte) 0xFE) || (byteData[0] == (byte) 0xFE &amp;amp;&amp;amp; byteData[1] == (byte) 0xFF)))&lt;br /&gt;
        fileText = new String(byteData, &amp;quot;UTF-16&amp;quot;);&lt;br /&gt;
      // / Otherwise, use system default encoding&lt;br /&gt;
      else&lt;br /&gt;
        fileText = new String(byteData);&lt;br /&gt;
      int length = fileText.length();&lt;br /&gt;
      StringTokenizer perLine = new StringTokenizer(fileText, &amp;quot;\n&amp;quot;);&lt;br /&gt;
      // / Determine &amp;quot;Return Char&amp;quot; used in this file&lt;br /&gt;
      // / This simply finds first occurrence of CR, CR+LF or LF...&lt;br /&gt;
      for (int i = 0; i &amp;lt; length; i++) {&lt;br /&gt;
        char iTh = fileText.charAt(i);&lt;br /&gt;
        if (iTh == &amp;quot;\r&amp;quot;) {&lt;br /&gt;
          if (i &amp;lt; length - 1 &amp;amp;&amp;amp; fileText.charAt(i + 1) == &amp;quot;\n&amp;quot;)&lt;br /&gt;
            perLine = new StringTokenizer(fileText, &amp;quot;\r\n&amp;quot;);&lt;br /&gt;
          else&lt;br /&gt;
            perLine = new StringTokenizer(fileText, &amp;quot;\r&amp;quot;);&lt;br /&gt;
          break;&lt;br /&gt;
        } else if (iTh == &amp;quot;\n&amp;quot;)&lt;br /&gt;
          // / Use the one already created&lt;br /&gt;
          break;&lt;br /&gt;
      }&lt;br /&gt;
      int lineNumber = 0, numLines = perLine.countTokens();&lt;br /&gt;
      textLines = new String[numLines];&lt;br /&gt;
      while (perLine.hasMoreElements()) {&lt;br /&gt;
        String oneLine = perLine.nextToken();&lt;br /&gt;
        if (oneLine == null)&lt;br /&gt;
          // / To make LineBreakMeasurer to return a valid TextLayout&lt;br /&gt;
          // / on an empty line, simply feed it a space char...&lt;br /&gt;
          oneLine = &amp;quot; &amp;quot;;&lt;br /&gt;
        textLines[lineNumber++] = oneLine;&lt;br /&gt;
      }&lt;br /&gt;
      fp.setTextToDraw(fp.FILE_TEXT, null, null, textLines);&lt;br /&gt;
      rm.setEnabled(false);&lt;br /&gt;
      methodsMenu.setEnabled(false);&lt;br /&gt;
    } catch (Exception ex) {&lt;br /&gt;
      fireChangeStatus(&amp;quot;ERROR: Failed to Read Text File; See Stack Trace&amp;quot;, true);&lt;br /&gt;
      ex.printStackTrace();&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
  // / Returns a String storing current configuration&lt;br /&gt;
  private void writeCurrentOptions(String fileName) {&lt;br /&gt;
    try {&lt;br /&gt;
      String curOptions = fp.getCurrentOptions();&lt;br /&gt;
      BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(fileName));&lt;br /&gt;
      // / Prepend title and the option that is only obtainable here&lt;br /&gt;
      int range[] = rm.getSelectedRange();&lt;br /&gt;
      String completeOptions = (&amp;quot;Font2DTest Option File\n&amp;quot; + displayGridCBMI.getState() + &amp;quot;\n&amp;quot;&lt;br /&gt;
          + force16ColsCBMI.getState() + &amp;quot;\n&amp;quot; + showFontInfoCBMI.getState() + &amp;quot;\n&amp;quot;&lt;br /&gt;
          + rm.getSelectedItem() + &amp;quot;\n&amp;quot; + range[0] + &amp;quot;\n&amp;quot; + range[1] + &amp;quot;\n&amp;quot; + curOptions + tFileName);&lt;br /&gt;
      byte toBeWritten[] = completeOptions.getBytes(&amp;quot;UTF-16&amp;quot;);&lt;br /&gt;
      bos.write(toBeWritten, 0, toBeWritten.length);&lt;br /&gt;
      bos.close();&lt;br /&gt;
    } catch (Exception ex) {&lt;br /&gt;
      fireChangeStatus(&amp;quot;ERROR: Failed to Save Options File; See Stack Trace&amp;quot;, true);&lt;br /&gt;
      ex.printStackTrace();&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
  // / Updates GUI visibility/status after some parameters have changed&lt;br /&gt;
  private void updateGUI() {&lt;br /&gt;
    int selectedText = textMenu.getSelectedIndex();&lt;br /&gt;
    // / Set the visibility of User Text dialog&lt;br /&gt;
    if (selectedText == fp.USER_TEXT)&lt;br /&gt;
      userTextDialog.show();&lt;br /&gt;
    else&lt;br /&gt;
      userTextDialog.hide();&lt;br /&gt;
    // / Change the visibility/status/availability of Print JDialog buttons&lt;br /&gt;
    printModeCBs[fp.ONE_PAGE].setSelected(true);&lt;br /&gt;
    if (selectedText == fp.FILE_TEXT || selectedText == fp.USER_TEXT) {&lt;br /&gt;
      // / ABP&lt;br /&gt;
      // / update methodsMenu to show that TextLayout.draw is being used&lt;br /&gt;
      // / when we are in FILE_TEXT mode&lt;br /&gt;
      if (selectedText == fp.FILE_TEXT)&lt;br /&gt;
        methodsMenu.setSelectedItem(&amp;quot;TextLayout.draw&amp;quot;);&lt;br /&gt;
      methodsMenu.setEnabled(selectedText == fp.USER_TEXT);&lt;br /&gt;
      printModeCBs[fp.CUR_RANGE].setEnabled(false);&lt;br /&gt;
      printModeCBs[fp.ALL_TEXT].setEnabled(true);&lt;br /&gt;
    } else {&lt;br /&gt;
      // / ABP&lt;br /&gt;
      // / update methodsMenu to show that drawGlyph is being used&lt;br /&gt;
      // / when we are in ALL_GLYPHS mode&lt;br /&gt;
      if (selectedText == fp.ALL_GLYPHS)&lt;br /&gt;
        methodsMenu.setSelectedItem(&amp;quot;drawGlyphVector&amp;quot;);&lt;br /&gt;
      methodsMenu.setEnabled(selectedText == fp.RANGE_TEXT);&lt;br /&gt;
      printModeCBs[fp.CUR_RANGE].setEnabled(true);&lt;br /&gt;
      printModeCBs[fp.ALL_TEXT].setEnabled(false);&lt;br /&gt;
    }&lt;br /&gt;
    // / Modify RangeMenu and fontInfo label availabilty&lt;br /&gt;
    if (selectedText == fp.RANGE_TEXT) {&lt;br /&gt;
      fontInfos[1].setVisible(true);&lt;br /&gt;
      rm.setEnabled(true);&lt;br /&gt;
    } else {&lt;br /&gt;
      fontInfos[1].setVisible(false);&lt;br /&gt;
      rm.setEnabled(false);&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
  // / Loads saved options and applies them&lt;br /&gt;
  private void loadOptions(String fileName) {&lt;br /&gt;
    try {&lt;br /&gt;
      BufferedInputStream bis = new BufferedInputStream(new FileInputStream(fileName));&lt;br /&gt;
      int numBytes = bis.available();&lt;br /&gt;
      byte byteData[] = new byte[numBytes];&lt;br /&gt;
      bis.read(byteData, 0, numBytes);&lt;br /&gt;
      bis.close();&lt;br /&gt;
      if (numBytes &amp;lt; 2 || (byteData[0] != (byte) 0xFE || byteData[1] != (byte) 0xFF))&lt;br /&gt;
        throw new Exception(&amp;quot;Not a Font2DTest options file&amp;quot;);&lt;br /&gt;
      String options = new String(byteData, &amp;quot;UTF-16&amp;quot;);&lt;br /&gt;
      StringTokenizer perLine = new StringTokenizer(options, &amp;quot;\n&amp;quot;);&lt;br /&gt;
      String title = perLine.nextToken();&lt;br /&gt;
      if (!title.equals(&amp;quot;Font2DTest Option File&amp;quot;))&lt;br /&gt;
        throw new Exception(&amp;quot;Not a Font2DTest options file&amp;quot;);&lt;br /&gt;
      // / Parse all options&lt;br /&gt;
      boolean displayGridOpt = Boolean.parseBoolean(perLine.nextToken());&lt;br /&gt;
      boolean force16ColsOpt = Boolean.parseBoolean(perLine.nextToken());&lt;br /&gt;
      boolean showFontInfoOpt = Boolean.parseBoolean(perLine.nextToken());&lt;br /&gt;
      String rangeNameOpt = perLine.nextToken();&lt;br /&gt;
      int rangeStartOpt = Integer.parseInt(perLine.nextToken());&lt;br /&gt;
      int rangeEndOpt = Integer.parseInt(perLine.nextToken());&lt;br /&gt;
      String fontNameOpt = perLine.nextToken();&lt;br /&gt;
      float fontSizeOpt = Float.parseFloat(perLine.nextToken());&lt;br /&gt;
      int fontStyleOpt = Integer.parseInt(perLine.nextToken());&lt;br /&gt;
      int fontTransformOpt = Integer.parseInt(perLine.nextToken());&lt;br /&gt;
      int g2TransformOpt = Integer.parseInt(perLine.nextToken());&lt;br /&gt;
      int textToUseOpt = Integer.parseInt(perLine.nextToken());&lt;br /&gt;
      int drawMethodOpt = Integer.parseInt(perLine.nextToken());&lt;br /&gt;
      int antialiasOpt = Integer.parseInt(perLine.nextToken());&lt;br /&gt;
      int fractionalOpt = Integer.parseInt(perLine.nextToken());&lt;br /&gt;
      int lcdContrast = Integer.parseInt(perLine.nextToken());&lt;br /&gt;
      String userTextOpt[] = { &amp;quot;Java2D!&amp;quot; }, dialogEntry = &amp;quot;Java2D!&amp;quot;;&lt;br /&gt;
      if (textToUseOpt == fp.USER_TEXT) {&lt;br /&gt;
        int numLines = perLine.countTokens(), lineNumber = 0;&lt;br /&gt;
        if (numLines != 0) {&lt;br /&gt;
          userTextOpt = new String[numLines];&lt;br /&gt;
          dialogEntry = &amp;quot;&amp;quot;;&lt;br /&gt;
          for (; perLine.hasMoreElements(); lineNumber++) {&lt;br /&gt;
            userTextOpt[lineNumber] = perLine.nextToken();&lt;br /&gt;
            dialogEntry += userTextOpt[lineNumber] + &amp;quot;\n&amp;quot;;&lt;br /&gt;
          }&lt;br /&gt;
        }&lt;br /&gt;
      }&lt;br /&gt;
      // / Reset GUIs&lt;br /&gt;
      displayGridCBMI.setState(displayGridOpt);&lt;br /&gt;
      force16ColsCBMI.setState(force16ColsOpt);&lt;br /&gt;
      showFontInfoCBMI.setState(showFontInfoOpt);&lt;br /&gt;
      rm.setSelectedRange(rangeNameOpt, rangeStartOpt, rangeEndOpt);&lt;br /&gt;
      fontMenu.setSelectedItem(fontNameOpt);&lt;br /&gt;
      sizeField.setText(String.valueOf(fontSizeOpt));&lt;br /&gt;
      styleMenu.setSelectedIndex(fontStyleOpt);&lt;br /&gt;
      transformMenu.setSelectedIndex(fontTransformOpt);&lt;br /&gt;
      transformMenuG2.setSelectedIndex(g2TransformOpt);&lt;br /&gt;
      textMenu.setSelectedIndex(textToUseOpt);&lt;br /&gt;
      methodsMenu.setSelectedIndex(drawMethodOpt);&lt;br /&gt;
      antiAliasMenu.setSelectedIndex(antialiasOpt);&lt;br /&gt;
      fracMetricsMenu.setSelectedIndex(fractionalOpt);&lt;br /&gt;
      contrastSlider.setValue(lcdContrast);&lt;br /&gt;
      userTextArea.setText(dialogEntry);&lt;br /&gt;
      updateGUI();&lt;br /&gt;
      if (textToUseOpt == fp.FILE_TEXT) {&lt;br /&gt;
        tFileName = perLine.nextToken();&lt;br /&gt;
        readTextFile(tFileName);&lt;br /&gt;
      }&lt;br /&gt;
      // / Reset option variables and repaint&lt;br /&gt;
      fp.loadOptions(displayGridOpt, force16ColsOpt, rangeStartOpt, rangeEndOpt, fontNameOpt,&lt;br /&gt;
          fontSizeOpt, fontStyleOpt, fontTransformOpt, g2TransformOpt, textToUseOpt, drawMethodOpt,&lt;br /&gt;
          antialiasOpt, fractionalOpt, lcdContrast, userTextOpt);&lt;br /&gt;
      if (showFontInfoOpt) {&lt;br /&gt;
        fireUpdateFontInfo();&lt;br /&gt;
        fontInfoDialog.show();&lt;br /&gt;
      } else&lt;br /&gt;
        fontInfoDialog.hide();&lt;br /&gt;
    } catch (Exception ex) {&lt;br /&gt;
      fireChangeStatus(&amp;quot;ERROR: Failed to Load Options File; See Stack Trace&amp;quot;, true);&lt;br /&gt;
      ex.printStackTrace();&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
  // / Loads a previously saved image&lt;br /&gt;
  private void loadComparisonPNG(String fileName) {&lt;br /&gt;
    try {&lt;br /&gt;
      BufferedImage image = javax.imageio.ImageIO.read(new File(fileName));&lt;br /&gt;
      JFrame f = new JFrame(&amp;quot;Comparison PNG&amp;quot;);&lt;br /&gt;
      ImagePanel ip = new ImagePanel(image);&lt;br /&gt;
      f.setResizable(false);&lt;br /&gt;
      f.getContentPane().add(ip);&lt;br /&gt;
      f.addWindowListener(new WindowAdapter() {&lt;br /&gt;
        public void windowClosing(WindowEvent e) {&lt;br /&gt;
          ((JFrame) e.getSource()).dispose();&lt;br /&gt;
        }&lt;br /&gt;
      });&lt;br /&gt;
      f.pack();&lt;br /&gt;
      f.show();&lt;br /&gt;
    } catch (Exception ex) {&lt;br /&gt;
      fireChangeStatus(&amp;quot;ERROR: Failed to Load PNG File; See Stack Trace&amp;quot;, true);&lt;br /&gt;
      ex.printStackTrace();&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
  // / Interface functions...&lt;br /&gt;
  // / ActionListener interface function&lt;br /&gt;
  // / Responds to JMenuItem, JTextField and JButton actions&lt;br /&gt;
  public void actionPerformed(ActionEvent e) {&lt;br /&gt;
    Object source = e.getSource();&lt;br /&gt;
    if (source instanceof JMenuItem) {&lt;br /&gt;
      JMenuItem mi = (JMenuItem) source;&lt;br /&gt;
      String itemName = mi.getText();&lt;br /&gt;
      if (itemName.equals(&amp;quot;Save Selected Options...&amp;quot;)) {&lt;br /&gt;
        String fileName = promptFile(true, &amp;quot;options.txt&amp;quot;);&lt;br /&gt;
        if (fileName != null)&lt;br /&gt;
          writeCurrentOptions(fileName);&lt;br /&gt;
      } else if (itemName.equals(&amp;quot;Load Options...&amp;quot;)) {&lt;br /&gt;
        String fileName = promptFile(false, &amp;quot;options.txt&amp;quot;);&lt;br /&gt;
        if (fileName != null)&lt;br /&gt;
          loadOptions(fileName);&lt;br /&gt;
      } else if (itemName.equals(&amp;quot;Save as PNG...&amp;quot;)) {&lt;br /&gt;
        String fileName = promptFile(true, fontMenu.getSelectedItem() + &amp;quot;.png&amp;quot;);&lt;br /&gt;
        if (fileName != null)&lt;br /&gt;
          fp.doSavePNG(fileName);&lt;br /&gt;
      } else if (itemName.equals(&amp;quot;Load PNG File to Compare...&amp;quot;)) {&lt;br /&gt;
        String fileName = promptFile(false, null);&lt;br /&gt;
        if (fileName != null)&lt;br /&gt;
          loadComparisonPNG(fileName);&lt;br /&gt;
      } else if (itemName.equals(&amp;quot;Page Setup...&amp;quot;))&lt;br /&gt;
        fp.doPageSetup();&lt;br /&gt;
      else if (itemName.equals(&amp;quot;Print...&amp;quot;))&lt;br /&gt;
        printDialog.show();&lt;br /&gt;
      else if (itemName.equals(&amp;quot;Close&amp;quot;))&lt;br /&gt;
        parent.dispose();&lt;br /&gt;
      else if (itemName.equals(&amp;quot;Exit&amp;quot;))&lt;br /&gt;
        System.exit(0);&lt;br /&gt;
    }&lt;br /&gt;
    else if (source instanceof JTextField) {&lt;br /&gt;
      JTextField tf = (JTextField) source;&lt;br /&gt;
      float sz = 12f;&lt;br /&gt;
      try {&lt;br /&gt;
        sz = Float.parseFloat(sizeField.getText());&lt;br /&gt;
        if (sz &amp;lt; 1f || sz &amp;gt; 120f) {&lt;br /&gt;
          sz = 12f;&lt;br /&gt;
          sizeField.setText(&amp;quot;12&amp;quot;);&lt;br /&gt;
        }&lt;br /&gt;
      } catch (Exception se) {&lt;br /&gt;
        sizeField.setText(&amp;quot;12&amp;quot;);&lt;br /&gt;
      }&lt;br /&gt;
      if (tf == sizeField)&lt;br /&gt;
        fp.setFontParams(fontMenu.getSelectedItem(), sz, styleMenu.getSelectedIndex(),&lt;br /&gt;
            transformMenu.getSelectedIndex());&lt;br /&gt;
    }&lt;br /&gt;
    else if (source instanceof JButton) {&lt;br /&gt;
      String itemName = ((JButton) source).getText();&lt;br /&gt;
      // / Print dialog buttons...&lt;br /&gt;
      if (itemName.equals(&amp;quot;Print&amp;quot;)) {&lt;br /&gt;
        for (int i = 0; i &amp;lt; printModeCBs.length; i++)&lt;br /&gt;
          if (printModeCBs[i].isSelected()) {&lt;br /&gt;
            printDialog.hide();&lt;br /&gt;
            fp.doPrint(i);&lt;br /&gt;
          }&lt;br /&gt;
      } else if (itemName.equals(&amp;quot;Cancel&amp;quot;))&lt;br /&gt;
        printDialog.hide();&lt;br /&gt;
      // / Update button from Usert Text JDialog...&lt;br /&gt;
      else if (itemName.equals(&amp;quot;Update&amp;quot;))&lt;br /&gt;
        fp.setTextToDraw(fp.USER_TEXT, null, parseUserText(userTextArea.getText()), null);&lt;br /&gt;
    } else if (source instanceof JComboBox) {&lt;br /&gt;
      JComboBox c = (JComboBox) source;&lt;br /&gt;
      // / RangeMenu handles actions by itself and then calls fireRangeChanged,&lt;br /&gt;
      // / so it is not listed or handled here&lt;br /&gt;
      if (c == fontMenu || c == styleMenu || c == transformMenu) {&lt;br /&gt;
        float sz = 12f;&lt;br /&gt;
        try {&lt;br /&gt;
          sz = Float.parseFloat(sizeField.getText());&lt;br /&gt;
          if (sz &amp;lt; 1f || sz &amp;gt; 120f) {&lt;br /&gt;
            sz = 12f;&lt;br /&gt;
            sizeField.setText(&amp;quot;12&amp;quot;);&lt;br /&gt;
          }&lt;br /&gt;
        } catch (Exception se) {&lt;br /&gt;
          sizeField.setText(&amp;quot;12&amp;quot;);&lt;br /&gt;
        }&lt;br /&gt;
        fp.setFontParams(fontMenu.getSelectedItem(), sz, styleMenu.getSelectedIndex(),&lt;br /&gt;
            transformMenu.getSelectedIndex());&lt;br /&gt;
      } else if (c == methodsMenu)&lt;br /&gt;
        fp.setDrawMethod(methodsMenu.getSelectedIndex());&lt;br /&gt;
      else if (c == textMenu) {&lt;br /&gt;
        if (canDisplayCheck) {&lt;br /&gt;
          fireRangeChanged();&lt;br /&gt;
        }&lt;br /&gt;
        int selected = textMenu.getSelectedIndex();&lt;br /&gt;
        if (selected == fp.RANGE_TEXT)&lt;br /&gt;
          fp.setTextToDraw(fp.RANGE_TEXT, rm.getSelectedRange(), null, null);&lt;br /&gt;
        else if (selected == fp.USER_TEXT)&lt;br /&gt;
          fp.setTextToDraw(fp.USER_TEXT, null, parseUserText(userTextArea.getText()), null);&lt;br /&gt;
        else if (selected == fp.FILE_TEXT) {&lt;br /&gt;
          String fileName = promptFile(false, null);&lt;br /&gt;
          if (fileName != null) {&lt;br /&gt;
            tFileName = fileName;&lt;br /&gt;
            readTextFile(fileName);&lt;br /&gt;
          } else {&lt;br /&gt;
            // / User cancelled selection; reset to previous choice&lt;br /&gt;
            c.setSelectedIndex(currentTextChoice);&lt;br /&gt;
            return;&lt;br /&gt;
          }&lt;br /&gt;
        } else if (selected == fp.ALL_GLYPHS)&lt;br /&gt;
          fp.setTextToDraw(fp.ALL_GLYPHS, null, null, null);&lt;br /&gt;
        updateGUI();&lt;br /&gt;
        currentTextChoice = selected;&lt;br /&gt;
      } else if (c == transformMenuG2) {&lt;br /&gt;
        fp.setTransformG2(transformMenuG2.getSelectedIndex());&lt;br /&gt;
      } else if (c == antiAliasMenu || c == fracMetricsMenu) {&lt;br /&gt;
        if (c == antiAliasMenu) {&lt;br /&gt;
          boolean enabled = FontPanel.AAValues.isLCDMode(antiAliasMenu.getSelectedItem());&lt;br /&gt;
          contrastSlider.setEnabled(enabled);&lt;br /&gt;
        }&lt;br /&gt;
        fp.setRenderingHints(antiAliasMenu.getSelectedItem(), fracMetricsMenu.getSelectedItem(),&lt;br /&gt;
            contrastSlider.getValue());&lt;br /&gt;
      }&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
  public void stateChanged(ChangeEvent e) {&lt;br /&gt;
    Object source = e.getSource();&lt;br /&gt;
    if (source instanceof JSlider) {&lt;br /&gt;
      fp.setRenderingHints(antiAliasMenu.getSelectedItem(), fracMetricsMenu.getSelectedItem(),&lt;br /&gt;
          contrastSlider.getValue());&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
  // / ItemListener interface function&lt;br /&gt;
  // / Responds to JCheckBoxMenuItem, JComboBox and JCheckBox actions&lt;br /&gt;
  public void itemStateChanged(ItemEvent e) {&lt;br /&gt;
    Object source = e.getSource();&lt;br /&gt;
    if (source instanceof JCheckBoxMenuItem) {&lt;br /&gt;
      JCheckBoxMenuItem cbmi = (JCheckBoxMenuItem) source;&lt;br /&gt;
      if (cbmi == displayGridCBMI)&lt;br /&gt;
        fp.setGridDisplay(displayGridCBMI.getState());&lt;br /&gt;
      else if (cbmi == force16ColsCBMI)&lt;br /&gt;
        fp.setForce16Columns(force16ColsCBMI.getState());&lt;br /&gt;
      else if (cbmi == showFontInfoCBMI) {&lt;br /&gt;
        if (showFontInfoCBMI.getState()) {&lt;br /&gt;
          fireUpdateFontInfo();&lt;br /&gt;
          fontInfoDialog.show();&lt;br /&gt;
        } else&lt;br /&gt;
          fontInfoDialog.hide();&lt;br /&gt;
      }&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
  private static void printUsage() {&lt;br /&gt;
    String usage = &amp;quot;Usage: java -jar Font2DTest.jar [options]\n&amp;quot; + &amp;quot;\nwhere options include:\n&amp;quot;&lt;br /&gt;
        + &amp;quot;    -dcdc | -disablecandisplaycheck disable canDisplay check for font\n&amp;quot;&lt;br /&gt;
        + &amp;quot;    -?    | -help                   print this help message\n&amp;quot; + &amp;quot;\nExample :\n&amp;quot;&lt;br /&gt;
        + &amp;quot;     To disable canDisplay check on font for ranges\n&amp;quot;&lt;br /&gt;
        + &amp;quot;     java -jar Font2DTest.jar -dcdc&amp;quot;;&lt;br /&gt;
    System.out.println(usage);&lt;br /&gt;
    System.exit(0);&lt;br /&gt;
  }&lt;br /&gt;
  // / Main function&lt;br /&gt;
  public static void main(String argv[]) {&lt;br /&gt;
    if (argv.length &amp;gt; 0) {&lt;br /&gt;
      if (argv[0].equalsIgnoreCase(&amp;quot;-disablecandisplaycheck&amp;quot;) || argv[0].equalsIgnoreCase(&amp;quot;-dcdc&amp;quot;)) {&lt;br /&gt;
        canDisplayCheck = false;&lt;br /&gt;
      } else {&lt;br /&gt;
        printUsage();&lt;br /&gt;
      }&lt;br /&gt;
    }&lt;br /&gt;
    UIManager.put(&amp;quot;swing.boldMetal&amp;quot;, Boolean.FALSE);&lt;br /&gt;
    final JFrame f = new JFrame(&amp;quot;Font2DTest&amp;quot;);&lt;br /&gt;
    final Font2DTest f2dt = new Font2DTest(f, false);&lt;br /&gt;
    f.addWindowListener(new WindowAdapter() {&lt;br /&gt;
      public void windowOpening(WindowEvent e) {&lt;br /&gt;
        f2dt.repaint();&lt;br /&gt;
      }&lt;br /&gt;
      public void windowClosing(WindowEvent e) {&lt;br /&gt;
        System.exit(0);&lt;br /&gt;
      }&lt;br /&gt;
    });&lt;br /&gt;
    f.getContentPane().add(f2dt);&lt;br /&gt;
    f.pack();&lt;br /&gt;
    f.show();&lt;br /&gt;
  }&lt;br /&gt;
  // / Inner class definitions...&lt;br /&gt;
  // / Class to display just an image file&lt;br /&gt;
  // / Used to show the comparison PNG image&lt;br /&gt;
  private final class ImagePanel extends JPanel {&lt;br /&gt;
    private final BufferedImage bi;&lt;br /&gt;
    public ImagePanel(BufferedImage image) {&lt;br /&gt;
      bi = image;&lt;br /&gt;
    }&lt;br /&gt;
    public Dimension getPreferredSize() {&lt;br /&gt;
      return new Dimension(bi.getWidth(), bi.getHeight());&lt;br /&gt;
    }&lt;br /&gt;
    public void paintComponent(Graphics g) {&lt;br /&gt;
      g.drawImage(bi, 0, 0, this);&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
  // / Classes made to avoid repetitive calls... (being lazy)&lt;br /&gt;
  private final class ButtonV2 extends JButton {&lt;br /&gt;
    public ButtonV2(String name, ActionListener al) {&lt;br /&gt;
      super(name);&lt;br /&gt;
      this.addActionListener(al);&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
  private final class ChoiceV2 extends JComboBox {&lt;br /&gt;
    private BitSet bitSet = null;&lt;br /&gt;
    public ChoiceV2() {&lt;br /&gt;
      ;&lt;br /&gt;
    }&lt;br /&gt;
    public ChoiceV2(ActionListener al) {&lt;br /&gt;
      super();&lt;br /&gt;
      this.addActionListener(al);&lt;br /&gt;
    }&lt;br /&gt;
    public ChoiceV2(ActionListener al, boolean fontChoice) {&lt;br /&gt;
      this(al);&lt;br /&gt;
      if (fontChoice) {&lt;br /&gt;
        // Register this component in ToolTipManager&lt;br /&gt;
        setToolTipText(&amp;quot;&amp;quot;);&lt;br /&gt;
        bitSet = new BitSet();&lt;br /&gt;
        setRenderer(new ChoiceV2Renderer(this));&lt;br /&gt;
      }&lt;br /&gt;
    }&lt;br /&gt;
    public String getToolTipText() {&lt;br /&gt;
      int index = this.getSelectedIndex();&lt;br /&gt;
      String fontName = (String) this.getSelectedItem();&lt;br /&gt;
      if (fontName != null &amp;amp;&amp;amp; (textMenu.getSelectedIndex() == fp.RANGE_TEXT)) {&lt;br /&gt;
        if (getBit(index)) {&lt;br /&gt;
          return &amp;quot;Font \&amp;quot;&amp;quot; + fontName + &amp;quot;\&amp;quot; can display some characters in \&amp;quot;&amp;quot;&lt;br /&gt;
              + rm.getSelectedItem() + &amp;quot;\&amp;quot; range&amp;quot;;&lt;br /&gt;
        } else {&lt;br /&gt;
          return &amp;quot;Font \&amp;quot;&amp;quot; + fontName + &amp;quot;\&amp;quot; cannot display any characters in \&amp;quot;&amp;quot;&lt;br /&gt;
              + rm.getSelectedItem() + &amp;quot;\&amp;quot; range&amp;quot;;&lt;br /&gt;
        }&lt;br /&gt;
      }&lt;br /&gt;
      return super.getToolTipText();&lt;br /&gt;
    }&lt;br /&gt;
    public void setBit(int bitIndex, boolean value) {&lt;br /&gt;
      bitSet.set(bitIndex, value);&lt;br /&gt;
    }&lt;br /&gt;
    public boolean getBit(int bitIndex) {&lt;br /&gt;
      return bitSet.get(bitIndex);&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
  private final class ChoiceV2Renderer extends DefaultListCellRenderer {&lt;br /&gt;
    private ImageIcon yesImage, blankImage;&lt;br /&gt;
    private ChoiceV2 choice = null;&lt;br /&gt;
    public ChoiceV2Renderer(ChoiceV2 choice) {&lt;br /&gt;
      try {&lt;br /&gt;
        yesImage = new ImageIcon(getClass().getResource(&amp;quot;yes.gif&amp;quot;));&lt;br /&gt;
        blankImage = new ImageIcon(getClass().getResource(&amp;quot;blank.gif&amp;quot;));&lt;br /&gt;
      } catch (Exception exception) {&lt;br /&gt;
        System.out.println(&amp;quot;Exception : &amp;quot; + exception);&lt;br /&gt;
      }&lt;br /&gt;
      this.choice = choice;&lt;br /&gt;
    }&lt;br /&gt;
    public Component getListCellRendererComponent(JList list, Object value, int index,&lt;br /&gt;
        boolean isSelected, boolean cellHasFocus) {&lt;br /&gt;
      if (textMenu.getSelectedIndex() == fp.RANGE_TEXT) {&lt;br /&gt;
        super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);&lt;br /&gt;
        // For JComboBox if index is -1, its rendering the selected index.&lt;br /&gt;
        if (index == -1) {&lt;br /&gt;
          index = choice.getSelectedIndex();&lt;br /&gt;
        }&lt;br /&gt;
        if (choice.getBit(index)) {&lt;br /&gt;
          setIcon(yesImage);&lt;br /&gt;
        } else {&lt;br /&gt;
          setIcon(blankImage);&lt;br /&gt;
        }&lt;br /&gt;
      } else {&lt;br /&gt;
        super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);&lt;br /&gt;
        setIcon(blankImage);&lt;br /&gt;
      }&lt;br /&gt;
      return this;&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
  private final class LabelV2 extends JLabel {&lt;br /&gt;
    public LabelV2(String name) {&lt;br /&gt;
      super(name);&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
  private final class MenuItemV2 extends JMenuItem {&lt;br /&gt;
    public MenuItemV2(String name, ActionListener al) {&lt;br /&gt;
      super(name);&lt;br /&gt;
      this.addActionListener(al);&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
  private final class CheckboxMenuItemV2 extends JCheckBoxMenuItem {&lt;br /&gt;
    public CheckboxMenuItemV2(String name, boolean b, ItemListener il) {&lt;br /&gt;
      super(name, b);&lt;br /&gt;
      this.addItemListener(il);&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
/*&lt;br /&gt;
 * @(#)FontPanel.java 1.20 05/11/17&lt;br /&gt;
 * &lt;br /&gt;
 * Copyright (c) 2006 Sun Microsystems, Inc. All Rights Reserved.&lt;br /&gt;
 * &lt;br /&gt;
 * Redistribution and use in source and binary forms, with or without&lt;br /&gt;
 * modification, are permitted provided that the following conditions are met:&lt;br /&gt;
 * &lt;br /&gt;
 * -Redistribution of source code must retain the above copyright notice, this&lt;br /&gt;
 * list of conditions and the following disclaimer.&lt;br /&gt;
 * &lt;br /&gt;
 * -Redistribution in binary form must reproduce the above copyright notice,&lt;br /&gt;
 * this list of conditions and the following disclaimer in the documentation&lt;br /&gt;
 * and/or other materials provided with the distribution.&lt;br /&gt;
 * &lt;br /&gt;
 * Neither the name of Sun Microsystems, Inc. or the names of contributors may&lt;br /&gt;
 * be used to endorse or promote products derived from this software without&lt;br /&gt;
 * specific prior written permission.&lt;br /&gt;
 * &lt;br /&gt;
 * This software is provided &amp;quot;AS IS,&amp;quot; without a warranty of any kind. ALL&lt;br /&gt;
 * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING ANY&lt;br /&gt;
 * IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR&lt;br /&gt;
 * NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN MIDROSYSTEMS, INC. (&amp;quot;SUN&amp;quot;) AND ITS&lt;br /&gt;
 * LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A&lt;br /&gt;
 * RESULT OF USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES.&lt;br /&gt;
 * IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT&lt;br /&gt;
 * OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR&lt;br /&gt;
 * PUNITIVE DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY,&lt;br /&gt;
 * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF SUN HAS&lt;br /&gt;
 * BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.&lt;br /&gt;
 * &lt;br /&gt;
 * You acknowledge that this software is not designed, licensed or intended for&lt;br /&gt;
 * use in the design, construction, operation or maintenance of any nuclear&lt;br /&gt;
 * facility.&lt;br /&gt;
 */&lt;br /&gt;
/*&lt;br /&gt;
 * @(#)FontPanel.java 1.20 05/11/17&lt;br /&gt;
 */&lt;br /&gt;
/**&lt;br /&gt;
 * FontPanel.java&lt;br /&gt;
 * &lt;br /&gt;
 * @version&lt;br /&gt;
 * @(#)FontPanel.java 1.1 00/08/22&lt;br /&gt;
 * @author Shinsuke Fukuda&lt;br /&gt;
 * @author Ankit Patel [Conversion to Swing - 01/07/30]&lt;br /&gt;
 */&lt;br /&gt;
// / This panel is combination of the text drawing area of Font2DTest&lt;br /&gt;
// / and the custom controlled scroll bar&lt;br /&gt;
final class FontPanel extends JPanel implements AdjustmentListener {&lt;br /&gt;
  // / Drawing Option Constants&lt;br /&gt;
  private final String STYLES[] = { &amp;quot;plain&amp;quot;, &amp;quot;bold&amp;quot;, &amp;quot;italic&amp;quot;, &amp;quot;bold italic&amp;quot; };&lt;br /&gt;
  private final int NONE = 0;&lt;br /&gt;
  private final int SCALE = 1;&lt;br /&gt;
  private final int SHEAR = 2;&lt;br /&gt;
  private final int ROTATE = 3;&lt;br /&gt;
  private final String TRANSFORMS[] = { &amp;quot;with no transforms&amp;quot;, &amp;quot;with scaling&amp;quot;, &amp;quot;with Shearing&amp;quot;,&lt;br /&gt;
      &amp;quot;with rotation&amp;quot; };&lt;br /&gt;
  private final int DRAW_STRING = 0;&lt;br /&gt;
  private final int DRAW_CHARS = 1;&lt;br /&gt;
  private final int DRAW_BYTES = 2;&lt;br /&gt;
  private final int DRAW_GLYPHV = 3;&lt;br /&gt;
  private final int TL_DRAW = 4;&lt;br /&gt;
  private final int GV_OUTLINE = 5;&lt;br /&gt;
  private final int TL_OUTLINE = 6;&lt;br /&gt;
  private final String METHODS[] = { &amp;quot;drawString&amp;quot;, &amp;quot;drawChars&amp;quot;, &amp;quot;drawBytes&amp;quot;, &amp;quot;drawGlyphVector&amp;quot;,&lt;br /&gt;
      &amp;quot;TextLayout.draw&amp;quot;, &amp;quot;GlyphVector.getOutline&amp;quot;, &amp;quot;TextLayout.getOutline&amp;quot; };&lt;br /&gt;
  public final int RANGE_TEXT = 0;&lt;br /&gt;
  public final int ALL_GLYPHS = 1;&lt;br /&gt;
  public final int USER_TEXT = 2;&lt;br /&gt;
  public final int FILE_TEXT = 3;&lt;br /&gt;
  private final String MS_OPENING[] = { &amp;quot; Unicode &amp;quot;, &amp;quot; Glyph Code &amp;quot;, &amp;quot; lines &amp;quot;, &amp;quot; lines &amp;quot; };&lt;br /&gt;
  private final String MS_CLOSING[] = { &amp;quot;&amp;quot;, &amp;quot;&amp;quot;, &amp;quot; of User Text &amp;quot;,&lt;br /&gt;
      &amp;quot; of LineBreakMeasurer-reformatted Text &amp;quot; };&lt;br /&gt;
  // / General Graphics Variable&lt;br /&gt;
  private final JScrollBar verticalBar;&lt;br /&gt;
  private final FontCanvas fc;&lt;br /&gt;
  private boolean updateBackBuffer = true;&lt;br /&gt;
  private boolean updateFontMetrics = true;&lt;br /&gt;
  private boolean updateFont = true;&lt;br /&gt;
  private boolean force16Cols = false;&lt;br /&gt;
  public boolean showingError = false;&lt;br /&gt;
  private int g2Transform = NONE; // / ABP&lt;br /&gt;
  // / Printing constants and variables&lt;br /&gt;
  public final int ONE_PAGE = 0;&lt;br /&gt;
  public final int CUR_RANGE = 1;&lt;br /&gt;
  public final int ALL_TEXT = 2;&lt;br /&gt;
  private int printMode = ONE_PAGE;&lt;br /&gt;
  private PageFormat page = null;&lt;br /&gt;
  private PrinterJob printer = null;&lt;br /&gt;
  // / Text drawing variables&lt;br /&gt;
  private String fontName = &amp;quot;Dialog&amp;quot;;&lt;br /&gt;
  private float fontSize = 12;&lt;br /&gt;
  private int fontStyle = Font.PLAIN;&lt;br /&gt;
  private int fontTransform = NONE;&lt;br /&gt;
  private Font testFont = null;&lt;br /&gt;
  private Object antiAliasType = VALUE_TEXT_ANTIALIAS_DEFAULT;&lt;br /&gt;
  private Object fractionalMetricsType = VALUE_FRACTIONALMETRICS_DEFAULT;&lt;br /&gt;
  private Object lcdContrast = getDefaultLCDContrast();&lt;br /&gt;
  private int drawMethod = DRAW_STRING;&lt;br /&gt;
  private int textToUse = RANGE_TEXT;&lt;br /&gt;
  private String userText[] = null;&lt;br /&gt;
  private String fileText[] = null;&lt;br /&gt;
  private int drawRange[] = { 0x0000, 0x007f };&lt;br /&gt;
  private String fontInfos[] = new String[2];&lt;br /&gt;
  private boolean showGrid = true;&lt;br /&gt;
  // / Parent Font2DTest panel&lt;br /&gt;
  private final Font2DTest f2dt;&lt;br /&gt;
  private final JFrame parent;&lt;br /&gt;
  public FontPanel(Font2DTest demo, JFrame f) {&lt;br /&gt;
    f2dt = demo;&lt;br /&gt;
    parent = f;&lt;br /&gt;
    verticalBar = new JScrollBar(JScrollBar.VERTICAL);&lt;br /&gt;
    fc = new FontCanvas();&lt;br /&gt;
    this.setLayout(new BorderLayout());&lt;br /&gt;
    this.add(&amp;quot;Center&amp;quot;, fc);&lt;br /&gt;
    this.add(&amp;quot;East&amp;quot;, verticalBar);&lt;br /&gt;
    verticalBar.addAdjustmentListener(this);&lt;br /&gt;
    this.addComponentListener(new ComponentAdapter() {&lt;br /&gt;
      public void componentResized(ComponentEvent e) {&lt;br /&gt;
        updateBackBuffer = true;&lt;br /&gt;
        updateFontMetrics = true;&lt;br /&gt;
      }&lt;br /&gt;
    });&lt;br /&gt;
    // / Initialize font and its infos&lt;br /&gt;
    testFont = new Font(fontName, fontStyle, (int) fontSize);&lt;br /&gt;
    if ((float) ((int) fontSize) != fontSize) {&lt;br /&gt;
      testFont = testFont.deriveFont(fontSize);&lt;br /&gt;
    }&lt;br /&gt;
    updateFontInfo();&lt;br /&gt;
  }&lt;br /&gt;
  public Dimension getPreferredSize() {&lt;br /&gt;
    return new Dimension(600, 200);&lt;br /&gt;
  }&lt;br /&gt;
  // / Functions called by the main programs to set the various parameters&lt;br /&gt;
  public void setTransformG2(int transform) {&lt;br /&gt;
    g2Transform = transform;&lt;br /&gt;
    updateBackBuffer = true;&lt;br /&gt;
    updateFontMetrics = true;&lt;br /&gt;
    fc.repaint();&lt;br /&gt;
  }&lt;br /&gt;
  // / convenience fcn to create AffineTransform of appropriate type&lt;br /&gt;
  private AffineTransform getAffineTransform(int transform) {&lt;br /&gt;
    // / ABP&lt;br /&gt;
    AffineTransform at = new AffineTransform();&lt;br /&gt;
    switch (transform) {&lt;br /&gt;
    case SCALE:&lt;br /&gt;
      at.setToScale(1.5f, 1.5f);&lt;br /&gt;
      break;&lt;br /&gt;
    case ROTATE:&lt;br /&gt;
      at.setToRotation(Math.PI / 6);&lt;br /&gt;
      break;&lt;br /&gt;
    case SHEAR:&lt;br /&gt;
      at.setToShear(0.4f, 0);&lt;br /&gt;
      break;&lt;br /&gt;
    case NONE:&lt;br /&gt;
      break;&lt;br /&gt;
    default:&lt;br /&gt;
      // System.err.println( &amp;quot;Illegal G2 Transform Arg: &amp;quot; + transform);&lt;br /&gt;
      break;&lt;br /&gt;
    }&lt;br /&gt;
    return at;&lt;br /&gt;
  }&lt;br /&gt;
  public void setFontParams(Object obj, float size, int style, int transform) {&lt;br /&gt;
    setFontParams((String) obj, size, style, transform);&lt;br /&gt;
  }&lt;br /&gt;
  public void setFontParams(String name, float size, int style, int transform) {&lt;br /&gt;
    boolean fontModified = false;&lt;br /&gt;
    if (!name.equals(fontName) || style != fontStyle)&lt;br /&gt;
      fontModified = true;&lt;br /&gt;
    fontName = name;&lt;br /&gt;
    fontSize = size;&lt;br /&gt;
    fontStyle = style;&lt;br /&gt;
    fontTransform = transform;&lt;br /&gt;
    // / Recreate the font as specified&lt;br /&gt;
    testFont = new Font(fontName, fontStyle, (int) fontSize);&lt;br /&gt;
    if ((float) ((int) fontSize) != fontSize) {&lt;br /&gt;
      testFont = testFont.deriveFont(fontSize);&lt;br /&gt;
    }&lt;br /&gt;
    if (fontTransform != NONE) {&lt;br /&gt;
      AffineTransform at = getAffineTransform(fontTransform);&lt;br /&gt;
      testFont = testFont.deriveFont(at);&lt;br /&gt;
    }&lt;br /&gt;
    updateBackBuffer = true;&lt;br /&gt;
    updateFontMetrics = true;&lt;br /&gt;
    fc.repaint();&lt;br /&gt;
    if (fontModified) {&lt;br /&gt;
      // / Tell main panel to update the font info&lt;br /&gt;
      updateFontInfo();&lt;br /&gt;
      f2dt.fireUpdateFontInfo();&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
  public void setRenderingHints(Object aa, Object fm, Object contrast) {&lt;br /&gt;
    antiAliasType = ((AAValues) aa).getHint();&lt;br /&gt;
    fractionalMetricsType = ((FMValues) fm).getHint();&lt;br /&gt;
    lcdContrast = contrast;&lt;br /&gt;
    updateBackBuffer = true;&lt;br /&gt;
    updateFontMetrics = true;&lt;br /&gt;
    fc.repaint();&lt;br /&gt;
  }&lt;br /&gt;
  public void setDrawMethod(int i) {&lt;br /&gt;
    drawMethod = i;&lt;br /&gt;
    updateBackBuffer = true;&lt;br /&gt;
    fc.repaint();&lt;br /&gt;
  }&lt;br /&gt;
  public void setTextToDraw(int i, int range[], String textSet[], String fileData[]) {&lt;br /&gt;
    textToUse = i;&lt;br /&gt;
    if (textToUse == RANGE_TEXT)&lt;br /&gt;
      drawRange = range;&lt;br /&gt;
    else if (textToUse == ALL_GLYPHS)&lt;br /&gt;
      drawMethod = DRAW_GLYPHV;&lt;br /&gt;
    else if (textToUse == USER_TEXT)&lt;br /&gt;
      userText = textSet;&lt;br /&gt;
    else if (textToUse == FILE_TEXT) {&lt;br /&gt;
      fileText = fileData;&lt;br /&gt;
      drawMethod = TL_DRAW;&lt;br /&gt;
    }&lt;br /&gt;
    updateBackBuffer = true;&lt;br /&gt;
    updateFontMetrics = true;&lt;br /&gt;
    fc.repaint();&lt;br /&gt;
    updateFontInfo();&lt;br /&gt;
  }&lt;br /&gt;
  public void setGridDisplay(boolean b) {&lt;br /&gt;
    showGrid = b;&lt;br /&gt;
    updateBackBuffer = true;&lt;br /&gt;
    fc.repaint();&lt;br /&gt;
  }&lt;br /&gt;
  public void setForce16Columns(boolean b) {&lt;br /&gt;
    force16Cols = b;&lt;br /&gt;
    updateBackBuffer = true;&lt;br /&gt;
    updateFontMetrics = true;&lt;br /&gt;
    fc.repaint();&lt;br /&gt;
  }&lt;br /&gt;
  // / Prints out the text display area&lt;br /&gt;
  public void doPrint(int i) {&lt;br /&gt;
    if (printer == null) {&lt;br /&gt;
      printer = PrinterJob.getPrinterJob();&lt;br /&gt;
      page = printer.defaultPage();&lt;br /&gt;
    }&lt;br /&gt;
    printMode = i;&lt;br /&gt;
    printer.setPrintable(fc, page);&lt;br /&gt;
    if (printer.printDialog()) {&lt;br /&gt;
      try {&lt;br /&gt;
        printer.print();&lt;br /&gt;
      } catch (Exception e) {&lt;br /&gt;
        f2dt.fireChangeStatus(&amp;quot;ERROR: Printing Failed; See Stack Trace&amp;quot;, true);&lt;br /&gt;
      }&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
  // / Displays the page setup dialog and updates PageFormat info&lt;br /&gt;
  public void doPageSetup() {&lt;br /&gt;
    if (printer == null) {&lt;br /&gt;
      printer = PrinterJob.getPrinterJob();&lt;br /&gt;
      page = printer.defaultPage();&lt;br /&gt;
    }&lt;br /&gt;
    page = printer.pageDialog(page);&lt;br /&gt;
  }&lt;br /&gt;
  // / Obtains the information about selected font&lt;br /&gt;
  private void updateFontInfo() {&lt;br /&gt;
    int numGlyphs = 0, numCharsInRange = drawRange[1] - drawRange[0] + 1;&lt;br /&gt;
    fontInfos[0] = &amp;quot;Font Face Name: &amp;quot; + testFont.getFontName();&lt;br /&gt;
    fontInfos[1] = &amp;quot;Glyphs in This Range: &amp;quot;;&lt;br /&gt;
    if (textToUse == RANGE_TEXT) {&lt;br /&gt;
      for (int i = drawRange[0]; i &amp;lt; drawRange[1]; i++)&lt;br /&gt;
        if (testFont.canDisplay(i))&lt;br /&gt;
          numGlyphs++;&lt;br /&gt;
      fontInfos[1] = fontInfos[1] + numGlyphs + &amp;quot; / &amp;quot; + numCharsInRange;&lt;br /&gt;
    } else&lt;br /&gt;
      fontInfos[1] = null;&lt;br /&gt;
  }&lt;br /&gt;
  // / Accessor for the font information&lt;br /&gt;
  public String[] getFontInfo() {&lt;br /&gt;
    return fontInfos;&lt;br /&gt;
  }&lt;br /&gt;
  // / Collects the currectly set options and returns them as string&lt;br /&gt;
  public String getCurrentOptions() {&lt;br /&gt;
    // / Create a new String to store the options&lt;br /&gt;
    // / The array will contain all 8 setting (font name, size...) and&lt;br /&gt;
    // / character range or user text data used (no file text data)&lt;br /&gt;
    int userTextSize = 0;&lt;br /&gt;
    String options;&lt;br /&gt;
    options = (fontName + &amp;quot;\n&amp;quot; + fontSize + &amp;quot;\n&amp;quot; + fontStyle + &amp;quot;\n&amp;quot; + fontTransform + &amp;quot;\n&amp;quot;&lt;br /&gt;
        + g2Transform + &amp;quot;\n&amp;quot; + textToUse + &amp;quot;\n&amp;quot; + drawMethod + &amp;quot;\n&amp;quot;&lt;br /&gt;
        + AAValues.getHintVal(antiAliasType) + &amp;quot;\n&amp;quot; + FMValues.getHintVal(fractionalMetricsType)&lt;br /&gt;
        + &amp;quot;\n&amp;quot; + lcdContrast + &amp;quot;\n&amp;quot;);&lt;br /&gt;
    if (textToUse == USER_TEXT)&lt;br /&gt;
      for (int i = 0; i &amp;lt; userText.length; i++)&lt;br /&gt;
        options += (userText[i] + &amp;quot;\n&amp;quot;);&lt;br /&gt;
    return options;&lt;br /&gt;
  }&lt;br /&gt;
  // / Reload all options and refreshes the canvas&lt;br /&gt;
  public void loadOptions(boolean grid, boolean force16, int start, int end, String name,&lt;br /&gt;
      float size, int style, int transform, int g2transform, int text, int method, int aa, int fm,&lt;br /&gt;
      int contrast, String user[]) {&lt;br /&gt;
    int range[] = { start, end };&lt;br /&gt;
    // / Since repaint call has a low priority, these functions will finish&lt;br /&gt;
    // / before the actual repainting is done&lt;br /&gt;
    setGridDisplay(grid);&lt;br /&gt;
    setForce16Columns(force16);&lt;br /&gt;
    // previous call to readTextFile has already set the text to draw&lt;br /&gt;
    if (textToUse != FILE_TEXT) {&lt;br /&gt;
      setTextToDraw(text, range, user, null);&lt;br /&gt;
    }&lt;br /&gt;
    setFontParams(name, size, style, transform);&lt;br /&gt;
    setTransformG2(g2transform); // ABP&lt;br /&gt;
    setDrawMethod(method);&lt;br /&gt;
    setRenderingHints(AAValues.getValue(aa), FMValues.getValue(fm), new Integer(contrast));&lt;br /&gt;
  }&lt;br /&gt;
  // / Writes the current screen to PNG file&lt;br /&gt;
  public void doSavePNG(String fileName) {&lt;br /&gt;
    fc.writePNG(fileName);&lt;br /&gt;
  }&lt;br /&gt;
  // / When scrolled using the scroll bar, update the backbuffer&lt;br /&gt;
  public void adjustmentValueChanged(AdjustmentEvent e) {&lt;br /&gt;
    updateBackBuffer = true;&lt;br /&gt;
    fc.repaint();&lt;br /&gt;
  }&lt;br /&gt;
  public void paintComponent(Graphics g) {&lt;br /&gt;
    // Windows does not repaint correctly, after&lt;br /&gt;
    // a zoom. Thus, we need to force the canvas&lt;br /&gt;
    // to repaint, but only once. After the first repaint,&lt;br /&gt;
    // everything stabilizes. [ABP]&lt;br /&gt;
    fc.repaint();&lt;br /&gt;
  }&lt;br /&gt;
  // / Inner class definition...&lt;br /&gt;
  // / Inner panel that holds the actual drawing area and its routines&lt;br /&gt;
  private class FontCanvas extends JPanel implements MouseListener, MouseMotionListener, Printable {&lt;br /&gt;
    // / Number of characters that will fit across and down this canvas&lt;br /&gt;
    private int numCharAcross, numCharDown;&lt;br /&gt;
    // / First and last character/line that will be drawn&lt;br /&gt;
    // / Limit is the end of range/text where no more draw will be done&lt;br /&gt;
    private int drawStart, drawEnd, drawLimit;&lt;br /&gt;
    // / FontMetrics variables&lt;br /&gt;
    // / Here, gridWidth is equivalent to maxAdvance (slightly bigger though)&lt;br /&gt;
    // / and gridHeight is equivalent to lineHeight&lt;br /&gt;
    private int maxAscent, maxDescent, gridWidth = 0, gridHeight = 0;&lt;br /&gt;
    // / Offset from the top left edge of the canvas where the draw will start&lt;br /&gt;
    private int canvasInset_X = 5, canvasInset_Y = 5;&lt;br /&gt;
    // / Offscreen buffer of this canvas&lt;br /&gt;
    private BufferedImage backBuffer = null;&lt;br /&gt;
    // / LineBreak&amp;quot;ed TextLayout vector&lt;br /&gt;
    private Vector lineBreakTLs = null;&lt;br /&gt;
    // / Whether the current draw command requested is for printing&lt;br /&gt;
    private boolean isPrinting = false;&lt;br /&gt;
    // / Other printing infos&lt;br /&gt;
    private int lastPage, printPageNumber, currentlyShownChar = 0;&lt;br /&gt;
    private final int PR_OFFSET = 10;&lt;br /&gt;
    private final int PR_TITLE_LINEHEIGHT = 30;&lt;br /&gt;
    // / Information about zooming (used with range text draw)&lt;br /&gt;
    private final JWindow zoomWindow;&lt;br /&gt;
    private BufferedImage zoomImage = null;&lt;br /&gt;
    private int mouseOverCharX = -1, mouseOverCharY = -1;&lt;br /&gt;
    private int currMouseOverChar = -1, prevZoomChar = -1;&lt;br /&gt;
    private float ZOOM = 2.0f;&lt;br /&gt;
    private boolean nowZooming = false;&lt;br /&gt;
    private boolean firstTime = true;&lt;br /&gt;
    // ABP&lt;br /&gt;
    // / Status bar message backup&lt;br /&gt;
    private String backupStatusString = null;&lt;br /&gt;
    // / Error constants&lt;br /&gt;
    private final String ERRORS[] = {&lt;br /&gt;
        &amp;quot;ERROR: drawBytes cannot handle characters beyond 0x00FF. Select different range or draw methods.&amp;quot;,&lt;br /&gt;
        &amp;quot;ERROR: Cannot fit text with the current font size. Resize the window or use smaller font size.&amp;quot;,&lt;br /&gt;
        &amp;quot;ERROR: Cannot print with the current font size. Use smaller font size.&amp;quot;, };&lt;br /&gt;
    private final int DRAW_BYTES_ERROR = 0;&lt;br /&gt;
    private final int CANT_FIT_DRAW = 1;&lt;br /&gt;
    private final int CANT_FIT_PRINT = 2;&lt;br /&gt;
    // / Other variables&lt;br /&gt;
    private final Cursor blankCursor;&lt;br /&gt;
    public FontCanvas() {&lt;br /&gt;
      this.addMouseListener(this);&lt;br /&gt;
      this.addMouseMotionListener(this);&lt;br /&gt;
      this.setForeground(Color.black);&lt;br /&gt;
      this.setBackground(Color.white);&lt;br /&gt;
      // / Creates an invisble pointer by giving it bogus image&lt;br /&gt;
      // / Possibly find a workaround for this...&lt;br /&gt;
      Toolkit tk = Toolkit.getDefaultToolkit();&lt;br /&gt;
      byte bogus[] = { (byte) 0 };&lt;br /&gt;
      blankCursor = tk.createCustomCursor(tk.createImage(bogus), new Point(0, 0), &amp;quot;&amp;quot;);&lt;br /&gt;
      zoomWindow = new JWindow(parent) {&lt;br /&gt;
        public void paint(Graphics g) {&lt;br /&gt;
          g.drawImage(zoomImage, 0, 0, zoomWindow);&lt;br /&gt;
        }&lt;br /&gt;
      };&lt;br /&gt;
      zoomWindow.setCursor(blankCursor);&lt;br /&gt;
      zoomWindow.pack();&lt;br /&gt;
    }&lt;br /&gt;
    public boolean firstTime() {&lt;br /&gt;
      return firstTime;&lt;br /&gt;
    }&lt;br /&gt;
    public void refresh() {&lt;br /&gt;
      firstTime = false;&lt;br /&gt;
      updateBackBuffer = true;&lt;br /&gt;
      repaint();&lt;br /&gt;
    }&lt;br /&gt;
    // / Sets the font, hints, according to the set parameters&lt;br /&gt;
    private void setParams(Graphics2D g2) {&lt;br /&gt;
      g2.setFont(testFont);&lt;br /&gt;
      g2.setRenderingHint(KEY_TEXT_ANTIALIASING, antiAliasType);&lt;br /&gt;
      g2.setRenderingHint(KEY_FRACTIONALMETRICS, fractionalMetricsType);&lt;br /&gt;
      g2.setRenderingHint(KEY_TEXT_LCD_CONTRAST, lcdContrast);&lt;br /&gt;
      /*&lt;br /&gt;
       * I am preserving a somewhat dubious behaviour of this program. Outline&lt;br /&gt;
       * text would be drawn anti-aliased by setting the graphics anti-aliasing&lt;br /&gt;
       * hint if the text anti-aliasing hint was set. The dubious element here&lt;br /&gt;
       * is that people simply using this program may think this is built-in&lt;br /&gt;
       * behaviour but its not - at least not when the app explictly draws&lt;br /&gt;
       * outline text. This becomes more dubious in cases such as &amp;quot;GASP&amp;quot; where&lt;br /&gt;
       * the size at which text is AA&amp;quot;ed is not something you can easily&lt;br /&gt;
       * calculate, so mimicing that behaviour isn&amp;quot;t going to be easy. So I&lt;br /&gt;
       * precisely preserve the behaviour : this is done only if the AA value is&lt;br /&gt;
       * &amp;quot;ON&amp;quot;. Its not applied in the other cases.&lt;br /&gt;
       */&lt;br /&gt;
      if (antiAliasType == VALUE_TEXT_ANTIALIAS_ON&lt;br /&gt;
          &amp;amp;&amp;amp; (drawMethod == TL_OUTLINE || drawMethod == GV_OUTLINE)) {&lt;br /&gt;
        g2.setRenderingHint(KEY_ANTIALIASING, VALUE_ANTIALIAS_ON);&lt;br /&gt;
      } else {&lt;br /&gt;
        g2.setRenderingHint(KEY_ANTIALIASING, VALUE_ANTIALIAS_OFF);&lt;br /&gt;
      }&lt;br /&gt;
    }&lt;br /&gt;
    // / Draws the grid (Used for unicode/glyph range drawing)&lt;br /&gt;
    private void drawGrid(Graphics2D g2) {&lt;br /&gt;
      int totalGridWidth = numCharAcross * gridWidth;&lt;br /&gt;
      int totalGridHeight = numCharDown * gridHeight;&lt;br /&gt;
      g2.setColor(Color.black);&lt;br /&gt;
      for (int i = 0; i &amp;lt; numCharDown + 1; i++)&lt;br /&gt;
        g2.drawLine(canvasInset_X, i * gridHeight + canvasInset_Y, canvasInset_X + totalGridWidth,&lt;br /&gt;
            i * gridHeight + canvasInset_Y);&lt;br /&gt;
      for (int i = 0; i &amp;lt; numCharAcross + 1; i++)&lt;br /&gt;
        g2.drawLine(i * gridWidth + canvasInset_X, canvasInset_Y, i * gridWidth + canvasInset_X,&lt;br /&gt;
            canvasInset_Y + totalGridHeight);&lt;br /&gt;
    }&lt;br /&gt;
    // / Draws one character at time onto the canvas according to&lt;br /&gt;
    // / the method requested (Used for RANGE_TEXT and ALL_GLYPHS)&lt;br /&gt;
    public void modeSpecificDrawChar(Graphics2D g2, int charCode, int baseX, int baseY) {&lt;br /&gt;
      GlyphVector gv;&lt;br /&gt;
      int oneGlyph[] = { charCode };&lt;br /&gt;
      char charArray[] = Character.toChars(charCode);&lt;br /&gt;
      FontRenderContext frc = g2.getFontRenderContext();&lt;br /&gt;
      AffineTransform oldTX = g2.getTransform();&lt;br /&gt;
      // / Create GlyphVector to measure the exact visual advance&lt;br /&gt;
      // / Using that number, adjust the position of the character drawn&lt;br /&gt;
      if (textToUse == ALL_GLYPHS)&lt;br /&gt;
        gv = testFont.createGlyphVector(frc, oneGlyph);&lt;br /&gt;
      else&lt;br /&gt;
        gv = testFont.createGlyphVector(frc, charArray);&lt;br /&gt;
      Rectangle2D r2d2 = gv.getPixelBounds(frc, 0, 0);&lt;br /&gt;
      int shiftedX = baseX;&lt;br /&gt;
      // getPixelBounds returns a result in device space.&lt;br /&gt;
      // we need to convert back to user space to be able to&lt;br /&gt;
      // calculate the shift as baseX is in user space.&lt;br /&gt;
      try {&lt;br /&gt;
        double pt[] = new double[4];&lt;br /&gt;
        pt[0] = r2d2.getX();&lt;br /&gt;
        pt[1] = r2d2.getY();&lt;br /&gt;
        pt[2] = r2d2.getX() + r2d2.getWidth();&lt;br /&gt;
        pt[3] = r2d2.getY() + r2d2.getHeight();&lt;br /&gt;
        oldTX.inverseTransform(pt, 0, pt, 0, 2);&lt;br /&gt;
        shiftedX = baseX - (int) (pt[2] / 2 + pt[0]);&lt;br /&gt;
      } catch (NoninvertibleTransformException e) {&lt;br /&gt;
      }&lt;br /&gt;
      // / ABP - keep track of old tform, restore it later&lt;br /&gt;
      g2.translate(shiftedX, baseY);&lt;br /&gt;
      g2.transform(getAffineTransform(g2Transform));&lt;br /&gt;
      if (textToUse == ALL_GLYPHS)&lt;br /&gt;
        g2.drawGlyphVector(gv, 0f, 0f);&lt;br /&gt;
      else {&lt;br /&gt;
        if (testFont.canDisplay(charCode))&lt;br /&gt;
          g2.setColor(Color.black);&lt;br /&gt;
        else {&lt;br /&gt;
          g2.setColor(Color.lightGray);&lt;br /&gt;
        }&lt;br /&gt;
        switch (drawMethod) {&lt;br /&gt;
        case DRAW_STRING:&lt;br /&gt;
          g2.drawString(new String(charArray), 0, 0);&lt;br /&gt;
          break;&lt;br /&gt;
        case DRAW_CHARS:&lt;br /&gt;
          g2.drawChars(charArray, 0, 1, 0, 0);&lt;br /&gt;
          break;&lt;br /&gt;
        case DRAW_BYTES:&lt;br /&gt;
          if (charCode &amp;gt; 0xff)&lt;br /&gt;
            throw new CannotDrawException(DRAW_BYTES_ERROR);&lt;br /&gt;
          byte oneByte[] = { (byte) charCode };&lt;br /&gt;
          g2.drawBytes(oneByte, 0, 1, 0, 0);&lt;br /&gt;
          break;&lt;br /&gt;
        case DRAW_GLYPHV:&lt;br /&gt;
          g2.drawGlyphVector(gv, 0f, 0f);&lt;br /&gt;
          break;&lt;br /&gt;
        case TL_DRAW:&lt;br /&gt;
          TextLayout tl = new TextLayout(new String(charArray), testFont, frc);&lt;br /&gt;
          tl.draw(g2, 0f, 0f);&lt;br /&gt;
          break;&lt;br /&gt;
        case GV_OUTLINE:&lt;br /&gt;
          r2d2 = gv.getVisualBounds();&lt;br /&gt;
          shiftedX = baseX - (int) (r2d2.getWidth() / 2 + r2d2.getX());&lt;br /&gt;
          g2.draw(gv.getOutline(0f, 0f));&lt;br /&gt;
          break;&lt;br /&gt;
        case TL_OUTLINE:&lt;br /&gt;
          r2d2 = gv.getVisualBounds();&lt;br /&gt;
          shiftedX = baseX - (int) (r2d2.getWidth() / 2 + r2d2.getX());&lt;br /&gt;
          TextLayout tlo = new TextLayout(new String(charArray), testFont, g2&lt;br /&gt;
              .getFontRenderContext());&lt;br /&gt;
          g2.draw(tlo.getOutline(null));&lt;br /&gt;
        }&lt;br /&gt;
      }&lt;br /&gt;
      // / ABP - restore old tform&lt;br /&gt;
      g2.setTransform(oldTX);&lt;br /&gt;
    }&lt;br /&gt;
    // Java2D!\\U01d586\\U01d587\\U01d588&lt;br /&gt;
    // / Draws one line of text at given position&lt;br /&gt;
    private void modeSpecificDrawLine(Graphics2D g2, String line, int baseX, int baseY) {&lt;br /&gt;
      // / ABP - keep track of old tform, restore it later&lt;br /&gt;
      AffineTransform oldTx = null;&lt;br /&gt;
      oldTx = g2.getTransform();&lt;br /&gt;
      g2.translate(baseX, baseY);&lt;br /&gt;
      g2.transform(getAffineTransform(g2Transform));&lt;br /&gt;
      switch (drawMethod) {&lt;br /&gt;
      case DRAW_STRING:&lt;br /&gt;
        g2.drawString(line, 0, 0);&lt;br /&gt;
        break;&lt;br /&gt;
      case DRAW_CHARS:&lt;br /&gt;
        g2.drawChars(line.toCharArray(), 0, line.length(), 0, 0);&lt;br /&gt;
        break;&lt;br /&gt;
      case DRAW_BYTES:&lt;br /&gt;
        try {&lt;br /&gt;
          byte lineBytes[] = line.getBytes(&amp;quot;ISO-8859-1&amp;quot;);&lt;br /&gt;
          g2.drawBytes(lineBytes, 0, lineBytes.length, 0, 0);&lt;br /&gt;
        } catch (Exception e) {&lt;br /&gt;
          e.printStackTrace();&lt;br /&gt;
        }&lt;br /&gt;
        break;&lt;br /&gt;
      case DRAW_GLYPHV:&lt;br /&gt;
        GlyphVector gv = testFont.createGlyphVector(g2.getFontRenderContext(), line);&lt;br /&gt;
        g2.drawGlyphVector(gv, (float) 0, (float) 0);&lt;br /&gt;
        break;&lt;br /&gt;
      case TL_DRAW:&lt;br /&gt;
        TextLayout tl = new TextLayout(line, testFont, g2.getFontRenderContext());&lt;br /&gt;
        tl.draw(g2, (float) 0, (float) 0);&lt;br /&gt;
        break;&lt;br /&gt;
      case GV_OUTLINE:&lt;br /&gt;
        GlyphVector gvo = testFont.createGlyphVector(g2.getFontRenderContext(), line);&lt;br /&gt;
        g2.draw(gvo.getOutline((float) 0, (float) 0));&lt;br /&gt;
        break;&lt;br /&gt;
      case TL_OUTLINE:&lt;br /&gt;
        TextLayout tlo = new TextLayout(line, testFont, g2.getFontRenderContext());&lt;br /&gt;
        AffineTransform at = new AffineTransform();&lt;br /&gt;
        g2.draw(tlo.getOutline(at));&lt;br /&gt;
      }&lt;br /&gt;
      // / ABP - restore old tform&lt;br /&gt;
      g2.setTransform(oldTx);&lt;br /&gt;
    }&lt;br /&gt;
    // / Draws one line of text at given position&lt;br /&gt;
    private void tlDrawLine(Graphics2D g2, TextLayout tl, float baseX, float baseY) {&lt;br /&gt;
      // / ABP - keep track of old tform, restore it later&lt;br /&gt;
      AffineTransform oldTx = null;&lt;br /&gt;
      oldTx = g2.getTransform();&lt;br /&gt;
      g2.translate(baseX, baseY);&lt;br /&gt;
      g2.transform(getAffineTransform(g2Transform));&lt;br /&gt;
      tl.draw(g2, (float) 0, (float) 0);&lt;br /&gt;
      // / ABP - restore old tform&lt;br /&gt;
      g2.setTransform(oldTx);&lt;br /&gt;
    }&lt;br /&gt;
    // / If textToUse is set to range drawing, then convert&lt;br /&gt;
    // / int to hex string and prepends 0s to make it length 4&lt;br /&gt;
    // / Otherwise line number was fed; simply return number + 1 converted to&lt;br /&gt;
    // String&lt;br /&gt;
    // / (This is because first line is 1, not 0)&lt;br /&gt;
    private String modeSpecificNumStr(int i) {&lt;br /&gt;
      if (textToUse == USER_TEXT || textToUse == FILE_TEXT)&lt;br /&gt;
        return String.valueOf(i + 1);&lt;br /&gt;
      StringBuffer s = new StringBuffer(Integer.toHexString(i));&lt;br /&gt;
      while (s.length() &amp;lt; 4)&lt;br /&gt;
        s.insert(0, &amp;quot;0&amp;quot;);&lt;br /&gt;
      return s.toString().toUpperCase();&lt;br /&gt;
    }&lt;br /&gt;
    // / Resets the scrollbar to display correct range of text currently on&lt;br /&gt;
    // screen&lt;br /&gt;
    // / (This scrollbar is not part of a &amp;quot;ScrollPane&amp;quot;. It merely simulates its&lt;br /&gt;
    // effect by&lt;br /&gt;
    // / indicating the necessary area to be drawn within the panel.&lt;br /&gt;
    // / By doing this, it prevents creating gigantic panel when large text&lt;br /&gt;
    // range,&lt;br /&gt;
    // / i.e. CJK Ideographs, is requested)&lt;br /&gt;
    private void resetScrollbar(int oldValue) {&lt;br /&gt;
      int totalNumRows = 1, numCharToDisplay;&lt;br /&gt;
      if (textToUse == RANGE_TEXT || textToUse == ALL_GLYPHS) {&lt;br /&gt;
        if (textToUse == RANGE_TEXT)&lt;br /&gt;
          numCharToDisplay = drawRange[1] - drawRange[0];&lt;br /&gt;
        else&lt;br /&gt;
          // / textToUse == ALL_GLYPHS&lt;br /&gt;
          numCharToDisplay = testFont.getNumGlyphs();&lt;br /&gt;
        totalNumRows = numCharToDisplay / numCharAcross;&lt;br /&gt;
        if (numCharToDisplay % numCharAcross != 0)&lt;br /&gt;
          totalNumRows++;&lt;br /&gt;
        if (oldValue / numCharAcross &amp;gt; totalNumRows)&lt;br /&gt;
          oldValue = 0;&lt;br /&gt;
        verticalBar.setValues(oldValue / numCharAcross, numCharDown, 0, totalNumRows);&lt;br /&gt;
      } else {&lt;br /&gt;
        if (textToUse == USER_TEXT)&lt;br /&gt;
          totalNumRows = userText.length;&lt;br /&gt;
        else&lt;br /&gt;
          // / textToUse == FILE_TEXT;&lt;br /&gt;
          totalNumRows = lineBreakTLs.size();&lt;br /&gt;
        verticalBar.setValues(oldValue, numCharDown, 0, totalNumRows);&lt;br /&gt;
      }&lt;br /&gt;
      if (totalNumRows &amp;lt;= numCharDown &amp;amp;&amp;amp; drawStart == 0) {&lt;br /&gt;
        verticalBar.setEnabled(false);&lt;br /&gt;
      } else {&lt;br /&gt;
        verticalBar.setEnabled(true);&lt;br /&gt;
      }&lt;br /&gt;
    }&lt;br /&gt;
    // / Calculates the font&amp;quot;s metrics that will be used for draw&lt;br /&gt;
    private void calcFontMetrics(Graphics2D g2d, int w, int h) {&lt;br /&gt;
      FontMetrics fm;&lt;br /&gt;
      Graphics2D g2 = (Graphics2D) g2d.create();&lt;br /&gt;
      // / ABP&lt;br /&gt;
      if (g2Transform != NONE &amp;amp;&amp;amp; textToUse != FILE_TEXT) {&lt;br /&gt;
        g2.setFont(g2.getFont().deriveFont(getAffineTransform(g2Transform)));&lt;br /&gt;
        fm = g2.getFontMetrics();&lt;br /&gt;
      } else {&lt;br /&gt;
        fm = g2.getFontMetrics();&lt;br /&gt;
      }&lt;br /&gt;
      maxAscent = fm.getMaxAscent();&lt;br /&gt;
      maxDescent = fm.getMaxDescent();&lt;br /&gt;
      if (maxAscent == 0)&lt;br /&gt;
        maxAscent = 10;&lt;br /&gt;
      if (maxDescent == 0)&lt;br /&gt;
        maxDescent = 5;&lt;br /&gt;
      if (textToUse == RANGE_TEXT || textToUse == ALL_GLYPHS) {&lt;br /&gt;
        // / Give slight extra room for each character&lt;br /&gt;
        maxAscent += 3;&lt;br /&gt;
        maxDescent += 3;&lt;br /&gt;
        gridWidth = fm.getMaxAdvance() + 6;&lt;br /&gt;
        gridHeight = maxAscent + maxDescent;&lt;br /&gt;
        if (force16Cols)&lt;br /&gt;
          numCharAcross = 16;&lt;br /&gt;
        else&lt;br /&gt;
          numCharAcross = (w - 10) / gridWidth;&lt;br /&gt;
        numCharDown = (h - 10) / gridHeight;&lt;br /&gt;
        canvasInset_X = (w - numCharAcross * gridWidth) / 2;&lt;br /&gt;
        canvasInset_Y = (h - numCharDown * gridHeight) / 2;&lt;br /&gt;
        if (numCharDown == 0 || numCharAcross == 0)&lt;br /&gt;
          throw new CannotDrawException(isPrinting ? CANT_FIT_PRINT : CANT_FIT_DRAW);&lt;br /&gt;
        if (!isPrinting)&lt;br /&gt;
          resetScrollbar(verticalBar.getValue() * numCharAcross);&lt;br /&gt;
      } else {&lt;br /&gt;
        maxDescent += fm.getLeading();&lt;br /&gt;
        canvasInset_X = 5;&lt;br /&gt;
        canvasInset_Y = 5;&lt;br /&gt;
        // / gridWidth and numCharAcross will not be used in this mode...&lt;br /&gt;
        gridHeight = maxAscent + maxDescent;&lt;br /&gt;
        numCharDown = (h - canvasInset_Y * 2) / gridHeight;&lt;br /&gt;
        if (numCharDown == 0)&lt;br /&gt;
          throw new CannotDrawException(isPrinting ? CANT_FIT_PRINT : CANT_FIT_DRAW);&lt;br /&gt;
        // / If this is text loaded from file, prepares the LineBreak&amp;quot;ed&lt;br /&gt;
        // / text layout at this point&lt;br /&gt;
        if (textToUse == FILE_TEXT) {&lt;br /&gt;
          if (!isPrinting)&lt;br /&gt;
            f2dt.fireChangeStatus(&amp;quot;LineBreaking Text... Please Wait&amp;quot;, false);&lt;br /&gt;
          lineBreakTLs = new Vector();&lt;br /&gt;
          for (int i = 0; i &amp;lt; fileText.length; i++) {&lt;br /&gt;
            AttributedString as = new AttributedString(fileText[i], g2.getFont().getAttributes());&lt;br /&gt;
            LineBreakMeasurer lbm = new LineBreakMeasurer(as.getIterator(), g2&lt;br /&gt;
                .getFontRenderContext());&lt;br /&gt;
            while (lbm.getPosition() &amp;lt; fileText[i].length())&lt;br /&gt;
              lineBreakTLs.add(lbm.nextLayout((float) w));&lt;br /&gt;
          }&lt;br /&gt;
        }&lt;br /&gt;
        if (!isPrinting)&lt;br /&gt;
          resetScrollbar(verticalBar.getValue());&lt;br /&gt;
      }&lt;br /&gt;
    }&lt;br /&gt;
    // / Calculates the amount of text that will be displayed on screen&lt;br /&gt;
    private void calcTextRange() {&lt;br /&gt;
      String displaying = null;&lt;br /&gt;
      if (textToUse == RANGE_TEXT || textToUse == ALL_GLYPHS) {&lt;br /&gt;
        if (isPrinting)&lt;br /&gt;
          if (printMode == ONE_PAGE)&lt;br /&gt;
            drawStart = currentlyShownChar;&lt;br /&gt;
          else&lt;br /&gt;
            // / printMode == CUR_RANGE&lt;br /&gt;
            drawStart = numCharAcross * numCharDown * printPageNumber;&lt;br /&gt;
        else&lt;br /&gt;
          drawStart = verticalBar.getValue() * numCharAcross;&lt;br /&gt;
        if (textToUse == RANGE_TEXT) {&lt;br /&gt;
          drawStart += drawRange[0];&lt;br /&gt;
          drawLimit = drawRange[1];&lt;br /&gt;
        } else&lt;br /&gt;
          drawLimit = testFont.getNumGlyphs();&lt;br /&gt;
        drawEnd = drawStart + numCharAcross * numCharDown - 1;&lt;br /&gt;
        if (drawEnd &amp;gt;= drawLimit)&lt;br /&gt;
          drawEnd = drawLimit;&lt;br /&gt;
      } else {&lt;br /&gt;
        if (isPrinting)&lt;br /&gt;
          if (printMode == ONE_PAGE)&lt;br /&gt;
            drawStart = currentlyShownChar;&lt;br /&gt;
          else&lt;br /&gt;
            // / printMode == ALL_TEXT&lt;br /&gt;
            drawStart = numCharDown * printPageNumber;&lt;br /&gt;
        else {&lt;br /&gt;
          drawStart = verticalBar.getValue();&lt;br /&gt;
        }&lt;br /&gt;
        drawEnd = drawStart + numCharDown - 1;&lt;br /&gt;
        if (textToUse == USER_TEXT)&lt;br /&gt;
          drawLimit = userText.length - 1;&lt;br /&gt;
        else&lt;br /&gt;
          drawLimit = lineBreakTLs.size() - 1;&lt;br /&gt;
        if (drawEnd &amp;gt;= drawLimit)&lt;br /&gt;
          drawEnd = drawLimit;&lt;br /&gt;
      }&lt;br /&gt;
      // ABP&lt;br /&gt;
      if (drawStart &amp;gt; drawEnd) {&lt;br /&gt;
        drawStart = 0;&lt;br /&gt;
        verticalBar.setValue(drawStart);&lt;br /&gt;
      }&lt;br /&gt;
      // / Change the status bar if not printing...&lt;br /&gt;
      if (!isPrinting) {&lt;br /&gt;
        backupStatusString = (&amp;quot;Displaying&amp;quot; + MS_OPENING[textToUse] + modeSpecificNumStr(drawStart)&lt;br /&gt;
            + &amp;quot; to &amp;quot; + modeSpecificNumStr(drawEnd) + MS_CLOSING[textToUse]);&lt;br /&gt;
        f2dt.fireChangeStatus(backupStatusString, false);&lt;br /&gt;
      }&lt;br /&gt;
    }&lt;br /&gt;
    // / Draws text according to the parameters set by Font2DTest GUI&lt;br /&gt;
    private void drawText(Graphics g, int w, int h) {&lt;br /&gt;
      Graphics2D g2;&lt;br /&gt;
      // / Create back buffer when not printing, and its Graphics2D&lt;br /&gt;
      // / Then set drawing parameters for that Graphics2D object&lt;br /&gt;
      if (isPrinting)&lt;br /&gt;
        g2 = (Graphics2D) g;&lt;br /&gt;
      else {&lt;br /&gt;
        backBuffer = (BufferedImage) this.createImage(w, h);&lt;br /&gt;
        g2 = backBuffer.createGraphics();&lt;br /&gt;
        g2.setColor(Color.white);&lt;br /&gt;
        g2.fillRect(0, 0, w, h);&lt;br /&gt;
        g2.setColor(Color.black);&lt;br /&gt;
      }&lt;br /&gt;
      // / sets font, RenderingHints.&lt;br /&gt;
      setParams(g2);&lt;br /&gt;
      // / If flag is set, recalculate fontMetrics and reset the scrollbar&lt;br /&gt;
      if (updateFontMetrics || isPrinting) {&lt;br /&gt;
        // / NOTE: re-calculates in case G2 transform&lt;br /&gt;
        // / is something other than NONE&lt;br /&gt;
        calcFontMetrics(g2, w, h);&lt;br /&gt;
        updateFontMetrics = false;&lt;br /&gt;
      }&lt;br /&gt;
      // / Calculate the amount of text that can be drawn...&lt;br /&gt;
      calcTextRange();&lt;br /&gt;
      // / Draw according to the set &amp;quot;Text to Use&amp;quot; mode&lt;br /&gt;
      if (textToUse == RANGE_TEXT || textToUse == ALL_GLYPHS) {&lt;br /&gt;
        int charToDraw = drawStart;&lt;br /&gt;
        if (showGrid)&lt;br /&gt;
          drawGrid(g2);&lt;br /&gt;
        if (!isPrinting)&lt;br /&gt;
          g.drawImage(backBuffer, 0, 0, this);&lt;br /&gt;
        for (int i = 0; i &amp;lt; numCharDown &amp;amp;&amp;amp; charToDraw &amp;lt;= drawEnd; i++) {&lt;br /&gt;
          for (int j = 0; j &amp;lt; numCharAcross &amp;amp;&amp;amp; charToDraw &amp;lt;= drawEnd; j++, charToDraw++) {&lt;br /&gt;
            int gridLocX = j * gridWidth + canvasInset_X;&lt;br /&gt;
            int gridLocY = i * gridHeight + canvasInset_Y;&lt;br /&gt;
            modeSpecificDrawChar(g2, charToDraw, gridLocX + gridWidth / 2, gridLocY + maxAscent);&lt;br /&gt;
            // if ( !isPrinting ) {&lt;br /&gt;
            // g.setClip( gridLocX, gridLocY, gridWidth + 1, gridHeight + 1 );&lt;br /&gt;
            // g.drawImage( backBuffer, 0, 0, this );&lt;br /&gt;
            // }&lt;br /&gt;
          }&lt;br /&gt;
        }&lt;br /&gt;
      } else if (textToUse == USER_TEXT) {&lt;br /&gt;
        g2.drawRect(0, 0, w - 1, h - 1);&lt;br /&gt;
        if (!isPrinting)&lt;br /&gt;
          g.drawImage(backBuffer, 0, 0, this);&lt;br /&gt;
        for (int i = drawStart; i &amp;lt;= drawEnd; i++) {&lt;br /&gt;
          int lineStartX = canvasInset_Y;&lt;br /&gt;
          int lineStartY = (i - drawStart) * gridHeight + maxAscent;&lt;br /&gt;
          modeSpecificDrawLine(g2, userText[i], lineStartX, lineStartY);&lt;br /&gt;
        }&lt;br /&gt;
      } else {&lt;br /&gt;
        float xPos, yPos = (float) canvasInset_Y;&lt;br /&gt;
        g2.drawRect(0, 0, w - 1, h - 1);&lt;br /&gt;
        if (!isPrinting)&lt;br /&gt;
          g.drawImage(backBuffer, 0, 0, this);&lt;br /&gt;
        for (int i = drawStart; i &amp;lt;= drawEnd; i++) {&lt;br /&gt;
          TextLayout oneLine = (TextLayout) lineBreakTLs.elementAt(i);&lt;br /&gt;
          xPos = oneLine.isLeftToRight() ? canvasInset_X&lt;br /&gt;
              : ((float) w - oneLine.getAdvance() - canvasInset_X);&lt;br /&gt;
          float fmData[] = { 0, oneLine.getAscent(), 0, oneLine.getDescent(), 0,&lt;br /&gt;
              oneLine.getLeading() };&lt;br /&gt;
          if (g2Transform != NONE) {&lt;br /&gt;
            AffineTransform at = getAffineTransform(g2Transform);&lt;br /&gt;
            at.transform(fmData, 0, fmData, 0, 3);&lt;br /&gt;
          }&lt;br /&gt;
          // yPos += oneLine.getAscent();&lt;br /&gt;
          yPos += fmData[1]; // ascent&lt;br /&gt;
          // oneLine.draw( g2, xPos, yPos );&lt;br /&gt;
          tlDrawLine(g2, oneLine, xPos, yPos);&lt;br /&gt;
          // yPos += oneLine.getDescent() + oneLine.getLeading();&lt;br /&gt;
          yPos += fmData[3] + fmData[5]; // descent + leading&lt;br /&gt;
        }&lt;br /&gt;
      }&lt;br /&gt;
      if (!isPrinting)&lt;br /&gt;
        g.drawImage(backBuffer, 0, 0, this);&lt;br /&gt;
      g2.dispose();&lt;br /&gt;
    }&lt;br /&gt;
    // / Component paintComponent function...&lt;br /&gt;
    // / Draws/Refreshes canvas according to flag(s) set by other functions&lt;br /&gt;
    public void paintComponent(Graphics g) {&lt;br /&gt;
      if (updateBackBuffer) {&lt;br /&gt;
        Dimension d = this.getSize();&lt;br /&gt;
        isPrinting = false;&lt;br /&gt;
        try {&lt;br /&gt;
          drawText(g, d.width, d.height);&lt;br /&gt;
        } catch (CannotDrawException e) {&lt;br /&gt;
          f2dt.fireChangeStatus(ERRORS[e.id], true);&lt;br /&gt;
          super.paintComponent(g);&lt;br /&gt;
          return;&lt;br /&gt;
        }&lt;br /&gt;
      } else {&lt;br /&gt;
        // / Screen refresh&lt;br /&gt;
        g.drawImage(backBuffer, 0, 0, this);&lt;br /&gt;
      }&lt;br /&gt;
      showingError = false;&lt;br /&gt;
      updateBackBuffer = false;&lt;br /&gt;
    }&lt;br /&gt;
    // / Printable interface function&lt;br /&gt;
    // / Component print function...&lt;br /&gt;
    public int print(Graphics g, PageFormat pf, int pageIndex) {&lt;br /&gt;
      if (pageIndex == 0) {&lt;br /&gt;
        // / Reset the last page index to max...&lt;br /&gt;
        lastPage = Integer.MAX_VALUE;&lt;br /&gt;
        currentlyShownChar = verticalBar.getValue() * numCharAcross;&lt;br /&gt;
      }&lt;br /&gt;
      if (printMode == ONE_PAGE) {&lt;br /&gt;
        if (pageIndex &amp;gt; 0)&lt;br /&gt;
          return NO_SUCH_PAGE;&lt;br /&gt;
      } else {&lt;br /&gt;
        if (pageIndex &amp;gt; lastPage)&lt;br /&gt;
          return NO_SUCH_PAGE;&lt;br /&gt;
      }&lt;br /&gt;
      int pageWidth = (int) pf.getImageableWidth();&lt;br /&gt;
      int pageHeight = (int) pf.getImageableHeight();&lt;br /&gt;
      // / Back up metrics and other drawing info before printing modifies it&lt;br /&gt;
      int backupDrawStart = drawStart, backupDrawEnd = drawEnd;&lt;br /&gt;
      int backupNumCharAcross = numCharAcross, backupNumCharDown = numCharDown;&lt;br /&gt;
      Vector backupLineBreakTLs = null;&lt;br /&gt;
      if (textToUse == FILE_TEXT)&lt;br /&gt;
        backupLineBreakTLs = (Vector) lineBreakTLs.clone();&lt;br /&gt;
      printPageNumber = pageIndex;&lt;br /&gt;
      isPrinting = true;&lt;br /&gt;
      // / Push the actual draw area 60 down to allow info to be printed&lt;br /&gt;
      g.translate((int) pf.getImageableX(), (int) pf.getImageableY() + 60);&lt;br /&gt;
      try {&lt;br /&gt;
        drawText(g, pageWidth, pageHeight - 60);&lt;br /&gt;
      } catch (CannotDrawException e) {&lt;br /&gt;
        f2dt.fireChangeStatus(ERRORS[e.id], true);&lt;br /&gt;
        return NO_SUCH_PAGE;&lt;br /&gt;
      }&lt;br /&gt;
      // / Draw information about what is being printed&lt;br /&gt;
      String hints = (&amp;quot; with antialias &amp;quot; + antiAliasType + &amp;quot;and&amp;quot; + &amp;quot; fractional metrics &amp;quot;&lt;br /&gt;
          + fractionalMetricsType + &amp;quot; and lcd contrast = &amp;quot; + lcdContrast);&lt;br /&gt;
      String infoLine1 = (&amp;quot;Printing&amp;quot; + MS_OPENING[textToUse] + modeSpecificNumStr(drawStart)&lt;br /&gt;
          + &amp;quot; to &amp;quot; + modeSpecificNumStr(drawEnd) + MS_CLOSING[textToUse]);&lt;br /&gt;
      String infoLine2 = (&amp;quot;With &amp;quot; + fontName + &amp;quot; &amp;quot; + STYLES[fontStyle] + &amp;quot; at &amp;quot; + fontSize&lt;br /&gt;
          + &amp;quot; point size &amp;quot; + TRANSFORMS[fontTransform]);&lt;br /&gt;
      String infoLine3 = &amp;quot;Using &amp;quot; + METHODS[drawMethod] + hints;&lt;br /&gt;
      String infoLine4 = &amp;quot;Page: &amp;quot; + (pageIndex + 1);&lt;br /&gt;
      g.setFont(new Font(&amp;quot;dialog&amp;quot;, Font.PLAIN, 12));&lt;br /&gt;
      g.setColor(Color.black);&lt;br /&gt;
      g.translate(0, -60);&lt;br /&gt;
      g.drawString(infoLine1, 15, 10);&lt;br /&gt;
      g.drawString(infoLine2, 15, 22);&lt;br /&gt;
      g.drawString(infoLine3, 15, 34);&lt;br /&gt;
      g.drawString(infoLine4, 15, 46);&lt;br /&gt;
      if (drawEnd == drawLimit)&lt;br /&gt;
        // / This indicates that the draw will be completed with this page&lt;br /&gt;
        lastPage = pageIndex;&lt;br /&gt;
      // / Restore the changed values back...&lt;br /&gt;
      // / This is important for JScrollBar settings and LineBreak&amp;quot;ed TLs&lt;br /&gt;
      drawStart = backupDrawStart;&lt;br /&gt;
      drawEnd = backupDrawEnd;&lt;br /&gt;
      numCharAcross = backupNumCharAcross;&lt;br /&gt;
      numCharDown = backupNumCharDown;&lt;br /&gt;
      if (textToUse == FILE_TEXT)&lt;br /&gt;
        lineBreakTLs = backupLineBreakTLs;&lt;br /&gt;
      return PAGE_EXISTS;&lt;br /&gt;
    }&lt;br /&gt;
    // / Ouputs the current canvas into a given PNG file&lt;br /&gt;
    public void writePNG(String fileName) {&lt;br /&gt;
      try {&lt;br /&gt;
        ImageIO.write(backBuffer, &amp;quot;png&amp;quot;, new java.io.File(fileName));&lt;br /&gt;
      } catch (Exception e) {&lt;br /&gt;
        f2dt.fireChangeStatus(&amp;quot;ERROR: Failed to Save PNG image; See stack trace&amp;quot;, true);&lt;br /&gt;
        e.printStackTrace();&lt;br /&gt;
      }&lt;br /&gt;
    }&lt;br /&gt;
    // / Figures out whether a character at the pointer location is valid&lt;br /&gt;
    // / And if so, updates mouse location informations, as well as&lt;br /&gt;
    // / the information on the status bar&lt;br /&gt;
    private boolean checkMouseLoc(MouseEvent e) {&lt;br /&gt;
      if (gridWidth != 0 &amp;amp;&amp;amp; gridHeight != 0)&lt;br /&gt;
        if (textToUse == RANGE_TEXT || textToUse == ALL_GLYPHS) {&lt;br /&gt;
          int charLocX = (e.getX() - canvasInset_X) / gridWidth;&lt;br /&gt;
          int charLocY = (e.getY() - canvasInset_Y) / gridHeight;&lt;br /&gt;
          // / Check to make sure the mouse click location is within drawn area&lt;br /&gt;
          if (charLocX &amp;gt;= 0 &amp;amp;&amp;amp; charLocY &amp;gt;= 0 &amp;amp;&amp;amp; charLocX &amp;lt; numCharAcross &amp;amp;&amp;amp; charLocY &amp;lt; numCharDown) {&lt;br /&gt;
            int mouseOverChar = charLocX + (verticalBar.getValue() + charLocY) * numCharAcross;&lt;br /&gt;
            if (textToUse == RANGE_TEXT)&lt;br /&gt;
              mouseOverChar += drawRange[0];&lt;br /&gt;
            if (mouseOverChar &amp;gt; drawEnd)&lt;br /&gt;
              return false;&lt;br /&gt;
            mouseOverCharX = charLocX;&lt;br /&gt;
            mouseOverCharY = charLocY;&lt;br /&gt;
            currMouseOverChar = mouseOverChar;&lt;br /&gt;
            // / Update status bar&lt;br /&gt;
            f2dt.fireChangeStatus(&amp;quot;Pointing to&amp;quot; + MS_OPENING[textToUse]&lt;br /&gt;
                + modeSpecificNumStr(mouseOverChar), false);&lt;br /&gt;
            return true;&lt;br /&gt;
          }&lt;br /&gt;
        }&lt;br /&gt;
      return false;&lt;br /&gt;
    }&lt;br /&gt;
    // / Shows (updates) the character zoom window&lt;br /&gt;
    public void showZoomed() {&lt;br /&gt;
      GlyphVector gv;&lt;br /&gt;
      Font backup = testFont;&lt;br /&gt;
      Point canvasLoc = this.getLocationOnScreen();&lt;br /&gt;
      // / Calculate the zoom area&amp;quot;s location and size...&lt;br /&gt;
      int dialogOffsetX = (int) (gridWidth * (ZOOM - 1) / 2);&lt;br /&gt;
      int dialogOffsetY = (int) (gridHeight * (ZOOM - 1) / 2);&lt;br /&gt;
      int zoomAreaX = mouseOverCharX * gridWidth + canvasInset_X - dialogOffsetX;&lt;br /&gt;
      int zoomAreaY = mouseOverCharY * gridHeight + canvasInset_Y - dialogOffsetY;&lt;br /&gt;
      int zoomAreaWidth = (int) (gridWidth * ZOOM);&lt;br /&gt;
      int zoomAreaHeight = (int) (gridHeight * ZOOM);&lt;br /&gt;
      // / Position and set size of zoom window as needed&lt;br /&gt;
      zoomWindow.setLocation(canvasLoc.x + zoomAreaX, canvasLoc.y + zoomAreaY);&lt;br /&gt;
      if (!nowZooming) {&lt;br /&gt;
        if (zoomWindow.getWarningString() != null)&lt;br /&gt;
          // / If this is not opened as a &amp;quot;secure&amp;quot; window,&lt;br /&gt;
          // / it has a banner below the zoom dialog which makes it look really&lt;br /&gt;
          // BAD&lt;br /&gt;
          // / So enlarge it by a bit&lt;br /&gt;
          zoomWindow.setSize(zoomAreaWidth + 1, zoomAreaHeight + 20);&lt;br /&gt;
        else&lt;br /&gt;
          zoomWindow.setSize(zoomAreaWidth + 1, zoomAreaHeight + 1);&lt;br /&gt;
      }&lt;br /&gt;
      // / Prepare zoomed image&lt;br /&gt;
      zoomImage = (BufferedImage) zoomWindow.createImage(zoomAreaWidth + 1, zoomAreaHeight + 1);&lt;br /&gt;
      Graphics2D g2 = (Graphics2D) zoomImage.getGraphics();&lt;br /&gt;
      testFont = testFont.deriveFont(fontSize * ZOOM);&lt;br /&gt;
      setParams(g2);&lt;br /&gt;
      g2.setColor(Color.white);&lt;br /&gt;
      g2.fillRect(0, 0, zoomAreaWidth, zoomAreaHeight);&lt;br /&gt;
      g2.setColor(Color.black);&lt;br /&gt;
      g2.drawRect(0, 0, zoomAreaWidth, zoomAreaHeight);&lt;br /&gt;
      modeSpecificDrawChar(g2, currMouseOverChar, zoomAreaWidth / 2, (int) (maxAscent * ZOOM));&lt;br /&gt;
      g2.dispose();&lt;br /&gt;
      if (!nowZooming)&lt;br /&gt;
        zoomWindow.show();&lt;br /&gt;
      // / This is sort of redundant... since there is a paint function&lt;br /&gt;
      // / inside zoomWindow definition that does the drawImage.&lt;br /&gt;
      // / (I should be able to call just repaint() here)&lt;br /&gt;
      // / However, for some reason, that paint function fails to respond&lt;br /&gt;
      // / from second time and on; So I have to force the paint here...&lt;br /&gt;
      zoomWindow.getGraphics().drawImage(zoomImage, 0, 0, this);&lt;br /&gt;
      nowZooming = true;&lt;br /&gt;
      prevZoomChar = currMouseOverChar;&lt;br /&gt;
      testFont = backup;&lt;br /&gt;
      // Windows does not repaint correctly, after&lt;br /&gt;
      // a zoom. Thus, we need to force the canvas&lt;br /&gt;
      // to repaint, but only once. After the first repaint,&lt;br /&gt;
      // everything stabilizes. [ABP]&lt;br /&gt;
      if (firstTime()) {&lt;br /&gt;
        refresh();&lt;br /&gt;
      }&lt;br /&gt;
    }&lt;br /&gt;
    // / Listener Functions&lt;br /&gt;
    // / MouseListener interface function&lt;br /&gt;
    // / Zooms a character when mouse is pressed above it&lt;br /&gt;
    public void mousePressed(MouseEvent e) {&lt;br /&gt;
      if (!showingError) {&lt;br /&gt;
        if (checkMouseLoc(e)) {&lt;br /&gt;
          showZoomed();&lt;br /&gt;
          this.setCursor(blankCursor);&lt;br /&gt;
        }&lt;br /&gt;
      }&lt;br /&gt;
    }&lt;br /&gt;
    // / MouseListener interface function&lt;br /&gt;
    // / Redraws the area that was drawn over by zoomed character&lt;br /&gt;
    public void mouseReleased(MouseEvent e) {&lt;br /&gt;
      if (textToUse == RANGE_TEXT || textToUse == ALL_GLYPHS) {&lt;br /&gt;
        if (nowZooming)&lt;br /&gt;
          zoomWindow.hide();&lt;br /&gt;
        nowZooming = false;&lt;br /&gt;
      }&lt;br /&gt;
      this.setCursor(Cursor.getDefaultCursor());&lt;br /&gt;
    }&lt;br /&gt;
    // / MouseListener interface function&lt;br /&gt;
    // / Resets the status bar to display range instead of a specific character&lt;br /&gt;
    public void mouseExited(MouseEvent e) {&lt;br /&gt;
      if (!showingError &amp;amp;&amp;amp; !nowZooming)&lt;br /&gt;
        f2dt.fireChangeStatus(backupStatusString, false);&lt;br /&gt;
    }&lt;br /&gt;
    // / MouseMotionListener interface function&lt;br /&gt;
    // / Adjusts the status bar message when mouse moves over a character&lt;br /&gt;
    public void mouseMoved(MouseEvent e) {&lt;br /&gt;
      if (!showingError) {&lt;br /&gt;
        if (!checkMouseLoc(e))&lt;br /&gt;
          f2dt.fireChangeStatus(backupStatusString, false);&lt;br /&gt;
      }&lt;br /&gt;
    }&lt;br /&gt;
    // / MouseMotionListener interface function&lt;br /&gt;
    // / Scrolls the zoomed character when mouse is dragged&lt;br /&gt;
    public void mouseDragged(MouseEvent e) {&lt;br /&gt;
      if (!showingError)&lt;br /&gt;
        if (nowZooming) {&lt;br /&gt;
          if (checkMouseLoc(e) &amp;amp;&amp;amp; currMouseOverChar != prevZoomChar)&lt;br /&gt;
            showZoomed();&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
    // / Empty function to comply with interface requirement&lt;br /&gt;
    public void mouseClicked(MouseEvent e) {&lt;br /&gt;
    }&lt;br /&gt;
    public void mouseEntered(MouseEvent e) {&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
  private final class CannotDrawException extends RuntimeException {&lt;br /&gt;
    // / Error ID&lt;br /&gt;
    public final int id;&lt;br /&gt;
    public CannotDrawException(int i) {&lt;br /&gt;
      id = i;&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
  enum FMValues {&lt;br /&gt;
    FMDEFAULT(&amp;quot;DEFAULT&amp;quot;, VALUE_FRACTIONALMETRICS_DEFAULT), FMOFF(&amp;quot;OFF&amp;quot;, VALUE_FRACTIONALMETRICS_OFF), FMON(&lt;br /&gt;
        &amp;quot;ON&amp;quot;, VALUE_FRACTIONALMETRICS_ON);&lt;br /&gt;
    private String name;&lt;br /&gt;
    private Object hint;&lt;br /&gt;
    private static FMValues[] valArray;&lt;br /&gt;
    FMValues(String s, Object o) {&lt;br /&gt;
      name = s;&lt;br /&gt;
      hint = o;&lt;br /&gt;
    }&lt;br /&gt;
    public String toString() {&lt;br /&gt;
      return name;&lt;br /&gt;
    }&lt;br /&gt;
    public Object getHint() {&lt;br /&gt;
      return hint;&lt;br /&gt;
    }&lt;br /&gt;
    public static Object getValue(int ordinal) {&lt;br /&gt;
      if (valArray == null) {&lt;br /&gt;
        valArray = (FMValues[]) EnumSet.allOf(FMValues.class).toArray(new FMValues[0]);&lt;br /&gt;
      }&lt;br /&gt;
      for (int i = 0; i &amp;lt; valArray.length; i++) {&lt;br /&gt;
        if (valArray[i].ordinal() == ordinal) {&lt;br /&gt;
          return valArray[i];&lt;br /&gt;
        }&lt;br /&gt;
      }&lt;br /&gt;
      return valArray[0];&lt;br /&gt;
    }&lt;br /&gt;
    private static FMValues[] getArray() {&lt;br /&gt;
      if (valArray == null) {&lt;br /&gt;
        valArray = (FMValues[]) EnumSet.allOf(FMValues.class).toArray(new FMValues[0]);&lt;br /&gt;
      }&lt;br /&gt;
      return valArray;&lt;br /&gt;
    }&lt;br /&gt;
    public static int getHintVal(Object hint) {&lt;br /&gt;
      getArray();&lt;br /&gt;
      for (int i = 0; i &amp;lt; valArray.length; i++) {&lt;br /&gt;
        if (valArray[i].getHint() == hint) {&lt;br /&gt;
          return i;&lt;br /&gt;
        }&lt;br /&gt;
      }&lt;br /&gt;
      return 0;&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
  enum AAValues {&lt;br /&gt;
    AADEFAULT(&amp;quot;DEFAULT&amp;quot;, VALUE_TEXT_ANTIALIAS_DEFAULT), AAOFF(&amp;quot;OFF&amp;quot;, VALUE_TEXT_ANTIALIAS_OFF), AAON(&lt;br /&gt;
        &amp;quot;ON&amp;quot;, VALUE_TEXT_ANTIALIAS_ON), AAGASP(&amp;quot;GASP&amp;quot;, VALUE_TEXT_ANTIALIAS_GASP), AALCDHRGB(&lt;br /&gt;
        &amp;quot;LCD_HRGB&amp;quot;, VALUE_TEXT_ANTIALIAS_LCD_HRGB), AALCDHBGR(&amp;quot;LCD_HBGR&amp;quot;,&lt;br /&gt;
        VALUE_TEXT_ANTIALIAS_LCD_HBGR), AALCDVRGB(&amp;quot;LCD_VRGB&amp;quot;, VALUE_TEXT_ANTIALIAS_LCD_VRGB), AALCDVBGR(&lt;br /&gt;
        &amp;quot;LCD_VBGR&amp;quot;, VALUE_TEXT_ANTIALIAS_LCD_VBGR);&lt;br /&gt;
    private String name;&lt;br /&gt;
    private Object hint;&lt;br /&gt;
    private static AAValues[] valArray;&lt;br /&gt;
    AAValues(String s, Object o) {&lt;br /&gt;
      name = s;&lt;br /&gt;
      hint = o;&lt;br /&gt;
    }&lt;br /&gt;
    public String toString() {&lt;br /&gt;
      return name;&lt;br /&gt;
    }&lt;br /&gt;
    public Object getHint() {&lt;br /&gt;
      return hint;&lt;br /&gt;
    }&lt;br /&gt;
    public static boolean isLCDMode(Object o) {&lt;br /&gt;
      return (o instanceof AAValues &amp;amp;&amp;amp; ((AAValues) o).ordinal() &amp;gt;= AALCDHRGB.ordinal());&lt;br /&gt;
    }&lt;br /&gt;
    public static Object getValue(int ordinal) {&lt;br /&gt;
      if (valArray == null) {&lt;br /&gt;
        valArray = (AAValues[]) EnumSet.allOf(AAValues.class).toArray(new AAValues[0]);&lt;br /&gt;
      }&lt;br /&gt;
      for (int i = 0; i &amp;lt; valArray.length; i++) {&lt;br /&gt;
        if (valArray[i].ordinal() == ordinal) {&lt;br /&gt;
          return valArray[i];&lt;br /&gt;
        }&lt;br /&gt;
      }&lt;br /&gt;
      return valArray[0];&lt;br /&gt;
    }&lt;br /&gt;
    private static AAValues[] getArray() {&lt;br /&gt;
      if (valArray == null) {&lt;br /&gt;
        Object[] oa = EnumSet.allOf(AAValues.class).toArray(new AAValues[0]);&lt;br /&gt;
        valArray = (AAValues[]) (EnumSet.allOf(AAValues.class).toArray(new AAValues[0]));&lt;br /&gt;
      }&lt;br /&gt;
      return valArray;&lt;br /&gt;
    }&lt;br /&gt;
    public static int getHintVal(Object hint) {&lt;br /&gt;
      getArray();&lt;br /&gt;
      for (int i = 0; i &amp;lt; valArray.length; i++) {&lt;br /&gt;
        if (valArray[i].getHint() == hint) {&lt;br /&gt;
          return i;&lt;br /&gt;
        }&lt;br /&gt;
      }&lt;br /&gt;
      return 0;&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
  private static Integer defaultContrast;&lt;br /&gt;
  static Integer getDefaultLCDContrast() {&lt;br /&gt;
    if (defaultContrast == null) {&lt;br /&gt;
      GraphicsConfiguration gc = GraphicsEnvironment.getLocalGraphicsEnvironment()&lt;br /&gt;
          .getDefaultScreenDevice().getDefaultConfiguration();&lt;br /&gt;
      Graphics2D g2d = (Graphics2D) (gc.createCompatibleImage(1, 1).getGraphics());&lt;br /&gt;
      defaultContrast = (Integer) g2d.getRenderingHint(RenderingHints.KEY_TEXT_LCD_CONTRAST);&lt;br /&gt;
    }&lt;br /&gt;
    return defaultContrast;&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
/*&lt;br /&gt;
 * @(#)RangeMenu.java 1.18 05/11/17&lt;br /&gt;
 * &lt;br /&gt;
 * Copyright (c) 2006 Sun Microsystems, Inc. All Rights Reserved.&lt;br /&gt;
 * &lt;br /&gt;
 * Redistribution and use in source and binary forms, with or without&lt;br /&gt;
 * modification, are permitted provided that the following conditions are met:&lt;br /&gt;
 * &lt;br /&gt;
 * -Redistribution of source code must retain the above copyright notice, this&lt;br /&gt;
 * list of conditions and the following disclaimer.&lt;br /&gt;
 * &lt;br /&gt;
 * -Redistribution in binary form must reproduce the above copyright notice,&lt;br /&gt;
 * this list of conditions and the following disclaimer in the documentation&lt;br /&gt;
 * and/or other materials provided with the distribution.&lt;br /&gt;
 * &lt;br /&gt;
 * Neither the name of Sun Microsystems, Inc. or the names of contributors may&lt;br /&gt;
 * be used to endorse or promote products derived from this software without&lt;br /&gt;
 * specific prior written permission.&lt;br /&gt;
 * &lt;br /&gt;
 * This software is provided &amp;quot;AS IS,&amp;quot; without a warranty of any kind. ALL&lt;br /&gt;
 * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING ANY&lt;br /&gt;
 * IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR&lt;br /&gt;
 * NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN MIDROSYSTEMS, INC. (&amp;quot;SUN&amp;quot;) AND ITS&lt;br /&gt;
 * LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A&lt;br /&gt;
 * RESULT OF USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES.&lt;br /&gt;
 * IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT&lt;br /&gt;
 * OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR&lt;br /&gt;
 * PUNITIVE DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY,&lt;br /&gt;
 * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF SUN HAS&lt;br /&gt;
 * BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.&lt;br /&gt;
 * &lt;br /&gt;
 * You acknowledge that this software is not designed, licensed or intended for&lt;br /&gt;
 * use in the design, construction, operation or maintenance of any nuclear&lt;br /&gt;
 * facility.&lt;br /&gt;
 */&lt;br /&gt;
/*&lt;br /&gt;
 * @(#)RangeMenu.java 1.18 05/11/17&lt;br /&gt;
 */&lt;br /&gt;
/**&lt;br /&gt;
 * RangeMenu.java&lt;br /&gt;
 * &lt;br /&gt;
 * @version&lt;br /&gt;
 * @(#)RangeMenu.java 1.1 00/08/22&lt;br /&gt;
 * @author Shinsuke Fukuda&lt;br /&gt;
 * @author Ankit Patel [Conversion to Swing - 01/07/30]&lt;br /&gt;
 */&lt;br /&gt;
// / Custom made choice menu that holds data for unicode range&lt;br /&gt;
final class RangeMenu extends JComboBox implements ActionListener {&lt;br /&gt;
  // / Painfully extracted from java.lang.Character.UnicodeBlock. Arrrgh!&lt;br /&gt;
  // / Unicode 3.0 data.&lt;br /&gt;
  private final int[][] UNICODE_RANGES = { { 0x000000, 0x00007f }, // /&lt;br /&gt;
                                                                    // BASIC_LATIN&lt;br /&gt;
      { 0x000080, 0x0000ff }, // / LATIN_1_SUPPLEMENT&lt;br /&gt;
      { 0x000100, 0x00017f }, // / LATIN_EXTENDED_A&lt;br /&gt;
      { 0x000180, 0x00024f }, // / LATIN_EXTENDED_B&lt;br /&gt;
      { 0x000250, 0x0002af }, // / IPA_EXTENSIONS&lt;br /&gt;
      { 0x0002b0, 0x0002ff }, // / SPACING_MODIFIER_LETTERS&lt;br /&gt;
      { 0x000300, 0x00036f }, // / COMBINING_DIACRITICAL_MARKS&lt;br /&gt;
      { 0x000370, 0x0003ff }, // / GREEK&lt;br /&gt;
      { 0x000400, 0x0004ff }, // / CYRILLIC&lt;br /&gt;
      { 0x000500, 0x00052f }, // / CYRILLIC_SUPPLEMENTARY&lt;br /&gt;
      { 0x000530, 0x00058f }, // / ARMENIAN&lt;br /&gt;
      { 0x000590, 0x0005ff }, // / HEBREW&lt;br /&gt;
      { 0x000600, 0x0006ff }, // / ARABIC&lt;br /&gt;
      { 0x000700, 0x00074f }, // / SYRIAC&lt;br /&gt;
      { 0x000780, 0x0007bf }, // / THAANA&lt;br /&gt;
      { 0x000900, 0x00097f }, // / DEVANAGARI&lt;br /&gt;
      { 0x000980, 0x0009ff }, // / BENGALI&lt;br /&gt;
      { 0x000a00, 0x000a7f }, // / GURMUKHI&lt;br /&gt;
      { 0x000a80, 0x000aff }, // / GUJARATI&lt;br /&gt;
      { 0x000b00, 0x000b7f }, // / ORIYA&lt;br /&gt;
      { 0x000b80, 0x000bff }, // / TAMIL&lt;br /&gt;
      { 0x000c00, 0x000c7f }, // / TELUGU&lt;br /&gt;
      { 0x000c80, 0x000cff }, // / KANNADA&lt;br /&gt;
      { 0x000d00, 0x000d7f }, // / MALAYALAM&lt;br /&gt;
      { 0x000d80, 0x000dff }, // / SINHALA&lt;br /&gt;
      { 0x000e00, 0x000e7f }, // / THAI&lt;br /&gt;
      { 0x000e80, 0x000eff }, // / LAO&lt;br /&gt;
      { 0x000f00, 0x000fff }, // / TIBETAN&lt;br /&gt;
      { 0x001000, 0x00109f }, // / MYANMAR&lt;br /&gt;
      { 0x0010a0, 0x0010ff }, // / GEORGIAN&lt;br /&gt;
      { 0x001100, 0x0011ff }, // / HANGUL_JAMO&lt;br /&gt;
      { 0x001200, 0x00137f }, // / ETHIOPIC&lt;br /&gt;
      { 0x0013a0, 0x0013ff }, // / CHEROKEE&lt;br /&gt;
      { 0x001400, 0x00167f }, // / UNIFIED_CANADIAN_ABORIGINAL_SYLLABICS&lt;br /&gt;
      { 0x001680, 0x00169f }, // / OGHAM&lt;br /&gt;
      { 0x0016a0, 0x0016ff }, // / RUNIC&lt;br /&gt;
      { 0x001700, 0x00171f }, // / TAGALOG&lt;br /&gt;
      { 0x001720, 0x00173f }, // / HANUNOO&lt;br /&gt;
      { 0x001740, 0x00175f }, // / BUHID&lt;br /&gt;
      { 0x001760, 0x00177f }, // / TAGBANWA&lt;br /&gt;
      { 0x001780, 0x0017ff }, // / KHMER&lt;br /&gt;
      { 0x001800, 0x0018af }, // / MONGOLIAN&lt;br /&gt;
      { 0x001900, 0x00194f }, // / LIMBU&lt;br /&gt;
      { 0x001950, 0x00197f }, // / TAI_LE&lt;br /&gt;
      { 0x0019e0, 0x0019ff }, // / KHMER_SYMBOLS&lt;br /&gt;
      { 0x001d00, 0x001d7f }, // / PHONETIC_EXTENSIONS&lt;br /&gt;
      { 0x001e00, 0x001eff }, // / LATIN_EXTENDED_ADDITIONAL&lt;br /&gt;
      { 0x001f00, 0x001fff }, // / GREEK_EXTENDED&lt;br /&gt;
      { 0x002000, 0x00206f }, // / GENERAL_PUNCTUATION&lt;br /&gt;
      { 0x002070, 0x00209f }, // / SUPERSCRIPTS_AND_SUBSCRIPTS&lt;br /&gt;
      { 0x0020a0, 0x0020cf }, // / CURRENCY_SYMBOLS&lt;br /&gt;
      { 0x0020d0, 0x0020ff }, // / COMBINING_MARKS_FOR_SYMBOLS&lt;br /&gt;
      { 0x002100, 0x00214f }, // / LETTERLIKE_SYMBOLS&lt;br /&gt;
      { 0x002150, 0x00218f }, // / NUMBER_FORMS&lt;br /&gt;
      { 0x002190, 0x0021ff }, // / ARROWS&lt;br /&gt;
      { 0x002200, 0x0022ff }, // / MATHEMATICAL_OPERATORS&lt;br /&gt;
      { 0x002300, 0x0023ff }, // / MISCELLANEOUS_TECHNICAL&lt;br /&gt;
      { 0x002400, 0x00243f }, // / CONTROL_PICTURES&lt;br /&gt;
      { 0x002440, 0x00245f }, // / OPTICAL_CHARACTER_RECOGNITION&lt;br /&gt;
      { 0x002460, 0x0024ff }, // / ENCLOSED_ALPHANUMERICS&lt;br /&gt;
      { 0x002500, 0x00257f }, // / BOX_DRAWING&lt;br /&gt;
      { 0x002580, 0x00259f }, // / BLOCK_ELEMENTS&lt;br /&gt;
      { 0x0025a0, 0x0025ff }, // / GEOMETRIC_SHAPES&lt;br /&gt;
      { 0x002600, 0x0026ff }, // / MISCELLANEOUS_SYMBOLS&lt;br /&gt;
      { 0x002700, 0x0027bf }, // / DINGBATS&lt;br /&gt;
      { 0x0027c0, 0x0027ef }, // / MISCELLANEOUS_MATHEMATICAL_SYMBOLS_A&lt;br /&gt;
      { 0x0027f0, 0x0027ff }, // / SUPPLEMENTAL_ARROWS_A&lt;br /&gt;
      { 0x002800, 0x0028ff }, // / BRAILLE_PATTERNS&lt;br /&gt;
      { 0x002900, 0x00297f }, // / SUPPLEMENTAL_ARROWS_B&lt;br /&gt;
      { 0x002980, 0x0029ff }, // / MISCELLANEOUS_MATHEMATICAL_SYMBOLS_B&lt;br /&gt;
      { 0x002a00, 0x002aff }, // / SUPPLEMENTAL_MATHEMATICAL_OPERATORS&lt;br /&gt;
      { 0x002b00, 0x002bff }, // / MISCELLANEOUS_SYMBOLS_AND_ARROWS&lt;br /&gt;
      { 0x002e80, 0x002eff }, // / CJK_RADICALS_SUPPLEMENT&lt;br /&gt;
      { 0x002f00, 0x002fdf }, // / KANGXI_RADICALS&lt;br /&gt;
      { 0x002ff0, 0x002fff }, // / IDEOGRAPHIC_DESCRIPTION_CHARACTERS&lt;br /&gt;
      { 0x003000, 0x00303f }, // / CJK_SYMBOLS_AND_PUNCTUATION&lt;br /&gt;
      { 0x003040, 0x00309f }, // / HIRAGANA&lt;br /&gt;
      { 0x0030a0, 0x0030ff }, // / KATAKANA&lt;br /&gt;
      { 0x003100, 0x00312f }, // / BOPOMOFO&lt;br /&gt;
      { 0x003130, 0x00318f }, // / HANGUL_COMPATIBILITY_JAMO&lt;br /&gt;
      { 0x003190, 0x00319f }, // / KANBUN&lt;br /&gt;
      { 0x0031a0, 0x0031bf }, // / BOPOMOFO_EXTENDED&lt;br /&gt;
      { 0x0031f0, 0x0031ff }, // / KATAKANA_PHONETIC_EXTENSIONS&lt;br /&gt;
      { 0x003200, 0x0032ff }, // / ENCLOSED_CJK_LETTERS_AND_MONTHS&lt;br /&gt;
      { 0x003300, 0x0033ff }, // / CJK_COMPATIBILITY&lt;br /&gt;
      { 0x003400, 0x004dbf }, // / CJK_UNIFIED_IDEOGRAPHS_EXTENSION_A&lt;br /&gt;
      { 0x004dc0, 0x004dff }, // / YIJING_HEXAGRAM_SYMBOLS&lt;br /&gt;
      { 0x004e00, 0x009fff }, // / CJK_UNIFIED_IDEOGRAPHS&lt;br /&gt;
      { 0x00a000, 0x00a48f }, // / YI_SYLLABLES&lt;br /&gt;
      { 0x00a490, 0x00a4cf }, // / YI_RADICALS&lt;br /&gt;
      { 0x00ac00, 0x00d7af }, // / HANGUL_SYLLABLES&lt;br /&gt;
      { 0x00d800, 0x00dfff }, // / SURROGATES_AREA&lt;br /&gt;
      { 0x00e000, 0x00f8ff }, // / PRIVATE_USE_AREA&lt;br /&gt;
      { 0x00f900, 0x00faff }, // / CJK_COMPATIBILITY_IDEOGRAPHS&lt;br /&gt;
      { 0x00fb00, 0x00fb4f }, // / ALPHABETIC_PRESENTATION_FORMS&lt;br /&gt;
      { 0x00fb50, 0x00fdff }, // / ARABIC_PRESENTATION_FORMS_A&lt;br /&gt;
      { 0x00fe00, 0x00fe0f }, // / VARIATION_SELECTORS&lt;br /&gt;
      { 0x00fe20, 0x00fe2f }, // / COMBINING_HALF_MARKS&lt;br /&gt;
      { 0x00fe30, 0x00fe4f }, // / CJK_COMPATIBILITY_FORMS&lt;br /&gt;
      { 0x00fe50, 0x00fe6f }, // / SMALL_FORM_VARIANTS&lt;br /&gt;
      { 0x00fe70, 0x00feff }, // / ARABIC_PRESENTATION_FORMS_B&lt;br /&gt;
      { 0x00ff00, 0x00ffef }, // / HALFWIDTH_AND_FULLWIDTH_FORMS&lt;br /&gt;
      { 0x00fff0, 0x00ffff }, // / SPECIALS&lt;br /&gt;
      { 0x010000, 0x01007f }, // / LINEAR_B_SYLLABARY&lt;br /&gt;
      { 0x010080, 0x0100ff }, // / LINEAR_B_IDEOGRAMS&lt;br /&gt;
      { 0x010100, 0x01013f }, // / AEGEAN_NUMBERS&lt;br /&gt;
      { 0x010300, 0x01032f }, // / OLD_ITALIC&lt;br /&gt;
      { 0x010330, 0x01034f }, // / GOTHIC&lt;br /&gt;
      { 0x010380, 0x01039f }, // / UGARITIC&lt;br /&gt;
      { 0x010400, 0x01044f }, // / DESERET&lt;br /&gt;
      { 0x010450, 0x01047f }, // / SHAVIAN&lt;br /&gt;
      { 0x010480, 0x0104af }, // / OSMANYA&lt;br /&gt;
      { 0x010800, 0x01083f }, // / CYPRIOT_SYLLABARY&lt;br /&gt;
      { 0x01d000, 0x01d0ff }, // / BYZANTINE_MUSICAL_SYMBOLS&lt;br /&gt;
      { 0x01d100, 0x01d1ff }, // / MUSICAL_SYMBOLS&lt;br /&gt;
      { 0x01d300, 0x01d35f }, // / TAI_XUAN_JING_SYMBOLS&lt;br /&gt;
      { 0x01d400, 0x01d7ff }, // / MATHEMATICAL_ALPHANUMERIC_SYMBOLS&lt;br /&gt;
      { 0x020000, 0x02a6df }, // / CJK_UNIFIED_IDEOGRAPHS_EXTENSION_B&lt;br /&gt;
      { 0x02f800, 0x02fa1f }, // / CJK_COMPATIBILITY_IDEOGRAPHS_SUPPLEMENT&lt;br /&gt;
      { 0x0e0000, 0x0e007f }, // / TAGS&lt;br /&gt;
      { 0x0e0100, 0x0e01ef }, // / VARIATION_SELECTORS_SUPPLEMENT&lt;br /&gt;
      { 0x0f0000, 0x0fffff }, // / SUPPLEMENTARY_PRIVATE_USE_AREA_A&lt;br /&gt;
      { 0x100000, 0x10ffff }, // / SUPPLEMENTARY_PRIVATE_USE_AREA_B&lt;br /&gt;
      { 0x000000, 0x00007f }, // / OTHER [USER DEFINED RANGE]&lt;br /&gt;
  };&lt;br /&gt;
  private final String[] UNICODE_RANGE_NAMES = { &amp;quot;Basic Latin&amp;quot;, &amp;quot;Latin-1 Supplement&amp;quot;,&lt;br /&gt;
      &amp;quot;Latin Extended-A&amp;quot;, &amp;quot;Latin Extended-B&amp;quot;, &amp;quot;IPA Extensions&amp;quot;, &amp;quot;Spacing Modifier Letters&amp;quot;,&lt;br /&gt;
      &amp;quot;Combining Diacritical Marks&amp;quot;, &amp;quot;Greek&amp;quot;, &amp;quot;Cyrillic&amp;quot;, &amp;quot;Cyrillic Supplement&amp;quot;, &amp;quot;Armenian&amp;quot;,&lt;br /&gt;
      &amp;quot;Hebrew&amp;quot;, &amp;quot;Arabic&amp;quot;, &amp;quot;Syriac&amp;quot;, &amp;quot;Thaana&amp;quot;, &amp;quot;Devanagari&amp;quot;, &amp;quot;Bengali&amp;quot;, &amp;quot;Gurmukhi&amp;quot;, &amp;quot;Gujarati&amp;quot;,&lt;br /&gt;
      &amp;quot;Oriya&amp;quot;, &amp;quot;Tamil&amp;quot;, &amp;quot;Telugu&amp;quot;, &amp;quot;Kannada&amp;quot;, &amp;quot;Malayalam&amp;quot;, &amp;quot;Sinhala&amp;quot;, &amp;quot;Thai&amp;quot;, &amp;quot;Lao&amp;quot;, &amp;quot;Tibetan&amp;quot;,&lt;br /&gt;
      &amp;quot;Myanmar&amp;quot;, &amp;quot;Georgian&amp;quot;, &amp;quot;Hangul Jamo&amp;quot;, &amp;quot;Ethiopic&amp;quot;, &amp;quot;Cherokee&amp;quot;,&lt;br /&gt;
      &amp;quot;Unified Canadian Aboriginal Syllabics&amp;quot;, &amp;quot;Ogham&amp;quot;, &amp;quot;Runic&amp;quot;, &amp;quot;Tagalog&amp;quot;, &amp;quot;Hanunoo&amp;quot;, &amp;quot;Buhid&amp;quot;,&lt;br /&gt;
      &amp;quot;Tagbanwa&amp;quot;, &amp;quot;Khmer&amp;quot;, &amp;quot;Mongolian&amp;quot;, &amp;quot;Limbu&amp;quot;, &amp;quot;Tai Le&amp;quot;, &amp;quot;Khmer Symbols&amp;quot;, &amp;quot;Phonetic Extensions&amp;quot;,&lt;br /&gt;
      &amp;quot;Latin Extended Additional&amp;quot;, &amp;quot;Greek Extended&amp;quot;, &amp;quot;General Punctuation&amp;quot;,&lt;br /&gt;
      &amp;quot;Superscripts and Subscripts&amp;quot;, &amp;quot;Currency Symbols&amp;quot;, &amp;quot;Combining Marks for Symbols&amp;quot;,&lt;br /&gt;
      &amp;quot;Letterlike Symbols&amp;quot;, &amp;quot;Number Forms&amp;quot;, &amp;quot;Arrows&amp;quot;, &amp;quot;Mathematical Operators&amp;quot;,&lt;br /&gt;
      &amp;quot;Miscellaneous Technical&amp;quot;, &amp;quot;Control Pictures&amp;quot;, &amp;quot;Optical Character Recognition&amp;quot;,&lt;br /&gt;
      &amp;quot;Enclosed Alphanumerics&amp;quot;, &amp;quot;Box Drawing&amp;quot;, &amp;quot;Block Elements&amp;quot;, &amp;quot;Geometric Shapes&amp;quot;,&lt;br /&gt;
      &amp;quot;Miscellaneous Symbols&amp;quot;, &amp;quot;Dingbats&amp;quot;, &amp;quot;Miscellaneous Mathematical Symbols-A&amp;quot;,&lt;br /&gt;
      &amp;quot;Supplemental Arrows-A&amp;quot;, &amp;quot;Braille Patterns&amp;quot;, &amp;quot;Supplemental Arrows-B&amp;quot;,&lt;br /&gt;
      &amp;quot;Miscellaneous Mathematical Symbols-B&amp;quot;, &amp;quot;Supplemental Mathematical Operators&amp;quot;,&lt;br /&gt;
      &amp;quot;Miscellaneous Symbols and Arrows&amp;quot;, &amp;quot;CJK Radicals Supplement&amp;quot;, &amp;quot;Kangxi Radicals&amp;quot;,&lt;br /&gt;
      &amp;quot;Ideographic Description Characters&amp;quot;, &amp;quot;CJK Symbols and Punctuation&amp;quot;, &amp;quot;Hiragana&amp;quot;, &amp;quot;Katakana&amp;quot;,&lt;br /&gt;
      &amp;quot;Bopomofo&amp;quot;, &amp;quot;Hangul Compatibility Jamo&amp;quot;, &amp;quot;Kanbun&amp;quot;, &amp;quot;Bopomofo Extended&amp;quot;,&lt;br /&gt;
      &amp;quot;Katakana Phonetic Extensions&amp;quot;, &amp;quot;Enclosed CJK Letters and Months&amp;quot;, &amp;quot;CJK Compatibility&amp;quot;,&lt;br /&gt;
      &amp;quot;CJK Unified Ideographs Extension A&amp;quot;, &amp;quot;Yijing Hexagram Symbols&amp;quot;, &amp;quot;CJK Unified Ideographs&amp;quot;,&lt;br /&gt;
      &amp;quot;Yi Syllables&amp;quot;, &amp;quot;Yi Radicals&amp;quot;, &amp;quot;Hangul Syllables&amp;quot;, &amp;quot;Surrogates Area&amp;quot;, // High&lt;br /&gt;
                                                                            // Surrogates,&lt;br /&gt;
                                                                            // High&lt;br /&gt;
                                                                            // Private&lt;br /&gt;
                                                                            // Use&lt;br /&gt;
                                                                            // Surrogates,&lt;br /&gt;
                                                                            // Low&lt;br /&gt;
                                                                            // Surrogates&lt;br /&gt;
      &amp;quot;Private Use Area&amp;quot;, &amp;quot;CJK Compatibility Ideographs&amp;quot;, &amp;quot;Alphabetic Presentation Forms&amp;quot;,&lt;br /&gt;
      &amp;quot;Arabic Presentation Forms-A&amp;quot;, &amp;quot;Variation Selectors&amp;quot;, &amp;quot;Combining Half Marks&amp;quot;,&lt;br /&gt;
      &amp;quot;CJK Compatibility Forms&amp;quot;, &amp;quot;Small Form Variants&amp;quot;, &amp;quot;Arabic Presentation Forms-B&amp;quot;,&lt;br /&gt;
      &amp;quot;Halfwidth and Fullwidth Forms&amp;quot;, &amp;quot;Specials&amp;quot;, &amp;quot;Linear B Syllabary&amp;quot;, &amp;quot;Linear B Ideograms&amp;quot;,&lt;br /&gt;
      &amp;quot;Aegean Numbers&amp;quot;, &amp;quot;Old Italic&amp;quot;, &amp;quot;Gothic&amp;quot;, &amp;quot;Ugaritic&amp;quot;, &amp;quot;Deseret&amp;quot;, &amp;quot;Shavian&amp;quot;, &amp;quot;Osmanya&amp;quot;,&lt;br /&gt;
      &amp;quot;Cypriot Syllabary&amp;quot;, &amp;quot;Byzantine Musical Symbols&amp;quot;, &amp;quot;Musical Symbols&amp;quot;, &amp;quot;Tai Xuan Jing Symbols&amp;quot;,&lt;br /&gt;
      &amp;quot;Mathematical Alphanumeric Symbols&amp;quot;, &amp;quot;CJK Unified Ideographs Extension B&amp;quot;,&lt;br /&gt;
      &amp;quot;CJK Compatibility Ideographs Supplement&amp;quot;, &amp;quot;Tags&amp;quot;, &amp;quot;Variation Selectors Supplement&amp;quot;,&lt;br /&gt;
      &amp;quot;Supplementary Private Use Area-A&amp;quot;, &amp;quot;Supplementary Private Use Area-B&amp;quot;, &amp;quot;Custom...&amp;quot;, };&lt;br /&gt;
  private boolean useCustomRange = false;&lt;br /&gt;
  private int[] customRange = { 0x0000, 0x007f };&lt;br /&gt;
  // / Custom range dialog variables&lt;br /&gt;
  private final JDialog customRangeDialog;&lt;br /&gt;
  private final JTextField customRangeStart = new JTextField(&amp;quot;0000&amp;quot;, 4);&lt;br /&gt;
  private final JTextField customRangeEnd = new JTextField(&amp;quot;007F&amp;quot;, 4);&lt;br /&gt;
  private final int CUSTOM_RANGE_INDEX = UNICODE_RANGE_NAMES.length - 1;&lt;br /&gt;
  // / Parent Font2DTest Object holder&lt;br /&gt;
  private final Font2DTest parent;&lt;br /&gt;
  public static final int SURROGATES_AREA_INDEX = 91;&lt;br /&gt;
  public RangeMenu(Font2DTest demo, JFrame f) {&lt;br /&gt;
    super();&lt;br /&gt;
    parent = demo;&lt;br /&gt;
    for (int i = 0; i &amp;lt; UNICODE_RANGE_NAMES.length; i++)&lt;br /&gt;
      addItem(UNICODE_RANGE_NAMES[i]);&lt;br /&gt;
    setSelectedIndex(0);&lt;br /&gt;
    addActionListener(this);&lt;br /&gt;
    // / Set up custom range dialog...&lt;br /&gt;
    customRangeDialog = new JDialog(f, &amp;quot;Custom Unicode Range&amp;quot;, true);&lt;br /&gt;
    customRangeDialog.setResizable(false);&lt;br /&gt;
    JPanel dialogTop = new JPanel();&lt;br /&gt;
    JPanel dialogBottom = new JPanel();&lt;br /&gt;
    JButton okButton = new JButton(&amp;quot;OK&amp;quot;);&lt;br /&gt;
    JLabel from = new JLabel(&amp;quot;From:&amp;quot;);&lt;br /&gt;
    JLabel to = new JLabel(&amp;quot;To:&amp;quot;);&lt;br /&gt;
    Font labelFont = new Font(&amp;quot;dialog&amp;quot;, Font.BOLD, 12);&lt;br /&gt;
    from.setFont(labelFont);&lt;br /&gt;
    to.setFont(labelFont);&lt;br /&gt;
    okButton.setFont(labelFont);&lt;br /&gt;
    dialogTop.add(from);&lt;br /&gt;
    dialogTop.add(customRangeStart);&lt;br /&gt;
    dialogTop.add(to);&lt;br /&gt;
    dialogTop.add(customRangeEnd);&lt;br /&gt;
    dialogBottom.add(okButton);&lt;br /&gt;
    okButton.addActionListener(this);&lt;br /&gt;
    customRangeDialog.getContentPane().setLayout(new BorderLayout());&lt;br /&gt;
    customRangeDialog.getContentPane().add(&amp;quot;North&amp;quot;, dialogTop);&lt;br /&gt;
    customRangeDialog.getContentPane().add(&amp;quot;South&amp;quot;, dialogBottom);&lt;br /&gt;
    customRangeDialog.pack();&lt;br /&gt;
  }&lt;br /&gt;
  // / Return the range that is currently selected&lt;br /&gt;
  public int[] getSelectedRange() {&lt;br /&gt;
    if (useCustomRange) {&lt;br /&gt;
      int startIndex, endIndex;&lt;br /&gt;
      String startText, endText;&lt;br /&gt;
      String empty = &amp;quot;&amp;quot;;&lt;br /&gt;
      try {&lt;br /&gt;
        startText = customRangeStart.getText().trim();&lt;br /&gt;
        endText = customRangeEnd.getText().trim();&lt;br /&gt;
        if (startText.equals(empty) &amp;amp;&amp;amp; !endText.equals(empty)) {&lt;br /&gt;
          endIndex = Integer.parseInt(endText, 16);&lt;br /&gt;
          startIndex = endIndex - 7 * 25;&lt;br /&gt;
        } else if (!startText.equals(empty) &amp;amp;&amp;amp; endText.equals(empty)) {&lt;br /&gt;
          startIndex = Integer.parseInt(startText, 16);&lt;br /&gt;
          endIndex = startIndex + 7 * 25;&lt;br /&gt;
        } else {&lt;br /&gt;
          startIndex = Integer.parseInt(customRangeStart.getText(), 16);&lt;br /&gt;
          endIndex = Integer.parseInt(customRangeEnd.getText(), 16);&lt;br /&gt;
        }&lt;br /&gt;
      } catch (Exception e) {&lt;br /&gt;
        // / Error in parsing the hex number ---&lt;br /&gt;
        // / Reset the range to what it was before and return that&lt;br /&gt;
        customRangeStart.setText(Integer.toString(customRange[0], 16));&lt;br /&gt;
        customRangeEnd.setText(Integer.toString(customRange[1], 16));&lt;br /&gt;
        return customRange;&lt;br /&gt;
      }&lt;br /&gt;
      if (startIndex &amp;lt; 0)&lt;br /&gt;
        startIndex = 0;&lt;br /&gt;
      if (endIndex &amp;gt; 0xffff)&lt;br /&gt;
        endIndex = 0xffff;&lt;br /&gt;
      if (startIndex &amp;gt; endIndex)&lt;br /&gt;
        startIndex = endIndex;&lt;br /&gt;
      customRange[0] = startIndex;&lt;br /&gt;
      customRange[1] = endIndex;&lt;br /&gt;
      return customRange;&lt;br /&gt;
    } else&lt;br /&gt;
      return UNICODE_RANGES[getSelectedIndex()];&lt;br /&gt;
  }&lt;br /&gt;
  // / Function used by loadOptions in Font2DTest main panel&lt;br /&gt;
  // / to reset setting and range selection&lt;br /&gt;
  public void setSelectedRange(String name, int start, int end) {&lt;br /&gt;
    setSelectedItem(name);&lt;br /&gt;
    customRange[0] = start;&lt;br /&gt;
    customRange[1] = end;&lt;br /&gt;
    parent.fireRangeChanged();&lt;br /&gt;
  }&lt;br /&gt;
  // / ActionListener interface function&lt;br /&gt;
  // / ABP&lt;br /&gt;
  // / moved JComboBox event code into this fcn from&lt;br /&gt;
  // / itemStateChanged() method. Part of change to Swing.&lt;br /&gt;
  public void actionPerformed(ActionEvent e) {&lt;br /&gt;
    Object source = e.getSource();&lt;br /&gt;
    if (source instanceof JComboBox) {&lt;br /&gt;
      String rangeName = (String) ((JComboBox) source).getSelectedItem();&lt;br /&gt;
      if (rangeName.equals(&amp;quot;Custom...&amp;quot;)) {&lt;br /&gt;
        useCustomRange = true;&lt;br /&gt;
        customRangeDialog.setLocationRelativeTo(parent);&lt;br /&gt;
        customRangeDialog.show();&lt;br /&gt;
      } else {&lt;br /&gt;
        useCustomRange = false;&lt;br /&gt;
      }&lt;br /&gt;
      parent.fireRangeChanged();&lt;br /&gt;
    } else if (source instanceof JButton) {&lt;br /&gt;
      // / Since it is only &amp;quot;OK&amp;quot; button that sends any action here...&lt;br /&gt;
      customRangeDialog.hide();&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
          &lt;br /&gt;
    &lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;/div&gt;</summary>
		<author><name>Admin</name></author>	</entry>

	<entry>
		<id>http://jexp.ru/index.php?title=Java/Swing_Components&amp;diff=9250</id>
		<title>Java/Swing Components</title>
		<link rel="alternate" type="text/html" href="http://jexp.ru/index.php?title=Java/Swing_Components&amp;diff=9250"/>
				<updated>2010-06-01T07:45:15Z</updated>
		
		<summary type="html">&lt;p&gt;Admin: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;* [[Java/Swing Components/Action Framework | Action Framework]]&lt;br /&gt;
* [[Java/Swing Components/Animation | Animation]]&lt;br /&gt;
* [[Java/Swing Components/Border | Border]]&lt;br /&gt;
* [[Java/Swing Components/Button | Button]]&lt;br /&gt;
* [[Java/Swing Components/Button Bar | Button Bar]]&lt;br /&gt;
* [[Java/Swing Components/Calculator | Calculator]]&lt;br /&gt;
* [[Java/Swing Components/Calendar | Calendar]]&lt;br /&gt;
* [[Java/Swing Components/Chart | Chart]]&lt;br /&gt;
* [[Java/Swing Components/Clock | Clock]]&lt;br /&gt;
* [[Java/Swing Components/Color Chooser | Color Chooser]]&lt;br /&gt;
* [[Java/Swing Components/ComboBox | ComboBox]]&lt;br /&gt;
* [[Java/Swing Components/Data Binding | Data Binding]]&lt;br /&gt;
* [[Java/Swing Components/Data Binding Master Slave | Data Binding Master Slave]]&lt;br /&gt;
* [[Java/Swing Components/Data Binding Value Types | Data Binding Value Types]]&lt;br /&gt;
* [[Java/Swing Components/Data Validation | Data Validation]]&lt;br /&gt;
* [[Java/Swing Components/Dialog | Dialog]]&lt;br /&gt;
* [[Java/Swing Components/Dir Chooser | Dir Chooser]]&lt;br /&gt;
* [[Java/Swing Components/Dockable | Dockable]]&lt;br /&gt;
* [[Java/Swing Components/Dual List | Dual List]]&lt;br /&gt;
* [[Java/Swing Components/Email Client | Email Client]]&lt;br /&gt;
* [[Java/Swing Components/Event Schedular | Event Schedular]]&lt;br /&gt;
* [[Java/Swing Components/Font Chooser | Font Chooser]]&lt;br /&gt;
* [[Java/Swing Components/FormLayout | FormLayout]]&lt;br /&gt;
* [[Java/Swing Components/GlassPane | GlassPane]]&lt;br /&gt;
* [[Java/Swing Components/Grid Table | Grid Table]]&lt;br /&gt;
* [[Java/Swing Components/Item Chooser | Item Chooser]]&lt;br /&gt;
* [[Java/Swing Components/JGoodies Looks | JGoodies Looks]]&lt;br /&gt;
* [[Java/Swing Components/Label | Label]]&lt;br /&gt;
* [[Java/Swing Components/LayeredPane | LayeredPane]]&lt;br /&gt;
* [[Java/Swing Components/Link Button | Link Button]]&lt;br /&gt;
* [[Java/Swing Components/List | List]]&lt;br /&gt;
* [[Java/Swing Components/Outlook Bar | Outlook Bar]]&lt;br /&gt;
* [[Java/Swing Components/Panel | Panel]]&lt;br /&gt;
* [[Java/Swing Components/Property Sheet Table | Property Sheet Table]]&lt;br /&gt;
* [[Java/Swing Components/Separator | Separator]]&lt;br /&gt;
* [[Java/Swing Components/Slider | Slider]]&lt;br /&gt;
* [[Java/Swing Components/Status Bar | Status Bar]]&lt;br /&gt;
* [[Java/Swing Components/Swing Balloon | Swing Balloon]]&lt;br /&gt;
* [[Java/Swing Components/TabbedPane | TabbedPane]]&lt;br /&gt;
* [[Java/Swing Components/Taskpane | Taskpane]]&lt;br /&gt;
* [[Java/Swing Components/Timer | Timer]]&lt;br /&gt;
* [[Java/Swing Components/Tip of the Day | Tip of the Day]]&lt;br /&gt;
* [[Java/Swing Components/Tree | Tree]]&lt;br /&gt;
* [[Java/Swing Components/TreeTable | TreeTable]]&lt;br /&gt;
* [[Java/Swing Components/Wizard | Wizard]]&lt;/div&gt;</summary>
		<author><name>Admin</name></author>	</entry>

	<entry>
		<id>http://jexp.ru/index.php?title=Java/Swing_Components&amp;diff=9249</id>
		<title>Java/Swing Components</title>
		<link rel="alternate" type="text/html" href="http://jexp.ru/index.php?title=Java/Swing_Components&amp;diff=9249"/>
				<updated>2010-06-01T07:44:04Z</updated>
		
		<summary type="html">&lt;p&gt;Admin: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;* [[Java/Swing Components/Action Framework | Action Framework]]&lt;br /&gt;
* [[Java/Swing Components/Animation | Animation]]&lt;br /&gt;
* [[Java/Swing Components/Border | Border]]&lt;br /&gt;
* [[Java/Swing Components/Button | Button]]&lt;br /&gt;
* [[Java/Swing Components/Button Bar | Button Bar]]&lt;br /&gt;
* [[Java/Swing Components/Calculator | Calculator]]&lt;br /&gt;
* [[Java/Swing Components/Calendar | Calendar]]&lt;br /&gt;
* [[Java/Swing Components/Chart | Chart]]&lt;br /&gt;
* [[Java/Swing Components/Clock | Clock]]&lt;br /&gt;
* [[Java/Swing Components/Color Chooser | Color Chooser]]&lt;br /&gt;
* [[Java/Swing Components/ComboBox | ComboBox]]&lt;br /&gt;
* [[Java/Swing Components/Data Binding | Data Binding]]&lt;br /&gt;
* [[Java/Swing Components/Data Binding Master Slave | Data Binding Master Slave]]&lt;br /&gt;
* [[Java/Swing Components/Data Binding Value Types | Data Binding Value Types]]&lt;br /&gt;
* [[Java/Swing Components/Data Validation | Data Validation]]&lt;br /&gt;
* [[Java/Swing Components/Dialog | Dialog]]&lt;br /&gt;
* [[Java/Swing Components/Dir Chooser | Dir Chooser]]&lt;br /&gt;
* [[Java/Swing Components/Dockable | Dockable]]&lt;br /&gt;
* [[Java/Swing Components/Dual List | Dual List]]&lt;br /&gt;
* [[Java/Swing Components/Email Client | Email Client]]&lt;br /&gt;
* [[Java/Swing Components/Event Schedular | Event Schedular]]&lt;br /&gt;
* [[Java/Swing Components/Font Chooser | Font Chooser]]&lt;br /&gt;
* [[Java/Swing Components/FormLayout | FormLayout]]&lt;br /&gt;
* [[Java/Swing Components/GlassPane | GlassPane]]&lt;br /&gt;
* [[Java/Swing Components/Grid Table | Grid Table]]&lt;br /&gt;
* [[Java/Swing Components/Item Chooser | Item Chooser]]&lt;br /&gt;
* [[Java/Swing Components/JGoodies Looks | JGoodies Looks]]&lt;br /&gt;
* [[Java/Swing Components/Label | Label]]&lt;br /&gt;
* [[Java/Swing Components/LayeredPane | LayeredPane]]&lt;br /&gt;
* [[Java/Swing Components/Link Button | Link Button]]&lt;br /&gt;
* [[Java/Swing Components/List | List]]&lt;br /&gt;
* [[Java/Swing Components/Outlook Bar | Outlook Bar]]&lt;br /&gt;
* [[Java/Swing Components/Panel | Panel]]&lt;br /&gt;
* [[Java/Swing Components/Property Sheet Table | Property Sheet Table]]&lt;br /&gt;
* [[Java/Swing Components/Separator | Separator]]&lt;br /&gt;
* [[Java/Swing Components/Slider | Slider]]&lt;br /&gt;
* [[Java/Swing Components/Status Bar | Status Bar]]&lt;br /&gt;
* [[Java/Swing Components/Swing Balloon | Swing Balloon]]&lt;br /&gt;
* [[Java/Swing Components/TabbedPane | TabbedPane]]&lt;br /&gt;
* [[Java/Swing Components/Taskpane | Taskpane]]&lt;br /&gt;
* [[Java/Swing Components/Timer | Timer]]&lt;br /&gt;
* [[Java/Swing Components/Tip of the Day | Tip of the Day]]&lt;br /&gt;
* [[Java/Swing Components/Tree | Tree]]&lt;br /&gt;
* [[Java/Swing Components/TreeTable | TreeTable]]&lt;br /&gt;
* [[Java/Swing Components/Wizard | Wizard]]&lt;br /&gt;
&lt;br /&gt;
== A dialog allow selection and a font and its associated info. ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
/*&lt;br /&gt;
 * Copyright (C) 2001-2004 Colin Bell&lt;br /&gt;
 * colbell@users.sourceforge.net&lt;br /&gt;
 *&lt;br /&gt;
 * This library is free software; you can redistribute it and/or&lt;br /&gt;
 * modify it under the terms of the GNU Lesser General Public&lt;br /&gt;
 * License as published by the Free Software Foundation; either&lt;br /&gt;
 * version 2.1 of the License, or (at your option) any later version.&lt;br /&gt;
 *&lt;br /&gt;
 * This library is distributed in the hope that it will be useful,&lt;br /&gt;
 * but WITHOUT ANY WARRANTY; without even the implied warranty of&lt;br /&gt;
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU&lt;br /&gt;
 * Lesser General Public License for more details.&lt;br /&gt;
 *&lt;br /&gt;
 * You should have received a copy of the GNU Lesser General Public&lt;br /&gt;
 * License along with this library; if not, write to the Free Software&lt;br /&gt;
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA&lt;br /&gt;
 */&lt;br /&gt;
import java.awt.BorderLayout;&lt;br /&gt;
import java.awt.Dialog;&lt;br /&gt;
import java.awt.Dimension;&lt;br /&gt;
import java.awt.Font;&lt;br /&gt;
import java.awt.Frame;&lt;br /&gt;
import java.awt.GraphicsEnvironment;&lt;br /&gt;
import java.awt.GridBagConstraints;&lt;br /&gt;
import java.awt.GridBagLayout;&lt;br /&gt;
import java.awt.Insets;&lt;br /&gt;
import java.awt.event.ActionEvent;&lt;br /&gt;
import java.awt.event.ActionListener;&lt;br /&gt;
import java.io.Serializable;&lt;br /&gt;
import javax.swing.BorderFactory;&lt;br /&gt;
import javax.swing.JButton;&lt;br /&gt;
import javax.swing.JCheckBox;&lt;br /&gt;
import javax.swing.JComboBox;&lt;br /&gt;
import javax.swing.JDialog;&lt;br /&gt;
import javax.swing.JLabel;&lt;br /&gt;
import javax.swing.JPanel;&lt;br /&gt;
/**&lt;br /&gt;
 * A dialog allow selection and a font and its associated info.&lt;br /&gt;
 *&lt;br /&gt;
 * @author &lt;br /&gt;
 */&lt;br /&gt;
public class FontChooser extends JDialog&lt;br /&gt;
{&lt;br /&gt;
  private final boolean _selectStyles;&lt;br /&gt;
  private JComboBox _fontNamesCmb;&lt;br /&gt;
  private final JComboBox _fontSizesCmb = new JComboBox(new String[]&lt;br /&gt;
                        { &amp;quot;8&amp;quot;, &amp;quot;9&amp;quot;, &amp;quot;10&amp;quot;, &amp;quot;12&amp;quot;, &amp;quot;14&amp;quot; });&lt;br /&gt;
  private final JCheckBox _boldChk = new JCheckBox(&amp;quot;Bold&amp;quot;);&lt;br /&gt;
  private final JCheckBox _italicChk = new JCheckBox(&amp;quot;Italic&amp;quot;);&lt;br /&gt;
  private final JLabel _previewLbl = new JLabel(&amp;quot;PreviewText&amp;quot;);&lt;br /&gt;
  private Font _font;&lt;br /&gt;
  private ActionListener _previewUpdater;&lt;br /&gt;
  /**&lt;br /&gt;
   * Default ctor.&lt;br /&gt;
   */&lt;br /&gt;
  public FontChooser()&lt;br /&gt;
  {&lt;br /&gt;
    this((Frame)null);&lt;br /&gt;
  }&lt;br /&gt;
  /**&lt;br /&gt;
   * ctor specifying whether styles can be selected.&lt;br /&gt;
   *&lt;br /&gt;
   * @param selectStyles  If &amp;lt;TT&amp;gt;true&amp;lt;/TT&amp;gt; bold and italic checkboxes displayed.&lt;br /&gt;
   */&lt;br /&gt;
  public FontChooser(boolean selectStyles)&lt;br /&gt;
  {&lt;br /&gt;
    this((Frame)null, selectStyles);&lt;br /&gt;
  }&lt;br /&gt;
  /**&lt;br /&gt;
   * ctor specifying the parent frame.&lt;br /&gt;
   *&lt;br /&gt;
   * @param owner Parent frame.&lt;br /&gt;
   */&lt;br /&gt;
  public FontChooser(Frame owner)&lt;br /&gt;
  {&lt;br /&gt;
    super(owner, &amp;quot;Font Chooser&amp;quot;, true);&lt;br /&gt;
    _selectStyles = true;&lt;br /&gt;
    createUserInterface();&lt;br /&gt;
  }&lt;br /&gt;
  /**&lt;br /&gt;
   * ctor specifying the parent frame and whether styles can be selected.&lt;br /&gt;
   *&lt;br /&gt;
   * @param owner     Parent frame.&lt;br /&gt;
   * @param selectStyles  If &amp;lt;TT&amp;gt;true&amp;lt;/TT&amp;gt; bold and italic checkboxes displayed.&lt;br /&gt;
   */&lt;br /&gt;
  public FontChooser(Frame owner, boolean selectStyles)&lt;br /&gt;
  {&lt;br /&gt;
    super(owner, &amp;quot;Font Chooser&amp;quot;, true);&lt;br /&gt;
    _selectStyles = selectStyles;&lt;br /&gt;
    createUserInterface();&lt;br /&gt;
  }&lt;br /&gt;
  /**&lt;br /&gt;
   * ctor specifying the parent dialog.&lt;br /&gt;
   *&lt;br /&gt;
   * @param owner Parent frame.&lt;br /&gt;
   */&lt;br /&gt;
  public FontChooser(Dialog owner)&lt;br /&gt;
  {&lt;br /&gt;
    super(owner, &amp;quot;Font Chooser&amp;quot;, true);&lt;br /&gt;
    _selectStyles = true;&lt;br /&gt;
    createUserInterface();&lt;br /&gt;
  }&lt;br /&gt;
  /**&lt;br /&gt;
   * ctor specifying the parent dialog and whether styles can be selected.&lt;br /&gt;
   *&lt;br /&gt;
   * @param owner Parent frame.&lt;br /&gt;
   * @param selectStyles  If &amp;lt;TT&amp;gt;true&amp;lt;/TT&amp;gt; bold and italic checkboxes displayed.&lt;br /&gt;
   */&lt;br /&gt;
  public FontChooser(Dialog owner, boolean selectStyles)&lt;br /&gt;
  {&lt;br /&gt;
    super(owner, &amp;quot;Font Chooser&amp;quot;, true);&lt;br /&gt;
    _selectStyles = selectStyles;&lt;br /&gt;
    createUserInterface();&lt;br /&gt;
  }&lt;br /&gt;
  /**&lt;br /&gt;
   * Component is being added to its parent.&lt;br /&gt;
   */&lt;br /&gt;
  public void addNotify()&lt;br /&gt;
  {&lt;br /&gt;
    super.addNotify();&lt;br /&gt;
    if (_previewUpdater == null)&lt;br /&gt;
    {&lt;br /&gt;
      _previewUpdater = new PreviewLabelUpdater();&lt;br /&gt;
      _fontNamesCmb.addActionListener(_previewUpdater);&lt;br /&gt;
      _fontSizesCmb.addActionListener(_previewUpdater);&lt;br /&gt;
      _boldChk.addActionListener(_previewUpdater);&lt;br /&gt;
      _italicChk.addActionListener(_previewUpdater);&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
  /**&lt;br /&gt;
   * Component is being removed from its parent.&lt;br /&gt;
   */&lt;br /&gt;
  public void removeNotify()&lt;br /&gt;
  {&lt;br /&gt;
    super.removeNotify();&lt;br /&gt;
    if (_previewUpdater != null)&lt;br /&gt;
    {&lt;br /&gt;
      _fontNamesCmb.removeActionListener(_previewUpdater);&lt;br /&gt;
      _fontSizesCmb.removeActionListener(_previewUpdater);&lt;br /&gt;
      _boldChk.removeActionListener(_previewUpdater);&lt;br /&gt;
      _italicChk.removeActionListener(_previewUpdater);&lt;br /&gt;
      _previewUpdater = null;&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
  public Font showDialog()&lt;br /&gt;
  {&lt;br /&gt;
    return showDialog(null);&lt;br /&gt;
  }&lt;br /&gt;
  /**&lt;br /&gt;
   * Show dialog defaulting to the passed font.&lt;br /&gt;
   *&lt;br /&gt;
   * @param font  The font to default to.&lt;br /&gt;
   */&lt;br /&gt;
  public Font showDialog(Font font)&lt;br /&gt;
  {&lt;br /&gt;
    if (font != null)&lt;br /&gt;
    {&lt;br /&gt;
      _fontNamesCmb.setSelectedItem(font.getName());&lt;br /&gt;
      _fontSizesCmb.setSelectedItem(&amp;quot;&amp;quot; + font.getSize());&lt;br /&gt;
      _boldChk.setSelected(_selectStyles &amp;amp;&amp;amp; font.isBold());&lt;br /&gt;
      _italicChk.setSelected(_selectStyles &amp;amp;&amp;amp; font.isItalic());&lt;br /&gt;
    }&lt;br /&gt;
    else&lt;br /&gt;
    {&lt;br /&gt;
      _fontNamesCmb.setSelectedIndex(0);&lt;br /&gt;
      _fontSizesCmb.setSelectedIndex(0);&lt;br /&gt;
      _boldChk.setSelected(false);&lt;br /&gt;
      _italicChk.setSelected(false);&lt;br /&gt;
    }&lt;br /&gt;
    setupPreviewLabel();&lt;br /&gt;
    setVisible(true);&lt;br /&gt;
    return _font;&lt;br /&gt;
  }&lt;br /&gt;
  public Font getSelectedFont()&lt;br /&gt;
  {&lt;br /&gt;
    return _font;&lt;br /&gt;
  }&lt;br /&gt;
  protected void setupFontFromDialog()&lt;br /&gt;
  {&lt;br /&gt;
    int size = 12;&lt;br /&gt;
    try&lt;br /&gt;
    {&lt;br /&gt;
      size = Integer.parseInt((String)_fontSizesCmb.getSelectedItem());&lt;br /&gt;
    }&lt;br /&gt;
    catch (Exception ignore)&lt;br /&gt;
    {&lt;br /&gt;
      // Ignore.&lt;br /&gt;
    }&lt;br /&gt;
    FontInfo fi = new FontInfo();&lt;br /&gt;
    fi.setFamily((String)_fontNamesCmb.getSelectedItem());&lt;br /&gt;
    fi.setSize(size);&lt;br /&gt;
    fi.setIsBold(_boldChk.isSelected());&lt;br /&gt;
    fi.setIsItalic(_italicChk.isSelected());&lt;br /&gt;
    _font = fi.createFont();&lt;br /&gt;
  }&lt;br /&gt;
  private void createUserInterface()&lt;br /&gt;
  {&lt;br /&gt;
    final JPanel content = new JPanel(new GridBagLayout());&lt;br /&gt;
    final GridBagConstraints gbc = new GridBagConstraints();&lt;br /&gt;
    setContentPane(content);&lt;br /&gt;
    content.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));&lt;br /&gt;
    gbc.anchor = GridBagConstraints.WEST;&lt;br /&gt;
    gbc.insets = new Insets(2, 2, 2, 2);&lt;br /&gt;
    gbc.fill = GridBagConstraints.HORIZONTAL;&lt;br /&gt;
    gbc.gridx = gbc.gridy = 0;&lt;br /&gt;
    content.add(new JLabel(&amp;quot;Font&amp;quot;), gbc);&lt;br /&gt;
    ++gbc.gridx;&lt;br /&gt;
    content.add(new JLabel(&amp;quot;Size&amp;quot;), gbc);&lt;br /&gt;
    if (_selectStyles)&lt;br /&gt;
    {&lt;br /&gt;
      ++gbc.gridx;&lt;br /&gt;
      content.add(new JLabel(&amp;quot;Style&amp;quot;), gbc);&lt;br /&gt;
    }&lt;br /&gt;
    ++gbc.gridy;&lt;br /&gt;
    gbc.gridx = 0;&lt;br /&gt;
    _fontNamesCmb = new JComboBox(GraphicsEnvironment.getLocalGraphicsEnvironment().getAvailableFontFamilyNames());&lt;br /&gt;
    content.add(_fontNamesCmb, gbc);&lt;br /&gt;
    ++gbc.gridx;&lt;br /&gt;
    _fontSizesCmb.setEditable(true);&lt;br /&gt;
    content.add(_fontSizesCmb, gbc);&lt;br /&gt;
    if (_selectStyles)&lt;br /&gt;
    {&lt;br /&gt;
      ++gbc.gridx;&lt;br /&gt;
      content.add(_boldChk, gbc);&lt;br /&gt;
      ++gbc.gridy;&lt;br /&gt;
      content.add(_italicChk, gbc);&lt;br /&gt;
    }&lt;br /&gt;
    gbc.gridx = 0;&lt;br /&gt;
    ++gbc.gridy;&lt;br /&gt;
    gbc.gridwidth = GridBagConstraints.REMAINDER;&lt;br /&gt;
    gbc.fill = GridBagConstraints.BOTH;&lt;br /&gt;
    gbc.anchor = GridBagConstraints.CENTER;&lt;br /&gt;
    content.add(createPreviewPanel(), gbc);&lt;br /&gt;
    ++gbc.gridy;&lt;br /&gt;
    gbc.fill = GridBagConstraints.HORIZONTAL;&lt;br /&gt;
    content.add(createButtonsPanel(), gbc);&lt;br /&gt;
    pack();&lt;br /&gt;
    setResizable(true);&lt;br /&gt;
  }&lt;br /&gt;
  private JPanel createPreviewPanel()&lt;br /&gt;
  {&lt;br /&gt;
    final JPanel pnl = new JPanel(new BorderLayout());&lt;br /&gt;
    pnl.setBorder(BorderFactory.createTitledBorder(&amp;quot;PreviewTitle&amp;quot;));&lt;br /&gt;
    Dimension prefSize = _previewLbl.getPreferredSize();&lt;br /&gt;
    prefSize.height = 50;&lt;br /&gt;
    _previewLbl.setPreferredSize(prefSize);&lt;br /&gt;
    pnl.add(_previewLbl, BorderLayout.CENTER);&lt;br /&gt;
    setupPreviewLabel();&lt;br /&gt;
    return pnl;&lt;br /&gt;
  }&lt;br /&gt;
  private JPanel createButtonsPanel()&lt;br /&gt;
  {&lt;br /&gt;
    JPanel pnl = new JPanel();&lt;br /&gt;
    JButton okBtn = new JButton(&amp;quot;OK&amp;quot;);&lt;br /&gt;
    okBtn.addActionListener(new ActionListener()&lt;br /&gt;
    {&lt;br /&gt;
      public void actionPerformed(ActionEvent evt)&lt;br /&gt;
      {&lt;br /&gt;
        setupFontFromDialog();&lt;br /&gt;
        dispose();&lt;br /&gt;
      }&lt;br /&gt;
    });&lt;br /&gt;
    JButton cancelBtn = new JButton(&amp;quot;Cancel&amp;quot;);&lt;br /&gt;
    cancelBtn.addActionListener(new ActionListener()&lt;br /&gt;
    {&lt;br /&gt;
      public void actionPerformed(ActionEvent evt)&lt;br /&gt;
      {&lt;br /&gt;
        FontChooser.this._font = null;&lt;br /&gt;
        dispose();&lt;br /&gt;
      }&lt;br /&gt;
    });&lt;br /&gt;
    pnl.add(okBtn);&lt;br /&gt;
    pnl.add(cancelBtn);&lt;br /&gt;
    getRootPane().setDefaultButton(okBtn);&lt;br /&gt;
    return pnl;&lt;br /&gt;
  }&lt;br /&gt;
  private void setupPreviewLabel()&lt;br /&gt;
  {&lt;br /&gt;
    setupFontFromDialog();&lt;br /&gt;
    _previewLbl.setFont(_font);&lt;br /&gt;
  }&lt;br /&gt;
  private final class PreviewLabelUpdater implements ActionListener&lt;br /&gt;
  {&lt;br /&gt;
    public void actionPerformed(ActionEvent evt)&lt;br /&gt;
    {&lt;br /&gt;
      setupPreviewLabel();&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
/*&lt;br /&gt;
 * Copyright (C) 2001-2003 Colin Bell&lt;br /&gt;
 * colbell@users.sourceforge.net&lt;br /&gt;
 *&lt;br /&gt;
 * This library is free software; you can redistribute it and/or&lt;br /&gt;
 * modify it under the terms of the GNU Lesser General Public&lt;br /&gt;
 * License as published by the Free Software Foundation; either&lt;br /&gt;
 * version 2.1 of the License, or (at your option) any later version.&lt;br /&gt;
 *&lt;br /&gt;
 * This library is distributed in the hope that it will be useful,&lt;br /&gt;
 * but WITHOUT ANY WARRANTY; without even the implied warranty of&lt;br /&gt;
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU&lt;br /&gt;
 * Lesser General Public License for more details.&lt;br /&gt;
 *&lt;br /&gt;
 * You should have received a copy of the GNU Lesser General Public&lt;br /&gt;
 * License along with this library; if not, write to the Free Software&lt;br /&gt;
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA&lt;br /&gt;
 */&lt;br /&gt;
 class FontInfo implements Cloneable, Serializable&lt;br /&gt;
{&lt;br /&gt;
    private static final long serialVersionUID = 1L;&lt;br /&gt;
    public interface IPropertyNames&lt;br /&gt;
  {&lt;br /&gt;
    String FAMILY = &amp;quot;family&amp;quot;;&lt;br /&gt;
    String IS_BOLD = &amp;quot;isBold&amp;quot;;&lt;br /&gt;
    String IS_ITALIC = &amp;quot;isItalic&amp;quot;;&lt;br /&gt;
    String SIZE = &amp;quot;size&amp;quot;;&lt;br /&gt;
  }&lt;br /&gt;
  private static String DEFAULT_FAMILY = &amp;quot;Monospaced&amp;quot;;&lt;br /&gt;
  private String _familyName;&lt;br /&gt;
  private boolean _isBold;&lt;br /&gt;
  private boolean _isItalic;&lt;br /&gt;
  private int _size;&lt;br /&gt;
  public FontInfo()&lt;br /&gt;
  {&lt;br /&gt;
    super();&lt;br /&gt;
    setFamily(DEFAULT_FAMILY);&lt;br /&gt;
    setSize(12);&lt;br /&gt;
  }&lt;br /&gt;
  public FontInfo(Font font)&lt;br /&gt;
  {&lt;br /&gt;
    super();&lt;br /&gt;
    if (font == null)&lt;br /&gt;
    {&lt;br /&gt;
      throw new IllegalArgumentException(&amp;quot;Null Font passed&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
    setFont(font);&lt;br /&gt;
  }&lt;br /&gt;
  /**&lt;br /&gt;
   * Return a copy of this object.&lt;br /&gt;
   */&lt;br /&gt;
  public Object clone()&lt;br /&gt;
  {&lt;br /&gt;
    try&lt;br /&gt;
    {&lt;br /&gt;
      return super.clone();&lt;br /&gt;
    }&lt;br /&gt;
    catch (CloneNotSupportedException ex)&lt;br /&gt;
    {&lt;br /&gt;
      throw new InternalError(ex.getMessage()); // Impossible.&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
  public String getFamily()&lt;br /&gt;
  {&lt;br /&gt;
    return _familyName;&lt;br /&gt;
  }&lt;br /&gt;
  public void setFamily(String value)&lt;br /&gt;
  {&lt;br /&gt;
    _familyName = value != null ? value : DEFAULT_FAMILY;&lt;br /&gt;
  }&lt;br /&gt;
  public boolean isBold()&lt;br /&gt;
  {&lt;br /&gt;
    return _isBold;&lt;br /&gt;
  }&lt;br /&gt;
  public void setIsBold(boolean value)&lt;br /&gt;
  {&lt;br /&gt;
    _isBold = value;&lt;br /&gt;
  }&lt;br /&gt;
  public boolean isItalic()&lt;br /&gt;
  {&lt;br /&gt;
    return _isItalic;&lt;br /&gt;
  }&lt;br /&gt;
  public void setIsItalic(boolean value)&lt;br /&gt;
  {&lt;br /&gt;
    _isItalic = value;&lt;br /&gt;
  }&lt;br /&gt;
  public int getSize()&lt;br /&gt;
  {&lt;br /&gt;
    return _size;&lt;br /&gt;
  }&lt;br /&gt;
  public void setSize(int value)&lt;br /&gt;
  {&lt;br /&gt;
    _size = value;&lt;br /&gt;
  }&lt;br /&gt;
  public void setFont(Font font) throws IllegalArgumentException&lt;br /&gt;
  {&lt;br /&gt;
    if (font == null)&lt;br /&gt;
    {&lt;br /&gt;
      throw new IllegalArgumentException(&amp;quot;Null Font passed&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
    _familyName = font.getFamily();&lt;br /&gt;
    _isBold = font.isBold();&lt;br /&gt;
    _isItalic = font.isItalic();&lt;br /&gt;
    _size = font.getSize();&lt;br /&gt;
  }&lt;br /&gt;
  public boolean doesFontMatch(Font font)&lt;br /&gt;
  {&lt;br /&gt;
    if (font == null)&lt;br /&gt;
    {&lt;br /&gt;
      return false;&lt;br /&gt;
    }&lt;br /&gt;
    return font.getFamily().equals(_familyName)&lt;br /&gt;
      &amp;amp;&amp;amp; font.getSize() == getSize()&lt;br /&gt;
      &amp;amp;&amp;amp; font.getStyle() == generateStyle();&lt;br /&gt;
  }&lt;br /&gt;
  public int generateStyle()&lt;br /&gt;
  {&lt;br /&gt;
    int style = 0;&lt;br /&gt;
    if (!_isBold &amp;amp;&amp;amp; !_isItalic)&lt;br /&gt;
    {&lt;br /&gt;
      style = Font.PLAIN;&lt;br /&gt;
    }&lt;br /&gt;
    else&lt;br /&gt;
    {&lt;br /&gt;
      if (_isBold)&lt;br /&gt;
      {&lt;br /&gt;
        style |= Font.BOLD;&lt;br /&gt;
      }&lt;br /&gt;
      if (_isItalic)&lt;br /&gt;
      {&lt;br /&gt;
        style |= Font.ITALIC;&lt;br /&gt;
      }&lt;br /&gt;
    }&lt;br /&gt;
    return style;&lt;br /&gt;
  }&lt;br /&gt;
  public Font createFont()&lt;br /&gt;
  {&lt;br /&gt;
    return new Font(_familyName, generateStyle(), _size);&lt;br /&gt;
  }&lt;br /&gt;
  // i18n ? What is this used for?&lt;br /&gt;
  public String toString()&lt;br /&gt;
  {&lt;br /&gt;
    StringBuffer buf = new StringBuffer();&lt;br /&gt;
    buf.append(_familyName).append(&amp;quot;, &amp;quot; + _size);&lt;br /&gt;
    if (_isBold)&lt;br /&gt;
    {&lt;br /&gt;
      buf.append(&amp;quot;, bold&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
    if (_isItalic)&lt;br /&gt;
    {&lt;br /&gt;
      buf.append(&amp;quot;, italic&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
    return buf.toString();&lt;br /&gt;
  }&lt;br /&gt;
    /**&lt;br /&gt;
     * @see java.lang.Object#hashCode()&lt;br /&gt;
     */&lt;br /&gt;
    @Override&lt;br /&gt;
    public int hashCode() {&lt;br /&gt;
        final int PRIME = 31;&lt;br /&gt;
        int result = 1;&lt;br /&gt;
        result = PRIME * result + ((_familyName == null) ? 0 : _familyName.hashCode());&lt;br /&gt;
        result = PRIME * result + (_isBold ? 1231 : 1237);&lt;br /&gt;
        result = PRIME * result + (_isItalic ? 1231 : 1237);&lt;br /&gt;
        result = PRIME * result + _size;&lt;br /&gt;
        return result;&lt;br /&gt;
    }&lt;br /&gt;
    /**&lt;br /&gt;
     * @see java.lang.Object#equals(java.lang.Object)&lt;br /&gt;
     */&lt;br /&gt;
    @Override&lt;br /&gt;
    public boolean equals(Object obj) {&lt;br /&gt;
        if (this == obj)&lt;br /&gt;
            return true;&lt;br /&gt;
        if (obj == null)&lt;br /&gt;
            return false;&lt;br /&gt;
        if (getClass() != obj.getClass())&lt;br /&gt;
            return false;&lt;br /&gt;
        final FontInfo other = (FontInfo) obj;&lt;br /&gt;
        if (_familyName == null) {&lt;br /&gt;
            if (other._familyName != null)&lt;br /&gt;
                return false;&lt;br /&gt;
        } else if (!_familyName.equals(other._familyName))&lt;br /&gt;
            return false;&lt;br /&gt;
        if (_isBold != other._isBold)&lt;br /&gt;
            return false;&lt;br /&gt;
        if (_isItalic != other._isItalic)&lt;br /&gt;
            return false;&lt;br /&gt;
        if (_size != other._size)&lt;br /&gt;
            return false;&lt;br /&gt;
        return true;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
   &lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== FontChooser, adapted from NwFontChooserS by Noah Wairauch ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
/*BEGIN_COPYRIGHT_BLOCK&lt;br /&gt;
 *&lt;br /&gt;
 * Copyright (c) 2001-2008, JavaPLT group at Rice University (drjava@rice.edu)&lt;br /&gt;
 * All rights reserved.&lt;br /&gt;
 * &lt;br /&gt;
 * Redistribution and use in source and binary forms, with or without&lt;br /&gt;
 * modification, are permitted provided that the following conditions are met:&lt;br /&gt;
 *    * Redistributions of source code must retain the above copyright&lt;br /&gt;
 *      notice, this list of conditions and the following disclaimer.&lt;br /&gt;
 *    * Redistributions in binary form must reproduce the above copyright&lt;br /&gt;
 *      notice, this list of conditions and the following disclaimer in the&lt;br /&gt;
 *      documentation and/or other materials provided with the distribution.&lt;br /&gt;
 *    * Neither the names of DrJava, the JavaPLT group, Rice University, nor the&lt;br /&gt;
 *      names of its contributors may be used to endorse or promote products&lt;br /&gt;
 *      derived from this software without specific prior written permission.&lt;br /&gt;
 * &lt;br /&gt;
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS&lt;br /&gt;
 * &amp;quot;AS IS&amp;quot; AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT&lt;br /&gt;
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR&lt;br /&gt;
 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR&lt;br /&gt;
 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,&lt;br /&gt;
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,&lt;br /&gt;
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR&lt;br /&gt;
 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF&lt;br /&gt;
 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING&lt;br /&gt;
 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS&lt;br /&gt;
 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.&lt;br /&gt;
 *&lt;br /&gt;
 * This software is Open Source Initiative approved Open Source Software.&lt;br /&gt;
 * Open Source Initative Approved is a trademark of the Open Source Initiative.&lt;br /&gt;
 * &lt;br /&gt;
 * This file is part of DrJava.  Download the current version of this project&lt;br /&gt;
 * from http://www.drjava.org/ or http://sourceforge.net/projects/drjava/&lt;br /&gt;
 * &lt;br /&gt;
 * END_COPYRIGHT_BLOCK*/&lt;br /&gt;
&lt;br /&gt;
import javax.swing.*;&lt;br /&gt;
import javax.swing.event.ListSelectionEvent;&lt;br /&gt;
import javax.swing.event.ListSelectionListener;&lt;br /&gt;
import java.awt.*;&lt;br /&gt;
import java.awt.event.*;&lt;br /&gt;
/**&lt;br /&gt;
 * FontChooser, adapted from NwFontChooserS by Noah Wairauch.&lt;br /&gt;
 * (see http:///forum.java.sun.ru/thread.jsp?forum=57&amp;amp;thread=195067)&lt;br /&gt;
 *&lt;br /&gt;
 * @version $Id: FontChooser.java 4872 2009-04-06 21:37:28Z mgricken $&lt;br /&gt;
 */&lt;br /&gt;
public class FontChooser extends JDialog {&lt;br /&gt;
  /** Available font styles.&lt;br /&gt;
   */&lt;br /&gt;
  private static final String[] STYLES =&lt;br /&gt;
      new String[] { &amp;quot;Plain&amp;quot;, &amp;quot;Bold&amp;quot;, &amp;quot;Italic&amp;quot;, &amp;quot;Bold Italic&amp;quot; };&lt;br /&gt;
  /** Available font sizes.&lt;br /&gt;
   */&lt;br /&gt;
  private static final String[] SIZES =&lt;br /&gt;
      new String[] { &amp;quot;3&amp;quot;, &amp;quot;4&amp;quot;, &amp;quot;5&amp;quot;, &amp;quot;6&amp;quot;, &amp;quot;7&amp;quot;, &amp;quot;8&amp;quot;, &amp;quot;9&amp;quot;, &amp;quot;10&amp;quot;, &amp;quot;11&amp;quot;, &amp;quot;12&amp;quot;,&lt;br /&gt;
                     &amp;quot;13&amp;quot;, &amp;quot;14&amp;quot;, &amp;quot;15&amp;quot;, &amp;quot;16&amp;quot;, &amp;quot;17&amp;quot;, &amp;quot;18&amp;quot;, &amp;quot;19&amp;quot;, &amp;quot;20&amp;quot;, &amp;quot;22&amp;quot;,&lt;br /&gt;
                     &amp;quot;24&amp;quot;, &amp;quot;27&amp;quot;, &amp;quot;30&amp;quot;, &amp;quot;34&amp;quot;, &amp;quot;39&amp;quot;, &amp;quot;45&amp;quot;, &amp;quot;51&amp;quot;, &amp;quot;60&amp;quot;};&lt;br /&gt;
  // Lists to display&lt;br /&gt;
  private NwList _styleList;&lt;br /&gt;
  private NwList _fontList;&lt;br /&gt;
  private NwList _sizeList;&lt;br /&gt;
  // Swing elements&lt;br /&gt;
  private JButton _okButton;&lt;br /&gt;
  private JButton _cancelButton;&lt;br /&gt;
  private JLabel _sampleText = new JLabel();&lt;br /&gt;
  private boolean _clickedOK = false;&lt;br /&gt;
  /** Constructs a new modal FontChooser for the given frame,&lt;br /&gt;
   * using the specified font.&lt;br /&gt;
   */&lt;br /&gt;
  private FontChooser(Frame parent, Font font) {&lt;br /&gt;
    super(parent, true);&lt;br /&gt;
    initAll();&lt;br /&gt;
    if (font == null) font = _sampleText.getFont();&lt;br /&gt;
    _fontList.setSelectedItem(font.getName());&lt;br /&gt;
    _sizeList.setSelectedItem(font.getSize() + &amp;quot;&amp;quot;);&lt;br /&gt;
    _styleList.setSelectedItem(STYLES[font.getStyle()]);&lt;br /&gt;
    //this.setResizable(false);&lt;br /&gt;
    resize();&lt;br /&gt;
  }&lt;br /&gt;
  /** Method used to show the font chooser, and select a new font.&lt;br /&gt;
   *&lt;br /&gt;
   * @param parent The parent frame.&lt;br /&gt;
   * @param title  The title for this window.&lt;br /&gt;
   * @param font   The previously chosen font.&lt;br /&gt;
   * @return the newly chosen font.&lt;br /&gt;
   */&lt;br /&gt;
  public static Font showDialog(Frame parent, String title, Font font) {&lt;br /&gt;
    FontChooser fd = new FontChooser(parent, font);&lt;br /&gt;
    fd.setTitle(title);&lt;br /&gt;
    &lt;br /&gt;
    fd.setVisible(true);&lt;br /&gt;
    Font chosenFont = null;&lt;br /&gt;
    if (fd.clickedOK()) {&lt;br /&gt;
      chosenFont = fd.getFont();&lt;br /&gt;
    }&lt;br /&gt;
    fd.dispose();&lt;br /&gt;
    return (chosenFont);&lt;br /&gt;
  }&lt;br /&gt;
  /** Shows the font chooser with a standard title (&amp;quot;Font Chooser&amp;quot;).&lt;br /&gt;
   */&lt;br /&gt;
  public static Font showDialog(Frame parent, Font font) {&lt;br /&gt;
    return showDialog(parent, &amp;quot;Font Chooser&amp;quot;, font);&lt;br /&gt;
  }&lt;br /&gt;
  private void initAll() {&lt;br /&gt;
    getContentPane().setLayout(null);&lt;br /&gt;
    setBounds(50, 50, 425, 400);&lt;br /&gt;
    _sampleText = new JLabel();&lt;br /&gt;
    addLists();&lt;br /&gt;
    addButtons();&lt;br /&gt;
    _sampleText.setForeground(Color.black);&lt;br /&gt;
    getContentPane().add(_sampleText);&lt;br /&gt;
    addWindowListener(new WindowAdapter() {&lt;br /&gt;
      public void windowClosing(java.awt.event.WindowEvent e) {&lt;br /&gt;
        setVisible(false);&lt;br /&gt;
      }&lt;br /&gt;
    });&lt;br /&gt;
    addComponentListener(new ComponentAdapter() {&lt;br /&gt;
      public void componentResized(ComponentEvent evt) {&lt;br /&gt;
        resize();&lt;br /&gt;
      }&lt;br /&gt;
    });&lt;br /&gt;
  }&lt;br /&gt;
  private void resize() {&lt;br /&gt;
    int w = getWidth();&lt;br /&gt;
    int h = getHeight();&lt;br /&gt;
    double wf = (double) w / 425;&lt;br /&gt;
    int w2 = (int) (80 * wf);&lt;br /&gt;
    int w3 = (int) (50 * wf);&lt;br /&gt;
    if (w3 &amp;lt; 30) w3 = 30;&lt;br /&gt;
    int w1 = w - w2 - w3 - 25;&lt;br /&gt;
    _fontList.setBounds(5, 5, w1, h - 91);&lt;br /&gt;
    _styleList.setBounds(w1 + 10, 5, w2, h - 91);&lt;br /&gt;
    _sizeList.setBounds(w1 + w2 + 15, 5, w3, h - 91);&lt;br /&gt;
    _sampleText.setBounds(10, h - 78, w - 20, 45);&lt;br /&gt;
    _okButton.setBounds(w - 165, h - 55, 70, 20);&lt;br /&gt;
    _cancelButton.setBounds(w - 81, h - 55, 70, 20);&lt;br /&gt;
    validate();&lt;br /&gt;
  }&lt;br /&gt;
  private void addLists() {&lt;br /&gt;
    _fontList = new NwList(GraphicsEnvironment.getLocalGraphicsEnvironment().getAvailableFontFamilyNames());&lt;br /&gt;
    _styleList = new NwList(STYLES);&lt;br /&gt;
    _sizeList = new NwList(SIZES);&lt;br /&gt;
    getContentPane().add(_fontList);&lt;br /&gt;
    getContentPane().add(_styleList);&lt;br /&gt;
    getContentPane().add(_sizeList);&lt;br /&gt;
  }&lt;br /&gt;
  private void addButtons() {&lt;br /&gt;
    _okButton = new JButton(&amp;quot;OK&amp;quot;);&lt;br /&gt;
    _okButton.setMargin(new Insets(0, 0, 0, 0));&lt;br /&gt;
    _cancelButton = new JButton(&amp;quot;Cancel&amp;quot;);&lt;br /&gt;
    _cancelButton.setMargin(new Insets(0, 0, 0, 0));&lt;br /&gt;
    _okButton.setFont(new Font(&amp;quot; &amp;quot;, 1, 11));&lt;br /&gt;
    _cancelButton.setFont(new Font(&amp;quot; &amp;quot;, 1, 12));&lt;br /&gt;
    getContentPane().add(_okButton);&lt;br /&gt;
    getContentPane().add(_cancelButton);&lt;br /&gt;
    _okButton.addActionListener(new ActionListener() {&lt;br /&gt;
      public void actionPerformed(ActionEvent e) {&lt;br /&gt;
        setVisible(false);&lt;br /&gt;
        _clickedOK = true;&lt;br /&gt;
      }&lt;br /&gt;
    });&lt;br /&gt;
    _cancelButton.addActionListener(new ActionListener() {&lt;br /&gt;
      public void actionPerformed(ActionEvent e) {&lt;br /&gt;
        setVisible(false);&lt;br /&gt;
        _clickedOK = false;&lt;br /&gt;
      }&lt;br /&gt;
    });&lt;br /&gt;
  }&lt;br /&gt;
  private void showSample() {&lt;br /&gt;
    int g = 0;&lt;br /&gt;
    try { g = Integer.parseInt(_sizeList.getSelectedValue()); }&lt;br /&gt;
    catch (NumberFormatException nfe) { /* do nothing */ }&lt;br /&gt;
    String st = _styleList.getSelectedValue();&lt;br /&gt;
    int s = Font.PLAIN;&lt;br /&gt;
    if (st.equalsIgnoreCase(&amp;quot;Bold&amp;quot;)) s = Font.BOLD;&lt;br /&gt;
    if (st.equalsIgnoreCase(&amp;quot;Italic&amp;quot;)) s = Font.ITALIC;&lt;br /&gt;
    if (st.equalsIgnoreCase(&amp;quot;Bold Italic&amp;quot;)) s = Font.BOLD | Font.ITALIC;&lt;br /&gt;
    _sampleText.setFont(new Font(_fontList.getSelectedValue(), s, g));&lt;br /&gt;
    _sampleText.setText(&amp;quot;The quick brown fox jumped over the lazy dog.&amp;quot;);&lt;br /&gt;
    _sampleText.setVerticalAlignment(SwingConstants.TOP);&lt;br /&gt;
  }&lt;br /&gt;
  /** Returns whether the user clicked OK when the dialog was closed. (If false, the user clicked cancel.) */&lt;br /&gt;
  public boolean clickedOK() { return _clickedOK; }&lt;br /&gt;
  /** Returns the currently selected Font. */&lt;br /&gt;
  public Font getFont() { return _sampleText.getFont(); }&lt;br /&gt;
  /** Private inner class for a list which displays a list of options in addition to a label indicating the currently&lt;br /&gt;
    * selected item.&lt;br /&gt;
    */&lt;br /&gt;
  public class NwList extends JPanel {&lt;br /&gt;
    JList jl;&lt;br /&gt;
    JScrollPane sp;&lt;br /&gt;
    JLabel jt;&lt;br /&gt;
    String si = &amp;quot; &amp;quot;;&lt;br /&gt;
    public NwList(String[] values) {&lt;br /&gt;
      setLayout(null);&lt;br /&gt;
      jl = new JList(values);&lt;br /&gt;
      sp = new JScrollPane(jl);&lt;br /&gt;
      jt = new JLabel();&lt;br /&gt;
      jt.setBackground(Color.white);&lt;br /&gt;
      jt.setForeground(Color.black);&lt;br /&gt;
      jt.setOpaque(true);&lt;br /&gt;
      jt.setBorder(new JTextField().getBorder());&lt;br /&gt;
      jt.setFont(getFont());&lt;br /&gt;
      jl.addListSelectionListener(new ListSelectionListener() {&lt;br /&gt;
        public void valueChanged(ListSelectionEvent e) {&lt;br /&gt;
          jt.setText((String) jl.getSelectedValue());&lt;br /&gt;
          si = (String) jl.getSelectedValue();&lt;br /&gt;
          showSample();&lt;br /&gt;
        }&lt;br /&gt;
      });&lt;br /&gt;
      add(sp);&lt;br /&gt;
      add(jt);&lt;br /&gt;
    }&lt;br /&gt;
    public void setBounds(int x, int y, int w, int h) {&lt;br /&gt;
      super.setBounds(x, y, w, h);&lt;br /&gt;
      sp.setBounds(0, y + 16, w, h - 23);&lt;br /&gt;
      sp.revalidate();&lt;br /&gt;
      jt.setBounds(0, 0, w, 20);&lt;br /&gt;
    }&lt;br /&gt;
    public String getSelectedValue() { return (si); }&lt;br /&gt;
    public void setSelectedItem(String s) { jl.setSelectedValue(s, true);}&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
   &lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== FontChooser by Noah w ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
/* This code was found posted on a forum without any copyright&lt;br /&gt;
 * restrictions. It was written by someone named Noah W.&lt;br /&gt;
 * That&amp;quot;s all I know */&lt;br /&gt;
/* I have modified the original code but claim no copyright on it of any kind */&lt;br /&gt;
&lt;br /&gt;
/*&lt;br /&gt;
This file is part of BORG.&lt;br /&gt;
    BORG is free software; you can redistribute it and/or modify&lt;br /&gt;
    it under the terms of the GNU General Public License as published by&lt;br /&gt;
    the Free Software Foundation; either version 2 of the License, or&lt;br /&gt;
    (at your option) any later version.&lt;br /&gt;
    BORG is distributed in the hope that it will be useful,&lt;br /&gt;
    but WITHOUT ANY WARRANTY; without even the implied warranty of&lt;br /&gt;
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the&lt;br /&gt;
    GNU General Public License for more details.&lt;br /&gt;
    You should have received a copy of the GNU General Public License&lt;br /&gt;
    along with BORG; if not, write to the Free Software&lt;br /&gt;
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA&lt;br /&gt;
Copyright 2003 by Mike Berger&lt;br /&gt;
 */&lt;br /&gt;
&lt;br /&gt;
import java.awt.Color;&lt;br /&gt;
import java.awt.Font;&lt;br /&gt;
import java.awt.Frame;&lt;br /&gt;
import java.awt.GraphicsEnvironment;&lt;br /&gt;
import java.awt.Insets;&lt;br /&gt;
import java.awt.event.ActionEvent;&lt;br /&gt;
import java.awt.event.ActionListener;&lt;br /&gt;
import java.awt.event.WindowAdapter;&lt;br /&gt;
import java.awt.event.WindowEvent;&lt;br /&gt;
import java.util.Enumeration;&lt;br /&gt;
import javax.swing.JButton;&lt;br /&gt;
import javax.swing.JDialog;&lt;br /&gt;
import javax.swing.JLabel;&lt;br /&gt;
import javax.swing.JList;&lt;br /&gt;
import javax.swing.JPanel;&lt;br /&gt;
import javax.swing.JScrollPane;&lt;br /&gt;
import javax.swing.JTextField;&lt;br /&gt;
import javax.swing.UIManager;&lt;br /&gt;
import javax.swing.event.ListSelectionEvent;&lt;br /&gt;
import javax.swing.event.ListSelectionListener;&lt;br /&gt;
import javax.swing.plaf.FontUIResource;&lt;br /&gt;
&lt;br /&gt;
//&lt;br /&gt;
// FontChooser by Noah w.&lt;br /&gt;
//&lt;br /&gt;
public class NwFontChooserS extends JDialog {&lt;br /&gt;
    String[] styleList = new String[] { &amp;quot;Plain&amp;quot;, &amp;quot;Bold&amp;quot;, &amp;quot;Italic&amp;quot; };&lt;br /&gt;
    String[] sizeList =&lt;br /&gt;
    new String[] {&lt;br /&gt;
        &amp;quot;3&amp;quot;,&lt;br /&gt;
        &amp;quot;4&amp;quot;,&lt;br /&gt;
        &amp;quot;5&amp;quot;,&lt;br /&gt;
        &amp;quot;6&amp;quot;,&lt;br /&gt;
        &amp;quot;7&amp;quot;,&lt;br /&gt;
        &amp;quot;8&amp;quot;,&lt;br /&gt;
        &amp;quot;9&amp;quot;,&lt;br /&gt;
        &amp;quot;10&amp;quot;,&lt;br /&gt;
        &amp;quot;11&amp;quot;,&lt;br /&gt;
        &amp;quot;12&amp;quot;,&lt;br /&gt;
        &amp;quot;13&amp;quot;,&lt;br /&gt;
        &amp;quot;14&amp;quot;,&lt;br /&gt;
        &amp;quot;15&amp;quot;,&lt;br /&gt;
        &amp;quot;16&amp;quot;,&lt;br /&gt;
        &amp;quot;17&amp;quot;,&lt;br /&gt;
        &amp;quot;18&amp;quot;,&lt;br /&gt;
        &amp;quot;19&amp;quot;,&lt;br /&gt;
        &amp;quot;20&amp;quot;,&lt;br /&gt;
        &amp;quot;22&amp;quot;,&lt;br /&gt;
        &amp;quot;24&amp;quot;,&lt;br /&gt;
        &amp;quot;27&amp;quot;,&lt;br /&gt;
        &amp;quot;30&amp;quot;,&lt;br /&gt;
        &amp;quot;34&amp;quot;,&lt;br /&gt;
        &amp;quot;39&amp;quot;,&lt;br /&gt;
        &amp;quot;45&amp;quot;,&lt;br /&gt;
        &amp;quot;51&amp;quot;,&lt;br /&gt;
        &amp;quot;60&amp;quot; };&lt;br /&gt;
        NwList StyleList;&lt;br /&gt;
        NwList FontList;&lt;br /&gt;
        NwList SizeList;&lt;br /&gt;
        static JLabel Sample = new JLabel();&lt;br /&gt;
        boolean ob = false;&lt;br /&gt;
        &lt;br /&gt;
        private NwFontChooserS(Frame parent, boolean modal, Font font) {&lt;br /&gt;
            super(parent, modal);&lt;br /&gt;
            initAll();&lt;br /&gt;
            setTitle(&amp;quot;Font Choosr&amp;quot;);&lt;br /&gt;
            if (font == null)&lt;br /&gt;
                font = Sample.getFont();&lt;br /&gt;
            FontList.setSelectedItem(font.getName());&lt;br /&gt;
            SizeList.setSelectedItem(font.getSize() + &amp;quot;&amp;quot;);&lt;br /&gt;
            StyleList.setSelectedItem(styleList[font.getStyle()]);&lt;br /&gt;
            &lt;br /&gt;
        }&lt;br /&gt;
        public static Font showDialog(Frame parent, String s, Font font) {&lt;br /&gt;
            NwFontChooserS fd = new NwFontChooserS(parent, true, font);&lt;br /&gt;
            if (s != null)&lt;br /&gt;
                fd.setTitle(s);&lt;br /&gt;
            fd.setVisible(true);&lt;br /&gt;
            Font fo = null;&lt;br /&gt;
            if (fd.ob)&lt;br /&gt;
                fo = Sample.getFont();&lt;br /&gt;
            fd.dispose();&lt;br /&gt;
            return (fo);&lt;br /&gt;
        }&lt;br /&gt;
        private void initAll() {&lt;br /&gt;
            getContentPane().setLayout(null);&lt;br /&gt;
            setBounds(50, 50, 450, 450);&lt;br /&gt;
            addLists();&lt;br /&gt;
            addButtons();&lt;br /&gt;
            Sample.setBounds(10, 320, 415, 25);&lt;br /&gt;
            Sample.setForeground(Color.black);&lt;br /&gt;
            getContentPane().add(Sample);&lt;br /&gt;
            addWindowListener(new WindowAdapter() {&lt;br /&gt;
                public void windowClosing(WindowEvent e) {&lt;br /&gt;
                    setVisible(false);&lt;br /&gt;
                }&lt;br /&gt;
            });&lt;br /&gt;
        }&lt;br /&gt;
        private void addLists() {&lt;br /&gt;
            FontList =&lt;br /&gt;
            new NwList(&lt;br /&gt;
            GraphicsEnvironment&lt;br /&gt;
            .getLocalGraphicsEnvironment()&lt;br /&gt;
            .getAvailableFontFamilyNames());&lt;br /&gt;
            StyleList = new NwList(styleList);&lt;br /&gt;
            SizeList = new NwList(sizeList);&lt;br /&gt;
            FontList.setBounds(10, 10, 260, 295);&lt;br /&gt;
            StyleList.setBounds(280, 10, 80, 295);&lt;br /&gt;
            SizeList.setBounds(370, 10, 40, 295);&lt;br /&gt;
            getContentPane().add(FontList);&lt;br /&gt;
            getContentPane().add(StyleList);&lt;br /&gt;
            getContentPane().add(SizeList);&lt;br /&gt;
        }&lt;br /&gt;
        private void addButtons() {&lt;br /&gt;
            JButton ok = new JButton(&amp;quot;OK&amp;quot;);&lt;br /&gt;
            ok.setMargin(new Insets(0, 0, 0, 0));&lt;br /&gt;
            JButton ca = new JButton(&amp;quot;Cancel&amp;quot;);&lt;br /&gt;
            ca.setMargin(new Insets(0, 0, 0, 0));&lt;br /&gt;
            ok.setBounds(260, 350, 70, 20);&lt;br /&gt;
            ok.setFont(new Font(&amp;quot; &amp;quot;, 1, 11));&lt;br /&gt;
            ca.setBounds(340, 350, 70, 20);&lt;br /&gt;
            ca.setFont(new Font(&amp;quot; &amp;quot;, 1, 12));&lt;br /&gt;
            getContentPane().add(ok);&lt;br /&gt;
            getContentPane().add(ca);&lt;br /&gt;
            ok.addActionListener(new ActionListener() {&lt;br /&gt;
                public void actionPerformed(ActionEvent e) {&lt;br /&gt;
                    setVisible(false);&lt;br /&gt;
                    ob = true;&lt;br /&gt;
                }&lt;br /&gt;
            });&lt;br /&gt;
            ca.addActionListener(new ActionListener() {&lt;br /&gt;
                public void actionPerformed(ActionEvent e) {&lt;br /&gt;
                    setVisible(false);&lt;br /&gt;
                    ob = false;&lt;br /&gt;
                }&lt;br /&gt;
            });&lt;br /&gt;
        }&lt;br /&gt;
        private void showSample() {&lt;br /&gt;
            int g = 0;&lt;br /&gt;
            try {&lt;br /&gt;
                g = Integer.parseInt(SizeList.getSelectedValue());&lt;br /&gt;
            }&lt;br /&gt;
            catch (NumberFormatException nfe) {&lt;br /&gt;
            }&lt;br /&gt;
            String st = StyleList.getSelectedValue();&lt;br /&gt;
            int s = Font.PLAIN;&lt;br /&gt;
            if (st.equalsIgnoreCase(&amp;quot;Bold&amp;quot;))&lt;br /&gt;
                s = Font.BOLD;&lt;br /&gt;
            if (st.equalsIgnoreCase(&amp;quot;Italic&amp;quot;))&lt;br /&gt;
                s = Font.ITALIC;&lt;br /&gt;
            Sample.setFont(new Font(FontList.getSelectedValue(), s, g));&lt;br /&gt;
            Sample.setText(&amp;quot;The quick brown fox jumped over the lazy dog.&amp;quot;);&lt;br /&gt;
        }&lt;br /&gt;
        //////////////////////////////////////////////////////////////////////&lt;br /&gt;
        private class NwList extends JPanel {&lt;br /&gt;
            JList jl;&lt;br /&gt;
            JScrollPane sp;&lt;br /&gt;
            JLabel jt;&lt;br /&gt;
            String si = &amp;quot; &amp;quot;;&lt;br /&gt;
            &lt;br /&gt;
            public NwList(String[] values) {&lt;br /&gt;
                setLayout(null);&lt;br /&gt;
                jl = new JList(values);&lt;br /&gt;
                sp = new JScrollPane(jl);&lt;br /&gt;
                jt = new JLabel();&lt;br /&gt;
                jt.setBackground(Color.white);&lt;br /&gt;
                jt.setForeground(Color.black);&lt;br /&gt;
                jt.setOpaque(true);&lt;br /&gt;
                jt.setBorder(new JTextField().getBorder());&lt;br /&gt;
                jt.setFont(getFont());&lt;br /&gt;
                jl.setBounds(0, 0, 100, 1000);&lt;br /&gt;
                jl.setBackground(Color.white);&lt;br /&gt;
                jl.addListSelectionListener(new ListSelectionListener() {&lt;br /&gt;
                    public void valueChanged(ListSelectionEvent e) {&lt;br /&gt;
                        jt.setText((String) jl.getSelectedValue());&lt;br /&gt;
                        si = (String) jl.getSelectedValue();&lt;br /&gt;
                        showSample();&lt;br /&gt;
                    }&lt;br /&gt;
                });&lt;br /&gt;
                add(sp);&lt;br /&gt;
                add(jt);&lt;br /&gt;
            }&lt;br /&gt;
            public String getSelectedValue() {&lt;br /&gt;
                return (si);&lt;br /&gt;
            }&lt;br /&gt;
            public void setSelectedItem(String s) {&lt;br /&gt;
                jl.setSelectedValue(s, true);&lt;br /&gt;
            }&lt;br /&gt;
            public void setBounds(int x, int y, int w, int h) {&lt;br /&gt;
                super.setBounds(x, y, w, h);&lt;br /&gt;
                sp.setBounds(0, y + 12, w, h - 23);&lt;br /&gt;
                sp.revalidate();&lt;br /&gt;
                jt.setBounds(0, 0, w, 20);&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
        &lt;br /&gt;
        static public String fontString(Font font) {&lt;br /&gt;
            String fs = font.getFamily();&lt;br /&gt;
            if( !font.isPlain() ) {&lt;br /&gt;
                fs += &amp;quot;-&amp;quot;;&lt;br /&gt;
                if( font.isBold()) {&lt;br /&gt;
                    fs += &amp;quot;BOLD&amp;quot;;&lt;br /&gt;
                }&lt;br /&gt;
                if( font.isItalic()) {&lt;br /&gt;
                    fs += &amp;quot;ITALIC&amp;quot;;&lt;br /&gt;
                }&lt;br /&gt;
            }&lt;br /&gt;
            fs += &amp;quot;-&amp;quot; + font.getSize();&lt;br /&gt;
            return(fs);&lt;br /&gt;
        }&lt;br /&gt;
        &lt;br /&gt;
        static public void setDefaultFont(Font f ) {&lt;br /&gt;
            FontUIResource fui = new FontUIResource(f);&lt;br /&gt;
            Enumeration&amp;lt;Object&amp;gt; keys = UIManager.getDefaults().keys();&lt;br /&gt;
            while (keys.hasMoreElements()) {&lt;br /&gt;
                Object key = keys.nextElement();&lt;br /&gt;
                Object value = UIManager.get(key);&lt;br /&gt;
                if (value instanceof FontUIResource)&lt;br /&gt;
                    UIManager.put(key, fui);&lt;br /&gt;
            }&lt;br /&gt;
            &lt;br /&gt;
        }&lt;br /&gt;
        &lt;br /&gt;
        public static void main(String args[]) {&lt;br /&gt;
            Font font = null;&lt;br /&gt;
            font = NwFontChooserS.showDialog(null, null, null);&lt;br /&gt;
            &lt;br /&gt;
            System.out.println(fontString(font));&lt;br /&gt;
        }&lt;br /&gt;
}&lt;br /&gt;
   &lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Font Chooser extends javax.swing.JDialog ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
/*&lt;br /&gt;
Atlantida is an open source (GPL) multilingual dictionary written in Java.&lt;br /&gt;
It can translate words from one language to another and pronounce them.&lt;br /&gt;
Copyright (C) 2006 Sergey S. http://atla.revdanica.ru/&lt;br /&gt;
This program is free software; you can redistribute it and/or&lt;br /&gt;
modify it under the terms of the GNU General Public License&lt;br /&gt;
as published by the Free Software Foundation; either version 2&lt;br /&gt;
of the License, or (at your option) any later version.&lt;br /&gt;
This program is distributed in the hope that it will be useful,&lt;br /&gt;
but WITHOUT ANY WARRANTY; without even the implied warranty of&lt;br /&gt;
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the&lt;br /&gt;
GNU General Public License for more details.&lt;br /&gt;
You should have received a copy of the GNU General Public License&lt;br /&gt;
along with this program; if not, write to the Free Software&lt;br /&gt;
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.&lt;br /&gt;
*/&lt;br /&gt;
/**&lt;br /&gt;
* FontChooser&lt;br /&gt;
* @author Janos Szatmary, Sergei S.&lt;br /&gt;
* @version 003&lt;br /&gt;
*/&lt;br /&gt;
/*&lt;br /&gt;
 * http://forum.java.sun.ru/thread.jsp?forum=57&amp;amp;thread=124810&lt;br /&gt;
 * For those who asked where&amp;quot;s the constructor, have in mind that the constructor provided&lt;br /&gt;
 * is private. As the author of the code says, the use of this class is as&lt;br /&gt;
 * follows (supposing we are in a Frame class):&lt;br /&gt;
 * FontChooser.showDialog(this,&amp;quot;FontChooser&amp;quot;,new Font(&amp;quot;Dialog&amp;quot;, 0, 12));&lt;br /&gt;
 * This file originally writter by Janos Szatmary, then modifyed by Sergei S. for&lt;br /&gt;
 * Atlantida Multilingual Dictionary http://atla.sf.net&lt;br /&gt;
*/&lt;br /&gt;
&lt;br /&gt;
import java.awt.*;&lt;br /&gt;
import java.awt.event.*;&lt;br /&gt;
import java.util.*;&lt;br /&gt;
import javax.swing.*;&lt;br /&gt;
&lt;br /&gt;
public class FontChooser extends javax.swing.JDialog&lt;br /&gt;
{&lt;br /&gt;
  String[] styleList = new String[]&lt;br /&gt;
  { &amp;quot;Plain&amp;quot;,&amp;quot;Bold&amp;quot;,&amp;quot;Italic&amp;quot;};&lt;br /&gt;
  String[] sizeList = new String[]&lt;br /&gt;
  { &amp;quot;2&amp;quot;,&amp;quot;4&amp;quot;,&amp;quot;6&amp;quot;,&amp;quot;8&amp;quot;,&amp;quot;10&amp;quot;,&amp;quot;12&amp;quot;,&amp;quot;14&amp;quot;,&amp;quot;16&amp;quot;,&amp;quot;18&amp;quot;,&amp;quot;20&amp;quot;,&amp;quot;22&amp;quot;,&amp;quot;24&amp;quot;,&amp;quot;30&amp;quot;,&amp;quot;36&amp;quot;,&amp;quot;48&amp;quot;,&amp;quot;72&amp;quot;};&lt;br /&gt;
  String currentFont = null;&lt;br /&gt;
  int currentStyle = -1;&lt;br /&gt;
  int currentSize = -1;&lt;br /&gt;
  public boolean ok = false;&lt;br /&gt;
  /* ------------------------------------------------------------- */&lt;br /&gt;
  private FontChooser(java.awt.Frame parent,boolean modal)&lt;br /&gt;
  {&lt;br /&gt;
    super (parent,modal);&lt;br /&gt;
    initComponents();&lt;br /&gt;
    setListValues(jFontList,GraphicsEnvironment.getLocalGraphicsEnvironment().getAvailableFontFamilyNames());&lt;br /&gt;
    setListValues(jStyleList,styleList);&lt;br /&gt;
    setListValues(jSizeList,sizeList);&lt;br /&gt;
    setCurrentFont(jSample.getFont());&lt;br /&gt;
    pack();&lt;br /&gt;
  }&lt;br /&gt;
  private FontChooser(java.awt.Frame parent,boolean modal,Font font)&lt;br /&gt;
  {&lt;br /&gt;
    this(parent,modal);&lt;br /&gt;
    setCurrentFont(font);&lt;br /&gt;
  }&lt;br /&gt;
  /* ------------------------------------------------------------- */&lt;br /&gt;
  private void setListValues(JList list,String[] values)&lt;br /&gt;
  {&lt;br /&gt;
    if(list.getModel() instanceof DefaultListModel)&lt;br /&gt;
    {&lt;br /&gt;
      DefaultListModel model = (DefaultListModel)&lt;br /&gt;
                               list.getModel();&lt;br /&gt;
      model.removeAllElements();&lt;br /&gt;
      for( String value : values )&lt;br /&gt;
      {&lt;br /&gt;
        model.addElement( value );&lt;br /&gt;
      }&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
  /* ------------------------------------------------------------- */&lt;br /&gt;
  private void setSampleFont()&lt;br /&gt;
  {&lt;br /&gt;
    if(currentFont != null &amp;amp;&amp;amp; currentStyle &amp;gt;= 0 &amp;amp;&amp;amp; currentSize &amp;gt; 0)&lt;br /&gt;
    {&lt;br /&gt;
      jSample.setFont(new Font&lt;br /&gt;
                      (currentFont,currentStyle,currentSize));&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
  private String styleToString(int style)&lt;br /&gt;
  {&lt;br /&gt;
    String str = &amp;quot;&amp;quot;;&lt;br /&gt;
    if((style&amp;amp;Font.BOLD) == Font.BOLD)&lt;br /&gt;
    {&lt;br /&gt;
      if(str.length() &amp;gt; 0)&lt;br /&gt;
      {&lt;br /&gt;
        str += &amp;quot;,&amp;quot;;&lt;br /&gt;
      }&lt;br /&gt;
      str += &amp;quot;Bold&amp;quot;;&lt;br /&gt;
    }&lt;br /&gt;
    if((style&amp;amp;Font.ITALIC) == Font.ITALIC)&lt;br /&gt;
    {&lt;br /&gt;
      if(str.length() &amp;gt; 0)&lt;br /&gt;
      {&lt;br /&gt;
        str += &amp;quot;,&amp;quot;;&lt;br /&gt;
      }&lt;br /&gt;
      str += &amp;quot;Italic&amp;quot;;&lt;br /&gt;
    }&lt;br /&gt;
    if( str.length() &amp;lt;= 0 )&lt;br /&gt;
    {&lt;br /&gt;
      str = &amp;quot;Plain&amp;quot;;&lt;br /&gt;
    }&lt;br /&gt;
    return str;&lt;br /&gt;
  }&lt;br /&gt;
  /* ------------------------------------------------------------- */&lt;br /&gt;
  public Font getCurrentFont()&lt;br /&gt;
  {&lt;br /&gt;
    return jSample.getFont();&lt;br /&gt;
  }&lt;br /&gt;
  /* ------------------------------------------------------------- */&lt;br /&gt;
  public void setCurrentFont(Font font)&lt;br /&gt;
  {&lt;br /&gt;
    if(font==null)&lt;br /&gt;
    {&lt;br /&gt;
      font = jSample.getFont();&lt;br /&gt;
    }&lt;br /&gt;
    jFont.setText(font.getName());&lt;br /&gt;
    jFontActionPerformed(null);&lt;br /&gt;
    jStyle.setText(styleToString(font.getStyle()));&lt;br /&gt;
    jStyleActionPerformed(null);&lt;br /&gt;
    jSize.setText(Integer.toString(font.getSize()));&lt;br /&gt;
    jSizeActionPerformed(null);&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  // Create font chooser dialog.&lt;br /&gt;
  // If user selected a font (i.e. clicked OK button) - return the font that user has selected.&lt;br /&gt;
  // If user didn&amp;quot;t click OK button - return &amp;quot;null&amp;quot;.&lt;br /&gt;
  public static Font showDialog( Frame parent, String title, Font font)&lt;br /&gt;
  {&lt;br /&gt;
    FontChooser dialog = new FontChooser(parent,true,font);&lt;br /&gt;
    Point p1 = parent.getLocation();&lt;br /&gt;
    Dimension d1 = parent.getSize();&lt;br /&gt;
    Dimension d2 = dialog.getSize();&lt;br /&gt;
    int x = p1.x+(d1.width-d2.width)/2;&lt;br /&gt;
    int y = p1.y+(d1.height-d2.height)/2;&lt;br /&gt;
    if(x &amp;lt; 0)&lt;br /&gt;
    {&lt;br /&gt;
      x = 0;&lt;br /&gt;
    }&lt;br /&gt;
    if(y &amp;lt; 0)&lt;br /&gt;
    {&lt;br /&gt;
      y = 0;&lt;br /&gt;
    }&lt;br /&gt;
    if(title!=null)&lt;br /&gt;
    {&lt;br /&gt;
      dialog.setTitle(title);&lt;br /&gt;
    }&lt;br /&gt;
    dialog.setLocation(x,y);&lt;br /&gt;
    dialog.setVisible(true);&lt;br /&gt;
    Font newfont = null;&lt;br /&gt;
    if(dialog.ok)&lt;br /&gt;
    {&lt;br /&gt;
      newfont = dialog.getCurrentFont();&lt;br /&gt;
    }&lt;br /&gt;
    dialog.dispose();&lt;br /&gt;
    return newfont;&lt;br /&gt;
  }&lt;br /&gt;
  /** This method is called from within the constructor to&lt;br /&gt;
  * initialize the form.&lt;br /&gt;
  * WARNING: Do NOT modify this code. The content of this method is&lt;br /&gt;
  * always regenerated by the FormEditor.&lt;br /&gt;
  */&lt;br /&gt;
  private void initComponents()&lt;br /&gt;
  {&lt;br /&gt;
    jPanel3 = new javax.swing.JPanel();&lt;br /&gt;
    jFont = new javax.swing.JTextField();&lt;br /&gt;
    jScrollPane1 = new javax.swing.JScrollPane();&lt;br /&gt;
    jFontList = new javax.swing.JList();&lt;br /&gt;
    jPanel4 = new javax.swing.JPanel();&lt;br /&gt;
    jStyle = new javax.swing.JTextField();&lt;br /&gt;
    jScrollPane2 = new javax.swing.JScrollPane();&lt;br /&gt;
    jStyleList = new javax.swing.JList();&lt;br /&gt;
    jPanel5 = new javax.swing.JPanel();&lt;br /&gt;
    jSize = new javax.swing.JTextField();&lt;br /&gt;
    jScrollPane3 = new javax.swing.JScrollPane();&lt;br /&gt;
    jSizeList = new javax.swing.JList();&lt;br /&gt;
    jPanel1 = new javax.swing.JPanel();&lt;br /&gt;
    jScrollPane4 = new javax.swing.JScrollPane();&lt;br /&gt;
    jSample = new javax.swing.JTextArea();&lt;br /&gt;
    jButtons = new javax.swing.JPanel();&lt;br /&gt;
    jOk = new javax.swing.JButton();&lt;br /&gt;
    jCancel = new javax.swing.JButton();&lt;br /&gt;
    jLabel6 = new javax.swing.JLabel();&lt;br /&gt;
    getContentPane().setLayout(new java.awt.GridBagLayout());&lt;br /&gt;
    java.awt.GridBagConstraints gridBagConstraints1;&lt;br /&gt;
    setTitle(&amp;quot;Font Chooser&amp;quot;);&lt;br /&gt;
    addWindowListener(new java.awt.event.WindowAdapter()&lt;br /&gt;
                      {&lt;br /&gt;
                        public void windowClosing(java.awt.event.WindowEvent evt)&lt;br /&gt;
                        {&lt;br /&gt;
                          closeDialog(evt);&lt;br /&gt;
                        }&lt;br /&gt;
                      }&lt;br /&gt;
                     );&lt;br /&gt;
    jPanel3.setLayout(new java.awt.GridBagLayout());&lt;br /&gt;
    java.awt.GridBagConstraints gridBagConstraints2;&lt;br /&gt;
    jPanel3.setBorder(new javax.swing.border.TitledBorder(new javax.swing.border.EtchedBorder(), &amp;quot; Font &amp;quot;));&lt;br /&gt;
    jFont.setColumns(24);&lt;br /&gt;
    jFont.addActionListener(new java.awt.event.ActionListener()&lt;br /&gt;
                            {&lt;br /&gt;
                              public void actionPerformed(java.awt.event.ActionEvent evt)&lt;br /&gt;
                              {&lt;br /&gt;
                                jFontActionPerformed(evt);&lt;br /&gt;
                              }&lt;br /&gt;
                            }&lt;br /&gt;
                           );&lt;br /&gt;
    gridBagConstraints2 = new java.awt.GridBagConstraints();&lt;br /&gt;
    gridBagConstraints2.gridwidth = 0;&lt;br /&gt;
    gridBagConstraints2.fill =&lt;br /&gt;
    java.awt.GridBagConstraints.HORIZONTAL;&lt;br /&gt;
    gridBagConstraints2.insets = new java.awt.Insets(0, 3, 0, 3);&lt;br /&gt;
    gridBagConstraints2.anchor = java.awt.GridBagConstraints.NORTHWEST;&lt;br /&gt;
    gridBagConstraints2.weightx = 1.0;&lt;br /&gt;
    jPanel3.add(jFont, gridBagConstraints2);&lt;br /&gt;
&lt;br /&gt;
    jFontList.setModel(new DefaultListModel());&lt;br /&gt;
    jFontList.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);&lt;br /&gt;
    jFontList.addListSelectionListener(new javax.swing.event.ListSelectionListener()&lt;br /&gt;
                                       {&lt;br /&gt;
                                         public void valueChanged(javax.swing.event.ListSelectionEvent evt)&lt;br /&gt;
                                         {&lt;br /&gt;
                                           jFontListValueChanged(evt);&lt;br /&gt;
                                         }&lt;br /&gt;
                                       }&lt;br /&gt;
                                      );&lt;br /&gt;
    jScrollPane1.setViewportView(jFontList);&lt;br /&gt;
    gridBagConstraints2 = new java.awt.GridBagConstraints();&lt;br /&gt;
    gridBagConstraints2.fill = java.awt.GridBagConstraints.BOTH;&lt;br /&gt;
    gridBagConstraints2.insets = new java.awt.Insets(3, 3, 3, 3);&lt;br /&gt;
    gridBagConstraints2.anchor = java.awt.GridBagConstraints.NORTHWEST;&lt;br /&gt;
    gridBagConstraints2.weightx = 1.0;&lt;br /&gt;
    gridBagConstraints2.weighty = 1.0;&lt;br /&gt;
    jPanel3.add(jScrollPane1, gridBagConstraints2);&lt;br /&gt;
&lt;br /&gt;
    gridBagConstraints1 = new java.awt.GridBagConstraints();&lt;br /&gt;
    gridBagConstraints1.fill = java.awt.GridBagConstraints.BOTH;&lt;br /&gt;
    gridBagConstraints1.insets = new java.awt.Insets(5, 5, 0, 0);&lt;br /&gt;
    gridBagConstraints1.weightx = 0.5;&lt;br /&gt;
    gridBagConstraints1.weighty = 1.0;&lt;br /&gt;
    getContentPane().add(jPanel3, gridBagConstraints1);&lt;br /&gt;
&lt;br /&gt;
    jPanel4.setLayout(new java.awt.GridBagLayout());&lt;br /&gt;
    java.awt.GridBagConstraints gridBagConstraints3;&lt;br /&gt;
    jPanel4.setBorder(new javax.swing.border.TitledBorder(new javax.swing.border.EtchedBorder(), &amp;quot; Style &amp;quot;));&lt;br /&gt;
    jStyle.setColumns(18);&lt;br /&gt;
    jStyle.addActionListener(new java.awt.event.ActionListener()&lt;br /&gt;
                             {&lt;br /&gt;
                               public void actionPerformed(java.awt.event.ActionEvent evt)&lt;br /&gt;
                               {&lt;br /&gt;
                                 jStyleActionPerformed(evt);&lt;br /&gt;
                               }&lt;br /&gt;
                             }&lt;br /&gt;
                            );&lt;br /&gt;
    gridBagConstraints3 = new java.awt.GridBagConstraints();&lt;br /&gt;
    gridBagConstraints3.gridwidth = 0;&lt;br /&gt;
    gridBagConstraints3.fill =&lt;br /&gt;
    java.awt.GridBagConstraints.HORIZONTAL;&lt;br /&gt;
    gridBagConstraints3.insets = new java.awt.Insets(0, 3, 0, 3);&lt;br /&gt;
    gridBagConstraints3.anchor = java.awt.GridBagConstraints.NORTHWEST;&lt;br /&gt;
    gridBagConstraints3.weightx = 1.0;&lt;br /&gt;
    jPanel4.add(jStyle, gridBagConstraints3);&lt;br /&gt;
    jStyleList.setModel(new DefaultListModel());&lt;br /&gt;
    jStyleList.setVisibleRowCount(4);&lt;br /&gt;
    jStyleList.addListSelectionListener(new javax.swing.event.ListSelectionListener()&lt;br /&gt;
                                        {&lt;br /&gt;
                                          public void valueChanged(javax.swing.event.ListSelectionEvent evt)&lt;br /&gt;
                                          {&lt;br /&gt;
                                            jStyleListValueChanged(evt);&lt;br /&gt;
                                          }&lt;br /&gt;
                                        }&lt;br /&gt;
                                       );&lt;br /&gt;
    jScrollPane2.setViewportView(jStyleList);&lt;br /&gt;
    gridBagConstraints3 = new java.awt.GridBagConstraints();&lt;br /&gt;
    gridBagConstraints3.fill = java.awt.GridBagConstraints.BOTH;&lt;br /&gt;
    gridBagConstraints3.insets = new java.awt.Insets(3, 3, 3, 3);&lt;br /&gt;
    gridBagConstraints3.anchor = java.awt.GridBagConstraints.NORTHWEST;&lt;br /&gt;
    gridBagConstraints3.weightx = 0.5;&lt;br /&gt;
    gridBagConstraints3.weighty = 1.0;&lt;br /&gt;
    jPanel4.add(jScrollPane2, gridBagConstraints3);&lt;br /&gt;
    gridBagConstraints1 = new java.awt.GridBagConstraints();&lt;br /&gt;
    gridBagConstraints1.fill = java.awt.GridBagConstraints.BOTH;&lt;br /&gt;
    gridBagConstraints1.insets = new java.awt.Insets(5, 5, 0, 0);&lt;br /&gt;
    gridBagConstraints1.weightx = 0.375;&lt;br /&gt;
    gridBagConstraints1.weighty = 1.0;&lt;br /&gt;
    getContentPane().add(jPanel4, gridBagConstraints1);&lt;br /&gt;
    jPanel5.setLayout(new java.awt.GridBagLayout());&lt;br /&gt;
    java.awt.GridBagConstraints gridBagConstraints4;&lt;br /&gt;
    jPanel5.setBorder(new javax.swing.border.TitledBorder(new javax.swing.border.EtchedBorder(), &amp;quot; Size &amp;quot;));&lt;br /&gt;
    jSize.setColumns(6);&lt;br /&gt;
    jSize.addActionListener(new&lt;br /&gt;
                            java.awt.event.ActionListener()&lt;br /&gt;
                            {&lt;br /&gt;
                              public void actionPerformed(java.awt.event.ActionEvent evt)&lt;br /&gt;
                              {&lt;br /&gt;
                                jSizeActionPerformed(evt);&lt;br /&gt;
                              }&lt;br /&gt;
                            }&lt;br /&gt;
                           );&lt;br /&gt;
    gridBagConstraints4 = new java.awt.GridBagConstraints();&lt;br /&gt;
    gridBagConstraints4.gridwidth = 0;&lt;br /&gt;
    gridBagConstraints4.fill = java.awt.GridBagConstraints.HORIZONTAL;&lt;br /&gt;
    gridBagConstraints4.insets = new java.awt.Insets(0, 3, 0, 3);&lt;br /&gt;
    gridBagConstraints4.anchor = java.awt.GridBagConstraints.NORTHWEST;&lt;br /&gt;
    gridBagConstraints4.weightx = 1.0;&lt;br /&gt;
    jPanel5.add(jSize, gridBagConstraints4);&lt;br /&gt;
    jSizeList.setModel(new DefaultListModel());&lt;br /&gt;
    jSizeList.setVisibleRowCount(4);&lt;br /&gt;
    jSizeList.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);&lt;br /&gt;
    jSizeList.addListSelectionListener(new javax.swing.event.ListSelectionListener()&lt;br /&gt;
                                       {&lt;br /&gt;
                                         public void valueChanged(javax.swing.event.ListSelectionEvent evt)&lt;br /&gt;
                                         {&lt;br /&gt;
                                           jSizeListValueChanged(evt);&lt;br /&gt;
                                         }&lt;br /&gt;
                                       }&lt;br /&gt;
                                      );&lt;br /&gt;
    jScrollPane3.setViewportView(jSizeList);&lt;br /&gt;
    gridBagConstraints4 = new java.awt.GridBagConstraints();&lt;br /&gt;
    gridBagConstraints4.fill = java.awt.GridBagConstraints.BOTH;&lt;br /&gt;
    gridBagConstraints4.insets = new java.awt.Insets(3, 3, 3, 3);&lt;br /&gt;
    gridBagConstraints4.anchor = java.awt.GridBagConstraints.NORTHWEST;&lt;br /&gt;
    gridBagConstraints4.weightx = 0.25;&lt;br /&gt;
    gridBagConstraints4.weighty = 1.0;&lt;br /&gt;
    jPanel5.add(jScrollPane3, gridBagConstraints4);&lt;br /&gt;
    gridBagConstraints1 = new java.awt.GridBagConstraints();&lt;br /&gt;
    gridBagConstraints1.gridwidth = 0;&lt;br /&gt;
    gridBagConstraints1.fill = java.awt.GridBagConstraints.BOTH;&lt;br /&gt;
    gridBagConstraints1.insets = new java.awt.Insets(5, 5, 0, 5);&lt;br /&gt;
    gridBagConstraints1.weightx = 0.125;&lt;br /&gt;
    gridBagConstraints1.weighty = 1.0;&lt;br /&gt;
    getContentPane().add(jPanel5, gridBagConstraints1);&lt;br /&gt;
    jPanel1.setLayout(new java.awt.GridBagLayout());&lt;br /&gt;
    java.awt.GridBagConstraints gridBagConstraints5;&lt;br /&gt;
    jPanel1.setBorder(new javax.swing.border.TitledBorder(new javax.swing.border.EtchedBorder(), &amp;quot; Sample &amp;quot;));&lt;br /&gt;
    jSample.setWrapStyleWord(true);&lt;br /&gt;
    jSample.setLineWrap(true);&lt;br /&gt;
    jSample.setColumns(20);&lt;br /&gt;
    jSample.setRows(3);&lt;br /&gt;
    jSample.setText(&amp;quot;The quick brown fox jumped over the lazy dog.&amp;quot;);&lt;br /&gt;
    jScrollPane4.setViewportView(jSample);&lt;br /&gt;
    gridBagConstraints5 = new java.awt.GridBagConstraints();&lt;br /&gt;
    gridBagConstraints5.fill = java.awt.GridBagConstraints.BOTH;&lt;br /&gt;
    gridBagConstraints5.insets = new java.awt.Insets(0, 3, 3, 3);&lt;br /&gt;
    gridBagConstraints5.weightx = 1.0;&lt;br /&gt;
    gridBagConstraints5.weighty = 1.0;&lt;br /&gt;
    jPanel1.add(jScrollPane4, gridBagConstraints5);&lt;br /&gt;
    gridBagConstraints1 = new java.awt.GridBagConstraints();&lt;br /&gt;
    gridBagConstraints1.gridwidth = 0;&lt;br /&gt;
    gridBagConstraints1.fill = java.awt.GridBagConstraints.BOTH;&lt;br /&gt;
    gridBagConstraints1.insets = new java.awt.Insets(0, 5, 0, 5);&lt;br /&gt;
    gridBagConstraints1.anchor = java.awt.GridBagConstraints.NORTHWEST;&lt;br /&gt;
    gridBagConstraints1.weightx = 1.0;&lt;br /&gt;
    getContentPane().add(jPanel1, gridBagConstraints1);&lt;br /&gt;
    jButtons.setLayout(new java.awt.GridBagLayout());&lt;br /&gt;
    java.awt.GridBagConstraints gridBagConstraints6;&lt;br /&gt;
    jOk.setMnemonic(KeyEvent.VK_O);&lt;br /&gt;
    jOk.setText(&amp;quot;OK&amp;quot;);&lt;br /&gt;
    jOk.setRequestFocusEnabled(false);&lt;br /&gt;
    jOk.addActionListener(new java.awt.event.ActionListener()&lt;br /&gt;
                          {&lt;br /&gt;
                            public void actionPerformed(java.awt.event.ActionEvent evt)&lt;br /&gt;
                            {&lt;br /&gt;
                              jOkActionPerformed(evt);&lt;br /&gt;
                            }&lt;br /&gt;
                          }&lt;br /&gt;
                         );&lt;br /&gt;
    gridBagConstraints6 = new java.awt.GridBagConstraints();&lt;br /&gt;
    gridBagConstraints6.insets = new java.awt.Insets(5, 5, 5, 0);&lt;br /&gt;
    gridBagConstraints6.anchor = java.awt.GridBagConstraints.WEST;&lt;br /&gt;
    jButtons.add(jOk, gridBagConstraints6);&lt;br /&gt;
&lt;br /&gt;
    jCancel.setMnemonic(KeyEvent.VK_C);&lt;br /&gt;
    jCancel.setText(&amp;quot;Cancel&amp;quot;);&lt;br /&gt;
    jCancel.setRequestFocusEnabled(false);&lt;br /&gt;
    jCancel.addActionListener(new&lt;br /&gt;
                              java.awt.event.ActionListener()&lt;br /&gt;
                              {&lt;br /&gt;
                                public void actionPerformed(java.awt.event.ActionEvent evt)&lt;br /&gt;
                                {&lt;br /&gt;
                                  jCancelActionPerformed(evt);&lt;br /&gt;
                                }&lt;br /&gt;
                              }&lt;br /&gt;
                             );&lt;br /&gt;
    gridBagConstraints6 = new java.awt.GridBagConstraints();&lt;br /&gt;
    gridBagConstraints6.gridwidth = 0;&lt;br /&gt;
    gridBagConstraints6.insets = new java.awt.Insets(5, 5, 5, 5);&lt;br /&gt;
    gridBagConstraints6.anchor = java.awt.GridBagConstraints.WEST;&lt;br /&gt;
    gridBagConstraints6.weightx = 1.0;&lt;br /&gt;
    jButtons.add(jCancel, gridBagConstraints6);&lt;br /&gt;
    gridBagConstraints6 = new java.awt.GridBagConstraints();&lt;br /&gt;
    gridBagConstraints6.weightx = 1.0;&lt;br /&gt;
    jButtons.add(jLabel6, gridBagConstraints6);&lt;br /&gt;
    gridBagConstraints1 = new java.awt.GridBagConstraints();&lt;br /&gt;
    gridBagConstraints1.gridwidth = 0;&lt;br /&gt;
    gridBagConstraints1.anchor = java.awt.GridBagConstraints.SOUTHWEST;&lt;br /&gt;
    gridBagConstraints1.weightx = 1.0;&lt;br /&gt;
    getContentPane().add(jButtons, gridBagConstraints1);&lt;br /&gt;
  }&lt;br /&gt;
  private void jCancelActionPerformed(java.awt.event.ActionEvent evt)&lt;br /&gt;
  {&lt;br /&gt;
    // Add your handling code here:&lt;br /&gt;
    setVisible(false);&lt;br /&gt;
  }&lt;br /&gt;
  private void jOkActionPerformed (java.awt.event.ActionEvent evt)&lt;br /&gt;
  {&lt;br /&gt;
    // Add your handling code here:&lt;br /&gt;
    ok = true;&lt;br /&gt;
    setVisible(false);&lt;br /&gt;
  }&lt;br /&gt;
  private void jSizeActionPerformed (java.awt.event.ActionEvent evt)&lt;br /&gt;
  {&lt;br /&gt;
    // Add your handling code here:&lt;br /&gt;
    int size = Integer.parseInt(jSize.getText());&lt;br /&gt;
    if(size &amp;gt; 0)&lt;br /&gt;
    {&lt;br /&gt;
      currentSize = size;&lt;br /&gt;
      setSampleFont();&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
  private void jStyleActionPerformed (java.awt.event.ActionEvent evt)&lt;br /&gt;
  {&lt;br /&gt;
    // Add your handling code here:&lt;br /&gt;
    StringTokenizer st = new StringTokenizer(jStyle.getText(),&amp;quot;,&amp;quot;);&lt;br /&gt;
    int style = 0;&lt;br /&gt;
    while(st.hasMoreTokens())&lt;br /&gt;
    {&lt;br /&gt;
      String str = st.nextToken().trim();&lt;br /&gt;
      if(str.equalsIgnoreCase(&amp;quot;Plain&amp;quot;))&lt;br /&gt;
      {&lt;br /&gt;
        style |= Font.PLAIN;&lt;br /&gt;
      }&lt;br /&gt;
      else&lt;br /&gt;
        if(str.equalsIgnoreCase(&amp;quot;Bold&amp;quot;))&lt;br /&gt;
      {&lt;br /&gt;
        style |= Font.BOLD;&lt;br /&gt;
      }&lt;br /&gt;
      else&lt;br /&gt;
        if(str.equalsIgnoreCase(&amp;quot;Italic&amp;quot;))&lt;br /&gt;
      {&lt;br /&gt;
        style |= Font.ITALIC;&lt;br /&gt;
      }&lt;br /&gt;
    }&lt;br /&gt;
    if(style &amp;gt;= 0)&lt;br /&gt;
    {&lt;br /&gt;
      currentStyle = style;&lt;br /&gt;
      setSampleFont();&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
  private void jFontActionPerformed (java.awt.event.ActionEvent evt)&lt;br /&gt;
  {&lt;br /&gt;
    // Add your handling code here:&lt;br /&gt;
    DefaultListModel model = (DefaultListModel)&lt;br /&gt;
                             jFontList.getModel();&lt;br /&gt;
    if(model.indexOf(jFont.getText()) &amp;gt;= 0)&lt;br /&gt;
    {&lt;br /&gt;
      currentFont = jFont.getText();&lt;br /&gt;
      setSampleFont();&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
  private void jStyleListValueChanged(javax.swing.event.ListSelectionEvent evt)&lt;br /&gt;
  {&lt;br /&gt;
    // Add your handling code here:&lt;br /&gt;
    String str = &amp;quot;&amp;quot;;&lt;br /&gt;
    Object[] values = jStyleList.getSelectedValues();&lt;br /&gt;
    if(values.length &amp;gt; 0)&lt;br /&gt;
    {&lt;br /&gt;
      int j;&lt;br /&gt;
      for(j=0; j &amp;lt; values.length; j++)&lt;br /&gt;
      {&lt;br /&gt;
        String s = (String) values[j];&lt;br /&gt;
        if(s.equalsIgnoreCase(&amp;quot;Plain&amp;quot;))&lt;br /&gt;
        {&lt;br /&gt;
          str = &amp;quot;Plain&amp;quot;;  break;&lt;br /&gt;
        }&lt;br /&gt;
        if(str.length() &amp;gt; 0)&lt;br /&gt;
        {&lt;br /&gt;
          str += &amp;quot;,&amp;quot;;&lt;br /&gt;
        }&lt;br /&gt;
        str += (String) values[j];&lt;br /&gt;
      }&lt;br /&gt;
    }&lt;br /&gt;
    else&lt;br /&gt;
    {&lt;br /&gt;
      str = styleToString(currentStyle);&lt;br /&gt;
    }&lt;br /&gt;
    jStyle.setText(str);&lt;br /&gt;
    jStyleActionPerformed(null);&lt;br /&gt;
  }&lt;br /&gt;
  private void jSizeListValueChanged(javax.swing.event.ListSelectionEvent evt)&lt;br /&gt;
  {&lt;br /&gt;
    // Add your handling code here:&lt;br /&gt;
    String str = (String) jSizeList.getSelectedValue();&lt;br /&gt;
    if(str==null || str.length() &amp;lt;= 0)&lt;br /&gt;
    {&lt;br /&gt;
      str = Integer.toString(currentSize);&lt;br /&gt;
    }&lt;br /&gt;
    jSize.setText(str);&lt;br /&gt;
    jSizeActionPerformed(null);&lt;br /&gt;
  }&lt;br /&gt;
  private void jFontListValueChanged(javax.swing.event.ListSelectionEvent evt)&lt;br /&gt;
  {&lt;br /&gt;
    // Add your handling code here:&lt;br /&gt;
    String str = (String) jFontList.getSelectedValue();&lt;br /&gt;
    if(str==null || str.length() &amp;lt;= 0)&lt;br /&gt;
    {&lt;br /&gt;
      str = currentFont;&lt;br /&gt;
    }&lt;br /&gt;
    jFont.setText(str);&lt;br /&gt;
    jFontActionPerformed(null);&lt;br /&gt;
  }&lt;br /&gt;
  /** Closes the dialog */&lt;br /&gt;
  private void closeDialog(java.awt.event.WindowEvent evt)&lt;br /&gt;
  {&lt;br /&gt;
    setVisible (false);&lt;br /&gt;
  }&lt;br /&gt;
  // Variables declaration - do not modify&lt;br /&gt;
  private javax.swing.JPanel jPanel3;&lt;br /&gt;
  private javax.swing.JTextField jFont;&lt;br /&gt;
  private javax.swing.JScrollPane jScrollPane1;&lt;br /&gt;
  private javax.swing.JList jFontList;&lt;br /&gt;
  private javax.swing.JPanel jPanel4;&lt;br /&gt;
  private javax.swing.JTextField jStyle;&lt;br /&gt;
  private javax.swing.JScrollPane jScrollPane2;&lt;br /&gt;
  private javax.swing.JList jStyleList;&lt;br /&gt;
  private javax.swing.JPanel jPanel5;&lt;br /&gt;
  private javax.swing.JTextField jSize;&lt;br /&gt;
  private javax.swing.JScrollPane jScrollPane3;&lt;br /&gt;
  private javax.swing.JList jSizeList;&lt;br /&gt;
  private javax.swing.JPanel jPanel1;&lt;br /&gt;
  private javax.swing.JScrollPane jScrollPane4;&lt;br /&gt;
  private javax.swing.JTextArea jSample;&lt;br /&gt;
  private javax.swing.JPanel jButtons;&lt;br /&gt;
  private javax.swing.JButton jOk;&lt;br /&gt;
  private javax.swing.JButton jCancel;&lt;br /&gt;
  private javax.swing.JLabel jLabel6;&lt;br /&gt;
  // End of variables declaration&lt;br /&gt;
}&lt;br /&gt;
   &lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Font Chooser Source Code ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Font dialog ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
/* &lt;br /&gt;
 * JCommon : a free general purpose class library for the Java(tm) platform&lt;br /&gt;
 * &lt;br /&gt;
 *&lt;br /&gt;
 * (C) Copyright 2000-2005, by Object Refinery Limited and Contributors.&lt;br /&gt;
 * &lt;br /&gt;
 * Project Info:  http://www.jfree.org/jcommon/index.html&lt;br /&gt;
 *&lt;br /&gt;
 * This library is free software; you can redistribute it and/or modify it &lt;br /&gt;
 * under the terms of the GNU Lesser General Public License as published by &lt;br /&gt;
 * the Free Software Foundation; either version 2.1 of the License, or &lt;br /&gt;
 * (at your option) any later version.&lt;br /&gt;
 *&lt;br /&gt;
 * This library is distributed in the hope that it will be useful, but &lt;br /&gt;
 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY &lt;br /&gt;
 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public &lt;br /&gt;
 * License for more details.&lt;br /&gt;
 *&lt;br /&gt;
 * You should have received a copy of the GNU Lesser General Public&lt;br /&gt;
 * License along with this library; if not, write to the Free Software&lt;br /&gt;
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, &lt;br /&gt;
 * USA.  &lt;br /&gt;
 *&lt;br /&gt;
 * [Java is a trademark or registered trademark of Sun Microsystems, Inc. &lt;br /&gt;
 * in the United States and other countries.]&lt;br /&gt;
 * &lt;br /&gt;
 * ----------------------&lt;br /&gt;
 * FontChooserDialog.java&lt;br /&gt;
 * ----------------------&lt;br /&gt;
 * (C) Copyright 2000-2004, by Object Refinery Limited.&lt;br /&gt;
 *&lt;br /&gt;
 * Original Author:  David Gilbert (for Object Refinery Limited);&lt;br /&gt;
 * Contributor(s):   -;&lt;br /&gt;
 *&lt;br /&gt;
 * $Id: FontChooserDialog.java,v 1.5 2007/11/02 17:50:36 taqua Exp $&lt;br /&gt;
 *&lt;br /&gt;
 * Changes (from 26-Oct-2001)&lt;br /&gt;
 * --------------------------&lt;br /&gt;
 * 26-Oct-2001 : Changed package to com.jrefinery.ui.*;&lt;br /&gt;
 * 14-Oct-2002 : Fixed errors reported by Checkstyle (DG);&lt;br /&gt;
 *&lt;br /&gt;
 */&lt;br /&gt;
import java.awt.BorderLayout;&lt;br /&gt;
import java.awt.Dialog;&lt;br /&gt;
import java.awt.Font;&lt;br /&gt;
import java.awt.Frame;&lt;br /&gt;
import java.awt.GraphicsEnvironment;&lt;br /&gt;
import java.awt.GridLayout;&lt;br /&gt;
import java.awt.event.ActionEvent;&lt;br /&gt;
import java.awt.event.ActionListener;&lt;br /&gt;
import javax.swing.BorderFactory;&lt;br /&gt;
import javax.swing.JButton;&lt;br /&gt;
import javax.swing.JCheckBox;&lt;br /&gt;
import javax.swing.JDialog;&lt;br /&gt;
import javax.swing.JList;&lt;br /&gt;
import javax.swing.JPanel;&lt;br /&gt;
import javax.swing.JScrollPane;&lt;br /&gt;
import javax.swing.JTextField;&lt;br /&gt;
import javax.swing.ListModel;&lt;br /&gt;
/**&lt;br /&gt;
 * A dialog for choosing a font from the available system fonts.&lt;br /&gt;
 *&lt;br /&gt;
 * @author David Gilbert&lt;br /&gt;
 */&lt;br /&gt;
public class FontChooserDialog extends StandardDialog {&lt;br /&gt;
    /** The panel within the dialog that contains the font selection controls. */&lt;br /&gt;
    private FontChooserPanel fontChooserPanel;&lt;br /&gt;
    /**&lt;br /&gt;
     * Standard constructor - builds a font chooser dialog owned by another dialog.&lt;br /&gt;
     *&lt;br /&gt;
     * @param owner  the dialog that &amp;quot;owns&amp;quot; this dialog.&lt;br /&gt;
     * @param title  the title for the dialog.&lt;br /&gt;
     * @param modal  a boolean that indicates whether or not the dialog is modal.&lt;br /&gt;
     * @param font  the initial font displayed.&lt;br /&gt;
     */&lt;br /&gt;
    public FontChooserDialog(final Dialog owner, final String title, final boolean modal, final Font font) {&lt;br /&gt;
        super(owner, title, modal);&lt;br /&gt;
        setContentPane(createContent(font));&lt;br /&gt;
    }&lt;br /&gt;
    /**&lt;br /&gt;
     * Standard constructor - builds a font chooser dialog owned by a frame.&lt;br /&gt;
     *&lt;br /&gt;
     * @param owner  the frame that &amp;quot;owns&amp;quot; this dialog.&lt;br /&gt;
     * @param title  the title for the dialog.&lt;br /&gt;
     * @param modal  a boolean that indicates whether or not the dialog is modal.&lt;br /&gt;
     * @param font  the initial font displayed.&lt;br /&gt;
     */&lt;br /&gt;
    public FontChooserDialog(final Frame owner, final String title, final boolean modal, final Font font) {&lt;br /&gt;
        super(owner, title, modal);&lt;br /&gt;
        setContentPane(createContent(font));&lt;br /&gt;
    }&lt;br /&gt;
    /**&lt;br /&gt;
     * Returns the selected font.&lt;br /&gt;
     *&lt;br /&gt;
     * @return the font.&lt;br /&gt;
     */&lt;br /&gt;
    public Font getSelectedFont() {&lt;br /&gt;
        return this.fontChooserPanel.getSelectedFont();&lt;br /&gt;
    }&lt;br /&gt;
    /**&lt;br /&gt;
     * Returns the panel that is the user interface.&lt;br /&gt;
     *&lt;br /&gt;
     * @param font  the font.&lt;br /&gt;
     *&lt;br /&gt;
     * @return the panel.&lt;br /&gt;
     */&lt;br /&gt;
    private JPanel createContent(Font font) {&lt;br /&gt;
        final JPanel content = new JPanel(new BorderLayout());&lt;br /&gt;
        content.setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4));&lt;br /&gt;
        if (font == null) {&lt;br /&gt;
            font = new Font(&amp;quot;Dialog&amp;quot;, 10, Font.PLAIN);&lt;br /&gt;
        }&lt;br /&gt;
        this.fontChooserPanel = new FontChooserPanel(font);&lt;br /&gt;
        content.add(this.fontChooserPanel);&lt;br /&gt;
        final JPanel buttons = createButtonPanel();&lt;br /&gt;
        buttons.setBorder(BorderFactory.createEmptyBorder(4, 0, 0, 0));&lt;br /&gt;
        content.add(buttons, BorderLayout.SOUTH);&lt;br /&gt;
        return content;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
/* &lt;br /&gt;
 * JCommon : a free general purpose class library for the Java(tm) platform&lt;br /&gt;
 * s&lt;br /&gt;
 *&lt;br /&gt;
 * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors.&lt;br /&gt;
 *&lt;br /&gt;
 * Project Info:  http://www.jfree.org/jcommon/index.html&lt;br /&gt;
 *&lt;br /&gt;
 * This library is free software; you can redistribute it and/or modify it&lt;br /&gt;
 * under the terms of the GNU Lesser General Public License as published by&lt;br /&gt;
 * the Free Software Foundation; either version 2.1 of the License, or&lt;br /&gt;
 * (at your option) any later version.&lt;br /&gt;
 *&lt;br /&gt;
 * This library is distributed in the hope that it will be useful, but&lt;br /&gt;
 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY&lt;br /&gt;
 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public&lt;br /&gt;
 * License for more details.&lt;br /&gt;
 *&lt;br /&gt;
 * You should have received a copy of the GNU Lesser General Public&lt;br /&gt;
 * License along with this library; if not, write to the Free Software&lt;br /&gt;
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301,&lt;br /&gt;
 * USA.&lt;br /&gt;
 *&lt;br /&gt;
 * [Java is a trademark or registered trademark of Sun Microsystems, Inc.&lt;br /&gt;
 * in the United States and other countries.]&lt;br /&gt;
 *&lt;br /&gt;
 * ---------------------&lt;br /&gt;
 * FontChooserPanel.java&lt;br /&gt;
 * ---------------------&lt;br /&gt;
 * (C) Copyright 2000-2008, by Object Refinery Limited.&lt;br /&gt;
 *&lt;br /&gt;
 * Original Author:  David Gilbert (for Object Refinery Limited);&lt;br /&gt;
 * Contributor(s):   Arnaud Lelievre;&lt;br /&gt;
 *&lt;br /&gt;
 * $Id: FontChooserPanel.java,v 1.6 2008/12/18 09:57:32 mungady Exp $&lt;br /&gt;
 *&lt;br /&gt;
 * Changes (from 26-Oct-2001)&lt;br /&gt;
 * --------------------------&lt;br /&gt;
 * 26-Oct-2001 : Changed package to com.jrefinery.ui.*;&lt;br /&gt;
 * 14-Oct-2002 : Fixed errors reported by Checkstyle (DG);&lt;br /&gt;
 * 08-Sep-2003 : Added internationalization via use of properties resourceBundle (RFE 690236) (AL);&lt;br /&gt;
 * 21-Feb-2004 : The FontParameter of the constructor was never used (TM);&lt;br /&gt;
 * 18-Dec-2008 : Use ResourceBundleWrapper - see JFreeChart patch 1607918 by&lt;br /&gt;
 *               Jess Thrysoee (DG);&lt;br /&gt;
 *&lt;br /&gt;
 */&lt;br /&gt;
/**&lt;br /&gt;
 * A panel for choosing a font from the available system fonts - still a bit of&lt;br /&gt;
 * a hack at the moment, but good enough for demonstration applications.&lt;br /&gt;
 *&lt;br /&gt;
 * @author David Gilbert&lt;br /&gt;
 */&lt;br /&gt;
class FontChooserPanel extends JPanel {&lt;br /&gt;
    /** The font sizes that can be selected. */&lt;br /&gt;
    public static final String[] SIZES = {&amp;quot;9&amp;quot;, &amp;quot;10&amp;quot;, &amp;quot;11&amp;quot;, &amp;quot;12&amp;quot;, &amp;quot;14&amp;quot;, &amp;quot;16&amp;quot;,&lt;br /&gt;
            &amp;quot;18&amp;quot;, &amp;quot;20&amp;quot;, &amp;quot;22&amp;quot;, &amp;quot;24&amp;quot;, &amp;quot;28&amp;quot;, &amp;quot;36&amp;quot;, &amp;quot;48&amp;quot;, &amp;quot;72&amp;quot;};&lt;br /&gt;
    /** The list of fonts. */&lt;br /&gt;
    private JList fontlist;&lt;br /&gt;
    /** The list of sizes. */&lt;br /&gt;
    private JList sizelist;&lt;br /&gt;
    /** The checkbox that indicates whether the font is bold. */&lt;br /&gt;
    private JCheckBox bold;&lt;br /&gt;
    /** The checkbox that indicates whether or not the font is italic. */&lt;br /&gt;
    private JCheckBox italic;&lt;br /&gt;
&lt;br /&gt;
    /**&lt;br /&gt;
     * Standard constructor - builds a FontChooserPanel initialised with the&lt;br /&gt;
     * specified font.&lt;br /&gt;
     *&lt;br /&gt;
     * @param font  the initial font to display.&lt;br /&gt;
     */&lt;br /&gt;
    public FontChooserPanel(final Font font) {&lt;br /&gt;
        final GraphicsEnvironment g&lt;br /&gt;
                = GraphicsEnvironment.getLocalGraphicsEnvironment();&lt;br /&gt;
        final String[] fonts = g.getAvailableFontFamilyNames();&lt;br /&gt;
        setLayout(new BorderLayout());&lt;br /&gt;
        final JPanel right = new JPanel(new BorderLayout());&lt;br /&gt;
        final JPanel fontPanel = new JPanel(new BorderLayout());&lt;br /&gt;
        fontPanel.setBorder(BorderFactory.createTitledBorder(&lt;br /&gt;
                            BorderFactory.createEtchedBorder(),&lt;br /&gt;
                            &amp;quot;Font&amp;quot;));&lt;br /&gt;
        this.fontlist = new JList(fonts);&lt;br /&gt;
        final JScrollPane fontpane = new JScrollPane(this.fontlist);&lt;br /&gt;
        fontpane.setBorder(BorderFactory.createEtchedBorder());&lt;br /&gt;
        fontPanel.add(fontpane);&lt;br /&gt;
        add(fontPanel);&lt;br /&gt;
        final JPanel sizePanel = new JPanel(new BorderLayout());&lt;br /&gt;
        sizePanel.setBorder(BorderFactory.createTitledBorder(&lt;br /&gt;
                            BorderFactory.createEtchedBorder(),&lt;br /&gt;
                            &amp;quot;Size&amp;quot;));&lt;br /&gt;
        this.sizelist = new JList(SIZES);&lt;br /&gt;
        final JScrollPane sizepane = new JScrollPane(this.sizelist);&lt;br /&gt;
        sizepane.setBorder(BorderFactory.createEtchedBorder());&lt;br /&gt;
        sizePanel.add(sizepane);&lt;br /&gt;
        final JPanel attributes = new JPanel(new GridLayout(1, 2));&lt;br /&gt;
        this.bold = new JCheckBox(&amp;quot;Bold&amp;quot;);&lt;br /&gt;
        this.italic = new JCheckBox(&amp;quot;Italic&amp;quot;);&lt;br /&gt;
        attributes.add(this.bold);&lt;br /&gt;
        attributes.add(this.italic);&lt;br /&gt;
        attributes.setBorder(BorderFactory.createTitledBorder(&lt;br /&gt;
                BorderFactory.createEtchedBorder(),&lt;br /&gt;
                &amp;quot;Attributes&amp;quot;));&lt;br /&gt;
        right.add(sizePanel, BorderLayout.CENTER);&lt;br /&gt;
        right.add(attributes, BorderLayout.SOUTH);&lt;br /&gt;
        add(right, BorderLayout.EAST);&lt;br /&gt;
        setSelectedFont(font);&lt;br /&gt;
    }&lt;br /&gt;
    /**&lt;br /&gt;
     * Returns a Font object representing the selection in the panel.&lt;br /&gt;
     *&lt;br /&gt;
     * @return the font.&lt;br /&gt;
     */&lt;br /&gt;
    public Font getSelectedFont() {&lt;br /&gt;
        return new Font(getSelectedName(), getSelectedStyle(),&lt;br /&gt;
                getSelectedSize());&lt;br /&gt;
    }&lt;br /&gt;
    /**&lt;br /&gt;
     * Returns the selected name.&lt;br /&gt;
     *&lt;br /&gt;
     * @return the name.&lt;br /&gt;
     */&lt;br /&gt;
    public String getSelectedName() {&lt;br /&gt;
        return (String) this.fontlist.getSelectedValue();&lt;br /&gt;
    }&lt;br /&gt;
    /**&lt;br /&gt;
     * Returns the selected style.&lt;br /&gt;
     *&lt;br /&gt;
     * @return the style.&lt;br /&gt;
     */&lt;br /&gt;
    public int getSelectedStyle() {&lt;br /&gt;
        if (this.bold.isSelected() &amp;amp;&amp;amp; this.italic.isSelected()) {&lt;br /&gt;
            return Font.BOLD + Font.ITALIC;&lt;br /&gt;
        }&lt;br /&gt;
        if (this.bold.isSelected()) {&lt;br /&gt;
            return Font.BOLD;&lt;br /&gt;
        }&lt;br /&gt;
        if (this.italic.isSelected()) {&lt;br /&gt;
            return Font.ITALIC;&lt;br /&gt;
        }&lt;br /&gt;
        else {&lt;br /&gt;
            return Font.PLAIN;&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
    /**&lt;br /&gt;
     * Returns the selected size.&lt;br /&gt;
     *&lt;br /&gt;
     * @return the size.&lt;br /&gt;
     */&lt;br /&gt;
    public int getSelectedSize() {&lt;br /&gt;
        final String selected = (String) this.sizelist.getSelectedValue();&lt;br /&gt;
        if (selected != null) {&lt;br /&gt;
            return Integer.parseInt(selected);&lt;br /&gt;
        }&lt;br /&gt;
        else {&lt;br /&gt;
            return 10;&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
    /**&lt;br /&gt;
     * Initializes the contents of the dialog from the given font&lt;br /&gt;
     * object.&lt;br /&gt;
     *&lt;br /&gt;
     * @param font the font from which to read the properties.&lt;br /&gt;
     */&lt;br /&gt;
    public void setSelectedFont (final Font font) {&lt;br /&gt;
        if (font == null) {&lt;br /&gt;
            throw new NullPointerException();&lt;br /&gt;
        }&lt;br /&gt;
        this.bold.setSelected(font.isBold());&lt;br /&gt;
        this.italic.setSelected(font.isItalic());&lt;br /&gt;
        final String fontName = font.getName();&lt;br /&gt;
        ListModel model = this.fontlist.getModel();&lt;br /&gt;
        this.fontlist.clearSelection();&lt;br /&gt;
        for (int i = 0; i &amp;lt; model.getSize(); i++) {&lt;br /&gt;
            if (fontName.equals(model.getElementAt(i))) {&lt;br /&gt;
                this.fontlist.setSelectedIndex(i);&lt;br /&gt;
                break;&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
        final String fontSize = String.valueOf(font.getSize());&lt;br /&gt;
        model = this.sizelist.getModel();&lt;br /&gt;
        this.sizelist.clearSelection();&lt;br /&gt;
        for (int i = 0; i &amp;lt; model.getSize(); i++) {&lt;br /&gt;
            if (fontSize.equals(model.getElementAt(i))) {&lt;br /&gt;
                this.sizelist.setSelectedIndex(i);&lt;br /&gt;
                break;&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
/* &lt;br /&gt;
 * JCommon : a free general purpose class library for the Java(tm) platform&lt;br /&gt;
 * &lt;br /&gt;
 *&lt;br /&gt;
 * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors.&lt;br /&gt;
 *&lt;br /&gt;
 * Project Info:  http://www.jfree.org/jcommon/index.html&lt;br /&gt;
 *&lt;br /&gt;
 * This library is free software; you can redistribute it and/or modify it&lt;br /&gt;
 * under the terms of the GNU Lesser General Public License as published by&lt;br /&gt;
 * the Free Software Foundation; either version 2.1 of the License, or&lt;br /&gt;
 * (at your option) any later version.&lt;br /&gt;
 *&lt;br /&gt;
 * This library is distributed in the hope that it will be useful, but&lt;br /&gt;
 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY&lt;br /&gt;
 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public&lt;br /&gt;
 * License for more details.&lt;br /&gt;
 *&lt;br /&gt;
 * You should have received a copy of the GNU Lesser General Public&lt;br /&gt;
 * License along with this library; if not, write to the Free Software&lt;br /&gt;
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301,&lt;br /&gt;
 * USA.&lt;br /&gt;
 *&lt;br /&gt;
 * [Java is a trademark or registered trademark of Sun Microsystems, Inc.&lt;br /&gt;
 * in the United States and other countries.]&lt;br /&gt;
 *&lt;br /&gt;
 * -------------------&lt;br /&gt;
 * StandardDialog.java&lt;br /&gt;
 * -------------------&lt;br /&gt;
 * (C) Copyright 2000-2008, by Object Refinery Limited.&lt;br /&gt;
 *&lt;br /&gt;
 * Original Author:  David Gilbert (for Object Refinery Limited);&lt;br /&gt;
 * Contributor(s):   Arnaud Lelievre;&lt;br /&gt;
 *&lt;br /&gt;
 * $Id: StandardDialog.java,v 1.7 2008/12/18 09:57:32 mungady Exp $&lt;br /&gt;
 *&lt;br /&gt;
 * Changes (from 26-Oct-2001)&lt;br /&gt;
 * --------------------------&lt;br /&gt;
 * 26-Oct-2001 : Changed package to com.jrefinery.ui.*;&lt;br /&gt;
 * 08-Sep-2003 : Added internationalization via use of properties&lt;br /&gt;
 *               resourceBundle (RFE 690236) (AL);&lt;br /&gt;
 * 18-Dec-2008 : Use ResourceBundleWrapper - see JFreeChart patch 1607918 by&lt;br /&gt;
 *               Jess Thrysoee (DG);&lt;br /&gt;
 *&lt;br /&gt;
 */&lt;br /&gt;
&lt;br /&gt;
/**&lt;br /&gt;
 * The base class for standard dialogs.&lt;br /&gt;
 *&lt;br /&gt;
 * @author David Gilbert&lt;br /&gt;
 */&lt;br /&gt;
class StandardDialog extends JDialog implements ActionListener {&lt;br /&gt;
    /** Flag that indicates whether or not the dialog was cancelled. */&lt;br /&gt;
    private boolean cancelled;&lt;br /&gt;
&lt;br /&gt;
    /**&lt;br /&gt;
     * Standard constructor - builds a dialog...&lt;br /&gt;
     *&lt;br /&gt;
     * @param owner  the owner.&lt;br /&gt;
     * @param title  the title.&lt;br /&gt;
     * @param modal  modal?&lt;br /&gt;
     */&lt;br /&gt;
    public StandardDialog(final Frame owner, final String title,&lt;br /&gt;
            final boolean modal) {&lt;br /&gt;
        super(owner, title, modal);&lt;br /&gt;
        this.cancelled = false;&lt;br /&gt;
    }&lt;br /&gt;
    /**&lt;br /&gt;
     * Standard constructor - builds a dialog...&lt;br /&gt;
     *&lt;br /&gt;
     * @param owner  the owner.&lt;br /&gt;
     * @param title  the title.&lt;br /&gt;
     * @param modal  modal?&lt;br /&gt;
     */&lt;br /&gt;
    public StandardDialog(final Dialog owner, final String title,&lt;br /&gt;
            final boolean modal) {&lt;br /&gt;
        super(owner, title, modal);&lt;br /&gt;
        this.cancelled = false;&lt;br /&gt;
    }&lt;br /&gt;
    /**&lt;br /&gt;
     * Returns a flag that indicates whether or not the dialog has been&lt;br /&gt;
     * cancelled.&lt;br /&gt;
     *&lt;br /&gt;
     * @return boolean.&lt;br /&gt;
     */&lt;br /&gt;
    public boolean isCancelled() {&lt;br /&gt;
        return this.cancelled;&lt;br /&gt;
    }&lt;br /&gt;
    /**&lt;br /&gt;
     * Handles clicks on the standard buttons.&lt;br /&gt;
     *&lt;br /&gt;
     * @param event  the event.&lt;br /&gt;
     */&lt;br /&gt;
    public void actionPerformed(final ActionEvent event) {&lt;br /&gt;
        final String command = event.getActionCommand();&lt;br /&gt;
        if (command.equals(&amp;quot;helpButton&amp;quot;)) {&lt;br /&gt;
            // display help information&lt;br /&gt;
        }&lt;br /&gt;
        else if (command.equals(&amp;quot;okButton&amp;quot;)) {&lt;br /&gt;
            this.cancelled = false;&lt;br /&gt;
            setVisible(false);&lt;br /&gt;
        }&lt;br /&gt;
        else if (command.equals(&amp;quot;cancelButton&amp;quot;)) {&lt;br /&gt;
            this.cancelled = true;&lt;br /&gt;
            setVisible(false);&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
    /**&lt;br /&gt;
     * Builds and returns the user interface for the dialog.  This method is&lt;br /&gt;
     * shared among the constructors.&lt;br /&gt;
     *&lt;br /&gt;
     * @return the button panel.&lt;br /&gt;
     */&lt;br /&gt;
    protected JPanel createButtonPanel() {&lt;br /&gt;
        final L1R2ButtonPanel buttons = new L1R2ButtonPanel(&lt;br /&gt;
                &amp;quot;Help&amp;quot;,&lt;br /&gt;
                &amp;quot;OK&amp;quot;,&lt;br /&gt;
                &amp;quot;Cancel&amp;quot;);&lt;br /&gt;
        final JButton helpButton = buttons.getLeftButton();&lt;br /&gt;
        helpButton.setActionCommand(&amp;quot;helpButton&amp;quot;);&lt;br /&gt;
        helpButton.addActionListener(this);&lt;br /&gt;
        final JButton okButton = buttons.getRightButton1();&lt;br /&gt;
        okButton.setActionCommand(&amp;quot;okButton&amp;quot;);&lt;br /&gt;
        okButton.addActionListener(this);&lt;br /&gt;
        final JButton cancelButton = buttons.getRightButton2();&lt;br /&gt;
        cancelButton.setActionCommand(&amp;quot;cancelButton&amp;quot;);&lt;br /&gt;
        cancelButton.addActionListener(this);&lt;br /&gt;
        buttons.setBorder(BorderFactory.createEmptyBorder(4, 0, 0, 0));&lt;br /&gt;
        return buttons;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
/* &lt;br /&gt;
 * JCommon : a free general purpose class library for the Java(tm) platform&lt;br /&gt;
 * &lt;br /&gt;
 *&lt;br /&gt;
 * (C) Copyright 2000-2005, by Object Refinery Limited and Contributors.&lt;br /&gt;
 * &lt;br /&gt;
 * Project Info:  http://www.jfree.org/jcommon/index.html&lt;br /&gt;
 *&lt;br /&gt;
 * This library is free software; you can redistribute it and/or modify it &lt;br /&gt;
 * under the terms of the GNU Lesser General Public License as published by &lt;br /&gt;
 * the Free Software Foundation; either version 2.1 of the License, or &lt;br /&gt;
 * (at your option) any later version.&lt;br /&gt;
 *&lt;br /&gt;
 * This library is distributed in the hope that it will be useful, but &lt;br /&gt;
 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY &lt;br /&gt;
 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public &lt;br /&gt;
 * License for more details.&lt;br /&gt;
 *&lt;br /&gt;
 * You should have received a copy of the GNU Lesser General Public&lt;br /&gt;
 * License along with this library; if not, write to the Free Software&lt;br /&gt;
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, &lt;br /&gt;
 * USA.  &lt;br /&gt;
 *&lt;br /&gt;
 * [Java is a trademark or registered trademark of Sun Microsystems, Inc. &lt;br /&gt;
 * in the United States and other countries.]&lt;br /&gt;
 * &lt;br /&gt;
 * --------------------&lt;br /&gt;
 * L1R2ButtonPanel.java&lt;br /&gt;
 * --------------------&lt;br /&gt;
 * (C) Copyright 2000-2004, by Object Refinery Limited.&lt;br /&gt;
 *&lt;br /&gt;
 * Original Author:  David Gilbert (for Object Refinery Limited);&lt;br /&gt;
 * Contributor(s):   -;&lt;br /&gt;
 *&lt;br /&gt;
 * $Id: L1R2ButtonPanel.java,v 1.4 2007/11/02 17:50:36 taqua Exp $&lt;br /&gt;
 *&lt;br /&gt;
 * Changes (from 26-Oct-2001)&lt;br /&gt;
 * --------------------------&lt;br /&gt;
 * 26-Oct-2001 : Changed package to com.jrefinery.ui.*;&lt;br /&gt;
 * 26-Jun-2002 : Removed unnecessary import (DG);&lt;br /&gt;
 * 14-Oct-2002 : Fixed errors reported by Checkstyle (DG);&lt;br /&gt;
 *&lt;br /&gt;
 */&lt;br /&gt;
&lt;br /&gt;
/**&lt;br /&gt;
 * A &amp;quot;ready-made&amp;quot; panel that has one button on the left and two buttons on the right - nested&lt;br /&gt;
 * panels and layout managers take care of resizing.&lt;br /&gt;
 *&lt;br /&gt;
 * @author David Gilbert&lt;br /&gt;
 */&lt;br /&gt;
class L1R2ButtonPanel extends JPanel {&lt;br /&gt;
    /** The left button. */&lt;br /&gt;
    private JButton left;&lt;br /&gt;
    /** The first button on the right of the panel. */&lt;br /&gt;
    private JButton right1;&lt;br /&gt;
    /** The second button on the right of the panel. */&lt;br /&gt;
    private JButton right2;&lt;br /&gt;
    /**&lt;br /&gt;
     * Standard constructor - creates a three button panel with the specified button labels.&lt;br /&gt;
     *&lt;br /&gt;
     * @param label1  the label for button 1.&lt;br /&gt;
     * @param label2  the label for button 2.&lt;br /&gt;
     * @param label3  the label for button 3.&lt;br /&gt;
     */&lt;br /&gt;
    public L1R2ButtonPanel(final String label1, final String label2, final String label3) {&lt;br /&gt;
        setLayout(new BorderLayout());&lt;br /&gt;
        // create the pieces...&lt;br /&gt;
        this.left = new JButton(label1);&lt;br /&gt;
        final JPanel rightButtonPanel = new JPanel(new GridLayout(1, 2));&lt;br /&gt;
        this.right1 = new JButton(label2);&lt;br /&gt;
        this.right2 = new JButton(label3);&lt;br /&gt;
        rightButtonPanel.add(this.right1);&lt;br /&gt;
        rightButtonPanel.add(this.right2);&lt;br /&gt;
        // ...and put them together&lt;br /&gt;
        add(this.left, BorderLayout.WEST);&lt;br /&gt;
        add(rightButtonPanel, BorderLayout.EAST);&lt;br /&gt;
    }&lt;br /&gt;
    /**&lt;br /&gt;
     * Returns a reference to button 1, allowing the caller to set labels, action-listeners etc.&lt;br /&gt;
     *&lt;br /&gt;
     * @return the left button.&lt;br /&gt;
     */&lt;br /&gt;
    public JButton getLeftButton() {&lt;br /&gt;
        return this.left;&lt;br /&gt;
    }&lt;br /&gt;
    /**&lt;br /&gt;
     * Returns a reference to button 2, allowing the caller to set labels, action-listeners etc.&lt;br /&gt;
     *&lt;br /&gt;
     * @return the right button 1.&lt;br /&gt;
     */&lt;br /&gt;
    public JButton getRightButton1() {&lt;br /&gt;
        return this.right1;&lt;br /&gt;
    }&lt;br /&gt;
    /**&lt;br /&gt;
     * Returns a reference to button 3, allowing the caller to set labels, action-listeners etc.&lt;br /&gt;
     *&lt;br /&gt;
     * @return  the right button 2.&lt;br /&gt;
     */&lt;br /&gt;
    public JButton getRightButton2() {&lt;br /&gt;
        return this.right2;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
/* &lt;br /&gt;
 * JCommon : a free general purpose class library for the Java(tm) platform&lt;br /&gt;
 * &lt;br /&gt;
 *&lt;br /&gt;
 * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors.&lt;br /&gt;
 *&lt;br /&gt;
 * Project Info:  http://www.jfree.org/jcommon/index.html&lt;br /&gt;
 *&lt;br /&gt;
 * This library is free software; you can redistribute it and/or modify it&lt;br /&gt;
 * under the terms of the GNU Lesser General Public License as published by&lt;br /&gt;
 * the Free Software Foundation; either version 2.1 of the License, or&lt;br /&gt;
 * (at your option) any later version.&lt;br /&gt;
 *&lt;br /&gt;
 * This library is distributed in the hope that it will be useful, but&lt;br /&gt;
 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY&lt;br /&gt;
 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public&lt;br /&gt;
 * License for more details.&lt;br /&gt;
 *&lt;br /&gt;
 * You should have received a copy of the GNU Lesser General Public&lt;br /&gt;
 * License along with this library; if not, write to the Free Software&lt;br /&gt;
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301,&lt;br /&gt;
 * USA.&lt;br /&gt;
 *&lt;br /&gt;
 * [Java is a trademark or registered trademark of Sun Microsystems, Inc.&lt;br /&gt;
 * in the United States and other countries.]&lt;br /&gt;
 *&lt;br /&gt;
 * ---------------------&lt;br /&gt;
 * FontDisplayField.java&lt;br /&gt;
 * ---------------------&lt;br /&gt;
 * (C) Copyright 2000-2008, by Object Refinery Limited.&lt;br /&gt;
 *&lt;br /&gt;
 * Original Author:  David Gilbert (for Object Refinery Limited);&lt;br /&gt;
 * Contributor(s):   Arnaud Lelievre;&lt;br /&gt;
 *&lt;br /&gt;
 * $Id: FontDisplayField.java,v 1.6 2008/12/18 09:57:32 mungady Exp $&lt;br /&gt;
 *&lt;br /&gt;
 * Changes (from 26-Oct-2001)&lt;br /&gt;
 * ----------------------------------&lt;br /&gt;
 * 26-Oct-2001 : Changed package to com.jrefinery.ui.*;&lt;br /&gt;
 * 14-Oct-2002 : Fixed errors reported by Checkstyle (DG);&lt;br /&gt;
 * 08-Sep-2003 : Added internationalization via use of properties&lt;br /&gt;
 *               resourceBundle (RFE 690236) (AL);&lt;br /&gt;
 * 18-Dec-2008 : Use ResourceBundleWrapper - see JFreeChart patch 1607918 by&lt;br /&gt;
 *               Jess Thrysoee (DG);&lt;br /&gt;
 *&lt;br /&gt;
 */&lt;br /&gt;
&lt;br /&gt;
/**&lt;br /&gt;
 * A field for displaying a font selection.  The display field itself is&lt;br /&gt;
 * read-only, to the developer must provide another mechanism to allow the&lt;br /&gt;
 * user to change the font.&lt;br /&gt;
 *&lt;br /&gt;
 * @author David Gilbert&lt;br /&gt;
 */&lt;br /&gt;
class FontDisplayField extends JTextField {&lt;br /&gt;
    /** The current font. */&lt;br /&gt;
    private Font displayFont;&lt;br /&gt;
&lt;br /&gt;
    /**&lt;br /&gt;
     * Standard constructor - builds a FontDescriptionField initialised with&lt;br /&gt;
     * the specified font.&lt;br /&gt;
     *&lt;br /&gt;
     * @param font  the font.&lt;br /&gt;
     */&lt;br /&gt;
    public FontDisplayField(final Font font) {&lt;br /&gt;
        super(&amp;quot;&amp;quot;);&lt;br /&gt;
        setDisplayFont(font);&lt;br /&gt;
        setEnabled(false);&lt;br /&gt;
    }&lt;br /&gt;
    /**&lt;br /&gt;
     * Returns the current font.&lt;br /&gt;
     *&lt;br /&gt;
     * @return the font.&lt;br /&gt;
     */&lt;br /&gt;
    public Font getDisplayFont() {&lt;br /&gt;
        return this.displayFont;&lt;br /&gt;
    }&lt;br /&gt;
    /**&lt;br /&gt;
     * Sets the font.&lt;br /&gt;
     *&lt;br /&gt;
     * @param font  the font.&lt;br /&gt;
     */&lt;br /&gt;
    public void setDisplayFont(final Font font) {&lt;br /&gt;
        this.displayFont = font;&lt;br /&gt;
        setText(fontToString(this.displayFont));&lt;br /&gt;
    }&lt;br /&gt;
    /**&lt;br /&gt;
     * Returns a string representation of the specified font.&lt;br /&gt;
     *&lt;br /&gt;
     * @param font  the font.&lt;br /&gt;
     *&lt;br /&gt;
     * @return a string describing the font.&lt;br /&gt;
     */&lt;br /&gt;
    private String fontToString(final Font font) {&lt;br /&gt;
        if (font != null) {&lt;br /&gt;
            return font.getFontName() + &amp;quot;, &amp;quot; + font.getSize();&lt;br /&gt;
        }&lt;br /&gt;
        else {&lt;br /&gt;
            return &amp;quot;No Font Selected&amp;quot;;&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Font Dialog from claribole ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
/*   FILE: FontDialog.java&lt;br /&gt;
 *   DATE OF CREATION:   Wed Jan 15 17:07:07 2002&lt;br /&gt;
 *   AUTHOR :            Emmanuel Pietriga (emmanuel@w3.org)&lt;br /&gt;
 *   MODIF:              Emmanuel Pietriga (emmanuel.pietriga@inria.fr)&lt;br /&gt;
 *   Copyright (c) Emmanuel Pietriga, 2002. All Rights Reserved&lt;br /&gt;
 *   Copyright (c) INRIA, 2008. All Rights Reserved&lt;br /&gt;
 *   Licensed under the GNU LGPL. For full terms see the file COPYING.&lt;br /&gt;
 *&lt;br /&gt;
 * $Id: FontDialog.java 1207 2008-08-13 16:03:07Z epietrig $&lt;br /&gt;
 */&lt;br /&gt;
&lt;br /&gt;
import java.awt.Container;&lt;br /&gt;
import java.awt.Dialog;&lt;br /&gt;
import java.awt.FlowLayout;&lt;br /&gt;
import java.awt.Font;&lt;br /&gt;
import java.awt.Frame;&lt;br /&gt;
import java.awt.GridBagConstraints;&lt;br /&gt;
import java.awt.GridBagLayout;&lt;br /&gt;
import java.awt.Window;&lt;br /&gt;
import java.awt.event.ActionEvent;&lt;br /&gt;
import java.awt.event.ActionListener;&lt;br /&gt;
import java.awt.event.ruponentAdapter;&lt;br /&gt;
import java.awt.event.ruponentEvent;&lt;br /&gt;
import java.awt.event.WindowAdapter;&lt;br /&gt;
import java.awt.event.WindowEvent;&lt;br /&gt;
import java.util.StringTokenizer;&lt;br /&gt;
import javax.swing.JButton;&lt;br /&gt;
import javax.swing.JDialog;&lt;br /&gt;
import javax.swing.JList;&lt;br /&gt;
import javax.swing.JPanel;&lt;br /&gt;
import javax.swing.JScrollPane;&lt;br /&gt;
public class FontDialog extends JDialog implements ActionListener {&lt;br /&gt;
  static final String ZVTM_FONT_CHOOSER = &amp;quot;ZVTM Font Chooser&amp;quot;;&lt;br /&gt;
    static String DEFAULT_FAMILY=&amp;quot;Dialog&amp;quot;;&lt;br /&gt;
    static int DEFAULT_STYLE=Font.PLAIN;&lt;br /&gt;
    static int DEFAULT_SIZE=10;&lt;br /&gt;
    FontTracker ft;&lt;br /&gt;
    JButton okBt,cancelBt;&lt;br /&gt;
    JList familyList,styleList,sizeList;&lt;br /&gt;
    String[] allFontFamilies=java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment().getAvailableFontFamilyNames();&lt;br /&gt;
    String[] allFontStyles={&amp;quot;Plain&amp;quot;,&amp;quot;Bold&amp;quot;,&amp;quot;Italic&amp;quot;,&amp;quot;BoldItalic&amp;quot;};&lt;br /&gt;
    String[] allFontSizes={&amp;quot;4&amp;quot;,&amp;quot;6&amp;quot;,&amp;quot;8&amp;quot;,&amp;quot;10&amp;quot;,&amp;quot;12&amp;quot;,&amp;quot;14&amp;quot;,&amp;quot;16&amp;quot;,&amp;quot;18&amp;quot;,&amp;quot;20&amp;quot;,&amp;quot;24&amp;quot;};&lt;br /&gt;
    &lt;br /&gt;
    /** Call a FontDialog window that will return  the font selected in the window&lt;br /&gt;
     *@param owner application frame that owns this Modal component&lt;br /&gt;
     */&lt;br /&gt;
    public static Font getFontDialog(Frame owner){&lt;br /&gt;
  FontTracker res=new FontTracker();&lt;br /&gt;
  FontDialog fd=new FontDialog(res,owner);&lt;br /&gt;
  fd.addWindowListener(new FontDialog.Closer());&lt;br /&gt;
        fd.addComponentListener(new FontDialog.DisposeOnClose());&lt;br /&gt;
  fd.setLocationRelativeTo(owner);&lt;br /&gt;
  fd.setVisible(true);  //blocks until the dialog is closed&lt;br /&gt;
  return res.getFont();&lt;br /&gt;
    }&lt;br /&gt;
    /** Call a FontDialog window that will return  the font selected in the window&lt;br /&gt;
     *@param owner application dialog that owns this Modal component&lt;br /&gt;
     */&lt;br /&gt;
    public static Font getFontDialog(Dialog owner){&lt;br /&gt;
  FontTracker res=new FontTracker();&lt;br /&gt;
  FontDialog fd=new FontDialog(res,owner);&lt;br /&gt;
  fd.addWindowListener(new FontDialog.Closer());&lt;br /&gt;
        fd.addComponentListener(new FontDialog.DisposeOnClose());&lt;br /&gt;
  fd.setLocationRelativeTo(owner);&lt;br /&gt;
  fd.setVisible(true);  //blocks until the dialog is closed&lt;br /&gt;
  return res.getFont();&lt;br /&gt;
    }&lt;br /&gt;
    /** Call a FontDialog window that will return  the font selected in the window&lt;br /&gt;
     *@param owner application frame that owns this Modal component&lt;br /&gt;
     *@param f a font giving the default parameters with which the dialog should be initialized (family, size, style)&lt;br /&gt;
     */&lt;br /&gt;
    public static Font getFontDialog(Frame owner,Font f){&lt;br /&gt;
  if (f!=null){&lt;br /&gt;
      DEFAULT_FAMILY=f.getFamily();&lt;br /&gt;
      DEFAULT_STYLE=f.getStyle();&lt;br /&gt;
      DEFAULT_SIZE=f.getSize();&lt;br /&gt;
  }&lt;br /&gt;
  FontTracker res=new FontTracker();&lt;br /&gt;
  FontDialog fd=new FontDialog(res,owner);&lt;br /&gt;
  fd.addWindowListener(new FontDialog.Closer());&lt;br /&gt;
        fd.addComponentListener(new FontDialog.DisposeOnClose());&lt;br /&gt;
  fd.setLocationRelativeTo(owner);&lt;br /&gt;
  fd.setVisible(true);  //blocks until the dialog is closed&lt;br /&gt;
  return res.getFont();&lt;br /&gt;
    }&lt;br /&gt;
    /** Call a FontDialog window that will return  the font selected in the window&lt;br /&gt;
     *@param owner application dialog that owns this Modal component&lt;br /&gt;
     *@param f a font giving the default parameters with which the dialog should be initialized (family, size, style)&lt;br /&gt;
     */&lt;br /&gt;
    public static Font getFontDialog(Dialog owner,Font f){&lt;br /&gt;
  if (f!=null){&lt;br /&gt;
      DEFAULT_FAMILY=f.getFamily();&lt;br /&gt;
      DEFAULT_STYLE=f.getStyle();&lt;br /&gt;
      DEFAULT_SIZE=f.getSize();&lt;br /&gt;
  }&lt;br /&gt;
  FontTracker res=new FontTracker();&lt;br /&gt;
  FontDialog fd=new FontDialog(res,owner);&lt;br /&gt;
  fd.addWindowListener(new FontDialog.Closer());&lt;br /&gt;
        fd.addComponentListener(new FontDialog.DisposeOnClose());&lt;br /&gt;
  fd.setLocationRelativeTo(owner);&lt;br /&gt;
  fd.setVisible(true);  //blocks until the dialog is closed&lt;br /&gt;
  return res.getFont();&lt;br /&gt;
    }&lt;br /&gt;
    /**&lt;br /&gt;
     * Font.decode does not seem to work that well, or I don;t understand how it is supposed to work&lt;br /&gt;
     * Anyway, this one does what I want (decodes family+&amp;quot; &amp;quot;+style+&amp;quot; &amp;quot;+size)&lt;br /&gt;
     */&lt;br /&gt;
    public static Font decode(String fontSpec){&lt;br /&gt;
  if (fontSpec!=null &amp;amp;&amp;amp; fontSpec.length()&amp;gt;0){&lt;br /&gt;
      StringTokenizer st=new StringTokenizer(fontSpec,&amp;quot; &amp;quot;,false);&lt;br /&gt;
      String[] tokens=new String[st.countTokens()];&lt;br /&gt;
      if (tokens.length&amp;gt;=3){&lt;br /&gt;
    int i=0;&lt;br /&gt;
    while (st.hasMoreTokens()) {&lt;br /&gt;
        tokens[i++]=st.nextToken();&lt;br /&gt;
    }&lt;br /&gt;
    String tokenizedFamily=&amp;quot;&amp;quot;;&lt;br /&gt;
    for (int j=0;j&amp;lt;tokens.length-3;j++){&lt;br /&gt;
        tokenizedFamily+=tokens[j]+&amp;quot; &amp;quot;;&lt;br /&gt;
    }&lt;br /&gt;
    tokenizedFamily+=tokens[tokens.length-3];&lt;br /&gt;
    String family=tokenizedFamily;if (family==null){family=DEFAULT_FAMILY;}&lt;br /&gt;
    String tokenizedStyle=tokens[tokens.length-2];&lt;br /&gt;
    String tokenizedSize=tokens[tokens.length-1];&lt;br /&gt;
    int style;&lt;br /&gt;
    if (tokenizedStyle.equals(&amp;quot;Bold&amp;quot;)){style=Font.BOLD;}&lt;br /&gt;
    else if (tokenizedStyle.equals(&amp;quot;Italic&amp;quot;)){style=Font.ITALIC;}&lt;br /&gt;
    else if (tokenizedStyle.equals(&amp;quot;BoldItalic&amp;quot;)){style=Font.BOLD+Font.ITALIC;}&lt;br /&gt;
    else {style=Font.PLAIN;}//&amp;quot;Plain&amp;quot;&lt;br /&gt;
    int size;&lt;br /&gt;
    try {&lt;br /&gt;
        size=Integer.parseInt(tokenizedSize);&lt;br /&gt;
        if (size&amp;lt;=0){size=DEFAULT_SIZE;}&lt;br /&gt;
    }&lt;br /&gt;
    catch (NumberFormatException ex){size=DEFAULT_SIZE;}&lt;br /&gt;
    return new Font(family,style,size);&lt;br /&gt;
      }&lt;br /&gt;
      else {return new Font(DEFAULT_FAMILY,DEFAULT_STYLE,DEFAULT_SIZE);}&lt;br /&gt;
  }&lt;br /&gt;
  else {return new Font(DEFAULT_FAMILY,DEFAULT_STYLE,DEFAULT_SIZE);}&lt;br /&gt;
    }&lt;br /&gt;
    FontDialog(FontTracker ftt,Frame owner){&lt;br /&gt;
  super(owner,ZVTM_FONT_CHOOSER,true);&lt;br /&gt;
  setLocation(owner.getLocation());&lt;br /&gt;
  ft=ftt;&lt;br /&gt;
  initUI();&lt;br /&gt;
    }&lt;br /&gt;
    FontDialog(FontTracker ftt,Dialog owner){&lt;br /&gt;
  super(owner,ZVTM_FONT_CHOOSER,true);&lt;br /&gt;
  setLocation(owner.getLocation());&lt;br /&gt;
  ft=ftt;&lt;br /&gt;
  initUI();&lt;br /&gt;
    }&lt;br /&gt;
    void initUI(){//depending on selected item/default shape type&lt;br /&gt;
  Container cp=this.getContentPane();&lt;br /&gt;
  try {&lt;br /&gt;
     okBt.removeActionListener(this);&lt;br /&gt;
     cancelBt.removeActionListener(this);&lt;br /&gt;
  }&lt;br /&gt;
  catch (NullPointerException ex){/*all these might be null (for instance when poping up a GlyphFactory for the first time)*/}&lt;br /&gt;
  cp.removeAll();&lt;br /&gt;
  //main font panel&lt;br /&gt;
  JPanel mainPanel=new JPanel();&lt;br /&gt;
  GridBagLayout gridBag1=new GridBagLayout();&lt;br /&gt;
  GridBagConstraints constraints1=new GridBagConstraints();&lt;br /&gt;
  mainPanel.setLayout(gridBag1);&lt;br /&gt;
  constraints1.fill=GridBagConstraints.BOTH;&lt;br /&gt;
  constraints1.anchor=GridBagConstraints.CENTER;&lt;br /&gt;
  familyList=new JList(allFontFamilies);&lt;br /&gt;
  JScrollPane sp1=new JScrollPane(familyList);&lt;br /&gt;
  buildConstraints(constraints1,0,0,1,1,30,100);&lt;br /&gt;
  gridBag1.setConstraints(sp1,constraints1);&lt;br /&gt;
  mainPanel.add(sp1);&lt;br /&gt;
  styleList=new JList(allFontStyles);&lt;br /&gt;
  JScrollPane sp2=new JScrollPane(styleList);&lt;br /&gt;
  buildConstraints(constraints1,1,0,1,1,30,0);&lt;br /&gt;
  gridBag1.setConstraints(sp2,constraints1);&lt;br /&gt;
  mainPanel.add(sp2);&lt;br /&gt;
  sizeList=new JList(allFontSizes);&lt;br /&gt;
  JScrollPane sp3=new JScrollPane(sizeList);&lt;br /&gt;
  buildConstraints(constraints1,2,0,1,1,25,0);&lt;br /&gt;
  gridBag1.setConstraints(sp3,constraints1);&lt;br /&gt;
  mainPanel.add(sp3);&lt;br /&gt;
  //ok, cancel, reset buttons&lt;br /&gt;
  JPanel btPanel=new JPanel();&lt;br /&gt;
  btPanel.setLayout(new FlowLayout());&lt;br /&gt;
  okBt=new JButton(&amp;quot;OK&amp;quot;); &lt;br /&gt;
  okBt.addActionListener(this);&lt;br /&gt;
  btPanel.add(okBt);&lt;br /&gt;
  cancelBt=new JButton(&amp;quot;Cancel&amp;quot;); &lt;br /&gt;
  cancelBt.addActionListener(this);&lt;br /&gt;
  btPanel.add(cancelBt);&lt;br /&gt;
  //main components&lt;br /&gt;
  GridBagLayout gridBag=new GridBagLayout();&lt;br /&gt;
  GridBagConstraints constraints=new GridBagConstraints();&lt;br /&gt;
  cp.setLayout(gridBag);&lt;br /&gt;
  constraints.fill=GridBagConstraints.BOTH;&lt;br /&gt;
  constraints.anchor=GridBagConstraints.CENTER;&lt;br /&gt;
  buildConstraints(constraints,0,0,1,1,100,99);&lt;br /&gt;
  gridBag.setConstraints(mainPanel,constraints);&lt;br /&gt;
  cp.add(mainPanel);&lt;br /&gt;
  buildConstraints(constraints,0,1,1,1,100,1);&lt;br /&gt;
  gridBag.setConstraints(btPanel,constraints);&lt;br /&gt;
  cp.add(btPanel);&lt;br /&gt;
  this.setSize(350,200);&lt;br /&gt;
  this.setResizable(false);&lt;br /&gt;
  familyList.setSelectedValue(DEFAULT_FAMILY,true);&lt;br /&gt;
  if (DEFAULT_STYLE==Font.PLAIN){styleList.setSelectedValue(&amp;quot;Plain&amp;quot;,true);}&lt;br /&gt;
  else if (DEFAULT_STYLE==Font.BOLD){styleList.setSelectedValue(&amp;quot;Bold&amp;quot;,true);}&lt;br /&gt;
  else if (DEFAULT_STYLE==Font.ITALIC){styleList.setSelectedValue(&amp;quot;Italic&amp;quot;,true);}&lt;br /&gt;
  else if (DEFAULT_STYLE==Font.BOLD+Font.ITALIC){styleList.setSelectedValue(&amp;quot;BoldItalic&amp;quot;,true);}&lt;br /&gt;
  sizeList.setSelectedValue((new Integer(DEFAULT_SIZE)).toString(),true);&lt;br /&gt;
    }&lt;br /&gt;
    public void actionPerformed(ActionEvent e){&lt;br /&gt;
  Object source=e.getSource();&lt;br /&gt;
  if (source==okBt){&lt;br /&gt;
      ft.setFont(getSelectedFont());&lt;br /&gt;
      this.dispose();&lt;br /&gt;
  }&lt;br /&gt;
  else if (source==cancelBt){&lt;br /&gt;
      ft.setFont(null);&lt;br /&gt;
      this.dispose();&lt;br /&gt;
  }&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    Font getSelectedFont(){&lt;br /&gt;
  String family=(String)familyList.getSelectedValue();if (family==null){family=DEFAULT_FAMILY;}&lt;br /&gt;
  String selectedStyle=(String)styleList.getSelectedValue();&lt;br /&gt;
  int style;&lt;br /&gt;
  if (selectedStyle.equals(&amp;quot;Bold&amp;quot;)){style=Font.BOLD;}&lt;br /&gt;
  else if (selectedStyle.equals(&amp;quot;Italic&amp;quot;)){style=Font.ITALIC;}&lt;br /&gt;
  else if (selectedStyle.equals(&amp;quot;BoldItalic&amp;quot;)){style=Font.BOLD+Font.ITALIC;}&lt;br /&gt;
  else {style=Font.PLAIN;}//&amp;quot;Plain&amp;quot;&lt;br /&gt;
  int size;&lt;br /&gt;
  try {&lt;br /&gt;
      String selectedSize=(String)sizeList.getSelectedValue();&lt;br /&gt;
      size=Integer.parseInt(selectedSize);&lt;br /&gt;
      if (size&amp;lt;=0){size=DEFAULT_SIZE;}&lt;br /&gt;
  }&lt;br /&gt;
  catch (NumberFormatException ex){size=DEFAULT_SIZE;}&lt;br /&gt;
  return new Font(family,style,size);&lt;br /&gt;
    }&lt;br /&gt;
    static void buildConstraints(GridBagConstraints gbc, int gx,int gy,int gw,int gh,int wx,int wy){&lt;br /&gt;
  gbc.gridx=gx;&lt;br /&gt;
  gbc.gridy=gy;&lt;br /&gt;
  gbc.gridwidth=gw;&lt;br /&gt;
  gbc.gridheight=gh;&lt;br /&gt;
  gbc.weightx=wx;&lt;br /&gt;
  gbc.weighty=wy;&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    static class Closer extends WindowAdapter {&lt;br /&gt;
        public void windowClosing(WindowEvent e) {&lt;br /&gt;
            Window w = e.getWindow();&lt;br /&gt;
            w.setVisible(false);&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
    static class DisposeOnClose extends ComponentAdapter {&lt;br /&gt;
        public void componentHidden(ComponentEvent e) {&lt;br /&gt;
            Window w = (Window)e.getComponent();&lt;br /&gt;
            w.dispose();&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
    public static String getFontStyleName(int i){&lt;br /&gt;
  if (i==java.awt.Font.BOLD){return &amp;quot;Bold&amp;quot;;}&lt;br /&gt;
  else if (i==java.awt.Font.ITALIC){return &amp;quot;Italic&amp;quot;;}&lt;br /&gt;
  else if (i==java.awt.Font.BOLD+java.awt.Font.ITALIC){return &amp;quot;BoldItalic&amp;quot;;}&lt;br /&gt;
  else {return &amp;quot;Plain&amp;quot;;}&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
class FontTracker {&lt;br /&gt;
    Font font;&lt;br /&gt;
    public void setFont(Font f){&lt;br /&gt;
  font=f;&lt;br /&gt;
    }&lt;br /&gt;
    public Font getFont() {&lt;br /&gt;
        return font;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
   &lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Font Loader Dialog ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
/*&lt;br /&gt;
 * FontLoaderDialog.java&lt;br /&gt;
 *&lt;br /&gt;
 * Created on November 13, 2006, 8:30 AM&lt;br /&gt;
 */&lt;br /&gt;
&lt;br /&gt;
// Revised from jaspersoft designer&lt;br /&gt;
import java.lang.reflect.InvocationTargetException;&lt;br /&gt;
import javax.swing.SwingUtilities;&lt;br /&gt;
/**&lt;br /&gt;
 *&lt;br /&gt;
 * @author  gtoffoli&lt;br /&gt;
 */&lt;br /&gt;
public class FontLoaderDialog extends javax.swing.JDialog {&lt;br /&gt;
    &lt;br /&gt;
    /** Creates new form FontLoaderDialog */&lt;br /&gt;
    public FontLoaderDialog(java.awt.Frame parent, boolean modal) {&lt;br /&gt;
        super(parent, modal);&lt;br /&gt;
        initComponents();&lt;br /&gt;
        //applyI18n();&lt;br /&gt;
        this.pack();&lt;br /&gt;
        &lt;br /&gt;
        setLocationRelativeTo(null);&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    /** This method is called from within the constructor to&lt;br /&gt;
     * initialize the form.&lt;br /&gt;
     * WARNING: Do NOT modify this code. The content of this method is&lt;br /&gt;
     * always regenerated by the Form Editor.&lt;br /&gt;
     */&lt;br /&gt;
    // &amp;lt;editor-fold defaultstate=&amp;quot;collapsed&amp;quot; desc=&amp;quot;Generated Code&amp;quot;&amp;gt;//GEN-BEGIN:initComponents&lt;br /&gt;
    private void initComponents() {&lt;br /&gt;
        java.awt.GridBagConstraints gridBagConstraints;&lt;br /&gt;
        jLabelStatus = new javax.swing.JLabel();&lt;br /&gt;
        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);&lt;br /&gt;
        getContentPane().setLayout(new java.awt.GridBagLayout());&lt;br /&gt;
        jLabelStatus.setText(&amp;quot;FontLoaderDialog.Label.LoadingStatus&amp;quot;); // NOI18N&lt;br /&gt;
        jLabelStatus.setVerticalAlignment(javax.swing.SwingConstants.TOP);&lt;br /&gt;
        jLabelStatus.setPreferredSize(new java.awt.Dimension(391, 51));&lt;br /&gt;
        gridBagConstraints = new java.awt.GridBagConstraints();&lt;br /&gt;
        gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;&lt;br /&gt;
        gridBagConstraints.weightx = 1.0;&lt;br /&gt;
        gridBagConstraints.weighty = 1.0;&lt;br /&gt;
        gridBagConstraints.insets = new java.awt.Insets(4, 4, 4, 4);&lt;br /&gt;
        getContentPane().add(jLabelStatus, gridBagConstraints);&lt;br /&gt;
        pack();&lt;br /&gt;
    }// &amp;lt;/editor-fold&amp;gt;//GEN-END:initComponents&lt;br /&gt;
    &lt;br /&gt;
    public void setStatus(String s)&lt;br /&gt;
    {&lt;br /&gt;
        jLabelStatus.setText(s);&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    public void fontsLoadingStatusUpdated(String statusMsg) {&lt;br /&gt;
        &lt;br /&gt;
        final String s = statusMsg;&lt;br /&gt;
        try {&lt;br /&gt;
            SwingUtilities.invokeAndWait( new Runnable()&lt;br /&gt;
            {&lt;br /&gt;
                public void run()&lt;br /&gt;
                {&lt;br /&gt;
                    setStatus(s);&lt;br /&gt;
                }&lt;br /&gt;
            }&lt;br /&gt;
            );&lt;br /&gt;
        } catch (InterruptedException ex) {&lt;br /&gt;
            ex.printStackTrace();&lt;br /&gt;
        } catch (InvocationTargetException ex) {&lt;br /&gt;
            ex.printStackTrace();&lt;br /&gt;
        }&lt;br /&gt;
        &lt;br /&gt;
    }&lt;br /&gt;
    public void fontsLoadingStarted() {&lt;br /&gt;
        &lt;br /&gt;
        try {&lt;br /&gt;
            SwingUtilities.invokeAndWait( new Runnable()&lt;br /&gt;
            {&lt;br /&gt;
                public void run()&lt;br /&gt;
                {&lt;br /&gt;
                    setVisible(true);&lt;br /&gt;
                }&lt;br /&gt;
            }&lt;br /&gt;
            );&lt;br /&gt;
        } catch (InterruptedException ex) {&lt;br /&gt;
            ex.printStackTrace();&lt;br /&gt;
        } catch (InvocationTargetException ex) {&lt;br /&gt;
            ex.printStackTrace();&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
    public void fontsLoadingFinished() {&lt;br /&gt;
        try {&lt;br /&gt;
            SwingUtilities.invokeAndWait( new Runnable()&lt;br /&gt;
            {&lt;br /&gt;
                public void run()&lt;br /&gt;
                {&lt;br /&gt;
                    setVisible(false);&lt;br /&gt;
                }&lt;br /&gt;
            }&lt;br /&gt;
            );&lt;br /&gt;
        } catch (InterruptedException ex) {&lt;br /&gt;
            ex.printStackTrace();&lt;br /&gt;
        } catch (InvocationTargetException ex) {&lt;br /&gt;
            ex.printStackTrace();&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    // Variables declaration - do not modify//GEN-BEGIN:variables&lt;br /&gt;
    private javax.swing.JLabel jLabelStatus;&lt;br /&gt;
    // End of variables declaration//GEN-END:variables&lt;br /&gt;
    &lt;br /&gt;
//    public void applyI18n(){&lt;br /&gt;
//                // Start autogenerated code ----------------------&lt;br /&gt;
//                jLabelStatus.setText(I18n.getString(&amp;quot;fontLoaderDialog.labelStatus&amp;quot;,&amp;quot;Loading status&amp;quot;));&lt;br /&gt;
//                // End autogenerated code ----------------------&lt;br /&gt;
//    }&lt;br /&gt;
}&lt;br /&gt;
   &lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== JFont Chooser ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
// revised from greef ui&lt;br /&gt;
import java.awt.BorderLayout;&lt;br /&gt;
import java.awt.ruponent;&lt;br /&gt;
import java.awt.Container;&lt;br /&gt;
import java.awt.FlowLayout;&lt;br /&gt;
import java.awt.Font;&lt;br /&gt;
import java.awt.GraphicsEnvironment;&lt;br /&gt;
import java.awt.GridBagConstraints;&lt;br /&gt;
import java.awt.GridBagLayout;&lt;br /&gt;
import java.awt.HeadlessException;&lt;br /&gt;
import java.awt.Insets;&lt;br /&gt;
import java.awt.Window;&lt;br /&gt;
import java.awt.event.ActionEvent;&lt;br /&gt;
import java.awt.event.ActionListener;&lt;br /&gt;
import java.awt.event.ruponentAdapter;&lt;br /&gt;
import java.awt.event.ruponentEvent;&lt;br /&gt;
import java.awt.event.KeyEvent;&lt;br /&gt;
import java.awt.event.WindowAdapter;&lt;br /&gt;
import java.awt.event.WindowEvent;&lt;br /&gt;
import java.io.Serializable;&lt;br /&gt;
import javax.swing.AbstractAction;&lt;br /&gt;
import javax.swing.Action;&lt;br /&gt;
import javax.swing.ActionMap;&lt;br /&gt;
import javax.swing.InputMap;&lt;br /&gt;
import javax.swing.JButton;&lt;br /&gt;
import javax.swing.JCheckBox;&lt;br /&gt;
import javax.swing.JComponent;&lt;br /&gt;
import javax.swing.JDialog;&lt;br /&gt;
import javax.swing.JLabel;&lt;br /&gt;
import javax.swing.JList;&lt;br /&gt;
import javax.swing.JOptionPane;&lt;br /&gt;
import javax.swing.JPanel;&lt;br /&gt;
import javax.swing.JScrollPane;&lt;br /&gt;
import javax.swing.KeyStroke;&lt;br /&gt;
import javax.swing.ListSelectionModel;&lt;br /&gt;
import javax.swing.UIManager;&lt;br /&gt;
import javax.swing.event.ChangeEvent;&lt;br /&gt;
import javax.swing.event.ChangeListener;&lt;br /&gt;
import javax.swing.event.EventListenerList;&lt;br /&gt;
import javax.swing.event.ListSelectionEvent;&lt;br /&gt;
import javax.swing.event.ListSelectionListener;&lt;br /&gt;
/**&lt;br /&gt;
 * &amp;lt;code&amp;gt;JFontChooser&amp;lt;/code&amp;gt; provides a pane of controls designed to allow&lt;br /&gt;
 * a user to manipulate and select a font.&lt;br /&gt;
 *&lt;br /&gt;
 * This class provides three levels of API:&lt;br /&gt;
 * &amp;lt;ol&amp;gt;&lt;br /&gt;
 * &amp;lt;li&amp;gt;A static convenience method which shows a modal font-chooser&lt;br /&gt;
 * dialog and returns the font selected by the user.&lt;br /&gt;
 * &amp;lt;li&amp;gt;A static convenience method for creating a font-chooser dialog&lt;br /&gt;
 * where &amp;lt;code&amp;gt;ActionListeners&amp;lt;/code&amp;gt; can be specified to be invoked when&lt;br /&gt;
 * the user presses one of the dialog buttons.&lt;br /&gt;
 * &amp;lt;li&amp;gt;The ability to create instances of &amp;lt;code&amp;gt;JFontChooser&amp;lt;/code&amp;gt; panes&lt;br /&gt;
 * directly (within any container). &amp;lt;code&amp;gt;PropertyChange&amp;lt;/code&amp;gt; listeners&lt;br /&gt;
 * can be added to detect when the current &amp;quot;font&amp;quot; property changes.&lt;br /&gt;
 * &amp;lt;/ol&amp;gt;&lt;br /&gt;
 * &amp;lt;p&amp;gt;&lt;br /&gt;
 *&lt;br /&gt;
 * @author Adrian BER&lt;br /&gt;
 */&lt;br /&gt;
public class JFontChooser extends JComponent {&lt;br /&gt;
    /** The list of possible font sizes. */&lt;br /&gt;
    private static final Integer[] SIZES =&lt;br /&gt;
            {8, 9, 10, 11, 12, 13, 14, 16, 18, 20, 24, 26, 28, 32, 36, 40, 48, 56, 64, 72};&lt;br /&gt;
    /** The list of possible fonts. */&lt;br /&gt;
    private static final String[] FONTS = GraphicsEnvironment.getLocalGraphicsEnvironment()&lt;br /&gt;
            .getAvailableFontFamilyNames();&lt;br /&gt;
&lt;br /&gt;
    private FontSelectionModel selectionModel;&lt;br /&gt;
    private JList fontList;&lt;br /&gt;
    private JList sizeList;&lt;br /&gt;
    private JCheckBox boldCheckBox;&lt;br /&gt;
    private JCheckBox italicCheckBox;&lt;br /&gt;
    private JLabel previewLabel;&lt;br /&gt;
    /** The preview text, if null the font name will be the preview text. */&lt;br /&gt;
    private String previewText;&lt;br /&gt;
    /** Listener used to update the font of the selection model. */&lt;br /&gt;
    private SelectionUpdater selectionUpdater = new SelectionUpdater();&lt;br /&gt;
    /** Listener used to update the font in the components. This should be registered&lt;br /&gt;
     * with the selection model. */&lt;br /&gt;
    private LabelUpdater labelUpdater = new LabelUpdater();&lt;br /&gt;
    /** True if the components are being updated and no event should be generated. */&lt;br /&gt;
    private boolean updatingComponents = false;&lt;br /&gt;
    /** Listener class used to update the font in the components. This should be registered&lt;br /&gt;
      * with the selection model. */&lt;br /&gt;
    private class LabelUpdater implements ChangeListener {&lt;br /&gt;
        public void stateChanged(ChangeEvent e) {&lt;br /&gt;
            updateComponents();&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
    /** Listener class used to update the font of the preview label. */&lt;br /&gt;
    private class SelectionUpdater implements ChangeListener, ListSelectionListener {&lt;br /&gt;
        public void stateChanged(ChangeEvent e) {&lt;br /&gt;
            if (!updatingComponents) {&lt;br /&gt;
                setFont(buildFont());&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
        public void valueChanged(ListSelectionEvent e) {&lt;br /&gt;
            if (!updatingComponents) {&lt;br /&gt;
                setFont(buildFont());&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
    /**&lt;br /&gt;
     * Shows a modal font-chooser dialog and blocks until the&lt;br /&gt;
     * dialog is hidden.  If the user presses the &amp;quot;OK&amp;quot; button, then&lt;br /&gt;
     * this method hides/disposes the dialog and returns the selected color.&lt;br /&gt;
     * If the user presses the &amp;quot;Cancel&amp;quot; button or closes the dialog without&lt;br /&gt;
     * pressing &amp;quot;OK&amp;quot;, then this method hides/disposes the dialog and returns&lt;br /&gt;
     * &amp;lt;code&amp;gt;null&amp;lt;/code&amp;gt;.&lt;br /&gt;
     *&lt;br /&gt;
     * @param component    the parent &amp;lt;code&amp;gt;Component&amp;lt;/code&amp;gt; for the dialog&lt;br /&gt;
     * @param title        the String containing the dialog&amp;quot;s title&lt;br /&gt;
     * @return the selected font or &amp;lt;code&amp;gt;null&amp;lt;/code&amp;gt; if the user opted out&lt;br /&gt;
     * @exception HeadlessException if GraphicsEnvironment.isHeadless()&lt;br /&gt;
     * returns true.&lt;br /&gt;
     * @see java.awt.GraphicsEnvironment#isHeadless&lt;br /&gt;
     */&lt;br /&gt;
    public Font showDialog(Component component, String title) {&lt;br /&gt;
        FontTracker ok = new FontTracker(this);&lt;br /&gt;
        JDialog dialog = createDialog(component, title, true, ok, null);&lt;br /&gt;
        dialog.addWindowListener(new FontChooserDialog.Closer());&lt;br /&gt;
        dialog.addComponentListener(new FontChooserDialog.DisposeOnClose());&lt;br /&gt;
        dialog.setVisible(true); // blocks until user brings dialog down...&lt;br /&gt;
        return ok.getFont();&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    /**&lt;br /&gt;
     * Creates and returns a new dialog containing the specified&lt;br /&gt;
     * &amp;lt;code&amp;gt;ColorChooser&amp;lt;/code&amp;gt; pane along with &amp;quot;OK&amp;quot;, &amp;quot;Cancel&amp;quot;, and &amp;quot;Reset&amp;quot;&lt;br /&gt;
     * buttons. If the &amp;quot;OK&amp;quot; or &amp;quot;Cancel&amp;quot; buttons are pressed, the dialog is&lt;br /&gt;
     * automatically hidden (but not disposed).  If the &amp;quot;Reset&amp;quot;&lt;br /&gt;
     * button is pressed, the color-chooser&amp;quot;s color will be reset to the&lt;br /&gt;
     * font which was set the last time &amp;lt;code&amp;gt;show&amp;lt;/code&amp;gt; was invoked on the&lt;br /&gt;
     * dialog and the dialog will remain showing.&lt;br /&gt;
     *&lt;br /&gt;
     * @param c              the parent component for the dialog&lt;br /&gt;
     * @param title          the title for the dialog&lt;br /&gt;
     * @param modal          a boolean. When true, the remainder of the program&lt;br /&gt;
     *                       is inactive until the dialog is closed.&lt;br /&gt;
     * @param okListener     the ActionListener invoked when &amp;quot;OK&amp;quot; is pressed&lt;br /&gt;
     * @param cancelListener the ActionListener invoked when &amp;quot;Cancel&amp;quot; is pressed&lt;br /&gt;
     * @return a new dialog containing the font-chooser pane&lt;br /&gt;
     * @exception HeadlessException if GraphicsEnvironment.isHeadless()&lt;br /&gt;
     * returns true.&lt;br /&gt;
     * @see java.awt.GraphicsEnvironment#isHeadless&lt;br /&gt;
     */&lt;br /&gt;
    public JDialog createDialog(Component c, String title, boolean modal,&lt;br /&gt;
        ActionListener okListener, ActionListener cancelListener) {&lt;br /&gt;
        return new FontChooserDialog(c, title, modal, this,&lt;br /&gt;
                okListener, cancelListener);&lt;br /&gt;
    }&lt;br /&gt;
    /**&lt;br /&gt;
     * Creates a color chooser pane with an initial font which is the same font&lt;br /&gt;
     * as the default font for labels.&lt;br /&gt;
     */&lt;br /&gt;
    public JFontChooser() {&lt;br /&gt;
        this(new DefaultFontSelectionModel());&lt;br /&gt;
    }&lt;br /&gt;
    /**&lt;br /&gt;
     * Creates a font chooser pane with the specified initial font.&lt;br /&gt;
     *&lt;br /&gt;
     * @param initialFont the initial font set in the chooser&lt;br /&gt;
     */&lt;br /&gt;
    public JFontChooser(Font initialFont) {&lt;br /&gt;
        this(new DefaultFontSelectionModel(initialFont));&lt;br /&gt;
    }&lt;br /&gt;
    /**&lt;br /&gt;
     * Creates a font chooser pane with the specified&lt;br /&gt;
     * &amp;lt;code&amp;gt;FontSelectionModel&amp;lt;/code&amp;gt;.&lt;br /&gt;
     *&lt;br /&gt;
     * @param model the font selection model used by this component&lt;br /&gt;
     */&lt;br /&gt;
    public JFontChooser(FontSelectionModel model) {&lt;br /&gt;
        selectionModel = model;&lt;br /&gt;
        init(model.getSelectedFont());&lt;br /&gt;
        selectionModel.addChangeListener(labelUpdater);&lt;br /&gt;
    }&lt;br /&gt;
    private void init(Font font) {&lt;br /&gt;
        setLayout(new GridBagLayout());&lt;br /&gt;
        Insets ins = new Insets(2, 2, 2, 2);&lt;br /&gt;
        fontList = new JList(FONTS);&lt;br /&gt;
        fontList.setVisibleRowCount(10);&lt;br /&gt;
        fontList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);&lt;br /&gt;
        add(new JScrollPane(fontList), new GridBagConstraints(0, 0, 1, 1, 2, 2,&lt;br /&gt;
                GridBagConstraints.CENTER, GridBagConstraints.BOTH,&lt;br /&gt;
                ins, 0, 0));&lt;br /&gt;
        sizeList = new JList(SIZES);&lt;br /&gt;
        ((JLabel)sizeList.getCellRenderer()).setHorizontalAlignment(JLabel.RIGHT);&lt;br /&gt;
        sizeList.setVisibleRowCount(10);&lt;br /&gt;
        sizeList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);&lt;br /&gt;
        add(new JScrollPane(sizeList), new GridBagConstraints(1, 0, 1, 1, 1, 2,&lt;br /&gt;
                GridBagConstraints.CENTER, GridBagConstraints.BOTH,&lt;br /&gt;
                ins, 0, 0));&lt;br /&gt;
        boldCheckBox = new JCheckBox(&amp;quot;Bold&amp;quot;);&lt;br /&gt;
        add(boldCheckBox, new GridBagConstraints(0, 1, 2, 1, 1, 0,&lt;br /&gt;
                GridBagConstraints.WEST, GridBagConstraints.NONE,&lt;br /&gt;
                ins, 0, 0));&lt;br /&gt;
        italicCheckBox = new JCheckBox(&amp;quot;Italic&amp;quot;);&lt;br /&gt;
        add(italicCheckBox, new GridBagConstraints(0, 2, 2, 1, 1, 0,&lt;br /&gt;
                GridBagConstraints.WEST, GridBagConstraints.NONE,&lt;br /&gt;
                ins, 0, 0));&lt;br /&gt;
        previewLabel = new JLabel(&amp;quot;&amp;quot;);&lt;br /&gt;
        previewLabel.setHorizontalAlignment(JLabel.CENTER);&lt;br /&gt;
        previewLabel.setVerticalAlignment(JLabel.CENTER);&lt;br /&gt;
        add(new JScrollPane(previewLabel), new GridBagConstraints(0, 3, 2, 1, 1, 1,&lt;br /&gt;
                GridBagConstraints.CENTER, GridBagConstraints.BOTH,&lt;br /&gt;
                ins, 0, 0));&lt;br /&gt;
        setFont(font == null ? previewLabel.getFont() : font);&lt;br /&gt;
        fontList.addListSelectionListener(selectionUpdater);&lt;br /&gt;
        sizeList.addListSelectionListener(selectionUpdater);&lt;br /&gt;
        boldCheckBox.addChangeListener(selectionUpdater);&lt;br /&gt;
        italicCheckBox.addChangeListener(selectionUpdater);&lt;br /&gt;
    }&lt;br /&gt;
    private Font buildFont() {&lt;br /&gt;
//        Font labelFont = previewLabel.getFont();&lt;br /&gt;
        String fontName = (String)fontList.getSelectedValue();&lt;br /&gt;
        if (fontName == null) {&lt;br /&gt;
            return null;&lt;br /&gt;
//            fontName = labelFont.getName();&lt;br /&gt;
        }&lt;br /&gt;
        Integer sizeInt = (Integer)sizeList.getSelectedValue();&lt;br /&gt;
        if (sizeInt == null) {&lt;br /&gt;
//            size = labelFont.getSize();&lt;br /&gt;
            return null;&lt;br /&gt;
        }&lt;br /&gt;
        // create the font&lt;br /&gt;
//        // first create the font attributes&lt;br /&gt;
//        HashMap map = new HashMap();&lt;br /&gt;
//        map.put(TextAttribute.BACKGROUND, Color.white);&lt;br /&gt;
//        map.put(TextAttribute.FAMILY, fontName);&lt;br /&gt;
//        map.put(TextAttribute.FOREGROUND, Color.black);&lt;br /&gt;
//        map.put(TextAttribute.SIZE , new Float(size));&lt;br /&gt;
//        map.put(TextAttribute.UNDERLINE, italicCheckBox.isSelected() ? TextAttribute.UNDERLINE_LOW_ONE_PIXEL : TextAttribute.UNDERLINE_LOW_TWO_PIXEL);&lt;br /&gt;
//        map.put(TextAttribute.STRIKETHROUGH, italicCheckBox.isSelected() ? TextAttribute.STRIKETHROUGH_ON : Boolean.FALSE);&lt;br /&gt;
//        map.put(TextAttribute.WEIGHT, boldCheckBox.isSelected() ? TextAttribute.WEIGHT_BOLD : TextAttribute.WEIGHT_REGULAR);&lt;br /&gt;
//        map.put(TextAttribute.POSTURE,&lt;br /&gt;
//                italicCheckBox.isSelected() ? TextAttribute.POSTURE_OBLIQUE : TextAttribute.POSTURE_REGULAR);&lt;br /&gt;
//&lt;br /&gt;
//        return new Font(map);&lt;br /&gt;
        return new Font(fontName,&lt;br /&gt;
                (italicCheckBox.isSelected() ? Font.ITALIC : Font.PLAIN)&lt;br /&gt;
                | (boldCheckBox.isSelected() ? Font.BOLD : Font.PLAIN),&lt;br /&gt;
                sizeInt);&lt;br /&gt;
    }&lt;br /&gt;
    /** Updates the font in the preview component according to the selected values. */&lt;br /&gt;
    private void updateComponents() {&lt;br /&gt;
        updatingComponents = true;&lt;br /&gt;
        Font font = getFont();&lt;br /&gt;
        fontList.setSelectedValue(font.getName(), true);&lt;br /&gt;
        sizeList.setSelectedValue(font.getSize(), true);&lt;br /&gt;
        boldCheckBox.setSelected(font.isBold());&lt;br /&gt;
        italicCheckBox.setSelected(font.isItalic());&lt;br /&gt;
        if (previewText == null) {&lt;br /&gt;
            previewLabel.setText(font.getName());&lt;br /&gt;
        }&lt;br /&gt;
        // set the font and fire a property change&lt;br /&gt;
        Font oldValue = previewLabel.getFont();&lt;br /&gt;
        previewLabel.setFont(font);&lt;br /&gt;
        firePropertyChange(&amp;quot;font&amp;quot;, oldValue, font);&lt;br /&gt;
        updatingComponents = false;&lt;br /&gt;
    }&lt;br /&gt;
    /**&lt;br /&gt;
     * Returns the data model that handles font selections.&lt;br /&gt;
     *&lt;br /&gt;
     * @return a FontSelectionModel object&lt;br /&gt;
     */&lt;br /&gt;
    public FontSelectionModel getSelectionModel() {&lt;br /&gt;
        return selectionModel;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    /**&lt;br /&gt;
     * Set the model containing the selected font.&lt;br /&gt;
     *&lt;br /&gt;
     * @param newModel   the new FontSelectionModel object&lt;br /&gt;
     */&lt;br /&gt;
    public void setSelectionModel(FontSelectionModel newModel ) {&lt;br /&gt;
        FontSelectionModel oldModel = selectionModel;&lt;br /&gt;
        selectionModel = newModel;&lt;br /&gt;
        oldModel.removeChangeListener(labelUpdater);&lt;br /&gt;
        newModel.addChangeListener(labelUpdater);&lt;br /&gt;
        firePropertyChange(&amp;quot;selectionModel&amp;quot;, oldModel, newModel);&lt;br /&gt;
    }&lt;br /&gt;
    /**&lt;br /&gt;
     * Gets the current font value from the font chooser.&lt;br /&gt;
     *&lt;br /&gt;
     * @return the current font value of the font chooser&lt;br /&gt;
     */&lt;br /&gt;
    public Font getFont() {&lt;br /&gt;
        return selectionModel.getSelectedFont();&lt;br /&gt;
    }&lt;br /&gt;
    /**&lt;br /&gt;
     * Sets the current font of the font chooser to the specified font.&lt;br /&gt;
     * The &amp;lt;code&amp;gt;ColorSelectionModel&amp;lt;/code&amp;gt; will fire a &amp;lt;code&amp;gt;ChangeEvent&amp;lt;/code&amp;gt;&lt;br /&gt;
     * @param font the font to be set in the font chooser&lt;br /&gt;
     * @see JComponent#addPropertyChangeListener&lt;br /&gt;
     */&lt;br /&gt;
    public void setFont(Font font) {&lt;br /&gt;
        selectionModel.setSelectedFont(font);&lt;br /&gt;
    }&lt;br /&gt;
    /** Returns the preview text displayed in the preview component.&lt;br /&gt;
     * @return the preview text, if null the font name will be displayed&lt;br /&gt;
     */&lt;br /&gt;
    public String getPreviewText() {&lt;br /&gt;
        return previewText;&lt;br /&gt;
    }&lt;br /&gt;
    /** Sets the preview text displayed in the preview component.&lt;br /&gt;
     * @param previewText the preview text, if null the font name will be displayed&lt;br /&gt;
     */&lt;br /&gt;
    public void setPreviewText(String previewText) {&lt;br /&gt;
        this.previewText = previewText;&lt;br /&gt;
        previewLabel.setText(&amp;quot;&amp;quot;);&lt;br /&gt;
        updateComponents();&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
/*&lt;br /&gt;
 * Class which builds a font chooser dialog consisting of&lt;br /&gt;
 * a JFontChooser with &amp;quot;Ok&amp;quot;, &amp;quot;Cancel&amp;quot;, and &amp;quot;Reset&amp;quot; buttons.&lt;br /&gt;
 *&lt;br /&gt;
 * Note: This needs to be fixed to deal with localization!&lt;br /&gt;
 */&lt;br /&gt;
class FontChooserDialog extends JDialog {&lt;br /&gt;
    private Font initialFont;&lt;br /&gt;
    private JFontChooser chooserPane;&lt;br /&gt;
    public FontChooserDialog(Component c, String title, boolean modal,&lt;br /&gt;
              JFontChooser chooserPane,&lt;br /&gt;
              ActionListener okListener, ActionListener cancelListener) {&lt;br /&gt;
        super(JOptionPane.getFrameForComponent(c), title, modal);&lt;br /&gt;
        //setResizable(false);&lt;br /&gt;
        String okString = UIManager.getString(&amp;quot;ColorChooser.okText&amp;quot;);&lt;br /&gt;
        String cancelString = UIManager.getString(&amp;quot;ColorChooser.cancelText&amp;quot;);&lt;br /&gt;
        String resetString = UIManager.getString(&amp;quot;ColorChooser.resetText&amp;quot;);&lt;br /&gt;
        /*&lt;br /&gt;
         * Create Lower button panel&lt;br /&gt;
         */&lt;br /&gt;
        JPanel buttonPane = new JPanel();&lt;br /&gt;
        buttonPane.setLayout(new FlowLayout(FlowLayout.CENTER));&lt;br /&gt;
        JButton okButton = new JButton(okString);&lt;br /&gt;
        getRootPane().setDefaultButton(okButton);&lt;br /&gt;
        okButton.setActionCommand(&amp;quot;OK&amp;quot;);&lt;br /&gt;
        if (okListener != null) {&lt;br /&gt;
            okButton.addActionListener(okListener);&lt;br /&gt;
        }&lt;br /&gt;
        okButton.addActionListener(new ActionListener() {&lt;br /&gt;
            public void actionPerformed(ActionEvent e) {&lt;br /&gt;
                setVisible(false);&lt;br /&gt;
            }&lt;br /&gt;
        });&lt;br /&gt;
        buttonPane.add(okButton);&lt;br /&gt;
        JButton cancelButton = new JButton(cancelString);&lt;br /&gt;
        // The following few lines are used to register esc to close the dialog&lt;br /&gt;
        Action cancelKeyAction = new AbstractAction() {&lt;br /&gt;
            public void actionPerformed(ActionEvent e) {&lt;br /&gt;
                // todo make it in 1.3&lt;br /&gt;
//                ActionListener[] listeners&lt;br /&gt;
//                        = ((AbstractButton) e.getSource()).getActionListeners();&lt;br /&gt;
//                for (int i = 0; i &amp;lt; listeners.length; i++) {&lt;br /&gt;
//                    listeners[i].actionPerformed(e);&lt;br /&gt;
//                }&lt;br /&gt;
            }&lt;br /&gt;
        };&lt;br /&gt;
        KeyStroke cancelKeyStroke = KeyStroke.getKeyStroke((char) KeyEvent.VK_ESCAPE);&lt;br /&gt;
        InputMap inputMap = cancelButton.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);&lt;br /&gt;
        ActionMap actionMap = cancelButton.getActionMap();&lt;br /&gt;
        if (inputMap != null &amp;amp;&amp;amp; actionMap != null) {&lt;br /&gt;
            inputMap.put(cancelKeyStroke, &amp;quot;cancel&amp;quot;);&lt;br /&gt;
            actionMap.put(&amp;quot;cancel&amp;quot;, cancelKeyAction);&lt;br /&gt;
        }&lt;br /&gt;
        // end esc handling&lt;br /&gt;
        cancelButton.setActionCommand(&amp;quot;cancel&amp;quot;);&lt;br /&gt;
        if (cancelListener != null) {&lt;br /&gt;
            cancelButton.addActionListener(cancelListener);&lt;br /&gt;
        }&lt;br /&gt;
        cancelButton.addActionListener(new ActionListener() {&lt;br /&gt;
            public void actionPerformed(ActionEvent e) {&lt;br /&gt;
                setVisible(false);&lt;br /&gt;
            }&lt;br /&gt;
        });&lt;br /&gt;
        buttonPane.add(cancelButton);&lt;br /&gt;
        JButton resetButton = new JButton(resetString);&lt;br /&gt;
        resetButton.addActionListener(new ActionListener() {&lt;br /&gt;
            public void actionPerformed(ActionEvent e) {&lt;br /&gt;
                reset();&lt;br /&gt;
            }&lt;br /&gt;
        });&lt;br /&gt;
        int mnemonic = UIManager.getInt(&amp;quot;ColorChooser.resetMnemonic&amp;quot;);&lt;br /&gt;
        if (mnemonic != -1) {&lt;br /&gt;
            resetButton.setMnemonic(mnemonic);&lt;br /&gt;
        }&lt;br /&gt;
        buttonPane.add(resetButton);&lt;br /&gt;
&lt;br /&gt;
        // initialiase the content pane&lt;br /&gt;
        this.chooserPane = chooserPane;&lt;br /&gt;
        Container contentPane = getContentPane();&lt;br /&gt;
        contentPane.setLayout(new BorderLayout());&lt;br /&gt;
        contentPane.add(chooserPane, BorderLayout.CENTER);&lt;br /&gt;
        contentPane.add(buttonPane, BorderLayout.SOUTH);&lt;br /&gt;
        pack();&lt;br /&gt;
        setLocationRelativeTo(c);&lt;br /&gt;
    }&lt;br /&gt;
    public void setVisible(boolean visible) {&lt;br /&gt;
        if (visible)&lt;br /&gt;
            initialFont = chooserPane.getFont();&lt;br /&gt;
        super.setVisible(visible);&lt;br /&gt;
    }&lt;br /&gt;
    public void reset() {&lt;br /&gt;
        chooserPane.setFont(initialFont);&lt;br /&gt;
    }&lt;br /&gt;
    static class Closer extends WindowAdapter implements Serializable {&lt;br /&gt;
        public void windowClosing(WindowEvent e) {&lt;br /&gt;
            Window w = e.getWindow();&lt;br /&gt;
            w.setVisible(false);&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
    static class DisposeOnClose extends ComponentAdapter implements Serializable {&lt;br /&gt;
        public void componentHidden(ComponentEvent e) {&lt;br /&gt;
            Window w = (Window) e.getComponent();&lt;br /&gt;
            w.dispose();&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
class FontTracker implements ActionListener, Serializable {&lt;br /&gt;
    JFontChooser chooser;&lt;br /&gt;
    Font color;&lt;br /&gt;
    public FontTracker(JFontChooser c) {&lt;br /&gt;
        chooser = c;&lt;br /&gt;
    }&lt;br /&gt;
    public void actionPerformed(ActionEvent e) {&lt;br /&gt;
        color = chooser.getFont();&lt;br /&gt;
    }&lt;br /&gt;
    public Font getFont() {&lt;br /&gt;
        return color;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
/**&lt;br /&gt;
 * A generic implementation of &amp;lt;code&amp;gt;{@link FontSelectionModel}&amp;lt;/code&amp;gt;.&lt;br /&gt;
 *&lt;br /&gt;
 * @author Adrian BER&lt;br /&gt;
 */&lt;br /&gt;
class DefaultFontSelectionModel implements FontSelectionModel {&lt;br /&gt;
    /** The default selected font. */&lt;br /&gt;
    private static final Font DEFAULT_INITIAL_FONT = new Font(&amp;quot;Dialog&amp;quot;, Font.PLAIN, 12);&lt;br /&gt;
    &lt;br /&gt;
    /** The selected font. */&lt;br /&gt;
    private Font selectedFont;&lt;br /&gt;
    /** The change listeners notified by a change in this model. */&lt;br /&gt;
    private EventListenerList listeners = new EventListenerList();&lt;br /&gt;
    /**&lt;br /&gt;
     * Creates a &amp;lt;code&amp;gt;DefaultFontSelectionModel&amp;lt;/code&amp;gt; with the&lt;br /&gt;
     * current font set to &amp;lt;code&amp;gt;Dialog, 12&amp;lt;/code&amp;gt;.  This is&lt;br /&gt;
     * the default constructor.&lt;br /&gt;
     */&lt;br /&gt;
    public DefaultFontSelectionModel() {&lt;br /&gt;
        this(DEFAULT_INITIAL_FONT);&lt;br /&gt;
    }&lt;br /&gt;
    /**&lt;br /&gt;
     * Creates a &amp;lt;code&amp;gt;DefaultFontSelectionModel&amp;lt;/code&amp;gt; with the&lt;br /&gt;
     * current font set to &amp;lt;code&amp;gt;font&amp;lt;/code&amp;gt;, which should be&lt;br /&gt;
     * non-&amp;lt;code&amp;gt;null&amp;lt;/code&amp;gt;.  Note that setting the font to&lt;br /&gt;
     * &amp;lt;code&amp;gt;null&amp;lt;/code&amp;gt; is undefined and may have unpredictable&lt;br /&gt;
     * results.&lt;br /&gt;
     *&lt;br /&gt;
     * @param selectedFont the new &amp;lt;code&amp;gt;Font&amp;lt;/code&amp;gt;&lt;br /&gt;
     */&lt;br /&gt;
    public DefaultFontSelectionModel(Font selectedFont) {&lt;br /&gt;
        if (selectedFont == null) {&lt;br /&gt;
            selectedFont = DEFAULT_INITIAL_FONT;&lt;br /&gt;
        }&lt;br /&gt;
        this.selectedFont = selectedFont;&lt;br /&gt;
    }&lt;br /&gt;
    public Font getSelectedFont() {&lt;br /&gt;
        return selectedFont;&lt;br /&gt;
    }&lt;br /&gt;
    public void setSelectedFont(Font selectedFont) {&lt;br /&gt;
        if (selectedFont != null) {&lt;br /&gt;
            this.selectedFont = selectedFont;&lt;br /&gt;
            fireChangeListeners();&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
    public void addChangeListener(ChangeListener listener) {&lt;br /&gt;
        listeners.add(ChangeListener.class, listener);&lt;br /&gt;
    }&lt;br /&gt;
    public void removeChangeListener(ChangeListener listener) {&lt;br /&gt;
        listeners.remove(ChangeListener.class, listener);&lt;br /&gt;
    }&lt;br /&gt;
    /** Fires the listeners registered with this model. */&lt;br /&gt;
    protected void fireChangeListeners() {&lt;br /&gt;
        ChangeEvent ev = new ChangeEvent(this);&lt;br /&gt;
        Object[] l = listeners.getListeners(ChangeListener.class);&lt;br /&gt;
        for (Object listener : l) {&lt;br /&gt;
            ((ChangeListener) listener).stateChanged(ev);&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
/**&lt;br /&gt;
 * A model that supports selecting a &amp;lt;code&amp;gt;Font&amp;lt;/code&amp;gt;.&lt;br /&gt;
 *&lt;br /&gt;
 * @author Adrian BER&lt;br /&gt;
 *&lt;br /&gt;
 * @see java.awt.Font&lt;br /&gt;
 */&lt;br /&gt;
interface FontSelectionModel {&lt;br /&gt;
    /**&lt;br /&gt;
     * Returns the selected &amp;lt;code&amp;gt;Font&amp;lt;/code&amp;gt; which should be&lt;br /&gt;
     * non-&amp;lt;code&amp;gt;null&amp;lt;/code&amp;gt;.&lt;br /&gt;
     *&lt;br /&gt;
     * @return  the selected &amp;lt;code&amp;gt;Font&amp;lt;/code&amp;gt;&lt;br /&gt;
     * @see     #setSelectedFont&lt;br /&gt;
     */&lt;br /&gt;
    Font getSelectedFont();&lt;br /&gt;
    /**&lt;br /&gt;
     * Sets the selected font to &amp;lt;code&amp;gt;font&amp;lt;/code&amp;gt;.&lt;br /&gt;
     * Note that setting the font to &amp;lt;code&amp;gt;null&amp;lt;/code&amp;gt;&lt;br /&gt;
     * is undefined and may have unpredictable results.&lt;br /&gt;
     * This method fires a state changed event if it sets the&lt;br /&gt;
     * current font to a new non-&amp;lt;code&amp;gt;null&amp;lt;/code&amp;gt; font.&lt;br /&gt;
     *&lt;br /&gt;
     * @param font the new &amp;lt;code&amp;gt;Font&amp;lt;/code&amp;gt;&lt;br /&gt;
     * @see   #getSelectedFont&lt;br /&gt;
     * @see   #addChangeListener&lt;br /&gt;
     */&lt;br /&gt;
    void setSelectedFont(Font font);&lt;br /&gt;
    /**&lt;br /&gt;
     * Adds &amp;lt;code&amp;gt;listener&amp;lt;/code&amp;gt; as a listener to changes in the model.&lt;br /&gt;
     * @param listener the &amp;lt;code&amp;gt;ChangeListener&amp;lt;/code&amp;gt; to be added&lt;br /&gt;
     */&lt;br /&gt;
    void addChangeListener(ChangeListener listener);&lt;br /&gt;
    /**&lt;br /&gt;
     * Removes &amp;lt;code&amp;gt;listener&amp;lt;/code&amp;gt; as a listener to changes in the model.&lt;br /&gt;
     * @param listener the &amp;lt;code&amp;gt;ChangeListener&amp;lt;/code&amp;gt; to be removed&lt;br /&gt;
     */&lt;br /&gt;
    void removeChangeListener(ChangeListener listener);&lt;br /&gt;
}&lt;br /&gt;
//////////////////////////////&lt;br /&gt;
package com.greef.ui.font;&lt;br /&gt;
import com.greef.ui.UIUtilities;&lt;br /&gt;
import javax.swing.*;&lt;br /&gt;
import javax.swing.event.ChangeListener;&lt;br /&gt;
import javax.swing.event.ChangeEvent;&lt;br /&gt;
import javax.swing.event.DocumentListener;&lt;br /&gt;
import javax.swing.event.DocumentEvent;&lt;br /&gt;
import java.awt.*;&lt;br /&gt;
import java.awt.event.ActionListener;&lt;br /&gt;
import java.awt.event.ActionEvent;&lt;br /&gt;
/**&lt;br /&gt;
 * @author Adrian BER (beradrian@yahoo.ru)&lt;br /&gt;
 */&lt;br /&gt;
public class JFontChooserDemo extends JPanel {&lt;br /&gt;
    private static final Insets INSETS = new Insets(5, 5, 5, 5);&lt;br /&gt;
    private JFontChooser fontChooser;&lt;br /&gt;
    private JCheckBox defaultPreviewCheckBox;&lt;br /&gt;
    private JTextField previewTextField;&lt;br /&gt;
    private JLabel previewLabel;&lt;br /&gt;
    private JTextArea codeTextArea;&lt;br /&gt;
    public JFontChooserDemo() {&lt;br /&gt;
        init();&lt;br /&gt;
    }&lt;br /&gt;
    private void init() {&lt;br /&gt;
        setLayout(new GridBagLayout());&lt;br /&gt;
        defaultPreviewCheckBox = new JCheckBox(&amp;quot;Use font name as the preview text&amp;quot;);&lt;br /&gt;
        defaultPreviewCheckBox.addChangeListener(new ChangeListener() {&lt;br /&gt;
            public void stateChanged(ChangeEvent e) {&lt;br /&gt;
                boolean selected = defaultPreviewCheckBox.isSelected();&lt;br /&gt;
                fontChooser.setPreviewText(selected ? null : previewTextField.getText());&lt;br /&gt;
                previewLabel.setEnabled(!selected);&lt;br /&gt;
                previewTextField.setEnabled(!selected);&lt;br /&gt;
                updateCode();&lt;br /&gt;
            }&lt;br /&gt;
        });&lt;br /&gt;
        add(defaultPreviewCheckBox, new GridBagConstraints(0, 0, 2, 1, 0, 0, GridBagConstraints.WEST,&lt;br /&gt;
                GridBagConstraints.NONE, INSETS, 0, 0));&lt;br /&gt;
        previewLabel = new JLabel(&amp;quot;Preview text:&amp;quot;);&lt;br /&gt;
        add(previewLabel, new GridBagConstraints(0, 1, 1, 1, 0, 0, GridBagConstraints.EAST,&lt;br /&gt;
                GridBagConstraints.NONE, INSETS, 0, 0));&lt;br /&gt;
        previewTextField = new JTextField();&lt;br /&gt;
        previewTextField.getDocument().addDocumentListener(new DocumentListener() {&lt;br /&gt;
            private void changePreviewText() {&lt;br /&gt;
                fontChooser.setPreviewText(previewTextField.getText());&lt;br /&gt;
                updateCode();&lt;br /&gt;
            }&lt;br /&gt;
            public void insertUpdate(DocumentEvent e) {&lt;br /&gt;
                changePreviewText();&lt;br /&gt;
            }&lt;br /&gt;
            public void removeUpdate(DocumentEvent e) {&lt;br /&gt;
                changePreviewText();&lt;br /&gt;
            }&lt;br /&gt;
            public void changedUpdate(DocumentEvent e) {&lt;br /&gt;
                changePreviewText();&lt;br /&gt;
            }&lt;br /&gt;
        });&lt;br /&gt;
        add(previewTextField, new GridBagConstraints(1, 1, 1, 1, 1, 0, GridBagConstraints.WEST,&lt;br /&gt;
                GridBagConstraints.HORIZONTAL, INSETS, 0, 0));&lt;br /&gt;
        JButton testButton = new JButton(&amp;quot;Test&amp;quot;);&lt;br /&gt;
        testButton.addActionListener(new ActionListener() {&lt;br /&gt;
            public void actionPerformed(ActionEvent e) {&lt;br /&gt;
                Font font = fontChooser.showDialog(JFontChooserDemo.this, &amp;quot;Choose a font&amp;quot;);&lt;br /&gt;
                JOptionPane.showMessageDialog(JFontChooserDemo.this, font == null ? &amp;quot;You canceled the dialog.&amp;quot;&lt;br /&gt;
                        : &amp;quot;You have selected &amp;quot; + font.getName() + &amp;quot;, &amp;quot; + font.getSize()&lt;br /&gt;
                        + (font.isBold() ? &amp;quot;, Bold&amp;quot; : &amp;quot;&amp;quot;) + (font.isItalic() ? &amp;quot;, Italic&amp;quot; : &amp;quot;&amp;quot;));&lt;br /&gt;
            }&lt;br /&gt;
        });&lt;br /&gt;
        add(testButton, new GridBagConstraints(0, 2, 2, 1, 1, 0, GridBagConstraints.NORTHEAST,&lt;br /&gt;
                GridBagConstraints.NONE, INSETS, 0, 0));&lt;br /&gt;
        codeTextArea = new JTextArea(5, 30);&lt;br /&gt;
        codeTextArea.setOpaque(false);&lt;br /&gt;
        codeTextArea.setEditable(false);&lt;br /&gt;
        codeTextArea.setBorder(BorderFactory.createTitledBorder(&amp;quot;Code&amp;quot;));&lt;br /&gt;
        add(codeTextArea, new GridBagConstraints(0, 3, 2, 1, 1, 1, GridBagConstraints.CENTER,&lt;br /&gt;
                GridBagConstraints.BOTH, INSETS, 0, 0));&lt;br /&gt;
        setFontChooser(new JFontChooser());&lt;br /&gt;
    }&lt;br /&gt;
    private void setFontChooser(JFontChooser fontChooser) {&lt;br /&gt;
        this.fontChooser = fontChooser;&lt;br /&gt;
        String previewText = fontChooser.getPreviewText();&lt;br /&gt;
        defaultPreviewCheckBox.setSelected(previewText == null);&lt;br /&gt;
        previewTextField.setText(previewText);&lt;br /&gt;
        updateCode();&lt;br /&gt;
    }&lt;br /&gt;
    private void updateCode() {&lt;br /&gt;
        codeTextArea.setText(&amp;quot;JFontChooser fontChooser = new JFontChooser();\n&amp;quot;&lt;br /&gt;
                + (defaultPreviewCheckBox.isSelected() ? &amp;quot;&amp;quot; : &amp;quot;fontChooser.setPreviewText(\&amp;quot;&amp;quot;&lt;br /&gt;
                    + previewTextField.getText() + &amp;quot;\&amp;quot;);\n&amp;quot;)&lt;br /&gt;
                + &amp;quot;Font font = fontChooser.showDialog(invokerComponent, \&amp;quot;Choose a font\&amp;quot;);\n&amp;quot;&lt;br /&gt;
                + &amp;quot;System.out.println(font == null ? \&amp;quot;You have canceled the dialog.\&amp;quot; : \&amp;quot;You have selected \&amp;quot; + font);&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
    public void updateUI() {&lt;br /&gt;
        super.updateUI();&lt;br /&gt;
        if (fontChooser != null)&lt;br /&gt;
            SwingUtilities.updateComponentTreeUI(fontChooser);&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
   &lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== JFreeChart: Font Dialog ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Word like special font chooser ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
/*&lt;br /&gt;
 * @(#)Font2DTest.java  1.28 05/11/17&lt;br /&gt;
 * &lt;br /&gt;
 * Copyright (c) 2006 Sun Microsystems, Inc. All Rights Reserved.&lt;br /&gt;
 * &lt;br /&gt;
 * Redistribution and use in source and binary forms, with or without&lt;br /&gt;
 * modification, are permitted provided that the following conditions are met:&lt;br /&gt;
 * &lt;br /&gt;
 * -Redistribution of source code must retain the above copyright notice, this&lt;br /&gt;
 *  list of conditions and the following disclaimer.&lt;br /&gt;
 * &lt;br /&gt;
 * -Redistribution in binary form must reproduce the above copyright notice, &lt;br /&gt;
 *  this list of conditions and the following disclaimer in the documentation&lt;br /&gt;
 *  and/or other materials provided with the distribution.&lt;br /&gt;
 * &lt;br /&gt;
 * Neither the name of Sun Microsystems, Inc. or the names of contributors may &lt;br /&gt;
 * be used to endorse or promote products derived from this software without &lt;br /&gt;
 * specific prior written permission.&lt;br /&gt;
 * &lt;br /&gt;
 * This software is provided &amp;quot;AS IS,&amp;quot; without a warranty of any kind. ALL &lt;br /&gt;
 * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING&lt;br /&gt;
 * ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE&lt;br /&gt;
 * OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN MIDROSYSTEMS, INC. (&amp;quot;SUN&amp;quot;)&lt;br /&gt;
 * AND ITS LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE&lt;br /&gt;
 * AS A RESULT OF USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS&lt;br /&gt;
 * DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR ANY LOST &lt;br /&gt;
 * REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, &lt;br /&gt;
 * INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY &lt;br /&gt;
 * OF LIABILITY, ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, &lt;br /&gt;
 * EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.&lt;br /&gt;
 * &lt;br /&gt;
 * You acknowledge that this software is not designed, licensed or intended&lt;br /&gt;
 * for use in the design, construction, operation or maintenance of any&lt;br /&gt;
 * nuclear facility.&lt;br /&gt;
 */&lt;br /&gt;
/*&lt;br /&gt;
 * @(#)Font2DTest.java  1.28 05/11/17&lt;br /&gt;
 */&lt;br /&gt;
import static java.awt.RenderingHints.KEY_ANTIALIASING;&lt;br /&gt;
import static java.awt.RenderingHints.KEY_FRACTIONALMETRICS;&lt;br /&gt;
import static java.awt.RenderingHints.KEY_TEXT_ANTIALIASING;&lt;br /&gt;
import static java.awt.RenderingHints.KEY_TEXT_LCD_CONTRAST;&lt;br /&gt;
import static java.awt.RenderingHints.VALUE_ANTIALIAS_OFF;&lt;br /&gt;
import static java.awt.RenderingHints.VALUE_ANTIALIAS_ON;&lt;br /&gt;
import static java.awt.RenderingHints.VALUE_FRACTIONALMETRICS_DEFAULT;&lt;br /&gt;
import static java.awt.RenderingHints.VALUE_FRACTIONALMETRICS_OFF;&lt;br /&gt;
import static java.awt.RenderingHints.VALUE_FRACTIONALMETRICS_ON;&lt;br /&gt;
import static java.awt.RenderingHints.VALUE_TEXT_ANTIALIAS_DEFAULT;&lt;br /&gt;
import static java.awt.RenderingHints.VALUE_TEXT_ANTIALIAS_GASP;&lt;br /&gt;
import static java.awt.RenderingHints.VALUE_TEXT_ANTIALIAS_LCD_HBGR;&lt;br /&gt;
import static java.awt.RenderingHints.VALUE_TEXT_ANTIALIAS_LCD_HRGB;&lt;br /&gt;
import static java.awt.RenderingHints.VALUE_TEXT_ANTIALIAS_LCD_VBGR;&lt;br /&gt;
import static java.awt.RenderingHints.VALUE_TEXT_ANTIALIAS_LCD_VRGB;&lt;br /&gt;
import static java.awt.RenderingHints.VALUE_TEXT_ANTIALIAS_OFF;&lt;br /&gt;
import static java.awt.RenderingHints.VALUE_TEXT_ANTIALIAS_ON;&lt;br /&gt;
import java.awt.BorderLayout;&lt;br /&gt;
import java.awt.Color;&lt;br /&gt;
import java.awt.ruponent;&lt;br /&gt;
import java.awt.Container;&lt;br /&gt;
import java.awt.Cursor;&lt;br /&gt;
import java.awt.Dimension;&lt;br /&gt;
import java.awt.Font;&lt;br /&gt;
import java.awt.FontMetrics;&lt;br /&gt;
import java.awt.Graphics;&lt;br /&gt;
import java.awt.Graphics2D;&lt;br /&gt;
import java.awt.GraphicsConfiguration;&lt;br /&gt;
import java.awt.GraphicsEnvironment;&lt;br /&gt;
import java.awt.GridBagConstraints;&lt;br /&gt;
import java.awt.GridBagLayout;&lt;br /&gt;
import java.awt.GridLayout;&lt;br /&gt;
import java.awt.Insets;&lt;br /&gt;
import java.awt.Point;&lt;br /&gt;
import java.awt.RenderingHints;&lt;br /&gt;
import java.awt.Toolkit;&lt;br /&gt;
import java.awt.event.ActionEvent;&lt;br /&gt;
import java.awt.event.ActionListener;&lt;br /&gt;
import java.awt.event.AdjustmentEvent;&lt;br /&gt;
import java.awt.event.AdjustmentListener;&lt;br /&gt;
import java.awt.event.ruponentAdapter;&lt;br /&gt;
import java.awt.event.ruponentEvent;&lt;br /&gt;
import java.awt.event.ItemEvent;&lt;br /&gt;
import java.awt.event.ItemListener;&lt;br /&gt;
import java.awt.event.MouseEvent;&lt;br /&gt;
import java.awt.event.MouseListener;&lt;br /&gt;
import java.awt.event.MouseMotionListener;&lt;br /&gt;
import java.awt.event.WindowAdapter;&lt;br /&gt;
import java.awt.event.WindowEvent;&lt;br /&gt;
import java.awt.font.FontRenderContext;&lt;br /&gt;
import java.awt.font.GlyphVector;&lt;br /&gt;
import java.awt.font.LineBreakMeasurer;&lt;br /&gt;
import java.awt.font.TextLayout;&lt;br /&gt;
import java.awt.geom.AffineTransform;&lt;br /&gt;
import java.awt.geom.NoninvertibleTransformException;&lt;br /&gt;
import java.awt.geom.Rectangle2D;&lt;br /&gt;
import java.awt.image.BufferedImage;&lt;br /&gt;
import java.awt.print.PageFormat;&lt;br /&gt;
import java.awt.print.Printable;&lt;br /&gt;
import java.awt.print.PrinterJob;&lt;br /&gt;
import java.io.BufferedInputStream;&lt;br /&gt;
import java.io.BufferedOutputStream;&lt;br /&gt;
import java.io.File;&lt;br /&gt;
import java.io.FileInputStream;&lt;br /&gt;
import java.io.FileOutputStream;&lt;br /&gt;
import java.text.AttributedString;&lt;br /&gt;
import java.util.BitSet;&lt;br /&gt;
import java.util.EnumSet;&lt;br /&gt;
import java.util.StringTokenizer;&lt;br /&gt;
import java.util.Vector;&lt;br /&gt;
import javax.imageio.ImageIO;&lt;br /&gt;
import javax.swing.ButtonGroup;&lt;br /&gt;
import javax.swing.DefaultListCellRenderer;&lt;br /&gt;
import javax.swing.ImageIcon;&lt;br /&gt;
import javax.swing.JButton;&lt;br /&gt;
import javax.swing.JCheckBoxMenuItem;&lt;br /&gt;
import javax.swing.JComboBox;&lt;br /&gt;
import javax.swing.JComponent;&lt;br /&gt;
import javax.swing.JDialog;&lt;br /&gt;
import javax.swing.JFileChooser;&lt;br /&gt;
import javax.swing.JFrame;&lt;br /&gt;
import javax.swing.JLabel;&lt;br /&gt;
import javax.swing.JList;&lt;br /&gt;
import javax.swing.JMenu;&lt;br /&gt;
import javax.swing.JMenuBar;&lt;br /&gt;
import javax.swing.JMenuItem;&lt;br /&gt;
import javax.swing.JPanel;&lt;br /&gt;
import javax.swing.JRadioButton;&lt;br /&gt;
import javax.swing.JScrollBar;&lt;br /&gt;
import javax.swing.JScrollPane;&lt;br /&gt;
import javax.swing.JSlider;&lt;br /&gt;
import javax.swing.JTextArea;&lt;br /&gt;
import javax.swing.JTextField;&lt;br /&gt;
import javax.swing.JWindow;&lt;br /&gt;
import javax.swing.UIManager;&lt;br /&gt;
import javax.swing.event.ChangeEvent;&lt;br /&gt;
import javax.swing.event.ChangeListener;&lt;br /&gt;
/**&lt;br /&gt;
 * Font2DTest.java&lt;br /&gt;
 * &lt;br /&gt;
 * @version&lt;br /&gt;
 * @(#)Font2DTest.java 1.2 00/08/22&lt;br /&gt;
 * @author Shinsuke Fukuda&lt;br /&gt;
 * @author Ankit Patel [Conversion to Swing - 01/07/30]&lt;br /&gt;
 */&lt;br /&gt;
// / Main Font2DTest Class&lt;br /&gt;
public final class Font2DTest extends JPanel implements ActionListener, ItemListener,&lt;br /&gt;
    ChangeListener {&lt;br /&gt;
  // / JFrame that will contain Font2DTest&lt;br /&gt;
  private final JFrame parent;&lt;br /&gt;
  // / FontPanel class that will contain all graphical output&lt;br /&gt;
  private final FontPanel fp;&lt;br /&gt;
  // / RangeMenu class that contains info about the unicode ranges&lt;br /&gt;
  private final RangeMenu rm;&lt;br /&gt;
  // / Other menus to set parameters for text drawing&lt;br /&gt;
  private final ChoiceV2 fontMenu;&lt;br /&gt;
  private final JTextField sizeField;&lt;br /&gt;
  private final ChoiceV2 styleMenu;&lt;br /&gt;
  private final ChoiceV2 textMenu;&lt;br /&gt;
  private int currentTextChoice = 0;&lt;br /&gt;
  private final ChoiceV2 transformMenu;&lt;br /&gt;
  private final ChoiceV2 transformMenuG2;&lt;br /&gt;
  private final ChoiceV2 methodsMenu;&lt;br /&gt;
  private final JComboBox antiAliasMenu;&lt;br /&gt;
  private final JComboBox fracMetricsMenu;&lt;br /&gt;
  private final JSlider contrastSlider;&lt;br /&gt;
  // / CheckboxMenuItems&lt;br /&gt;
  private CheckboxMenuItemV2 displayGridCBMI;&lt;br /&gt;
  private CheckboxMenuItemV2 force16ColsCBMI;&lt;br /&gt;
  private CheckboxMenuItemV2 showFontInfoCBMI;&lt;br /&gt;
  // / JDialog boxes&lt;br /&gt;
  private JDialog userTextDialog;&lt;br /&gt;
  private JTextArea userTextArea;&lt;br /&gt;
  private JDialog printDialog;&lt;br /&gt;
  private JDialog fontInfoDialog;&lt;br /&gt;
  private LabelV2 fontInfos[] = new LabelV2[2];&lt;br /&gt;
  private JFileChooser filePromptDialog = null;&lt;br /&gt;
  private ButtonGroup printCBGroup;&lt;br /&gt;
  private JRadioButton printModeCBs[] = new JRadioButton[3];&lt;br /&gt;
  // / Status bar&lt;br /&gt;
  private final LabelV2 statusBar;&lt;br /&gt;
  private int fontStyles[] = { Font.PLAIN, Font.BOLD, Font.ITALIC, Font.BOLD | Font.ITALIC };&lt;br /&gt;
  // / Text filename&lt;br /&gt;
  private String tFileName;&lt;br /&gt;
  // Enabled or disabled status of canDisplay check&lt;br /&gt;
  private static boolean canDisplayCheck = true;&lt;br /&gt;
  // / Initialize GUI variables and its layouts&lt;br /&gt;
  public Font2DTest(JFrame f, boolean isApplet) {&lt;br /&gt;
    parent = f;&lt;br /&gt;
    rm = new RangeMenu(this, parent);&lt;br /&gt;
    fp = new FontPanel(this, parent);&lt;br /&gt;
    statusBar = new LabelV2(&amp;quot;&amp;quot;);&lt;br /&gt;
    fontMenu = new ChoiceV2(this, canDisplayCheck);&lt;br /&gt;
    sizeField = new JTextField(&amp;quot;12&amp;quot;, 3);&lt;br /&gt;
    sizeField.addActionListener(this);&lt;br /&gt;
    styleMenu = new ChoiceV2(this);&lt;br /&gt;
    textMenu = new ChoiceV2(); // listener added later&lt;br /&gt;
    transformMenu = new ChoiceV2(this);&lt;br /&gt;
    transformMenuG2 = new ChoiceV2(this);&lt;br /&gt;
    methodsMenu = new ChoiceV2(this);&lt;br /&gt;
    antiAliasMenu = new JComboBox(EnumSet.allOf(FontPanel.AAValues.class).toArray());&lt;br /&gt;
    antiAliasMenu.addActionListener(this);&lt;br /&gt;
    fracMetricsMenu = new JComboBox(EnumSet.allOf(FontPanel.FMValues.class).toArray());&lt;br /&gt;
    fracMetricsMenu.addActionListener(this);&lt;br /&gt;
    contrastSlider = new JSlider(JSlider.HORIZONTAL, 100, 250, FontPanel.getDefaultLCDContrast()&lt;br /&gt;
        .intValue());&lt;br /&gt;
    contrastSlider.setEnabled(false);&lt;br /&gt;
    contrastSlider.setMajorTickSpacing(20);&lt;br /&gt;
    contrastSlider.setMinorTickSpacing(10);&lt;br /&gt;
    contrastSlider.setPaintTicks(true);&lt;br /&gt;
    contrastSlider.setPaintLabels(true);&lt;br /&gt;
    contrastSlider.addChangeListener(this);&lt;br /&gt;
    setupPanel();&lt;br /&gt;
    setupMenu(isApplet);&lt;br /&gt;
    setupDialog(isApplet);&lt;br /&gt;
    if (canDisplayCheck) {&lt;br /&gt;
      fireRangeChanged();&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
  // / Set up the main interface panel&lt;br /&gt;
  private void setupPanel() {&lt;br /&gt;
    GridBagLayout gbl = new GridBagLayout();&lt;br /&gt;
    GridBagConstraints gbc = new GridBagConstraints();&lt;br /&gt;
    gbc.fill = GridBagConstraints.HORIZONTAL;&lt;br /&gt;
    gbc.weightx = 1;&lt;br /&gt;
    gbc.insets = new Insets(2, 0, 2, 2);&lt;br /&gt;
    this.setLayout(gbl);&lt;br /&gt;
    addLabeledComponentToGBL(&amp;quot;Font: &amp;quot;, fontMenu, gbl, gbc, this);&lt;br /&gt;
    addLabeledComponentToGBL(&amp;quot;Size: &amp;quot;, sizeField, gbl, gbc, this);&lt;br /&gt;
    gbc.gridwidth = GridBagConstraints.REMAINDER;&lt;br /&gt;
    addLabeledComponentToGBL(&amp;quot;Font Transform:&amp;quot;, transformMenu, gbl, gbc, this);&lt;br /&gt;
    gbc.gridwidth = 1;&lt;br /&gt;
    addLabeledComponentToGBL(&amp;quot;Range: &amp;quot;, rm, gbl, gbc, this);&lt;br /&gt;
    addLabeledComponentToGBL(&amp;quot;Style: &amp;quot;, styleMenu, gbl, gbc, this);&lt;br /&gt;
    gbc.gridwidth = GridBagConstraints.REMAINDER;&lt;br /&gt;
    addLabeledComponentToGBL(&amp;quot;Graphics Transform: &amp;quot;, transformMenuG2, gbl, gbc, this);&lt;br /&gt;
    gbc.gridwidth = 1;&lt;br /&gt;
    gbc.anchor = GridBagConstraints.WEST;&lt;br /&gt;
    addLabeledComponentToGBL(&amp;quot;Method: &amp;quot;, methodsMenu, gbl, gbc, this);&lt;br /&gt;
    addLabeledComponentToGBL(&amp;quot;&amp;quot;, null, gbl, gbc, this);&lt;br /&gt;
    gbc.anchor = GridBagConstraints.EAST;&lt;br /&gt;
    gbc.gridwidth = GridBagConstraints.REMAINDER;&lt;br /&gt;
    addLabeledComponentToGBL(&amp;quot;Text to use:&amp;quot;, textMenu, gbl, gbc, this);&lt;br /&gt;
    gbc.weightx = 1;&lt;br /&gt;
    gbc.gridwidth = 1;&lt;br /&gt;
    gbc.fill = GridBagConstraints.HORIZONTAL;&lt;br /&gt;
    gbc.anchor = GridBagConstraints.WEST;&lt;br /&gt;
    addLabeledComponentToGBL(&amp;quot;LCD contrast: &amp;quot;, contrastSlider, gbl, gbc, this);&lt;br /&gt;
    gbc.gridwidth = 1;&lt;br /&gt;
    gbc.fill = GridBagConstraints.NONE;&lt;br /&gt;
    addLabeledComponentToGBL(&amp;quot;Antialiasing: &amp;quot;, antiAliasMenu, gbl, gbc, this);&lt;br /&gt;
    gbc.anchor = GridBagConstraints.EAST;&lt;br /&gt;
    gbc.gridwidth = GridBagConstraints.REMAINDER;&lt;br /&gt;
    addLabeledComponentToGBL(&amp;quot;Fractional metrics: &amp;quot;, fracMetricsMenu, gbl, gbc, this);&lt;br /&gt;
    gbc.weightx = 1;&lt;br /&gt;
    gbc.weighty = 1;&lt;br /&gt;
    gbc.anchor = GridBagConstraints.WEST;&lt;br /&gt;
    gbc.insets = new Insets(2, 0, 0, 2);&lt;br /&gt;
    gbc.fill = GridBagConstraints.BOTH;&lt;br /&gt;
    gbl.setConstraints(fp, gbc);&lt;br /&gt;
    this.add(fp);&lt;br /&gt;
    gbc.weighty = 0;&lt;br /&gt;
    gbc.insets = new Insets(0, 2, 0, 0);&lt;br /&gt;
    gbl.setConstraints(statusBar, gbc);&lt;br /&gt;
    this.add(statusBar);&lt;br /&gt;
  }&lt;br /&gt;
  // / Adds a component to a container with a label to its left in GridBagLayout&lt;br /&gt;
  private void addLabeledComponentToGBL(String name, JComponent c, GridBagLayout gbl,&lt;br /&gt;
      GridBagConstraints gbc, Container target) {&lt;br /&gt;
    LabelV2 l = new LabelV2(name);&lt;br /&gt;
    GridBagConstraints gbcLabel = (GridBagConstraints) gbc.clone();&lt;br /&gt;
    gbcLabel.insets = new Insets(2, 2, 2, 0);&lt;br /&gt;
    gbcLabel.gridwidth = 1;&lt;br /&gt;
    gbcLabel.weightx = 0;&lt;br /&gt;
    if (c == null)&lt;br /&gt;
      c = new JLabel(&amp;quot;&amp;quot;);&lt;br /&gt;
    gbl.setConstraints(l, gbcLabel);&lt;br /&gt;
    target.add(l);&lt;br /&gt;
    gbl.setConstraints(c, gbc);&lt;br /&gt;
    target.add(c);&lt;br /&gt;
  }&lt;br /&gt;
  // / Sets up menu entries&lt;br /&gt;
  private void setupMenu(boolean isApplet) {&lt;br /&gt;
    JMenu fileMenu = new JMenu(&amp;quot;File&amp;quot;);&lt;br /&gt;
    JMenu optionMenu = new JMenu(&amp;quot;Option&amp;quot;);&lt;br /&gt;
    fileMenu.add(new MenuItemV2(&amp;quot;Save Selected Options...&amp;quot;, this));&lt;br /&gt;
    fileMenu.add(new MenuItemV2(&amp;quot;Load Options...&amp;quot;, this));&lt;br /&gt;
    fileMenu.addSeparator();&lt;br /&gt;
    fileMenu.add(new MenuItemV2(&amp;quot;Save as PNG...&amp;quot;, this));&lt;br /&gt;
    fileMenu.add(new MenuItemV2(&amp;quot;Load PNG File to Compare...&amp;quot;, this));&lt;br /&gt;
    fileMenu.add(new MenuItemV2(&amp;quot;Page Setup...&amp;quot;, this));&lt;br /&gt;
    fileMenu.add(new MenuItemV2(&amp;quot;Print...&amp;quot;, this));&lt;br /&gt;
    fileMenu.addSeparator();&lt;br /&gt;
    if (!isApplet)&lt;br /&gt;
      fileMenu.add(new MenuItemV2(&amp;quot;Exit&amp;quot;, this));&lt;br /&gt;
    else&lt;br /&gt;
      fileMenu.add(new MenuItemV2(&amp;quot;Close&amp;quot;, this));&lt;br /&gt;
    displayGridCBMI = new CheckboxMenuItemV2(&amp;quot;Display Grid&amp;quot;, true, this);&lt;br /&gt;
    force16ColsCBMI = new CheckboxMenuItemV2(&amp;quot;Force 16 Columns&amp;quot;, false, this);&lt;br /&gt;
    showFontInfoCBMI = new CheckboxMenuItemV2(&amp;quot;Display Font Info&amp;quot;, false, this);&lt;br /&gt;
    optionMenu.add(displayGridCBMI);&lt;br /&gt;
    optionMenu.add(force16ColsCBMI);&lt;br /&gt;
    optionMenu.add(showFontInfoCBMI);&lt;br /&gt;
    JMenuBar mb = parent.getJMenuBar();&lt;br /&gt;
    if (mb == null)&lt;br /&gt;
      mb = new JMenuBar();&lt;br /&gt;
    mb.add(fileMenu);&lt;br /&gt;
    mb.add(optionMenu);&lt;br /&gt;
    parent.setJMenuBar(mb);&lt;br /&gt;
    String fontList[] = GraphicsEnvironment.getLocalGraphicsEnvironment()&lt;br /&gt;
        .getAvailableFontFamilyNames();&lt;br /&gt;
    for (int i = 0; i &amp;lt; fontList.length; i++)&lt;br /&gt;
      fontMenu.addItem(fontList[i]);&lt;br /&gt;
    fontMenu.setSelectedItem(&amp;quot;Dialog&amp;quot;);&lt;br /&gt;
    styleMenu.addItem(&amp;quot;Plain&amp;quot;);&lt;br /&gt;
    styleMenu.addItem(&amp;quot;Bold&amp;quot;);&lt;br /&gt;
    styleMenu.addItem(&amp;quot;Italic&amp;quot;);&lt;br /&gt;
    styleMenu.addItem(&amp;quot;Bold Italic&amp;quot;);&lt;br /&gt;
    transformMenu.addItem(&amp;quot;None&amp;quot;);&lt;br /&gt;
    transformMenu.addItem(&amp;quot;Scale&amp;quot;);&lt;br /&gt;
    transformMenu.addItem(&amp;quot;Shear&amp;quot;);&lt;br /&gt;
    transformMenu.addItem(&amp;quot;Rotate&amp;quot;);&lt;br /&gt;
    transformMenuG2.addItem(&amp;quot;None&amp;quot;);&lt;br /&gt;
    transformMenuG2.addItem(&amp;quot;Scale&amp;quot;);&lt;br /&gt;
    transformMenuG2.addItem(&amp;quot;Shear&amp;quot;);&lt;br /&gt;
    transformMenuG2.addItem(&amp;quot;Rotate&amp;quot;);&lt;br /&gt;
    methodsMenu.addItem(&amp;quot;drawString&amp;quot;);&lt;br /&gt;
    methodsMenu.addItem(&amp;quot;drawChars&amp;quot;);&lt;br /&gt;
    methodsMenu.addItem(&amp;quot;drawBytes&amp;quot;);&lt;br /&gt;
    methodsMenu.addItem(&amp;quot;drawGlyphVector&amp;quot;);&lt;br /&gt;
    methodsMenu.addItem(&amp;quot;TextLayout.draw&amp;quot;);&lt;br /&gt;
    methodsMenu.addItem(&amp;quot;GlyphVector.getOutline + draw&amp;quot;);&lt;br /&gt;
    methodsMenu.addItem(&amp;quot;TextLayout.getOutline + draw&amp;quot;);&lt;br /&gt;
    textMenu.addItem(&amp;quot;Unicode Range&amp;quot;);&lt;br /&gt;
    textMenu.addItem(&amp;quot;All Glyphs&amp;quot;);&lt;br /&gt;
    textMenu.addItem(&amp;quot;User Text&amp;quot;);&lt;br /&gt;
    textMenu.addItem(&amp;quot;Text File&amp;quot;);&lt;br /&gt;
    textMenu.addActionListener(this); // listener added later so unneeded events&lt;br /&gt;
                                      // not thrown&lt;br /&gt;
  }&lt;br /&gt;
  // / Sets up the all dialogs used in Font2DTest...&lt;br /&gt;
  private void setupDialog(boolean isApplet) {&lt;br /&gt;
    if (!isApplet)&lt;br /&gt;
      filePromptDialog = new JFileChooser();&lt;br /&gt;
    else&lt;br /&gt;
      filePromptDialog = null;&lt;br /&gt;
    // / Prepare user text dialog...&lt;br /&gt;
    userTextDialog = new JDialog(parent, &amp;quot;User Text&amp;quot;, false);&lt;br /&gt;
    JPanel dialogTopPanel = new JPanel();&lt;br /&gt;
    JPanel dialogBottomPanel = new JPanel();&lt;br /&gt;
    LabelV2 message1 = new LabelV2(&amp;quot;Enter text below and then press update&amp;quot;);&lt;br /&gt;
    LabelV2 message2 = new LabelV2(&amp;quot;(Unicode char can be denoted by \\uXXXX)&amp;quot;);&lt;br /&gt;
    LabelV2 message3 = new LabelV2(&amp;quot;(Supplementary chars can be denoted by \\UXXXXXX)&amp;quot;);&lt;br /&gt;
    userTextArea = new JTextArea(&amp;quot;Java2D!&amp;quot;);&lt;br /&gt;
    ButtonV2 bUpdate = new ButtonV2(&amp;quot;Update&amp;quot;, this);&lt;br /&gt;
    userTextArea.setFont(new Font(&amp;quot;dialog&amp;quot;, Font.PLAIN, 12));&lt;br /&gt;
    dialogTopPanel.setLayout(new GridLayout(3, 1));&lt;br /&gt;
    dialogTopPanel.add(message1);&lt;br /&gt;
    dialogTopPanel.add(message2);&lt;br /&gt;
    dialogTopPanel.add(message3);&lt;br /&gt;
    dialogBottomPanel.add(bUpdate);&lt;br /&gt;
    // ABP&lt;br /&gt;
    JScrollPane userTextAreaSP = new JScrollPane(userTextArea);&lt;br /&gt;
    userTextAreaSP.setPreferredSize(new Dimension(300, 100));&lt;br /&gt;
    userTextDialog.getContentPane().setLayout(new BorderLayout());&lt;br /&gt;
    userTextDialog.getContentPane().add(&amp;quot;North&amp;quot;, dialogTopPanel);&lt;br /&gt;
    userTextDialog.getContentPane().add(&amp;quot;Center&amp;quot;, userTextAreaSP);&lt;br /&gt;
    userTextDialog.getContentPane().add(&amp;quot;South&amp;quot;, dialogBottomPanel);&lt;br /&gt;
    userTextDialog.pack();&lt;br /&gt;
    userTextDialog.addWindowListener(new WindowAdapter() {&lt;br /&gt;
      public void windowClosing(WindowEvent e) {&lt;br /&gt;
        userTextDialog.hide();&lt;br /&gt;
      }&lt;br /&gt;
    });&lt;br /&gt;
    // / Prepare printing dialog...&lt;br /&gt;
    printCBGroup = new ButtonGroup();&lt;br /&gt;
    printModeCBs[fp.ONE_PAGE] = new JRadioButton(&lt;br /&gt;
        &amp;quot;Print one page from currently displayed character/line&amp;quot;, true);&lt;br /&gt;
    printModeCBs[fp.CUR_RANGE] = new JRadioButton(&lt;br /&gt;
        &amp;quot;Print all characters in currently selected range&amp;quot;, false);&lt;br /&gt;
    printModeCBs[fp.ALL_TEXT] = new JRadioButton(&amp;quot;Print all lines of text&amp;quot;, false);&lt;br /&gt;
    LabelV2 l = new LabelV2(&lt;br /&gt;
        &amp;quot;Note: Page range in native \&amp;quot;Print\&amp;quot; dialog will not affect the result&amp;quot;);&lt;br /&gt;
    JPanel buttonPanel = new JPanel();&lt;br /&gt;
    printModeCBs[fp.ALL_TEXT].setEnabled(false);&lt;br /&gt;
    buttonPanel.add(new ButtonV2(&amp;quot;Print&amp;quot;, this));&lt;br /&gt;
    buttonPanel.add(new ButtonV2(&amp;quot;Cancel&amp;quot;, this));&lt;br /&gt;
    printDialog = new JDialog(parent, &amp;quot;Print...&amp;quot;, true);&lt;br /&gt;
    printDialog.setResizable(false);&lt;br /&gt;
    printDialog.addWindowListener(new WindowAdapter() {&lt;br /&gt;
      public void windowClosing(WindowEvent e) {&lt;br /&gt;
        printDialog.hide();&lt;br /&gt;
      }&lt;br /&gt;
    });&lt;br /&gt;
    printDialog.getContentPane().setLayout(new GridLayout(printModeCBs.length + 2, 1));&lt;br /&gt;
    printDialog.getContentPane().add(l);&lt;br /&gt;
    for (int i = 0; i &amp;lt; printModeCBs.length; i++) {&lt;br /&gt;
      printCBGroup.add(printModeCBs[i]);&lt;br /&gt;
      printDialog.getContentPane().add(printModeCBs[i]);&lt;br /&gt;
    }&lt;br /&gt;
    printDialog.getContentPane().add(buttonPanel);&lt;br /&gt;
    printDialog.pack();&lt;br /&gt;
    // / Prepare font information dialog...&lt;br /&gt;
    fontInfoDialog = new JDialog(parent, &amp;quot;Font info&amp;quot;, false);&lt;br /&gt;
    fontInfoDialog.setResizable(false);&lt;br /&gt;
    fontInfoDialog.addWindowListener(new WindowAdapter() {&lt;br /&gt;
      public void windowClosing(WindowEvent e) {&lt;br /&gt;
        fontInfoDialog.hide();&lt;br /&gt;
        showFontInfoCBMI.setState(false);&lt;br /&gt;
      }&lt;br /&gt;
    });&lt;br /&gt;
    JPanel fontInfoPanel = new JPanel();&lt;br /&gt;
    fontInfoPanel.setLayout(new GridLayout(fontInfos.length, 1));&lt;br /&gt;
    for (int i = 0; i &amp;lt; fontInfos.length; i++) {&lt;br /&gt;
      fontInfos[i] = new LabelV2(&amp;quot;&amp;quot;);&lt;br /&gt;
      fontInfoPanel.add(fontInfos[i]);&lt;br /&gt;
    }&lt;br /&gt;
    fontInfoDialog.getContentPane().add(fontInfoPanel);&lt;br /&gt;
    // / Move the location of the dialog...&lt;br /&gt;
    userTextDialog.setLocation(200, 300);&lt;br /&gt;
    fontInfoDialog.setLocation(0, 400);&lt;br /&gt;
  }&lt;br /&gt;
  // / RangeMenu object signals using this function&lt;br /&gt;
  // / when Unicode range has been changed and text needs to be redrawn&lt;br /&gt;
  public void fireRangeChanged() {&lt;br /&gt;
    int range[] = rm.getSelectedRange();&lt;br /&gt;
    fp.setTextToDraw(fp.RANGE_TEXT, range, null, null);&lt;br /&gt;
    if (canDisplayCheck) {&lt;br /&gt;
      setupFontList(range[0], range[1]);&lt;br /&gt;
    }&lt;br /&gt;
    if (showFontInfoCBMI.getState())&lt;br /&gt;
      fireUpdateFontInfo();&lt;br /&gt;
  }&lt;br /&gt;
  // / Changes the message on the status bar&lt;br /&gt;
  public void fireChangeStatus(String message, boolean error) {&lt;br /&gt;
    // / If this is not ran as an applet, use own status bar,&lt;br /&gt;
    // / Otherwise, use the appletviewer/browser&amp;quot;s status bar&lt;br /&gt;
    statusBar.setText(message);&lt;br /&gt;
    if (error)&lt;br /&gt;
      fp.showingError = true;&lt;br /&gt;
    else&lt;br /&gt;
      fp.showingError = false;&lt;br /&gt;
  }&lt;br /&gt;
  // / Updates the information about the selected font&lt;br /&gt;
  public void fireUpdateFontInfo() {&lt;br /&gt;
    if (showFontInfoCBMI.getState()) {&lt;br /&gt;
      String infos[] = fp.getFontInfo();&lt;br /&gt;
      for (int i = 0; i &amp;lt; fontInfos.length; i++)&lt;br /&gt;
        fontInfos[i].setText(infos[i]);&lt;br /&gt;
      fontInfoDialog.pack();&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
  private void setupFontList(int rangeStart, int rangeEnd) {&lt;br /&gt;
    int listCount = fontMenu.getItemCount();&lt;br /&gt;
    int size = 16;&lt;br /&gt;
    try {&lt;br /&gt;
      size = Float.valueOf(sizeField.getText()).intValue();&lt;br /&gt;
    } catch (Exception e) {&lt;br /&gt;
      System.out.println(&amp;quot;Invalid font size in the size textField. Using default value of 16&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
    int style = fontStyles[styleMenu.getSelectedIndex()];&lt;br /&gt;
    Font f;&lt;br /&gt;
    for (int i = 0; i &amp;lt; listCount; i++) {&lt;br /&gt;
      String fontName = (String) fontMenu.getItemAt(i);&lt;br /&gt;
      f = new Font(fontName, style, size);&lt;br /&gt;
      if ((rm.getSelectedIndex() != RangeMenu.SURROGATES_AREA_INDEX)&lt;br /&gt;
          &amp;amp;&amp;amp; canDisplayRange(f, rangeStart, rangeEnd)) {&lt;br /&gt;
        fontMenu.setBit(i, true);&lt;br /&gt;
      } else {&lt;br /&gt;
        fontMenu.setBit(i, false);&lt;br /&gt;
      }&lt;br /&gt;
    }&lt;br /&gt;
    fontMenu.repaint();&lt;br /&gt;
  }&lt;br /&gt;
  protected boolean canDisplayRange(Font font, int rangeStart, int rangeEnd) {&lt;br /&gt;
    for (int i = rangeStart; i &amp;lt; rangeEnd; i++) {&lt;br /&gt;
      if (font.canDisplay(i)) {&lt;br /&gt;
        return true;&lt;br /&gt;
      }&lt;br /&gt;
    }&lt;br /&gt;
    return false;&lt;br /&gt;
  }&lt;br /&gt;
  // / Displays a file load/save dialog and returns the specified file&lt;br /&gt;
  private String promptFile(boolean isSave, String initFileName) {&lt;br /&gt;
    int retVal;&lt;br /&gt;
    String str;&lt;br /&gt;
    // / ABP&lt;br /&gt;
    if (filePromptDialog == null)&lt;br /&gt;
      return null;&lt;br /&gt;
    if (isSave) {&lt;br /&gt;
      filePromptDialog.setDialogType(JFileChooser.SAVE_DIALOG);&lt;br /&gt;
      filePromptDialog.setDialogTitle(&amp;quot;Save...&amp;quot;);&lt;br /&gt;
      str = &amp;quot;Save&amp;quot;;&lt;br /&gt;
    } else {&lt;br /&gt;
      filePromptDialog.setDialogType(JFileChooser.OPEN_DIALOG);&lt;br /&gt;
      filePromptDialog.setDialogTitle(&amp;quot;Load...&amp;quot;);&lt;br /&gt;
      str = &amp;quot;Load&amp;quot;;&lt;br /&gt;
    }&lt;br /&gt;
    if (initFileName != null)&lt;br /&gt;
      filePromptDialog.setSelectedFile(new File(initFileName));&lt;br /&gt;
    retVal = filePromptDialog.showDialog(this, str);&lt;br /&gt;
    if (retVal == JFileChooser.APPROVE_OPTION) {&lt;br /&gt;
      File file = filePromptDialog.getSelectedFile();&lt;br /&gt;
      String fileName = file.getAbsolutePath();&lt;br /&gt;
      if (fileName != null) {&lt;br /&gt;
        return fileName;&lt;br /&gt;
      }&lt;br /&gt;
    }&lt;br /&gt;
    return null;&lt;br /&gt;
  }&lt;br /&gt;
  // / Converts user text into arrays of String, delimited at newline character&lt;br /&gt;
  // / Also replaces any valid escape sequence with appropriate unicode&lt;br /&gt;
  // character&lt;br /&gt;
  // / Support \\UXXXXXX notation for surrogates&lt;br /&gt;
  private String[] parseUserText(String orig) {&lt;br /&gt;
    int length = orig.length();&lt;br /&gt;
    StringTokenizer perLine = new StringTokenizer(orig, &amp;quot;\n&amp;quot;);&lt;br /&gt;
    String textLines[] = new String[perLine.countTokens()];&lt;br /&gt;
    int lineNumber = 0;&lt;br /&gt;
    while (perLine.hasMoreElements()) {&lt;br /&gt;
      StringBuffer converted = new StringBuffer();&lt;br /&gt;
      String oneLine = perLine.nextToken();&lt;br /&gt;
      int lineLength = oneLine.length();&lt;br /&gt;
      int prevEscapeEnd = 0;&lt;br /&gt;
      int nextEscape = -1;&lt;br /&gt;
      do {&lt;br /&gt;
        int nextBMPEscape = oneLine.indexOf(&amp;quot;\\u&amp;quot;, prevEscapeEnd);&lt;br /&gt;
        int nextSupEscape = oneLine.indexOf(&amp;quot;\\U&amp;quot;, prevEscapeEnd);&lt;br /&gt;
        nextEscape = (nextBMPEscape &amp;lt; 0) ? ((nextSupEscape &amp;lt; 0) ? -1 : nextSupEscape)&lt;br /&gt;
            : ((nextSupEscape &amp;lt; 0) ? nextBMPEscape : Math.min(nextBMPEscape, nextSupEscape));&lt;br /&gt;
        if (nextEscape != -1) {&lt;br /&gt;
          if (prevEscapeEnd &amp;lt; nextEscape)&lt;br /&gt;
            converted.append(oneLine.substring(prevEscapeEnd, nextEscape));&lt;br /&gt;
          prevEscapeEnd = nextEscape + (nextEscape == nextBMPEscape ? 6 : 8);&lt;br /&gt;
          try {&lt;br /&gt;
            String hex = oneLine.substring(nextEscape + 2, prevEscapeEnd);&lt;br /&gt;
            if (nextEscape == nextBMPEscape) {&lt;br /&gt;
              converted.append((char) Integer.parseInt(hex, 16));&lt;br /&gt;
            } else {&lt;br /&gt;
              converted.append(new String(Character.toChars(Integer.parseInt(hex, 16))));&lt;br /&gt;
            }&lt;br /&gt;
          } catch (Exception e) {&lt;br /&gt;
            int copyLimit = Math.min(lineLength, prevEscapeEnd);&lt;br /&gt;
            converted.append(oneLine.substring(nextEscape, copyLimit));&lt;br /&gt;
          }&lt;br /&gt;
        }&lt;br /&gt;
      } while (nextEscape != -1);&lt;br /&gt;
      if (prevEscapeEnd &amp;lt; lineLength)&lt;br /&gt;
        converted.append(oneLine.substring(prevEscapeEnd, lineLength));&lt;br /&gt;
      textLines[lineNumber++] = converted.toString();&lt;br /&gt;
    }&lt;br /&gt;
    return textLines;&lt;br /&gt;
  }&lt;br /&gt;
  // / Reads the text from specified file, detecting UTF-16 encoding&lt;br /&gt;
  // / Then breaks the text into String array, delimited at every line break&lt;br /&gt;
  private void readTextFile(String fileName) {&lt;br /&gt;
    try {&lt;br /&gt;
      String fileText, textLines[];&lt;br /&gt;
      BufferedInputStream bis = new BufferedInputStream(new FileInputStream(fileName));&lt;br /&gt;
      int numBytes = bis.available();&lt;br /&gt;
      if (numBytes == 0) {&lt;br /&gt;
        throw new Exception(&amp;quot;Text file &amp;quot; + fileName + &amp;quot; is empty&amp;quot;);&lt;br /&gt;
      }&lt;br /&gt;
      byte byteData[] = new byte[numBytes];&lt;br /&gt;
      bis.read(byteData, 0, numBytes);&lt;br /&gt;
      bis.close();&lt;br /&gt;
      // / If byte mark is found, then use UTF-16 encoding to convert bytes...&lt;br /&gt;
      if (numBytes &amp;gt;= 2&lt;br /&gt;
          &amp;amp;&amp;amp; ((byteData[0] == (byte) 0xFF &amp;amp;&amp;amp; byteData[1] == (byte) 0xFE) || (byteData[0] == (byte) 0xFE &amp;amp;&amp;amp; byteData[1] == (byte) 0xFF)))&lt;br /&gt;
        fileText = new String(byteData, &amp;quot;UTF-16&amp;quot;);&lt;br /&gt;
      // / Otherwise, use system default encoding&lt;br /&gt;
      else&lt;br /&gt;
        fileText = new String(byteData);&lt;br /&gt;
      int length = fileText.length();&lt;br /&gt;
      StringTokenizer perLine = new StringTokenizer(fileText, &amp;quot;\n&amp;quot;);&lt;br /&gt;
      // / Determine &amp;quot;Return Char&amp;quot; used in this file&lt;br /&gt;
      // / This simply finds first occurrence of CR, CR+LF or LF...&lt;br /&gt;
      for (int i = 0; i &amp;lt; length; i++) {&lt;br /&gt;
        char iTh = fileText.charAt(i);&lt;br /&gt;
        if (iTh == &amp;quot;\r&amp;quot;) {&lt;br /&gt;
          if (i &amp;lt; length - 1 &amp;amp;&amp;amp; fileText.charAt(i + 1) == &amp;quot;\n&amp;quot;)&lt;br /&gt;
            perLine = new StringTokenizer(fileText, &amp;quot;\r\n&amp;quot;);&lt;br /&gt;
          else&lt;br /&gt;
            perLine = new StringTokenizer(fileText, &amp;quot;\r&amp;quot;);&lt;br /&gt;
          break;&lt;br /&gt;
        } else if (iTh == &amp;quot;\n&amp;quot;)&lt;br /&gt;
          // / Use the one already created&lt;br /&gt;
          break;&lt;br /&gt;
      }&lt;br /&gt;
      int lineNumber = 0, numLines = perLine.countTokens();&lt;br /&gt;
      textLines = new String[numLines];&lt;br /&gt;
      while (perLine.hasMoreElements()) {&lt;br /&gt;
        String oneLine = perLine.nextToken();&lt;br /&gt;
        if (oneLine == null)&lt;br /&gt;
          // / To make LineBreakMeasurer to return a valid TextLayout&lt;br /&gt;
          // / on an empty line, simply feed it a space char...&lt;br /&gt;
          oneLine = &amp;quot; &amp;quot;;&lt;br /&gt;
        textLines[lineNumber++] = oneLine;&lt;br /&gt;
      }&lt;br /&gt;
      fp.setTextToDraw(fp.FILE_TEXT, null, null, textLines);&lt;br /&gt;
      rm.setEnabled(false);&lt;br /&gt;
      methodsMenu.setEnabled(false);&lt;br /&gt;
    } catch (Exception ex) {&lt;br /&gt;
      fireChangeStatus(&amp;quot;ERROR: Failed to Read Text File; See Stack Trace&amp;quot;, true);&lt;br /&gt;
      ex.printStackTrace();&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
  // / Returns a String storing current configuration&lt;br /&gt;
  private void writeCurrentOptions(String fileName) {&lt;br /&gt;
    try {&lt;br /&gt;
      String curOptions = fp.getCurrentOptions();&lt;br /&gt;
      BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(fileName));&lt;br /&gt;
      // / Prepend title and the option that is only obtainable here&lt;br /&gt;
      int range[] = rm.getSelectedRange();&lt;br /&gt;
      String completeOptions = (&amp;quot;Font2DTest Option File\n&amp;quot; + displayGridCBMI.getState() + &amp;quot;\n&amp;quot;&lt;br /&gt;
          + force16ColsCBMI.getState() + &amp;quot;\n&amp;quot; + showFontInfoCBMI.getState() + &amp;quot;\n&amp;quot;&lt;br /&gt;
          + rm.getSelectedItem() + &amp;quot;\n&amp;quot; + range[0] + &amp;quot;\n&amp;quot; + range[1] + &amp;quot;\n&amp;quot; + curOptions + tFileName);&lt;br /&gt;
      byte toBeWritten[] = completeOptions.getBytes(&amp;quot;UTF-16&amp;quot;);&lt;br /&gt;
      bos.write(toBeWritten, 0, toBeWritten.length);&lt;br /&gt;
      bos.close();&lt;br /&gt;
    } catch (Exception ex) {&lt;br /&gt;
      fireChangeStatus(&amp;quot;ERROR: Failed to Save Options File; See Stack Trace&amp;quot;, true);&lt;br /&gt;
      ex.printStackTrace();&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
  // / Updates GUI visibility/status after some parameters have changed&lt;br /&gt;
  private void updateGUI() {&lt;br /&gt;
    int selectedText = textMenu.getSelectedIndex();&lt;br /&gt;
    // / Set the visibility of User Text dialog&lt;br /&gt;
    if (selectedText == fp.USER_TEXT)&lt;br /&gt;
      userTextDialog.show();&lt;br /&gt;
    else&lt;br /&gt;
      userTextDialog.hide();&lt;br /&gt;
    // / Change the visibility/status/availability of Print JDialog buttons&lt;br /&gt;
    printModeCBs[fp.ONE_PAGE].setSelected(true);&lt;br /&gt;
    if (selectedText == fp.FILE_TEXT || selectedText == fp.USER_TEXT) {&lt;br /&gt;
      // / ABP&lt;br /&gt;
      // / update methodsMenu to show that TextLayout.draw is being used&lt;br /&gt;
      // / when we are in FILE_TEXT mode&lt;br /&gt;
      if (selectedText == fp.FILE_TEXT)&lt;br /&gt;
        methodsMenu.setSelectedItem(&amp;quot;TextLayout.draw&amp;quot;);&lt;br /&gt;
      methodsMenu.setEnabled(selectedText == fp.USER_TEXT);&lt;br /&gt;
      printModeCBs[fp.CUR_RANGE].setEnabled(false);&lt;br /&gt;
      printModeCBs[fp.ALL_TEXT].setEnabled(true);&lt;br /&gt;
    } else {&lt;br /&gt;
      // / ABP&lt;br /&gt;
      // / update methodsMenu to show that drawGlyph is being used&lt;br /&gt;
      // / when we are in ALL_GLYPHS mode&lt;br /&gt;
      if (selectedText == fp.ALL_GLYPHS)&lt;br /&gt;
        methodsMenu.setSelectedItem(&amp;quot;drawGlyphVector&amp;quot;);&lt;br /&gt;
      methodsMenu.setEnabled(selectedText == fp.RANGE_TEXT);&lt;br /&gt;
      printModeCBs[fp.CUR_RANGE].setEnabled(true);&lt;br /&gt;
      printModeCBs[fp.ALL_TEXT].setEnabled(false);&lt;br /&gt;
    }&lt;br /&gt;
    // / Modify RangeMenu and fontInfo label availabilty&lt;br /&gt;
    if (selectedText == fp.RANGE_TEXT) {&lt;br /&gt;
      fontInfos[1].setVisible(true);&lt;br /&gt;
      rm.setEnabled(true);&lt;br /&gt;
    } else {&lt;br /&gt;
      fontInfos[1].setVisible(false);&lt;br /&gt;
      rm.setEnabled(false);&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
  // / Loads saved options and applies them&lt;br /&gt;
  private void loadOptions(String fileName) {&lt;br /&gt;
    try {&lt;br /&gt;
      BufferedInputStream bis = new BufferedInputStream(new FileInputStream(fileName));&lt;br /&gt;
      int numBytes = bis.available();&lt;br /&gt;
      byte byteData[] = new byte[numBytes];&lt;br /&gt;
      bis.read(byteData, 0, numBytes);&lt;br /&gt;
      bis.close();&lt;br /&gt;
      if (numBytes &amp;lt; 2 || (byteData[0] != (byte) 0xFE || byteData[1] != (byte) 0xFF))&lt;br /&gt;
        throw new Exception(&amp;quot;Not a Font2DTest options file&amp;quot;);&lt;br /&gt;
      String options = new String(byteData, &amp;quot;UTF-16&amp;quot;);&lt;br /&gt;
      StringTokenizer perLine = new StringTokenizer(options, &amp;quot;\n&amp;quot;);&lt;br /&gt;
      String title = perLine.nextToken();&lt;br /&gt;
      if (!title.equals(&amp;quot;Font2DTest Option File&amp;quot;))&lt;br /&gt;
        throw new Exception(&amp;quot;Not a Font2DTest options file&amp;quot;);&lt;br /&gt;
      // / Parse all options&lt;br /&gt;
      boolean displayGridOpt = Boolean.parseBoolean(perLine.nextToken());&lt;br /&gt;
      boolean force16ColsOpt = Boolean.parseBoolean(perLine.nextToken());&lt;br /&gt;
      boolean showFontInfoOpt = Boolean.parseBoolean(perLine.nextToken());&lt;br /&gt;
      String rangeNameOpt = perLine.nextToken();&lt;br /&gt;
      int rangeStartOpt = Integer.parseInt(perLine.nextToken());&lt;br /&gt;
      int rangeEndOpt = Integer.parseInt(perLine.nextToken());&lt;br /&gt;
      String fontNameOpt = perLine.nextToken();&lt;br /&gt;
      float fontSizeOpt = Float.parseFloat(perLine.nextToken());&lt;br /&gt;
      int fontStyleOpt = Integer.parseInt(perLine.nextToken());&lt;br /&gt;
      int fontTransformOpt = Integer.parseInt(perLine.nextToken());&lt;br /&gt;
      int g2TransformOpt = Integer.parseInt(perLine.nextToken());&lt;br /&gt;
      int textToUseOpt = Integer.parseInt(perLine.nextToken());&lt;br /&gt;
      int drawMethodOpt = Integer.parseInt(perLine.nextToken());&lt;br /&gt;
      int antialiasOpt = Integer.parseInt(perLine.nextToken());&lt;br /&gt;
      int fractionalOpt = Integer.parseInt(perLine.nextToken());&lt;br /&gt;
      int lcdContrast = Integer.parseInt(perLine.nextToken());&lt;br /&gt;
      String userTextOpt[] = { &amp;quot;Java2D!&amp;quot; }, dialogEntry = &amp;quot;Java2D!&amp;quot;;&lt;br /&gt;
      if (textToUseOpt == fp.USER_TEXT) {&lt;br /&gt;
        int numLines = perLine.countTokens(), lineNumber = 0;&lt;br /&gt;
        if (numLines != 0) {&lt;br /&gt;
          userTextOpt = new String[numLines];&lt;br /&gt;
          dialogEntry = &amp;quot;&amp;quot;;&lt;br /&gt;
          for (; perLine.hasMoreElements(); lineNumber++) {&lt;br /&gt;
            userTextOpt[lineNumber] = perLine.nextToken();&lt;br /&gt;
            dialogEntry += userTextOpt[lineNumber] + &amp;quot;\n&amp;quot;;&lt;br /&gt;
          }&lt;br /&gt;
        }&lt;br /&gt;
      }&lt;br /&gt;
      // / Reset GUIs&lt;br /&gt;
      displayGridCBMI.setState(displayGridOpt);&lt;br /&gt;
      force16ColsCBMI.setState(force16ColsOpt);&lt;br /&gt;
      showFontInfoCBMI.setState(showFontInfoOpt);&lt;br /&gt;
      rm.setSelectedRange(rangeNameOpt, rangeStartOpt, rangeEndOpt);&lt;br /&gt;
      fontMenu.setSelectedItem(fontNameOpt);&lt;br /&gt;
      sizeField.setText(String.valueOf(fontSizeOpt));&lt;br /&gt;
      styleMenu.setSelectedIndex(fontStyleOpt);&lt;br /&gt;
      transformMenu.setSelectedIndex(fontTransformOpt);&lt;br /&gt;
      transformMenuG2.setSelectedIndex(g2TransformOpt);&lt;br /&gt;
      textMenu.setSelectedIndex(textToUseOpt);&lt;br /&gt;
      methodsMenu.setSelectedIndex(drawMethodOpt);&lt;br /&gt;
      antiAliasMenu.setSelectedIndex(antialiasOpt);&lt;br /&gt;
      fracMetricsMenu.setSelectedIndex(fractionalOpt);&lt;br /&gt;
      contrastSlider.setValue(lcdContrast);&lt;br /&gt;
      userTextArea.setText(dialogEntry);&lt;br /&gt;
      updateGUI();&lt;br /&gt;
      if (textToUseOpt == fp.FILE_TEXT) {&lt;br /&gt;
        tFileName = perLine.nextToken();&lt;br /&gt;
        readTextFile(tFileName);&lt;br /&gt;
      }&lt;br /&gt;
      // / Reset option variables and repaint&lt;br /&gt;
      fp.loadOptions(displayGridOpt, force16ColsOpt, rangeStartOpt, rangeEndOpt, fontNameOpt,&lt;br /&gt;
          fontSizeOpt, fontStyleOpt, fontTransformOpt, g2TransformOpt, textToUseOpt, drawMethodOpt,&lt;br /&gt;
          antialiasOpt, fractionalOpt, lcdContrast, userTextOpt);&lt;br /&gt;
      if (showFontInfoOpt) {&lt;br /&gt;
        fireUpdateFontInfo();&lt;br /&gt;
        fontInfoDialog.show();&lt;br /&gt;
      } else&lt;br /&gt;
        fontInfoDialog.hide();&lt;br /&gt;
    } catch (Exception ex) {&lt;br /&gt;
      fireChangeStatus(&amp;quot;ERROR: Failed to Load Options File; See Stack Trace&amp;quot;, true);&lt;br /&gt;
      ex.printStackTrace();&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
  // / Loads a previously saved image&lt;br /&gt;
  private void loadComparisonPNG(String fileName) {&lt;br /&gt;
    try {&lt;br /&gt;
      BufferedImage image = javax.imageio.ImageIO.read(new File(fileName));&lt;br /&gt;
      JFrame f = new JFrame(&amp;quot;Comparison PNG&amp;quot;);&lt;br /&gt;
      ImagePanel ip = new ImagePanel(image);&lt;br /&gt;
      f.setResizable(false);&lt;br /&gt;
      f.getContentPane().add(ip);&lt;br /&gt;
      f.addWindowListener(new WindowAdapter() {&lt;br /&gt;
        public void windowClosing(WindowEvent e) {&lt;br /&gt;
          ((JFrame) e.getSource()).dispose();&lt;br /&gt;
        }&lt;br /&gt;
      });&lt;br /&gt;
      f.pack();&lt;br /&gt;
      f.show();&lt;br /&gt;
    } catch (Exception ex) {&lt;br /&gt;
      fireChangeStatus(&amp;quot;ERROR: Failed to Load PNG File; See Stack Trace&amp;quot;, true);&lt;br /&gt;
      ex.printStackTrace();&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
  // / Interface functions...&lt;br /&gt;
  // / ActionListener interface function&lt;br /&gt;
  // / Responds to JMenuItem, JTextField and JButton actions&lt;br /&gt;
  public void actionPerformed(ActionEvent e) {&lt;br /&gt;
    Object source = e.getSource();&lt;br /&gt;
    if (source instanceof JMenuItem) {&lt;br /&gt;
      JMenuItem mi = (JMenuItem) source;&lt;br /&gt;
      String itemName = mi.getText();&lt;br /&gt;
      if (itemName.equals(&amp;quot;Save Selected Options...&amp;quot;)) {&lt;br /&gt;
        String fileName = promptFile(true, &amp;quot;options.txt&amp;quot;);&lt;br /&gt;
        if (fileName != null)&lt;br /&gt;
          writeCurrentOptions(fileName);&lt;br /&gt;
      } else if (itemName.equals(&amp;quot;Load Options...&amp;quot;)) {&lt;br /&gt;
        String fileName = promptFile(false, &amp;quot;options.txt&amp;quot;);&lt;br /&gt;
        if (fileName != null)&lt;br /&gt;
          loadOptions(fileName);&lt;br /&gt;
      } else if (itemName.equals(&amp;quot;Save as PNG...&amp;quot;)) {&lt;br /&gt;
        String fileName = promptFile(true, fontMenu.getSelectedItem() + &amp;quot;.png&amp;quot;);&lt;br /&gt;
        if (fileName != null)&lt;br /&gt;
          fp.doSavePNG(fileName);&lt;br /&gt;
      } else if (itemName.equals(&amp;quot;Load PNG File to Compare...&amp;quot;)) {&lt;br /&gt;
        String fileName = promptFile(false, null);&lt;br /&gt;
        if (fileName != null)&lt;br /&gt;
          loadComparisonPNG(fileName);&lt;br /&gt;
      } else if (itemName.equals(&amp;quot;Page Setup...&amp;quot;))&lt;br /&gt;
        fp.doPageSetup();&lt;br /&gt;
      else if (itemName.equals(&amp;quot;Print...&amp;quot;))&lt;br /&gt;
        printDialog.show();&lt;br /&gt;
      else if (itemName.equals(&amp;quot;Close&amp;quot;))&lt;br /&gt;
        parent.dispose();&lt;br /&gt;
      else if (itemName.equals(&amp;quot;Exit&amp;quot;))&lt;br /&gt;
        System.exit(0);&lt;br /&gt;
    }&lt;br /&gt;
    else if (source instanceof JTextField) {&lt;br /&gt;
      JTextField tf = (JTextField) source;&lt;br /&gt;
      float sz = 12f;&lt;br /&gt;
      try {&lt;br /&gt;
        sz = Float.parseFloat(sizeField.getText());&lt;br /&gt;
        if (sz &amp;lt; 1f || sz &amp;gt; 120f) {&lt;br /&gt;
          sz = 12f;&lt;br /&gt;
          sizeField.setText(&amp;quot;12&amp;quot;);&lt;br /&gt;
        }&lt;br /&gt;
      } catch (Exception se) {&lt;br /&gt;
        sizeField.setText(&amp;quot;12&amp;quot;);&lt;br /&gt;
      }&lt;br /&gt;
      if (tf == sizeField)&lt;br /&gt;
        fp.setFontParams(fontMenu.getSelectedItem(), sz, styleMenu.getSelectedIndex(),&lt;br /&gt;
            transformMenu.getSelectedIndex());&lt;br /&gt;
    }&lt;br /&gt;
    else if (source instanceof JButton) {&lt;br /&gt;
      String itemName = ((JButton) source).getText();&lt;br /&gt;
      // / Print dialog buttons...&lt;br /&gt;
      if (itemName.equals(&amp;quot;Print&amp;quot;)) {&lt;br /&gt;
        for (int i = 0; i &amp;lt; printModeCBs.length; i++)&lt;br /&gt;
          if (printModeCBs[i].isSelected()) {&lt;br /&gt;
            printDialog.hide();&lt;br /&gt;
            fp.doPrint(i);&lt;br /&gt;
          }&lt;br /&gt;
      } else if (itemName.equals(&amp;quot;Cancel&amp;quot;))&lt;br /&gt;
        printDialog.hide();&lt;br /&gt;
      // / Update button from Usert Text JDialog...&lt;br /&gt;
      else if (itemName.equals(&amp;quot;Update&amp;quot;))&lt;br /&gt;
        fp.setTextToDraw(fp.USER_TEXT, null, parseUserText(userTextArea.getText()), null);&lt;br /&gt;
    } else if (source instanceof JComboBox) {&lt;br /&gt;
      JComboBox c = (JComboBox) source;&lt;br /&gt;
      // / RangeMenu handles actions by itself and then calls fireRangeChanged,&lt;br /&gt;
      // / so it is not listed or handled here&lt;br /&gt;
      if (c == fontMenu || c == styleMenu || c == transformMenu) {&lt;br /&gt;
        float sz = 12f;&lt;br /&gt;
        try {&lt;br /&gt;
          sz = Float.parseFloat(sizeField.getText());&lt;br /&gt;
          if (sz &amp;lt; 1f || sz &amp;gt; 120f) {&lt;br /&gt;
            sz = 12f;&lt;br /&gt;
            sizeField.setText(&amp;quot;12&amp;quot;);&lt;br /&gt;
          }&lt;br /&gt;
        } catch (Exception se) {&lt;br /&gt;
          sizeField.setText(&amp;quot;12&amp;quot;);&lt;br /&gt;
        }&lt;br /&gt;
        fp.setFontParams(fontMenu.getSelectedItem(), sz, styleMenu.getSelectedIndex(),&lt;br /&gt;
            transformMenu.getSelectedIndex());&lt;br /&gt;
      } else if (c == methodsMenu)&lt;br /&gt;
        fp.setDrawMethod(methodsMenu.getSelectedIndex());&lt;br /&gt;
      else if (c == textMenu) {&lt;br /&gt;
        if (canDisplayCheck) {&lt;br /&gt;
          fireRangeChanged();&lt;br /&gt;
        }&lt;br /&gt;
        int selected = textMenu.getSelectedIndex();&lt;br /&gt;
        if (selected == fp.RANGE_TEXT)&lt;br /&gt;
          fp.setTextToDraw(fp.RANGE_TEXT, rm.getSelectedRange(), null, null);&lt;br /&gt;
        else if (selected == fp.USER_TEXT)&lt;br /&gt;
          fp.setTextToDraw(fp.USER_TEXT, null, parseUserText(userTextArea.getText()), null);&lt;br /&gt;
        else if (selected == fp.FILE_TEXT) {&lt;br /&gt;
          String fileName = promptFile(false, null);&lt;br /&gt;
          if (fileName != null) {&lt;br /&gt;
            tFileName = fileName;&lt;br /&gt;
            readTextFile(fileName);&lt;br /&gt;
          } else {&lt;br /&gt;
            // / User cancelled selection; reset to previous choice&lt;br /&gt;
            c.setSelectedIndex(currentTextChoice);&lt;br /&gt;
            return;&lt;br /&gt;
          }&lt;br /&gt;
        } else if (selected == fp.ALL_GLYPHS)&lt;br /&gt;
          fp.setTextToDraw(fp.ALL_GLYPHS, null, null, null);&lt;br /&gt;
        updateGUI();&lt;br /&gt;
        currentTextChoice = selected;&lt;br /&gt;
      } else if (c == transformMenuG2) {&lt;br /&gt;
        fp.setTransformG2(transformMenuG2.getSelectedIndex());&lt;br /&gt;
      } else if (c == antiAliasMenu || c == fracMetricsMenu) {&lt;br /&gt;
        if (c == antiAliasMenu) {&lt;br /&gt;
          boolean enabled = FontPanel.AAValues.isLCDMode(antiAliasMenu.getSelectedItem());&lt;br /&gt;
          contrastSlider.setEnabled(enabled);&lt;br /&gt;
        }&lt;br /&gt;
        fp.setRenderingHints(antiAliasMenu.getSelectedItem(), fracMetricsMenu.getSelectedItem(),&lt;br /&gt;
            contrastSlider.getValue());&lt;br /&gt;
      }&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
  public void stateChanged(ChangeEvent e) {&lt;br /&gt;
    Object source = e.getSource();&lt;br /&gt;
    if (source instanceof JSlider) {&lt;br /&gt;
      fp.setRenderingHints(antiAliasMenu.getSelectedItem(), fracMetricsMenu.getSelectedItem(),&lt;br /&gt;
          contrastSlider.getValue());&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
  // / ItemListener interface function&lt;br /&gt;
  // / Responds to JCheckBoxMenuItem, JComboBox and JCheckBox actions&lt;br /&gt;
  public void itemStateChanged(ItemEvent e) {&lt;br /&gt;
    Object source = e.getSource();&lt;br /&gt;
    if (source instanceof JCheckBoxMenuItem) {&lt;br /&gt;
      JCheckBoxMenuItem cbmi = (JCheckBoxMenuItem) source;&lt;br /&gt;
      if (cbmi == displayGridCBMI)&lt;br /&gt;
        fp.setGridDisplay(displayGridCBMI.getState());&lt;br /&gt;
      else if (cbmi == force16ColsCBMI)&lt;br /&gt;
        fp.setForce16Columns(force16ColsCBMI.getState());&lt;br /&gt;
      else if (cbmi == showFontInfoCBMI) {&lt;br /&gt;
        if (showFontInfoCBMI.getState()) {&lt;br /&gt;
          fireUpdateFontInfo();&lt;br /&gt;
          fontInfoDialog.show();&lt;br /&gt;
        } else&lt;br /&gt;
          fontInfoDialog.hide();&lt;br /&gt;
      }&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
  private static void printUsage() {&lt;br /&gt;
    String usage = &amp;quot;Usage: java -jar Font2DTest.jar [options]\n&amp;quot; + &amp;quot;\nwhere options include:\n&amp;quot;&lt;br /&gt;
        + &amp;quot;    -dcdc | -disablecandisplaycheck disable canDisplay check for font\n&amp;quot;&lt;br /&gt;
        + &amp;quot;    -?    | -help                   print this help message\n&amp;quot; + &amp;quot;\nExample :\n&amp;quot;&lt;br /&gt;
        + &amp;quot;     To disable canDisplay check on font for ranges\n&amp;quot;&lt;br /&gt;
        + &amp;quot;     java -jar Font2DTest.jar -dcdc&amp;quot;;&lt;br /&gt;
    System.out.println(usage);&lt;br /&gt;
    System.exit(0);&lt;br /&gt;
  }&lt;br /&gt;
  // / Main function&lt;br /&gt;
  public static void main(String argv[]) {&lt;br /&gt;
    if (argv.length &amp;gt; 0) {&lt;br /&gt;
      if (argv[0].equalsIgnoreCase(&amp;quot;-disablecandisplaycheck&amp;quot;) || argv[0].equalsIgnoreCase(&amp;quot;-dcdc&amp;quot;)) {&lt;br /&gt;
        canDisplayCheck = false;&lt;br /&gt;
      } else {&lt;br /&gt;
        printUsage();&lt;br /&gt;
      }&lt;br /&gt;
    }&lt;br /&gt;
    UIManager.put(&amp;quot;swing.boldMetal&amp;quot;, Boolean.FALSE);&lt;br /&gt;
    final JFrame f = new JFrame(&amp;quot;Font2DTest&amp;quot;);&lt;br /&gt;
    final Font2DTest f2dt = new Font2DTest(f, false);&lt;br /&gt;
    f.addWindowListener(new WindowAdapter() {&lt;br /&gt;
      public void windowOpening(WindowEvent e) {&lt;br /&gt;
        f2dt.repaint();&lt;br /&gt;
      }&lt;br /&gt;
      public void windowClosing(WindowEvent e) {&lt;br /&gt;
        System.exit(0);&lt;br /&gt;
      }&lt;br /&gt;
    });&lt;br /&gt;
    f.getContentPane().add(f2dt);&lt;br /&gt;
    f.pack();&lt;br /&gt;
    f.show();&lt;br /&gt;
  }&lt;br /&gt;
  // / Inner class definitions...&lt;br /&gt;
  // / Class to display just an image file&lt;br /&gt;
  // / Used to show the comparison PNG image&lt;br /&gt;
  private final class ImagePanel extends JPanel {&lt;br /&gt;
    private final BufferedImage bi;&lt;br /&gt;
    public ImagePanel(BufferedImage image) {&lt;br /&gt;
      bi = image;&lt;br /&gt;
    }&lt;br /&gt;
    public Dimension getPreferredSize() {&lt;br /&gt;
      return new Dimension(bi.getWidth(), bi.getHeight());&lt;br /&gt;
    }&lt;br /&gt;
    public void paintComponent(Graphics g) {&lt;br /&gt;
      g.drawImage(bi, 0, 0, this);&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
  // / Classes made to avoid repetitive calls... (being lazy)&lt;br /&gt;
  private final class ButtonV2 extends JButton {&lt;br /&gt;
    public ButtonV2(String name, ActionListener al) {&lt;br /&gt;
      super(name);&lt;br /&gt;
      this.addActionListener(al);&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
  private final class ChoiceV2 extends JComboBox {&lt;br /&gt;
    private BitSet bitSet = null;&lt;br /&gt;
    public ChoiceV2() {&lt;br /&gt;
      ;&lt;br /&gt;
    }&lt;br /&gt;
    public ChoiceV2(ActionListener al) {&lt;br /&gt;
      super();&lt;br /&gt;
      this.addActionListener(al);&lt;br /&gt;
    }&lt;br /&gt;
    public ChoiceV2(ActionListener al, boolean fontChoice) {&lt;br /&gt;
      this(al);&lt;br /&gt;
      if (fontChoice) {&lt;br /&gt;
        // Register this component in ToolTipManager&lt;br /&gt;
        setToolTipText(&amp;quot;&amp;quot;);&lt;br /&gt;
        bitSet = new BitSet();&lt;br /&gt;
        setRenderer(new ChoiceV2Renderer(this));&lt;br /&gt;
      }&lt;br /&gt;
    }&lt;br /&gt;
    public String getToolTipText() {&lt;br /&gt;
      int index = this.getSelectedIndex();&lt;br /&gt;
      String fontName = (String) this.getSelectedItem();&lt;br /&gt;
      if (fontName != null &amp;amp;&amp;amp; (textMenu.getSelectedIndex() == fp.RANGE_TEXT)) {&lt;br /&gt;
        if (getBit(index)) {&lt;br /&gt;
          return &amp;quot;Font \&amp;quot;&amp;quot; + fontName + &amp;quot;\&amp;quot; can display some characters in \&amp;quot;&amp;quot;&lt;br /&gt;
              + rm.getSelectedItem() + &amp;quot;\&amp;quot; range&amp;quot;;&lt;br /&gt;
        } else {&lt;br /&gt;
          return &amp;quot;Font \&amp;quot;&amp;quot; + fontName + &amp;quot;\&amp;quot; cannot display any characters in \&amp;quot;&amp;quot;&lt;br /&gt;
              + rm.getSelectedItem() + &amp;quot;\&amp;quot; range&amp;quot;;&lt;br /&gt;
        }&lt;br /&gt;
      }&lt;br /&gt;
      return super.getToolTipText();&lt;br /&gt;
    }&lt;br /&gt;
    public void setBit(int bitIndex, boolean value) {&lt;br /&gt;
      bitSet.set(bitIndex, value);&lt;br /&gt;
    }&lt;br /&gt;
    public boolean getBit(int bitIndex) {&lt;br /&gt;
      return bitSet.get(bitIndex);&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
  private final class ChoiceV2Renderer extends DefaultListCellRenderer {&lt;br /&gt;
    private ImageIcon yesImage, blankImage;&lt;br /&gt;
    private ChoiceV2 choice = null;&lt;br /&gt;
    public ChoiceV2Renderer(ChoiceV2 choice) {&lt;br /&gt;
      try {&lt;br /&gt;
        yesImage = new ImageIcon(getClass().getResource(&amp;quot;yes.gif&amp;quot;));&lt;br /&gt;
        blankImage = new ImageIcon(getClass().getResource(&amp;quot;blank.gif&amp;quot;));&lt;br /&gt;
      } catch (Exception exception) {&lt;br /&gt;
        System.out.println(&amp;quot;Exception : &amp;quot; + exception);&lt;br /&gt;
      }&lt;br /&gt;
      this.choice = choice;&lt;br /&gt;
    }&lt;br /&gt;
    public Component getListCellRendererComponent(JList list, Object value, int index,&lt;br /&gt;
        boolean isSelected, boolean cellHasFocus) {&lt;br /&gt;
      if (textMenu.getSelectedIndex() == fp.RANGE_TEXT) {&lt;br /&gt;
        super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);&lt;br /&gt;
        // For JComboBox if index is -1, its rendering the selected index.&lt;br /&gt;
        if (index == -1) {&lt;br /&gt;
          index = choice.getSelectedIndex();&lt;br /&gt;
        }&lt;br /&gt;
        if (choice.getBit(index)) {&lt;br /&gt;
          setIcon(yesImage);&lt;br /&gt;
        } else {&lt;br /&gt;
          setIcon(blankImage);&lt;br /&gt;
        }&lt;br /&gt;
      } else {&lt;br /&gt;
        super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);&lt;br /&gt;
        setIcon(blankImage);&lt;br /&gt;
      }&lt;br /&gt;
      return this;&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
  private final class LabelV2 extends JLabel {&lt;br /&gt;
    public LabelV2(String name) {&lt;br /&gt;
      super(name);&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
  private final class MenuItemV2 extends JMenuItem {&lt;br /&gt;
    public MenuItemV2(String name, ActionListener al) {&lt;br /&gt;
      super(name);&lt;br /&gt;
      this.addActionListener(al);&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
  private final class CheckboxMenuItemV2 extends JCheckBoxMenuItem {&lt;br /&gt;
    public CheckboxMenuItemV2(String name, boolean b, ItemListener il) {&lt;br /&gt;
      super(name, b);&lt;br /&gt;
      this.addItemListener(il);&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
/*&lt;br /&gt;
 * @(#)FontPanel.java 1.20 05/11/17&lt;br /&gt;
 * &lt;br /&gt;
 * Copyright (c) 2006 Sun Microsystems, Inc. All Rights Reserved.&lt;br /&gt;
 * &lt;br /&gt;
 * Redistribution and use in source and binary forms, with or without&lt;br /&gt;
 * modification, are permitted provided that the following conditions are met:&lt;br /&gt;
 * &lt;br /&gt;
 * -Redistribution of source code must retain the above copyright notice, this&lt;br /&gt;
 * list of conditions and the following disclaimer.&lt;br /&gt;
 * &lt;br /&gt;
 * -Redistribution in binary form must reproduce the above copyright notice,&lt;br /&gt;
 * this list of conditions and the following disclaimer in the documentation&lt;br /&gt;
 * and/or other materials provided with the distribution.&lt;br /&gt;
 * &lt;br /&gt;
 * Neither the name of Sun Microsystems, Inc. or the names of contributors may&lt;br /&gt;
 * be used to endorse or promote products derived from this software without&lt;br /&gt;
 * specific prior written permission.&lt;br /&gt;
 * &lt;br /&gt;
 * This software is provided &amp;quot;AS IS,&amp;quot; without a warranty of any kind. ALL&lt;br /&gt;
 * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING ANY&lt;br /&gt;
 * IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR&lt;br /&gt;
 * NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN MIDROSYSTEMS, INC. (&amp;quot;SUN&amp;quot;) AND ITS&lt;br /&gt;
 * LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A&lt;br /&gt;
 * RESULT OF USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES.&lt;br /&gt;
 * IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT&lt;br /&gt;
 * OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR&lt;br /&gt;
 * PUNITIVE DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY,&lt;br /&gt;
 * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF SUN HAS&lt;br /&gt;
 * BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.&lt;br /&gt;
 * &lt;br /&gt;
 * You acknowledge that this software is not designed, licensed or intended for&lt;br /&gt;
 * use in the design, construction, operation or maintenance of any nuclear&lt;br /&gt;
 * facility.&lt;br /&gt;
 */&lt;br /&gt;
/*&lt;br /&gt;
 * @(#)FontPanel.java 1.20 05/11/17&lt;br /&gt;
 */&lt;br /&gt;
/**&lt;br /&gt;
 * FontPanel.java&lt;br /&gt;
 * &lt;br /&gt;
 * @version&lt;br /&gt;
 * @(#)FontPanel.java 1.1 00/08/22&lt;br /&gt;
 * @author Shinsuke Fukuda&lt;br /&gt;
 * @author Ankit Patel [Conversion to Swing - 01/07/30]&lt;br /&gt;
 */&lt;br /&gt;
// / This panel is combination of the text drawing area of Font2DTest&lt;br /&gt;
// / and the custom controlled scroll bar&lt;br /&gt;
final class FontPanel extends JPanel implements AdjustmentListener {&lt;br /&gt;
  // / Drawing Option Constants&lt;br /&gt;
  private final String STYLES[] = { &amp;quot;plain&amp;quot;, &amp;quot;bold&amp;quot;, &amp;quot;italic&amp;quot;, &amp;quot;bold italic&amp;quot; };&lt;br /&gt;
  private final int NONE = 0;&lt;br /&gt;
  private final int SCALE = 1;&lt;br /&gt;
  private final int SHEAR = 2;&lt;br /&gt;
  private final int ROTATE = 3;&lt;br /&gt;
  private final String TRANSFORMS[] = { &amp;quot;with no transforms&amp;quot;, &amp;quot;with scaling&amp;quot;, &amp;quot;with Shearing&amp;quot;,&lt;br /&gt;
      &amp;quot;with rotation&amp;quot; };&lt;br /&gt;
  private final int DRAW_STRING = 0;&lt;br /&gt;
  private final int DRAW_CHARS = 1;&lt;br /&gt;
  private final int DRAW_BYTES = 2;&lt;br /&gt;
  private final int DRAW_GLYPHV = 3;&lt;br /&gt;
  private final int TL_DRAW = 4;&lt;br /&gt;
  private final int GV_OUTLINE = 5;&lt;br /&gt;
  private final int TL_OUTLINE = 6;&lt;br /&gt;
  private final String METHODS[] = { &amp;quot;drawString&amp;quot;, &amp;quot;drawChars&amp;quot;, &amp;quot;drawBytes&amp;quot;, &amp;quot;drawGlyphVector&amp;quot;,&lt;br /&gt;
      &amp;quot;TextLayout.draw&amp;quot;, &amp;quot;GlyphVector.getOutline&amp;quot;, &amp;quot;TextLayout.getOutline&amp;quot; };&lt;br /&gt;
  public final int RANGE_TEXT = 0;&lt;br /&gt;
  public final int ALL_GLYPHS = 1;&lt;br /&gt;
  public final int USER_TEXT = 2;&lt;br /&gt;
  public final int FILE_TEXT = 3;&lt;br /&gt;
  private final String MS_OPENING[] = { &amp;quot; Unicode &amp;quot;, &amp;quot; Glyph Code &amp;quot;, &amp;quot; lines &amp;quot;, &amp;quot; lines &amp;quot; };&lt;br /&gt;
  private final String MS_CLOSING[] = { &amp;quot;&amp;quot;, &amp;quot;&amp;quot;, &amp;quot; of User Text &amp;quot;,&lt;br /&gt;
      &amp;quot; of LineBreakMeasurer-reformatted Text &amp;quot; };&lt;br /&gt;
  // / General Graphics Variable&lt;br /&gt;
  private final JScrollBar verticalBar;&lt;br /&gt;
  private final FontCanvas fc;&lt;br /&gt;
  private boolean updateBackBuffer = true;&lt;br /&gt;
  private boolean updateFontMetrics = true;&lt;br /&gt;
  private boolean updateFont = true;&lt;br /&gt;
  private boolean force16Cols = false;&lt;br /&gt;
  public boolean showingError = false;&lt;br /&gt;
  private int g2Transform = NONE; // / ABP&lt;br /&gt;
  // / Printing constants and variables&lt;br /&gt;
  public final int ONE_PAGE = 0;&lt;br /&gt;
  public final int CUR_RANGE = 1;&lt;br /&gt;
  public final int ALL_TEXT = 2;&lt;br /&gt;
  private int printMode = ONE_PAGE;&lt;br /&gt;
  private PageFormat page = null;&lt;br /&gt;
  private PrinterJob printer = null;&lt;br /&gt;
  // / Text drawing variables&lt;br /&gt;
  private String fontName = &amp;quot;Dialog&amp;quot;;&lt;br /&gt;
  private float fontSize = 12;&lt;br /&gt;
  private int fontStyle = Font.PLAIN;&lt;br /&gt;
  private int fontTransform = NONE;&lt;br /&gt;
  private Font testFont = null;&lt;br /&gt;
  private Object antiAliasType = VALUE_TEXT_ANTIALIAS_DEFAULT;&lt;br /&gt;
  private Object fractionalMetricsType = VALUE_FRACTIONALMETRICS_DEFAULT;&lt;br /&gt;
  private Object lcdContrast = getDefaultLCDContrast();&lt;br /&gt;
  private int drawMethod = DRAW_STRING;&lt;br /&gt;
  private int textToUse = RANGE_TEXT;&lt;br /&gt;
  private String userText[] = null;&lt;br /&gt;
  private String fileText[] = null;&lt;br /&gt;
  private int drawRange[] = { 0x0000, 0x007f };&lt;br /&gt;
  private String fontInfos[] = new String[2];&lt;br /&gt;
  private boolean showGrid = true;&lt;br /&gt;
  // / Parent Font2DTest panel&lt;br /&gt;
  private final Font2DTest f2dt;&lt;br /&gt;
  private final JFrame parent;&lt;br /&gt;
  public FontPanel(Font2DTest demo, JFrame f) {&lt;br /&gt;
    f2dt = demo;&lt;br /&gt;
    parent = f;&lt;br /&gt;
    verticalBar = new JScrollBar(JScrollBar.VERTICAL);&lt;br /&gt;
    fc = new FontCanvas();&lt;br /&gt;
    this.setLayout(new BorderLayout());&lt;br /&gt;
    this.add(&amp;quot;Center&amp;quot;, fc);&lt;br /&gt;
    this.add(&amp;quot;East&amp;quot;, verticalBar);&lt;br /&gt;
    verticalBar.addAdjustmentListener(this);&lt;br /&gt;
    this.addComponentListener(new ComponentAdapter() {&lt;br /&gt;
      public void componentResized(ComponentEvent e) {&lt;br /&gt;
        updateBackBuffer = true;&lt;br /&gt;
        updateFontMetrics = true;&lt;br /&gt;
      }&lt;br /&gt;
    });&lt;br /&gt;
    // / Initialize font and its infos&lt;br /&gt;
    testFont = new Font(fontName, fontStyle, (int) fontSize);&lt;br /&gt;
    if ((float) ((int) fontSize) != fontSize) {&lt;br /&gt;
      testFont = testFont.deriveFont(fontSize);&lt;br /&gt;
    }&lt;br /&gt;
    updateFontInfo();&lt;br /&gt;
  }&lt;br /&gt;
  public Dimension getPreferredSize() {&lt;br /&gt;
    return new Dimension(600, 200);&lt;br /&gt;
  }&lt;br /&gt;
  // / Functions called by the main programs to set the various parameters&lt;br /&gt;
  public void setTransformG2(int transform) {&lt;br /&gt;
    g2Transform = transform;&lt;br /&gt;
    updateBackBuffer = true;&lt;br /&gt;
    updateFontMetrics = true;&lt;br /&gt;
    fc.repaint();&lt;br /&gt;
  }&lt;br /&gt;
  // / convenience fcn to create AffineTransform of appropriate type&lt;br /&gt;
  private AffineTransform getAffineTransform(int transform) {&lt;br /&gt;
    // / ABP&lt;br /&gt;
    AffineTransform at = new AffineTransform();&lt;br /&gt;
    switch (transform) {&lt;br /&gt;
    case SCALE:&lt;br /&gt;
      at.setToScale(1.5f, 1.5f);&lt;br /&gt;
      break;&lt;br /&gt;
    case ROTATE:&lt;br /&gt;
      at.setToRotation(Math.PI / 6);&lt;br /&gt;
      break;&lt;br /&gt;
    case SHEAR:&lt;br /&gt;
      at.setToShear(0.4f, 0);&lt;br /&gt;
      break;&lt;br /&gt;
    case NONE:&lt;br /&gt;
      break;&lt;br /&gt;
    default:&lt;br /&gt;
      // System.err.println( &amp;quot;Illegal G2 Transform Arg: &amp;quot; + transform);&lt;br /&gt;
      break;&lt;br /&gt;
    }&lt;br /&gt;
    return at;&lt;br /&gt;
  }&lt;br /&gt;
  public void setFontParams(Object obj, float size, int style, int transform) {&lt;br /&gt;
    setFontParams((String) obj, size, style, transform);&lt;br /&gt;
  }&lt;br /&gt;
  public void setFontParams(String name, float size, int style, int transform) {&lt;br /&gt;
    boolean fontModified = false;&lt;br /&gt;
    if (!name.equals(fontName) || style != fontStyle)&lt;br /&gt;
      fontModified = true;&lt;br /&gt;
    fontName = name;&lt;br /&gt;
    fontSize = size;&lt;br /&gt;
    fontStyle = style;&lt;br /&gt;
    fontTransform = transform;&lt;br /&gt;
    // / Recreate the font as specified&lt;br /&gt;
    testFont = new Font(fontName, fontStyle, (int) fontSize);&lt;br /&gt;
    if ((float) ((int) fontSize) != fontSize) {&lt;br /&gt;
      testFont = testFont.deriveFont(fontSize);&lt;br /&gt;
    }&lt;br /&gt;
    if (fontTransform != NONE) {&lt;br /&gt;
      AffineTransform at = getAffineTransform(fontTransform);&lt;br /&gt;
      testFont = testFont.deriveFont(at);&lt;br /&gt;
    }&lt;br /&gt;
    updateBackBuffer = true;&lt;br /&gt;
    updateFontMetrics = true;&lt;br /&gt;
    fc.repaint();&lt;br /&gt;
    if (fontModified) {&lt;br /&gt;
      // / Tell main panel to update the font info&lt;br /&gt;
      updateFontInfo();&lt;br /&gt;
      f2dt.fireUpdateFontInfo();&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
  public void setRenderingHints(Object aa, Object fm, Object contrast) {&lt;br /&gt;
    antiAliasType = ((AAValues) aa).getHint();&lt;br /&gt;
    fractionalMetricsType = ((FMValues) fm).getHint();&lt;br /&gt;
    lcdContrast = contrast;&lt;br /&gt;
    updateBackBuffer = true;&lt;br /&gt;
    updateFontMetrics = true;&lt;br /&gt;
    fc.repaint();&lt;br /&gt;
  }&lt;br /&gt;
  public void setDrawMethod(int i) {&lt;br /&gt;
    drawMethod = i;&lt;br /&gt;
    updateBackBuffer = true;&lt;br /&gt;
    fc.repaint();&lt;br /&gt;
  }&lt;br /&gt;
  public void setTextToDraw(int i, int range[], String textSet[], String fileData[]) {&lt;br /&gt;
    textToUse = i;&lt;br /&gt;
    if (textToUse == RANGE_TEXT)&lt;br /&gt;
      drawRange = range;&lt;br /&gt;
    else if (textToUse == ALL_GLYPHS)&lt;br /&gt;
      drawMethod = DRAW_GLYPHV;&lt;br /&gt;
    else if (textToUse == USER_TEXT)&lt;br /&gt;
      userText = textSet;&lt;br /&gt;
    else if (textToUse == FILE_TEXT) {&lt;br /&gt;
      fileText = fileData;&lt;br /&gt;
      drawMethod = TL_DRAW;&lt;br /&gt;
    }&lt;br /&gt;
    updateBackBuffer = true;&lt;br /&gt;
    updateFontMetrics = true;&lt;br /&gt;
    fc.repaint();&lt;br /&gt;
    updateFontInfo();&lt;br /&gt;
  }&lt;br /&gt;
  public void setGridDisplay(boolean b) {&lt;br /&gt;
    showGrid = b;&lt;br /&gt;
    updateBackBuffer = true;&lt;br /&gt;
    fc.repaint();&lt;br /&gt;
  }&lt;br /&gt;
  public void setForce16Columns(boolean b) {&lt;br /&gt;
    force16Cols = b;&lt;br /&gt;
    updateBackBuffer = true;&lt;br /&gt;
    updateFontMetrics = true;&lt;br /&gt;
    fc.repaint();&lt;br /&gt;
  }&lt;br /&gt;
  // / Prints out the text display area&lt;br /&gt;
  public void doPrint(int i) {&lt;br /&gt;
    if (printer == null) {&lt;br /&gt;
      printer = PrinterJob.getPrinterJob();&lt;br /&gt;
      page = printer.defaultPage();&lt;br /&gt;
    }&lt;br /&gt;
    printMode = i;&lt;br /&gt;
    printer.setPrintable(fc, page);&lt;br /&gt;
    if (printer.printDialog()) {&lt;br /&gt;
      try {&lt;br /&gt;
        printer.print();&lt;br /&gt;
      } catch (Exception e) {&lt;br /&gt;
        f2dt.fireChangeStatus(&amp;quot;ERROR: Printing Failed; See Stack Trace&amp;quot;, true);&lt;br /&gt;
      }&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
  // / Displays the page setup dialog and updates PageFormat info&lt;br /&gt;
  public void doPageSetup() {&lt;br /&gt;
    if (printer == null) {&lt;br /&gt;
      printer = PrinterJob.getPrinterJob();&lt;br /&gt;
      page = printer.defaultPage();&lt;br /&gt;
    }&lt;br /&gt;
    page = printer.pageDialog(page);&lt;br /&gt;
  }&lt;br /&gt;
  // / Obtains the information about selected font&lt;br /&gt;
  private void updateFontInfo() {&lt;br /&gt;
    int numGlyphs = 0, numCharsInRange = drawRange[1] - drawRange[0] + 1;&lt;br /&gt;
    fontInfos[0] = &amp;quot;Font Face Name: &amp;quot; + testFont.getFontName();&lt;br /&gt;
    fontInfos[1] = &amp;quot;Glyphs in This Range: &amp;quot;;&lt;br /&gt;
    if (textToUse == RANGE_TEXT) {&lt;br /&gt;
      for (int i = drawRange[0]; i &amp;lt; drawRange[1]; i++)&lt;br /&gt;
        if (testFont.canDisplay(i))&lt;br /&gt;
          numGlyphs++;&lt;br /&gt;
      fontInfos[1] = fontInfos[1] + numGlyphs + &amp;quot; / &amp;quot; + numCharsInRange;&lt;br /&gt;
    } else&lt;br /&gt;
      fontInfos[1] = null;&lt;br /&gt;
  }&lt;br /&gt;
  // / Accessor for the font information&lt;br /&gt;
  public String[] getFontInfo() {&lt;br /&gt;
    return fontInfos;&lt;br /&gt;
  }&lt;br /&gt;
  // / Collects the currectly set options and returns them as string&lt;br /&gt;
  public String getCurrentOptions() {&lt;br /&gt;
    // / Create a new String to store the options&lt;br /&gt;
    // / The array will contain all 8 setting (font name, size...) and&lt;br /&gt;
    // / character range or user text data used (no file text data)&lt;br /&gt;
    int userTextSize = 0;&lt;br /&gt;
    String options;&lt;br /&gt;
    options = (fontName + &amp;quot;\n&amp;quot; + fontSize + &amp;quot;\n&amp;quot; + fontStyle + &amp;quot;\n&amp;quot; + fontTransform + &amp;quot;\n&amp;quot;&lt;br /&gt;
        + g2Transform + &amp;quot;\n&amp;quot; + textToUse + &amp;quot;\n&amp;quot; + drawMethod + &amp;quot;\n&amp;quot;&lt;br /&gt;
        + AAValues.getHintVal(antiAliasType) + &amp;quot;\n&amp;quot; + FMValues.getHintVal(fractionalMetricsType)&lt;br /&gt;
        + &amp;quot;\n&amp;quot; + lcdContrast + &amp;quot;\n&amp;quot;);&lt;br /&gt;
    if (textToUse == USER_TEXT)&lt;br /&gt;
      for (int i = 0; i &amp;lt; userText.length; i++)&lt;br /&gt;
        options += (userText[i] + &amp;quot;\n&amp;quot;);&lt;br /&gt;
    return options;&lt;br /&gt;
  }&lt;br /&gt;
  // / Reload all options and refreshes the canvas&lt;br /&gt;
  public void loadOptions(boolean grid, boolean force16, int start, int end, String name,&lt;br /&gt;
      float size, int style, int transform, int g2transform, int text, int method, int aa, int fm,&lt;br /&gt;
      int contrast, String user[]) {&lt;br /&gt;
    int range[] = { start, end };&lt;br /&gt;
    // / Since repaint call has a low priority, these functions will finish&lt;br /&gt;
    // / before the actual repainting is done&lt;br /&gt;
    setGridDisplay(grid);&lt;br /&gt;
    setForce16Columns(force16);&lt;br /&gt;
    // previous call to readTextFile has already set the text to draw&lt;br /&gt;
    if (textToUse != FILE_TEXT) {&lt;br /&gt;
      setTextToDraw(text, range, user, null);&lt;br /&gt;
    }&lt;br /&gt;
    setFontParams(name, size, style, transform);&lt;br /&gt;
    setTransformG2(g2transform); // ABP&lt;br /&gt;
    setDrawMethod(method);&lt;br /&gt;
    setRenderingHints(AAValues.getValue(aa), FMValues.getValue(fm), new Integer(contrast));&lt;br /&gt;
  }&lt;br /&gt;
  // / Writes the current screen to PNG file&lt;br /&gt;
  public void doSavePNG(String fileName) {&lt;br /&gt;
    fc.writePNG(fileName);&lt;br /&gt;
  }&lt;br /&gt;
  // / When scrolled using the scroll bar, update the backbuffer&lt;br /&gt;
  public void adjustmentValueChanged(AdjustmentEvent e) {&lt;br /&gt;
    updateBackBuffer = true;&lt;br /&gt;
    fc.repaint();&lt;br /&gt;
  }&lt;br /&gt;
  public void paintComponent(Graphics g) {&lt;br /&gt;
    // Windows does not repaint correctly, after&lt;br /&gt;
    // a zoom. Thus, we need to force the canvas&lt;br /&gt;
    // to repaint, but only once. After the first repaint,&lt;br /&gt;
    // everything stabilizes. [ABP]&lt;br /&gt;
    fc.repaint();&lt;br /&gt;
  }&lt;br /&gt;
  // / Inner class definition...&lt;br /&gt;
  // / Inner panel that holds the actual drawing area and its routines&lt;br /&gt;
  private class FontCanvas extends JPanel implements MouseListener, MouseMotionListener, Printable {&lt;br /&gt;
    // / Number of characters that will fit across and down this canvas&lt;br /&gt;
    private int numCharAcross, numCharDown;&lt;br /&gt;
    // / First and last character/line that will be drawn&lt;br /&gt;
    // / Limit is the end of range/text where no more draw will be done&lt;br /&gt;
    private int drawStart, drawEnd, drawLimit;&lt;br /&gt;
    // / FontMetrics variables&lt;br /&gt;
    // / Here, gridWidth is equivalent to maxAdvance (slightly bigger though)&lt;br /&gt;
    // / and gridHeight is equivalent to lineHeight&lt;br /&gt;
    private int maxAscent, maxDescent, gridWidth = 0, gridHeight = 0;&lt;br /&gt;
    // / Offset from the top left edge of the canvas where the draw will start&lt;br /&gt;
    private int canvasInset_X = 5, canvasInset_Y = 5;&lt;br /&gt;
    // / Offscreen buffer of this canvas&lt;br /&gt;
    private BufferedImage backBuffer = null;&lt;br /&gt;
    // / LineBreak&amp;quot;ed TextLayout vector&lt;br /&gt;
    private Vector lineBreakTLs = null;&lt;br /&gt;
    // / Whether the current draw command requested is for printing&lt;br /&gt;
    private boolean isPrinting = false;&lt;br /&gt;
    // / Other printing infos&lt;br /&gt;
    private int lastPage, printPageNumber, currentlyShownChar = 0;&lt;br /&gt;
    private final int PR_OFFSET = 10;&lt;br /&gt;
    private final int PR_TITLE_LINEHEIGHT = 30;&lt;br /&gt;
    // / Information about zooming (used with range text draw)&lt;br /&gt;
    private final JWindow zoomWindow;&lt;br /&gt;
    private BufferedImage zoomImage = null;&lt;br /&gt;
    private int mouseOverCharX = -1, mouseOverCharY = -1;&lt;br /&gt;
    private int currMouseOverChar = -1, prevZoomChar = -1;&lt;br /&gt;
    private float ZOOM = 2.0f;&lt;br /&gt;
    private boolean nowZooming = false;&lt;br /&gt;
    private boolean firstTime = true;&lt;br /&gt;
    // ABP&lt;br /&gt;
    // / Status bar message backup&lt;br /&gt;
    private String backupStatusString = null;&lt;br /&gt;
    // / Error constants&lt;br /&gt;
    private final String ERRORS[] = {&lt;br /&gt;
        &amp;quot;ERROR: drawBytes cannot handle characters beyond 0x00FF. Select different range or draw methods.&amp;quot;,&lt;br /&gt;
        &amp;quot;ERROR: Cannot fit text with the current font size. Resize the window or use smaller font size.&amp;quot;,&lt;br /&gt;
        &amp;quot;ERROR: Cannot print with the current font size. Use smaller font size.&amp;quot;, };&lt;br /&gt;
    private final int DRAW_BYTES_ERROR = 0;&lt;br /&gt;
    private final int CANT_FIT_DRAW = 1;&lt;br /&gt;
    private final int CANT_FIT_PRINT = 2;&lt;br /&gt;
    // / Other variables&lt;br /&gt;
    private final Cursor blankCursor;&lt;br /&gt;
    public FontCanvas() {&lt;br /&gt;
      this.addMouseListener(this);&lt;br /&gt;
      this.addMouseMotionListener(this);&lt;br /&gt;
      this.setForeground(Color.black);&lt;br /&gt;
      this.setBackground(Color.white);&lt;br /&gt;
      // / Creates an invisble pointer by giving it bogus image&lt;br /&gt;
      // / Possibly find a workaround for this...&lt;br /&gt;
      Toolkit tk = Toolkit.getDefaultToolkit();&lt;br /&gt;
      byte bogus[] = { (byte) 0 };&lt;br /&gt;
      blankCursor = tk.createCustomCursor(tk.createImage(bogus), new Point(0, 0), &amp;quot;&amp;quot;);&lt;br /&gt;
      zoomWindow = new JWindow(parent) {&lt;br /&gt;
        public void paint(Graphics g) {&lt;br /&gt;
          g.drawImage(zoomImage, 0, 0, zoomWindow);&lt;br /&gt;
        }&lt;br /&gt;
      };&lt;br /&gt;
      zoomWindow.setCursor(blankCursor);&lt;br /&gt;
      zoomWindow.pack();&lt;br /&gt;
    }&lt;br /&gt;
    public boolean firstTime() {&lt;br /&gt;
      return firstTime;&lt;br /&gt;
    }&lt;br /&gt;
    public void refresh() {&lt;br /&gt;
      firstTime = false;&lt;br /&gt;
      updateBackBuffer = true;&lt;br /&gt;
      repaint();&lt;br /&gt;
    }&lt;br /&gt;
    // / Sets the font, hints, according to the set parameters&lt;br /&gt;
    private void setParams(Graphics2D g2) {&lt;br /&gt;
      g2.setFont(testFont);&lt;br /&gt;
      g2.setRenderingHint(KEY_TEXT_ANTIALIASING, antiAliasType);&lt;br /&gt;
      g2.setRenderingHint(KEY_FRACTIONALMETRICS, fractionalMetricsType);&lt;br /&gt;
      g2.setRenderingHint(KEY_TEXT_LCD_CONTRAST, lcdContrast);&lt;br /&gt;
      /*&lt;br /&gt;
       * I am preserving a somewhat dubious behaviour of this program. Outline&lt;br /&gt;
       * text would be drawn anti-aliased by setting the graphics anti-aliasing&lt;br /&gt;
       * hint if the text anti-aliasing hint was set. The dubious element here&lt;br /&gt;
       * is that people simply using this program may think this is built-in&lt;br /&gt;
       * behaviour but its not - at least not when the app explictly draws&lt;br /&gt;
       * outline text. This becomes more dubious in cases such as &amp;quot;GASP&amp;quot; where&lt;br /&gt;
       * the size at which text is AA&amp;quot;ed is not something you can easily&lt;br /&gt;
       * calculate, so mimicing that behaviour isn&amp;quot;t going to be easy. So I&lt;br /&gt;
       * precisely preserve the behaviour : this is done only if the AA value is&lt;br /&gt;
       * &amp;quot;ON&amp;quot;. Its not applied in the other cases.&lt;br /&gt;
       */&lt;br /&gt;
      if (antiAliasType == VALUE_TEXT_ANTIALIAS_ON&lt;br /&gt;
          &amp;amp;&amp;amp; (drawMethod == TL_OUTLINE || drawMethod == GV_OUTLINE)) {&lt;br /&gt;
        g2.setRenderingHint(KEY_ANTIALIASING, VALUE_ANTIALIAS_ON);&lt;br /&gt;
      } else {&lt;br /&gt;
        g2.setRenderingHint(KEY_ANTIALIASING, VALUE_ANTIALIAS_OFF);&lt;br /&gt;
      }&lt;br /&gt;
    }&lt;br /&gt;
    // / Draws the grid (Used for unicode/glyph range drawing)&lt;br /&gt;
    private void drawGrid(Graphics2D g2) {&lt;br /&gt;
      int totalGridWidth = numCharAcross * gridWidth;&lt;br /&gt;
      int totalGridHeight = numCharDown * gridHeight;&lt;br /&gt;
      g2.setColor(Color.black);&lt;br /&gt;
      for (int i = 0; i &amp;lt; numCharDown + 1; i++)&lt;br /&gt;
        g2.drawLine(canvasInset_X, i * gridHeight + canvasInset_Y, canvasInset_X + totalGridWidth,&lt;br /&gt;
            i * gridHeight + canvasInset_Y);&lt;br /&gt;
      for (int i = 0; i &amp;lt; numCharAcross + 1; i++)&lt;br /&gt;
        g2.drawLine(i * gridWidth + canvasInset_X, canvasInset_Y, i * gridWidth + canvasInset_X,&lt;br /&gt;
            canvasInset_Y + totalGridHeight);&lt;br /&gt;
    }&lt;br /&gt;
    // / Draws one character at time onto the canvas according to&lt;br /&gt;
    // / the method requested (Used for RANGE_TEXT and ALL_GLYPHS)&lt;br /&gt;
    public void modeSpecificDrawChar(Graphics2D g2, int charCode, int baseX, int baseY) {&lt;br /&gt;
      GlyphVector gv;&lt;br /&gt;
      int oneGlyph[] = { charCode };&lt;br /&gt;
      char charArray[] = Character.toChars(charCode);&lt;br /&gt;
      FontRenderContext frc = g2.getFontRenderContext();&lt;br /&gt;
      AffineTransform oldTX = g2.getTransform();&lt;br /&gt;
      // / Create GlyphVector to measure the exact visual advance&lt;br /&gt;
      // / Using that number, adjust the position of the character drawn&lt;br /&gt;
      if (textToUse == ALL_GLYPHS)&lt;br /&gt;
        gv = testFont.createGlyphVector(frc, oneGlyph);&lt;br /&gt;
      else&lt;br /&gt;
        gv = testFont.createGlyphVector(frc, charArray);&lt;br /&gt;
      Rectangle2D r2d2 = gv.getPixelBounds(frc, 0, 0);&lt;br /&gt;
      int shiftedX = baseX;&lt;br /&gt;
      // getPixelBounds returns a result in device space.&lt;br /&gt;
      // we need to convert back to user space to be able to&lt;br /&gt;
      // calculate the shift as baseX is in user space.&lt;br /&gt;
      try {&lt;br /&gt;
        double pt[] = new double[4];&lt;br /&gt;
        pt[0] = r2d2.getX();&lt;br /&gt;
        pt[1] = r2d2.getY();&lt;br /&gt;
        pt[2] = r2d2.getX() + r2d2.getWidth();&lt;br /&gt;
        pt[3] = r2d2.getY() + r2d2.getHeight();&lt;br /&gt;
        oldTX.inverseTransform(pt, 0, pt, 0, 2);&lt;br /&gt;
        shiftedX = baseX - (int) (pt[2] / 2 + pt[0]);&lt;br /&gt;
      } catch (NoninvertibleTransformException e) {&lt;br /&gt;
      }&lt;br /&gt;
      // / ABP - keep track of old tform, restore it later&lt;br /&gt;
      g2.translate(shiftedX, baseY);&lt;br /&gt;
      g2.transform(getAffineTransform(g2Transform));&lt;br /&gt;
      if (textToUse == ALL_GLYPHS)&lt;br /&gt;
        g2.drawGlyphVector(gv, 0f, 0f);&lt;br /&gt;
      else {&lt;br /&gt;
        if (testFont.canDisplay(charCode))&lt;br /&gt;
          g2.setColor(Color.black);&lt;br /&gt;
        else {&lt;br /&gt;
          g2.setColor(Color.lightGray);&lt;br /&gt;
        }&lt;br /&gt;
        switch (drawMethod) {&lt;br /&gt;
        case DRAW_STRING:&lt;br /&gt;
          g2.drawString(new String(charArray), 0, 0);&lt;br /&gt;
          break;&lt;br /&gt;
        case DRAW_CHARS:&lt;br /&gt;
          g2.drawChars(charArray, 0, 1, 0, 0);&lt;br /&gt;
          break;&lt;br /&gt;
        case DRAW_BYTES:&lt;br /&gt;
          if (charCode &amp;gt; 0xff)&lt;br /&gt;
            throw new CannotDrawException(DRAW_BYTES_ERROR);&lt;br /&gt;
          byte oneByte[] = { (byte) charCode };&lt;br /&gt;
          g2.drawBytes(oneByte, 0, 1, 0, 0);&lt;br /&gt;
          break;&lt;br /&gt;
        case DRAW_GLYPHV:&lt;br /&gt;
          g2.drawGlyphVector(gv, 0f, 0f);&lt;br /&gt;
          break;&lt;br /&gt;
        case TL_DRAW:&lt;br /&gt;
          TextLayout tl = new TextLayout(new String(charArray), testFont, frc);&lt;br /&gt;
          tl.draw(g2, 0f, 0f);&lt;br /&gt;
          break;&lt;br /&gt;
        case GV_OUTLINE:&lt;br /&gt;
          r2d2 = gv.getVisualBounds();&lt;br /&gt;
          shiftedX = baseX - (int) (r2d2.getWidth() / 2 + r2d2.getX());&lt;br /&gt;
          g2.draw(gv.getOutline(0f, 0f));&lt;br /&gt;
          break;&lt;br /&gt;
        case TL_OUTLINE:&lt;br /&gt;
          r2d2 = gv.getVisualBounds();&lt;br /&gt;
          shiftedX = baseX - (int) (r2d2.getWidth() / 2 + r2d2.getX());&lt;br /&gt;
          TextLayout tlo = new TextLayout(new String(charArray), testFont, g2&lt;br /&gt;
              .getFontRenderContext());&lt;br /&gt;
          g2.draw(tlo.getOutline(null));&lt;br /&gt;
        }&lt;br /&gt;
      }&lt;br /&gt;
      // / ABP - restore old tform&lt;br /&gt;
      g2.setTransform(oldTX);&lt;br /&gt;
    }&lt;br /&gt;
    // Java2D!\\U01d586\\U01d587\\U01d588&lt;br /&gt;
    // / Draws one line of text at given position&lt;br /&gt;
    private void modeSpecificDrawLine(Graphics2D g2, String line, int baseX, int baseY) {&lt;br /&gt;
      // / ABP - keep track of old tform, restore it later&lt;br /&gt;
      AffineTransform oldTx = null;&lt;br /&gt;
      oldTx = g2.getTransform();&lt;br /&gt;
      g2.translate(baseX, baseY);&lt;br /&gt;
      g2.transform(getAffineTransform(g2Transform));&lt;br /&gt;
      switch (drawMethod) {&lt;br /&gt;
      case DRAW_STRING:&lt;br /&gt;
        g2.drawString(line, 0, 0);&lt;br /&gt;
        break;&lt;br /&gt;
      case DRAW_CHARS:&lt;br /&gt;
        g2.drawChars(line.toCharArray(), 0, line.length(), 0, 0);&lt;br /&gt;
        break;&lt;br /&gt;
      case DRAW_BYTES:&lt;br /&gt;
        try {&lt;br /&gt;
          byte lineBytes[] = line.getBytes(&amp;quot;ISO-8859-1&amp;quot;);&lt;br /&gt;
          g2.drawBytes(lineBytes, 0, lineBytes.length, 0, 0);&lt;br /&gt;
        } catch (Exception e) {&lt;br /&gt;
          e.printStackTrace();&lt;br /&gt;
        }&lt;br /&gt;
        break;&lt;br /&gt;
      case DRAW_GLYPHV:&lt;br /&gt;
        GlyphVector gv = testFont.createGlyphVector(g2.getFontRenderContext(), line);&lt;br /&gt;
        g2.drawGlyphVector(gv, (float) 0, (float) 0);&lt;br /&gt;
        break;&lt;br /&gt;
      case TL_DRAW:&lt;br /&gt;
        TextLayout tl = new TextLayout(line, testFont, g2.getFontRenderContext());&lt;br /&gt;
        tl.draw(g2, (float) 0, (float) 0);&lt;br /&gt;
        break;&lt;br /&gt;
      case GV_OUTLINE:&lt;br /&gt;
        GlyphVector gvo = testFont.createGlyphVector(g2.getFontRenderContext(), line);&lt;br /&gt;
        g2.draw(gvo.getOutline((float) 0, (float) 0));&lt;br /&gt;
        break;&lt;br /&gt;
      case TL_OUTLINE:&lt;br /&gt;
        TextLayout tlo = new TextLayout(line, testFont, g2.getFontRenderContext());&lt;br /&gt;
        AffineTransform at = new AffineTransform();&lt;br /&gt;
        g2.draw(tlo.getOutline(at));&lt;br /&gt;
      }&lt;br /&gt;
      // / ABP - restore old tform&lt;br /&gt;
      g2.setTransform(oldTx);&lt;br /&gt;
    }&lt;br /&gt;
    // / Draws one line of text at given position&lt;br /&gt;
    private void tlDrawLine(Graphics2D g2, TextLayout tl, float baseX, float baseY) {&lt;br /&gt;
      // / ABP - keep track of old tform, restore it later&lt;br /&gt;
      AffineTransform oldTx = null;&lt;br /&gt;
      oldTx = g2.getTransform();&lt;br /&gt;
      g2.translate(baseX, baseY);&lt;br /&gt;
      g2.transform(getAffineTransform(g2Transform));&lt;br /&gt;
      tl.draw(g2, (float) 0, (float) 0);&lt;br /&gt;
      // / ABP - restore old tform&lt;br /&gt;
      g2.setTransform(oldTx);&lt;br /&gt;
    }&lt;br /&gt;
    // / If textToUse is set to range drawing, then convert&lt;br /&gt;
    // / int to hex string and prepends 0s to make it length 4&lt;br /&gt;
    // / Otherwise line number was fed; simply return number + 1 converted to&lt;br /&gt;
    // String&lt;br /&gt;
    // / (This is because first line is 1, not 0)&lt;br /&gt;
    private String modeSpecificNumStr(int i) {&lt;br /&gt;
      if (textToUse == USER_TEXT || textToUse == FILE_TEXT)&lt;br /&gt;
        return String.valueOf(i + 1);&lt;br /&gt;
      StringBuffer s = new StringBuffer(Integer.toHexString(i));&lt;br /&gt;
      while (s.length() &amp;lt; 4)&lt;br /&gt;
        s.insert(0, &amp;quot;0&amp;quot;);&lt;br /&gt;
      return s.toString().toUpperCase();&lt;br /&gt;
    }&lt;br /&gt;
    // / Resets the scrollbar to display correct range of text currently on&lt;br /&gt;
    // screen&lt;br /&gt;
    // / (This scrollbar is not part of a &amp;quot;ScrollPane&amp;quot;. It merely simulates its&lt;br /&gt;
    // effect by&lt;br /&gt;
    // / indicating the necessary area to be drawn within the panel.&lt;br /&gt;
    // / By doing this, it prevents creating gigantic panel when large text&lt;br /&gt;
    // range,&lt;br /&gt;
    // / i.e. CJK Ideographs, is requested)&lt;br /&gt;
    private void resetScrollbar(int oldValue) {&lt;br /&gt;
      int totalNumRows = 1, numCharToDisplay;&lt;br /&gt;
      if (textToUse == RANGE_TEXT || textToUse == ALL_GLYPHS) {&lt;br /&gt;
        if (textToUse == RANGE_TEXT)&lt;br /&gt;
          numCharToDisplay = drawRange[1] - drawRange[0];&lt;br /&gt;
        else&lt;br /&gt;
          // / textToUse == ALL_GLYPHS&lt;br /&gt;
          numCharToDisplay = testFont.getNumGlyphs();&lt;br /&gt;
        totalNumRows = numCharToDisplay / numCharAcross;&lt;br /&gt;
        if (numCharToDisplay % numCharAcross != 0)&lt;br /&gt;
          totalNumRows++;&lt;br /&gt;
        if (oldValue / numCharAcross &amp;gt; totalNumRows)&lt;br /&gt;
          oldValue = 0;&lt;br /&gt;
        verticalBar.setValues(oldValue / numCharAcross, numCharDown, 0, totalNumRows);&lt;br /&gt;
      } else {&lt;br /&gt;
        if (textToUse == USER_TEXT)&lt;br /&gt;
          totalNumRows = userText.length;&lt;br /&gt;
        else&lt;br /&gt;
          // / textToUse == FILE_TEXT;&lt;br /&gt;
          totalNumRows = lineBreakTLs.size();&lt;br /&gt;
        verticalBar.setValues(oldValue, numCharDown, 0, totalNumRows);&lt;br /&gt;
      }&lt;br /&gt;
      if (totalNumRows &amp;lt;= numCharDown &amp;amp;&amp;amp; drawStart == 0) {&lt;br /&gt;
        verticalBar.setEnabled(false);&lt;br /&gt;
      } else {&lt;br /&gt;
        verticalBar.setEnabled(true);&lt;br /&gt;
      }&lt;br /&gt;
    }&lt;br /&gt;
    // / Calculates the font&amp;quot;s metrics that will be used for draw&lt;br /&gt;
    private void calcFontMetrics(Graphics2D g2d, int w, int h) {&lt;br /&gt;
      FontMetrics fm;&lt;br /&gt;
      Graphics2D g2 = (Graphics2D) g2d.create();&lt;br /&gt;
      // / ABP&lt;br /&gt;
      if (g2Transform != NONE &amp;amp;&amp;amp; textToUse != FILE_TEXT) {&lt;br /&gt;
        g2.setFont(g2.getFont().deriveFont(getAffineTransform(g2Transform)));&lt;br /&gt;
        fm = g2.getFontMetrics();&lt;br /&gt;
      } else {&lt;br /&gt;
        fm = g2.getFontMetrics();&lt;br /&gt;
      }&lt;br /&gt;
      maxAscent = fm.getMaxAscent();&lt;br /&gt;
      maxDescent = fm.getMaxDescent();&lt;br /&gt;
      if (maxAscent == 0)&lt;br /&gt;
        maxAscent = 10;&lt;br /&gt;
      if (maxDescent == 0)&lt;br /&gt;
        maxDescent = 5;&lt;br /&gt;
      if (textToUse == RANGE_TEXT || textToUse == ALL_GLYPHS) {&lt;br /&gt;
        // / Give slight extra room for each character&lt;br /&gt;
        maxAscent += 3;&lt;br /&gt;
        maxDescent += 3;&lt;br /&gt;
        gridWidth = fm.getMaxAdvance() + 6;&lt;br /&gt;
        gridHeight = maxAscent + maxDescent;&lt;br /&gt;
        if (force16Cols)&lt;br /&gt;
          numCharAcross = 16;&lt;br /&gt;
        else&lt;br /&gt;
          numCharAcross = (w - 10) / gridWidth;&lt;br /&gt;
        numCharDown = (h - 10) / gridHeight;&lt;br /&gt;
        canvasInset_X = (w - numCharAcross * gridWidth) / 2;&lt;br /&gt;
        canvasInset_Y = (h - numCharDown * gridHeight) / 2;&lt;br /&gt;
        if (numCharDown == 0 || numCharAcross == 0)&lt;br /&gt;
          throw new CannotDrawException(isPrinting ? CANT_FIT_PRINT : CANT_FIT_DRAW);&lt;br /&gt;
        if (!isPrinting)&lt;br /&gt;
          resetScrollbar(verticalBar.getValue() * numCharAcross);&lt;br /&gt;
      } else {&lt;br /&gt;
        maxDescent += fm.getLeading();&lt;br /&gt;
        canvasInset_X = 5;&lt;br /&gt;
        canvasInset_Y = 5;&lt;br /&gt;
        // / gridWidth and numCharAcross will not be used in this mode...&lt;br /&gt;
        gridHeight = maxAscent + maxDescent;&lt;br /&gt;
        numCharDown = (h - canvasInset_Y * 2) / gridHeight;&lt;br /&gt;
        if (numCharDown == 0)&lt;br /&gt;
          throw new CannotDrawException(isPrinting ? CANT_FIT_PRINT : CANT_FIT_DRAW);&lt;br /&gt;
        // / If this is text loaded from file, prepares the LineBreak&amp;quot;ed&lt;br /&gt;
        // / text layout at this point&lt;br /&gt;
        if (textToUse == FILE_TEXT) {&lt;br /&gt;
          if (!isPrinting)&lt;br /&gt;
            f2dt.fireChangeStatus(&amp;quot;LineBreaking Text... Please Wait&amp;quot;, false);&lt;br /&gt;
          lineBreakTLs = new Vector();&lt;br /&gt;
          for (int i = 0; i &amp;lt; fileText.length; i++) {&lt;br /&gt;
            AttributedString as = new AttributedString(fileText[i], g2.getFont().getAttributes());&lt;br /&gt;
            LineBreakMeasurer lbm = new LineBreakMeasurer(as.getIterator(), g2&lt;br /&gt;
                .getFontRenderContext());&lt;br /&gt;
            while (lbm.getPosition() &amp;lt; fileText[i].length())&lt;br /&gt;
              lineBreakTLs.add(lbm.nextLayout((float) w));&lt;br /&gt;
          }&lt;br /&gt;
        }&lt;br /&gt;
        if (!isPrinting)&lt;br /&gt;
          resetScrollbar(verticalBar.getValue());&lt;br /&gt;
      }&lt;br /&gt;
    }&lt;br /&gt;
    // / Calculates the amount of text that will be displayed on screen&lt;br /&gt;
    private void calcTextRange() {&lt;br /&gt;
      String displaying = null;&lt;br /&gt;
      if (textToUse == RANGE_TEXT || textToUse == ALL_GLYPHS) {&lt;br /&gt;
        if (isPrinting)&lt;br /&gt;
          if (printMode == ONE_PAGE)&lt;br /&gt;
            drawStart = currentlyShownChar;&lt;br /&gt;
          else&lt;br /&gt;
            // / printMode == CUR_RANGE&lt;br /&gt;
            drawStart = numCharAcross * numCharDown * printPageNumber;&lt;br /&gt;
        else&lt;br /&gt;
          drawStart = verticalBar.getValue() * numCharAcross;&lt;br /&gt;
        if (textToUse == RANGE_TEXT) {&lt;br /&gt;
          drawStart += drawRange[0];&lt;br /&gt;
          drawLimit = drawRange[1];&lt;br /&gt;
        } else&lt;br /&gt;
          drawLimit = testFont.getNumGlyphs();&lt;br /&gt;
        drawEnd = drawStart + numCharAcross * numCharDown - 1;&lt;br /&gt;
        if (drawEnd &amp;gt;= drawLimit)&lt;br /&gt;
          drawEnd = drawLimit;&lt;br /&gt;
      } else {&lt;br /&gt;
        if (isPrinting)&lt;br /&gt;
          if (printMode == ONE_PAGE)&lt;br /&gt;
            drawStart = currentlyShownChar;&lt;br /&gt;
          else&lt;br /&gt;
            // / printMode == ALL_TEXT&lt;br /&gt;
            drawStart = numCharDown * printPageNumber;&lt;br /&gt;
        else {&lt;br /&gt;
          drawStart = verticalBar.getValue();&lt;br /&gt;
        }&lt;br /&gt;
        drawEnd = drawStart + numCharDown - 1;&lt;br /&gt;
        if (textToUse == USER_TEXT)&lt;br /&gt;
          drawLimit = userText.length - 1;&lt;br /&gt;
        else&lt;br /&gt;
          drawLimit = lineBreakTLs.size() - 1;&lt;br /&gt;
        if (drawEnd &amp;gt;= drawLimit)&lt;br /&gt;
          drawEnd = drawLimit;&lt;br /&gt;
      }&lt;br /&gt;
      // ABP&lt;br /&gt;
      if (drawStart &amp;gt; drawEnd) {&lt;br /&gt;
        drawStart = 0;&lt;br /&gt;
        verticalBar.setValue(drawStart);&lt;br /&gt;
      }&lt;br /&gt;
      // / Change the status bar if not printing...&lt;br /&gt;
      if (!isPrinting) {&lt;br /&gt;
        backupStatusString = (&amp;quot;Displaying&amp;quot; + MS_OPENING[textToUse] + modeSpecificNumStr(drawStart)&lt;br /&gt;
            + &amp;quot; to &amp;quot; + modeSpecificNumStr(drawEnd) + MS_CLOSING[textToUse]);&lt;br /&gt;
        f2dt.fireChangeStatus(backupStatusString, false);&lt;br /&gt;
      }&lt;br /&gt;
    }&lt;br /&gt;
    // / Draws text according to the parameters set by Font2DTest GUI&lt;br /&gt;
    private void drawText(Graphics g, int w, int h) {&lt;br /&gt;
      Graphics2D g2;&lt;br /&gt;
      // / Create back buffer when not printing, and its Graphics2D&lt;br /&gt;
      // / Then set drawing parameters for that Graphics2D object&lt;br /&gt;
      if (isPrinting)&lt;br /&gt;
        g2 = (Graphics2D) g;&lt;br /&gt;
      else {&lt;br /&gt;
        backBuffer = (BufferedImage) this.createImage(w, h);&lt;br /&gt;
        g2 = backBuffer.createGraphics();&lt;br /&gt;
        g2.setColor(Color.white);&lt;br /&gt;
        g2.fillRect(0, 0, w, h);&lt;br /&gt;
        g2.setColor(Color.black);&lt;br /&gt;
      }&lt;br /&gt;
      // / sets font, RenderingHints.&lt;br /&gt;
      setParams(g2);&lt;br /&gt;
      // / If flag is set, recalculate fontMetrics and reset the scrollbar&lt;br /&gt;
      if (updateFontMetrics || isPrinting) {&lt;br /&gt;
        // / NOTE: re-calculates in case G2 transform&lt;br /&gt;
        // / is something other than NONE&lt;br /&gt;
        calcFontMetrics(g2, w, h);&lt;br /&gt;
        updateFontMetrics = false;&lt;br /&gt;
      }&lt;br /&gt;
      // / Calculate the amount of text that can be drawn...&lt;br /&gt;
      calcTextRange();&lt;br /&gt;
      // / Draw according to the set &amp;quot;Text to Use&amp;quot; mode&lt;br /&gt;
      if (textToUse == RANGE_TEXT || textToUse == ALL_GLYPHS) {&lt;br /&gt;
        int charToDraw = drawStart;&lt;br /&gt;
        if (showGrid)&lt;br /&gt;
          drawGrid(g2);&lt;br /&gt;
        if (!isPrinting)&lt;br /&gt;
          g.drawImage(backBuffer, 0, 0, this);&lt;br /&gt;
        for (int i = 0; i &amp;lt; numCharDown &amp;amp;&amp;amp; charToDraw &amp;lt;= drawEnd; i++) {&lt;br /&gt;
          for (int j = 0; j &amp;lt; numCharAcross &amp;amp;&amp;amp; charToDraw &amp;lt;= drawEnd; j++, charToDraw++) {&lt;br /&gt;
            int gridLocX = j * gridWidth + canvasInset_X;&lt;br /&gt;
            int gridLocY = i * gridHeight + canvasInset_Y;&lt;br /&gt;
            modeSpecificDrawChar(g2, charToDraw, gridLocX + gridWidth / 2, gridLocY + maxAscent);&lt;br /&gt;
            // if ( !isPrinting ) {&lt;br /&gt;
            // g.setClip( gridLocX, gridLocY, gridWidth + 1, gridHeight + 1 );&lt;br /&gt;
            // g.drawImage( backBuffer, 0, 0, this );&lt;br /&gt;
            // }&lt;br /&gt;
          }&lt;br /&gt;
        }&lt;br /&gt;
      } else if (textToUse == USER_TEXT) {&lt;br /&gt;
        g2.drawRect(0, 0, w - 1, h - 1);&lt;br /&gt;
        if (!isPrinting)&lt;br /&gt;
          g.drawImage(backBuffer, 0, 0, this);&lt;br /&gt;
        for (int i = drawStart; i &amp;lt;= drawEnd; i++) {&lt;br /&gt;
          int lineStartX = canvasInset_Y;&lt;br /&gt;
          int lineStartY = (i - drawStart) * gridHeight + maxAscent;&lt;br /&gt;
          modeSpecificDrawLine(g2, userText[i], lineStartX, lineStartY);&lt;br /&gt;
        }&lt;br /&gt;
      } else {&lt;br /&gt;
        float xPos, yPos = (float) canvasInset_Y;&lt;br /&gt;
        g2.drawRect(0, 0, w - 1, h - 1);&lt;br /&gt;
        if (!isPrinting)&lt;br /&gt;
          g.drawImage(backBuffer, 0, 0, this);&lt;br /&gt;
        for (int i = drawStart; i &amp;lt;= drawEnd; i++) {&lt;br /&gt;
          TextLayout oneLine = (TextLayout) lineBreakTLs.elementAt(i);&lt;br /&gt;
          xPos = oneLine.isLeftToRight() ? canvasInset_X&lt;br /&gt;
              : ((float) w - oneLine.getAdvance() - canvasInset_X);&lt;br /&gt;
          float fmData[] = { 0, oneLine.getAscent(), 0, oneLine.getDescent(), 0,&lt;br /&gt;
              oneLine.getLeading() };&lt;br /&gt;
          if (g2Transform != NONE) {&lt;br /&gt;
            AffineTransform at = getAffineTransform(g2Transform);&lt;br /&gt;
            at.transform(fmData, 0, fmData, 0, 3);&lt;br /&gt;
          }&lt;br /&gt;
          // yPos += oneLine.getAscent();&lt;br /&gt;
          yPos += fmData[1]; // ascent&lt;br /&gt;
          // oneLine.draw( g2, xPos, yPos );&lt;br /&gt;
          tlDrawLine(g2, oneLine, xPos, yPos);&lt;br /&gt;
          // yPos += oneLine.getDescent() + oneLine.getLeading();&lt;br /&gt;
          yPos += fmData[3] + fmData[5]; // descent + leading&lt;br /&gt;
        }&lt;br /&gt;
      }&lt;br /&gt;
      if (!isPrinting)&lt;br /&gt;
        g.drawImage(backBuffer, 0, 0, this);&lt;br /&gt;
      g2.dispose();&lt;br /&gt;
    }&lt;br /&gt;
    // / Component paintComponent function...&lt;br /&gt;
    // / Draws/Refreshes canvas according to flag(s) set by other functions&lt;br /&gt;
    public void paintComponent(Graphics g) {&lt;br /&gt;
      if (updateBackBuffer) {&lt;br /&gt;
        Dimension d = this.getSize();&lt;br /&gt;
        isPrinting = false;&lt;br /&gt;
        try {&lt;br /&gt;
          drawText(g, d.width, d.height);&lt;br /&gt;
        } catch (CannotDrawException e) {&lt;br /&gt;
          f2dt.fireChangeStatus(ERRORS[e.id], true);&lt;br /&gt;
          super.paintComponent(g);&lt;br /&gt;
          return;&lt;br /&gt;
        }&lt;br /&gt;
      } else {&lt;br /&gt;
        // / Screen refresh&lt;br /&gt;
        g.drawImage(backBuffer, 0, 0, this);&lt;br /&gt;
      }&lt;br /&gt;
      showingError = false;&lt;br /&gt;
      updateBackBuffer = false;&lt;br /&gt;
    }&lt;br /&gt;
    // / Printable interface function&lt;br /&gt;
    // / Component print function...&lt;br /&gt;
    public int print(Graphics g, PageFormat pf, int pageIndex) {&lt;br /&gt;
      if (pageIndex == 0) {&lt;br /&gt;
        // / Reset the last page index to max...&lt;br /&gt;
        lastPage = Integer.MAX_VALUE;&lt;br /&gt;
        currentlyShownChar = verticalBar.getValue() * numCharAcross;&lt;br /&gt;
      }&lt;br /&gt;
      if (printMode == ONE_PAGE) {&lt;br /&gt;
        if (pageIndex &amp;gt; 0)&lt;br /&gt;
          return NO_SUCH_PAGE;&lt;br /&gt;
      } else {&lt;br /&gt;
        if (pageIndex &amp;gt; lastPage)&lt;br /&gt;
          return NO_SUCH_PAGE;&lt;br /&gt;
      }&lt;br /&gt;
      int pageWidth = (int) pf.getImageableWidth();&lt;br /&gt;
      int pageHeight = (int) pf.getImageableHeight();&lt;br /&gt;
      // / Back up metrics and other drawing info before printing modifies it&lt;br /&gt;
      int backupDrawStart = drawStart, backupDrawEnd = drawEnd;&lt;br /&gt;
      int backupNumCharAcross = numCharAcross, backupNumCharDown = numCharDown;&lt;br /&gt;
      Vector backupLineBreakTLs = null;&lt;br /&gt;
      if (textToUse == FILE_TEXT)&lt;br /&gt;
        backupLineBreakTLs = (Vector) lineBreakTLs.clone();&lt;br /&gt;
      printPageNumber = pageIndex;&lt;br /&gt;
      isPrinting = true;&lt;br /&gt;
      // / Push the actual draw area 60 down to allow info to be printed&lt;br /&gt;
      g.translate((int) pf.getImageableX(), (int) pf.getImageableY() + 60);&lt;br /&gt;
      try {&lt;br /&gt;
        drawText(g, pageWidth, pageHeight - 60);&lt;br /&gt;
      } catch (CannotDrawException e) {&lt;br /&gt;
        f2dt.fireChangeStatus(ERRORS[e.id], true);&lt;br /&gt;
        return NO_SUCH_PAGE;&lt;br /&gt;
      }&lt;br /&gt;
      // / Draw information about what is being printed&lt;br /&gt;
      String hints = (&amp;quot; with antialias &amp;quot; + antiAliasType + &amp;quot;and&amp;quot; + &amp;quot; fractional metrics &amp;quot;&lt;br /&gt;
          + fractionalMetricsType + &amp;quot; and lcd contrast = &amp;quot; + lcdContrast);&lt;br /&gt;
      String infoLine1 = (&amp;quot;Printing&amp;quot; + MS_OPENING[textToUse] + modeSpecificNumStr(drawStart)&lt;br /&gt;
          + &amp;quot; to &amp;quot; + modeSpecificNumStr(drawEnd) + MS_CLOSING[textToUse]);&lt;br /&gt;
      String infoLine2 = (&amp;quot;With &amp;quot; + fontName + &amp;quot; &amp;quot; + STYLES[fontStyle] + &amp;quot; at &amp;quot; + fontSize&lt;br /&gt;
          + &amp;quot; point size &amp;quot; + TRANSFORMS[fontTransform]);&lt;br /&gt;
      String infoLine3 = &amp;quot;Using &amp;quot; + METHODS[drawMethod] + hints;&lt;br /&gt;
      String infoLine4 = &amp;quot;Page: &amp;quot; + (pageIndex + 1);&lt;br /&gt;
      g.setFont(new Font(&amp;quot;dialog&amp;quot;, Font.PLAIN, 12));&lt;br /&gt;
      g.setColor(Color.black);&lt;br /&gt;
      g.translate(0, -60);&lt;br /&gt;
      g.drawString(infoLine1, 15, 10);&lt;br /&gt;
      g.drawString(infoLine2, 15, 22);&lt;br /&gt;
      g.drawString(infoLine3, 15, 34);&lt;br /&gt;
      g.drawString(infoLine4, 15, 46);&lt;br /&gt;
      if (drawEnd == drawLimit)&lt;br /&gt;
        // / This indicates that the draw will be completed with this page&lt;br /&gt;
        lastPage = pageIndex;&lt;br /&gt;
      // / Restore the changed values back...&lt;br /&gt;
      // / This is important for JScrollBar settings and LineBreak&amp;quot;ed TLs&lt;br /&gt;
      drawStart = backupDrawStart;&lt;br /&gt;
      drawEnd = backupDrawEnd;&lt;br /&gt;
      numCharAcross = backupNumCharAcross;&lt;br /&gt;
      numCharDown = backupNumCharDown;&lt;br /&gt;
      if (textToUse == FILE_TEXT)&lt;br /&gt;
        lineBreakTLs = backupLineBreakTLs;&lt;br /&gt;
      return PAGE_EXISTS;&lt;br /&gt;
    }&lt;br /&gt;
    // / Ouputs the current canvas into a given PNG file&lt;br /&gt;
    public void writePNG(String fileName) {&lt;br /&gt;
      try {&lt;br /&gt;
        ImageIO.write(backBuffer, &amp;quot;png&amp;quot;, new java.io.File(fileName));&lt;br /&gt;
      } catch (Exception e) {&lt;br /&gt;
        f2dt.fireChangeStatus(&amp;quot;ERROR: Failed to Save PNG image; See stack trace&amp;quot;, true);&lt;br /&gt;
        e.printStackTrace();&lt;br /&gt;
      }&lt;br /&gt;
    }&lt;br /&gt;
    // / Figures out whether a character at the pointer location is valid&lt;br /&gt;
    // / And if so, updates mouse location informations, as well as&lt;br /&gt;
    // / the information on the status bar&lt;br /&gt;
    private boolean checkMouseLoc(MouseEvent e) {&lt;br /&gt;
      if (gridWidth != 0 &amp;amp;&amp;amp; gridHeight != 0)&lt;br /&gt;
        if (textToUse == RANGE_TEXT || textToUse == ALL_GLYPHS) {&lt;br /&gt;
          int charLocX = (e.getX() - canvasInset_X) / gridWidth;&lt;br /&gt;
          int charLocY = (e.getY() - canvasInset_Y) / gridHeight;&lt;br /&gt;
          // / Check to make sure the mouse click location is within drawn area&lt;br /&gt;
          if (charLocX &amp;gt;= 0 &amp;amp;&amp;amp; charLocY &amp;gt;= 0 &amp;amp;&amp;amp; charLocX &amp;lt; numCharAcross &amp;amp;&amp;amp; charLocY &amp;lt; numCharDown) {&lt;br /&gt;
            int mouseOverChar = charLocX + (verticalBar.getValue() + charLocY) * numCharAcross;&lt;br /&gt;
            if (textToUse == RANGE_TEXT)&lt;br /&gt;
              mouseOverChar += drawRange[0];&lt;br /&gt;
            if (mouseOverChar &amp;gt; drawEnd)&lt;br /&gt;
              return false;&lt;br /&gt;
            mouseOverCharX = charLocX;&lt;br /&gt;
            mouseOverCharY = charLocY;&lt;br /&gt;
            currMouseOverChar = mouseOverChar;&lt;br /&gt;
            // / Update status bar&lt;br /&gt;
            f2dt.fireChangeStatus(&amp;quot;Pointing to&amp;quot; + MS_OPENING[textToUse]&lt;br /&gt;
                + modeSpecificNumStr(mouseOverChar), false);&lt;br /&gt;
            return true;&lt;br /&gt;
          }&lt;br /&gt;
        }&lt;br /&gt;
      return false;&lt;br /&gt;
    }&lt;br /&gt;
    // / Shows (updates) the character zoom window&lt;br /&gt;
    public void showZoomed() {&lt;br /&gt;
      GlyphVector gv;&lt;br /&gt;
      Font backup = testFont;&lt;br /&gt;
      Point canvasLoc = this.getLocationOnScreen();&lt;br /&gt;
      // / Calculate the zoom area&amp;quot;s location and size...&lt;br /&gt;
      int dialogOffsetX = (int) (gridWidth * (ZOOM - 1) / 2);&lt;br /&gt;
      int dialogOffsetY = (int) (gridHeight * (ZOOM - 1) / 2);&lt;br /&gt;
      int zoomAreaX = mouseOverCharX * gridWidth + canvasInset_X - dialogOffsetX;&lt;br /&gt;
      int zoomAreaY = mouseOverCharY * gridHeight + canvasInset_Y - dialogOffsetY;&lt;br /&gt;
      int zoomAreaWidth = (int) (gridWidth * ZOOM);&lt;br /&gt;
      int zoomAreaHeight = (int) (gridHeight * ZOOM);&lt;br /&gt;
      // / Position and set size of zoom window as needed&lt;br /&gt;
      zoomWindow.setLocation(canvasLoc.x + zoomAreaX, canvasLoc.y + zoomAreaY);&lt;br /&gt;
      if (!nowZooming) {&lt;br /&gt;
        if (zoomWindow.getWarningString() != null)&lt;br /&gt;
          // / If this is not opened as a &amp;quot;secure&amp;quot; window,&lt;br /&gt;
          // / it has a banner below the zoom dialog which makes it look really&lt;br /&gt;
          // BAD&lt;br /&gt;
          // / So enlarge it by a bit&lt;br /&gt;
          zoomWindow.setSize(zoomAreaWidth + 1, zoomAreaHeight + 20);&lt;br /&gt;
        else&lt;br /&gt;
          zoomWindow.setSize(zoomAreaWidth + 1, zoomAreaHeight + 1);&lt;br /&gt;
      }&lt;br /&gt;
      // / Prepare zoomed image&lt;br /&gt;
      zoomImage = (BufferedImage) zoomWindow.createImage(zoomAreaWidth + 1, zoomAreaHeight + 1);&lt;br /&gt;
      Graphics2D g2 = (Graphics2D) zoomImage.getGraphics();&lt;br /&gt;
      testFont = testFont.deriveFont(fontSize * ZOOM);&lt;br /&gt;
      setParams(g2);&lt;br /&gt;
      g2.setColor(Color.white);&lt;br /&gt;
      g2.fillRect(0, 0, zoomAreaWidth, zoomAreaHeight);&lt;br /&gt;
      g2.setColor(Color.black);&lt;br /&gt;
      g2.drawRect(0, 0, zoomAreaWidth, zoomAreaHeight);&lt;br /&gt;
      modeSpecificDrawChar(g2, currMouseOverChar, zoomAreaWidth / 2, (int) (maxAscent * ZOOM));&lt;br /&gt;
      g2.dispose();&lt;br /&gt;
      if (!nowZooming)&lt;br /&gt;
        zoomWindow.show();&lt;br /&gt;
      // / This is sort of redundant... since there is a paint function&lt;br /&gt;
      // / inside zoomWindow definition that does the drawImage.&lt;br /&gt;
      // / (I should be able to call just repaint() here)&lt;br /&gt;
      // / However, for some reason, that paint function fails to respond&lt;br /&gt;
      // / from second time and on; So I have to force the paint here...&lt;br /&gt;
      zoomWindow.getGraphics().drawImage(zoomImage, 0, 0, this);&lt;br /&gt;
      nowZooming = true;&lt;br /&gt;
      prevZoomChar = currMouseOverChar;&lt;br /&gt;
      testFont = backup;&lt;br /&gt;
      // Windows does not repaint correctly, after&lt;br /&gt;
      // a zoom. Thus, we need to force the canvas&lt;br /&gt;
      // to repaint, but only once. After the first repaint,&lt;br /&gt;
      // everything stabilizes. [ABP]&lt;br /&gt;
      if (firstTime()) {&lt;br /&gt;
        refresh();&lt;br /&gt;
      }&lt;br /&gt;
    }&lt;br /&gt;
    // / Listener Functions&lt;br /&gt;
    // / MouseListener interface function&lt;br /&gt;
    // / Zooms a character when mouse is pressed above it&lt;br /&gt;
    public void mousePressed(MouseEvent e) {&lt;br /&gt;
      if (!showingError) {&lt;br /&gt;
        if (checkMouseLoc(e)) {&lt;br /&gt;
          showZoomed();&lt;br /&gt;
          this.setCursor(blankCursor);&lt;br /&gt;
        }&lt;br /&gt;
      }&lt;br /&gt;
    }&lt;br /&gt;
    // / MouseListener interface function&lt;br /&gt;
    // / Redraws the area that was drawn over by zoomed character&lt;br /&gt;
    public void mouseReleased(MouseEvent e) {&lt;br /&gt;
      if (textToUse == RANGE_TEXT || textToUse == ALL_GLYPHS) {&lt;br /&gt;
        if (nowZooming)&lt;br /&gt;
          zoomWindow.hide();&lt;br /&gt;
        nowZooming = false;&lt;br /&gt;
      }&lt;br /&gt;
      this.setCursor(Cursor.getDefaultCursor());&lt;br /&gt;
    }&lt;br /&gt;
    // / MouseListener interface function&lt;br /&gt;
    // / Resets the status bar to display range instead of a specific character&lt;br /&gt;
    public void mouseExited(MouseEvent e) {&lt;br /&gt;
      if (!showingError &amp;amp;&amp;amp; !nowZooming)&lt;br /&gt;
        f2dt.fireChangeStatus(backupStatusString, false);&lt;br /&gt;
    }&lt;br /&gt;
    // / MouseMotionListener interface function&lt;br /&gt;
    // / Adjusts the status bar message when mouse moves over a character&lt;br /&gt;
    public void mouseMoved(MouseEvent e) {&lt;br /&gt;
      if (!showingError) {&lt;br /&gt;
        if (!checkMouseLoc(e))&lt;br /&gt;
          f2dt.fireChangeStatus(backupStatusString, false);&lt;br /&gt;
      }&lt;br /&gt;
    }&lt;br /&gt;
    // / MouseMotionListener interface function&lt;br /&gt;
    // / Scrolls the zoomed character when mouse is dragged&lt;br /&gt;
    public void mouseDragged(MouseEvent e) {&lt;br /&gt;
      if (!showingError)&lt;br /&gt;
        if (nowZooming) {&lt;br /&gt;
          if (checkMouseLoc(e) &amp;amp;&amp;amp; currMouseOverChar != prevZoomChar)&lt;br /&gt;
            showZoomed();&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
    // / Empty function to comply with interface requirement&lt;br /&gt;
    public void mouseClicked(MouseEvent e) {&lt;br /&gt;
    }&lt;br /&gt;
    public void mouseEntered(MouseEvent e) {&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
  private final class CannotDrawException extends RuntimeException {&lt;br /&gt;
    // / Error ID&lt;br /&gt;
    public final int id;&lt;br /&gt;
    public CannotDrawException(int i) {&lt;br /&gt;
      id = i;&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
  enum FMValues {&lt;br /&gt;
    FMDEFAULT(&amp;quot;DEFAULT&amp;quot;, VALUE_FRACTIONALMETRICS_DEFAULT), FMOFF(&amp;quot;OFF&amp;quot;, VALUE_FRACTIONALMETRICS_OFF), FMON(&lt;br /&gt;
        &amp;quot;ON&amp;quot;, VALUE_FRACTIONALMETRICS_ON);&lt;br /&gt;
    private String name;&lt;br /&gt;
    private Object hint;&lt;br /&gt;
    private static FMValues[] valArray;&lt;br /&gt;
    FMValues(String s, Object o) {&lt;br /&gt;
      name = s;&lt;br /&gt;
      hint = o;&lt;br /&gt;
    }&lt;br /&gt;
    public String toString() {&lt;br /&gt;
      return name;&lt;br /&gt;
    }&lt;br /&gt;
    public Object getHint() {&lt;br /&gt;
      return hint;&lt;br /&gt;
    }&lt;br /&gt;
    public static Object getValue(int ordinal) {&lt;br /&gt;
      if (valArray == null) {&lt;br /&gt;
        valArray = (FMValues[]) EnumSet.allOf(FMValues.class).toArray(new FMValues[0]);&lt;br /&gt;
      }&lt;br /&gt;
      for (int i = 0; i &amp;lt; valArray.length; i++) {&lt;br /&gt;
        if (valArray[i].ordinal() == ordinal) {&lt;br /&gt;
          return valArray[i];&lt;br /&gt;
        }&lt;br /&gt;
      }&lt;br /&gt;
      return valArray[0];&lt;br /&gt;
    }&lt;br /&gt;
    private static FMValues[] getArray() {&lt;br /&gt;
      if (valArray == null) {&lt;br /&gt;
        valArray = (FMValues[]) EnumSet.allOf(FMValues.class).toArray(new FMValues[0]);&lt;br /&gt;
      }&lt;br /&gt;
      return valArray;&lt;br /&gt;
    }&lt;br /&gt;
    public static int getHintVal(Object hint) {&lt;br /&gt;
      getArray();&lt;br /&gt;
      for (int i = 0; i &amp;lt; valArray.length; i++) {&lt;br /&gt;
        if (valArray[i].getHint() == hint) {&lt;br /&gt;
          return i;&lt;br /&gt;
        }&lt;br /&gt;
      }&lt;br /&gt;
      return 0;&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
  enum AAValues {&lt;br /&gt;
    AADEFAULT(&amp;quot;DEFAULT&amp;quot;, VALUE_TEXT_ANTIALIAS_DEFAULT), AAOFF(&amp;quot;OFF&amp;quot;, VALUE_TEXT_ANTIALIAS_OFF), AAON(&lt;br /&gt;
        &amp;quot;ON&amp;quot;, VALUE_TEXT_ANTIALIAS_ON), AAGASP(&amp;quot;GASP&amp;quot;, VALUE_TEXT_ANTIALIAS_GASP), AALCDHRGB(&lt;br /&gt;
        &amp;quot;LCD_HRGB&amp;quot;, VALUE_TEXT_ANTIALIAS_LCD_HRGB), AALCDHBGR(&amp;quot;LCD_HBGR&amp;quot;,&lt;br /&gt;
        VALUE_TEXT_ANTIALIAS_LCD_HBGR), AALCDVRGB(&amp;quot;LCD_VRGB&amp;quot;, VALUE_TEXT_ANTIALIAS_LCD_VRGB), AALCDVBGR(&lt;br /&gt;
        &amp;quot;LCD_VBGR&amp;quot;, VALUE_TEXT_ANTIALIAS_LCD_VBGR);&lt;br /&gt;
    private String name;&lt;br /&gt;
    private Object hint;&lt;br /&gt;
    private static AAValues[] valArray;&lt;br /&gt;
    AAValues(String s, Object o) {&lt;br /&gt;
      name = s;&lt;br /&gt;
      hint = o;&lt;br /&gt;
    }&lt;br /&gt;
    public String toString() {&lt;br /&gt;
      return name;&lt;br /&gt;
    }&lt;br /&gt;
    public Object getHint() {&lt;br /&gt;
      return hint;&lt;br /&gt;
    }&lt;br /&gt;
    public static boolean isLCDMode(Object o) {&lt;br /&gt;
      return (o instanceof AAValues &amp;amp;&amp;amp; ((AAValues) o).ordinal() &amp;gt;= AALCDHRGB.ordinal());&lt;br /&gt;
    }&lt;br /&gt;
    public static Object getValue(int ordinal) {&lt;br /&gt;
      if (valArray == null) {&lt;br /&gt;
        valArray = (AAValues[]) EnumSet.allOf(AAValues.class).toArray(new AAValues[0]);&lt;br /&gt;
      }&lt;br /&gt;
      for (int i = 0; i &amp;lt; valArray.length; i++) {&lt;br /&gt;
        if (valArray[i].ordinal() == ordinal) {&lt;br /&gt;
          return valArray[i];&lt;br /&gt;
        }&lt;br /&gt;
      }&lt;br /&gt;
      return valArray[0];&lt;br /&gt;
    }&lt;br /&gt;
    private static AAValues[] getArray() {&lt;br /&gt;
      if (valArray == null) {&lt;br /&gt;
        Object[] oa = EnumSet.allOf(AAValues.class).toArray(new AAValues[0]);&lt;br /&gt;
        valArray = (AAValues[]) (EnumSet.allOf(AAValues.class).toArray(new AAValues[0]));&lt;br /&gt;
      }&lt;br /&gt;
      return valArray;&lt;br /&gt;
    }&lt;br /&gt;
    public static int getHintVal(Object hint) {&lt;br /&gt;
      getArray();&lt;br /&gt;
      for (int i = 0; i &amp;lt; valArray.length; i++) {&lt;br /&gt;
        if (valArray[i].getHint() == hint) {&lt;br /&gt;
          return i;&lt;br /&gt;
        }&lt;br /&gt;
      }&lt;br /&gt;
      return 0;&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
  private static Integer defaultContrast;&lt;br /&gt;
  static Integer getDefaultLCDContrast() {&lt;br /&gt;
    if (defaultContrast == null) {&lt;br /&gt;
      GraphicsConfiguration gc = GraphicsEnvironment.getLocalGraphicsEnvironment()&lt;br /&gt;
          .getDefaultScreenDevice().getDefaultConfiguration();&lt;br /&gt;
      Graphics2D g2d = (Graphics2D) (gc.createCompatibleImage(1, 1).getGraphics());&lt;br /&gt;
      defaultContrast = (Integer) g2d.getRenderingHint(RenderingHints.KEY_TEXT_LCD_CONTRAST);&lt;br /&gt;
    }&lt;br /&gt;
    return defaultContrast;&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
/*&lt;br /&gt;
 * @(#)RangeMenu.java 1.18 05/11/17&lt;br /&gt;
 * &lt;br /&gt;
 * Copyright (c) 2006 Sun Microsystems, Inc. All Rights Reserved.&lt;br /&gt;
 * &lt;br /&gt;
 * Redistribution and use in source and binary forms, with or without&lt;br /&gt;
 * modification, are permitted provided that the following conditions are met:&lt;br /&gt;
 * &lt;br /&gt;
 * -Redistribution of source code must retain the above copyright notice, this&lt;br /&gt;
 * list of conditions and the following disclaimer.&lt;br /&gt;
 * &lt;br /&gt;
 * -Redistribution in binary form must reproduce the above copyright notice,&lt;br /&gt;
 * this list of conditions and the following disclaimer in the documentation&lt;br /&gt;
 * and/or other materials provided with the distribution.&lt;br /&gt;
 * &lt;br /&gt;
 * Neither the name of Sun Microsystems, Inc. or the names of contributors may&lt;br /&gt;
 * be used to endorse or promote products derived from this software without&lt;br /&gt;
 * specific prior written permission.&lt;br /&gt;
 * &lt;br /&gt;
 * This software is provided &amp;quot;AS IS,&amp;quot; without a warranty of any kind. ALL&lt;br /&gt;
 * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING ANY&lt;br /&gt;
 * IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR&lt;br /&gt;
 * NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN MIDROSYSTEMS, INC. (&amp;quot;SUN&amp;quot;) AND ITS&lt;br /&gt;
 * LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A&lt;br /&gt;
 * RESULT OF USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES.&lt;br /&gt;
 * IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT&lt;br /&gt;
 * OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR&lt;br /&gt;
 * PUNITIVE DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY,&lt;br /&gt;
 * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF SUN HAS&lt;br /&gt;
 * BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.&lt;br /&gt;
 * &lt;br /&gt;
 * You acknowledge that this software is not designed, licensed or intended for&lt;br /&gt;
 * use in the design, construction, operation or maintenance of any nuclear&lt;br /&gt;
 * facility.&lt;br /&gt;
 */&lt;br /&gt;
/*&lt;br /&gt;
 * @(#)RangeMenu.java 1.18 05/11/17&lt;br /&gt;
 */&lt;br /&gt;
/**&lt;br /&gt;
 * RangeMenu.java&lt;br /&gt;
 * &lt;br /&gt;
 * @version&lt;br /&gt;
 * @(#)RangeMenu.java 1.1 00/08/22&lt;br /&gt;
 * @author Shinsuke Fukuda&lt;br /&gt;
 * @author Ankit Patel [Conversion to Swing - 01/07/30]&lt;br /&gt;
 */&lt;br /&gt;
// / Custom made choice menu that holds data for unicode range&lt;br /&gt;
final class RangeMenu extends JComboBox implements ActionListener {&lt;br /&gt;
  // / Painfully extracted from java.lang.Character.UnicodeBlock. Arrrgh!&lt;br /&gt;
  // / Unicode 3.0 data.&lt;br /&gt;
  private final int[][] UNICODE_RANGES = { { 0x000000, 0x00007f }, // /&lt;br /&gt;
                                                                    // BASIC_LATIN&lt;br /&gt;
      { 0x000080, 0x0000ff }, // / LATIN_1_SUPPLEMENT&lt;br /&gt;
      { 0x000100, 0x00017f }, // / LATIN_EXTENDED_A&lt;br /&gt;
      { 0x000180, 0x00024f }, // / LATIN_EXTENDED_B&lt;br /&gt;
      { 0x000250, 0x0002af }, // / IPA_EXTENSIONS&lt;br /&gt;
      { 0x0002b0, 0x0002ff }, // / SPACING_MODIFIER_LETTERS&lt;br /&gt;
      { 0x000300, 0x00036f }, // / COMBINING_DIACRITICAL_MARKS&lt;br /&gt;
      { 0x000370, 0x0003ff }, // / GREEK&lt;br /&gt;
      { 0x000400, 0x0004ff }, // / CYRILLIC&lt;br /&gt;
      { 0x000500, 0x00052f }, // / CYRILLIC_SUPPLEMENTARY&lt;br /&gt;
      { 0x000530, 0x00058f }, // / ARMENIAN&lt;br /&gt;
      { 0x000590, 0x0005ff }, // / HEBREW&lt;br /&gt;
      { 0x000600, 0x0006ff }, // / ARABIC&lt;br /&gt;
      { 0x000700, 0x00074f }, // / SYRIAC&lt;br /&gt;
      { 0x000780, 0x0007bf }, // / THAANA&lt;br /&gt;
      { 0x000900, 0x00097f }, // / DEVANAGARI&lt;br /&gt;
      { 0x000980, 0x0009ff }, // / BENGALI&lt;br /&gt;
      { 0x000a00, 0x000a7f }, // / GURMUKHI&lt;br /&gt;
      { 0x000a80, 0x000aff }, // / GUJARATI&lt;br /&gt;
      { 0x000b00, 0x000b7f }, // / ORIYA&lt;br /&gt;
      { 0x000b80, 0x000bff }, // / TAMIL&lt;br /&gt;
      { 0x000c00, 0x000c7f }, // / TELUGU&lt;br /&gt;
      { 0x000c80, 0x000cff }, // / KANNADA&lt;br /&gt;
      { 0x000d00, 0x000d7f }, // / MALAYALAM&lt;br /&gt;
      { 0x000d80, 0x000dff }, // / SINHALA&lt;br /&gt;
      { 0x000e00, 0x000e7f }, // / THAI&lt;br /&gt;
      { 0x000e80, 0x000eff }, // / LAO&lt;br /&gt;
      { 0x000f00, 0x000fff }, // / TIBETAN&lt;br /&gt;
      { 0x001000, 0x00109f }, // / MYANMAR&lt;br /&gt;
      { 0x0010a0, 0x0010ff }, // / GEORGIAN&lt;br /&gt;
      { 0x001100, 0x0011ff }, // / HANGUL_JAMO&lt;br /&gt;
      { 0x001200, 0x00137f }, // / ETHIOPIC&lt;br /&gt;
      { 0x0013a0, 0x0013ff }, // / CHEROKEE&lt;br /&gt;
      { 0x001400, 0x00167f }, // / UNIFIED_CANADIAN_ABORIGINAL_SYLLABICS&lt;br /&gt;
      { 0x001680, 0x00169f }, // / OGHAM&lt;br /&gt;
      { 0x0016a0, 0x0016ff }, // / RUNIC&lt;br /&gt;
      { 0x001700, 0x00171f }, // / TAGALOG&lt;br /&gt;
      { 0x001720, 0x00173f }, // / HANUNOO&lt;br /&gt;
      { 0x001740, 0x00175f }, // / BUHID&lt;br /&gt;
      { 0x001760, 0x00177f }, // / TAGBANWA&lt;br /&gt;
      { 0x001780, 0x0017ff }, // / KHMER&lt;br /&gt;
      { 0x001800, 0x0018af }, // / MONGOLIAN&lt;br /&gt;
      { 0x001900, 0x00194f }, // / LIMBU&lt;br /&gt;
      { 0x001950, 0x00197f }, // / TAI_LE&lt;br /&gt;
      { 0x0019e0, 0x0019ff }, // / KHMER_SYMBOLS&lt;br /&gt;
      { 0x001d00, 0x001d7f }, // / PHONETIC_EXTENSIONS&lt;br /&gt;
      { 0x001e00, 0x001eff }, // / LATIN_EXTENDED_ADDITIONAL&lt;br /&gt;
      { 0x001f00, 0x001fff }, // / GREEK_EXTENDED&lt;br /&gt;
      { 0x002000, 0x00206f }, // / GENERAL_PUNCTUATION&lt;br /&gt;
      { 0x002070, 0x00209f }, // / SUPERSCRIPTS_AND_SUBSCRIPTS&lt;br /&gt;
      { 0x0020a0, 0x0020cf }, // / CURRENCY_SYMBOLS&lt;br /&gt;
      { 0x0020d0, 0x0020ff }, // / COMBINING_MARKS_FOR_SYMBOLS&lt;br /&gt;
      { 0x002100, 0x00214f }, // / LETTERLIKE_SYMBOLS&lt;br /&gt;
      { 0x002150, 0x00218f }, // / NUMBER_FORMS&lt;br /&gt;
      { 0x002190, 0x0021ff }, // / ARROWS&lt;br /&gt;
      { 0x002200, 0x0022ff }, // / MATHEMATICAL_OPERATORS&lt;br /&gt;
      { 0x002300, 0x0023ff }, // / MISCELLANEOUS_TECHNICAL&lt;br /&gt;
      { 0x002400, 0x00243f }, // / CONTROL_PICTURES&lt;br /&gt;
      { 0x002440, 0x00245f }, // / OPTICAL_CHARACTER_RECOGNITION&lt;br /&gt;
      { 0x002460, 0x0024ff }, // / ENCLOSED_ALPHANUMERICS&lt;br /&gt;
      { 0x002500, 0x00257f }, // / BOX_DRAWING&lt;br /&gt;
      { 0x002580, 0x00259f }, // / BLOCK_ELEMENTS&lt;br /&gt;
      { 0x0025a0, 0x0025ff }, // / GEOMETRIC_SHAPES&lt;br /&gt;
      { 0x002600, 0x0026ff }, // / MISCELLANEOUS_SYMBOLS&lt;br /&gt;
      { 0x002700, 0x0027bf }, // / DINGBATS&lt;br /&gt;
      { 0x0027c0, 0x0027ef }, // / MISCELLANEOUS_MATHEMATICAL_SYMBOLS_A&lt;br /&gt;
      { 0x0027f0, 0x0027ff }, // / SUPPLEMENTAL_ARROWS_A&lt;br /&gt;
      { 0x002800, 0x0028ff }, // / BRAILLE_PATTERNS&lt;br /&gt;
      { 0x002900, 0x00297f }, // / SUPPLEMENTAL_ARROWS_B&lt;br /&gt;
      { 0x002980, 0x0029ff }, // / MISCELLANEOUS_MATHEMATICAL_SYMBOLS_B&lt;br /&gt;
      { 0x002a00, 0x002aff }, // / SUPPLEMENTAL_MATHEMATICAL_OPERATORS&lt;br /&gt;
      { 0x002b00, 0x002bff }, // / MISCELLANEOUS_SYMBOLS_AND_ARROWS&lt;br /&gt;
      { 0x002e80, 0x002eff }, // / CJK_RADICALS_SUPPLEMENT&lt;br /&gt;
      { 0x002f00, 0x002fdf }, // / KANGXI_RADICALS&lt;br /&gt;
      { 0x002ff0, 0x002fff }, // / IDEOGRAPHIC_DESCRIPTION_CHARACTERS&lt;br /&gt;
      { 0x003000, 0x00303f }, // / CJK_SYMBOLS_AND_PUNCTUATION&lt;br /&gt;
      { 0x003040, 0x00309f }, // / HIRAGANA&lt;br /&gt;
      { 0x0030a0, 0x0030ff }, // / KATAKANA&lt;br /&gt;
      { 0x003100, 0x00312f }, // / BOPOMOFO&lt;br /&gt;
      { 0x003130, 0x00318f }, // / HANGUL_COMPATIBILITY_JAMO&lt;br /&gt;
      { 0x003190, 0x00319f }, // / KANBUN&lt;br /&gt;
      { 0x0031a0, 0x0031bf }, // / BOPOMOFO_EXTENDED&lt;br /&gt;
      { 0x0031f0, 0x0031ff }, // / KATAKANA_PHONETIC_EXTENSIONS&lt;br /&gt;
      { 0x003200, 0x0032ff }, // / ENCLOSED_CJK_LETTERS_AND_MONTHS&lt;br /&gt;
      { 0x003300, 0x0033ff }, // / CJK_COMPATIBILITY&lt;br /&gt;
      { 0x003400, 0x004dbf }, // / CJK_UNIFIED_IDEOGRAPHS_EXTENSION_A&lt;br /&gt;
      { 0x004dc0, 0x004dff }, // / YIJING_HEXAGRAM_SYMBOLS&lt;br /&gt;
      { 0x004e00, 0x009fff }, // / CJK_UNIFIED_IDEOGRAPHS&lt;br /&gt;
      { 0x00a000, 0x00a48f }, // / YI_SYLLABLES&lt;br /&gt;
      { 0x00a490, 0x00a4cf }, // / YI_RADICALS&lt;br /&gt;
      { 0x00ac00, 0x00d7af }, // / HANGUL_SYLLABLES&lt;br /&gt;
      { 0x00d800, 0x00dfff }, // / SURROGATES_AREA&lt;br /&gt;
      { 0x00e000, 0x00f8ff }, // / PRIVATE_USE_AREA&lt;br /&gt;
      { 0x00f900, 0x00faff }, // / CJK_COMPATIBILITY_IDEOGRAPHS&lt;br /&gt;
      { 0x00fb00, 0x00fb4f }, // / ALPHABETIC_PRESENTATION_FORMS&lt;br /&gt;
      { 0x00fb50, 0x00fdff }, // / ARABIC_PRESENTATION_FORMS_A&lt;br /&gt;
      { 0x00fe00, 0x00fe0f }, // / VARIATION_SELECTORS&lt;br /&gt;
      { 0x00fe20, 0x00fe2f }, // / COMBINING_HALF_MARKS&lt;br /&gt;
      { 0x00fe30, 0x00fe4f }, // / CJK_COMPATIBILITY_FORMS&lt;br /&gt;
      { 0x00fe50, 0x00fe6f }, // / SMALL_FORM_VARIANTS&lt;br /&gt;
      { 0x00fe70, 0x00feff }, // / ARABIC_PRESENTATION_FORMS_B&lt;br /&gt;
      { 0x00ff00, 0x00ffef }, // / HALFWIDTH_AND_FULLWIDTH_FORMS&lt;br /&gt;
      { 0x00fff0, 0x00ffff }, // / SPECIALS&lt;br /&gt;
      { 0x010000, 0x01007f }, // / LINEAR_B_SYLLABARY&lt;br /&gt;
      { 0x010080, 0x0100ff }, // / LINEAR_B_IDEOGRAMS&lt;br /&gt;
      { 0x010100, 0x01013f }, // / AEGEAN_NUMBERS&lt;br /&gt;
      { 0x010300, 0x01032f }, // / OLD_ITALIC&lt;br /&gt;
      { 0x010330, 0x01034f }, // / GOTHIC&lt;br /&gt;
      { 0x010380, 0x01039f }, // / UGARITIC&lt;br /&gt;
      { 0x010400, 0x01044f }, // / DESERET&lt;br /&gt;
      { 0x010450, 0x01047f }, // / SHAVIAN&lt;br /&gt;
      { 0x010480, 0x0104af }, // / OSMANYA&lt;br /&gt;
      { 0x010800, 0x01083f }, // / CYPRIOT_SYLLABARY&lt;br /&gt;
      { 0x01d000, 0x01d0ff }, // / BYZANTINE_MUSICAL_SYMBOLS&lt;br /&gt;
      { 0x01d100, 0x01d1ff }, // / MUSICAL_SYMBOLS&lt;br /&gt;
      { 0x01d300, 0x01d35f }, // / TAI_XUAN_JING_SYMBOLS&lt;br /&gt;
      { 0x01d400, 0x01d7ff }, // / MATHEMATICAL_ALPHANUMERIC_SYMBOLS&lt;br /&gt;
      { 0x020000, 0x02a6df }, // / CJK_UNIFIED_IDEOGRAPHS_EXTENSION_B&lt;br /&gt;
      { 0x02f800, 0x02fa1f }, // / CJK_COMPATIBILITY_IDEOGRAPHS_SUPPLEMENT&lt;br /&gt;
      { 0x0e0000, 0x0e007f }, // / TAGS&lt;br /&gt;
      { 0x0e0100, 0x0e01ef }, // / VARIATION_SELECTORS_SUPPLEMENT&lt;br /&gt;
      { 0x0f0000, 0x0fffff }, // / SUPPLEMENTARY_PRIVATE_USE_AREA_A&lt;br /&gt;
      { 0x100000, 0x10ffff }, // / SUPPLEMENTARY_PRIVATE_USE_AREA_B&lt;br /&gt;
      { 0x000000, 0x00007f }, // / OTHER [USER DEFINED RANGE]&lt;br /&gt;
  };&lt;br /&gt;
  private final String[] UNICODE_RANGE_NAMES = { &amp;quot;Basic Latin&amp;quot;, &amp;quot;Latin-1 Supplement&amp;quot;,&lt;br /&gt;
      &amp;quot;Latin Extended-A&amp;quot;, &amp;quot;Latin Extended-B&amp;quot;, &amp;quot;IPA Extensions&amp;quot;, &amp;quot;Spacing Modifier Letters&amp;quot;,&lt;br /&gt;
      &amp;quot;Combining Diacritical Marks&amp;quot;, &amp;quot;Greek&amp;quot;, &amp;quot;Cyrillic&amp;quot;, &amp;quot;Cyrillic Supplement&amp;quot;, &amp;quot;Armenian&amp;quot;,&lt;br /&gt;
      &amp;quot;Hebrew&amp;quot;, &amp;quot;Arabic&amp;quot;, &amp;quot;Syriac&amp;quot;, &amp;quot;Thaana&amp;quot;, &amp;quot;Devanagari&amp;quot;, &amp;quot;Bengali&amp;quot;, &amp;quot;Gurmukhi&amp;quot;, &amp;quot;Gujarati&amp;quot;,&lt;br /&gt;
      &amp;quot;Oriya&amp;quot;, &amp;quot;Tamil&amp;quot;, &amp;quot;Telugu&amp;quot;, &amp;quot;Kannada&amp;quot;, &amp;quot;Malayalam&amp;quot;, &amp;quot;Sinhala&amp;quot;, &amp;quot;Thai&amp;quot;, &amp;quot;Lao&amp;quot;, &amp;quot;Tibetan&amp;quot;,&lt;br /&gt;
      &amp;quot;Myanmar&amp;quot;, &amp;quot;Georgian&amp;quot;, &amp;quot;Hangul Jamo&amp;quot;, &amp;quot;Ethiopic&amp;quot;, &amp;quot;Cherokee&amp;quot;,&lt;br /&gt;
      &amp;quot;Unified Canadian Aboriginal Syllabics&amp;quot;, &amp;quot;Ogham&amp;quot;, &amp;quot;Runic&amp;quot;, &amp;quot;Tagalog&amp;quot;, &amp;quot;Hanunoo&amp;quot;, &amp;quot;Buhid&amp;quot;,&lt;br /&gt;
      &amp;quot;Tagbanwa&amp;quot;, &amp;quot;Khmer&amp;quot;, &amp;quot;Mongolian&amp;quot;, &amp;quot;Limbu&amp;quot;, &amp;quot;Tai Le&amp;quot;, &amp;quot;Khmer Symbols&amp;quot;, &amp;quot;Phonetic Extensions&amp;quot;,&lt;br /&gt;
      &amp;quot;Latin Extended Additional&amp;quot;, &amp;quot;Greek Extended&amp;quot;, &amp;quot;General Punctuation&amp;quot;,&lt;br /&gt;
      &amp;quot;Superscripts and Subscripts&amp;quot;, &amp;quot;Currency Symbols&amp;quot;, &amp;quot;Combining Marks for Symbols&amp;quot;,&lt;br /&gt;
      &amp;quot;Letterlike Symbols&amp;quot;, &amp;quot;Number Forms&amp;quot;, &amp;quot;Arrows&amp;quot;, &amp;quot;Mathematical Operators&amp;quot;,&lt;br /&gt;
      &amp;quot;Miscellaneous Technical&amp;quot;, &amp;quot;Control Pictures&amp;quot;, &amp;quot;Optical Character Recognition&amp;quot;,&lt;br /&gt;
      &amp;quot;Enclosed Alphanumerics&amp;quot;, &amp;quot;Box Drawing&amp;quot;, &amp;quot;Block Elements&amp;quot;, &amp;quot;Geometric Shapes&amp;quot;,&lt;br /&gt;
      &amp;quot;Miscellaneous Symbols&amp;quot;, &amp;quot;Dingbats&amp;quot;, &amp;quot;Miscellaneous Mathematical Symbols-A&amp;quot;,&lt;br /&gt;
      &amp;quot;Supplemental Arrows-A&amp;quot;, &amp;quot;Braille Patterns&amp;quot;, &amp;quot;Supplemental Arrows-B&amp;quot;,&lt;br /&gt;
      &amp;quot;Miscellaneous Mathematical Symbols-B&amp;quot;, &amp;quot;Supplemental Mathematical Operators&amp;quot;,&lt;br /&gt;
      &amp;quot;Miscellaneous Symbols and Arrows&amp;quot;, &amp;quot;CJK Radicals Supplement&amp;quot;, &amp;quot;Kangxi Radicals&amp;quot;,&lt;br /&gt;
      &amp;quot;Ideographic Description Characters&amp;quot;, &amp;quot;CJK Symbols and Punctuation&amp;quot;, &amp;quot;Hiragana&amp;quot;, &amp;quot;Katakana&amp;quot;,&lt;br /&gt;
      &amp;quot;Bopomofo&amp;quot;, &amp;quot;Hangul Compatibility Jamo&amp;quot;, &amp;quot;Kanbun&amp;quot;, &amp;quot;Bopomofo Extended&amp;quot;,&lt;br /&gt;
      &amp;quot;Katakana Phonetic Extensions&amp;quot;, &amp;quot;Enclosed CJK Letters and Months&amp;quot;, &amp;quot;CJK Compatibility&amp;quot;,&lt;br /&gt;
      &amp;quot;CJK Unified Ideographs Extension A&amp;quot;, &amp;quot;Yijing Hexagram Symbols&amp;quot;, &amp;quot;CJK Unified Ideographs&amp;quot;,&lt;br /&gt;
      &amp;quot;Yi Syllables&amp;quot;, &amp;quot;Yi Radicals&amp;quot;, &amp;quot;Hangul Syllables&amp;quot;, &amp;quot;Surrogates Area&amp;quot;, // High&lt;br /&gt;
                                                                            // Surrogates,&lt;br /&gt;
                                                                            // High&lt;br /&gt;
                                                                            // Private&lt;br /&gt;
                                                                            // Use&lt;br /&gt;
                                                                            // Surrogates,&lt;br /&gt;
                                                                            // Low&lt;br /&gt;
                                                                            // Surrogates&lt;br /&gt;
      &amp;quot;Private Use Area&amp;quot;, &amp;quot;CJK Compatibility Ideographs&amp;quot;, &amp;quot;Alphabetic Presentation Forms&amp;quot;,&lt;br /&gt;
      &amp;quot;Arabic Presentation Forms-A&amp;quot;, &amp;quot;Variation Selectors&amp;quot;, &amp;quot;Combining Half Marks&amp;quot;,&lt;br /&gt;
      &amp;quot;CJK Compatibility Forms&amp;quot;, &amp;quot;Small Form Variants&amp;quot;, &amp;quot;Arabic Presentation Forms-B&amp;quot;,&lt;br /&gt;
      &amp;quot;Halfwidth and Fullwidth Forms&amp;quot;, &amp;quot;Specials&amp;quot;, &amp;quot;Linear B Syllabary&amp;quot;, &amp;quot;Linear B Ideograms&amp;quot;,&lt;br /&gt;
      &amp;quot;Aegean Numbers&amp;quot;, &amp;quot;Old Italic&amp;quot;, &amp;quot;Gothic&amp;quot;, &amp;quot;Ugaritic&amp;quot;, &amp;quot;Deseret&amp;quot;, &amp;quot;Shavian&amp;quot;, &amp;quot;Osmanya&amp;quot;,&lt;br /&gt;
      &amp;quot;Cypriot Syllabary&amp;quot;, &amp;quot;Byzantine Musical Symbols&amp;quot;, &amp;quot;Musical Symbols&amp;quot;, &amp;quot;Tai Xuan Jing Symbols&amp;quot;,&lt;br /&gt;
      &amp;quot;Mathematical Alphanumeric Symbols&amp;quot;, &amp;quot;CJK Unified Ideographs Extension B&amp;quot;,&lt;br /&gt;
      &amp;quot;CJK Compatibility Ideographs Supplement&amp;quot;, &amp;quot;Tags&amp;quot;, &amp;quot;Variation Selectors Supplement&amp;quot;,&lt;br /&gt;
      &amp;quot;Supplementary Private Use Area-A&amp;quot;, &amp;quot;Supplementary Private Use Area-B&amp;quot;, &amp;quot;Custom...&amp;quot;, };&lt;br /&gt;
  private boolean useCustomRange = false;&lt;br /&gt;
  private int[] customRange = { 0x0000, 0x007f };&lt;br /&gt;
  // / Custom range dialog variables&lt;br /&gt;
  private final JDialog customRangeDialog;&lt;br /&gt;
  private final JTextField customRangeStart = new JTextField(&amp;quot;0000&amp;quot;, 4);&lt;br /&gt;
  private final JTextField customRangeEnd = new JTextField(&amp;quot;007F&amp;quot;, 4);&lt;br /&gt;
  private final int CUSTOM_RANGE_INDEX = UNICODE_RANGE_NAMES.length - 1;&lt;br /&gt;
  // / Parent Font2DTest Object holder&lt;br /&gt;
  private final Font2DTest parent;&lt;br /&gt;
  public static final int SURROGATES_AREA_INDEX = 91;&lt;br /&gt;
  public RangeMenu(Font2DTest demo, JFrame f) {&lt;br /&gt;
    super();&lt;br /&gt;
    parent = demo;&lt;br /&gt;
    for (int i = 0; i &amp;lt; UNICODE_RANGE_NAMES.length; i++)&lt;br /&gt;
      addItem(UNICODE_RANGE_NAMES[i]);&lt;br /&gt;
    setSelectedIndex(0);&lt;br /&gt;
    addActionListener(this);&lt;br /&gt;
    // / Set up custom range dialog...&lt;br /&gt;
    customRangeDialog = new JDialog(f, &amp;quot;Custom Unicode Range&amp;quot;, true);&lt;br /&gt;
    customRangeDialog.setResizable(false);&lt;br /&gt;
    JPanel dialogTop = new JPanel();&lt;br /&gt;
    JPanel dialogBottom = new JPanel();&lt;br /&gt;
    JButton okButton = new JButton(&amp;quot;OK&amp;quot;);&lt;br /&gt;
    JLabel from = new JLabel(&amp;quot;From:&amp;quot;);&lt;br /&gt;
    JLabel to = new JLabel(&amp;quot;To:&amp;quot;);&lt;br /&gt;
    Font labelFont = new Font(&amp;quot;dialog&amp;quot;, Font.BOLD, 12);&lt;br /&gt;
    from.setFont(labelFont);&lt;br /&gt;
    to.setFont(labelFont);&lt;br /&gt;
    okButton.setFont(labelFont);&lt;br /&gt;
    dialogTop.add(from);&lt;br /&gt;
    dialogTop.add(customRangeStart);&lt;br /&gt;
    dialogTop.add(to);&lt;br /&gt;
    dialogTop.add(customRangeEnd);&lt;br /&gt;
    dialogBottom.add(okButton);&lt;br /&gt;
    okButton.addActionListener(this);&lt;br /&gt;
    customRangeDialog.getContentPane().setLayout(new BorderLayout());&lt;br /&gt;
    customRangeDialog.getContentPane().add(&amp;quot;North&amp;quot;, dialogTop);&lt;br /&gt;
    customRangeDialog.getContentPane().add(&amp;quot;South&amp;quot;, dialogBottom);&lt;br /&gt;
    customRangeDialog.pack();&lt;br /&gt;
  }&lt;br /&gt;
  // / Return the range that is currently selected&lt;br /&gt;
  public int[] getSelectedRange() {&lt;br /&gt;
    if (useCustomRange) {&lt;br /&gt;
      int startIndex, endIndex;&lt;br /&gt;
      String startText, endText;&lt;br /&gt;
      String empty = &amp;quot;&amp;quot;;&lt;br /&gt;
      try {&lt;br /&gt;
        startText = customRangeStart.getText().trim();&lt;br /&gt;
        endText = customRangeEnd.getText().trim();&lt;br /&gt;
        if (startText.equals(empty) &amp;amp;&amp;amp; !endText.equals(empty)) {&lt;br /&gt;
          endIndex = Integer.parseInt(endText, 16);&lt;br /&gt;
          startIndex = endIndex - 7 * 25;&lt;br /&gt;
        } else if (!startText.equals(empty) &amp;amp;&amp;amp; endText.equals(empty)) {&lt;br /&gt;
          startIndex = Integer.parseInt(startText, 16);&lt;br /&gt;
          endIndex = startIndex + 7 * 25;&lt;br /&gt;
        } else {&lt;br /&gt;
          startIndex = Integer.parseInt(customRangeStart.getText(), 16);&lt;br /&gt;
          endIndex = Integer.parseInt(customRangeEnd.getText(), 16);&lt;br /&gt;
        }&lt;br /&gt;
      } catch (Exception e) {&lt;br /&gt;
        // / Error in parsing the hex number ---&lt;br /&gt;
        // / Reset the range to what it was before and return that&lt;br /&gt;
        customRangeStart.setText(Integer.toString(customRange[0], 16));&lt;br /&gt;
        customRangeEnd.setText(Integer.toString(customRange[1], 16));&lt;br /&gt;
        return customRange;&lt;br /&gt;
      }&lt;br /&gt;
      if (startIndex &amp;lt; 0)&lt;br /&gt;
        startIndex = 0;&lt;br /&gt;
      if (endIndex &amp;gt; 0xffff)&lt;br /&gt;
        endIndex = 0xffff;&lt;br /&gt;
      if (startIndex &amp;gt; endIndex)&lt;br /&gt;
        startIndex = endIndex;&lt;br /&gt;
      customRange[0] = startIndex;&lt;br /&gt;
      customRange[1] = endIndex;&lt;br /&gt;
      return customRange;&lt;br /&gt;
    } else&lt;br /&gt;
      return UNICODE_RANGES[getSelectedIndex()];&lt;br /&gt;
  }&lt;br /&gt;
  // / Function used by loadOptions in Font2DTest main panel&lt;br /&gt;
  // / to reset setting and range selection&lt;br /&gt;
  public void setSelectedRange(String name, int start, int end) {&lt;br /&gt;
    setSelectedItem(name);&lt;br /&gt;
    customRange[0] = start;&lt;br /&gt;
    customRange[1] = end;&lt;br /&gt;
    parent.fireRangeChanged();&lt;br /&gt;
  }&lt;br /&gt;
  // / ActionListener interface function&lt;br /&gt;
  // / ABP&lt;br /&gt;
  // / moved JComboBox event code into this fcn from&lt;br /&gt;
  // / itemStateChanged() method. Part of change to Swing.&lt;br /&gt;
  public void actionPerformed(ActionEvent e) {&lt;br /&gt;
    Object source = e.getSource();&lt;br /&gt;
    if (source instanceof JComboBox) {&lt;br /&gt;
      String rangeName = (String) ((JComboBox) source).getSelectedItem();&lt;br /&gt;
      if (rangeName.equals(&amp;quot;Custom...&amp;quot;)) {&lt;br /&gt;
        useCustomRange = true;&lt;br /&gt;
        customRangeDialog.setLocationRelativeTo(parent);&lt;br /&gt;
        customRangeDialog.show();&lt;br /&gt;
      } else {&lt;br /&gt;
        useCustomRange = false;&lt;br /&gt;
      }&lt;br /&gt;
      parent.fireRangeChanged();&lt;br /&gt;
    } else if (source instanceof JButton) {&lt;br /&gt;
      // / Since it is only &amp;quot;OK&amp;quot; button that sends any action here...&lt;br /&gt;
      customRangeDialog.hide();&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
          &lt;br /&gt;
    &lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;/div&gt;</summary>
		<author><name>Admin</name></author>	</entry>

	<entry>
		<id>http://jexp.ru/index.php?title=Java&amp;diff=9248</id>
		<title>Java</title>
		<link rel="alternate" type="text/html" href="http://jexp.ru/index.php?title=Java&amp;diff=9248"/>
				<updated>2010-06-01T07:30:08Z</updated>
		
		<summary type="html">&lt;p&gt;Admin: 1 версия&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;* [[Java/2D Graphics GUI | 2D Graphics GUI]]&lt;br /&gt;
* [[Java/3D | 3D]]&lt;br /&gt;
* [[Java/Advanced Graphics | Advanced Graphics]]&lt;br /&gt;
* [[Java/Ant | Ant]]&lt;br /&gt;
* [[Java/Apache Common | Apache Common]]&lt;br /&gt;
* [[Java/Chart | Chart]]&lt;br /&gt;
* [[Java/Class | Class]]&lt;br /&gt;
* [[Java/Collections Data Structure | Collections Data Structure]]&lt;br /&gt;
* [[Java/Data Type | Data Type]]&lt;br /&gt;
* [[Java/Database SQL JDBC | Database SQL JDBC]]&lt;br /&gt;
* [[Java/Design Pattern | Design Pattern]]&lt;br /&gt;
* [[Java/Development Class | Development Class]]&lt;br /&gt;
* [[Java/EJB3 | EJB3]]&lt;br /&gt;
* [[Java/Email | Email]]&lt;br /&gt;
* [[Java/Event | Event]]&lt;br /&gt;
* [[Java/File Input Output | File Input Output]]&lt;br /&gt;
* [[Java/GWT | GWT]]&lt;br /&gt;
* [[Java/Game | Game]]&lt;br /&gt;
* [[Java/Generics | Generics]]&lt;br /&gt;
* [[Java/Hibernate | Hibernate]]&lt;br /&gt;
* [[Java/J2EE | J2EE]]&lt;br /&gt;
* [[Java/J2ME | J2ME]]&lt;br /&gt;
* [[Java/JDK 6 | JDK 6]]&lt;br /&gt;
* [[Java/JNDI LDAP | JNDI LDAP]]&lt;br /&gt;
* [[Java/JPA | JPA]]&lt;br /&gt;
* [[Java/JSP | JSP]]&lt;br /&gt;
* [[Java/JSTL | JSTL]]&lt;br /&gt;
* [[Java/Language Basics | Language Basics]]&lt;br /&gt;
* [[Java/Network Protocol | Network Protocol]]&lt;br /&gt;
* [[Java/PDF RTF | PDF RTF]]&lt;br /&gt;
* [[Java/Reflection | Reflection]]&lt;br /&gt;
* [[Java/Regular Expressions | Regular Expressions]]&lt;br /&gt;
* [[Java/SWT JFace Eclipse | SWT JFace Eclipse]]&lt;br /&gt;
* [[Java/Scripting | Scripting]]&lt;br /&gt;
* [[Java/Security | Security]]&lt;br /&gt;
* [[Java/Servlets | Servlets]]&lt;br /&gt;
* [[Java/Spring | Spring]]&lt;br /&gt;
* [[Java/Swing Components | Swing Components]]&lt;br /&gt;
* [[Java/Swing JFC | Swing JFC]]&lt;br /&gt;
* [[Java/Threads | Threads]]&lt;br /&gt;
* [[Java/Tiny Application | Tiny Application]]&lt;br /&gt;
* [[Java/Velocity | Velocity]]&lt;br /&gt;
* [[Java/Web Services SOA | Web Services SOA]]&lt;br /&gt;
* [[Java/XML | XML]]&lt;/div&gt;</summary>
		<author><name>Admin</name></author>	</entry>

	<entry>
		<id>http://jexp.ru/index.php?title=Java/Web_Services_SOA/AXIOM&amp;diff=9244</id>
		<title>Java/Web Services SOA/AXIOM</title>
		<link rel="alternate" type="text/html" href="http://jexp.ru/index.php?title=Java/Web_Services_SOA/AXIOM&amp;diff=9244"/>
				<updated>2010-06-01T07:30:07Z</updated>
		
		<summary type="html">&lt;p&gt;Admin: 1 версия&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== We are deploying an AXIOM based POJO service after writing a services.xml and creating an aar ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
Axis2 Quick Start Guide - Sample 3 (AXIOM)&lt;br /&gt;
==========================================&lt;br /&gt;
This sample contains source code for the xdocs/1_1/quickstartguide.html document found in &lt;br /&gt;
the extracted Axis2 Documents Distribution. For a more detailed description on the &lt;br /&gt;
source code kindly see this &amp;quot;Axis2 Quick Start Guide&amp;quot; document.&lt;br /&gt;
Introduction&lt;br /&gt;
============&lt;br /&gt;
In this sample, we are deploying an AXIOM based POJO service after writing&lt;br /&gt;
a services.xml and creating an aar. We also test successful&lt;br /&gt;
deployment using an AXIOM based client.&lt;br /&gt;
&lt;br /&gt;
Pre-Requisites&lt;br /&gt;
==============&lt;br /&gt;
Apache Ant 1.6.2 or later&lt;br /&gt;
Building the Service&lt;br /&gt;
====================&lt;br /&gt;
Type &amp;quot;ant generate.service&amp;quot; from AXIS2_HOME/samples/quickstartaxiom directory.&lt;br /&gt;
Then deploy the &lt;br /&gt;
AXIS2_HOME/samples/quickstartaxiom/build/StockQuoteService.aar&lt;br /&gt;
&lt;br /&gt;
Running the Client&lt;br /&gt;
==================&lt;br /&gt;
Type ant run.client in the AXIS2_HOME/samples/quickstartaxiom directory&lt;br /&gt;
Help&lt;br /&gt;
====&lt;br /&gt;
Please contact axis-user list (axis-user@ws.apache.org) if you have&lt;br /&gt;
any trouble running the sample.&lt;br /&gt;
&lt;br /&gt;
        &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;/div&gt;</summary>
		<author><name>Admin</name></author>	</entry>

	<entry>
		<id>http://jexp.ru/index.php?title=Java/Web_Services_SOA&amp;diff=9246</id>
		<title>Java/Web Services SOA</title>
		<link rel="alternate" type="text/html" href="http://jexp.ru/index.php?title=Java/Web_Services_SOA&amp;diff=9246"/>
				<updated>2010-06-01T07:30:07Z</updated>
		
		<summary type="html">&lt;p&gt;Admin: 1 версия&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;* [[Java/Web Services SOA/ADB | ADB]]&lt;br /&gt;
* [[Java/Web Services SOA/AXIOM | AXIOM]]&lt;br /&gt;
* [[Java/Web Services SOA/AXIS2 | AXIS2]]&lt;br /&gt;
* [[Java/Web Services SOA/Asynchronous Web Method | Asynchronous Web Method]]&lt;br /&gt;
* [[Java/Web Services SOA/CXF XFire | CXF XFire]]&lt;br /&gt;
* [[Java/Web Services SOA/CXF XFire Document Literal | CXF XFire Document Literal]]&lt;br /&gt;
* [[Java/Web Services SOA/Code First | Code First]]&lt;br /&gt;
* [[Java/Web Services SOA/HTTPS | HTTPS]]&lt;br /&gt;
* [[Java/Web Services SOA/JAX WS | JAX WS]]&lt;br /&gt;
* [[Java/Web Services SOA/JAX WS Attachment | JAX WS Attachment]]&lt;br /&gt;
* [[Java/Web Services SOA/JAX WS Document Literal | JAX WS Document Literal]]&lt;br /&gt;
* [[Java/Web Services SOA/JAX WS RPC | JAX WS RPC]]&lt;br /&gt;
* [[Java/Web Services SOA/JAX WS Tools | JAX WS Tools]]&lt;br /&gt;
* [[Java/Web Services SOA/JMS | JMS]]&lt;br /&gt;
* [[Java/Web Services SOA/JavaScript SOAP | JavaScript SOAP]]&lt;br /&gt;
* [[Java/Web Services SOA/JiBX | JiBX]]&lt;br /&gt;
* [[Java/Web Services SOA/MTOM | MTOM]]&lt;br /&gt;
* [[Java/Web Services SOA/POJO Web service | POJO Web service]]&lt;br /&gt;
* [[Java/Web Services SOA/REST | REST]]&lt;br /&gt;
* [[Java/Web Services SOA/RPC | RPC]]&lt;br /&gt;
* [[Java/Web Services SOA/SOAP | SOAP]]&lt;br /&gt;
* [[Java/Web Services SOA/Spring | Spring]]&lt;br /&gt;
* [[Java/Web Services SOA/WS Addressing | WS Addressing]]&lt;br /&gt;
* [[Java/Web Services SOA/WS Policy | WS Policy]]&lt;br /&gt;
* [[Java/Web Services SOA/WS ReliableMessaging | WS ReliableMessaging]]&lt;br /&gt;
* [[Java/Web Services SOA/WSDL | WSDL]]&lt;br /&gt;
* [[Java/Web Services SOA/XMLBEANS | XMLBEANS]]&lt;br /&gt;
* [[Java/Web Services SOA/eBay | eBay]]&lt;/div&gt;</summary>
		<author><name>Admin</name></author>	</entry>

	<entry>
		<id>http://jexp.ru/index.php?title=Java/Web_Services_SOA/ADB&amp;diff=9239</id>
		<title>Java/Web Services SOA/ADB</title>
		<link rel="alternate" type="text/html" href="http://jexp.ru/index.php?title=Java/Web_Services_SOA/ADB&amp;diff=9239"/>
				<updated>2010-06-01T07:27:49Z</updated>
		
		<summary type="html">&lt;p&gt;Admin: 1 версия&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Deploying an ADB generated service ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
Axis2 Quick Start Guide- Sample 2 (ADB)&lt;br /&gt;
======================================&lt;br /&gt;
This sample contains source code for the xdocs/1_1/quickstartguide.html document found in &lt;br /&gt;
the extracted Axis2 Documents Distribution. For a more detailed description on the &lt;br /&gt;
source code kindly see this &amp;quot;Axis2 Quick Start Guide&amp;quot; document.&lt;br /&gt;
Introduction&lt;br /&gt;
============&lt;br /&gt;
In this sample, we are deploying an ADB generated service. The service&lt;br /&gt;
is tested using generated client stubs.&lt;br /&gt;
Pre-Requisites&lt;br /&gt;
==============&lt;br /&gt;
Apache Ant 1.6.2 or later&lt;br /&gt;
Building the Service&lt;br /&gt;
====================&lt;br /&gt;
Type &amp;quot;ant generate.service&amp;quot; from Axis2_HOME/samples/quickstartadb&lt;br /&gt;
directory and then deploy the &lt;br /&gt;
Axis2_HOME/samples/quickstartadb/build/service/build/lib/StockQuoteService.aar&lt;br /&gt;
Running the Client&lt;br /&gt;
==================&lt;br /&gt;
type ant run.client in the Axis2_HOME/samples/quickstartadb directory&lt;br /&gt;
Help&lt;br /&gt;
====&lt;br /&gt;
Please contact axis-user list (axis-user@ws.apache.org) if you&lt;br /&gt;
have any trouble running the sample.&lt;br /&gt;
&lt;br /&gt;
        &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;/div&gt;</summary>
		<author><name>Admin</name></author>	</entry>

	<entry>
		<id>http://jexp.ru/index.php?title=Java/Web_Services_SOA/JAX_WS&amp;diff=9241</id>
		<title>Java/Web Services SOA/JAX WS</title>
		<link rel="alternate" type="text/html" href="http://jexp.ru/index.php?title=Java/Web_Services_SOA/JAX_WS&amp;diff=9241"/>
				<updated>2010-06-01T07:27:49Z</updated>
		
		<summary type="html">&lt;p&gt;Admin: 1 версия&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Create a simple Web Service ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
import java.text.SimpleDateFormat;&lt;br /&gt;
import java.util.Calendar;&lt;br /&gt;
import javax.jws.WebMethod;&lt;br /&gt;
import javax.jws.WebService;&lt;br /&gt;
@WebService()&lt;br /&gt;
public class Main {&lt;br /&gt;
  @WebMethod&lt;br /&gt;
  public String getTime() {&lt;br /&gt;
    Calendar calendar = Calendar.getInstance();&lt;br /&gt;
    SimpleDateFormat sdf = new SimpleDateFormat(&amp;quot;HH:mm&amp;quot;);&lt;br /&gt;
    return (sdf.format(calendar.getTime()));&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Developing Web Services Using JAX-WS ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
import javax.jws.WebService;&lt;br /&gt;
import javax.jws.WebMethod;&lt;br /&gt;
@WebService(&lt;br /&gt;
    name=&amp;quot;Calculator&amp;quot;,&lt;br /&gt;
    serviceName=&amp;quot;CalculatorService&amp;quot;,&lt;br /&gt;
    targetNamespace=&amp;quot;http://techtip.ru/jaxws/sample&amp;quot;&lt;br /&gt;
)&lt;br /&gt;
public class Calculator {&lt;br /&gt;
        public Calculator() {}&lt;br /&gt;
        &lt;br /&gt;
        @WebMethod(operationName=&amp;quot;add&amp;quot;, action=&amp;quot;urn:Add&amp;quot;)&lt;br /&gt;
        public int add(int i, int j) {&lt;br /&gt;
            int k = i +j ;&lt;br /&gt;
            System.out.println(i + &amp;quot;+&amp;quot; + j +&amp;quot; = &amp;quot; + k);&lt;br /&gt;
            return k;&lt;br /&gt;
        }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
import javax.xml.ws.WebServiceRef;&lt;br /&gt;
public class JAXWSClient {&lt;br /&gt;
  public static void main(String[] args) throws Exception {&lt;br /&gt;
    @WebServiceRef(wsdlLocation = &amp;quot;http://localhost:8080/jaxws-webservice/CalculatorService?WSDL&amp;quot;)&lt;br /&gt;
    static CalculatorService service;&lt;br /&gt;
    Calculator port = service.getCalculatorPort();&lt;br /&gt;
    System.out.println(&amp;quot; Invoking add operation on the calculator port&amp;quot;);&lt;br /&gt;
    for (int i = 0; i &amp;gt; 10; i++) {&lt;br /&gt;
      int ret = port.add(i, 10);&lt;br /&gt;
      if (ret != (i + 10)) {&lt;br /&gt;
        System.out.println(&amp;quot;Unexpected greeting &amp;quot; + ret);&lt;br /&gt;
        return;&lt;br /&gt;
      }&lt;br /&gt;
      System.out.println(&amp;quot; Adding : &amp;quot; + i + &amp;quot; + 10 = &amp;quot; + ret);&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== JAX-WS Any URI ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== JAX-WS: No data binding ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== JAX-WS: Nodatabinding-JAXB-Integration ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== JAX-WS: Polymorphic Processor ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== JAX-WS: Polymorphic Processor With Validation ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== JAX-WS: Raw Bytes Mtom ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== JAX-WS: simpleclient ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== JAX-WS: simpleclient basic authentication ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== JAX-WS: simple client cert ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== JAX-WS: Style Example ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Simple web service based on jaxws ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
/*&lt;br /&gt;
 * Client.java&lt;br /&gt;
 *&lt;br /&gt;
 * Created on March 7, 2006, 11:31 PM&lt;br /&gt;
 */&lt;br /&gt;
package client;&lt;br /&gt;
import javax.xml.ws.WebServiceRef;&lt;br /&gt;
import endpoint.HelloService;&lt;br /&gt;
import endpoint.Hello;&lt;br /&gt;
public class Client&lt;br /&gt;
{&lt;br /&gt;
    @WebServiceRef(wsdlLocation=&amp;quot;http://localhost:8080/Hello/HelloService?WSDL&amp;quot;)&lt;br /&gt;
    static HelloService service;&lt;br /&gt;
    &lt;br /&gt;
    public static void main(String[] args)&lt;br /&gt;
    {&lt;br /&gt;
        Client client = new Client();&lt;br /&gt;
        client.doHello();&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    public void doHello()&lt;br /&gt;
    {&lt;br /&gt;
        try&lt;br /&gt;
        {&lt;br /&gt;
            Hello port = service.getHelloPort();&lt;br /&gt;
            String ret = port.getHello(System.getProperty(&amp;quot;user.name&amp;quot;));&lt;br /&gt;
            System.out.println(&amp;quot;Hello result = &amp;quot; + ret);&lt;br /&gt;
        }&lt;br /&gt;
        catch(Exception e)&lt;br /&gt;
        {&lt;br /&gt;
            e.printStackTrace();&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
/////////////////////////&lt;br /&gt;
package endpoint;&lt;br /&gt;
import javax.jws.WebService;&lt;br /&gt;
@WebService&lt;br /&gt;
public class Hello&lt;br /&gt;
{&lt;br /&gt;
    public String getHello(String name)&lt;br /&gt;
    {&lt;br /&gt;
        return &amp;quot;Hello &amp;quot; + name + &amp;quot;!&amp;quot;;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
       &lt;br /&gt;
           &lt;br /&gt;
         &lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== XML Web Service WSDL ==&lt;/div&gt;</summary>
		<author><name>Admin</name></author>	</entry>

	<entry>
		<id>http://jexp.ru/index.php?title=Java/Web_Services_SOA/eBay&amp;diff=9233</id>
		<title>Java/Web Services SOA/eBay</title>
		<link rel="alternate" type="text/html" href="http://jexp.ru/index.php?title=Java/Web_Services_SOA/eBay&amp;diff=9233"/>
				<updated>2010-06-01T07:27:48Z</updated>
		
		<summary type="html">&lt;p&gt;Admin: 1 версия&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== JAX-WS: web services EBay Client Server ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
Copyright 2006 Sun Microsystems, Inc. ALL RIGHTS RESERVED Use of &lt;br /&gt;
this software is authorized pursuant to the terms of the license &lt;br /&gt;
found at http://developers.sun.ru/berkeley_license.html .&lt;br /&gt;
Copyright 1994-2005 Sun Microsystems, Inc. All Rights Reserved.&lt;br /&gt;
Redistribution and use in source and binary forms, with or without &lt;br /&gt;
modification, are permitted provided that the following conditions &lt;br /&gt;
are met:&lt;br /&gt;
 &lt;br /&gt;
    * Redistribution of source code must retain the above copyright &lt;br /&gt;
    notice, this list of conditions and the following disclaimer.&lt;br /&gt;
    * Redistribution in binary form must reproduce the above &lt;br /&gt;
    copyright notice, this list of conditions and the following &lt;br /&gt;
    disclaimer in the documentation and/or other materials provided &lt;br /&gt;
    with the distribution.&lt;br /&gt;
Neither the name of Sun Microsystems, Inc. or the names of &lt;br /&gt;
contributors may be used to endorse or promote products derived from &lt;br /&gt;
this software without specific prior written permission.&lt;br /&gt;
This software is provided &amp;quot;AS IS,&amp;quot; without a warranty of any kind. &lt;br /&gt;
ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, &lt;br /&gt;
INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A &lt;br /&gt;
PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN &lt;br /&gt;
MICROSYSTEMS, INC. (&amp;quot;SUN&amp;quot;) AND ITS LICENSORS SHALL NOT BE LIABLE FOR &lt;br /&gt;
ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR &lt;br /&gt;
DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN &lt;br /&gt;
OR ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR &lt;br /&gt;
FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE &lt;br /&gt;
DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, &lt;br /&gt;
ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF &lt;br /&gt;
SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.&lt;br /&gt;
 &lt;br /&gt;
You acknowledge that this software is not designed, licensed or &lt;br /&gt;
intended for use in the design, construction, operation or &lt;br /&gt;
maintenance of any nuclear facility. &lt;br /&gt;
        &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;/div&gt;</summary>
		<author><name>Admin</name></author>	</entry>

	<entry>
		<id>http://jexp.ru/index.php?title=Java/Web_Services_SOA/WSDL&amp;diff=9235</id>
		<title>Java/Web Services SOA/WSDL</title>
		<link rel="alternate" type="text/html" href="http://jexp.ru/index.php?title=Java/Web_Services_SOA/WSDL&amp;diff=9235"/>
				<updated>2010-06-01T07:27:48Z</updated>
		
		<summary type="html">&lt;p&gt;Admin: 1 версия&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== WSDL Helper ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
/**&lt;br /&gt;
 * Licensed to the Apache Software Foundation (ASF) under one&lt;br /&gt;
 * or more contributor license agreements. See the NOTICE file&lt;br /&gt;
 * distributed with this work for additional information&lt;br /&gt;
 * regarding copyright ownership. The ASF licenses this file&lt;br /&gt;
 * to you under the Apache License, Version 2.0 (the&lt;br /&gt;
 * &amp;quot;License&amp;quot;); you may not use this file except in compliance&lt;br /&gt;
 * with the License. You may obtain a copy of the License at&lt;br /&gt;
 *&lt;br /&gt;
 * http://www.apache.org/licenses/LICENSE-2.0&lt;br /&gt;
 *&lt;br /&gt;
 * Unless required by applicable law or agreed to in writing,&lt;br /&gt;
 * software distributed under the License is distributed on an&lt;br /&gt;
 * &amp;quot;AS IS&amp;quot; BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY&lt;br /&gt;
 * KIND, either express or implied. See the License for the&lt;br /&gt;
 * specific language governing permissions and limitations&lt;br /&gt;
 * under the License.&lt;br /&gt;
 */&lt;br /&gt;
&lt;br /&gt;
import java.io.File;&lt;br /&gt;
import java.util.ArrayList;&lt;br /&gt;
import java.util.HashMap;&lt;br /&gt;
import java.util.Iterator;&lt;br /&gt;
import java.util.List;&lt;br /&gt;
import java.util.Map;&lt;br /&gt;
import javax.wsdl.Binding;&lt;br /&gt;
import javax.wsdl.BindingOperation;&lt;br /&gt;
import javax.wsdl.Definition;&lt;br /&gt;
import javax.wsdl.Input;&lt;br /&gt;
import javax.wsdl.Message;&lt;br /&gt;
import javax.wsdl.Operation;&lt;br /&gt;
import javax.wsdl.Output;&lt;br /&gt;
import javax.wsdl.Part;&lt;br /&gt;
import javax.wsdl.PortType;&lt;br /&gt;
import javax.wsdl.factory.WSDLFactory;&lt;br /&gt;
import javax.wsdl.xml.WSDLReader;&lt;br /&gt;
public class WSDLHelper {&lt;br /&gt;
    public BindingOperation getBindingOperation(Definition def, String operationName) {&lt;br /&gt;
        if (operationName == null) {&lt;br /&gt;
            return null;&lt;br /&gt;
        }&lt;br /&gt;
        Iterator ite = def.getBindings().values().iterator();&lt;br /&gt;
        while (ite.hasNext()) {&lt;br /&gt;
            Binding binding = (Binding)ite.next();&lt;br /&gt;
            Iterator ite1 = binding.getBindingOperations().iterator();&lt;br /&gt;
            while (ite1.hasNext()) {&lt;br /&gt;
                BindingOperation bop = (BindingOperation)ite1.next();&lt;br /&gt;
                if (bop.getName().equals(operationName)) {&lt;br /&gt;
                    return bop;&lt;br /&gt;
                }&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
        return null;&lt;br /&gt;
    }&lt;br /&gt;
    public BindingOperation getBindingOperation(Binding binding, String operationName) {&lt;br /&gt;
        if (operationName == null) {&lt;br /&gt;
            return null;&lt;br /&gt;
        }&lt;br /&gt;
        List bindingOperations = binding.getBindingOperations();&lt;br /&gt;
        for (Iterator iter = bindingOperations.iterator(); iter.hasNext();) {&lt;br /&gt;
            BindingOperation bindingOperation = (BindingOperation)iter.next();&lt;br /&gt;
            if (operationName.equals(bindingOperation.getName())) {&lt;br /&gt;
                return bindingOperation;&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
        return null;&lt;br /&gt;
    }&lt;br /&gt;
    public Map getParts(Operation operation, boolean out) {&lt;br /&gt;
        Message message = null;&lt;br /&gt;
        if (out) {&lt;br /&gt;
            Output output = operation.getOutput();&lt;br /&gt;
            message = output.getMessage();&lt;br /&gt;
        } else {&lt;br /&gt;
            Input input = operation.getInput();&lt;br /&gt;
            message = input.getMessage();&lt;br /&gt;
        }&lt;br /&gt;
        return message.getParts() == null ? new HashMap() : message.getParts();&lt;br /&gt;
    }&lt;br /&gt;
    public List&amp;lt;PortType&amp;gt; getPortTypes(Definition def) {&lt;br /&gt;
        List&amp;lt;PortType&amp;gt; portTypes = new ArrayList&amp;lt;PortType&amp;gt;();&lt;br /&gt;
        Iterator ite = def.getPortTypes().values().iterator();&lt;br /&gt;
        while (ite.hasNext()) {&lt;br /&gt;
            PortType portType = (PortType)ite.next();&lt;br /&gt;
            portTypes.add(portType);&lt;br /&gt;
        }&lt;br /&gt;
        return portTypes;&lt;br /&gt;
    }&lt;br /&gt;
    public List&amp;lt;Part&amp;gt; getInMessageParts(Operation operation) {&lt;br /&gt;
        Input input = operation.getInput();&lt;br /&gt;
        List&amp;lt;Part&amp;gt; partsList = new ArrayList&amp;lt;Part&amp;gt;();&lt;br /&gt;
        if (input != null) {&lt;br /&gt;
            Iterator ite = input.getMessage().getParts().values().iterator();&lt;br /&gt;
            while (ite.hasNext()) {&lt;br /&gt;
                partsList.add((Part)ite.next());&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
        return partsList;&lt;br /&gt;
    }&lt;br /&gt;
    public List&amp;lt;Part&amp;gt; getOutMessageParts(Operation operation) {&lt;br /&gt;
        Output output = operation.getOutput();&lt;br /&gt;
        List&amp;lt;Part&amp;gt; partsList = new ArrayList&amp;lt;Part&amp;gt;();&lt;br /&gt;
        if (output != null) {&lt;br /&gt;
            Iterator ite = output.getMessage().getParts().values().iterator();&lt;br /&gt;
            while (ite.hasNext()) {&lt;br /&gt;
                partsList.add((Part)ite.next());&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
        return partsList;&lt;br /&gt;
    }&lt;br /&gt;
    public Binding getBinding(BindingOperation bop, Definition def) {&lt;br /&gt;
        Iterator ite = def.getBindings().values().iterator();&lt;br /&gt;
        while (ite.hasNext()) {&lt;br /&gt;
            Binding binding = (Binding)ite.next();&lt;br /&gt;
            for (Iterator ite2 = binding.getBindingOperations().iterator(); ite2.hasNext();) {&lt;br /&gt;
                BindingOperation bindingOperation = (BindingOperation)ite2.next();&lt;br /&gt;
                if (bindingOperation.getName().equals(bop.getName())) {&lt;br /&gt;
                    return binding;&lt;br /&gt;
                }&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
        return null;&lt;br /&gt;
    }&lt;br /&gt;
    public Definition getDefinition(File wsdlFile) throws Exception {&lt;br /&gt;
        WSDLFactory wsdlFactory = WSDLFactory.newInstance();&lt;br /&gt;
        WSDLReader reader = wsdlFactory.newWSDLReader();&lt;br /&gt;
        reader.setFeature(&amp;quot;javax.wsdl.verbose&amp;quot;, false);&lt;br /&gt;
        return reader.readWSDL(wsdlFile.toURI().toURL().toString());&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;/div&gt;</summary>
		<author><name>Admin</name></author>	</entry>

	<entry>
		<id>http://jexp.ru/index.php?title=Java/Web_Services_SOA/XMLBEANS&amp;diff=9237</id>
		<title>Java/Web Services SOA/XMLBEANS</title>
		<link rel="alternate" type="text/html" href="http://jexp.ru/index.php?title=Java/Web_Services_SOA/XMLBEANS&amp;diff=9237"/>
				<updated>2010-06-01T07:27:48Z</updated>
		
		<summary type="html">&lt;p&gt;Admin: 1 версия&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== In this sample, we are deploying an XMLBEANS generated service ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
Axis2 Quick Start Guide- Sample 4 (XML Beans)&lt;br /&gt;
============================================&lt;br /&gt;
This sample contains source code for the xdocs/1_1/quickstartguide.html document found in &lt;br /&gt;
the extracted Axis2 Documents Distribution. For a more detailed description on the &lt;br /&gt;
source code kindly see this &amp;quot;Axis2 Quick Start Guide&amp;quot; document.&lt;br /&gt;
Introduction&lt;br /&gt;
============&lt;br /&gt;
In this sample, we are deploying an XMLBEANS generated service. The service&lt;br /&gt;
is tested using generated client stubs.&lt;br /&gt;
&lt;br /&gt;
Pre-Requisites&lt;br /&gt;
==============&lt;br /&gt;
Apache Ant 1.6.2 or later&lt;br /&gt;
Building the Service&lt;br /&gt;
====================&lt;br /&gt;
Type &amp;quot;ant generate.service&amp;quot; from Axis2_HOME/samples/quickstartxmlbeans&lt;br /&gt;
directory. Then deploy the &lt;br /&gt;
AXIS2_HOME/samples/quickstartxmlbeans/build/service/build/lib/StockQuoteService.aar&lt;br /&gt;
&lt;br /&gt;
Running the Client&lt;br /&gt;
==================&lt;br /&gt;
type ant run.client in the AXIS2_HOME/samples/quickstartxmlbeans directory&lt;br /&gt;
Help&lt;br /&gt;
====&lt;br /&gt;
Please contact axis-user list (axis-user@ws.apache.org) if you have&lt;br /&gt;
any trouble running the sample.&lt;br /&gt;
        &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;/div&gt;</summary>
		<author><name>Admin</name></author>	</entry>

	<entry>
		<id>http://jexp.ru/index.php?title=Java/Web_Services_SOA/JAX_WS_Tools&amp;diff=9227</id>
		<title>Java/Web Services SOA/JAX WS Tools</title>
		<link rel="alternate" type="text/html" href="http://jexp.ru/index.php?title=Java/Web_Services_SOA/JAX_WS_Tools&amp;diff=9227"/>
				<updated>2010-06-01T07:27:46Z</updated>
		
		<summary type="html">&lt;p&gt;Admin: 1 версия&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Using wsgen Tools ==&lt;/div&gt;</summary>
		<author><name>Admin</name></author>	</entry>

	<entry>
		<id>http://jexp.ru/index.php?title=Java/Web_Services_SOA/JAX_WS_Attachment&amp;diff=9229</id>
		<title>Java/Web Services SOA/JAX WS Attachment</title>
		<link rel="alternate" type="text/html" href="http://jexp.ru/index.php?title=Java/Web_Services_SOA/JAX_WS_Attachment&amp;diff=9229"/>
				<updated>2010-06-01T07:27:46Z</updated>
		
		<summary type="html">&lt;p&gt;Admin: 1 версия&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== JAX-WS: Attachment From Java ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== JAX-WS: Attachment From WSDL ==&lt;/div&gt;</summary>
		<author><name>Admin</name></author>	</entry>

	<entry>
		<id>http://jexp.ru/index.php?title=Java/Web_Services_SOA/RPC&amp;diff=9231</id>
		<title>Java/Web Services SOA/RPC</title>
		<link rel="alternate" type="text/html" href="http://jexp.ru/index.php?title=Java/Web_Services_SOA/RPC&amp;diff=9231"/>
				<updated>2010-06-01T07:27:46Z</updated>
		
		<summary type="html">&lt;p&gt;Admin: 1 версия&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== The RPC-Literal style binding ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
Hello World Demo using RPC-Literal Style&lt;br /&gt;
========================================&lt;br /&gt;
This version of Helloe World demonstrates the use&lt;br /&gt;
of the RPC-Literal style binding.&lt;br /&gt;
Please review the README in the samples directory before&lt;br /&gt;
continuing.&lt;br /&gt;
&lt;br /&gt;
Prerequisites&lt;br /&gt;
-------------&lt;br /&gt;
If your environment already includes cxf-manifest-incubator.jar on the&lt;br /&gt;
CLASSPATH, and the JDK and ant bin directories on the PATH&lt;br /&gt;
it is not necessary to set the environment as described in&lt;br /&gt;
the samples directory&amp;quot;s README.  If your environment is not&lt;br /&gt;
properly configured, or if you are planning on using wsdl2java,&lt;br /&gt;
javac, and java to build and run the demos, you must set the&lt;br /&gt;
environment.&lt;br /&gt;
&lt;br /&gt;
Building and running the demo using ant&lt;br /&gt;
---------------------------------------&lt;br /&gt;
From the samples/hello_world_RPCLit directory, the ant build script&lt;br /&gt;
can be used to build and run the demo.&lt;br /&gt;
Using either UNIX or Windows:&lt;br /&gt;
  ant build&lt;br /&gt;
  ant server &lt;br /&gt;
  ant client&lt;br /&gt;
    &lt;br /&gt;
To remove the code generated from the WSDL file and the .class&lt;br /&gt;
files, run:&lt;br /&gt;
  ant clean&lt;br /&gt;
&lt;br /&gt;
Building the demo using wsdl2java and javac&lt;br /&gt;
-------------------------------------------&lt;br /&gt;
From the samples/hello_world_RPCLit directory, first create the target&lt;br /&gt;
directory build/classes and then generate code from the WSDL file.&lt;br /&gt;
For UNIX:&lt;br /&gt;
  mkdir -p build/classes&lt;br /&gt;
  wsdl2java -d build/classes -compile ./wsdl/hello_world_RPCLit.wsdl&lt;br /&gt;
For Windows:&lt;br /&gt;
  mkdir build\classes&lt;br /&gt;
    Must use back slashes.&lt;br /&gt;
  wsdl2java -d build\classes -compile .\wsdl\hello_world_RPCLit.wsdl&lt;br /&gt;
    May use either forward or back slashes.&lt;br /&gt;
Now compile the provided client and server applications with the commands:&lt;br /&gt;
For UNIX:  &lt;br /&gt;
  &lt;br /&gt;
  export CLASSPATH=$CLASSPATH:$CXF_HOME/lib/cxf-manifest-incubator.jar:./build/classes&lt;br /&gt;
  javac -d build/classes src/demo/hwRPCLit/client/*.java&lt;br /&gt;
  javac -d build/classes src/demo/hwRPCLit/server/*.java&lt;br /&gt;
For Windows:&lt;br /&gt;
  set classpath=%classpath%;%CXF_HOME%\lib\cxf-manifest-incubator.jar;.\build\classes&lt;br /&gt;
  javac -d build\classes src\demo\hwRPCLit\client\*.java&lt;br /&gt;
  javac -d build\classes src\demo\hwRPCLit\server\*.java&lt;br /&gt;
&lt;br /&gt;
Running the demo using java&lt;br /&gt;
---------------------------&lt;br /&gt;
From the samples/hello_world_RPCLit directory run the following &lt;br /&gt;
commands. They are entered on a single command line:&lt;br /&gt;
For UNIX (must use forward slashes):&lt;br /&gt;
    java -Djava.util.logging.config.file=$CXF_HOME/etc/logging.properties&lt;br /&gt;
         demo.hwRPCLit.server.Server &amp;amp;&lt;br /&gt;
    java -Djava.util.logging.config.file=$CXF_HOME/etc/logging.properties&lt;br /&gt;
         demo.hwRPCLit.client.Client ./wsdl/hello_world_RPCLit.wsdl&lt;br /&gt;
The server process starts in the background.  After running the client,&lt;br /&gt;
use the kill command to terminate the server process.&lt;br /&gt;
For Windows (may use either forward or back slashes):&lt;br /&gt;
  start &lt;br /&gt;
    java -Djava.util.logging.config.file=%CXF_HOME%\etc\logging.properties&lt;br /&gt;
         demo.hwRPCLit.server.Server&lt;br /&gt;
    java -Djava.util.logging.config.file=%CXF_HOME%\etc\logging.properties&lt;br /&gt;
       demo.hwRPCLit.client.Client .\wsdl\hello_world_RPCLit.wsdl&lt;br /&gt;
A new command windows opens for the server process.  After running the&lt;br /&gt;
client, terminate the server process by issuing Ctrl-C in its command window.&lt;br /&gt;
To remove the code generated from the WSDL file and the .class&lt;br /&gt;
files, either delete the build directory and its contents or run:&lt;br /&gt;
  ant clean&lt;br /&gt;
&lt;br /&gt;
Building and running the demo in a servlet container&lt;br /&gt;
----------------------------------------------------&lt;br /&gt;
From the samples/hello_world_RPCLit directory, the ant build script&lt;br /&gt;
can be used to create the war file that is deployed into the&lt;br /&gt;
servlet container.&lt;br /&gt;
Build the war file with the command:&lt;br /&gt;
  ant war&lt;br /&gt;
    &lt;br /&gt;
Preparing deploy to APACHE TOMCAT&lt;br /&gt;
* set CATALINA_HOME environment to your TOMCAT home directory&lt;br /&gt;
    &lt;br /&gt;
Deploy the application into APACHE TOMCAT with the commond:&lt;br /&gt;
[NOTE] This step will check if the cxf jars present in Tomcat, &lt;br /&gt;
       if not, it will automatically copy all the jars into CATALINA_HOME/shared/lib&lt;br /&gt;
  &lt;br /&gt;
  ant deploy -Dtomcat=true&lt;br /&gt;
The servlet container will extract the war and deploy the application.&lt;br /&gt;
&lt;br /&gt;
Using ant, run the client application with the command:&lt;br /&gt;
  ant client-servlet -Dbase.url=http://localhost:#&lt;br /&gt;
Where # is the TCP/IP port used by the servlet container,&lt;br /&gt;
e.g., 8080.&lt;br /&gt;
Or&lt;br /&gt;
  ant client-servlet -Dhost=localhost -Dport=8080&lt;br /&gt;
You can ignore the -Dhost and -Dport if your tomcat setup is same, i.e ant client-servlet&lt;br /&gt;
Using java, run the client application with the command:&lt;br /&gt;
  For UNIX:&lt;br /&gt;
    &lt;br /&gt;
    java -Djava.util.logging.config.file=$CXF_HOME/etc/logging.properties&lt;br /&gt;
         demo.hwRPCLit.client.Client http://localhost:#/helloworld/services/hello_world_rpclit?wsdl&lt;br /&gt;
  For Windows:&lt;br /&gt;
    java -Djava.util.logging.config.file=%CXF_HOME%\etc\logging.properties&lt;br /&gt;
       demo.hwRPCLit.client.Client http://localhost:#/helloworld/services/hello_world_rpclit?wsdl&lt;br /&gt;
Where # is the TCP/IP port used by the servlet container,&lt;br /&gt;
e.g., 8080.&lt;br /&gt;
Undeploy the application from the APACHE TOMCAT with the command:&lt;br /&gt;
   ant undeploy -Dtomcat=true&lt;br /&gt;
&lt;br /&gt;
Running demo with HTTP GET&lt;br /&gt;
----------------------------------------------------&lt;br /&gt;
APACHE CXF support HTTP GET to invoke the service, instead of running &lt;br /&gt;
   ant client&lt;br /&gt;
you can use &lt;br /&gt;
   ant client.get &lt;br /&gt;
to invoke the service with simple HttpURLConnection, or you can even&lt;br /&gt;
use your favoriate browser to get the results back.&lt;br /&gt;
&lt;br /&gt;
///////////////////////////////////////////////////////////////////////&lt;br /&gt;
/**&lt;br /&gt;
 * Licensed to the Apache Software Foundation (ASF) under one&lt;br /&gt;
 * or more contributor license agreements. See the NOTICE file&lt;br /&gt;
 * distributed with this work for additional information&lt;br /&gt;
 * regarding copyright ownership. The ASF licenses this file&lt;br /&gt;
 * to you under the Apache License, Version 2.0 (the&lt;br /&gt;
 * &amp;quot;License&amp;quot;); you may not use this file except in compliance&lt;br /&gt;
 * with the License. You may obtain a copy of the License at&lt;br /&gt;
 *&lt;br /&gt;
 * http://www.apache.org/licenses/LICENSE-2.0&lt;br /&gt;
 *&lt;br /&gt;
 * Unless required by applicable law or agreed to in writing,&lt;br /&gt;
 * software distributed under the License is distributed on an&lt;br /&gt;
 * &amp;quot;AS IS&amp;quot; BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY&lt;br /&gt;
 * KIND, either express or implied. See the License for the&lt;br /&gt;
 * specific language governing permissions and limitations&lt;br /&gt;
 * under the License.&lt;br /&gt;
 */&lt;br /&gt;
package demo.hwRPCLit.client;&lt;br /&gt;
import java.io.File;&lt;br /&gt;
import java.net.URL;&lt;br /&gt;
import javax.xml.namespace.QName;&lt;br /&gt;
import org.apache.hello_world_rpclit.GreeterRPCLit;&lt;br /&gt;
import org.apache.hello_world_rpclit.SOAPServiceRPCLit;&lt;br /&gt;
import org.apache.hello_world_rpclit.types.MyComplexStruct;&lt;br /&gt;
public final class Client {&lt;br /&gt;
    private static final QName SERVICE_NAME = &lt;br /&gt;
        new QName(&amp;quot;http://apache.org/hello_world_rpclit&amp;quot;, &amp;quot;SOAPServiceRPCLit&amp;quot;);&lt;br /&gt;
    private static final QName PORT_NAME = &lt;br /&gt;
        new QName(&amp;quot;http://apache.org/hello_world_rpclit&amp;quot;, &amp;quot;SoapPortRPCLit&amp;quot;);&lt;br /&gt;
    private Client() {&lt;br /&gt;
    } &lt;br /&gt;
    public static void main(String[] args) throws Exception {&lt;br /&gt;
        if (args.length == 0) { &lt;br /&gt;
            System.out.println(&amp;quot;please specify wsdl&amp;quot;);&lt;br /&gt;
            System.exit(1); &lt;br /&gt;
        }&lt;br /&gt;
        URL wsdlURL;&lt;br /&gt;
        File wsdlFile = new File(args[0]);&lt;br /&gt;
        if (wsdlFile.exists()) {&lt;br /&gt;
            wsdlURL = wsdlFile.toURL();&lt;br /&gt;
        } else {&lt;br /&gt;
            wsdlURL = new URL(args[0]);&lt;br /&gt;
        }&lt;br /&gt;
        &lt;br /&gt;
        SOAPServiceRPCLit service = new SOAPServiceRPCLit(wsdlURL, SERVICE_NAME);&lt;br /&gt;
        GreeterRPCLit greeter = (GreeterRPCLit)service.getPort(PORT_NAME, GreeterRPCLit.class);&lt;br /&gt;
        System.out.println(&amp;quot;Invoking sayHi...&amp;quot;);&lt;br /&gt;
        System.out.println(&amp;quot;server responded with: &amp;quot; + greeter.sayHi());&lt;br /&gt;
        System.out.println(); &lt;br /&gt;
        System.out.println(&amp;quot;Invoking greetMe...&amp;quot;);&lt;br /&gt;
        System.out.println(&amp;quot;server responded with: &amp;quot; + greeter.greetMe(System.getProperty(&amp;quot;user.name&amp;quot;)));&lt;br /&gt;
        System.out.println();&lt;br /&gt;
        &lt;br /&gt;
        MyComplexStruct argument = new MyComplexStruct();&lt;br /&gt;
        MyComplexStruct retVal = null;&lt;br /&gt;
        String str1 = &amp;quot;this is element 1&amp;quot;; &lt;br /&gt;
        String str2 = &amp;quot;this is element 2&amp;quot;; &lt;br /&gt;
        int int1 = 42; &lt;br /&gt;
        argument.setElem1(str1);&lt;br /&gt;
        argument.setElem2(str2);&lt;br /&gt;
        argument.setElem3(int1);&lt;br /&gt;
        System.out.println(&amp;quot;Invoking sendReceiveData...&amp;quot;);&lt;br /&gt;
        retVal = greeter.sendReceiveData(argument);&lt;br /&gt;
        System.out.println(&amp;quot;Response from sendReceiveData operation :&amp;quot;);&lt;br /&gt;
        System.out.println(&amp;quot;Element-1 : &amp;quot; + retVal.getElem1());&lt;br /&gt;
        System.out.println(&amp;quot;Element-2 : &amp;quot; + retVal.getElem2());&lt;br /&gt;
        System.out.println(&amp;quot;Element-3 : &amp;quot; + retVal.getElem3());&lt;br /&gt;
        System.out.println();&lt;br /&gt;
&lt;br /&gt;
        System.exit(0); &lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
///////////////////////////////////////////////////////////////////////&lt;br /&gt;
/**&lt;br /&gt;
 * Licensed to the Apache Software Foundation (ASF) under one&lt;br /&gt;
 * or more contributor license agreements. See the NOTICE file&lt;br /&gt;
 * distributed with this work for additional information&lt;br /&gt;
 * regarding copyright ownership. The ASF licenses this file&lt;br /&gt;
 * to you under the Apache License, Version 2.0 (the&lt;br /&gt;
 * &amp;quot;License&amp;quot;); you may not use this file except in compliance&lt;br /&gt;
 * with the License. You may obtain a copy of the License at&lt;br /&gt;
 *&lt;br /&gt;
 * http://www.apache.org/licenses/LICENSE-2.0&lt;br /&gt;
 *&lt;br /&gt;
 * Unless required by applicable law or agreed to in writing,&lt;br /&gt;
 * software distributed under the License is distributed on an&lt;br /&gt;
 * &amp;quot;AS IS&amp;quot; BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY&lt;br /&gt;
 * KIND, either express or implied. See the License for the&lt;br /&gt;
 * specific language governing permissions and limitations&lt;br /&gt;
 * under the License.&lt;br /&gt;
 */&lt;br /&gt;
package demo.hwRPCLit.client;&lt;br /&gt;
import java.io.ByteArrayOutputStream;&lt;br /&gt;
import java.io.InputStream;&lt;br /&gt;
import java.net.HttpURLConnection;&lt;br /&gt;
import java.net.URL;&lt;br /&gt;
import java.util.Properties;&lt;br /&gt;
import javax.xml.transform.OutputKeys;&lt;br /&gt;
import javax.xml.transform.Source;&lt;br /&gt;
import javax.xml.transform.Transformer;&lt;br /&gt;
import javax.xml.transform.TransformerFactory;&lt;br /&gt;
import javax.xml.transform.stream.StreamResult;&lt;br /&gt;
import javax.xml.transform.stream.StreamSource;&lt;br /&gt;
public final class Get {&lt;br /&gt;
    private Get() {&lt;br /&gt;
    } &lt;br /&gt;
    public static void main(String args[]) throws Exception {&lt;br /&gt;
        // Sent HTTP GET request to invoke sayHi&lt;br /&gt;
        String target = &amp;quot;http://localhost:9000/SoapContext/SoapPort/sayHi&amp;quot;;&lt;br /&gt;
        URL url = new URL(target);&lt;br /&gt;
        HttpURLConnection httpConnection = (HttpURLConnection) url.openConnection();&lt;br /&gt;
        httpConnection.connect();&lt;br /&gt;
        System.out.println(&amp;quot;Invoking server through HTTP GET to invoke sayHi&amp;quot;);&lt;br /&gt;
        InputStream in = httpConnection.getInputStream();&lt;br /&gt;
        StreamSource source = new StreamSource(in);&lt;br /&gt;
        printSource(source);&lt;br /&gt;
        // Sent HTTP GET request to invoke greetMe FAULT&lt;br /&gt;
        target = &amp;quot;http://localhost:9000/SoapContext/SoapPort/greetMe/me/CXF&amp;quot;;&lt;br /&gt;
        url = new URL(target);&lt;br /&gt;
        httpConnection = (HttpURLConnection) url.openConnection();&lt;br /&gt;
        httpConnection.connect();&lt;br /&gt;
        System.out.println(&amp;quot;Invoking server through HTTP GET to invoke greetMe&amp;quot;);&lt;br /&gt;
        try {&lt;br /&gt;
            in = httpConnection.getInputStream();&lt;br /&gt;
            source = new StreamSource(in);&lt;br /&gt;
            printSource(source);&lt;br /&gt;
        } catch (Exception e) {&lt;br /&gt;
            System.err.println(&amp;quot;GreetMe Fault: &amp;quot; + e.getMessage());&lt;br /&gt;
        }&lt;br /&gt;
        InputStream err = httpConnection.getErrorStream();&lt;br /&gt;
        source = new StreamSource(err);&lt;br /&gt;
        printSource(source);&lt;br /&gt;
        // Sent HTTP GET request to invoke greetMe&lt;br /&gt;
        target = &amp;quot;http://localhost:9000/SoapContext/SoapPort/greetMe/in/CXF&amp;quot;;&lt;br /&gt;
        url = new URL(target);&lt;br /&gt;
        httpConnection = (HttpURLConnection) url.openConnection();&lt;br /&gt;
        httpConnection.connect();&lt;br /&gt;
        System.out.println(&amp;quot;Invoking server through HTTP GET to invoke greetMe&amp;quot;);&lt;br /&gt;
        in = httpConnection.getInputStream();&lt;br /&gt;
        source = new StreamSource(in);&lt;br /&gt;
        printSource(source);&lt;br /&gt;
    }&lt;br /&gt;
    private static void printSource(Source source) {&lt;br /&gt;
        try {&lt;br /&gt;
            ByteArrayOutputStream bos = new ByteArrayOutputStream();&lt;br /&gt;
            StreamResult sr = new StreamResult(bos);&lt;br /&gt;
            Transformer trans = TransformerFactory.newInstance().newTransformer();&lt;br /&gt;
            Properties oprops = new Properties();&lt;br /&gt;
            oprops.put(OutputKeys.OMIT_XML_DECLARATION, &amp;quot;yes&amp;quot;);&lt;br /&gt;
            trans.setOutputProperties(oprops);&lt;br /&gt;
            trans.transform(source, sr);&lt;br /&gt;
            System.out.println();&lt;br /&gt;
            System.out.println(&amp;quot;**** Response ******&amp;quot;);&lt;br /&gt;
            System.out.println();&lt;br /&gt;
            System.out.println(bos.toString());&lt;br /&gt;
            bos.close();&lt;br /&gt;
            System.out.println();&lt;br /&gt;
        } catch (Exception e) {&lt;br /&gt;
            e.printStackTrace();&lt;br /&gt;
        }&lt;br /&gt;
    }    &lt;br /&gt;
}&lt;br /&gt;
///////////////////////////////////////////////////////////////////////&lt;br /&gt;
/**&lt;br /&gt;
 * Licensed to the Apache Software Foundation (ASF) under one&lt;br /&gt;
 * or more contributor license agreements. See the NOTICE file&lt;br /&gt;
 * distributed with this work for additional information&lt;br /&gt;
 * regarding copyright ownership. The ASF licenses this file&lt;br /&gt;
 * to you under the Apache License, Version 2.0 (the&lt;br /&gt;
 * &amp;quot;License&amp;quot;); you may not use this file except in compliance&lt;br /&gt;
 * with the License. You may obtain a copy of the License at&lt;br /&gt;
 *&lt;br /&gt;
 * http://www.apache.org/licenses/LICENSE-2.0&lt;br /&gt;
 *&lt;br /&gt;
 * Unless required by applicable law or agreed to in writing,&lt;br /&gt;
 * software distributed under the License is distributed on an&lt;br /&gt;
 * &amp;quot;AS IS&amp;quot; BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY&lt;br /&gt;
 * KIND, either express or implied. See the License for the&lt;br /&gt;
 * specific language governing permissions and limitations&lt;br /&gt;
 * under the License.&lt;br /&gt;
 */&lt;br /&gt;
package demo.hwRPCLit.server;&lt;br /&gt;
import java.util.logging.Logger;&lt;br /&gt;
import org.apache.hello_world_rpclit.GreeterRPCLit;&lt;br /&gt;
import org.apache.hello_world_rpclit.types.MyComplexStruct;&lt;br /&gt;
@javax.jws.WebService(portName = &amp;quot;SoapPortRPCLit&amp;quot;, serviceName = &amp;quot;SOAPServiceRPCLit&amp;quot;, &lt;br /&gt;
                      targetNamespace = &amp;quot;http://apache.org/hello_world_rpclit&amp;quot;, &lt;br /&gt;
                      endpointInterface = &amp;quot;org.apache.hello_world_rpclit.GreeterRPCLit&amp;quot;)&lt;br /&gt;
public class GreeterRPCLitImpl implements GreeterRPCLit {&lt;br /&gt;
    private static final Logger LOG = Logger.getLogger(GreeterRPCLitImpl.class.getPackage().getName());&lt;br /&gt;
    public String greetMe(String me) {&lt;br /&gt;
        LOG.info(&amp;quot;Executing operation greetMe&amp;quot;);&lt;br /&gt;
        System.out.println(&amp;quot;Executing operation greetMe&amp;quot;);&lt;br /&gt;
        System.out.println(&amp;quot;Message received: &amp;quot; + me + &amp;quot;\n&amp;quot;);&lt;br /&gt;
        return &amp;quot;Hello &amp;quot; + me;&lt;br /&gt;
    }&lt;br /&gt;
    public String sayHi() {&lt;br /&gt;
        LOG.info(&amp;quot;Executing operation sayHi&amp;quot;);&lt;br /&gt;
        System.out.println(&amp;quot;Executing operation sayHi&amp;quot; + &amp;quot;\n&amp;quot;);&lt;br /&gt;
        return &amp;quot;Bonjour&amp;quot;;&lt;br /&gt;
    }&lt;br /&gt;
    public MyComplexStruct sendReceiveData(MyComplexStruct in) {&lt;br /&gt;
        LOG.info(&amp;quot;Executing operation sendReceiveData&amp;quot;);&lt;br /&gt;
        System.out.println(&amp;quot;Executing operation sendReceiveData&amp;quot;);&lt;br /&gt;
        System.out.println(&amp;quot;Received struct with values :\nElement-1 : &amp;quot; + in.getElem1() + &amp;quot;\nElement-2 : &amp;quot;&lt;br /&gt;
                           + in.getElem2() + &amp;quot;\nElement-3 : &amp;quot; + in.getElem3() + &amp;quot;\n&amp;quot;);&lt;br /&gt;
        return in;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
///////////////////////////////////////////////////////////////////////&lt;br /&gt;
/**&lt;br /&gt;
 * Licensed to the Apache Software Foundation (ASF) under one&lt;br /&gt;
 * or more contributor license agreements. See the NOTICE file&lt;br /&gt;
 * distributed with this work for additional information&lt;br /&gt;
 * regarding copyright ownership. The ASF licenses this file&lt;br /&gt;
 * to you under the Apache License, Version 2.0 (the&lt;br /&gt;
 * &amp;quot;License&amp;quot;); you may not use this file except in compliance&lt;br /&gt;
 * with the License. You may obtain a copy of the License at&lt;br /&gt;
 *&lt;br /&gt;
 * http://www.apache.org/licenses/LICENSE-2.0&lt;br /&gt;
 *&lt;br /&gt;
 * Unless required by applicable law or agreed to in writing,&lt;br /&gt;
 * software distributed under the License is distributed on an&lt;br /&gt;
 * &amp;quot;AS IS&amp;quot; BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY&lt;br /&gt;
 * KIND, either express or implied. See the License for the&lt;br /&gt;
 * specific language governing permissions and limitations&lt;br /&gt;
 * under the License.&lt;br /&gt;
 */&lt;br /&gt;
package demo.hwRPCLit.server;&lt;br /&gt;
import javax.xml.ws.Endpoint;&lt;br /&gt;
public class Server {&lt;br /&gt;
    protected Server() throws Exception {&lt;br /&gt;
        System.out.println(&amp;quot;Starting Server&amp;quot;);&lt;br /&gt;
        Object implementor = new GreeterRPCLitImpl();&lt;br /&gt;
        String address = &amp;quot;http://localhost:9000/SoapContext/SoapPort&amp;quot;;&lt;br /&gt;
        Endpoint.publish(address, implementor);&lt;br /&gt;
    }&lt;br /&gt;
    public static void main(String args[]) throws Exception {&lt;br /&gt;
        new Server();&lt;br /&gt;
        System.out.println(&amp;quot;Server ready...&amp;quot;);&lt;br /&gt;
        &lt;br /&gt;
        Thread.sleep(5 * 60 * 1000); &lt;br /&gt;
        System.out.println(&amp;quot;Server exiting&amp;quot;);&lt;br /&gt;
        System.exit(0);&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
///////////////////////////////////////////////////////////////////////&lt;br /&gt;
&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot;?&amp;gt;&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
  Licensed to the Apache Software Foundation (ASF) under one&lt;br /&gt;
  or more contributor license agreements. See the NOTICE file&lt;br /&gt;
  distributed with this work for additional information&lt;br /&gt;
  regarding copyright ownership. The ASF licenses this file&lt;br /&gt;
  to you under the Apache License, Version 2.0 (the&lt;br /&gt;
  &amp;quot;License&amp;quot;); you may not use this file except in compliance&lt;br /&gt;
  with the License. You may obtain a copy of the License at&lt;br /&gt;
 &lt;br /&gt;
  http://www.apache.org/licenses/LICENSE-2.0&lt;br /&gt;
 &lt;br /&gt;
  Unless required by applicable law or agreed to in writing,&lt;br /&gt;
  software distributed under the License is distributed on an&lt;br /&gt;
  &amp;quot;AS IS&amp;quot; BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY&lt;br /&gt;
  KIND, either express or implied. See the License for the&lt;br /&gt;
  specific language governing permissions and limitations&lt;br /&gt;
  under the License.&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&amp;lt;wsdl:definitions name=&amp;quot;HelloWorld&amp;quot; targetNamespace=&amp;quot;http://apache.org/hello_world_rpclit&amp;quot; &lt;br /&gt;
    xmlns=&amp;quot;http://schemas.xmlsoap.org/wsdl/&amp;quot;&lt;br /&gt;
    xmlns:soap=&amp;quot;http://schemas.xmlsoap.org/wsdl/soap/&amp;quot; &lt;br /&gt;
    xmlns:tns=&amp;quot;http://apache.org/hello_world_rpclit&amp;quot;&lt;br /&gt;
    xmlns:x1=&amp;quot;http://apache.org/hello_world_rpclit/types&amp;quot;&lt;br /&gt;
    xmlns:wsdl=&amp;quot;http://schemas.xmlsoap.org/wsdl/&amp;quot; &lt;br /&gt;
    xmlns:xsd=&amp;quot;http://www.w3.org/2001/XMLSchema&amp;quot;&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
    &amp;lt;wsdl:types&amp;gt;&lt;br /&gt;
        &amp;lt;schema targetNamespace=&amp;quot;http://apache.org/hello_world_rpclit/types&amp;quot; &lt;br /&gt;
            xmlns=&amp;quot;http://www.w3.org/2001/XMLSchema&amp;quot; elementFormDefault=&amp;quot;qualified&amp;quot;&amp;gt;&lt;br /&gt;
            &amp;lt;complexType name=&amp;quot;myComplexStruct&amp;quot;&amp;gt;&lt;br /&gt;
            &amp;lt;sequence&amp;gt;&lt;br /&gt;
                &amp;lt;element name=&amp;quot;elem1&amp;quot; type=&amp;quot;xsd:string&amp;quot;/&amp;gt;&lt;br /&gt;
                &amp;lt;element name=&amp;quot;elem2&amp;quot; type=&amp;quot;xsd:string&amp;quot;/&amp;gt;&lt;br /&gt;
                &amp;lt;element name=&amp;quot;elem3&amp;quot; type=&amp;quot;xsd:int&amp;quot;/&amp;gt;&lt;br /&gt;
            &amp;lt;/sequence&amp;gt;&lt;br /&gt;
            &amp;lt;/complexType&amp;gt;&lt;br /&gt;
        &amp;lt;/schema&amp;gt;&lt;br /&gt;
    &amp;lt;/wsdl:types&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
    &amp;lt;wsdl:message name=&amp;quot;sayHiRequest&amp;quot;/&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
    &amp;lt;wsdl:message name=&amp;quot;sayHiResponse&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;wsdl:part type=&amp;quot;xsd:string&amp;quot; name=&amp;quot;out&amp;quot;/&amp;gt;&lt;br /&gt;
    &amp;lt;/wsdl:message&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
    &amp;lt;wsdl:message name=&amp;quot;greetMeRequest&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;wsdl:part type=&amp;quot;xsd:string&amp;quot; name=&amp;quot;in&amp;quot;/&amp;gt;&lt;br /&gt;
    &amp;lt;/wsdl:message&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
    &amp;lt;wsdl:message name=&amp;quot;greetMeResponse&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;wsdl:part type=&amp;quot;xsd:string&amp;quot; name=&amp;quot;out&amp;quot;/&amp;gt;&lt;br /&gt;
    &amp;lt;/wsdl:message&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
    &amp;lt;wsdl:message name=&amp;quot;sendReceiveDataRequest&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;wsdl:part type=&amp;quot;x1:myComplexStruct&amp;quot; name=&amp;quot;in&amp;quot;/&amp;gt;&lt;br /&gt;
    &amp;lt;/wsdl:message&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
    &amp;lt;wsdl:message name=&amp;quot;sendReceiveDataResponse&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;wsdl:part type=&amp;quot;x1:myComplexStruct&amp;quot; name=&amp;quot;out&amp;quot;/&amp;gt;&lt;br /&gt;
    &amp;lt;/wsdl:message&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
    &amp;lt;wsdl:portType name=&amp;quot;GreeterRPCLit&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;wsdl:operation name=&amp;quot;sayHi&amp;quot;&amp;gt;&lt;br /&gt;
            &amp;lt;wsdl:input message=&amp;quot;tns:sayHiRequest&amp;quot; name=&amp;quot;sayHiRequest&amp;quot;/&amp;gt;&lt;br /&gt;
            &amp;lt;wsdl:output message=&amp;quot;tns:sayHiResponse&amp;quot; name=&amp;quot;sayHiResponse&amp;quot;/&amp;gt;&lt;br /&gt;
        &amp;lt;/wsdl:operation&amp;gt;&lt;br /&gt;
        &amp;lt;wsdl:operation name=&amp;quot;greetMe&amp;quot;&amp;gt;&lt;br /&gt;
            &amp;lt;wsdl:input message=&amp;quot;tns:greetMeRequest&amp;quot; name=&amp;quot;greetMeRequest&amp;quot;/&amp;gt;&lt;br /&gt;
            &amp;lt;wsdl:output message=&amp;quot;tns:greetMeResponse&amp;quot; name=&amp;quot;greetMeResponse&amp;quot;/&amp;gt;&lt;br /&gt;
        &amp;lt;/wsdl:operation&amp;gt;&lt;br /&gt;
        &amp;lt;wsdl:operation name=&amp;quot;sendReceiveData&amp;quot;&amp;gt;&lt;br /&gt;
            &amp;lt;wsdl:input message=&amp;quot;tns:sendReceiveDataRequest&amp;quot; name=&amp;quot;SendReceiveDataRequest&amp;quot;/&amp;gt;&lt;br /&gt;
        &amp;lt;wsdl:output message=&amp;quot;tns:sendReceiveDataResponse&amp;quot; name=&amp;quot;SendReceiveDataResponse&amp;quot;/&amp;gt;&lt;br /&gt;
        &amp;lt;/wsdl:operation&amp;gt;&lt;br /&gt;
    &amp;lt;/wsdl:portType&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
    &amp;lt;wsdl:binding name=&amp;quot;Greeter_SOAPBinding_RPCLit&amp;quot; type=&amp;quot;tns:GreeterRPCLit&amp;quot;&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
        &amp;lt;soap:binding style=&amp;quot;rpc&amp;quot; transport=&amp;quot;http://schemas.xmlsoap.org/soap/http&amp;quot;/&amp;gt;&lt;br /&gt;
        &lt;br /&gt;
        &amp;lt;wsdl:operation name=&amp;quot;sayHi&amp;quot;&amp;gt;&lt;br /&gt;
            &amp;lt;soap:operation soapAction=&amp;quot;&amp;quot; style=&amp;quot;rpc&amp;quot;/&amp;gt;&lt;br /&gt;
            &amp;lt;wsdl:input&amp;gt;&lt;br /&gt;
                &amp;lt;soap:body namespace=&amp;quot;http://apache.org/hello_world_rpclit&amp;quot; use=&amp;quot;literal&amp;quot;/&amp;gt;&lt;br /&gt;
            &amp;lt;/wsdl:input&amp;gt;&lt;br /&gt;
            &amp;lt;wsdl:output&amp;gt;&lt;br /&gt;
                &amp;lt;soap:body namespace=&amp;quot;http://apache.org/hello_world_rpclit&amp;quot; use=&amp;quot;literal&amp;quot;/&amp;gt;&lt;br /&gt;
            &amp;lt;/wsdl:output&amp;gt;&lt;br /&gt;
        &amp;lt;/wsdl:operation&amp;gt;&lt;br /&gt;
        &lt;br /&gt;
        &amp;lt;wsdl:operation name=&amp;quot;greetMe&amp;quot;&amp;gt;&lt;br /&gt;
            &amp;lt;soap:operation soapAction=&amp;quot;&amp;quot; style=&amp;quot;rpc&amp;quot;/&amp;gt;&lt;br /&gt;
            &amp;lt;wsdl:input&amp;gt;&lt;br /&gt;
                &amp;lt;soap:body namespace=&amp;quot;http://apache.org/hello_world_rpclit&amp;quot; use=&amp;quot;literal&amp;quot;/&amp;gt;&lt;br /&gt;
            &amp;lt;/wsdl:input&amp;gt;&lt;br /&gt;
            &amp;lt;wsdl:output&amp;gt;&lt;br /&gt;
                &amp;lt;soap:body namespace=&amp;quot;http://apache.org/hello_world_rpclit&amp;quot; use=&amp;quot;literal&amp;quot;/&amp;gt;&lt;br /&gt;
            &amp;lt;/wsdl:output&amp;gt;&lt;br /&gt;
        &amp;lt;/wsdl:operation&amp;gt;&lt;br /&gt;
        &lt;br /&gt;
        &amp;lt;wsdl:operation name=&amp;quot;sendReceiveData&amp;quot;&amp;gt;&lt;br /&gt;
            &amp;lt;soap:operation soapAction=&amp;quot;&amp;quot; style=&amp;quot;rpc&amp;quot;/&amp;gt;&lt;br /&gt;
               &amp;lt;wsdl:input&amp;gt;&lt;br /&gt;
                   &amp;lt;soap:body namespace=&amp;quot;http://apache.org/hello_world_rpclit&amp;quot; use=&amp;quot;literal&amp;quot;/&amp;gt;&lt;br /&gt;
               &amp;lt;/wsdl:input&amp;gt;&lt;br /&gt;
               &amp;lt;wsdl:output&amp;gt;&lt;br /&gt;
                   &amp;lt;soap:body namespace=&amp;quot;http://apache.org/hello_world_rpclit&amp;quot; use=&amp;quot;literal&amp;quot;/&amp;gt;&lt;br /&gt;
               &amp;lt;/wsdl:output&amp;gt;   &lt;br /&gt;
        &amp;lt;/wsdl:operation&amp;gt;&lt;br /&gt;
    &amp;lt;/wsdl:binding&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
    &amp;lt;wsdl:service name=&amp;quot;SOAPServiceRPCLit&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;wsdl:port binding=&amp;quot;tns:Greeter_SOAPBinding_RPCLit&amp;quot; name=&amp;quot;SoapPortRPCLit&amp;quot;&amp;gt;&lt;br /&gt;
            &amp;lt;soap:address location=&amp;quot;http://localhost:9000/SoapContext/SoapPort&amp;quot;/&amp;gt;&lt;br /&gt;
        &amp;lt;/wsdl:port&amp;gt;&lt;br /&gt;
    &amp;lt;/wsdl:service&amp;gt;&lt;br /&gt;
&amp;lt;/wsdl:definitions&amp;gt;&lt;br /&gt;
        &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;/div&gt;</summary>
		<author><name>Admin</name></author>	</entry>

	<entry>
		<id>http://jexp.ru/index.php?title=Java/Web_Services_SOA/JAX_WS_RPC&amp;diff=9223</id>
		<title>Java/Web Services SOA/JAX WS RPC</title>
		<link rel="alternate" type="text/html" href="http://jexp.ru/index.php?title=Java/Web_Services_SOA/JAX_WS_RPC&amp;diff=9223"/>
				<updated>2010-06-01T07:27:45Z</updated>
		
		<summary type="html">&lt;p&gt;Admin: 1 версия&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== JAX-WS: HelloWorld RPC ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== JAX-WS: RPC Literal From WSDL ==&lt;/div&gt;</summary>
		<author><name>Admin</name></author>	</entry>

	<entry>
		<id>http://jexp.ru/index.php?title=Java/Web_Services_SOA/Asynchronous_Web_Method&amp;diff=9225</id>
		<title>Java/Web Services SOA/Asynchronous Web Method</title>
		<link rel="alternate" type="text/html" href="http://jexp.ru/index.php?title=Java/Web_Services_SOA/Asynchronous_Web_Method&amp;diff=9225"/>
				<updated>2010-06-01T07:27:45Z</updated>
		
		<summary type="html">&lt;p&gt;Admin: 1 версия&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== This example demonstrates the use of asynchronous Web method invocations ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
Sample: Google Spell Checker&lt;br /&gt;
=============================&lt;br /&gt;
Introduction&lt;br /&gt;
============&lt;br /&gt;
This example demonstrates the use of asynchronous Web method invocations. The user can continue to type &lt;br /&gt;
text on the text editor where the text editor does the spell check from a hosted Web service. The Web &lt;br /&gt;
method invocation is carried out in an asynchronous manner allowing the user to continuously type text &lt;br /&gt;
without having to stall for the response.&lt;br /&gt;
&lt;br /&gt;
Pre-Requisites&lt;br /&gt;
==============&lt;br /&gt;
Apache Ant 1.6.2 or later&lt;br /&gt;
&lt;br /&gt;
Running The Sample&lt;br /&gt;
==================&lt;br /&gt;
To generate stubs and run the text editor, type ant.&lt;br /&gt;
Note that when running the build script, a stub is generated for the hosted spell check service at:&lt;br /&gt;
http://tools.wso2.net:12001/axis2/services/SimplifiedSpellCheck?wsdl&lt;br /&gt;
N.B.: This public Web service uses Google Web APIs to provide spell check service. In case of a&lt;br /&gt;
failure SimplifiedSpellCheck echo sends back the phrase (sent for spell check) instead of throwing&lt;br /&gt;
an error. Therefore, if the spell check editor just outputs the input words/phrase, that is because&lt;br /&gt;
of this behavior of the SimplifiedSpellCheck service.&lt;br /&gt;
Help&lt;br /&gt;
====&lt;br /&gt;
Please contact axis-user list (axis-user@ws.apache.org) if you have any trouble running the sample.&lt;br /&gt;
        &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;/div&gt;</summary>
		<author><name>Admin</name></author>	</entry>

	<entry>
		<id>http://jexp.ru/index.php?title=Java/Web_Services_SOA/HTTPS&amp;diff=9221</id>
		<title>Java/Web Services SOA/HTTPS</title>
		<link rel="alternate" type="text/html" href="http://jexp.ru/index.php?title=Java/Web_Services_SOA/HTTPS&amp;diff=9221"/>
				<updated>2010-06-01T07:27:44Z</updated>
		
		<summary type="html">&lt;p&gt;Admin: 1 версия&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Doing the communication using HTTPS ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
Hello World Demo using HTTPS communications&lt;br /&gt;
=============================================&lt;br /&gt;
This demo takes the hello world demo a step further &lt;br /&gt;
by doing the communication using HTTPS.&lt;br /&gt;
Please review the README in the samples directory before&lt;br /&gt;
continuing.&lt;br /&gt;
&lt;br /&gt;
Prerequisite&lt;br /&gt;
------------&lt;br /&gt;
If your environment already includes cxf-manifest-incubator.jar on the&lt;br /&gt;
CLASSPATH, and the JDK and ant bin directories on the PATH&lt;br /&gt;
it is not necessary to run the environment script described in&lt;br /&gt;
the samples directory README.  If your environment is not&lt;br /&gt;
properly configured, or if you are planning on using wsdl2java,&lt;br /&gt;
javac, and java to build and run the demos, you must set the&lt;br /&gt;
environment by running the script.&lt;br /&gt;
&lt;br /&gt;
Building and running the demo using ant&lt;br /&gt;
---------------------------------------&lt;br /&gt;
From the samples/hello_world_https directory, the ant build script&lt;br /&gt;
can be used to build demo.&lt;br /&gt;
Using either UNIX or Windows:&lt;br /&gt;
  ant build&lt;br /&gt;
    &lt;br /&gt;
To remove the code generated from the WSDL file and the .class&lt;br /&gt;
files, run:&lt;br /&gt;
  ant clean&lt;br /&gt;
&lt;br /&gt;
The demo illustrates how authentication can be achieved through&lt;br /&gt;
configuration using 2 different scenarios. The non-defaulted security&lt;br /&gt;
policy values are be specified via configuration files.&lt;br /&gt;
Scenario 1:&lt;br /&gt;
A HTTPS listener is started up. The listener requires&lt;br /&gt;
client authentication so the client must provide suitable credentials.&lt;br /&gt;
The listener configuration is taken from the &amp;quot;CherryServer.cxf&amp;quot; file&lt;br /&gt;
located in this directory.  The client&amp;quot;s security data is taken from&lt;br /&gt;
from the &amp;quot;InsecureClient.cxf&amp;quot; file in this directory, using the bean name:&lt;br /&gt;
&amp;quot;{http://apache.org/hello_world_soap_http}SoapPort.http-conduit&amp;quot;. The&lt;br /&gt;
client does NOT provide the appropriate credentials and so the&lt;br /&gt;
invocation on the server fails.&lt;br /&gt;
To run:&lt;br /&gt;
  ant server&lt;br /&gt;
  ant insecure.client&lt;br /&gt;
Scenario 2: &lt;br /&gt;
The same HTTPS listener is used. The client&amp;quot;s security data is taken&lt;br /&gt;
from the &amp;quot;WibbleClient.cxf&amp;quot; configuration file in this directory, &lt;br /&gt;
using the bean name:&lt;br /&gt;
&amp;quot;{http://apache.org/hello_world_soap_http}SoapPort.http-conduit&amp;quot;. &lt;br /&gt;
The client is configured to provide its certificate &amp;quot;CN=Wibble&amp;quot; and&lt;br /&gt;
chain stored in the Java KeyStore &amp;quot;certs/wibble.jks&amp;quot; to the server. The&lt;br /&gt;
server authenticates the client&amp;quot;s certificate using its trust store&lt;br /&gt;
&amp;quot;certs/truststore.jks&amp;quot;, which holds the Certificate Authorities&amp;quot;&lt;br /&gt;
certificates.&lt;br /&gt;
Likewise the client authenticates the server&amp;quot;s certificate &amp;quot;CN=Cherry&amp;quot;&lt;br /&gt;
and chain against the same trust store.  Note also the usage of the&lt;br /&gt;
cipherSuitesFilter configuration in the configuration files,&lt;br /&gt;
where each party imposes different ciphersuites contraints, so that the&lt;br /&gt;
ciphersuite eventually negotiated during the TLS handshake is acceptable&lt;br /&gt;
to both sides. This may be viewed by adding a -Djavax.net.debug=all &lt;br /&gt;
argument to the JVM.&lt;br /&gt;
But please note that it is not adviseable to store sensitive data such&lt;br /&gt;
as passwords stored in a clear text configuration file, unless the&lt;br /&gt;
file is sufficiently protected by OS level permissions. The KeyStores&lt;br /&gt;
may be configured programatically so using user interaction may be&lt;br /&gt;
employed to keep passwords from being stored in configuration files.&lt;br /&gt;
The approach taken here is for demonstration reasons only. &lt;br /&gt;
&lt;br /&gt;
To run:&lt;br /&gt;
  ant server&lt;br /&gt;
  ant secure.client&lt;br /&gt;
Certificates:&lt;br /&gt;
If the certificates are expired for some reason, a shell script in &lt;br /&gt;
bin/gencerts.sh will generate the set of certificates needed for&lt;br /&gt;
this sample. Just do the following:&lt;br /&gt;
        cd certs&lt;br /&gt;
        sh ../bin/gencerts.sh&lt;br /&gt;
       &lt;br /&gt;
   &lt;br /&gt;
        &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;/div&gt;</summary>
		<author><name>Admin</name></author>	</entry>

	<entry>
		<id>http://jexp.ru/index.php?title=Java/Web_Services_SOA/JMS&amp;diff=9217</id>
		<title>Java/Web Services SOA/JMS</title>
		<link rel="alternate" type="text/html" href="http://jexp.ru/index.php?title=Java/Web_Services_SOA/JMS&amp;diff=9217"/>
				<updated>2010-06-01T07:27:43Z</updated>
		
		<summary type="html">&lt;p&gt;Admin: 1 версия&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Document-Literal style binding over JMS Transport using the queue mechanism ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
JMS Transport Demo using Document-Literal Style&lt;br /&gt;
==========================================================&lt;br /&gt;
This sample demonstrates use of the Document-Literal style &lt;br /&gt;
binding over JMS Transport using the queue mechanism.&lt;br /&gt;
Please review the README in the samples directory before&lt;br /&gt;
continuing.&lt;br /&gt;
This demo uses ActiveMQ as the JMS implementation for &lt;br /&gt;
illustration purposes only. Other JMS implementations &lt;br /&gt;
such as Apache Qpid could also be used in the same way.&lt;br /&gt;
For details on how to use this demo on non-ActiveMQ &lt;br /&gt;
implementations please check &amp;quot;Using other JMS implementaions&amp;quot;&lt;br /&gt;
below.&lt;br /&gt;
Prerequisite&lt;br /&gt;
------------&lt;br /&gt;
If your environment already includes cxf-manifest-incubator.jar on the&lt;br /&gt;
CLASSPATH, and the JDK and ant bin directories on the PATH&lt;br /&gt;
it is not necessary to set the environment as described in&lt;br /&gt;
the samples directory README.  If your environment is not&lt;br /&gt;
properly configured, or if you are planning on using wsdl2java,&lt;br /&gt;
javac, and java to build and run the demos, you must set the&lt;br /&gt;
environment.&lt;br /&gt;
This demo requires ActiveMQ 4.1.X. Before you run this&lt;br /&gt;
demo, please make sure you had installed the ActiveMQ 4.1.X and&lt;br /&gt;
set ACTIVEMQ_HOME and ACTIVEMQ_VERSION environment variables.&lt;br /&gt;
ActiveMQ 4.1.0 the version variable should be&lt;br /&gt;
For Unix:&lt;br /&gt;
export ACTIVEMQ_VERSION=4.1.0-incubator&lt;br /&gt;
For Windows:&lt;br /&gt;
set ACTIVEMQ_VERSION=4.1.0-incubator&lt;br /&gt;
ActiveMQ 4.1.1 the version variable should be&lt;br /&gt;
For Unix:&lt;br /&gt;
export ACTIVEMQ_VERSION=4.1.1&lt;br /&gt;
For Windows:&lt;br /&gt;
set ACTIVEMQ_VERSION=4.1.1&lt;br /&gt;
&lt;br /&gt;
Before you run this demo, please start up the JMS message broker first.&lt;br /&gt;
From your ActiveMQ 4.1.X installation launch ActiveMQ JMS broker in a&lt;br /&gt;
separate window or in the background using the commandline:&lt;br /&gt;
For Unix:&lt;br /&gt;
cd &amp;lt;activemq.home.dir&amp;gt;/bin&lt;br /&gt;
activemq&lt;br /&gt;
For Windows:&lt;br /&gt;
cd &amp;lt;activemq.home.dir&amp;gt;\bin&lt;br /&gt;
activemq.bat&lt;br /&gt;
The location of &amp;lt;activemq.home.dir&amp;gt; depends on whether you have installed the&lt;br /&gt;
binary or source release.&lt;br /&gt;
&lt;br /&gt;
Building and running the demo using ant&lt;br /&gt;
---------------------------------------&lt;br /&gt;
From the samples/jms_queue directory, the ant build script&lt;br /&gt;
can be used to build and run the demo.&lt;br /&gt;
Using either UNIX or Windows:&lt;br /&gt;
  ant build&lt;br /&gt;
  ant jmsbroker.start &lt;br /&gt;
  ant server &lt;br /&gt;
  ant client&lt;br /&gt;
    &lt;br /&gt;
To remove the code generated from the WSDL file and the .class&lt;br /&gt;
files, run:&lt;br /&gt;
  ant clean&lt;br /&gt;
&lt;br /&gt;
Building the demo using wsdl2java and javac&lt;br /&gt;
-------------------------------------------&lt;br /&gt;
From the samples/jms_queue directory, first create the target&lt;br /&gt;
directory build/classes and then generate code from the WSDL file.&lt;br /&gt;
For UNIX:&lt;br /&gt;
  mkdir -p build/classes&lt;br /&gt;
  wsdl2java -d build/classes -compile ./wsdl/jms_greeter.wsdl&lt;br /&gt;
For Windows:&lt;br /&gt;
  mkdir build\classes&lt;br /&gt;
    Must use back slashes.&lt;br /&gt;
  wsdl2java -d build\classes -compile .\wsdl\jms_greeter.wsdl&lt;br /&gt;
    May use either forward or back slashes.&lt;br /&gt;
Now compile the provided client and server applications with the commands:&lt;br /&gt;
For UNIX:  &lt;br /&gt;
  &lt;br /&gt;
  export CLASSPATH=$CLASSPATH:$CXF_HOME/lib/cxf-manifest-incubator.jar:./build/classes:&lt;br /&gt;
$ACTIVEMQ_HOME/apache-activemq-$ACTIVEMQ_VERSION.jar&lt;br /&gt;
  javac -d build/classes src/demo/jms_greeter/client/*.java&lt;br /&gt;
  javac -d build/classes src/demo/jms_greeter/server/*.java&lt;br /&gt;
For Windows:&lt;br /&gt;
  set classpath=%classpath%;%CXF_HOME%\lib\cxf-manifest-incubator.jar;.\build\classes;&lt;br /&gt;
%ACTIVEMQ_HOME%\apache-activemq-%ACTIVEMQ_VERSION%.jar&lt;br /&gt;
  javac -d build\classes src\demo\jms_greeter\client\*.java&lt;br /&gt;
  javac -d build\classes src\demo\jms_greeter\server\*.java&lt;br /&gt;
&lt;br /&gt;
Running the demo using java&lt;br /&gt;
---------------------------&lt;br /&gt;
From the samples/jms_queue directory run the commands, entered on a&lt;br /&gt;
single command line:&lt;br /&gt;
For UNIX (must use forward slashes):&lt;br /&gt;
    java -Djava.util.logging.config.file=$CXF_HOME/etc/logging.properties&lt;br /&gt;
         demo.jms_greeter.server.Server &amp;amp;&lt;br /&gt;
    java -Djava.util.logging.config.file=$CXF_HOME/etc/logging.properties&lt;br /&gt;
         demo.jms_greeter.client.Client ./wsdl/jms_greeter.wsdl&lt;br /&gt;
The server process starts in the background.  After running the client,&lt;br /&gt;
use the kill command to terminate the server process.&lt;br /&gt;
For Windows (may use either forward or back slashes):&lt;br /&gt;
  start &lt;br /&gt;
    java -Djava.util.logging.config.file=%CXF_HOME%\etc\logging.properties&lt;br /&gt;
         demo.jms_greeter.server.Server&lt;br /&gt;
    java -Djava.util.logging.config.file=%CXF_HOME%\etc\logging.properties&lt;br /&gt;
         demo.jms_greeter.client.Client .\wsdl\jms_greeter.wsdl&lt;br /&gt;
A new command windows opens for the server process.  After running the&lt;br /&gt;
client, terminate the server process by issuing Ctrl-C in its command window.&lt;br /&gt;
&lt;br /&gt;
Now you can stop ActiveMQ JMS Broker by issuing Ctrl-C in its command window.&lt;br /&gt;
To remove the code generated from the WSDL file and the .class&lt;br /&gt;
files, either delete the build directory and its contents or run:&lt;br /&gt;
  ant clean&lt;br /&gt;
Using other JMS implementations:&lt;br /&gt;
-------------------------------&lt;br /&gt;
Using it with Apache Qpid:  &lt;br /&gt;
-------------------------&lt;br /&gt;
Before running the run, you will have to set QPID_HOME in your environment, &lt;br /&gt;
and also have to start the Qpid broker. &lt;br /&gt;
The following changes are needed to the demo to make it work for Apache Qpid.&lt;br /&gt;
1. Changes to wsdl/jms_greeter.wsdl&lt;br /&gt;
- Replace the jms:address element under wsdl:port with:                &lt;br /&gt;
      &amp;lt;jms:address&lt;br /&gt;
          destinationStyle=&amp;quot;queue&amp;quot;&lt;br /&gt;
          jndiConnectionFactoryName=&amp;quot;local&amp;quot;&lt;br /&gt;
          jndiDestinationName=&amp;quot;dq&amp;quot;&amp;gt;&lt;br /&gt;
          &amp;lt;jms:JMSNamingProperty name=&amp;quot;java.naming.factory.initial&amp;quot; &lt;br /&gt;
               value=&amp;quot;org.apache.qpid.jndi.PropertiesFileInitialContextFactory&amp;quot;/&amp;gt;&lt;br /&gt;
          &amp;lt;jms:JMSNamingProperty name=&amp;quot;java.naming.provider.url&amp;quot; &lt;br /&gt;
               value=&amp;quot;tcp://localhost:5672&amp;quot;/&amp;gt;&lt;br /&gt;
          &amp;lt;jms:JMSNamingProperty name=&amp;quot;connectionfactory.local&amp;quot; &lt;br /&gt;
               value=&amp;quot;amqp://guest:guest@clientid/test?brokerlist=&amp;quot;tcp://localhost:5672&amp;quot;&amp;quot;/&amp;gt;&lt;br /&gt;
          &amp;lt;jms:JMSNamingProperty name=&amp;quot;queue.dq&amp;quot; value=&amp;quot;queue://queuetest&amp;quot;/&amp;gt;&lt;br /&gt;
      &amp;lt;/jms:address&amp;gt;&lt;br /&gt;
2. Changes to build.xml.&lt;br /&gt;
- Replace &lt;br /&gt;
    &amp;lt;condition property=&amp;quot;activemq.home&amp;quot; value=&amp;quot;${env.ACTIVEMQ_HOME}&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;isset property=&amp;quot;env.ACTIVEMQ_HOME&amp;quot;/&amp;gt;&lt;br /&gt;
    &amp;lt;/condition&amp;gt;&lt;br /&gt;
    &amp;lt;fail message=&amp;quot;this sample need to use activemq, please setup  ACTIVEMQ_HOME in your environment&amp;quot;&lt;br /&gt;
        unless=&amp;quot;activemq.home&amp;quot;/&amp;gt;&lt;br /&gt;
    &amp;lt;condition property=&amp;quot;activemq.version&amp;quot; value=&amp;quot;${env.ACTIVEMQ_VERSION}&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;isset property=&amp;quot;env.ACTIVEMQ_VERSION&amp;quot;/&amp;gt;&lt;br /&gt;
    &amp;lt;/condition&amp;gt;&lt;br /&gt;
    &amp;lt;fail message=&amp;quot;this sample need to use activemq, please setup ACTIVEMQ_VERSION in your envrionment&amp;quot;&lt;br /&gt;
        unless=&amp;quot;activemq.version&amp;quot;/&amp;gt;&lt;br /&gt;
    &amp;lt;property name=&amp;quot;thirdparty.classpath&amp;quot; location=&amp;quot;${activemq.home}/incubator-activemq-${activemq.version}.jar&amp;quot;/&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
  with&lt;br /&gt;
   &amp;lt;condition property=&amp;quot;qpid.home&amp;quot; value=&amp;quot;${env.QPID_HOME}&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;isset property=&amp;quot;env.QPID_HOME&amp;quot;/&amp;gt;&lt;br /&gt;
    &amp;lt;/condition&amp;gt;&lt;br /&gt;
    &amp;lt;fail message=&amp;quot;this sample need to use qpid, please setup QPID_HOME in your environment&amp;quot;&lt;br /&gt;
        unless=&amp;quot;qpid.home&amp;quot;/&amp;gt;&lt;br /&gt;
    &amp;lt;property name=&amp;quot;thirdparty.classpath&amp;quot; location=&amp;quot;${qpid.home}/lib/qpid-incubating.jar&amp;quot;/&amp;gt;    &lt;br /&gt;
- Remove the target jmsbroker.start from build.xml. This is only a helper function to start the &lt;br /&gt;
  Active MQ broker, and is not required if the broker can be started through the scripts.&lt;br /&gt;
3. Remove the file, EmbeddedBroker.java from under the directory src/demo/jms_greeter/broker. This is&lt;br /&gt;
   only a helper function and therefore need not be used, as long as the broker is started&lt;br /&gt;
   through the scripts.&lt;br /&gt;
   &lt;br /&gt;
   &lt;br /&gt;
//////////////////////////////////////////////////////////////////////////&lt;br /&gt;
/**&lt;br /&gt;
 * Licensed to the Apache Software Foundation (ASF) under one&lt;br /&gt;
 * or more contributor license agreements. See the NOTICE file&lt;br /&gt;
 * distributed with this work for additional information&lt;br /&gt;
 * regarding copyright ownership. The ASF licenses this file&lt;br /&gt;
 * to you under the Apache License, Version 2.0 (the&lt;br /&gt;
 * &amp;quot;License&amp;quot;); you may not use this file except in compliance&lt;br /&gt;
 * with the License. You may obtain a copy of the License at&lt;br /&gt;
 *&lt;br /&gt;
 * http://www.apache.org/licenses/LICENSE-2.0&lt;br /&gt;
 *&lt;br /&gt;
 * Unless required by applicable law or agreed to in writing,&lt;br /&gt;
 * software distributed under the License is distributed on an&lt;br /&gt;
 * &amp;quot;AS IS&amp;quot; BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY&lt;br /&gt;
 * KIND, either express or implied. See the License for the&lt;br /&gt;
 * specific language governing permissions and limitations&lt;br /&gt;
 * under the License.&lt;br /&gt;
 */&lt;br /&gt;
package demo.jms_greeter.server;&lt;br /&gt;
import java.util.logging.Logger;&lt;br /&gt;
import org.apache.cxf.jms_greeter.JMSGreeterPortType;&lt;br /&gt;
@javax.jws.WebService(portName = &amp;quot;GreeterPort&amp;quot;, &lt;br /&gt;
                      serviceName = &amp;quot;JMSGreeterService&amp;quot;,&lt;br /&gt;
                      targetNamespace = &amp;quot;http://cxf.apache.org/jms_greeter&amp;quot;,&lt;br /&gt;
                      endpointInterface = &amp;quot;org.apache.cxf.jms_greeter.JMSGreeterPortType&amp;quot;,&lt;br /&gt;
                      wsdlLocation = &amp;quot;file:./wsdl/jms_greeter.wsdl&amp;quot;)&lt;br /&gt;
public class GreeterJMSImpl implements JMSGreeterPortType {&lt;br /&gt;
    private static final Logger LOG = Logger.getLogger(GreeterJMSImpl.class.getPackage().getName());&lt;br /&gt;
    public String greetMe(String me) {&lt;br /&gt;
        LOG.info(&amp;quot;Executing operation greetMe&amp;quot;);&lt;br /&gt;
        System.out.println(&amp;quot;Executing operation greetMe&amp;quot;);&lt;br /&gt;
        System.out.println(&amp;quot;Message received: &amp;quot; + me + &amp;quot;\n&amp;quot;);&lt;br /&gt;
        return &amp;quot;Hello &amp;quot; + me;&lt;br /&gt;
    }&lt;br /&gt;
    public String sayHi() {&lt;br /&gt;
        LOG.info(&amp;quot;Executing operation sayHi&amp;quot;);&lt;br /&gt;
        System.out.println(&amp;quot;Executing operation sayHi&amp;quot; + &amp;quot;\n&amp;quot;);&lt;br /&gt;
        return &amp;quot;Bonjour&amp;quot;;&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    public void greetMeOneWay(String me) {&lt;br /&gt;
        LOG.info(&amp;quot;Executing operation greetMeOneWay&amp;quot;);&lt;br /&gt;
        System.out.println(&amp;quot;Executing operation greetMeOneWay\n&amp;quot;);&lt;br /&gt;
        System.out.println(&amp;quot;Hello there &amp;quot; + me);&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
///////////////////////////////////////////////////////////////////////////&lt;br /&gt;
/**&lt;br /&gt;
 * Licensed to the Apache Software Foundation (ASF) under one&lt;br /&gt;
 * or more contributor license agreements. See the NOTICE file&lt;br /&gt;
 * distributed with this work for additional information&lt;br /&gt;
 * regarding copyright ownership. The ASF licenses this file&lt;br /&gt;
 * to you under the Apache License, Version 2.0 (the&lt;br /&gt;
 * &amp;quot;License&amp;quot;); you may not use this file except in compliance&lt;br /&gt;
 * with the License. You may obtain a copy of the License at&lt;br /&gt;
 *&lt;br /&gt;
 * http://www.apache.org/licenses/LICENSE-2.0&lt;br /&gt;
 *&lt;br /&gt;
 * Unless required by applicable law or agreed to in writing,&lt;br /&gt;
 * software distributed under the License is distributed on an&lt;br /&gt;
 * &amp;quot;AS IS&amp;quot; BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY&lt;br /&gt;
 * KIND, either express or implied. See the License for the&lt;br /&gt;
 * specific language governing permissions and limitations&lt;br /&gt;
 * under the License.&lt;br /&gt;
 */&lt;br /&gt;
package demo.jms_greeter.broker;&lt;br /&gt;
import org.apache.activemq.broker.BrokerService;&lt;br /&gt;
import org.apache.activemq.store.memory.MemoryPersistenceAdapter;&lt;br /&gt;
public final class EmbeddedBroker {&lt;br /&gt;
    private EmbeddedBroker() {&lt;br /&gt;
    }&lt;br /&gt;
    public static void main(String[] args) throws Exception {&lt;br /&gt;
        BrokerService broker = new BrokerService();&lt;br /&gt;
        broker.setPersistenceAdapter(new MemoryPersistenceAdapter());&lt;br /&gt;
        broker.addConnector(&amp;quot;tcp://localhost:61616&amp;quot;);&lt;br /&gt;
        broker.start();&lt;br /&gt;
        System.out.println(&amp;quot;JMS broker ready ...&amp;quot;);&lt;br /&gt;
        Thread.sleep(125 * 60 * 1000);&lt;br /&gt;
        System.out.println(&amp;quot;JMS broker exiting&amp;quot;);&lt;br /&gt;
        broker.stop();&lt;br /&gt;
        System.exit(0);&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
///////////////////////////////////////////////////////////////////////////&lt;br /&gt;
/**&lt;br /&gt;
 * Licensed to the Apache Software Foundation (ASF) under one&lt;br /&gt;
 * or more contributor license agreements. See the NOTICE file&lt;br /&gt;
 * distributed with this work for additional information&lt;br /&gt;
 * regarding copyright ownership. The ASF licenses this file&lt;br /&gt;
 * to you under the Apache License, Version 2.0 (the&lt;br /&gt;
 * &amp;quot;License&amp;quot;); you may not use this file except in compliance&lt;br /&gt;
 * with the License. You may obtain a copy of the License at&lt;br /&gt;
 *&lt;br /&gt;
 * http://www.apache.org/licenses/LICENSE-2.0&lt;br /&gt;
 *&lt;br /&gt;
 * Unless required by applicable law or agreed to in writing,&lt;br /&gt;
 * software distributed under the License is distributed on an&lt;br /&gt;
 * &amp;quot;AS IS&amp;quot; BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY&lt;br /&gt;
 * KIND, either express or implied. See the License for the&lt;br /&gt;
 * specific language governing permissions and limitations&lt;br /&gt;
 * under the License.&lt;br /&gt;
 */&lt;br /&gt;
package demo.jms_greeter.client;&lt;br /&gt;
import java.io.File;&lt;br /&gt;
import java.lang.reflect.InvocationHandler;&lt;br /&gt;
import java.lang.reflect.Proxy;&lt;br /&gt;
import java.util.Map;&lt;br /&gt;
import javax.xml.namespace.QName;&lt;br /&gt;
import javax.xml.ws.BindingProvider;&lt;br /&gt;
import org.apache.cxf.jms_greeter.JMSGreeterPortType;&lt;br /&gt;
import org.apache.cxf.jms_greeter.JMSGreeterService;&lt;br /&gt;
import org.apache.cxf.transport.jms.JMSMessageHeadersType;&lt;br /&gt;
import org.apache.cxf.transport.jms.JMSPropertyType;&lt;br /&gt;
&lt;br /&gt;
public final class Client {&lt;br /&gt;
    private static final QName SERVICE_NAME =&lt;br /&gt;
        new QName(&amp;quot;http://cxf.apache.org/jms_greeter&amp;quot;, &amp;quot;JMSGreeterService&amp;quot;);&lt;br /&gt;
    private static final QName PORT_NAME =&lt;br /&gt;
        new QName(&amp;quot;http://cxf.apache.org/jms_greeter&amp;quot;, &amp;quot;GreeterPort&amp;quot;);&lt;br /&gt;
    private Client() {&lt;br /&gt;
    }&lt;br /&gt;
    public static void main(String[] args) throws Exception {&lt;br /&gt;
        if (args.length == 0) {&lt;br /&gt;
            System.out.println(&amp;quot;please specify wsdl&amp;quot;);&lt;br /&gt;
            System.exit(1);&lt;br /&gt;
        }&lt;br /&gt;
        File wsdl = new File(args[0]);&lt;br /&gt;
        JMSGreeterService service = new JMSGreeterService(wsdl.toURL(), SERVICE_NAME);&lt;br /&gt;
        JMSGreeterPortType greeter = (JMSGreeterPortType)service.getPort(PORT_NAME, JMSGreeterPortType.class);&lt;br /&gt;
        System.out.println(&amp;quot;Invoking sayHi...&amp;quot;);&lt;br /&gt;
        System.out.println(&amp;quot;server responded with: &amp;quot; + greeter.sayHi());&lt;br /&gt;
        System.out.println();&lt;br /&gt;
        System.out.println(&amp;quot;Invoking greetMe...&amp;quot;);&lt;br /&gt;
        System.out.println(&amp;quot;server responded with: &amp;quot; + greeter.greetMe(System.getProperty(&amp;quot;user.name&amp;quot;)));&lt;br /&gt;
        System.out.println();&lt;br /&gt;
        System.out.println(&amp;quot;Invoking greetMeOneWay...&amp;quot;);&lt;br /&gt;
        greeter.greetMeOneWay(System.getProperty(&amp;quot;user.name&amp;quot;));&lt;br /&gt;
        System.out.println(&amp;quot;No response from server as method is OneWay&amp;quot;);&lt;br /&gt;
        System.out.println();&lt;br /&gt;
        &lt;br /&gt;
        // Demonstration of JMS Context usage&lt;br /&gt;
        InvocationHandler handler = Proxy.getInvocationHandler(greeter);&lt;br /&gt;
        BindingProvider  bp = null;&lt;br /&gt;
        if (handler instanceof BindingProvider) {&lt;br /&gt;
            bp = (BindingProvider)handler;&lt;br /&gt;
            Map&amp;lt;String, Object&amp;gt; requestContext = bp.getRequestContext();&lt;br /&gt;
            JMSMessageHeadersType requestHeader = new JMSMessageHeadersType();&lt;br /&gt;
            requestHeader.setJMSCorrelationID(&amp;quot;JMS_QUEUE_SAMPLE_CORRELATION_ID&amp;quot;);&lt;br /&gt;
            requestHeader.setJMSExpiration(3600000L);&lt;br /&gt;
            JMSPropertyType propType = new JMSPropertyType();&lt;br /&gt;
            propType.setName(&amp;quot;Test.Prop&amp;quot;);&lt;br /&gt;
            propType.setValue(&amp;quot;mustReturn&amp;quot;);&lt;br /&gt;
            requestHeader.getProperty().add(propType);&lt;br /&gt;
            requestContext.put(&amp;quot;org.apache.cxf.jms.client.request.headers&amp;quot;, requestHeader);&lt;br /&gt;
            //To override the default receive timeout.&lt;br /&gt;
            requestContext.put(&amp;quot;org.apache.cxf.jms.client.timeout&amp;quot;, new Long(1000));&lt;br /&gt;
        }&lt;br /&gt;
        System.out.println(&amp;quot;Invoking sayHi with JMS Context information ...&amp;quot;);&lt;br /&gt;
        System.out.println(&amp;quot;server responded with: &amp;quot; + greeter.sayHi());&lt;br /&gt;
        if (bp != null) {&lt;br /&gt;
            Map&amp;lt;String, Object&amp;gt; responseContext = bp.getResponseContext();&lt;br /&gt;
            JMSMessageHeadersType responseHdr = (JMSMessageHeadersType)responseContext.get(&lt;br /&gt;
                                       &amp;quot;org.apache.cxf.jms.client.response.headers&amp;quot;);&lt;br /&gt;
            if (responseHdr == null) {&lt;br /&gt;
                System.out.println(&amp;quot;response Header should not be null&amp;quot;);&lt;br /&gt;
                System.out.println();&lt;br /&gt;
                System.exit(1);&lt;br /&gt;
            }&lt;br /&gt;
            if (&amp;quot;JMS_QUEUE_SAMPLE_CORRELATION_ID&amp;quot;.equals(responseHdr.getJMSCorrelationID())&lt;br /&gt;
                &amp;amp;&amp;amp; responseHdr.getProperty() != null) {&lt;br /&gt;
                System.out.println(&amp;quot;Received expected contents in response context&amp;quot;);&lt;br /&gt;
            } else {&lt;br /&gt;
                System.out.println(&amp;quot;Received wrong contents in response context&amp;quot;);&lt;br /&gt;
                System.out.println();&lt;br /&gt;
                System.exit(2);&lt;br /&gt;
            }&lt;br /&gt;
        } else {&lt;br /&gt;
            System.out.println(&amp;quot;Failed to get the binding provider cannot access context info.&amp;quot;);&lt;br /&gt;
            System.exit(3);&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
        System.out.println();&lt;br /&gt;
        System.exit(0);&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
///////////////////////////////////////////////////////////////////////////&lt;br /&gt;
/**&lt;br /&gt;
 * Licensed to the Apache Software Foundation (ASF) under one&lt;br /&gt;
 * or more contributor license agreements. See the NOTICE file&lt;br /&gt;
 * distributed with this work for additional information&lt;br /&gt;
 * regarding copyright ownership. The ASF licenses this file&lt;br /&gt;
 * to you under the Apache License, Version 2.0 (the&lt;br /&gt;
 * &amp;quot;License&amp;quot;); you may not use this file except in compliance&lt;br /&gt;
 * with the License. You may obtain a copy of the License at&lt;br /&gt;
 *&lt;br /&gt;
 * http://www.apache.org/licenses/LICENSE-2.0&lt;br /&gt;
 *&lt;br /&gt;
 * Unless required by applicable law or agreed to in writing,&lt;br /&gt;
 * software distributed under the License is distributed on an&lt;br /&gt;
 * &amp;quot;AS IS&amp;quot; BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY&lt;br /&gt;
 * KIND, either express or implied. See the License for the&lt;br /&gt;
 * specific language governing permissions and limitations&lt;br /&gt;
 * under the License.&lt;br /&gt;
 */&lt;br /&gt;
package demo.jms_greeter.server;&lt;br /&gt;
import javax.xml.ws.Endpoint;&lt;br /&gt;
public class Server {&lt;br /&gt;
    protected Server() throws Exception {&lt;br /&gt;
        System.out.println(&amp;quot;Starting Server&amp;quot;);&lt;br /&gt;
        Object implementor = new GreeterJMSImpl();&lt;br /&gt;
        String address = &amp;quot;http://cxf.apache.org/transports/jms&amp;quot;;&lt;br /&gt;
        Endpoint.publish(address, implementor);&lt;br /&gt;
    }&lt;br /&gt;
    public static void main(String args[]) throws Exception {&lt;br /&gt;
        new Server();&lt;br /&gt;
        System.out.println(&amp;quot;Server ready...&amp;quot;);&lt;br /&gt;
        Thread.sleep(125 * 60 * 1000);&lt;br /&gt;
        System.out.println(&amp;quot;Server exiting&amp;quot;);&lt;br /&gt;
        System.exit(0);&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
///////////////////////////////////////////////////////////////////////////&lt;br /&gt;
&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot;?&amp;gt;&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
  Licensed to the Apache Software Foundation (ASF) under one&lt;br /&gt;
  or more contributor license agreements. See the NOTICE file&lt;br /&gt;
  distributed with this work for additional information&lt;br /&gt;
  regarding copyright ownership. The ASF licenses this file&lt;br /&gt;
  to you under the Apache License, Version 2.0 (the&lt;br /&gt;
  &amp;quot;License&amp;quot;); you may not use this file except in compliance&lt;br /&gt;
  with the License. You may obtain a copy of the License at&lt;br /&gt;
&lt;br /&gt;
  http://www.apache.org/licenses/LICENSE-2.0&lt;br /&gt;
&lt;br /&gt;
  Unless required by applicable law or agreed to in writing,&lt;br /&gt;
  software distributed under the License is distributed on an&lt;br /&gt;
  &amp;quot;AS IS&amp;quot; BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY&lt;br /&gt;
  KIND, either express or implied. See the License for the&lt;br /&gt;
  specific language governing permissions and limitations&lt;br /&gt;
  under the License.&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&amp;lt;wsdl:definitions name=&amp;quot;JMSGreeterService&amp;quot;&lt;br /&gt;
    targetNamespace=&amp;quot;http://cxf.apache.org/jms_greeter&amp;quot; &lt;br /&gt;
    xmlns=&amp;quot;http://schemas.xmlsoap.org/wsdl/&amp;quot; &lt;br /&gt;
    xmlns:jms=&amp;quot;http://cxf.apache.org/transports/jms&amp;quot; &lt;br /&gt;
    xmlns:soap=&amp;quot;http://schemas.xmlsoap.org/wsdl/soap/&amp;quot; &lt;br /&gt;
    xmlns:tns=&amp;quot;http://cxf.apache.org/jms_greeter&amp;quot;&lt;br /&gt;
    xmlns:xsd=&amp;quot;http://www.w3.org/2001/XMLSchema&amp;quot; &lt;br /&gt;
    xmlns:wsdl=&amp;quot;http://schemas.xmlsoap.org/wsdl/&amp;quot; &lt;br /&gt;
    xmlns:x1=&amp;quot;http://cxf.apache.org/jms_greeter/types&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;wsdl:types&amp;gt;&lt;br /&gt;
        &amp;lt;schema targetNamespace=&amp;quot;http://cxf.apache.org/jms_greeter/types&amp;quot; &lt;br /&gt;
            xmlns=&amp;quot;http://www.w3.org/2001/XMLSchema&amp;quot; elementFormDefault=&amp;quot;qualified&amp;quot;&amp;gt;&lt;br /&gt;
            &amp;lt;element name=&amp;quot;sayHi&amp;quot;&amp;gt;&lt;br /&gt;
                &amp;lt;complexType/&amp;gt;&lt;br /&gt;
            &amp;lt;/element&amp;gt;&lt;br /&gt;
            &amp;lt;element name=&amp;quot;sayHiResponse&amp;quot;&amp;gt;&lt;br /&gt;
                &amp;lt;complexType&amp;gt;&lt;br /&gt;
                    &amp;lt;sequence&amp;gt;&lt;br /&gt;
                        &amp;lt;element name=&amp;quot;responseType&amp;quot; type=&amp;quot;xsd:string&amp;quot;/&amp;gt;&lt;br /&gt;
                    &amp;lt;/sequence&amp;gt;&lt;br /&gt;
                &amp;lt;/complexType&amp;gt;&lt;br /&gt;
            &amp;lt;/element&amp;gt;&lt;br /&gt;
            &amp;lt;element name=&amp;quot;greetMe&amp;quot;&amp;gt;&lt;br /&gt;
                &amp;lt;complexType&amp;gt;&lt;br /&gt;
                    &amp;lt;sequence&amp;gt;&lt;br /&gt;
                        &amp;lt;element name=&amp;quot;requestType&amp;quot; type=&amp;quot;xsd:string&amp;quot;/&amp;gt;&lt;br /&gt;
                    &amp;lt;/sequence&amp;gt;&lt;br /&gt;
                &amp;lt;/complexType&amp;gt;&lt;br /&gt;
            &amp;lt;/element&amp;gt;&lt;br /&gt;
            &amp;lt;element name=&amp;quot;greetMeResponse&amp;quot;&amp;gt;&lt;br /&gt;
                &amp;lt;complexType&amp;gt;&lt;br /&gt;
                    &amp;lt;sequence&amp;gt;&lt;br /&gt;
                        &amp;lt;element name=&amp;quot;responseType&amp;quot; type=&amp;quot;xsd:string&amp;quot;/&amp;gt;&lt;br /&gt;
                    &amp;lt;/sequence&amp;gt;&lt;br /&gt;
                &amp;lt;/complexType&amp;gt;&lt;br /&gt;
            &amp;lt;/element&amp;gt;&lt;br /&gt;
            &amp;lt;element name=&amp;quot;greetMeOneWay&amp;quot;&amp;gt;&lt;br /&gt;
                &amp;lt;complexType&amp;gt;&lt;br /&gt;
                    &amp;lt;sequence&amp;gt;&lt;br /&gt;
                        &amp;lt;element name=&amp;quot;requestType&amp;quot; type=&amp;quot;xsd:string&amp;quot;/&amp;gt;&lt;br /&gt;
                    &amp;lt;/sequence&amp;gt;&lt;br /&gt;
                &amp;lt;/complexType&amp;gt;&lt;br /&gt;
            &amp;lt;/element&amp;gt;&lt;br /&gt;
        &amp;lt;/schema&amp;gt;&lt;br /&gt;
    &amp;lt;/wsdl:types&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
    &amp;lt;wsdl:message name=&amp;quot;sayHiRequest&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;wsdl:part element=&amp;quot;x1:sayHi&amp;quot; name=&amp;quot;in&amp;quot;/&amp;gt;&lt;br /&gt;
    &amp;lt;/wsdl:message&amp;gt;&lt;br /&gt;
    &amp;lt;wsdl:message name=&amp;quot;sayHiResponse&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;wsdl:part element=&amp;quot;x1:sayHiResponse&amp;quot; name=&amp;quot;out&amp;quot;/&amp;gt;&lt;br /&gt;
    &amp;lt;/wsdl:message&amp;gt;&lt;br /&gt;
    &amp;lt;wsdl:message name=&amp;quot;greetMeRequest&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;wsdl:part element=&amp;quot;x1:greetMe&amp;quot; name=&amp;quot;in&amp;quot;/&amp;gt;&lt;br /&gt;
    &amp;lt;/wsdl:message&amp;gt;&lt;br /&gt;
    &amp;lt;wsdl:message name=&amp;quot;greetMeResponse&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;wsdl:part element=&amp;quot;x1:greetMeResponse&amp;quot; name=&amp;quot;out&amp;quot;/&amp;gt;&lt;br /&gt;
    &amp;lt;/wsdl:message&amp;gt;&lt;br /&gt;
    &amp;lt;wsdl:message name=&amp;quot;greetMeOneWayRequest&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;wsdl:part element=&amp;quot;x1:greetMeOneWay&amp;quot; name=&amp;quot;in&amp;quot;/&amp;gt;&lt;br /&gt;
    &amp;lt;/wsdl:message&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
    &amp;lt;wsdl:portType name=&amp;quot;JMSGreeterPortType&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;wsdl:operation name=&amp;quot;sayHi&amp;quot;&amp;gt;&lt;br /&gt;
            &amp;lt;wsdl:input message=&amp;quot;tns:sayHiRequest&amp;quot; name=&amp;quot;sayHiRequest&amp;quot;/&amp;gt;&lt;br /&gt;
            &amp;lt;wsdl:output message=&amp;quot;tns:sayHiResponse&amp;quot; name=&amp;quot;sayHiResponse&amp;quot;/&amp;gt;&lt;br /&gt;
        &amp;lt;/wsdl:operation&amp;gt;&lt;br /&gt;
        &lt;br /&gt;
        &amp;lt;wsdl:operation name=&amp;quot;greetMe&amp;quot;&amp;gt;&lt;br /&gt;
            &amp;lt;wsdl:input message=&amp;quot;tns:greetMeRequest&amp;quot; name=&amp;quot;greetMeRequest&amp;quot;/&amp;gt;&lt;br /&gt;
            &amp;lt;wsdl:output message=&amp;quot;tns:greetMeResponse&amp;quot; name=&amp;quot;greetMeResponse&amp;quot;/&amp;gt;&lt;br /&gt;
        &amp;lt;/wsdl:operation&amp;gt;&lt;br /&gt;
        &lt;br /&gt;
        &amp;lt;wsdl:operation name=&amp;quot;greetMeOneWay&amp;quot;&amp;gt;&lt;br /&gt;
            &amp;lt;wsdl:input message=&amp;quot;tns:greetMeOneWayRequest&amp;quot; name=&amp;quot;greetMeOneWayRequest&amp;quot;/&amp;gt;&lt;br /&gt;
        &amp;lt;/wsdl:operation&amp;gt;&lt;br /&gt;
    &amp;lt;/wsdl:portType&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
    &amp;lt;wsdl:binding name=&amp;quot;JMSGreeterPortBinding&amp;quot; type=&amp;quot;tns:JMSGreeterPortType&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;soap:binding style=&amp;quot;document&amp;quot; transport=&amp;quot;http://cxf.apache.org/transport/jms&amp;quot;/&amp;gt;&lt;br /&gt;
       &lt;br /&gt;
        &amp;lt;wsdl:operation name=&amp;quot;greetMe&amp;quot;&amp;gt;&lt;br /&gt;
            &amp;lt;soap:operation soapAction=&amp;quot;&amp;quot; style=&amp;quot;document&amp;quot;/&amp;gt;&lt;br /&gt;
            &amp;lt;wsdl:input name=&amp;quot;greetMeRequest&amp;quot;&amp;gt;&lt;br /&gt;
                &amp;lt;soap:body use=&amp;quot;literal&amp;quot;/&amp;gt;&lt;br /&gt;
            &amp;lt;/wsdl:input&amp;gt;&lt;br /&gt;
            &amp;lt;wsdl:output name=&amp;quot;greetMeResponse&amp;quot;&amp;gt;&lt;br /&gt;
                &amp;lt;soap:body use=&amp;quot;literal&amp;quot;/&amp;gt;&lt;br /&gt;
            &amp;lt;/wsdl:output&amp;gt;&lt;br /&gt;
        &amp;lt;/wsdl:operation&amp;gt;&lt;br /&gt;
        &lt;br /&gt;
        &amp;lt;wsdl:operation name=&amp;quot;sayHi&amp;quot;&amp;gt;&lt;br /&gt;
            &amp;lt;soap:operation soapAction=&amp;quot;&amp;quot; style=&amp;quot;document&amp;quot;/&amp;gt;&lt;br /&gt;
            &amp;lt;wsdl:input name=&amp;quot;sayHiRequest&amp;quot;&amp;gt;&lt;br /&gt;
                &amp;lt;soap:body use=&amp;quot;literal&amp;quot;/&amp;gt;&lt;br /&gt;
            &amp;lt;/wsdl:input&amp;gt;&lt;br /&gt;
            &amp;lt;wsdl:output name=&amp;quot;sayHiResponse&amp;quot;&amp;gt;&lt;br /&gt;
                &amp;lt;soap:body use=&amp;quot;literal&amp;quot;/&amp;gt;&lt;br /&gt;
            &amp;lt;/wsdl:output&amp;gt;&lt;br /&gt;
        &amp;lt;/wsdl:operation&amp;gt;&lt;br /&gt;
        &lt;br /&gt;
        &amp;lt;wsdl:operation name=&amp;quot;greetMeOneWay&amp;quot;&amp;gt;&lt;br /&gt;
            &amp;lt;soap:operation soapaction=&amp;quot;&amp;quot; style=&amp;quot;document&amp;quot;/&amp;gt;&lt;br /&gt;
            &amp;lt;wsdl:input name=&amp;quot;greetMeOneWayRequest&amp;quot;&amp;gt;&lt;br /&gt;
                &amp;lt;soap:body use=&amp;quot;literal&amp;quot;/&amp;gt;&lt;br /&gt;
            &amp;lt;/wsdl:input&amp;gt;&lt;br /&gt;
        &amp;lt;/wsdl:operation&amp;gt;&lt;br /&gt;
    &amp;lt;/wsdl:binding&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
    &amp;lt;wsdl:service name=&amp;quot;JMSGreeterService&amp;quot;&amp;gt;&lt;br /&gt;
           &amp;lt;wsdl:port binding=&amp;quot;tns:JMSGreeterPortBinding&amp;quot; name=&amp;quot;GreeterPort&amp;quot;&amp;gt;&lt;br /&gt;
               &amp;lt;jms:address&lt;br /&gt;
                   destinationStyle=&amp;quot;queue&amp;quot;&lt;br /&gt;
                   jndiConnectionFactoryName=&amp;quot;ConnectionFactory&amp;quot; &lt;br /&gt;
                   jndiDestinationName=&amp;quot;dynamicQueues/test.cxf.jmstransport.queue&amp;quot;&amp;gt;&lt;br /&gt;
                   &lt;br /&gt;
                   &amp;lt;jms:JMSNamingProperty name=&amp;quot;java.naming.factory.initial&amp;quot; value=&amp;quot;org.apache.activemq.jndi.ActiveMQInitialContextFactory&amp;quot;/&amp;gt;&lt;br /&gt;
                   &amp;lt;jms:JMSNamingProperty name=&amp;quot;java.naming.provider.url&amp;quot; value=&amp;quot;tcp://localhost:61616&amp;quot;/&amp;gt;&lt;br /&gt;
                   &lt;br /&gt;
              &amp;lt;/jms:address&amp;gt;&lt;br /&gt;
           &amp;lt;/wsdl:port&amp;gt;&lt;br /&gt;
    &amp;lt;/wsdl:service&amp;gt;&lt;br /&gt;
&amp;lt;/wsdl:definitions&amp;gt;&lt;br /&gt;
        &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== The Document-Literal style binding over JMS transport using the pub/sub mechanism ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
JMS Transport Demo using Document-Literal Style.&lt;br /&gt;
==========================================================&lt;br /&gt;
This sample demonstrates use of the Document-Literal style&lt;br /&gt;
binding over JMS transport using the pub/sub mechanism.&lt;br /&gt;
Please review the README in the samples directory before&lt;br /&gt;
continuing.&lt;br /&gt;
This demo uses ActiveMQ as the JMS implementation for &lt;br /&gt;
illustration purposes only. Other JMS implementations &lt;br /&gt;
such as Apache Qpid could also be used in the same way.&lt;br /&gt;
For details on how to use this demo on non-ActiveMQ &lt;br /&gt;
implementations please check &amp;quot;Using other JMS implementaions&amp;quot;&lt;br /&gt;
below.&lt;br /&gt;
Prerequisite&lt;br /&gt;
------------&lt;br /&gt;
If your environment already includes cxf-manifest-incubator.jar on the&lt;br /&gt;
CLASSPATH, and the JDK and ant bin directories on the PATH&lt;br /&gt;
it is not necessary to set the environment as described in&lt;br /&gt;
the samples directory README.  If your environment is not&lt;br /&gt;
properly configured, or if you are planning on using wsdl2java,&lt;br /&gt;
javac, and java to build and run the demos, you must set the&lt;br /&gt;
environment.&lt;br /&gt;
This demo requires ActiveMQ 4.1.X. Before you run this&lt;br /&gt;
demo, please make sure you had installed the ActiveMQ 4.1.X and&lt;br /&gt;
set ACTIVEMQ_HOME and ACTIVEMQ_VERSION environment variables.&lt;br /&gt;
ActiveMQ 4.1.0 the version variable should be&lt;br /&gt;
For Unix:&lt;br /&gt;
export ACTIVEMQ_VERSION=4.1.0-incubator&lt;br /&gt;
For Windows:&lt;br /&gt;
set ACTIVEMQ_VERSION=4.1.0-incubator&lt;br /&gt;
ActiveMQ 4.1.1 the version variable should be&lt;br /&gt;
For Unix:&lt;br /&gt;
export ACTIVEMQ_VERSION=4.1.1&lt;br /&gt;
For Windows:&lt;br /&gt;
set ACTIVEMQ_VERSION=4.1.1&lt;br /&gt;
 &lt;br /&gt;
Before you run this demo, start up the JMS message broker.&lt;br /&gt;
From ActiveMQ 4.1.X insallation launch ActiveMQ JMS Broker in seperate window&lt;br /&gt;
or in background using the commands:&lt;br /&gt;
For Unix:&lt;br /&gt;
cd &amp;lt;activemq.home.dir&amp;gt;/bin&lt;br /&gt;
activemq&lt;br /&gt;
For Windows:&lt;br /&gt;
cd &amp;lt;activemq.home.dir&amp;gt;\bin&lt;br /&gt;
activemq.bat&lt;br /&gt;
The location of &amp;lt;activemq.home.dir&amp;gt; depends on whether you have installed the&lt;br /&gt;
binary or source release.&lt;br /&gt;
&lt;br /&gt;
Building and running the demo using ant&lt;br /&gt;
---------------------------------------&lt;br /&gt;
From the samples/jms_pubsub directory, the ant build script&lt;br /&gt;
can be used to build and run the demo.&lt;br /&gt;
Using either UNIX or Windows:&lt;br /&gt;
  ant build&lt;br /&gt;
  ant jmsbroker.start &lt;br /&gt;
  ant server&lt;br /&gt;
  ant client&lt;br /&gt;
    &lt;br /&gt;
To remove the code generated from the WSDL file and the .class&lt;br /&gt;
files, run:&lt;br /&gt;
  ant clean&lt;br /&gt;
&lt;br /&gt;
Building the demo using wsdl2java and javac&lt;br /&gt;
-------------------------------------------&lt;br /&gt;
From the samples/jms_pubsub directory, first create the target&lt;br /&gt;
directory build/classes and then generate code from the WSDL file.&lt;br /&gt;
For UNIX:&lt;br /&gt;
  mkdir -p build/classes&lt;br /&gt;
  wsdl2java -d build/classes -compile ./wsdl/jms_greeter.wsdl&lt;br /&gt;
For Windows:&lt;br /&gt;
  mkdir build\classes&lt;br /&gt;
    Must use back slashes.&lt;br /&gt;
  wsdl2java -d build\classes -compile .\wsdl\jms_greeter.wsdl&lt;br /&gt;
    May use either forward or back slashes.&lt;br /&gt;
Now compile the provided client and server applications with the commands:&lt;br /&gt;
For UNIX:  &lt;br /&gt;
  &lt;br /&gt;
  export CLASSPATH=$CLASSPATH:$CXF_HOME/lib/cxf-manifest-incubator.jar:./build/classes:&lt;br /&gt;
$ACTIVEMQ_HOME/apache-activemq-$ACTIVEMQ_VERSION.jar&lt;br /&gt;
  javac -d build/classes src/demo/jms_greeter/client/*.java&lt;br /&gt;
  javac -d build/classes src/demo/jms_greeter/server/*.java&lt;br /&gt;
For Windows:&lt;br /&gt;
  set classpath=%classpath%;%CXF_HOME%\lib\cxf-manifest-incubator.jar;.\build\classes;&lt;br /&gt;
%ACTIVEMQ_HOME%\apache-activemq-%ACTIVEMQ_VERSION%.jar&lt;br /&gt;
  javac -d build\classes src\demo\jms_greeter\client\*.java&lt;br /&gt;
  javac -d build\classes src\demo\jms_greeter\server\*.java&lt;br /&gt;
Running the demo using java&lt;br /&gt;
---------------------------&lt;br /&gt;
The location of &amp;lt;activemq.home.dir&amp;gt; depends on whether you have installed the&lt;br /&gt;
binary or source release.  &lt;br /&gt;
From the samples/jms_pubsub directory run the commands, entered on a&lt;br /&gt;
single command line:&lt;br /&gt;
For UNIX (must use forward slashes):&lt;br /&gt;
    java -Djava.util.logging.config.file=$CXF_HOME/etc/logging.properties&lt;br /&gt;
         demo.jms_greeter.server.Server &amp;amp;&lt;br /&gt;
    java -Djava.util.logging.config.file=$CXF_HOME/etc/logging.properties&lt;br /&gt;
         demo.jms_greeter.client.Client ./wsdl/jms_greeter.wsdl&lt;br /&gt;
The server process starts in the background.  After running the client,&lt;br /&gt;
use the kill command to terminate the server process.&lt;br /&gt;
For Windows (may use either forward or back slashes):&lt;br /&gt;
  start &lt;br /&gt;
    java -Djava.util.logging.config.file=%CXF_HOME%\etc\logging.properties&lt;br /&gt;
       demo.jms_greeter.server.Server   &lt;br /&gt;
    java -Djava.util.logging.config.file=%CXF_HOME%\etc\logging.properties&lt;br /&gt;
       demo.jms_greeter.client.Client .\wsdl\jms_greeter.wsdl&lt;br /&gt;
A new command windows opens for the server process.  After running the&lt;br /&gt;
client, terminate the server process by issuing Ctrl-C in its command window.&lt;br /&gt;
&lt;br /&gt;
Now you can stop ActiveMQ JMS Broker by issuing Ctrl-C in its command window.&lt;br /&gt;
To remove the code generated from the WSDL file and the .class&lt;br /&gt;
files, either delete the build directory and its contents or run:&lt;br /&gt;
  ant clean&lt;br /&gt;
Using other JMS implementations:&lt;br /&gt;
-------------------------------&lt;br /&gt;
Using it with Apache Qpid:  &lt;br /&gt;
-------------------------&lt;br /&gt;
Before running the run, you will have to set QPID_HOME in your environment, &lt;br /&gt;
and also have to start the Qpid broker. &lt;br /&gt;
The following changes are needed to the demo to make it work for Apache Qpid.&lt;br /&gt;
1. Changes to wsdl/jms_greeter.wsdl&lt;br /&gt;
- Replace the jms:address element under wsdl:port with:                &lt;br /&gt;
     &amp;lt;jms:address&lt;br /&gt;
         destinationStyle=&amp;quot;topic&amp;quot;&lt;br /&gt;
         jndiConnectionFactoryName=&amp;quot;local&amp;quot;&lt;br /&gt;
         jndiDestinationName=&amp;quot;direct&amp;quot;&amp;gt;&lt;br /&gt;
         &amp;lt;jms:JMSNamingProperty name=&amp;quot;java.naming.factory.initial&amp;quot; &lt;br /&gt;
             value=&amp;quot;org.apache.qpid.jndi.PropertiesFileInitialContextFactory&amp;quot;/&amp;gt;&lt;br /&gt;
         &amp;lt;jms:JMSNamingProperty name=&amp;quot;java.naming.provider.url&amp;quot; &lt;br /&gt;
             value=&amp;quot;tcp://localhost:5672&amp;quot;/&amp;gt;&lt;br /&gt;
         &amp;lt;jms:JMSNamingProperty name=&amp;quot;connectionfactory.local&amp;quot; &lt;br /&gt;
             value=&amp;quot;amqp://guest:guest@pdartix30.boston.amer.iona.ru1167022402426/test?brokerlist=&amp;quot;tcp://localhost:5672&amp;quot;&amp;quot;/&amp;gt;&lt;br /&gt;
         &amp;lt;jms:JMSNamingProperty name=&amp;quot;topic.direct&amp;quot; value=&amp;quot;topic://topictest&amp;quot;/&amp;gt;&lt;br /&gt;
     &amp;lt;/jms:address&amp;gt;&lt;br /&gt;
2. Changes to build.xml.&lt;br /&gt;
- Replace &lt;br /&gt;
    &amp;lt;condition property=&amp;quot;activemq.home&amp;quot; value=&amp;quot;${env.ACTIVEMQ_HOME}&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;isset property=&amp;quot;env.ACTIVEMQ_HOME&amp;quot;/&amp;gt;&lt;br /&gt;
    &amp;lt;/condition&amp;gt;&lt;br /&gt;
    &amp;lt;fail message=&amp;quot;this sample need to use activemq, please setup  ACTIVEMQ_HOME in your environment&amp;quot;&lt;br /&gt;
        unless=&amp;quot;activemq.home&amp;quot;/&amp;gt;&lt;br /&gt;
    &amp;lt;condition property=&amp;quot;activemq.version&amp;quot; value=&amp;quot;${env.ACTIVEMQ_VERSION}&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;isset property=&amp;quot;env.ACTIVEMQ_VERSION&amp;quot;/&amp;gt;&lt;br /&gt;
    &amp;lt;/condition&amp;gt;&lt;br /&gt;
    &amp;lt;fail message=&amp;quot;this sample need to use activemq, please setup ACTIVEMQ_VERSION in your envrionment&amp;quot;&lt;br /&gt;
        unless=&amp;quot;activemq.version&amp;quot;/&amp;gt;&lt;br /&gt;
    &amp;lt;property name=&amp;quot;thirdparty.classpath&amp;quot; location=&amp;quot;${activemq.home}/incubator-activemq-${activemq.version}.jar&amp;quot;/&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
  with&lt;br /&gt;
   &amp;lt;condition property=&amp;quot;qpid.home&amp;quot; value=&amp;quot;${env.QPID_HOME}&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;isset property=&amp;quot;env.QPID_HOME&amp;quot;/&amp;gt;&lt;br /&gt;
    &amp;lt;/condition&amp;gt;&lt;br /&gt;
    &amp;lt;fail message=&amp;quot;this sample need to use qpid, please setup QPID_HOME in your environment&amp;quot;&lt;br /&gt;
        unless=&amp;quot;qpid.home&amp;quot;/&amp;gt;&lt;br /&gt;
    &amp;lt;property name=&amp;quot;thirdparty.classpath&amp;quot; location=&amp;quot;${qpid.home}/lib/qpid-incubating.jar&amp;quot;/&amp;gt;    &lt;br /&gt;
- Remove the target jmsbroker.start from build.xml. This is only a helper function to start the &lt;br /&gt;
  Active MQ broker, and is not required if the broker can be started through the scripts.&lt;br /&gt;
3. Remove the file, EmbeddedBroker.java from under the directory src/demo/jms_greeter/broker. This is&lt;br /&gt;
   only a helper function and therefore need not be used, as long as the broker is started&lt;br /&gt;
   through the scripts.&lt;br /&gt;
&lt;br /&gt;
///////////////////////////////////////////////////////////////////////////&lt;br /&gt;
/**&lt;br /&gt;
 * Licensed to the Apache Software Foundation (ASF) under one&lt;br /&gt;
 * or more contributor license agreements. See the NOTICE file&lt;br /&gt;
 * distributed with this work for additional information&lt;br /&gt;
 * regarding copyright ownership. The ASF licenses this file&lt;br /&gt;
 * to you under the Apache License, Version 2.0 (the&lt;br /&gt;
 * &amp;quot;License&amp;quot;); you may not use this file except in compliance&lt;br /&gt;
 * with the License. You may obtain a copy of the License at&lt;br /&gt;
 *&lt;br /&gt;
 * http://www.apache.org/licenses/LICENSE-2.0&lt;br /&gt;
 *&lt;br /&gt;
 * Unless required by applicable law or agreed to in writing,&lt;br /&gt;
 * software distributed under the License is distributed on an&lt;br /&gt;
 * &amp;quot;AS IS&amp;quot; BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY&lt;br /&gt;
 * KIND, either express or implied. See the License for the&lt;br /&gt;
 * specific language governing permissions and limitations&lt;br /&gt;
 * under the License.&lt;br /&gt;
 */&lt;br /&gt;
package demo.jms_greeter.broker;&lt;br /&gt;
import org.apache.activemq.broker.BrokerService;&lt;br /&gt;
import org.apache.activemq.store.memory.MemoryPersistenceAdapter;&lt;br /&gt;
public final class EmbeddedBroker {&lt;br /&gt;
    private EmbeddedBroker() {&lt;br /&gt;
    }&lt;br /&gt;
    public static void main(String[] args) throws Exception {&lt;br /&gt;
        BrokerService broker = new BrokerService();&lt;br /&gt;
        broker.setPersistenceAdapter(new MemoryPersistenceAdapter());&lt;br /&gt;
        broker.addConnector(&amp;quot;tcp://localhost:61616&amp;quot;);&lt;br /&gt;
        broker.start();&lt;br /&gt;
        System.out.println(&amp;quot;JMS broker ready ...&amp;quot;);&lt;br /&gt;
        Thread.sleep(125 * 60 * 1000);&lt;br /&gt;
        System.out.println(&amp;quot;JMS broker exiting&amp;quot;);&lt;br /&gt;
        broker.stop();&lt;br /&gt;
        System.exit(0);&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
///////////////////////////////////////////////////////////////////////////&lt;br /&gt;
/**&lt;br /&gt;
 * Licensed to the Apache Software Foundation (ASF) under one&lt;br /&gt;
 * or more contributor license agreements. See the NOTICE file&lt;br /&gt;
 * distributed with this work for additional information&lt;br /&gt;
 * regarding copyright ownership. The ASF licenses this file&lt;br /&gt;
 * to you under the Apache License, Version 2.0 (the&lt;br /&gt;
 * &amp;quot;License&amp;quot;); you may not use this file except in compliance&lt;br /&gt;
 * with the License. You may obtain a copy of the License at&lt;br /&gt;
 *&lt;br /&gt;
 * http://www.apache.org/licenses/LICENSE-2.0&lt;br /&gt;
 *&lt;br /&gt;
 * Unless required by applicable law or agreed to in writing,&lt;br /&gt;
 * software distributed under the License is distributed on an&lt;br /&gt;
 * &amp;quot;AS IS&amp;quot; BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY&lt;br /&gt;
 * KIND, either express or implied. See the License for the&lt;br /&gt;
 * specific language governing permissions and limitations&lt;br /&gt;
 * under the License.&lt;br /&gt;
 */&lt;br /&gt;
package demo.jms_greeter.client;&lt;br /&gt;
import java.io.File;&lt;br /&gt;
import javax.xml.namespace.QName;&lt;br /&gt;
import org.apache.cxf.jms_greeter.JMSGreeterPortType;&lt;br /&gt;
import org.apache.cxf.jms_greeter.JMSGreeterService;&lt;br /&gt;
public final class Client {&lt;br /&gt;
    private static final QName SERVICE_NAME =&lt;br /&gt;
        new QName(&amp;quot;http://cxf.apache.org/jms_greeter&amp;quot;, &amp;quot;JMSGreeterService&amp;quot;);&lt;br /&gt;
    private static final QName PORT_NAME =&lt;br /&gt;
        new QName(&amp;quot;http://cxf.apache.org/jms_greeter&amp;quot;, &amp;quot;GreeterPort&amp;quot;);&lt;br /&gt;
    private Client() {&lt;br /&gt;
    }&lt;br /&gt;
    public static void main(String[] args) throws Exception {&lt;br /&gt;
        if (args.length == 0) {&lt;br /&gt;
            System.out.println(&amp;quot;please specify wsdl&amp;quot;);&lt;br /&gt;
            System.exit(1);&lt;br /&gt;
        }&lt;br /&gt;
        File wsdl = new File(args[0]);&lt;br /&gt;
        JMSGreeterService service = new JMSGreeterService(wsdl.toURL(), SERVICE_NAME);&lt;br /&gt;
        JMSGreeterPortType greeter = (JMSGreeterPortType)service.getPort(PORT_NAME, JMSGreeterPortType.class);&lt;br /&gt;
        System.out.println(&amp;quot;Invoking greetMeOneWay...&amp;quot;);&lt;br /&gt;
        greeter.greetMeOneWay(System.getProperty(&amp;quot;user.name&amp;quot;));&lt;br /&gt;
        System.out.println(&amp;quot;No response from server as method is OneWay&amp;quot;);&lt;br /&gt;
        System.out.println();&lt;br /&gt;
        System.exit(0);&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
///////////////////////////////////////////////////////////////////////////&lt;br /&gt;
/**&lt;br /&gt;
 * Licensed to the Apache Software Foundation (ASF) under one&lt;br /&gt;
 * or more contributor license agreements. See the NOTICE file&lt;br /&gt;
 * distributed with this work for additional information&lt;br /&gt;
 * regarding copyright ownership. The ASF licenses this file&lt;br /&gt;
 * to you under the Apache License, Version 2.0 (the&lt;br /&gt;
 * &amp;quot;License&amp;quot;); you may not use this file except in compliance&lt;br /&gt;
 * with the License. You may obtain a copy of the License at&lt;br /&gt;
 *&lt;br /&gt;
 * http://www.apache.org/licenses/LICENSE-2.0&lt;br /&gt;
 *&lt;br /&gt;
 * Unless required by applicable law or agreed to in writing,&lt;br /&gt;
 * software distributed under the License is distributed on an&lt;br /&gt;
 * &amp;quot;AS IS&amp;quot; BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY&lt;br /&gt;
 * KIND, either express or implied. See the License for the&lt;br /&gt;
 * specific language governing permissions and limitations&lt;br /&gt;
 * under the License.&lt;br /&gt;
 */&lt;br /&gt;
package demo.jms_greeter.server;&lt;br /&gt;
import java.util.logging.Logger;&lt;br /&gt;
import org.apache.cxf.jms_greeter.JMSGreeterPortType;&lt;br /&gt;
@javax.jws.WebService(portName = &amp;quot;GreeterPort&amp;quot;, serviceName = &amp;quot;JMSGreeterService&amp;quot;,&lt;br /&gt;
                      targetNamespace = &amp;quot;http://cxf.apache.org/jms_greeter&amp;quot;,&lt;br /&gt;
                      endpointInterface = &amp;quot;org.apache.cxf.jms_greeter.JMSGreeterPortType&amp;quot;,&lt;br /&gt;
                      wsdlLocation = &amp;quot;file:./wsdl/jms_greeter.wsdl&amp;quot;)&lt;br /&gt;
public class GreeterJMSImpl implements JMSGreeterPortType {&lt;br /&gt;
    private static final Logger LOG = Logger.getLogger(GreeterJMSImpl.class.getPackage().getName());&lt;br /&gt;
    public void greetMeOneWay(String me) {&lt;br /&gt;
        LOG.info(&amp;quot;Executing operation greetMeOneWay&amp;quot;);&lt;br /&gt;
        System.out.println(&amp;quot;Executing operation greetMeOneWay\n&amp;quot;);&lt;br /&gt;
        System.out.println(&amp;quot;Hello there &amp;quot; + me);&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
///////////////////////////////////////////////////////////////////////////&lt;br /&gt;
/**&lt;br /&gt;
 * Licensed to the Apache Software Foundation (ASF) under one&lt;br /&gt;
 * or more contributor license agreements. See the NOTICE file&lt;br /&gt;
 * distributed with this work for additional information&lt;br /&gt;
 * regarding copyright ownership. The ASF licenses this file&lt;br /&gt;
 * to you under the Apache License, Version 2.0 (the&lt;br /&gt;
 * &amp;quot;License&amp;quot;); you may not use this file except in compliance&lt;br /&gt;
 * with the License. You may obtain a copy of the License at&lt;br /&gt;
 *&lt;br /&gt;
 * http://www.apache.org/licenses/LICENSE-2.0&lt;br /&gt;
 *&lt;br /&gt;
 * Unless required by applicable law or agreed to in writing,&lt;br /&gt;
 * software distributed under the License is distributed on an&lt;br /&gt;
 * &amp;quot;AS IS&amp;quot; BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY&lt;br /&gt;
 * KIND, either express or implied. See the License for the&lt;br /&gt;
 * specific language governing permissions and limitations&lt;br /&gt;
 * under the License.&lt;br /&gt;
 */&lt;br /&gt;
package demo.jms_greeter.server;&lt;br /&gt;
import javax.xml.ws.Endpoint;&lt;br /&gt;
public class Server {&lt;br /&gt;
    protected Server() throws Exception {&lt;br /&gt;
        System.out.println(&amp;quot;Starting Server&amp;quot;);&lt;br /&gt;
        Object implementor = new GreeterJMSImpl();&lt;br /&gt;
        String address = &amp;quot;http://cxf.apache.org/transports/jms&amp;quot;;&lt;br /&gt;
        Endpoint.publish(address, implementor);&lt;br /&gt;
    }&lt;br /&gt;
    public static void main(String args[]) throws Exception {&lt;br /&gt;
        new Server();&lt;br /&gt;
        System.out.println(&amp;quot;Server ready...&amp;quot;);&lt;br /&gt;
        Thread.sleep(125 * 60 * 1000);&lt;br /&gt;
        System.out.println(&amp;quot;Server exiting&amp;quot;);&lt;br /&gt;
        System.exit(0);&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
///////////////////////////////////////////////////////////////////////////&lt;br /&gt;
&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot;?&amp;gt;&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
  Licensed to the Apache Software Foundation (ASF) under one&lt;br /&gt;
  or more contributor license agreements. See the NOTICE file&lt;br /&gt;
  distributed with this work for additional information&lt;br /&gt;
  regarding copyright ownership. The ASF licenses this file&lt;br /&gt;
  to you under the Apache License, Version 2.0 (the&lt;br /&gt;
  &amp;quot;License&amp;quot;); you may not use this file except in compliance&lt;br /&gt;
  with the License. You may obtain a copy of the License at&lt;br /&gt;
&lt;br /&gt;
  http://www.apache.org/licenses/LICENSE-2.0&lt;br /&gt;
&lt;br /&gt;
  Unless required by applicable law or agreed to in writing,&lt;br /&gt;
  software distributed under the License is distributed on an&lt;br /&gt;
  &amp;quot;AS IS&amp;quot; BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY&lt;br /&gt;
  KIND, either express or implied. See the License for the&lt;br /&gt;
  specific language governing permissions and limitations&lt;br /&gt;
  under the License.&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&amp;lt;wsdl:definitions name=&amp;quot;JMSGreeterService&amp;quot;&lt;br /&gt;
    targetNamespace=&amp;quot;http://cxf.apache.org/jms_greeter&amp;quot; &lt;br /&gt;
    xmlns=&amp;quot;http://schemas.xmlsoap.org/wsdl/&amp;quot; &lt;br /&gt;
    xmlns:jms=&amp;quot;http://cxf.apache.org/transports/jms&amp;quot; &lt;br /&gt;
    xmlns:soap=&amp;quot;http://schemas.xmlsoap.org/wsdl/soap/&amp;quot; &lt;br /&gt;
    xmlns:tns=&amp;quot;http://cxf.apache.org/jms_greeter&amp;quot;&lt;br /&gt;
    xmlns:xsd=&amp;quot;http://www.w3.org/2001/XMLSchema&amp;quot; &lt;br /&gt;
    xmlns:wsdl=&amp;quot;http://schemas.xmlsoap.org/wsdl/&amp;quot; &lt;br /&gt;
    xmlns:x1=&amp;quot;http://cxf.apache.org/jms_greeter/types&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;wsdl:types&amp;gt;&lt;br /&gt;
        &amp;lt;schema targetNamespace=&amp;quot;http://cxf.apache.org/jms_greeter/types&amp;quot; &lt;br /&gt;
            xmlns=&amp;quot;http://www.w3.org/2001/XMLSchema&amp;quot; elementFormDefault=&amp;quot;qualified&amp;quot;&amp;gt;&lt;br /&gt;
            &amp;lt;element name=&amp;quot;greetMeOneWay&amp;quot;&amp;gt;&lt;br /&gt;
                &amp;lt;complexType&amp;gt;&lt;br /&gt;
                    &amp;lt;sequence&amp;gt;&lt;br /&gt;
                        &amp;lt;element name=&amp;quot;requestType&amp;quot; type=&amp;quot;xsd:string&amp;quot;/&amp;gt;&lt;br /&gt;
                    &amp;lt;/sequence&amp;gt;&lt;br /&gt;
                &amp;lt;/complexType&amp;gt;&lt;br /&gt;
            &amp;lt;/element&amp;gt;&lt;br /&gt;
        &amp;lt;/schema&amp;gt;&lt;br /&gt;
    &amp;lt;/wsdl:types&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
    &amp;lt;wsdl:message name=&amp;quot;greetMeOneWayRequest&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;wsdl:part element=&amp;quot;x1:greetMeOneWay&amp;quot; name=&amp;quot;in&amp;quot;/&amp;gt;&lt;br /&gt;
    &amp;lt;/wsdl:message&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
    &amp;lt;wsdl:portType name=&amp;quot;JMSGreeterPortType&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;wsdl:operation name=&amp;quot;greetMeOneWay&amp;quot;&amp;gt;&lt;br /&gt;
            &amp;lt;wsdl:input message=&amp;quot;tns:greetMeOneWayRequest&amp;quot; name=&amp;quot;greetMeOneWayRequest&amp;quot;/&amp;gt;&lt;br /&gt;
        &amp;lt;/wsdl:operation&amp;gt;&lt;br /&gt;
    &amp;lt;/wsdl:portType&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
    &amp;lt;wsdl:binding name=&amp;quot;JMSGreeterPortBinding&amp;quot; type=&amp;quot;tns:JMSGreeterPortType&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;soap:binding style=&amp;quot;document&amp;quot; transport=&amp;quot;http://cxf.apache.org/transport/jms&amp;quot;/&amp;gt;&lt;br /&gt;
       &lt;br /&gt;
        &amp;lt;wsdl:operation name=&amp;quot;greetMeOneWay&amp;quot;&amp;gt;&lt;br /&gt;
            &amp;lt;soap:operation soapaction=&amp;quot;&amp;quot; style=&amp;quot;document&amp;quot;/&amp;gt;&lt;br /&gt;
            &amp;lt;wsdl:input name=&amp;quot;greetMeOneWayRequest&amp;quot;&amp;gt;&lt;br /&gt;
                &amp;lt;soap:body use=&amp;quot;literal&amp;quot;/&amp;gt;&lt;br /&gt;
            &amp;lt;/wsdl:input&amp;gt;&lt;br /&gt;
        &amp;lt;/wsdl:operation&amp;gt;&lt;br /&gt;
    &amp;lt;/wsdl:binding&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
    &amp;lt;wsdl:service name=&amp;quot;JMSGreeterService&amp;quot;&amp;gt;&lt;br /&gt;
           &amp;lt;wsdl:port binding=&amp;quot;tns:JMSGreeterPortBinding&amp;quot; name=&amp;quot;GreeterPort&amp;quot;&amp;gt;&lt;br /&gt;
               &amp;lt;jms:address&lt;br /&gt;
                   destinationStyle=&amp;quot;topic&amp;quot;&lt;br /&gt;
                   jndiConnectionFactoryName=&amp;quot;ConnectionFactory&amp;quot; &lt;br /&gt;
                   jndiDestinationName=&amp;quot;dynamicTopics/test.cxf.jmstransport.topic&amp;quot;&lt;br /&gt;
                   &amp;gt;&lt;br /&gt;
                   &lt;br /&gt;
                   &amp;lt;jms:JMSNamingProperty name=&amp;quot;java.naming.factory.initial&amp;quot; value=&amp;quot;org.apache.activemq.jndi.ActiveMQInitialContextFactory&amp;quot;/&amp;gt;&lt;br /&gt;
                   &amp;lt;jms:JMSNamingProperty name=&amp;quot;java.naming.provider.url&amp;quot; value=&amp;quot;tcp://localhost:61616&amp;quot;/&amp;gt;&lt;br /&gt;
                   &lt;br /&gt;
                   &lt;br /&gt;
                &amp;lt;/jms:address&amp;gt;&lt;br /&gt;
           &amp;lt;/wsdl:port&amp;gt;&lt;br /&gt;
    &amp;lt;/wsdl:service&amp;gt;&lt;br /&gt;
&amp;lt;/wsdl:definitions&amp;gt;&lt;br /&gt;
        &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;/div&gt;</summary>
		<author><name>Admin</name></author>	</entry>

	<entry>
		<id>http://jexp.ru/index.php?title=Java/Web_Services_SOA/MTOM&amp;diff=9219</id>
		<title>Java/Web Services SOA/MTOM</title>
		<link rel="alternate" type="text/html" href="http://jexp.ru/index.php?title=Java/Web_Services_SOA/MTOM&amp;diff=9219"/>
				<updated>2010-06-01T07:27:43Z</updated>
		
		<summary type="html">&lt;p&gt;Admin: 1 версия&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== The capabilities and power of MTOM support of AXIS2: user can send a file to the service. ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
Sample: MTOM (Message Transmission Optimization Mechanism)&lt;br /&gt;
=========================================================&lt;br /&gt;
Introduction:&lt;br /&gt;
============&lt;br /&gt;
This sample demonstrates the capabilities and power of MTOM support of AXIS2. In this sample the&lt;br /&gt;
user can send a file to the service.&lt;br /&gt;
Prerequisites&lt;br /&gt;
=============&lt;br /&gt;
Apache Ant 1.6.2 or later&lt;br /&gt;
&lt;br /&gt;
Running the Sample:&lt;br /&gt;
===================&lt;br /&gt;
1. Use ant generate.service or just the ant command alone in the Axis2_HOME/sample/mtom/ to build the service.&lt;br /&gt;
2. Generated service gets copied to the AXIS2_HOME/repository/services automatically.&lt;br /&gt;
3. Run the AXIS2_HOME/bin/axis2server.{sh/bat} to start the standalone axis2 server. (Alternatively&lt;br /&gt;
  you can drop the sample into the services directory of a Axis2 server running in a servlet container)&lt;br /&gt;
4. Use ant generate.client to build the client.&lt;br /&gt;
5. Use ant run.client -Dfile &amp;quot;file to be sent&amp;quot; -Ddest &amp;quot;destination file name&amp;quot; to run the client.&lt;br /&gt;
&lt;br /&gt;
Note&lt;br /&gt;
==============&lt;br /&gt;
Sometimes, if you&amp;quot;re having trouble running the client successfully, &lt;br /&gt;
It may be necessary to clean the services repository before you generate the service, deploy it&lt;br /&gt;
and run the client. (i.e. delete services created from previous samples.)&lt;br /&gt;
Help&lt;br /&gt;
====&lt;br /&gt;
Please contact axis-user list (axis-user@ws.apache.org) if you have any trouble running the sample.&lt;br /&gt;
&lt;br /&gt;
        &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;/div&gt;</summary>
		<author><name>Admin</name></author>	</entry>

	<entry>
		<id>http://jexp.ru/index.php?title=Java/Web_Services_SOA/JAX_WS_Document_Literal&amp;diff=9213</id>
		<title>Java/Web Services SOA/JAX WS Document Literal</title>
		<link rel="alternate" type="text/html" href="http://jexp.ru/index.php?title=Java/Web_Services_SOA/JAX_WS_Document_Literal&amp;diff=9213"/>
				<updated>2010-06-01T07:27:41Z</updated>
		
		<summary type="html">&lt;p&gt;Admin: 1 версия&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== JAX-WS: Doc-Literal From Java ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== JAX-WS: Doc-Literal From WSDL ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== JAX-WS: Doc-Literal String XML ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== JAX-WS: Document Literal ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== JAX-WS: Document-Literal String XML Based64 ==&lt;/div&gt;</summary>
		<author><name>Admin</name></author>	</entry>

	<entry>
		<id>http://jexp.ru/index.php?title=Java/Web_Services_SOA/WS_ReliableMessaging&amp;diff=9215</id>
		<title>Java/Web Services SOA/WS ReliableMessaging</title>
		<link rel="alternate" type="text/html" href="http://jexp.ru/index.php?title=Java/Web_Services_SOA/WS_ReliableMessaging&amp;diff=9215"/>
				<updated>2010-06-01T07:27:41Z</updated>
		
		<summary type="html">&lt;p&gt;Admin: 1 версия&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== This demo shows how WS-ReliableMessaging support in Apache CXF may be enabled ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
WS-RM Demo&lt;br /&gt;
==========&lt;br /&gt;
This demo shows how WS-ReliableMessaging support in Apache CXF may be enabled.  &lt;br /&gt;
The client and server both use interceptor configuration to install the&lt;br /&gt;
WS-RM interceptors, comprising logical interceptors (RMInInterceptor/RMOutInterceptor)&lt;br /&gt;
responsible for managing the reliability properties of the current message, and a&lt;br /&gt;
protocol interceptor (RMSoapInterceptor) responsible for encoding/decoding&lt;br /&gt;
these properties as SOAP Headers.&lt;br /&gt;
As WS-RM is dependent on WS-Addressing, the configuration uses &lt;br /&gt;
the same approach as the ws_addressing sample to enable this&lt;br /&gt;
functionality. However, you may notice that the WS-Addressing&lt;br /&gt;
namespace URI is different in this case (i.e.&lt;br /&gt;
http://schemas.xmlsoap.org/ws/2004/08/addressing as opposed to&lt;br /&gt;
http://www.w3.org/2005/08/addressing). This is because the WS-RM&lt;br /&gt;
specification is still based on an older version of WS-Addressing.&lt;br /&gt;
Three additional interceptors are configured: &lt;br /&gt;
- LoggingInInterceptor used on both the client- and server-side to log the &lt;br /&gt;
inbound SOAP messages and display these to the console. Notice the usage of &lt;br /&gt;
out-of-band RM protocol messages (CreateSequence and CreateSequenceResponse)&lt;br /&gt;
and the WS-RM headers in application-level messages (Sequence,&lt;br /&gt;
SequenceAcknowledgement, AckRequested etc.)  &lt;br /&gt;
- LoggingOutInterceptor used on both the client- and server-side to log the &lt;br /&gt;
outbound SOAP messages and display these to the console.&lt;br /&gt;
- MessageLossSimulator used only on the client-side to simulate message &lt;br /&gt;
loss by discarding every second application level message. This simulated &lt;br /&gt;
unreliability allows the retransmission of unacknowledged messages to be &lt;br /&gt;
observed.&lt;br /&gt;
This demo also illustrates usage of the decoupled HTTP transport, whereby&lt;br /&gt;
a separate server-&amp;gt;client HTTP connection is used to deliver responses&lt;br /&gt;
to (application or RM protocol) requests and server side originated &lt;br /&gt;
standalone acknowlegments.&lt;br /&gt;
The &amp;quot;partial response&amp;quot; referred to in the log output is the payload of&lt;br /&gt;
the HTTP 202 Accepted response sent on the back-channel of the original &lt;br /&gt;
client-&amp;gt;server connection. &lt;br /&gt;
In all other respects this demo is based on the basic hello_world sample,&lt;br /&gt;
illustrating that WS-Addressing usage is independent of the application.&lt;br /&gt;
One notable addition to the familiar hello_world WSDL is the usage&lt;br /&gt;
of the &amp;lt;wsaw:UsingAddressing&amp;gt; extension element to indicate the&lt;br /&gt;
WS-Addressing support is enabled for the service endpoint.&lt;br /&gt;
Please review the README in the samples directory before continuing.&lt;br /&gt;
&lt;br /&gt;
Prerequisite&lt;br /&gt;
------------&lt;br /&gt;
If your environment already includes cxf-manifest-incubator.jar on the CLASSPATH,&lt;br /&gt;
and the JDK and ant bin directories on the PATH, it is not necessary to&lt;br /&gt;
run the environment script described in the samples directory README.&lt;br /&gt;
If your environment is not properly configured, or if you are planning&lt;br /&gt;
on using wsdl2java, javac, and java to build and run the demos, you must&lt;br /&gt;
set the environment by running the script.&lt;br /&gt;
Building and running the demo using ant&lt;br /&gt;
---------------------------------------&lt;br /&gt;
From the samples/ws_rm directory, the ant build script can be used to&lt;br /&gt;
build and run the demo.  The server and client targets automatically build&lt;br /&gt;
the demo.&lt;br /&gt;
Using either UNIX or Windows:&lt;br /&gt;
  ant server&lt;br /&gt;
  ant client&lt;br /&gt;
On startup, the client makes a sequence of 4 oneway invocations.&lt;br /&gt;
The output of the logging interceptors will show that only the 1st and 3rd&lt;br /&gt;
reach their destination. Notice how after approximately 2 seconds the&lt;br /&gt;
messages that actually have arrived at the server will be acknowledged,&lt;br /&gt;
and how after approximately 4 seconds the client will resend the 2nd and 4th&lt;br /&gt;
application message. These will be acknowledged another 2 seconds&lt;br /&gt;
later so that there will be no further retransmissions from the client.&lt;br /&gt;
To remove the code generated from the WSDL file and the .class&lt;br /&gt;
files, run:&lt;br /&gt;
  ant clean&lt;br /&gt;
&lt;br /&gt;
Building the demo using wsdl2java and javac&lt;br /&gt;
-------------------------------------------&lt;br /&gt;
From the samples/ws_rm directory, first create the target directory&lt;br /&gt;
build/classes and then generate code from the WSDL file.&lt;br /&gt;
For UNIX:&lt;br /&gt;
  mkdir -p build/classes&lt;br /&gt;
  wsdl2java -d build/classes -compile ./wsdl/hello_world_rm.wsdl&lt;br /&gt;
For Windows:&lt;br /&gt;
  mkdir build\classes&lt;br /&gt;
    Must use back slashes.&lt;br /&gt;
  wsdl2java -d build\classes -compile .\wsdl\hello_world_rm.wsdl&lt;br /&gt;
    May use either forward or back slashes.&lt;br /&gt;
Now compile the provided client and server applications with the commands:&lt;br /&gt;
For UNIX:  &lt;br /&gt;
  &lt;br /&gt;
  export CLASSPATH=$CLASSPATH:$CXF_HOME/lib/celtix.jar:./build/classes&lt;br /&gt;
  javac -d build/classes src/demo/ws_rm/common/*.java&lt;br /&gt;
  javac -d build/classes src/demo/ws_rm/client/*.java&lt;br /&gt;
  javac -d build/classes src/demo/ws_rm/server/*.java&lt;br /&gt;
For Windows:&lt;br /&gt;
  set classpath=%classpath%;%CXF_HOME%\lib\celtix.jar;.\build\classes&lt;br /&gt;
  javac -d build\classes src\demo\ws_rm\common\*.java&lt;br /&gt;
  javac -d build\classes src\demo\ws_rm\client\*.java&lt;br /&gt;
  javac -d build\classes src\demo\ws_rm\server\*.java&lt;br /&gt;
Running the demo using java&lt;br /&gt;
---------------------------&lt;br /&gt;
From the samples/ws_rm directory run the commands (entered on a single command line):&lt;br /&gt;
For UNIX (must use forward slashes):&lt;br /&gt;
    java -Djava.util.logging.config.file=./logging.properties&lt;br /&gt;
         demo.ws_rm.server.Server &amp;amp;&lt;br /&gt;
    java -Djava.util.logging.config.file=./logging.properties&lt;br /&gt;
         demo.ws_rm.client.Client ./wsdl/hello_world_rm.wsdl&lt;br /&gt;
The server process starts in the background.&lt;br /&gt;
For Windows (may use either forward or back slashes):&lt;br /&gt;
  start &lt;br /&gt;
    java -Djava.util.logging.config.file=.\logging.properties&lt;br /&gt;
         demo.ws_rm.server.Server&lt;br /&gt;
    java -Djava.util.logging.config.file=.\logging.properties&lt;br /&gt;
         demo.ws_rm.client.Client .\wsdl\hello_world_rm.wsdl&lt;br /&gt;
The server process starts in a new command window.&lt;br /&gt;
After running the client, terminate the server process.&lt;br /&gt;
To remove the code generated from the WSDL file and the .class&lt;br /&gt;
files, either delete the build directory and its contents or run:&lt;br /&gt;
  ant clean&lt;br /&gt;
&lt;br /&gt;
//////////////////////////////////////////////////////////////////////////////////&lt;br /&gt;
/**&lt;br /&gt;
 * Licensed to the Apache Software Foundation (ASF) under one&lt;br /&gt;
 * or more contributor license agreements. See the NOTICE file&lt;br /&gt;
 * distributed with this work for additional information&lt;br /&gt;
 * regarding copyright ownership. The ASF licenses this file&lt;br /&gt;
 * to you under the Apache License, Version 2.0 (the&lt;br /&gt;
 * &amp;quot;License&amp;quot;); you may not use this file except in compliance&lt;br /&gt;
 * with the License. You may obtain a copy of the License at&lt;br /&gt;
 *&lt;br /&gt;
 * http://www.apache.org/licenses/LICENSE-2.0&lt;br /&gt;
 *&lt;br /&gt;
 * Unless required by applicable law or agreed to in writing,&lt;br /&gt;
 * software distributed under the License is distributed on an&lt;br /&gt;
 * &amp;quot;AS IS&amp;quot; BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY&lt;br /&gt;
 * KIND, either express or implied. See the License for the&lt;br /&gt;
 * specific language governing permissions and limitations&lt;br /&gt;
 * under the License.&lt;br /&gt;
 */&lt;br /&gt;
package demo.ws_rm.client;&lt;br /&gt;
import java.lang.reflect.UndeclaredThrowableException;&lt;br /&gt;
import demo.ws_rm.rumon.MessageLossSimulator;&lt;br /&gt;
import org.apache.cxf.Bus;&lt;br /&gt;
import org.apache.cxf.bus.spring.SpringBusFactory;&lt;br /&gt;
import org.apache.cxf.hello_world_soap_http.Greeter;&lt;br /&gt;
import org.apache.cxf.hello_world_soap_http.GreeterService;&lt;br /&gt;
&lt;br /&gt;
public final class Client {&lt;br /&gt;
    &lt;br /&gt;
    private static final String USER_NAME = System.getProperty(&amp;quot;user.name&amp;quot;);&lt;br /&gt;
    private Client() {&lt;br /&gt;
    } &lt;br /&gt;
    public static void main(String args[]) throws Exception {&lt;br /&gt;
        try { &lt;br /&gt;
       &lt;br /&gt;
            SpringBusFactory bf = new SpringBusFactory();&lt;br /&gt;
            Bus bus = bf.createBus(&amp;quot;ws_rm.xml&amp;quot;);&lt;br /&gt;
            bf.setDefaultBus(bus);&lt;br /&gt;
            bus.getOutInterceptors().add(new MessageLossSimulator());&lt;br /&gt;
 &lt;br /&gt;
            GreeterService service = new GreeterService();&lt;br /&gt;
            Greeter port = service.getGreeterPort();&lt;br /&gt;
            String[] names = new String[] {&amp;quot;Anne&amp;quot;, &amp;quot;Bill&amp;quot;, &amp;quot;Chris&amp;quot;, &amp;quot;Daisy&amp;quot;};&lt;br /&gt;
            // make a sequence of 4 invocations&lt;br /&gt;
            for (int i = 0; i &amp;lt; 4; i++) {&lt;br /&gt;
                System.out.println(&amp;quot;Invoking greetMeOneWay...&amp;quot;);&lt;br /&gt;
                port.greetMeOneWay(names[i]);&lt;br /&gt;
                System.out.println(&amp;quot;No response as method is OneWay\n&amp;quot;);&lt;br /&gt;
            }&lt;br /&gt;
            // allow aynchronous resends to occur&lt;br /&gt;
            Thread.sleep(30 * 1000);&lt;br /&gt;
            bus.shutdown(true);&lt;br /&gt;
        } catch (UndeclaredThrowableException ex) { &lt;br /&gt;
            ex.getUndeclaredThrowable().printStackTrace();&lt;br /&gt;
        } catch (Exception ex) { &lt;br /&gt;
            ex.printStackTrace();&lt;br /&gt;
        } finally { &lt;br /&gt;
            System.exit(0); &lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
//////////////////////////////////////////////////////////////////////////////////&lt;br /&gt;
/**&lt;br /&gt;
 * Licensed to the Apache Software Foundation (ASF) under one&lt;br /&gt;
 * or more contributor license agreements. See the NOTICE file&lt;br /&gt;
 * distributed with this work for additional information&lt;br /&gt;
 * regarding copyright ownership. The ASF licenses this file&lt;br /&gt;
 * to you under the Apache License, Version 2.0 (the&lt;br /&gt;
 * &amp;quot;License&amp;quot;); you may not use this file except in compliance&lt;br /&gt;
 * with the License. You may obtain a copy of the License at&lt;br /&gt;
 *&lt;br /&gt;
 * http://www.apache.org/licenses/LICENSE-2.0&lt;br /&gt;
 *&lt;br /&gt;
 * Unless required by applicable law or agreed to in writing,&lt;br /&gt;
 * software distributed under the License is distributed on an&lt;br /&gt;
 * &amp;quot;AS IS&amp;quot; BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY&lt;br /&gt;
 * KIND, either express or implied. See the License for the&lt;br /&gt;
 * specific language governing permissions and limitations&lt;br /&gt;
 * under the License.&lt;br /&gt;
 */&lt;br /&gt;
package demos.ws_rm.rumon;&lt;br /&gt;
import java.util.logging.LogRecord;&lt;br /&gt;
import java.util.logging.SimpleFormatter;&lt;br /&gt;
public class ConciseFormatter extends SimpleFormatter {&lt;br /&gt;
    public synchronized String format(LogRecord record) {&lt;br /&gt;
        String longForm = super.format(record);&lt;br /&gt;
        String shortForm = longForm.indexOf(&amp;quot;INFO: &amp;quot;) &amp;gt; 0&lt;br /&gt;
                           ? longForm.substring(longForm.indexOf(&amp;quot;INFO: &amp;quot;) + 6)&lt;br /&gt;
                           : longForm;&lt;br /&gt;
        return shortForm;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
//////////////////////////////////////////////////////////////////////////////////&lt;br /&gt;
/**&lt;br /&gt;
 * Licensed to the Apache Software Foundation (ASF) under one&lt;br /&gt;
 * or more contributor license agreements. See the NOTICE file&lt;br /&gt;
 * distributed with this work for additional information&lt;br /&gt;
 * regarding copyright ownership. The ASF licenses this file&lt;br /&gt;
 * to you under the Apache License, Version 2.0 (the&lt;br /&gt;
 * &amp;quot;License&amp;quot;); you may not use this file except in compliance&lt;br /&gt;
 * with the License. You may obtain a copy of the License at&lt;br /&gt;
 *&lt;br /&gt;
 * http://www.apache.org/licenses/LICENSE-2.0&lt;br /&gt;
 *&lt;br /&gt;
 * Unless required by applicable law or agreed to in writing,&lt;br /&gt;
 * software distributed under the License is distributed on an&lt;br /&gt;
 * &amp;quot;AS IS&amp;quot; BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY&lt;br /&gt;
 * KIND, either express or implied. See the License for the&lt;br /&gt;
 * specific language governing permissions and limitations&lt;br /&gt;
 * under the License.&lt;br /&gt;
 */&lt;br /&gt;
package demo.ws_rm.rumon;&lt;br /&gt;
import java.io.IOException;&lt;br /&gt;
import java.io.OutputStream;&lt;br /&gt;
import java.math.BigInteger;&lt;br /&gt;
import java.util.ListIterator;&lt;br /&gt;
import java.util.logging.Level;&lt;br /&gt;
import java.util.logging.Logger;&lt;br /&gt;
import org.apache.cxf.interceptor.Fault;&lt;br /&gt;
import org.apache.cxf.interceptor.InterceptorChain;&lt;br /&gt;
import org.apache.cxf.interceptor.MessageSenderInterceptor;&lt;br /&gt;
import org.apache.cxf.io.AbstractWrappedOutputStream;&lt;br /&gt;
import org.apache.cxf.message.Message;&lt;br /&gt;
import org.apache.cxf.phase.AbstractPhaseInterceptor;&lt;br /&gt;
import org.apache.cxf.phase.Phase;&lt;br /&gt;
import org.apache.cxf.phase.PhaseInterceptor;&lt;br /&gt;
import org.apache.cxf.ws.addressing.AddressingProperties;&lt;br /&gt;
import org.apache.cxf.ws.rm.RMContextUtils;&lt;br /&gt;
/**&lt;br /&gt;
 * &lt;br /&gt;
 */&lt;br /&gt;
public class MessageLossSimulator extends AbstractPhaseInterceptor&amp;lt;Message&amp;gt; {&lt;br /&gt;
    private static final Logger LOG = Logger.getLogger(MessageLossSimulator.class.getName());&lt;br /&gt;
    private int appMessageCount; &lt;br /&gt;
    &lt;br /&gt;
    public MessageLossSimulator() {&lt;br /&gt;
        super(Phase.PREPARE_SEND);&lt;br /&gt;
        addBefore(MessageSenderInterceptor.class.getName());&lt;br /&gt;
    }&lt;br /&gt;
    /**&lt;br /&gt;
      * Simulate loss of every second application message by replacing the stream normally &lt;br /&gt;
      * provided by the transport (in the MessageSenderInterceptor)/ &lt;br /&gt;
     */ &lt;br /&gt;
    public void handleMessage(Message message) throws Fault {&lt;br /&gt;
        AddressingProperties maps =&lt;br /&gt;
            RMContextUtils.retrieveMAPs(message, false, true);&lt;br /&gt;
        RMContextUtils.ensureExposedVersion(maps);&lt;br /&gt;
        String action = null;&lt;br /&gt;
        if (maps != null &amp;amp;&amp;amp; null != maps.getAction()) {&lt;br /&gt;
            action = maps.getAction().getValue();&lt;br /&gt;
        }&lt;br /&gt;
        if (RMContextUtils.isRMProtocolMessage(action)) { &lt;br /&gt;
            return;&lt;br /&gt;
        }&lt;br /&gt;
        appMessageCount++;&lt;br /&gt;
        if (0 != (appMessageCount % 2)) {&lt;br /&gt;
            return;&lt;br /&gt;
        }&lt;br /&gt;
        &lt;br /&gt;
        InterceptorChain chain = message.getInterceptorChain();&lt;br /&gt;
        ListIterator it = chain.getIterator();&lt;br /&gt;
        while (it.hasNext()) {&lt;br /&gt;
            PhaseInterceptor pi = (PhaseInterceptor)it.next();&lt;br /&gt;
            if (MessageSenderInterceptor.class.getName().equals(pi.getId())) {&lt;br /&gt;
                chain.remove(pi);&lt;br /&gt;
                LOG.fine(&amp;quot;Removed MessageSenderInterceptor from interceptor chain.&amp;quot;);&lt;br /&gt;
                break;&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
        &lt;br /&gt;
        message.setContent(OutputStream.class, new WrappedOutputStream(message));     &lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    private class WrappedOutputStream extends AbstractWrappedOutputStream {&lt;br /&gt;
        private Message outMessage;&lt;br /&gt;
        public WrappedOutputStream(Message m) {&lt;br /&gt;
            this.outMessage = m;&lt;br /&gt;
        }&lt;br /&gt;
        @Override&lt;br /&gt;
        protected void onFirstWrite() throws IOException {&lt;br /&gt;
            if (LOG.isLoggable(Level.FINE)) {&lt;br /&gt;
                BigInteger nr = RMContextUtils.retrieveRMProperties(outMessage, true)&lt;br /&gt;
                    .getSequence().getMessageNumber();&lt;br /&gt;
                LOG.fine(&amp;quot;Losing message &amp;quot; + nr);&lt;br /&gt;
            }&lt;br /&gt;
            wrappedStream = new DummyOutputStream();&lt;br /&gt;
        }&lt;br /&gt;
    }    &lt;br /&gt;
            &lt;br /&gt;
    &lt;br /&gt;
    private class DummyOutputStream extends OutputStream {&lt;br /&gt;
        @Override&lt;br /&gt;
        public void write(int b) throws IOException {&lt;br /&gt;
            // TODO Auto-generated method stub&lt;br /&gt;
            &lt;br /&gt;
        }&lt;br /&gt;
        &lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
//////////////////////////////////////////////////////////////////////////////////&lt;br /&gt;
/**&lt;br /&gt;
 * Licensed to the Apache Software Foundation (ASF) under one&lt;br /&gt;
 * or more contributor license agreements. See the NOTICE file&lt;br /&gt;
 * distributed with this work for additional information&lt;br /&gt;
 * regarding copyright ownership. The ASF licenses this file&lt;br /&gt;
 * to you under the Apache License, Version 2.0 (the&lt;br /&gt;
 * &amp;quot;License&amp;quot;); you may not use this file except in compliance&lt;br /&gt;
 * with the License. You may obtain a copy of the License at&lt;br /&gt;
 *&lt;br /&gt;
 * http://www.apache.org/licenses/LICENSE-2.0&lt;br /&gt;
 *&lt;br /&gt;
 * Unless required by applicable law or agreed to in writing,&lt;br /&gt;
 * software distributed under the License is distributed on an&lt;br /&gt;
 * &amp;quot;AS IS&amp;quot; BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY&lt;br /&gt;
 * KIND, either express or implied. See the License for the&lt;br /&gt;
 * specific language governing permissions and limitations&lt;br /&gt;
 * under the License.&lt;br /&gt;
 */&lt;br /&gt;
package demo.ws_rm.server;&lt;br /&gt;
import java.util.logging.Logger;&lt;br /&gt;
import org.apache.cxf.hello_world_soap_http.Greeter;&lt;br /&gt;
@javax.jws.WebService(serviceName = &amp;quot;GreeterService&amp;quot;,&lt;br /&gt;
            portName = &amp;quot;GreeterPort&amp;quot;,&lt;br /&gt;
            endpointInterface = &amp;quot;org.apache.cxf.hello_world_soap_http.Greeter&amp;quot;,&lt;br /&gt;
            wsdlLocation = &amp;quot;file:./wsdl/hello_world_rm.wsdl&amp;quot;,&lt;br /&gt;
            targetNamespace = &amp;quot;http://cxf.apache.org/hello_world_soap_http&amp;quot;)&lt;br /&gt;
                  &lt;br /&gt;
public class GreeterImpl implements Greeter {&lt;br /&gt;
    private static final Logger LOG = &lt;br /&gt;
        Logger.getLogger(GreeterImpl.class.getPackage().getName());&lt;br /&gt;
    &lt;br /&gt;
    /* (non-Javadoc)&lt;br /&gt;
     * @see org.apache.cxf.hello_world_soap_http.Greeter#greetMe(java.lang.String)&lt;br /&gt;
     */&lt;br /&gt;
    public String greetMe(String me) {&lt;br /&gt;
        LOG.info(&amp;quot;Executing operation greetMe&amp;quot;);&lt;br /&gt;
        System.out.println(&amp;quot;Executing operation greetMe&amp;quot;);&lt;br /&gt;
        System.out.println(&amp;quot;Message received: &amp;quot; + me + &amp;quot;\n&amp;quot;);&lt;br /&gt;
        return &amp;quot;Hello &amp;quot; + me;&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    /* (non-Javadoc)&lt;br /&gt;
     * @see org.apache.cxf.hello_world_soap_http.Greeter#greetMeOneWay(java.lang.String)&lt;br /&gt;
     */&lt;br /&gt;
    public void greetMeOneWay(String me) {&lt;br /&gt;
        LOG.info(&amp;quot;Executing operation greetMeOneWay&amp;quot;);&lt;br /&gt;
        System.out.println(&amp;quot;Executing operation greetMeOneWay\n&amp;quot;);&lt;br /&gt;
        System.out.println(&amp;quot;Hello there &amp;quot; + me);&lt;br /&gt;
    }&lt;br /&gt;
    /* (non-Javadoc)&lt;br /&gt;
     * @see org.apache.cxf.hello_world_soap_http.Greeter#sayHi()&lt;br /&gt;
     */&lt;br /&gt;
    public String sayHi() {&lt;br /&gt;
        LOG.info(&amp;quot;Executing operation sayHi&amp;quot;);&lt;br /&gt;
        System.out.println(&amp;quot;Executing operation sayHi\n&amp;quot;);&lt;br /&gt;
        return &amp;quot;Bonjour&amp;quot;;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
//////////////////////////////////////////////////////////////////////////////////&lt;br /&gt;
&lt;br /&gt;
/**&lt;br /&gt;
 * Licensed to the Apache Software Foundation (ASF) under one&lt;br /&gt;
 * or more contributor license agreements. See the NOTICE file&lt;br /&gt;
 * distributed with this work for additional information&lt;br /&gt;
 * regarding copyright ownership. The ASF licenses this file&lt;br /&gt;
 * to you under the Apache License, Version 2.0 (the&lt;br /&gt;
 * &amp;quot;License&amp;quot;); you may not use this file except in compliance&lt;br /&gt;
 * with the License. You may obtain a copy of the License at&lt;br /&gt;
 *&lt;br /&gt;
 * http://www.apache.org/licenses/LICENSE-2.0&lt;br /&gt;
 *&lt;br /&gt;
 * Unless required by applicable law or agreed to in writing,&lt;br /&gt;
 * software distributed under the License is distributed on an&lt;br /&gt;
 * &amp;quot;AS IS&amp;quot; BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY&lt;br /&gt;
 * KIND, either express or implied. See the License for the&lt;br /&gt;
 * specific language governing permissions and limitations&lt;br /&gt;
 * under the License.&lt;br /&gt;
 */&lt;br /&gt;
package demo.ws_rm.server;&lt;br /&gt;
import javax.xml.ws.Endpoint;&lt;br /&gt;
import org.apache.cxf.Bus;&lt;br /&gt;
import org.apache.cxf.bus.spring.SpringBusFactory;&lt;br /&gt;
public class Server {&lt;br /&gt;
    protected Server() throws Exception {&lt;br /&gt;
        System.out.println(&amp;quot;Starting Server&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
        Object implementor = new GreeterImpl();&lt;br /&gt;
        String address = &amp;quot;http://localhost:9000/SoapContext/GreeterPort&amp;quot;;&lt;br /&gt;
        Endpoint e = Endpoint.publish(address, implementor);&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    public static void main(String args[]) throws Exception {&lt;br /&gt;
        SpringBusFactory bf = new SpringBusFactory();&lt;br /&gt;
        Bus bus = bf.createBus(&amp;quot;ws_rm.xml&amp;quot;);&lt;br /&gt;
        bf.setDefaultBus(bus);&lt;br /&gt;
        new Server();&lt;br /&gt;
        System.out.println(&amp;quot;Server ready...&amp;quot;); &lt;br /&gt;
        &lt;br /&gt;
        Thread.sleep(5 * 60 * 1000); &lt;br /&gt;
      &lt;br /&gt;
        bus.shutdown(true);&lt;br /&gt;
        System.out.println(&amp;quot;Server exiting&amp;quot;);&lt;br /&gt;
        System.exit(0);&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
/////////////////////////////////////////////////////////////////////////////&lt;br /&gt;
&lt;br /&gt;
&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot;?&amp;gt;&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
  Licensed to the Apache Software Foundation (ASF) under one&lt;br /&gt;
  or more contributor license agreements. See the NOTICE file&lt;br /&gt;
  distributed with this work for additional information&lt;br /&gt;
  regarding copyright ownership. The ASF licenses this file&lt;br /&gt;
  to you under the Apache License, Version 2.0 (the&lt;br /&gt;
  &amp;quot;License&amp;quot;); you may not use this file except in compliance&lt;br /&gt;
  with the License. You may obtain a copy of the License at&lt;br /&gt;
 &lt;br /&gt;
  http://www.apache.org/licenses/LICENSE-2.0&lt;br /&gt;
 &lt;br /&gt;
  Unless required by applicable law or agreed to in writing,&lt;br /&gt;
  software distributed under the License is distributed on an&lt;br /&gt;
  &amp;quot;AS IS&amp;quot; BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY&lt;br /&gt;
  KIND, either express or implied. See the License for the&lt;br /&gt;
  specific language governing permissions and limitations&lt;br /&gt;
  under the License.&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&amp;lt;wsdl:definitions name=&amp;quot;HelloWorld&amp;quot; targetNamespace=&amp;quot;http://cxf.apache.org/hello_world_soap_http&amp;quot; &lt;br /&gt;
    xmlns=&amp;quot;http://schemas.xmlsoap.org/wsdl/&amp;quot; &lt;br /&gt;
    xmlns:soap=&amp;quot;http://schemas.xmlsoap.org/wsdl/soap/&amp;quot; &lt;br /&gt;
    xmlns:tns=&amp;quot;http://cxf.apache.org/hello_world_soap_http&amp;quot;&lt;br /&gt;
    xmlns:x1=&amp;quot;http://cxf.apache.org/hello_world_soap_http/types&amp;quot;&lt;br /&gt;
    xmlns:wsdl=&amp;quot;http://schemas.xmlsoap.org/wsdl/&amp;quot; &lt;br /&gt;
    xmlns:xsd=&amp;quot;http://www.w3.org/2001/XMLSchema&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;wsdl:types&amp;gt;&lt;br /&gt;
        &amp;lt;schema targetNamespace=&amp;quot;http://cxf.apache.org/hello_world_soap_http/types&amp;quot; &lt;br /&gt;
            xmlns=&amp;quot;http://www.w3.org/2001/XMLSchema&amp;quot; elementFormDefault=&amp;quot;qualified&amp;quot;&amp;gt;&lt;br /&gt;
            &amp;lt;element name=&amp;quot;sayHi&amp;quot;&amp;gt;&lt;br /&gt;
                &amp;lt;complexType/&amp;gt;&lt;br /&gt;
            &amp;lt;/element&amp;gt;&lt;br /&gt;
            &amp;lt;element name=&amp;quot;sayHiResponse&amp;quot;&amp;gt;&lt;br /&gt;
                &amp;lt;complexType&amp;gt;&lt;br /&gt;
                    &amp;lt;sequence&amp;gt;&lt;br /&gt;
                        &amp;lt;element name=&amp;quot;responseType&amp;quot; type=&amp;quot;xsd:string&amp;quot;/&amp;gt;&lt;br /&gt;
                    &amp;lt;/sequence&amp;gt;&lt;br /&gt;
                &amp;lt;/complexType&amp;gt;&lt;br /&gt;
            &amp;lt;/element&amp;gt;&lt;br /&gt;
            &amp;lt;element name=&amp;quot;greetMe&amp;quot;&amp;gt;&lt;br /&gt;
                &amp;lt;complexType&amp;gt;&lt;br /&gt;
                    &amp;lt;sequence&amp;gt;&lt;br /&gt;
                        &amp;lt;element name=&amp;quot;requestType&amp;quot; type=&amp;quot;xsd:string&amp;quot;/&amp;gt;&lt;br /&gt;
                    &amp;lt;/sequence&amp;gt;&lt;br /&gt;
                &amp;lt;/complexType&amp;gt;&lt;br /&gt;
            &amp;lt;/element&amp;gt;&lt;br /&gt;
            &amp;lt;element name=&amp;quot;greetMeResponse&amp;quot;&amp;gt;&lt;br /&gt;
                &amp;lt;complexType&amp;gt;&lt;br /&gt;
                    &amp;lt;sequence&amp;gt;&lt;br /&gt;
                        &amp;lt;element name=&amp;quot;responseType&amp;quot; type=&amp;quot;xsd:string&amp;quot;/&amp;gt;&lt;br /&gt;
                    &amp;lt;/sequence&amp;gt;&lt;br /&gt;
                &amp;lt;/complexType&amp;gt;&lt;br /&gt;
            &amp;lt;/element&amp;gt;&lt;br /&gt;
            &amp;lt;element name=&amp;quot;greetMeOneWay&amp;quot;&amp;gt;&lt;br /&gt;
                &amp;lt;complexType&amp;gt;&lt;br /&gt;
                    &amp;lt;sequence&amp;gt;&lt;br /&gt;
                        &amp;lt;element name=&amp;quot;requestType&amp;quot; type=&amp;quot;xsd:string&amp;quot;/&amp;gt;&lt;br /&gt;
                    &amp;lt;/sequence&amp;gt;&lt;br /&gt;
                &amp;lt;/complexType&amp;gt;&lt;br /&gt;
            &amp;lt;/element&amp;gt;&lt;br /&gt;
        &amp;lt;/schema&amp;gt;&lt;br /&gt;
    &amp;lt;/wsdl:types&amp;gt;&lt;br /&gt;
    &amp;lt;wsdl:message name=&amp;quot;sayHiRequest&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;wsdl:part element=&amp;quot;x1:sayHi&amp;quot; name=&amp;quot;in&amp;quot;/&amp;gt;&lt;br /&gt;
    &amp;lt;/wsdl:message&amp;gt;&lt;br /&gt;
    &amp;lt;wsdl:message name=&amp;quot;sayHiResponse&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;wsdl:part element=&amp;quot;x1:sayHiResponse&amp;quot; name=&amp;quot;out&amp;quot;/&amp;gt;&lt;br /&gt;
    &amp;lt;/wsdl:message&amp;gt;&lt;br /&gt;
    &amp;lt;wsdl:message name=&amp;quot;greetMeRequest&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;wsdl:part element=&amp;quot;x1:greetMe&amp;quot; name=&amp;quot;in&amp;quot;/&amp;gt;&lt;br /&gt;
    &amp;lt;/wsdl:message&amp;gt;&lt;br /&gt;
    &amp;lt;wsdl:message name=&amp;quot;greetMeResponse&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;wsdl:part element=&amp;quot;x1:greetMeResponse&amp;quot; name=&amp;quot;out&amp;quot;/&amp;gt;&lt;br /&gt;
    &amp;lt;/wsdl:message&amp;gt;&lt;br /&gt;
    &amp;lt;wsdl:message name=&amp;quot;greetMeOneWayRequest&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;wsdl:part element=&amp;quot;x1:greetMeOneWay&amp;quot; name=&amp;quot;in&amp;quot;/&amp;gt;&lt;br /&gt;
    &amp;lt;/wsdl:message&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
    &amp;lt;wsdl:portType name=&amp;quot;Greeter&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;wsdl:operation name=&amp;quot;sayHi&amp;quot;&amp;gt;&lt;br /&gt;
            &amp;lt;wsdl:input message=&amp;quot;tns:sayHiRequest&amp;quot; name=&amp;quot;sayHiRequest&amp;quot;/&amp;gt;&lt;br /&gt;
            &amp;lt;wsdl:output message=&amp;quot;tns:sayHiResponse&amp;quot; name=&amp;quot;sayHiResponse&amp;quot;/&amp;gt;&lt;br /&gt;
        &amp;lt;/wsdl:operation&amp;gt;&lt;br /&gt;
        &lt;br /&gt;
        &amp;lt;wsdl:operation name=&amp;quot;greetMe&amp;quot;&amp;gt;&lt;br /&gt;
            &amp;lt;wsdl:input message=&amp;quot;tns:greetMeRequest&amp;quot; name=&amp;quot;greetMeRequest&amp;quot;/&amp;gt;&lt;br /&gt;
            &amp;lt;wsdl:output message=&amp;quot;tns:greetMeResponse&amp;quot; name=&amp;quot;greetMeResponse&amp;quot;/&amp;gt;&lt;br /&gt;
        &amp;lt;/wsdl:operation&amp;gt;&lt;br /&gt;
        &lt;br /&gt;
        &amp;lt;wsdl:operation name=&amp;quot;greetMeOneWay&amp;quot;&amp;gt;&lt;br /&gt;
            &amp;lt;wsdl:input message=&amp;quot;tns:greetMeOneWayRequest&amp;quot; name=&amp;quot;greetMeOneWayRequest&amp;quot;/&amp;gt;&lt;br /&gt;
        &amp;lt;/wsdl:operation&amp;gt;&lt;br /&gt;
    &amp;lt;/wsdl:portType&amp;gt;&lt;br /&gt;
    &amp;lt;wsdl:binding name=&amp;quot;Greeter_SOAPBinding&amp;quot; type=&amp;quot;tns:Greeter&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;soap:binding style=&amp;quot;document&amp;quot; transport=&amp;quot;http://schemas.xmlsoap.org/soap/http&amp;quot;/&amp;gt;&lt;br /&gt;
        &lt;br /&gt;
        &amp;lt;wsdl:operation name=&amp;quot;sayHi&amp;quot;&amp;gt;&lt;br /&gt;
            &amp;lt;soap:operation soapAction=&amp;quot;&amp;quot; style=&amp;quot;document&amp;quot;/&amp;gt;&lt;br /&gt;
            &amp;lt;wsdl:input name=&amp;quot;sayHiRequest&amp;quot;&amp;gt;&lt;br /&gt;
                &amp;lt;soap:body use=&amp;quot;literal&amp;quot;/&amp;gt;&lt;br /&gt;
            &amp;lt;/wsdl:input&amp;gt;&lt;br /&gt;
            &amp;lt;wsdl:output name=&amp;quot;sayHiResponse&amp;quot;&amp;gt;&lt;br /&gt;
                &amp;lt;soap:body use=&amp;quot;literal&amp;quot;/&amp;gt;&lt;br /&gt;
            &amp;lt;/wsdl:output&amp;gt;&lt;br /&gt;
        &amp;lt;/wsdl:operation&amp;gt;&lt;br /&gt;
        &lt;br /&gt;
        &amp;lt;wsdl:operation name=&amp;quot;greetMe&amp;quot;&amp;gt;&lt;br /&gt;
            &amp;lt;soap:operation soapAction=&amp;quot;&amp;quot; style=&amp;quot;document&amp;quot;/&amp;gt;&lt;br /&gt;
            &amp;lt;wsdl:input name=&amp;quot;greetMeRequest&amp;quot;&amp;gt;&lt;br /&gt;
                &amp;lt;soap:body use=&amp;quot;literal&amp;quot;/&amp;gt;&lt;br /&gt;
            &amp;lt;/wsdl:input&amp;gt;&lt;br /&gt;
            &amp;lt;wsdl:output name=&amp;quot;greetMeResponse&amp;quot;&amp;gt;&lt;br /&gt;
                &amp;lt;soap:body use=&amp;quot;literal&amp;quot;/&amp;gt;&lt;br /&gt;
            &amp;lt;/wsdl:output&amp;gt;&lt;br /&gt;
        &amp;lt;/wsdl:operation&amp;gt;&lt;br /&gt;
        &lt;br /&gt;
        &amp;lt;wsdl:operation name=&amp;quot;greetMeOneWay&amp;quot;&amp;gt;&lt;br /&gt;
            &amp;lt;soap:operation soapAction=&amp;quot;&amp;quot; style=&amp;quot;document&amp;quot;/&amp;gt;&lt;br /&gt;
            &amp;lt;wsdl:input name=&amp;quot;greetMeOneWayRequest&amp;quot;&amp;gt;&lt;br /&gt;
                &amp;lt;soap:body use=&amp;quot;literal&amp;quot;/&amp;gt;&lt;br /&gt;
            &amp;lt;/wsdl:input&amp;gt;&lt;br /&gt;
        &amp;lt;/wsdl:operation&amp;gt;&lt;br /&gt;
    &amp;lt;/wsdl:binding&amp;gt;&lt;br /&gt;
    &amp;lt;wsdl:service name=&amp;quot;GreeterService&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;wsdl:port binding=&amp;quot;tns:Greeter_SOAPBinding&amp;quot; name=&amp;quot;GreeterPort&amp;quot;&amp;gt;&lt;br /&gt;
            &amp;lt;soap:address location=&amp;quot;http://localhost:9000/SoapContext/GreeterPort&amp;quot;/&amp;gt;&lt;br /&gt;
            &amp;lt;wswa:UsingAddressing xmlns:wswa=&amp;quot;http://www.w3.org/2005/02/addressing/wsdl&amp;quot;/&amp;gt;&lt;br /&gt;
        &amp;lt;/wsdl:port&amp;gt;&lt;br /&gt;
    &amp;lt;/wsdl:service&amp;gt;&lt;br /&gt;
&amp;lt;/wsdl:definitions&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
        &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;/div&gt;</summary>
		<author><name>Admin</name></author>	</entry>

	<entry>
		<id>http://jexp.ru/index.php?title=Java/Web_Services_SOA/CXF_XFire&amp;diff=9209</id>
		<title>Java/Web Services SOA/CXF XFire</title>
		<link rel="alternate" type="text/html" href="http://jexp.ru/index.php?title=Java/Web_Services_SOA/CXF_XFire&amp;diff=9209"/>
				<updated>2010-06-01T07:27:40Z</updated>
		
		<summary type="html">&lt;p&gt;Admin: 1 версия&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== MTOSI 1.1 Samples ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
MTOSI 1.1 Samples&lt;br /&gt;
=================&lt;br /&gt;
mtosi_1.1 contains the following subdirectories:&lt;br /&gt;
wsdl            - contains the mtosi 1.1 wsdls&lt;br /&gt;
xsd             - contains the mtosi 1.1 schemas&lt;br /&gt;
alarm_retrieval - contains a simple sample implementation of the &lt;br /&gt;
                  alarm_retrieval mtosi interface.  Please refer to&lt;br /&gt;
                  the alarm_retrieval/README.txt for instructions to&lt;br /&gt;
                  run that demo.&lt;br /&gt;
code_gen        - contains targets for generating code for mtosi&lt;br /&gt;
                  interfaces which do not have a sample implementation&lt;br /&gt;
&lt;br /&gt;
Going beyond the basic sample&lt;br /&gt;
=============================&lt;br /&gt;
You can use the alarm_retrieval demo as a template for implementing&lt;br /&gt;
any of the other mtosi interfaces.  The code_gen directory&lt;br /&gt;
demonstrates the wsdl2java targets needed to generate code for the&lt;br /&gt;
remaining mtosi interfaces.&lt;br /&gt;
&lt;br /&gt;
        &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== This demo illustrates the use of the JAX-WS APIs to run a simple client against a standalone server using SOAP 1.1 over HTTP ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
Hello World Demo using Document/Literal Style&lt;br /&gt;
=============================================&lt;br /&gt;
This demo illustrates the use of the JAX-WS APIs to run a simple&lt;br /&gt;
client against a standalone server using SOAP 1.1 over HTTP.&lt;br /&gt;
It also shows how CXF configuration can be used to enable schema validation&lt;br /&gt;
on the client and/or server side: By default the message parameters would not&lt;br /&gt;
be validated, but the presence of the cxf.xml configuration file on&lt;br /&gt;
the classpath, and its content change this default behavior:&lt;br /&gt;
The configuration file specifies that &lt;br /&gt;
a) if a JAX-WS client proxy is created for port {http://apache.org/hello_world_soap_http}SoapPort&lt;br /&gt;
it should have schema validation enabled.&lt;br /&gt;
b) if a JAX-WS server endpoint is created for port {http://apache.org/hello_world_soap_http}SoapPort&lt;br /&gt;
it should have schema validation enabled.&lt;br /&gt;
The client&amp;quot;s second greetMe invocation causes an exception (a marshalling&lt;br /&gt;
error) on the client side, i.e. before the request with the invalid parameter&lt;br /&gt;
goes on the wire.&lt;br /&gt;
After commenting the definition of the &amp;lt;jaxws:client&amp;gt; element in cxf.xml you &lt;br /&gt;
will notice that the client&amp;quot;s second greetMe invocation still throws an exception,&lt;br /&gt;
but that this time the exception is caused by an unmarshalling error on the&lt;br /&gt;
server side.&lt;br /&gt;
Commenting both elements, or renaming/removing the cfg.xml file, and thus&lt;br /&gt;
restoring the default behavior, results in the second greetMe invocation&lt;br /&gt;
not causing an exception.&lt;br /&gt;
Please review the README in the samples directory before continuing.&lt;br /&gt;
&lt;br /&gt;
Prerequisite&lt;br /&gt;
------------&lt;br /&gt;
If your environment already includes cxf-manifest-incubator.jar on the&lt;br /&gt;
CLASSPATH, and the JDK and ant bin directories on the PATH&lt;br /&gt;
it is not necessary to set the environment as described in&lt;br /&gt;
the samples directory README.  If your environment is not&lt;br /&gt;
properly configured, or if you are planning on using wsdl2java,&lt;br /&gt;
javac, and java to build and run the demos, you must set the&lt;br /&gt;
environment.&lt;br /&gt;
&lt;br /&gt;
Building and running the demo using ant&lt;br /&gt;
---------------------------------------&lt;br /&gt;
From the samples/hello_world directory, the ant build script&lt;br /&gt;
can be used to build and run the demo.&lt;br /&gt;
Using either UNIX or Windows:&lt;br /&gt;
  ant build&lt;br /&gt;
  ant server&lt;br /&gt;
  ant client&lt;br /&gt;
    &lt;br /&gt;
To remove the code generated from the WSDL file and the .class&lt;br /&gt;
files, run:&lt;br /&gt;
  ant clean&lt;br /&gt;
&lt;br /&gt;
Building the demo using wsdl2java and javac&lt;br /&gt;
-------------------------------------------&lt;br /&gt;
From the samples/hello_world directory, first create the target&lt;br /&gt;
directory build/classes and then generate code from the WSDL file.&lt;br /&gt;
For UNIX:&lt;br /&gt;
  mkdir -p build/classes&lt;br /&gt;
  wsdl2java -d build/classes -compile ./wsdl/hello_world.wsdl&lt;br /&gt;
For Windows:&lt;br /&gt;
  mkdir build\classes&lt;br /&gt;
    Must use back slashes.&lt;br /&gt;
  wsdl2java -d build\classes -compile .\wsdl\hello_world.wsdl&lt;br /&gt;
    May use either forward or back slashes.&lt;br /&gt;
Now compile the provided client and server applications with the commands:&lt;br /&gt;
For UNIX:  &lt;br /&gt;
  &lt;br /&gt;
  export CLASSPATH=$CLASSPATH:$CXF_HOME/lib/cxf-manifest-incubator.jar:./build/classes&lt;br /&gt;
  javac -d build/classes src/demo/hw/client/*.java&lt;br /&gt;
  javac -d build/classes src/demo/hw/server/*.java&lt;br /&gt;
For Windows:&lt;br /&gt;
  set classpath=%classpath%;%CXF_HOME%\lib\cxf-manifest-incubator.jar;.\build\classes&lt;br /&gt;
  javac -d build\classes src\demo\hw\client\*.java&lt;br /&gt;
  javac -d build\classes src\demo\hw\server\*.java&lt;br /&gt;
&lt;br /&gt;
Running the demo using java&lt;br /&gt;
---------------------------&lt;br /&gt;
From the samples/hello_world directory run the commands, entered on a&lt;br /&gt;
single command line:&lt;br /&gt;
For UNIX (must use forward slashes):&lt;br /&gt;
    java -Djava.util.logging.config.file=$CXF_HOME/etc/logging.properties&lt;br /&gt;
         demo.hw.server.Server &amp;amp;&lt;br /&gt;
    java -Djava.util.logging.config.file=$CXF_HOME/etc/logging.properties&lt;br /&gt;
         demo.hw.client.Client ./wsdl/hello_world.wsdl&lt;br /&gt;
The server process starts in the background.  After running the client,&lt;br /&gt;
use the kill command to terminate the server process.&lt;br /&gt;
For Windows (may use either forward or back slashes):&lt;br /&gt;
  start &lt;br /&gt;
    java -Djava.util.logging.config.file=%CXF_HOME%\etc\logging.properties&lt;br /&gt;
         demo.hw.server.Server&lt;br /&gt;
    java -Djava.util.logging.config.file=%CXF_HOME%\etc\logging.properties&lt;br /&gt;
       demo.hw.client.Client .\wsdl\hello_world.wsdl&lt;br /&gt;
A new command windows opens for the server process.  After running the&lt;br /&gt;
client, terminate the server process by issuing Ctrl-C in its command window.&lt;br /&gt;
To remove the code generated from the WSDL file and the .class&lt;br /&gt;
files, either delete the build directory and its contents or run:&lt;br /&gt;
  ant clean&lt;br /&gt;
&lt;br /&gt;
Building and running the demo in a servlet container&lt;br /&gt;
----------------------------------------------------&lt;br /&gt;
From the samples/hello_world directory, the ant build script&lt;br /&gt;
can be used to create the war file that is deployed into the&lt;br /&gt;
servlet container.&lt;br /&gt;
Build the war file with the command:&lt;br /&gt;
  ant war&lt;br /&gt;
    &lt;br /&gt;
Preparing deploy to APACHE TOMCAT&lt;br /&gt;
* set CATALINA_HOME environment to your TOMCAT home directory&lt;br /&gt;
    &lt;br /&gt;
Deploy the application into APACHE TOMCAT with the commond:&lt;br /&gt;
[NOTE] This step will check if the cxf jars present in Tomcat, &lt;br /&gt;
       if not, it will automatically copy all the jars into CATALINA_HOME/shared/lib&lt;br /&gt;
  &lt;br /&gt;
  ant deploy -Dtomcat=true&lt;br /&gt;
The servlet container will extract the war and deploy the application.&lt;br /&gt;
&lt;br /&gt;
Using ant, run the client application with the command:&lt;br /&gt;
  ant client-servlet -Dbase.url=http://localhost:#&lt;br /&gt;
Where # is the TCP/IP port used by the servlet container,&lt;br /&gt;
e.g., 8080.&lt;br /&gt;
Or&lt;br /&gt;
  ant client-servlet -Dhost=localhost -Dport=8080&lt;br /&gt;
You can ignore the -Dhost and -Dport if your tomcat setup is same, i.e ant client-servlet&lt;br /&gt;
Using java, run the client application with the command:&lt;br /&gt;
  For UNIX:&lt;br /&gt;
    &lt;br /&gt;
    java -Djava.util.logging.config.file=$CXF_HOME/etc/logging.properties&lt;br /&gt;
         demo.hw.client.Client http://localhost:#/helloworld/services/hello_world?wsdl&lt;br /&gt;
  For Windows:&lt;br /&gt;
    java -Djava.util.logging.config.file=%CXF_HOME%\etc\logging.properties&lt;br /&gt;
       demo.hw.client.Client http://localhost:#/helloworld/services/hello_world?wsdl&lt;br /&gt;
Where # is the TCP/IP port used by the servlet container,&lt;br /&gt;
e.g., 8080.&lt;br /&gt;
Undeploy the application from the APACHE TOMCAT with the command:&lt;br /&gt;
   ant undeploy -Dtomcat=true&lt;br /&gt;
&lt;br /&gt;
Running demo with HTTP GET&lt;br /&gt;
----------------------------------------------------&lt;br /&gt;
APACHE CXF support HTTP GET to invoke the service, instead of running &lt;br /&gt;
   ant client&lt;br /&gt;
you can use &lt;br /&gt;
   ant client.get &lt;br /&gt;
to invoke the service with simple HttpURLConnection, or you can even&lt;br /&gt;
use your favoriate browser to get the results back.&lt;br /&gt;
/////////////////////////////////////////////////////////////////////////////&lt;br /&gt;
/**&lt;br /&gt;
 * Licensed to the Apache Software Foundation (ASF) under one&lt;br /&gt;
 * or more contributor license agreements. See the NOTICE file&lt;br /&gt;
 * distributed with this work for additional information&lt;br /&gt;
 * regarding copyright ownership. The ASF licenses this file&lt;br /&gt;
 * to you under the Apache License, Version 2.0 (the&lt;br /&gt;
 * &amp;quot;License&amp;quot;); you may not use this file except in compliance&lt;br /&gt;
 * with the License. You may obtain a copy of the License at&lt;br /&gt;
 *&lt;br /&gt;
 * http://www.apache.org/licenses/LICENSE-2.0&lt;br /&gt;
 *&lt;br /&gt;
 * Unless required by applicable law or agreed to in writing,&lt;br /&gt;
 * software distributed under the License is distributed on an&lt;br /&gt;
 * &amp;quot;AS IS&amp;quot; BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY&lt;br /&gt;
 * KIND, either express or implied. See the License for the&lt;br /&gt;
 * specific language governing permissions and limitations&lt;br /&gt;
 * under the License.&lt;br /&gt;
 */&lt;br /&gt;
package demo.hw.client;&lt;br /&gt;
import java.io.File;&lt;br /&gt;
import java.net.URL;&lt;br /&gt;
import javax.xml.namespace.QName;&lt;br /&gt;
import javax.xml.ws.WebServiceException;&lt;br /&gt;
import org.apache.hello_world_soap_http.Greeter;&lt;br /&gt;
import org.apache.hello_world_soap_http.PingMeFault;&lt;br /&gt;
import org.apache.hello_world_soap_http.SOAPService;&lt;br /&gt;
import org.apache.hello_world_soap_http.types.FaultDetail;&lt;br /&gt;
public final class Client {&lt;br /&gt;
    private static final QName SERVICE_NAME &lt;br /&gt;
        = new QName(&amp;quot;http://apache.org/hello_world_soap_http&amp;quot;, &amp;quot;SOAPService&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
    private Client() {&lt;br /&gt;
    } &lt;br /&gt;
    public static void main(String args[]) throws Exception {&lt;br /&gt;
        &lt;br /&gt;
        if (args.length == 0) { &lt;br /&gt;
            System.out.println(&amp;quot;please specify wsdl&amp;quot;);&lt;br /&gt;
            System.exit(1); &lt;br /&gt;
        }&lt;br /&gt;
        URL wsdlURL;&lt;br /&gt;
        File wsdlFile = new File(args[0]);&lt;br /&gt;
        if (wsdlFile.exists()) {&lt;br /&gt;
            wsdlURL = wsdlFile.toURL();&lt;br /&gt;
        } else {&lt;br /&gt;
            wsdlURL = new URL(args[0]);&lt;br /&gt;
        }&lt;br /&gt;
        &lt;br /&gt;
        System.out.println(wsdlURL);&lt;br /&gt;
        SOAPService ss = new SOAPService(wsdlURL, SERVICE_NAME);&lt;br /&gt;
        Greeter port = ss.getSoapPort();&lt;br /&gt;
        String resp; &lt;br /&gt;
        System.out.println(&amp;quot;Invoking sayHi...&amp;quot;);&lt;br /&gt;
        resp = port.sayHi();&lt;br /&gt;
        System.out.println(&amp;quot;Server responded with: &amp;quot; + resp);&lt;br /&gt;
        System.out.println();&lt;br /&gt;
        System.out.println(&amp;quot;Invoking greetMe...&amp;quot;);&lt;br /&gt;
        resp = port.greetMe(System.getProperty(&amp;quot;user.name&amp;quot;));&lt;br /&gt;
        System.out.println(&amp;quot;Server responded with: &amp;quot; + resp);&lt;br /&gt;
        System.out.println();&lt;br /&gt;
        System.out.println(&amp;quot;Invoking greetMe with invalid length string, expecting exception...&amp;quot;);&lt;br /&gt;
        try {&lt;br /&gt;
            resp = port.greetMe(&amp;quot;Invoking greetMe with invalid length string, expecting exception...&amp;quot;);&lt;br /&gt;
        } catch (WebServiceException ex) {&lt;br /&gt;
            System.out.println(&amp;quot;Caught expected WebServiceException:&amp;quot;);&lt;br /&gt;
            System.out.println(&amp;quot;    &amp;quot; + ex.getMessage());&lt;br /&gt;
        }&lt;br /&gt;
        System.out.println();&lt;br /&gt;
        System.out.println(&amp;quot;Invoking greetMeOneWay...&amp;quot;);&lt;br /&gt;
        port.greetMeOneWay(System.getProperty(&amp;quot;user.name&amp;quot;));&lt;br /&gt;
        System.out.println(&amp;quot;No response from server as method is OneWay&amp;quot;);&lt;br /&gt;
        System.out.println();&lt;br /&gt;
        try {&lt;br /&gt;
            System.out.println(&amp;quot;Invoking pingMe, expecting exception...&amp;quot;);&lt;br /&gt;
            port.pingMe();&lt;br /&gt;
        } catch (PingMeFault ex) {&lt;br /&gt;
            System.out.println(&amp;quot;Expected exception: PingMeFault has occurred: &amp;quot; + ex.getMessage());&lt;br /&gt;
            FaultDetail detail = ex.getFaultInfo();&lt;br /&gt;
            System.out.println(&amp;quot;FaultDetail major:&amp;quot; + detail.getMajor());&lt;br /&gt;
            System.out.println(&amp;quot;FaultDetail minor:&amp;quot; + detail.getMinor());            &lt;br /&gt;
        }          &lt;br /&gt;
        System.exit(0); &lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
/////////////////////////////////////////////////////////////////////////////&lt;br /&gt;
/**&lt;br /&gt;
 * Licensed to the Apache Software Foundation (ASF) under one&lt;br /&gt;
 * or more contributor license agreements. See the NOTICE file&lt;br /&gt;
 * distributed with this work for additional information&lt;br /&gt;
 * regarding copyright ownership. The ASF licenses this file&lt;br /&gt;
 * to you under the Apache License, Version 2.0 (the&lt;br /&gt;
 * &amp;quot;License&amp;quot;); you may not use this file except in compliance&lt;br /&gt;
 * with the License. You may obtain a copy of the License at&lt;br /&gt;
 *&lt;br /&gt;
 * http://www.apache.org/licenses/LICENSE-2.0&lt;br /&gt;
 *&lt;br /&gt;
 * Unless required by applicable law or agreed to in writing,&lt;br /&gt;
 * software distributed under the License is distributed on an&lt;br /&gt;
 * &amp;quot;AS IS&amp;quot; BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY&lt;br /&gt;
 * KIND, either express or implied. See the License for the&lt;br /&gt;
 * specific language governing permissions and limitations&lt;br /&gt;
 * under the License.&lt;br /&gt;
 */&lt;br /&gt;
package demo.hw.client;&lt;br /&gt;
import java.io.ByteArrayOutputStream;&lt;br /&gt;
import java.io.InputStream;&lt;br /&gt;
import java.net.HttpURLConnection;&lt;br /&gt;
import java.net.URL;&lt;br /&gt;
import java.util.Properties;&lt;br /&gt;
import javax.xml.transform.OutputKeys;&lt;br /&gt;
import javax.xml.transform.Source;&lt;br /&gt;
import javax.xml.transform.Transformer;&lt;br /&gt;
import javax.xml.transform.TransformerFactory;&lt;br /&gt;
import javax.xml.transform.stream.StreamResult;&lt;br /&gt;
import javax.xml.transform.stream.StreamSource;&lt;br /&gt;
public final class Get {&lt;br /&gt;
    private Get() {&lt;br /&gt;
    } &lt;br /&gt;
    public static void main(String args[]) throws Exception {&lt;br /&gt;
        // Sent HTTP GET request to invoke sayHi&lt;br /&gt;
        String target = &amp;quot;http://localhost:9000/SoapContext/SoapPort/sayHi&amp;quot;;&lt;br /&gt;
        URL url = new URL(target);&lt;br /&gt;
        HttpURLConnection httpConnection = (HttpURLConnection) url.openConnection();&lt;br /&gt;
        httpConnection.connect();&lt;br /&gt;
        System.out.println(&amp;quot;Invoking server through HTTP GET to invoke sayHi&amp;quot;);&lt;br /&gt;
        InputStream in = httpConnection.getInputStream();&lt;br /&gt;
        StreamSource source = new StreamSource(in);&lt;br /&gt;
        printSource(source);&lt;br /&gt;
        // Sent HTTP GET request to invoke greetMe FAULT&lt;br /&gt;
        target = &amp;quot;http://localhost:9000/SoapContext/SoapPort/greetMe/me/CXF&amp;quot;;&lt;br /&gt;
        url = new URL(target);&lt;br /&gt;
        httpConnection = (HttpURLConnection) url.openConnection();&lt;br /&gt;
        httpConnection.connect();&lt;br /&gt;
        System.out.println(&amp;quot;Invoking server through HTTP GET to invoke greetMe&amp;quot;);&lt;br /&gt;
        try {&lt;br /&gt;
            in = httpConnection.getInputStream();&lt;br /&gt;
            source = new StreamSource(in);&lt;br /&gt;
            printSource(source);&lt;br /&gt;
        } catch (Exception e) {&lt;br /&gt;
            System.err.println(&amp;quot;GreetMe Fault: &amp;quot; + e.getMessage());&lt;br /&gt;
        }&lt;br /&gt;
        InputStream err = httpConnection.getErrorStream();&lt;br /&gt;
        source = new StreamSource(err);&lt;br /&gt;
        printSource(source);&lt;br /&gt;
        // Sent HTTP GET request to invoke greetMe&lt;br /&gt;
        target = &amp;quot;http://localhost:9000/SoapContext/SoapPort/greetMe/requestType/CXF&amp;quot;;&lt;br /&gt;
        url = new URL(target);&lt;br /&gt;
        httpConnection = (HttpURLConnection) url.openConnection();&lt;br /&gt;
        httpConnection.connect();&lt;br /&gt;
        System.out.println(&amp;quot;Invoking server through HTTP GET to invoke greetMe&amp;quot;);&lt;br /&gt;
        in = httpConnection.getInputStream();&lt;br /&gt;
        source = new StreamSource(in);&lt;br /&gt;
        printSource(source);&lt;br /&gt;
        // Sent HTTP GET request to invoke pingMe&lt;br /&gt;
        target = &amp;quot;http://localhost:9000/SoapContext/SoapPort/pingMe&amp;quot;;&lt;br /&gt;
        url = new URL(target);&lt;br /&gt;
        httpConnection = (HttpURLConnection) url.openConnection();&lt;br /&gt;
        httpConnection.connect();&lt;br /&gt;
        System.out.println(&amp;quot;Invoking server through HTTP GET to invoke pingMe&amp;quot;);&lt;br /&gt;
        try {&lt;br /&gt;
            in = httpConnection.getInputStream();&lt;br /&gt;
        } catch (Exception e) {&lt;br /&gt;
            System.out.println(&amp;quot;PingMe fault raised&amp;quot;);&lt;br /&gt;
        }&lt;br /&gt;
        err = httpConnection.getErrorStream();&lt;br /&gt;
        source = new StreamSource(err);&lt;br /&gt;
        printSource(source);&lt;br /&gt;
    }&lt;br /&gt;
    private static void printSource(Source source) {&lt;br /&gt;
        try {&lt;br /&gt;
            ByteArrayOutputStream bos = new ByteArrayOutputStream();&lt;br /&gt;
            StreamResult sr = new StreamResult(bos);&lt;br /&gt;
            Transformer trans = TransformerFactory.newInstance().newTransformer();&lt;br /&gt;
            Properties oprops = new Properties();&lt;br /&gt;
            oprops.put(OutputKeys.OMIT_XML_DECLARATION, &amp;quot;yes&amp;quot;);&lt;br /&gt;
            trans.setOutputProperties(oprops);&lt;br /&gt;
            trans.transform(source, sr);&lt;br /&gt;
            System.out.println();&lt;br /&gt;
            System.out.println(&amp;quot;**** Response ******&amp;quot;);&lt;br /&gt;
            System.out.println();&lt;br /&gt;
            System.out.println(bos.toString());&lt;br /&gt;
            bos.close();&lt;br /&gt;
            System.out.println();&lt;br /&gt;
        } catch (Exception e) {&lt;br /&gt;
            e.printStackTrace();&lt;br /&gt;
        }&lt;br /&gt;
    }    &lt;br /&gt;
}&lt;br /&gt;
/////////////////////////////////////////////////////////////////////////////&lt;br /&gt;
/**&lt;br /&gt;
 * Licensed to the Apache Software Foundation (ASF) under one&lt;br /&gt;
 * or more contributor license agreements. See the NOTICE file&lt;br /&gt;
 * distributed with this work for additional information&lt;br /&gt;
 * regarding copyright ownership. The ASF licenses this file&lt;br /&gt;
 * to you under the Apache License, Version 2.0 (the&lt;br /&gt;
 * &amp;quot;License&amp;quot;); you may not use this file except in compliance&lt;br /&gt;
 * with the License. You may obtain a copy of the License at&lt;br /&gt;
 *&lt;br /&gt;
 * http://www.apache.org/licenses/LICENSE-2.0&lt;br /&gt;
 *&lt;br /&gt;
 * Unless required by applicable law or agreed to in writing,&lt;br /&gt;
 * software distributed under the License is distributed on an&lt;br /&gt;
 * &amp;quot;AS IS&amp;quot; BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY&lt;br /&gt;
 * KIND, either express or implied. See the License for the&lt;br /&gt;
 * specific language governing permissions and limitations&lt;br /&gt;
 * under the License.&lt;br /&gt;
 */&lt;br /&gt;
package demo.hw.server;&lt;br /&gt;
import java.util.logging.Logger;&lt;br /&gt;
import org.apache.hello_world_soap_http.Greeter;&lt;br /&gt;
import org.apache.hello_world_soap_http.PingMeFault;&lt;br /&gt;
import org.apache.hello_world_soap_http.types.FaultDetail;&lt;br /&gt;
@javax.jws.WebService(portName = &amp;quot;SoapPort&amp;quot;, serviceName = &amp;quot;SOAPService&amp;quot;, &lt;br /&gt;
                      targetNamespace = &amp;quot;http://apache.org/hello_world_soap_http&amp;quot;, &lt;br /&gt;
                      endpointInterface = &amp;quot;org.apache.hello_world_soap_http.Greeter&amp;quot;)&lt;br /&gt;
                  &lt;br /&gt;
public class GreeterImpl implements Greeter {&lt;br /&gt;
    private static final Logger LOG = &lt;br /&gt;
        Logger.getLogger(GreeterImpl.class.getPackage().getName());&lt;br /&gt;
    &lt;br /&gt;
    /* (non-Javadoc)&lt;br /&gt;
     * @see org.apache.hello_world_soap_http.Greeter#greetMe(java.lang.String)&lt;br /&gt;
     */&lt;br /&gt;
    public String greetMe(String me) {&lt;br /&gt;
        LOG.info(&amp;quot;Executing operation greetMe&amp;quot;);&lt;br /&gt;
        System.out.println(&amp;quot;Executing operation greetMe&amp;quot;);&lt;br /&gt;
        System.out.println(&amp;quot;Message received: &amp;quot; + me + &amp;quot;\n&amp;quot;);&lt;br /&gt;
        return &amp;quot;Hello &amp;quot; + me;&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    /* (non-Javadoc)&lt;br /&gt;
     * @see org.apache.hello_world_soap_http.Greeter#greetMeOneWay(java.lang.String)&lt;br /&gt;
     */&lt;br /&gt;
    public void greetMeOneWay(String me) {&lt;br /&gt;
        LOG.info(&amp;quot;Executing operation greetMeOneWay&amp;quot;);&lt;br /&gt;
        System.out.println(&amp;quot;Executing operation greetMeOneWay\n&amp;quot;);&lt;br /&gt;
        System.out.println(&amp;quot;Hello there &amp;quot; + me);&lt;br /&gt;
    }&lt;br /&gt;
    /* (non-Javadoc)&lt;br /&gt;
     * @see org.apache.hello_world_soap_http.Greeter#sayHi()&lt;br /&gt;
     */&lt;br /&gt;
    public String sayHi() {&lt;br /&gt;
        LOG.info(&amp;quot;Executing operation sayHi&amp;quot;);&lt;br /&gt;
        System.out.println(&amp;quot;Executing operation sayHi\n&amp;quot;);&lt;br /&gt;
        return &amp;quot;Bonjour&amp;quot;;&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    public void pingMe() throws PingMeFault {&lt;br /&gt;
        FaultDetail faultDetail = new FaultDetail();&lt;br /&gt;
        faultDetail.setMajor((short)2);&lt;br /&gt;
        faultDetail.setMinor((short)1);&lt;br /&gt;
        LOG.info(&amp;quot;Executing operation pingMe, throwing PingMeFault exception&amp;quot;);&lt;br /&gt;
        System.out.println(&amp;quot;Executing operation pingMe, throwing PingMeFault exception\n&amp;quot;);&lt;br /&gt;
        throw new PingMeFault(&amp;quot;PingMeFault raised by server&amp;quot;, faultDetail);&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
}&lt;br /&gt;
/////////////////////////////////////////////////////////////////////////////&lt;br /&gt;
/**&lt;br /&gt;
 * Licensed to the Apache Software Foundation (ASF) under one&lt;br /&gt;
 * or more contributor license agreements. See the NOTICE file&lt;br /&gt;
 * distributed with this work for additional information&lt;br /&gt;
 * regarding copyright ownership. The ASF licenses this file&lt;br /&gt;
 * to you under the Apache License, Version 2.0 (the&lt;br /&gt;
 * &amp;quot;License&amp;quot;); you may not use this file except in compliance&lt;br /&gt;
 * with the License. You may obtain a copy of the License at&lt;br /&gt;
 *&lt;br /&gt;
 * http://www.apache.org/licenses/LICENSE-2.0&lt;br /&gt;
 *&lt;br /&gt;
 * Unless required by applicable law or agreed to in writing,&lt;br /&gt;
 * software distributed under the License is distributed on an&lt;br /&gt;
 * &amp;quot;AS IS&amp;quot; BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY&lt;br /&gt;
 * KIND, either express or implied. See the License for the&lt;br /&gt;
 * specific language governing permissions and limitations&lt;br /&gt;
 * under the License.&lt;br /&gt;
 */&lt;br /&gt;
package demo.hw.server;&lt;br /&gt;
import javax.xml.ws.Endpoint;&lt;br /&gt;
public class Server {&lt;br /&gt;
    protected Server() throws Exception {&lt;br /&gt;
        System.out.println(&amp;quot;Starting Server&amp;quot;);&lt;br /&gt;
        Object implementor = new GreeterImpl();&lt;br /&gt;
        String address = &amp;quot;http://localhost:9000/SoapContext/SoapPort&amp;quot;;&lt;br /&gt;
        Endpoint.publish(address, implementor);&lt;br /&gt;
    }&lt;br /&gt;
    public static void main(String args[]) throws Exception {&lt;br /&gt;
        new Server();&lt;br /&gt;
        System.out.println(&amp;quot;Server ready...&amp;quot;);&lt;br /&gt;
        Thread.sleep(5 * 60 * 1000);&lt;br /&gt;
        System.out.println(&amp;quot;Server exiting&amp;quot;);&lt;br /&gt;
        System.exit(0);&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
/////////////////////////////////////////////////////////////////////////////&lt;br /&gt;
&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot;?&amp;gt;&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
  Licensed to the Apache Software Foundation (ASF) under one&lt;br /&gt;
  or more contributor license agreements. See the NOTICE file&lt;br /&gt;
  distributed with this work for additional information&lt;br /&gt;
  regarding copyright ownership. The ASF licenses this file&lt;br /&gt;
  to you under the Apache License, Version 2.0 (the&lt;br /&gt;
  &amp;quot;License&amp;quot;); you may not use this file except in compliance&lt;br /&gt;
  with the License. You may obtain a copy of the License at&lt;br /&gt;
 &lt;br /&gt;
  http://www.apache.org/licenses/LICENSE-2.0&lt;br /&gt;
 &lt;br /&gt;
  Unless required by applicable law or agreed to in writing,&lt;br /&gt;
  software distributed under the License is distributed on an&lt;br /&gt;
  &amp;quot;AS IS&amp;quot; BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY&lt;br /&gt;
  KIND, either express or implied. See the License for the&lt;br /&gt;
  specific language governing permissions and limitations&lt;br /&gt;
  under the License.&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&amp;lt;wsdl:definitions name=&amp;quot;HelloWorld&amp;quot; targetNamespace=&amp;quot;http://apache.org/hello_world_soap_http&amp;quot; &lt;br /&gt;
    xmlns=&amp;quot;http://schemas.xmlsoap.org/wsdl/&amp;quot; &lt;br /&gt;
    xmlns:soap=&amp;quot;http://schemas.xmlsoap.org/wsdl/soap/&amp;quot; &lt;br /&gt;
    xmlns:tns=&amp;quot;http://apache.org/hello_world_soap_http&amp;quot;&lt;br /&gt;
    xmlns:x1=&amp;quot;http://apache.org/hello_world_soap_http/types&amp;quot;&lt;br /&gt;
    xmlns:wsdl=&amp;quot;http://schemas.xmlsoap.org/wsdl/&amp;quot; &lt;br /&gt;
    xmlns:xsd=&amp;quot;http://www.w3.org/2001/XMLSchema&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;wsdl:types&amp;gt;&lt;br /&gt;
        &amp;lt;schema targetNamespace=&amp;quot;http://apache.org/hello_world_soap_http/types&amp;quot; &lt;br /&gt;
            xmlns=&amp;quot;http://www.w3.org/2001/XMLSchema&amp;quot;&lt;br /&gt;
      xmlns:tns=&amp;quot;http://apache.org/hello_world_soap_http/types&amp;quot;&lt;br /&gt;
            elementFormDefault=&amp;quot;qualified&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;simpleType name=&amp;quot;MyStringType&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;restriction base=&amp;quot;string&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;maxLength value=&amp;quot;30&amp;quot; /&amp;gt;&lt;br /&gt;
    &amp;lt;/restriction&amp;gt;&lt;br /&gt;
      &amp;lt;/simpleType&amp;gt;&lt;br /&gt;
            &amp;lt;element name=&amp;quot;sayHi&amp;quot;&amp;gt;&lt;br /&gt;
                &amp;lt;complexType/&amp;gt;&lt;br /&gt;
            &amp;lt;/element&amp;gt;&lt;br /&gt;
            &amp;lt;element name=&amp;quot;sayHiResponse&amp;quot;&amp;gt;&lt;br /&gt;
                &amp;lt;complexType&amp;gt;&lt;br /&gt;
                    &amp;lt;sequence&amp;gt;&lt;br /&gt;
                        &amp;lt;element name=&amp;quot;responseType&amp;quot; type=&amp;quot;string&amp;quot;/&amp;gt;&lt;br /&gt;
                    &amp;lt;/sequence&amp;gt;&lt;br /&gt;
                &amp;lt;/complexType&amp;gt;&lt;br /&gt;
            &amp;lt;/element&amp;gt;&lt;br /&gt;
            &amp;lt;element name=&amp;quot;greetMe&amp;quot;&amp;gt;&lt;br /&gt;
                &amp;lt;complexType&amp;gt;&lt;br /&gt;
                    &amp;lt;sequence&amp;gt;&lt;br /&gt;
                        &amp;lt;element name=&amp;quot;requestType&amp;quot; type=&amp;quot;tns:MyStringType&amp;quot;/&amp;gt;&lt;br /&gt;
                    &amp;lt;/sequence&amp;gt;&lt;br /&gt;
                &amp;lt;/complexType&amp;gt;&lt;br /&gt;
            &amp;lt;/element&amp;gt;&lt;br /&gt;
            &amp;lt;element name=&amp;quot;greetMeResponse&amp;quot;&amp;gt;&lt;br /&gt;
                &amp;lt;complexType&amp;gt;&lt;br /&gt;
                    &amp;lt;sequence&amp;gt;&lt;br /&gt;
                        &amp;lt;element name=&amp;quot;responseType&amp;quot; type=&amp;quot;string&amp;quot;/&amp;gt;&lt;br /&gt;
                    &amp;lt;/sequence&amp;gt;&lt;br /&gt;
                &amp;lt;/complexType&amp;gt;&lt;br /&gt;
            &amp;lt;/element&amp;gt;&lt;br /&gt;
            &amp;lt;element name=&amp;quot;greetMeOneWay&amp;quot;&amp;gt;&lt;br /&gt;
                &amp;lt;complexType&amp;gt;&lt;br /&gt;
                    &amp;lt;sequence&amp;gt;&lt;br /&gt;
                        &amp;lt;element name=&amp;quot;requestType&amp;quot; type=&amp;quot;string&amp;quot;/&amp;gt;&lt;br /&gt;
                    &amp;lt;/sequence&amp;gt;&lt;br /&gt;
                &amp;lt;/complexType&amp;gt;&lt;br /&gt;
            &amp;lt;/element&amp;gt;&lt;br /&gt;
            &amp;lt;element name=&amp;quot;pingMe&amp;quot;&amp;gt;&lt;br /&gt;
                &amp;lt;complexType/&amp;gt;&lt;br /&gt;
            &amp;lt;/element&amp;gt;&lt;br /&gt;
            &amp;lt;element name=&amp;quot;pingMeResponse&amp;quot;&amp;gt;&lt;br /&gt;
                &amp;lt;complexType/&amp;gt;&lt;br /&gt;
            &amp;lt;/element&amp;gt;&lt;br /&gt;
            &amp;lt;element name=&amp;quot;faultDetail&amp;quot;&amp;gt;&lt;br /&gt;
                &amp;lt;complexType&amp;gt;&lt;br /&gt;
                    &amp;lt;sequence&amp;gt;&lt;br /&gt;
                        &amp;lt;element name=&amp;quot;minor&amp;quot; type=&amp;quot;short&amp;quot;/&amp;gt;&lt;br /&gt;
                        &amp;lt;element name=&amp;quot;major&amp;quot; type=&amp;quot;short&amp;quot;/&amp;gt;&lt;br /&gt;
                    &amp;lt;/sequence&amp;gt;&lt;br /&gt;
                &amp;lt;/complexType&amp;gt;&lt;br /&gt;
            &amp;lt;/element&amp;gt;&lt;br /&gt;
        &amp;lt;/schema&amp;gt;&lt;br /&gt;
    &amp;lt;/wsdl:types&amp;gt;&lt;br /&gt;
    &amp;lt;wsdl:message name=&amp;quot;sayHiRequest&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;wsdl:part element=&amp;quot;x1:sayHi&amp;quot; name=&amp;quot;in&amp;quot;/&amp;gt;&lt;br /&gt;
    &amp;lt;/wsdl:message&amp;gt;&lt;br /&gt;
    &amp;lt;wsdl:message name=&amp;quot;sayHiResponse&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;wsdl:part element=&amp;quot;x1:sayHiResponse&amp;quot; name=&amp;quot;out&amp;quot;/&amp;gt;&lt;br /&gt;
    &amp;lt;/wsdl:message&amp;gt;&lt;br /&gt;
    &amp;lt;wsdl:message name=&amp;quot;greetMeRequest&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;wsdl:part element=&amp;quot;x1:greetMe&amp;quot; name=&amp;quot;in&amp;quot;/&amp;gt;&lt;br /&gt;
    &amp;lt;/wsdl:message&amp;gt;&lt;br /&gt;
    &amp;lt;wsdl:message name=&amp;quot;greetMeResponse&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;wsdl:part element=&amp;quot;x1:greetMeResponse&amp;quot; name=&amp;quot;out&amp;quot;/&amp;gt;&lt;br /&gt;
    &amp;lt;/wsdl:message&amp;gt;&lt;br /&gt;
    &amp;lt;wsdl:message name=&amp;quot;greetMeOneWayRequest&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;wsdl:part element=&amp;quot;x1:greetMeOneWay&amp;quot; name=&amp;quot;in&amp;quot;/&amp;gt;&lt;br /&gt;
    &amp;lt;/wsdl:message&amp;gt;&lt;br /&gt;
    &amp;lt;wsdl:message name=&amp;quot;pingMeRequest&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;wsdl:part name=&amp;quot;in&amp;quot; element=&amp;quot;x1:pingMe&amp;quot;/&amp;gt;&lt;br /&gt;
    &amp;lt;/wsdl:message&amp;gt;&lt;br /&gt;
    &amp;lt;wsdl:message name=&amp;quot;pingMeResponse&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;wsdl:part name=&amp;quot;out&amp;quot; element=&amp;quot;x1:pingMeResponse&amp;quot;/&amp;gt;&lt;br /&gt;
    &amp;lt;/wsdl:message&amp;gt;    &lt;br /&gt;
    &amp;lt;wsdl:message name=&amp;quot;pingMeFault&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;wsdl:part name=&amp;quot;faultDetail&amp;quot; element=&amp;quot;x1:faultDetail&amp;quot;/&amp;gt;&lt;br /&gt;
    &amp;lt;/wsdl:message&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
    &amp;lt;wsdl:portType name=&amp;quot;Greeter&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;wsdl:operation name=&amp;quot;sayHi&amp;quot;&amp;gt;&lt;br /&gt;
            &amp;lt;wsdl:input message=&amp;quot;tns:sayHiRequest&amp;quot; name=&amp;quot;sayHiRequest&amp;quot;/&amp;gt;&lt;br /&gt;
            &amp;lt;wsdl:output message=&amp;quot;tns:sayHiResponse&amp;quot; name=&amp;quot;sayHiResponse&amp;quot;/&amp;gt;&lt;br /&gt;
        &amp;lt;/wsdl:operation&amp;gt;&lt;br /&gt;
        &lt;br /&gt;
        &amp;lt;wsdl:operation name=&amp;quot;greetMe&amp;quot;&amp;gt;&lt;br /&gt;
            &amp;lt;wsdl:input message=&amp;quot;tns:greetMeRequest&amp;quot; name=&amp;quot;greetMeRequest&amp;quot;/&amp;gt;&lt;br /&gt;
            &amp;lt;wsdl:output message=&amp;quot;tns:greetMeResponse&amp;quot; name=&amp;quot;greetMeResponse&amp;quot;/&amp;gt;&lt;br /&gt;
        &amp;lt;/wsdl:operation&amp;gt;&lt;br /&gt;
        &lt;br /&gt;
        &amp;lt;wsdl:operation name=&amp;quot;greetMeOneWay&amp;quot;&amp;gt;&lt;br /&gt;
            &amp;lt;wsdl:input message=&amp;quot;tns:greetMeOneWayRequest&amp;quot; name=&amp;quot;greetMeOneWayRequest&amp;quot;/&amp;gt;&lt;br /&gt;
        &amp;lt;/wsdl:operation&amp;gt;&lt;br /&gt;
        &amp;lt;wsdl:operation name=&amp;quot;pingMe&amp;quot;&amp;gt;&lt;br /&gt;
            &amp;lt;wsdl:input name=&amp;quot;pingMeRequest&amp;quot; message=&amp;quot;tns:pingMeRequest&amp;quot;/&amp;gt;&lt;br /&gt;
            &amp;lt;wsdl:output name=&amp;quot;pingMeResponse&amp;quot; message=&amp;quot;tns:pingMeResponse&amp;quot;/&amp;gt;&lt;br /&gt;
            &amp;lt;wsdl:fault name=&amp;quot;pingMeFault&amp;quot; message=&amp;quot;tns:pingMeFault&amp;quot;/&amp;gt;&lt;br /&gt;
        &amp;lt;/wsdl:operation&amp;gt; &lt;br /&gt;
    &amp;lt;/wsdl:portType&amp;gt;&lt;br /&gt;
    &amp;lt;wsdl:binding name=&amp;quot;Greeter_SOAPBinding&amp;quot; type=&amp;quot;tns:Greeter&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;soap:binding style=&amp;quot;document&amp;quot; transport=&amp;quot;http://schemas.xmlsoap.org/soap/http&amp;quot;/&amp;gt;&lt;br /&gt;
        &lt;br /&gt;
        &amp;lt;wsdl:operation name=&amp;quot;sayHi&amp;quot;&amp;gt;&lt;br /&gt;
            &amp;lt;soap:operation soapAction=&amp;quot;&amp;quot; style=&amp;quot;document&amp;quot;/&amp;gt;&lt;br /&gt;
            &amp;lt;wsdl:input name=&amp;quot;sayHiRequest&amp;quot;&amp;gt;&lt;br /&gt;
                &amp;lt;soap:body use=&amp;quot;literal&amp;quot;/&amp;gt;&lt;br /&gt;
            &amp;lt;/wsdl:input&amp;gt;&lt;br /&gt;
            &amp;lt;wsdl:output name=&amp;quot;sayHiResponse&amp;quot;&amp;gt;&lt;br /&gt;
                &amp;lt;soap:body use=&amp;quot;literal&amp;quot;/&amp;gt;&lt;br /&gt;
            &amp;lt;/wsdl:output&amp;gt;&lt;br /&gt;
        &amp;lt;/wsdl:operation&amp;gt;&lt;br /&gt;
        &lt;br /&gt;
        &amp;lt;wsdl:operation name=&amp;quot;greetMe&amp;quot;&amp;gt;&lt;br /&gt;
            &amp;lt;soap:operation soapAction=&amp;quot;&amp;quot; style=&amp;quot;document&amp;quot;/&amp;gt;&lt;br /&gt;
            &amp;lt;wsdl:input name=&amp;quot;greetMeRequest&amp;quot;&amp;gt;&lt;br /&gt;
                &amp;lt;soap:body use=&amp;quot;literal&amp;quot;/&amp;gt;&lt;br /&gt;
            &amp;lt;/wsdl:input&amp;gt;&lt;br /&gt;
            &amp;lt;wsdl:output name=&amp;quot;greetMeResponse&amp;quot;&amp;gt;&lt;br /&gt;
                &amp;lt;soap:body use=&amp;quot;literal&amp;quot;/&amp;gt;&lt;br /&gt;
            &amp;lt;/wsdl:output&amp;gt;&lt;br /&gt;
        &amp;lt;/wsdl:operation&amp;gt;&lt;br /&gt;
        &lt;br /&gt;
        &amp;lt;wsdl:operation name=&amp;quot;greetMeOneWay&amp;quot;&amp;gt;&lt;br /&gt;
            &amp;lt;soap:operation soapAction=&amp;quot;&amp;quot; style=&amp;quot;document&amp;quot;/&amp;gt;&lt;br /&gt;
            &amp;lt;wsdl:input name=&amp;quot;greetMeOneWayRequest&amp;quot;&amp;gt;&lt;br /&gt;
                &amp;lt;soap:body use=&amp;quot;literal&amp;quot;/&amp;gt;&lt;br /&gt;
            &amp;lt;/wsdl:input&amp;gt;&lt;br /&gt;
        &amp;lt;/wsdl:operation&amp;gt;&lt;br /&gt;
        &amp;lt;wsdl:operation name=&amp;quot;pingMe&amp;quot;&amp;gt;&lt;br /&gt;
            &amp;lt;soap:operation style=&amp;quot;document&amp;quot;/&amp;gt;&lt;br /&gt;
            &amp;lt;wsdl:input&amp;gt;&lt;br /&gt;
                &amp;lt;soap:body use=&amp;quot;literal&amp;quot;/&amp;gt;&lt;br /&gt;
            &amp;lt;/wsdl:input&amp;gt;&lt;br /&gt;
            &amp;lt;wsdl:output&amp;gt;&lt;br /&gt;
                &amp;lt;soap:body use=&amp;quot;literal&amp;quot;/&amp;gt;&lt;br /&gt;
            &amp;lt;/wsdl:output&amp;gt;&lt;br /&gt;
            &amp;lt;wsdl:fault name=&amp;quot;pingMeFault&amp;quot;&amp;gt;&lt;br /&gt;
                &amp;lt;soap:fault name=&amp;quot;pingMeFault&amp;quot; use=&amp;quot;literal&amp;quot;/&amp;gt;&lt;br /&gt;
            &amp;lt;/wsdl:fault&amp;gt;&lt;br /&gt;
        &amp;lt;/wsdl:operation&amp;gt;&lt;br /&gt;
        &lt;br /&gt;
    &amp;lt;/wsdl:binding&amp;gt;&lt;br /&gt;
    &amp;lt;wsdl:service name=&amp;quot;SOAPService&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;wsdl:port binding=&amp;quot;tns:Greeter_SOAPBinding&amp;quot; name=&amp;quot;SoapPort&amp;quot;&amp;gt;&lt;br /&gt;
            &amp;lt;soap:address location=&amp;quot;http://localhost:9000/SoapContext/SoapPort&amp;quot;/&amp;gt;&lt;br /&gt;
        &amp;lt;/wsdl:port&amp;gt;&lt;br /&gt;
    &amp;lt;/wsdl:service&amp;gt;&lt;br /&gt;
&amp;lt;/wsdl:definitions&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
        &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== This demo illustrates the use of the JAX-WS asynchronous invocation model ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
/**&lt;br /&gt;
 * Licensed to the Apache Software Foundation (ASF) under one&lt;br /&gt;
 * or more contributor license agreements. See the NOTICE file&lt;br /&gt;
 * distributed with this work for additional information&lt;br /&gt;
 * regarding copyright ownership. The ASF licenses this file&lt;br /&gt;
 * to you under the Apache License, Version 2.0 (the&lt;br /&gt;
 * &amp;quot;License&amp;quot;); you may not use this file except in compliance&lt;br /&gt;
 * with the License. You may obtain a copy of the License at&lt;br /&gt;
 *&lt;br /&gt;
 * http://www.apache.org/licenses/LICENSE-2.0&lt;br /&gt;
 *&lt;br /&gt;
 * Unless required by applicable law or agreed to in writing,&lt;br /&gt;
 * software distributed under the License is distributed on an&lt;br /&gt;
 * &amp;quot;AS IS&amp;quot; BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY&lt;br /&gt;
 * KIND, either express or implied. See the License for the&lt;br /&gt;
 * specific language governing permissions and limitations&lt;br /&gt;
 * under the License.&lt;br /&gt;
 */&lt;br /&gt;
&lt;br /&gt;
Hello World Asynchronous Demo using Document/Literal Style&lt;br /&gt;
==========================================================&lt;br /&gt;
This demo illustrates the use of the JAX-WS asynchronous &lt;br /&gt;
invocation model. Please refer to the JAX-WS 2.0 specification&lt;br /&gt;
(http://jcp.org/aboutJava/communityProcess/pfd/jsr224/index.html)&lt;br /&gt;
for background.&lt;br /&gt;
The asynchronous model allows the client thread to continue after &lt;br /&gt;
making a two-way invocation without being blocked while awaiting a &lt;br /&gt;
response from the server. Once the response is available, it is&lt;br /&gt;
delivered to the client application asynchronously using one&lt;br /&gt;
of two alternative approaches:&lt;br /&gt;
- Callback: the client application implements the &lt;br /&gt;
javax.xml.ws.AsyncHandler interface to accept notification&lt;br /&gt;
of the response availability&lt;br /&gt;
- Polling: the client application periodically polls a&lt;br /&gt;
javax.xml.ws.Response instance to check if the response&lt;br /&gt;
is available&lt;br /&gt;
This demo illustrates both approaches.&lt;br /&gt;
Additional methods are generated on the Service Endpoint&lt;br /&gt;
Interface (SEI) to provide this asynchrony, named by &lt;br /&gt;
convention with the suffix &amp;quot;Async&amp;quot;.&lt;br /&gt;
As many applications will not require this functionality,&lt;br /&gt;
the asynchronous variants of the SEI methods are omitted&lt;br /&gt;
by default to avoid polluting the SEI with unnecessary &lt;br /&gt;
baggage. In order to enable generation of these methods,&lt;br /&gt;
a bindings file (wsdl/async_bindings.xml) is passed&lt;br /&gt;
to the wsdl2java generator. &lt;br /&gt;
Please review the README in the samples directory before&lt;br /&gt;
continuing.&lt;br /&gt;
&lt;br /&gt;
Prerequisite&lt;br /&gt;
------------&lt;br /&gt;
If your environment already includes cxf-manifest-incubator.jar on the&lt;br /&gt;
CLASSPATH, and the JDK and ant bin directories on the PATH&lt;br /&gt;
it is not necessary to set the environment as described in&lt;br /&gt;
the samples directory README.  If your environment is not&lt;br /&gt;
properly configured, or if you are planning on using wsdl2java,&lt;br /&gt;
javac, and java to build and run the demos, you must set the&lt;br /&gt;
environment.&lt;br /&gt;
&lt;br /&gt;
Building and running the demo using ant&lt;br /&gt;
---------------------------------------&lt;br /&gt;
From the samples/hello_world_async directory, the ant build script&lt;br /&gt;
can be used to build and run the demo.&lt;br /&gt;
Using either UNIX or Windows:&lt;br /&gt;
  ant build&lt;br /&gt;
  ant server &lt;br /&gt;
  ant client&lt;br /&gt;
    &lt;br /&gt;
To remove the code generated from the WSDL file and the .class&lt;br /&gt;
files, run:&lt;br /&gt;
  ant clean&lt;br /&gt;
&lt;br /&gt;
Building the demo using wsdl2java and javac&lt;br /&gt;
-------------------------------------------&lt;br /&gt;
From the samples/hello_world_async directory, run the following wsdl2java &lt;br /&gt;
command to generate classes required in the async case.&lt;br /&gt;
For UNIX:&lt;br /&gt;
  mkdir -p build/classes&lt;br /&gt;
  wsdl2java -d build/classes -b ./wsdl/async_binding.xml -compile ./wsdl/hello_world_async.wsdl&lt;br /&gt;
For Windows:&lt;br /&gt;
  mkdir build\classes&lt;br /&gt;
    Must use back slashes.&lt;br /&gt;
  wsdl2java -d build\classes -b .\wsdl\async_binding.xml -compile .\wsdl\hello_world_async.wsdl&lt;br /&gt;
    May use either forward or back slashes.&lt;br /&gt;
Now compile the provided client and server applications with the commands:&lt;br /&gt;
For UNIX:  &lt;br /&gt;
  &lt;br /&gt;
  export CLASSPATH=$CLASSPATH:$CXF_HOME/lib/cxf-manifest-incubator.jar:./build/classes&lt;br /&gt;
  javac -d build/classes src/demo/hw/client/*.java&lt;br /&gt;
  javac -d build/classes src/demo/hw/server/*.java&lt;br /&gt;
For Windows:&lt;br /&gt;
  set classpath=%classpath%;%CXF_HOME%\lib\cxf-manifest-incubator.jar;.\build\classes&lt;br /&gt;
  javac -d build\classes src\demo\hw\client\*.java&lt;br /&gt;
  javac -d build\classes src\demo\hw\server\*.java&lt;br /&gt;
&lt;br /&gt;
Running the demo using java&lt;br /&gt;
---------------------------&lt;br /&gt;
From the samples/hello_world_async directory run the commands, entered on a&lt;br /&gt;
single command line:&lt;br /&gt;
For UNIX (must use forward slashes):&lt;br /&gt;
    java -Djava.util.logging.config.file=$CXF_HOME/etc/logging.properties&lt;br /&gt;
         demo.hw.server.Server &amp;amp;&lt;br /&gt;
    java -Djava.util.logging.config.file=$CXF_HOME/etc/logging.properties&lt;br /&gt;
         demo.hw.client.Client ./wsdl/hello_world_async.wsdl&lt;br /&gt;
The server process starts in the background.  After running the client,&lt;br /&gt;
use the kill command to terminate the server process.&lt;br /&gt;
For Windows (may use either forward or back slashes):&lt;br /&gt;
  start &lt;br /&gt;
    java -Djava.util.logging.config.file=%CXF_HOME%\etc\logging.properties&lt;br /&gt;
         demo.hw.server.Server&lt;br /&gt;
    java -Djava.util.logging.config.file=%CXF_HOME%\etc\logging.properties&lt;br /&gt;
       demo.hw.client.Client .\wsdl\hello_world_async.wsdl&lt;br /&gt;
A new command windows opens for the server process.  After running the&lt;br /&gt;
client, terminate the server process by issuing Ctrl-C in its command window.&lt;br /&gt;
To remove the code generated from the WSDL file and the .class&lt;br /&gt;
files, either delete the build directory and its contents or run:&lt;br /&gt;
  ant clean&lt;br /&gt;
&lt;br /&gt;
///////////////////////////////////////////////////////////////////////////////&lt;br /&gt;
/**&lt;br /&gt;
 * Licensed to the Apache Software Foundation (ASF) under one&lt;br /&gt;
 * or more contributor license agreements. See the NOTICE file&lt;br /&gt;
 * distributed with this work for additional information&lt;br /&gt;
 * regarding copyright ownership. The ASF licenses this file&lt;br /&gt;
 * to you under the Apache License, Version 2.0 (the&lt;br /&gt;
 * &amp;quot;License&amp;quot;); you may not use this file except in compliance&lt;br /&gt;
 * with the License. You may obtain a copy of the License at&lt;br /&gt;
 *&lt;br /&gt;
 * http://www.apache.org/licenses/LICENSE-2.0&lt;br /&gt;
 *&lt;br /&gt;
 * Unless required by applicable law or agreed to in writing,&lt;br /&gt;
 * software distributed under the License is distributed on an&lt;br /&gt;
 * &amp;quot;AS IS&amp;quot; BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY&lt;br /&gt;
 * KIND, either express or implied. See the License for the&lt;br /&gt;
 * specific language governing permissions and limitations&lt;br /&gt;
 * under the License.&lt;br /&gt;
 */&lt;br /&gt;
&lt;br /&gt;
package demo.hw.client;&lt;br /&gt;
import java.io.File;&lt;br /&gt;
import java.util.concurrent.ExecutorService;&lt;br /&gt;
import java.util.concurrent.Executors;&lt;br /&gt;
import java.util.concurrent.Future;&lt;br /&gt;
import javax.xml.namespace.QName;&lt;br /&gt;
import javax.xml.ws.Response;&lt;br /&gt;
import org.apache.hello_world_async_soap_http.GreeterAsync;&lt;br /&gt;
import org.apache.hello_world_async_soap_http.SOAPService;&lt;br /&gt;
import org.apache.hello_world_async_soap_http.types.GreetMeSometimeResponse;&lt;br /&gt;
public final class Client {&lt;br /&gt;
    private static final QName SERVICE_NAME &lt;br /&gt;
        = new QName(&amp;quot;http://apache.org/hello_world_async_soap_http&amp;quot;, &amp;quot;SOAPService&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
    private Client() {&lt;br /&gt;
    } &lt;br /&gt;
    public static void main(String args[]) throws Exception {&lt;br /&gt;
        &lt;br /&gt;
        if (args.length == 0) { &lt;br /&gt;
            System.out.println(&amp;quot;please specify wsdl&amp;quot;);&lt;br /&gt;
            System.exit(1); &lt;br /&gt;
        }&lt;br /&gt;
        File wsdl = new File(args[0]);&lt;br /&gt;
        &lt;br /&gt;
        SOAPService ss = new SOAPService(wsdl.toURL(), SERVICE_NAME);&lt;br /&gt;
        ExecutorService executor = Executors.newFixedThreadPool(5);&lt;br /&gt;
        ss.setExecutor(executor);&lt;br /&gt;
        GreeterAsync port = ss.getSoapPort();&lt;br /&gt;
        String resp; &lt;br /&gt;
        &lt;br /&gt;
        // callback method&lt;br /&gt;
        TestAsyncHandler testAsyncHandler = new TestAsyncHandler();&lt;br /&gt;
        System.out.println(&amp;quot;Invoking greetMeSometimeAsync using callback object...&amp;quot;);&lt;br /&gt;
        Future&amp;lt;?&amp;gt; response = port.greetMeSometimeAsync(System.getProperty(&amp;quot;user.name&amp;quot;), testAsyncHandler);&lt;br /&gt;
        while (!response.isDone()) {&lt;br /&gt;
            Thread.sleep(100);&lt;br /&gt;
        }  &lt;br /&gt;
        resp = testAsyncHandler.getResponse();&lt;br /&gt;
        System.out.println();&lt;br /&gt;
        System.out.println(&amp;quot;Server responded through callback with: &amp;quot; + resp);&lt;br /&gt;
        System.out.println();&lt;br /&gt;
        &lt;br /&gt;
        //polling method&lt;br /&gt;
        System.out.println(&amp;quot;Invoking greetMeSometimeAsync using polling...&amp;quot;);&lt;br /&gt;
        Response&amp;lt;GreetMeSometimeResponse&amp;gt; greetMeSomeTimeResp = &lt;br /&gt;
            port.greetMeSometimeAsync(System.getProperty(&amp;quot;user.name&amp;quot;));&lt;br /&gt;
        while (!greetMeSomeTimeResp.isDone()) {&lt;br /&gt;
            Thread.sleep(100);&lt;br /&gt;
        }&lt;br /&gt;
        GreetMeSometimeResponse reply = greetMeSomeTimeResp.get();&lt;br /&gt;
        System.out.println(&amp;quot;Server responded through polling with: &amp;quot; + reply.getResponseType());    &lt;br /&gt;
        System.exit(0); &lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
///////////////////////////////////////////////////////////////////////////////&lt;br /&gt;
/**&lt;br /&gt;
 * Licensed to the Apache Software Foundation (ASF) under one&lt;br /&gt;
 * or more contributor license agreements. See the NOTICE file&lt;br /&gt;
 * distributed with this work for additional information&lt;br /&gt;
 * regarding copyright ownership. The ASF licenses this file&lt;br /&gt;
 * to you under the Apache License, Version 2.0 (the&lt;br /&gt;
 * &amp;quot;License&amp;quot;); you may not use this file except in compliance&lt;br /&gt;
 * with the License. You may obtain a copy of the License at&lt;br /&gt;
 *&lt;br /&gt;
 * http://www.apache.org/licenses/LICENSE-2.0&lt;br /&gt;
 *&lt;br /&gt;
 * Unless required by applicable law or agreed to in writing,&lt;br /&gt;
 * software distributed under the License is distributed on an&lt;br /&gt;
 * &amp;quot;AS IS&amp;quot; BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY&lt;br /&gt;
 * KIND, either express or implied. See the License for the&lt;br /&gt;
 * specific language governing permissions and limitations&lt;br /&gt;
 * under the License.&lt;br /&gt;
 */&lt;br /&gt;
package demo.hw.client;&lt;br /&gt;
import javax.xml.ws.AsyncHandler;&lt;br /&gt;
import javax.xml.ws.Response;&lt;br /&gt;
import org.apache.hello_world_async_soap_http.types.GreetMeSometimeResponse;&lt;br /&gt;
&lt;br /&gt;
public class TestAsyncHandler implements AsyncHandler&amp;lt;GreetMeSometimeResponse&amp;gt; {&lt;br /&gt;
    &lt;br /&gt;
    private GreetMeSometimeResponse reply;&lt;br /&gt;
    public void handleResponse(Response&amp;lt;GreetMeSometimeResponse&amp;gt; response) {&lt;br /&gt;
        try {&lt;br /&gt;
            System.err.println(&amp;quot;handleResponse called&amp;quot;);&lt;br /&gt;
            reply = response.get();&lt;br /&gt;
        } catch (Exception ex) {&lt;br /&gt;
            ex.printStackTrace();&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    public String getResponse() {&lt;br /&gt;
        return reply.getResponseType();&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
}&lt;br /&gt;
///////////////////////////////////////////////////////////////////////////////&lt;br /&gt;
/**&lt;br /&gt;
 * Licensed to the Apache Software Foundation (ASF) under one&lt;br /&gt;
 * or more contributor license agreements. See the NOTICE file&lt;br /&gt;
 * distributed with this work for additional information&lt;br /&gt;
 * regarding copyright ownership. The ASF licenses this file&lt;br /&gt;
 * to you under the Apache License, Version 2.0 (the&lt;br /&gt;
 * &amp;quot;License&amp;quot;); you may not use this file except in compliance&lt;br /&gt;
 * with the License. You may obtain a copy of the License at&lt;br /&gt;
 *&lt;br /&gt;
 * http://www.apache.org/licenses/LICENSE-2.0&lt;br /&gt;
 *&lt;br /&gt;
 * Unless required by applicable law or agreed to in writing,&lt;br /&gt;
 * software distributed under the License is distributed on an&lt;br /&gt;
 * &amp;quot;AS IS&amp;quot; BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY&lt;br /&gt;
 * KIND, either express or implied. See the License for the&lt;br /&gt;
 * specific language governing permissions and limitations&lt;br /&gt;
 * under the License.&lt;br /&gt;
 */&lt;br /&gt;
&lt;br /&gt;
package demo.hw.server;&lt;br /&gt;
import java.util.concurrent.Future;&lt;br /&gt;
import java.util.logging.Logger;&lt;br /&gt;
import javax.jws.WebService;&lt;br /&gt;
import javax.xml.ws.AsyncHandler;&lt;br /&gt;
import javax.xml.ws.Response;&lt;br /&gt;
import org.apache.hello_world_async_soap_http.GreeterAsync;&lt;br /&gt;
import org.apache.hello_world_async_soap_http.types.GreetMeSometimeResponse;&lt;br /&gt;
@WebService(serviceName = &amp;quot;SOAPService&amp;quot;, &lt;br /&gt;
            portName = &amp;quot;SoapPort&amp;quot;, &lt;br /&gt;
            endpointInterface = &amp;quot;org.apache.hello_world_async_soap_http.GreeterAsync&amp;quot;,&lt;br /&gt;
            targetNamespace = &amp;quot;http://apache.org/hello_world_async_soap_http&amp;quot;)&lt;br /&gt;
                  &lt;br /&gt;
public class GreeterImpl implements GreeterAsync {&lt;br /&gt;
    private static final Logger LOG = &lt;br /&gt;
        Logger.getLogger(GreeterImpl.class.getPackage().getName());&lt;br /&gt;
 &lt;br /&gt;
     /* (non-Javadoc)&lt;br /&gt;
     * @see org.apache.hello_world_soap_http.Greeter#greetMeSometime(java.lang.String)&lt;br /&gt;
     */&lt;br /&gt;
    public String greetMeSometime(String me) {&lt;br /&gt;
        LOG.info(&amp;quot;Executing operation greetMeSometime&amp;quot;);&lt;br /&gt;
        System.out.println(&amp;quot;Executing operation greetMeSometime\n&amp;quot;);&lt;br /&gt;
        return &amp;quot;How are you &amp;quot; + me;&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    public Future&amp;lt;?&amp;gt;  greetMeSometimeAsync(String requestType, &lt;br /&gt;
                                           AsyncHandler&amp;lt;GreetMeSometimeResponse&amp;gt; asyncHandler) {&lt;br /&gt;
        return null; &lt;br /&gt;
        /*not called */&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    public Response&amp;lt;GreetMeSometimeResponse&amp;gt; greetMeSometimeAsync(String requestType) { &lt;br /&gt;
        return null; &lt;br /&gt;
        /*not called */&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
}&lt;br /&gt;
///////////////////////////////////////////////////////////////////////////////&lt;br /&gt;
/**&lt;br /&gt;
 * Licensed to the Apache Software Foundation (ASF) under one&lt;br /&gt;
 * or more contributor license agreements. See the NOTICE file&lt;br /&gt;
 * distributed with this work for additional information&lt;br /&gt;
 * regarding copyright ownership. The ASF licenses this file&lt;br /&gt;
 * to you under the Apache License, Version 2.0 (the&lt;br /&gt;
 * &amp;quot;License&amp;quot;); you may not use this file except in compliance&lt;br /&gt;
 * with the License. You may obtain a copy of the License at&lt;br /&gt;
 *&lt;br /&gt;
 * http://www.apache.org/licenses/LICENSE-2.0&lt;br /&gt;
 *&lt;br /&gt;
 * Unless required by applicable law or agreed to in writing,&lt;br /&gt;
 * software distributed under the License is distributed on an&lt;br /&gt;
 * &amp;quot;AS IS&amp;quot; BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY&lt;br /&gt;
 * KIND, either express or implied. See the License for the&lt;br /&gt;
 * specific language governing permissions and limitations&lt;br /&gt;
 * under the License.&lt;br /&gt;
 */&lt;br /&gt;
&lt;br /&gt;
package demo.hw.server;&lt;br /&gt;
import javax.xml.ws.Endpoint;&lt;br /&gt;
public class Server {&lt;br /&gt;
    protected Server() throws Exception {&lt;br /&gt;
        System.out.println(&amp;quot;Starting Server&amp;quot;);&lt;br /&gt;
        Object implementor = new GreeterImpl();&lt;br /&gt;
        String address = &amp;quot;http://localhost:9000/SoapContext/SoapPort&amp;quot;;&lt;br /&gt;
        Endpoint.publish(address, implementor);&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    public static void main(String args[]) throws Exception {&lt;br /&gt;
        new Server();&lt;br /&gt;
        System.out.println(&amp;quot;Server ready...&amp;quot;); &lt;br /&gt;
        &lt;br /&gt;
        Thread.sleep(5 * 60 * 1000); &lt;br /&gt;
        System.out.println(&amp;quot;Server exiting&amp;quot;);&lt;br /&gt;
        System.exit(0);&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
///////////////////////////////////////////////////////////////////////////////&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
  Licensed to the Apache Software Foundation (ASF) under one&lt;br /&gt;
  or more contributor license agreements. See the NOTICE file&lt;br /&gt;
  distributed with this work for additional information&lt;br /&gt;
  regarding copyright ownership. The ASF licenses this file&lt;br /&gt;
  to you under the Apache License, Version 2.0 (the&lt;br /&gt;
  &amp;quot;License&amp;quot;); you may not use this file except in compliance&lt;br /&gt;
  with the License. You may obtain a copy of the License at&lt;br /&gt;
                                                                                                                                                             &lt;br /&gt;
  http://www.apache.org/licenses/LICENSE-2.0&lt;br /&gt;
                                                                                                                                                             &lt;br /&gt;
  Unless required by applicable law or agreed to in writing,&lt;br /&gt;
  software distributed under the License is distributed on an&lt;br /&gt;
  &amp;quot;AS IS&amp;quot; BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY&lt;br /&gt;
  KIND, either express or implied. See the License for the&lt;br /&gt;
  specific language governing permissions and limitations&lt;br /&gt;
  under the License.&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;bindings&lt;br /&gt;
    xmlns:xsd=&amp;quot;http://www.w3.org/2001/XMLSchema&amp;quot;&lt;br /&gt;
    xmlns:wsdl=&amp;quot;http://schemas.xmlsoap.org/wsdl/&amp;quot;&lt;br /&gt;
    wsdlLocation=&amp;quot;hello_world_async.wsdl&amp;quot;&lt;br /&gt;
    xmlns=&amp;quot;http://java.sun.ru/xml/ns/jaxws&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;bindings node=&amp;quot;wsdl:definitions&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;enableAsyncMapping&amp;gt;true&amp;lt;/enableAsyncMapping&amp;gt;&lt;br /&gt;
    &amp;lt;/bindings&amp;gt;&lt;br /&gt;
&amp;lt;/bindings&amp;gt;&lt;br /&gt;
///////////////////////////////////////////////////////////////////////////////&lt;br /&gt;
&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot;?&amp;gt;&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
  Licensed to the Apache Software Foundation (ASF) under one&lt;br /&gt;
  or more contributor license agreements. See the NOTICE file&lt;br /&gt;
  distributed with this work for additional information&lt;br /&gt;
  regarding copyright ownership. The ASF licenses this file&lt;br /&gt;
  to you under the Apache License, Version 2.0 (the&lt;br /&gt;
  &amp;quot;License&amp;quot;); you may not use this file except in compliance&lt;br /&gt;
  with the License. You may obtain a copy of the License at&lt;br /&gt;
                                                                                                                                                             &lt;br /&gt;
  http://www.apache.org/licenses/LICENSE-2.0&lt;br /&gt;
                                                                                                                                                             &lt;br /&gt;
  Unless required by applicable law or agreed to in writing,&lt;br /&gt;
  software distributed under the License is distributed on an&lt;br /&gt;
  &amp;quot;AS IS&amp;quot; BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY&lt;br /&gt;
  KIND, either express or implied. See the License for the&lt;br /&gt;
  specific language governing permissions and limitations&lt;br /&gt;
  under the License.&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&amp;lt;wsdl:definitions xmlns=&amp;quot;http://schemas.xmlsoap.org/wsdl/&amp;quot; xmlns:soap=&amp;quot;http://schemas.xmlsoap.org/wsdl/soap/&amp;quot; xmlns:tns=&amp;quot;http://apache.org/hello_world_async_soap_http&amp;quot; xmlns:x1=&amp;quot;http://apache.org/hello_world_async_soap_http/types&amp;quot; xmlns:wsdl=&amp;quot;http://schemas.xmlsoap.org/wsdl/&amp;quot; xmlns:xsd=&amp;quot;http://www.w3.org/2001/XMLSchema&amp;quot; targetNamespace=&amp;quot;http://apache.org/hello_world_async_soap_http&amp;quot; name=&amp;quot;HelloWorld&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;wsdl:types&amp;gt;&lt;br /&gt;
        &amp;lt;schema targetNamespace=&amp;quot;http://apache.org/hello_world_async_soap_http/types&amp;quot; xmlns=&amp;quot;http://www.w3.org/2001/XMLSchema&amp;quot; xmlns:x1=&amp;quot;http://apache.org/hello_world_async_soap_http/types&amp;quot; elementFormDefault=&amp;quot;qualified&amp;quot;&amp;gt;&lt;br /&gt;
            &amp;lt;element name=&amp;quot;greetMeSometime&amp;quot;&amp;gt;&lt;br /&gt;
                &amp;lt;complexType&amp;gt;&lt;br /&gt;
                    &amp;lt;sequence&amp;gt;&lt;br /&gt;
                        &amp;lt;element name=&amp;quot;requestType&amp;quot; type=&amp;quot;xsd:string&amp;quot;/&amp;gt;&lt;br /&gt;
                    &amp;lt;/sequence&amp;gt;&lt;br /&gt;
                &amp;lt;/complexType&amp;gt;&lt;br /&gt;
            &amp;lt;/element&amp;gt;&lt;br /&gt;
            &amp;lt;element name=&amp;quot;greetMeSometimeResponse&amp;quot;&amp;gt;&lt;br /&gt;
                &amp;lt;complexType&amp;gt;&lt;br /&gt;
                    &amp;lt;sequence&amp;gt;&lt;br /&gt;
                        &amp;lt;element name=&amp;quot;responseType&amp;quot; type=&amp;quot;xsd:string&amp;quot;/&amp;gt;&lt;br /&gt;
                    &amp;lt;/sequence&amp;gt;&lt;br /&gt;
                &amp;lt;/complexType&amp;gt;&lt;br /&gt;
            &amp;lt;/element&amp;gt;      &lt;br /&gt;
        &amp;lt;/schema&amp;gt;&lt;br /&gt;
    &amp;lt;/wsdl:types&amp;gt;&lt;br /&gt;
    &amp;lt;wsdl:message name=&amp;quot;greetMeSometimeRequest&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;wsdl:part name=&amp;quot;in&amp;quot; element=&amp;quot;x1:greetMeSometime&amp;quot;/&amp;gt;&lt;br /&gt;
    &amp;lt;/wsdl:message&amp;gt;&lt;br /&gt;
    &amp;lt;wsdl:message name=&amp;quot;greetMeSometimeResponse&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;wsdl:part name=&amp;quot;out&amp;quot; element=&amp;quot;x1:greetMeSometimeResponse&amp;quot;/&amp;gt;&lt;br /&gt;
    &amp;lt;/wsdl:message&amp;gt;&lt;br /&gt;
    &amp;lt;wsdl:portType name=&amp;quot;GreeterAsync&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;wsdl:operation name=&amp;quot;greetMeSometime&amp;quot;&amp;gt;&lt;br /&gt;
            &amp;lt;wsdl:input name=&amp;quot;greetMeSometimeRequest&amp;quot; message=&amp;quot;tns:greetMeSometimeRequest&amp;quot;/&amp;gt;&lt;br /&gt;
            &amp;lt;wsdl:output name=&amp;quot;greetMeSometimeResponse&amp;quot; message=&amp;quot;tns:greetMeSometimeResponse&amp;quot;/&amp;gt;&lt;br /&gt;
        &amp;lt;/wsdl:operation&amp;gt;&lt;br /&gt;
    &amp;lt;/wsdl:portType&amp;gt;&lt;br /&gt;
    &amp;lt;wsdl:binding name=&amp;quot;GreeterAsync_SOAPBinding&amp;quot; type=&amp;quot;tns:GreeterAsync&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;soap:binding style=&amp;quot;document&amp;quot; transport=&amp;quot;http://schemas.xmlsoap.org/soap/http&amp;quot;/&amp;gt;&lt;br /&gt;
        &amp;lt;wsdl:operation name=&amp;quot;greetMeSometime&amp;quot;&amp;gt;&lt;br /&gt;
            &amp;lt;soap:operation style=&amp;quot;document&amp;quot;/&amp;gt;&lt;br /&gt;
            &amp;lt;wsdl:input&amp;gt;&lt;br /&gt;
                &amp;lt;soap:body use=&amp;quot;literal&amp;quot;/&amp;gt;&lt;br /&gt;
            &amp;lt;/wsdl:input&amp;gt;&lt;br /&gt;
            &amp;lt;wsdl:output&amp;gt;&lt;br /&gt;
                &amp;lt;soap:body use=&amp;quot;literal&amp;quot;/&amp;gt;&lt;br /&gt;
            &amp;lt;/wsdl:output&amp;gt;&lt;br /&gt;
        &amp;lt;/wsdl:operation&amp;gt;&lt;br /&gt;
    &amp;lt;/wsdl:binding&amp;gt;&lt;br /&gt;
    &amp;lt;wsdl:service name=&amp;quot;SOAPService&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;wsdl:port name=&amp;quot;SoapPort&amp;quot; binding=&amp;quot;tns:GreeterAsync_SOAPBinding&amp;quot;&amp;gt;&lt;br /&gt;
            &amp;lt;soap:address location=&amp;quot;http://localhost:9000/SoapContext/SoapPort&amp;quot;/&amp;gt;&lt;br /&gt;
        &amp;lt;/wsdl:port&amp;gt;&lt;br /&gt;
    &amp;lt;/wsdl:service&amp;gt;&lt;br /&gt;
&amp;lt;/wsdl:definitions&amp;gt;&lt;br /&gt;
        &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== This demo shows a client creating a callback object by passing an EndpointReferenceType to the server ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
/**&lt;br /&gt;
 * Licensed to the Apache Software Foundation (ASF) under one&lt;br /&gt;
 * or more contributor license agreements. See the NOTICE file&lt;br /&gt;
 * distributed with this work for additional information&lt;br /&gt;
 * regarding copyright ownership. The ASF licenses this file&lt;br /&gt;
 * to you under the Apache License, Version 2.0 (the&lt;br /&gt;
 * &amp;quot;License&amp;quot;); you may not use this file except in compliance&lt;br /&gt;
 * with the License. You may obtain a copy of the License at&lt;br /&gt;
 *&lt;br /&gt;
 * http://www.apache.org/licenses/LICENSE-2.0&lt;br /&gt;
 *&lt;br /&gt;
 * Unless required by applicable law or agreed to in writing,&lt;br /&gt;
 * software distributed under the License is distributed on an&lt;br /&gt;
 * &amp;quot;AS IS&amp;quot; BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY&lt;br /&gt;
 * KIND, either express or implied. See the License for the&lt;br /&gt;
 * specific language governing permissions and limitations&lt;br /&gt;
 * under the License.&lt;br /&gt;
 */&lt;br /&gt;
&lt;br /&gt;
        &lt;br /&gt;
Callback Demo&lt;br /&gt;
=============================================&lt;br /&gt;
This demo shows a client creating a callback object by &lt;br /&gt;
passing an EndpointReferenceType to the server. The &lt;br /&gt;
EndpointRefrenceType is then used by the server to call &lt;br /&gt;
back on the callback object &lt;br /&gt;
Please review the README in the samples directory before&lt;br /&gt;
continuing.&lt;br /&gt;
&lt;br /&gt;
Prerequisite&lt;br /&gt;
------------&lt;br /&gt;
If your environment already includes cxf-manifest-incubator.jar on the&lt;br /&gt;
CLASSPATH, and the JDK and ant bin directories on the PATH&lt;br /&gt;
it is not necessary to set the environment as described in&lt;br /&gt;
the samples directory&amp;quot;s README.  If your environment is not&lt;br /&gt;
properly configured, or if you are planning on using wsdl2java,&lt;br /&gt;
javac, and java to build and run the demos, you must set the&lt;br /&gt;
environment.&lt;br /&gt;
&lt;br /&gt;
Building and running the demo using ant&lt;br /&gt;
---------------------------------------&lt;br /&gt;
From the samples/basic_callback directory, the ant build script&lt;br /&gt;
can be used to build and run the demo.&lt;br /&gt;
Using either UNIX or Windows:&lt;br /&gt;
  ant build&lt;br /&gt;
  ant server&lt;br /&gt;
  ant client&lt;br /&gt;
    &lt;br /&gt;
To remove the code generated from the WSDL file and the .class&lt;br /&gt;
files, run:&lt;br /&gt;
  ant clean&lt;br /&gt;
&lt;br /&gt;
Building the demo using wsdl2java and javac&lt;br /&gt;
------------------------------------------&lt;br /&gt;
From the samples/basic_callback directory, first create the target&lt;br /&gt;
directory build/classes and then generate code from the WSDL file.&lt;br /&gt;
For UNIX:&lt;br /&gt;
  mkdir -p build/classes&lt;br /&gt;
  wsdl2java -d build/classes -compile ./wsdl/basic_callback.wsdl&lt;br /&gt;
For Windows:&lt;br /&gt;
  mkdir build\classes&lt;br /&gt;
    Must use back slashes.&lt;br /&gt;
  wsdl2java -d build\classes -compile .\wsdl\basic_callback.wsdl&lt;br /&gt;
    May use either forward or back slashes.&lt;br /&gt;
Now compile the provided client and server applications with the commands:&lt;br /&gt;
For UNIX:  &lt;br /&gt;
  &lt;br /&gt;
  export CLASSPATH=$CLASSPATH:$CXF_HOME/lib/cxf-manifest-incubator.jar:./build/classes&lt;br /&gt;
  javac -d build/classes src/demo/callback/client/*.java&lt;br /&gt;
  javac -d build/classes src/demo/callback/server/*.java&lt;br /&gt;
For Windows:&lt;br /&gt;
  set classpath=%classpath%;%CXF_HOME%\lib\cxf-manifest-incubator.jar;.\build\classes&lt;br /&gt;
  javac -d build\classes src\demo\callback\client\*.java&lt;br /&gt;
  javac -d build\classes src\demo\callback\server\*.java&lt;br /&gt;
&lt;br /&gt;
Running the demo using java&lt;br /&gt;
---------------------------&lt;br /&gt;
From the samples/basic_callback directory run the commands, entered on a&lt;br /&gt;
single command line:&lt;br /&gt;
For UNIX (must use forward slashes):&lt;br /&gt;
    java -Djava.util.logging.config.file=$CXF_HOME/etc/logging.properties&lt;br /&gt;
         demo.callback.server.Server &amp;amp;&lt;br /&gt;
    java -Djava.util.logging.config.file=$CXF_HOME/etc/logging.properties&lt;br /&gt;
         demo.callback.client.Client ./wsdl/basic_callback.wsdl&lt;br /&gt;
The server process starts in the background.  After running the client,&lt;br /&gt;
use the kill command to terminate the server process.&lt;br /&gt;
For Windows (may use either forward or back slashes):&lt;br /&gt;
  start &lt;br /&gt;
    java -Djava.util.logging.config.file=%CXF_HOME%\etc\logging.properties&lt;br /&gt;
         demo.callback.server.Server&lt;br /&gt;
    java -Djava.util.logging.config.file=%CXF_HOME%\etc\logging.properties&lt;br /&gt;
       demo.callback.client.Client .\wsdl\basic_callback.wsdl&lt;br /&gt;
A new command windows opens for the server process.  After running the&lt;br /&gt;
client, terminate the server process by issuing Ctrl-C in its command window.&lt;br /&gt;
To remove the code generated from the WSDL file and the .class&lt;br /&gt;
files, either delete the build directory and its contents or run:&lt;br /&gt;
  ant clean&lt;br /&gt;
&lt;br /&gt;
////////////////////////////////////////////////////////////////&lt;br /&gt;
/**&lt;br /&gt;
 * Licensed to the Apache Software Foundation (ASF) under one&lt;br /&gt;
 * or more contributor license agreements. See the NOTICE file&lt;br /&gt;
 * distributed with this work for additional information&lt;br /&gt;
 * regarding copyright ownership. The ASF licenses this file&lt;br /&gt;
 * to you under the Apache License, Version 2.0 (the&lt;br /&gt;
 * &amp;quot;License&amp;quot;); you may not use this file except in compliance&lt;br /&gt;
 * with the License. You may obtain a copy of the License at&lt;br /&gt;
 *&lt;br /&gt;
 * http://www.apache.org/licenses/LICENSE-2.0&lt;br /&gt;
 *&lt;br /&gt;
 * Unless required by applicable law or agreed to in writing,&lt;br /&gt;
 * software distributed under the License is distributed on an&lt;br /&gt;
 * &amp;quot;AS IS&amp;quot; BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY&lt;br /&gt;
 * KIND, either express or implied. See the License for the&lt;br /&gt;
 * specific language governing permissions and limitations&lt;br /&gt;
 * under the License.&lt;br /&gt;
 */&lt;br /&gt;
&lt;br /&gt;
package demo.callback.client;&lt;br /&gt;
import org.apache.callback.CallbackPortType;&lt;br /&gt;
&lt;br /&gt;
@javax.jws.WebService(serviceName = &amp;quot;CallbackService&amp;quot;, &lt;br /&gt;
                      portName = &amp;quot;CallbackPort&amp;quot;,&lt;br /&gt;
                      endpointInterface = &amp;quot;org.apache.callback.CallbackPortType&amp;quot;,&lt;br /&gt;
                      targetNamespace = &amp;quot;http://apache.org/callback&amp;quot;)&lt;br /&gt;
                  &lt;br /&gt;
public class CallbackImpl implements CallbackPortType  {&lt;br /&gt;
    &lt;br /&gt;
    /**&lt;br /&gt;
     * serverSayHi&lt;br /&gt;
     * @param: return_message (String)&lt;br /&gt;
     * @return: String&lt;br /&gt;
     */&lt;br /&gt;
    public String serverSayHi(String message) {&lt;br /&gt;
        System.out.println(&amp;quot;Callback object invoked&amp;quot;);&lt;br /&gt;
        System.out.println(&amp;quot;Message recieved: &amp;quot; + message);&lt;br /&gt;
        return new String(&amp;quot;Hi &amp;quot; + message);&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
///////////////////////////////////////////////////////////////////&lt;br /&gt;
/**&lt;br /&gt;
 * Licensed to the Apache Software Foundation (ASF) under one&lt;br /&gt;
 * or more contributor license agreements. See the NOTICE file&lt;br /&gt;
 * distributed with this work for additional information&lt;br /&gt;
 * regarding copyright ownership. The ASF licenses this file&lt;br /&gt;
 * to you under the Apache License, Version 2.0 (the&lt;br /&gt;
 * &amp;quot;License&amp;quot;); you may not use this file except in compliance&lt;br /&gt;
 * with the License. You may obtain a copy of the License at&lt;br /&gt;
 *&lt;br /&gt;
 * http://www.apache.org/licenses/LICENSE-2.0&lt;br /&gt;
 *&lt;br /&gt;
 * Unless required by applicable law or agreed to in writing,&lt;br /&gt;
 * software distributed under the License is distributed on an&lt;br /&gt;
 * &amp;quot;AS IS&amp;quot; BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY&lt;br /&gt;
 * KIND, either express or implied. See the License for the&lt;br /&gt;
 * specific language governing permissions and limitations&lt;br /&gt;
 * under the License.&lt;br /&gt;
 */&lt;br /&gt;
&lt;br /&gt;
package demo.callback.client;&lt;br /&gt;
import java.io.File;&lt;br /&gt;
import java.net.URL;&lt;br /&gt;
import javax.xml.namespace.QName;&lt;br /&gt;
import javax.xml.ws.Endpoint;&lt;br /&gt;
import org.apache.callback.SOAPService;&lt;br /&gt;
import org.apache.callback.ServerPortType;&lt;br /&gt;
import org.apache.cxf.ws.addressing.EndpointReferenceType;&lt;br /&gt;
import org.apache.cxf.wsdl.EndpointReferenceUtils;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
public final class Client {&lt;br /&gt;
    private static final QName SERVICE_NAME &lt;br /&gt;
        = new QName(&amp;quot;http://apache.org/callback&amp;quot;, &amp;quot;SOAPService&amp;quot;);&lt;br /&gt;
    private static final QName SERVICE_NAME_CALLBACK &lt;br /&gt;
        = new QName(&amp;quot;http://apache.org/callback&amp;quot;, &amp;quot;CallbackService&amp;quot;);&lt;br /&gt;
    &lt;br /&gt;
    private static final QName PORT_NAME_CALLBACK &lt;br /&gt;
        = new QName(&amp;quot;http://apache.org/callback&amp;quot;, &amp;quot;CallbackPort&amp;quot;);&lt;br /&gt;
    &lt;br /&gt;
    private static final QName PORT_TYPE_CALLBACK&lt;br /&gt;
        = new QName(&amp;quot;http://apache.org/callback&amp;quot;, &amp;quot;CallbackPortType&amp;quot;);&lt;br /&gt;
    private Client() {&lt;br /&gt;
    } &lt;br /&gt;
    public static void main(String args[]) throws Exception {&lt;br /&gt;
        &lt;br /&gt;
        &lt;br /&gt;
        Object implementor = new CallbackImpl();&lt;br /&gt;
        String address = &amp;quot;http://localhost:9005/CallbackContext/CallbackPort&amp;quot;;&lt;br /&gt;
        Endpoint.publish(address, implementor);&lt;br /&gt;
        &lt;br /&gt;
        if (args.length == 0) { &lt;br /&gt;
            System.out.println(&amp;quot;please specify wsdl&amp;quot;);&lt;br /&gt;
            System.exit(1); &lt;br /&gt;
        }&lt;br /&gt;
        URL wsdlURL;&lt;br /&gt;
        File wsdlFile = new File(args[0]);&lt;br /&gt;
        if (wsdlFile.exists()) {&lt;br /&gt;
            wsdlURL = wsdlFile.toURL();&lt;br /&gt;
        } else {&lt;br /&gt;
            wsdlURL = new URL(args[0]);&lt;br /&gt;
        }&lt;br /&gt;
        &lt;br /&gt;
        SOAPService ss = new SOAPService(wsdlURL, SERVICE_NAME);&lt;br /&gt;
        ServerPortType port = ss.getSOAPPort();&lt;br /&gt;
        &lt;br /&gt;
        EndpointReferenceType ref =&lt;br /&gt;
            EndpointReferenceUtils.getEndpointReference(wsdlURL,&lt;br /&gt;
                                                        SERVICE_NAME_CALLBACK, &lt;br /&gt;
                                                        PORT_NAME_CALLBACK.getLocalPart());&lt;br /&gt;
        EndpointReferenceUtils.setInterfaceName(ref, PORT_TYPE_CALLBACK);&lt;br /&gt;
        &lt;br /&gt;
        String resp = port.registerCallback(ref);&lt;br /&gt;
        System.out.println(&amp;quot;Response from server: &amp;quot; + resp);&lt;br /&gt;
        &lt;br /&gt;
        System.exit(0); &lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
/////////////////////////////////////////////////////////////////&lt;br /&gt;
/**&lt;br /&gt;
 * Licensed to the Apache Software Foundation (ASF) under one&lt;br /&gt;
 * or more contributor license agreements. See the NOTICE file&lt;br /&gt;
 * distributed with this work for additional information&lt;br /&gt;
 * regarding copyright ownership. The ASF licenses this file&lt;br /&gt;
 * to you under the Apache License, Version 2.0 (the&lt;br /&gt;
 * &amp;quot;License&amp;quot;); you may not use this file except in compliance&lt;br /&gt;
 * with the License. You may obtain a copy of the License at&lt;br /&gt;
 *&lt;br /&gt;
 * http://www.apache.org/licenses/LICENSE-2.0&lt;br /&gt;
 *&lt;br /&gt;
 * Unless required by applicable law or agreed to in writing,&lt;br /&gt;
 * software distributed under the License is distributed on an&lt;br /&gt;
 * &amp;quot;AS IS&amp;quot; BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY&lt;br /&gt;
 * KIND, either express or implied. See the License for the&lt;br /&gt;
 * specific language governing permissions and limitations&lt;br /&gt;
 * under the License.&lt;br /&gt;
 */&lt;br /&gt;
&lt;br /&gt;
package demo.callback.server;&lt;br /&gt;
import javax.xml.ws.Endpoint;&lt;br /&gt;
public class Server {&lt;br /&gt;
    protected Server() throws Exception {&lt;br /&gt;
        System.out.println(&amp;quot;Starting Server&amp;quot;);&lt;br /&gt;
        Object implementor = new ServerImpl();&lt;br /&gt;
        String address = &amp;quot;http://localhost:9000/SoapContext/SoapPort&amp;quot;;&lt;br /&gt;
        Endpoint.publish(address, implementor);&lt;br /&gt;
    }&lt;br /&gt;
    public static void main(String args[]) throws Exception {&lt;br /&gt;
        new Server();&lt;br /&gt;
        System.out.println(&amp;quot;Server ready...&amp;quot;);&lt;br /&gt;
        Thread.sleep(5 * 60 * 1000);&lt;br /&gt;
        System.out.println(&amp;quot;Server exiting&amp;quot;);&lt;br /&gt;
        System.exit(0);&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
/////////////////////////////////////////////////////////////&lt;br /&gt;
/**&lt;br /&gt;
 * Licensed to the Apache Software Foundation (ASF) under one&lt;br /&gt;
 * or more contributor license agreements. See the NOTICE file&lt;br /&gt;
 * distributed with this work for additional information&lt;br /&gt;
 * regarding copyright ownership. The ASF licenses this file&lt;br /&gt;
 * to you under the Apache License, Version 2.0 (the&lt;br /&gt;
 * &amp;quot;License&amp;quot;); you may not use this file except in compliance&lt;br /&gt;
 * with the License. You may obtain a copy of the License at&lt;br /&gt;
 *&lt;br /&gt;
 * http://www.apache.org/licenses/LICENSE-2.0&lt;br /&gt;
 *&lt;br /&gt;
 * Unless required by applicable law or agreed to in writing,&lt;br /&gt;
 * software distributed under the License is distributed on an&lt;br /&gt;
 * &amp;quot;AS IS&amp;quot; BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY&lt;br /&gt;
 * KIND, either express or implied. See the License for the&lt;br /&gt;
 * specific language governing permissions and limitations&lt;br /&gt;
 * under the License.&lt;br /&gt;
 */&lt;br /&gt;
package demo.callback.server;&lt;br /&gt;
import java.net.URL;&lt;br /&gt;
import javax.xml.namespace.QName;&lt;br /&gt;
import javax.xml.ws.Service;&lt;br /&gt;
import org.apache.callback.CallbackPortType;&lt;br /&gt;
import org.apache.callback.ServerPortType;&lt;br /&gt;
import org.apache.cxf.jaxb.JAXBUtils;&lt;br /&gt;
import org.apache.cxf.ws.addressing.EndpointReferenceType;&lt;br /&gt;
import org.apache.cxf.wsdl.EndpointReferenceUtils;&lt;br /&gt;
import org.apache.cxf.wsdl.WSDLManager;&lt;br /&gt;
import org.apache.cxf.wsdl11.WSDLManagerImpl;&lt;br /&gt;
&lt;br /&gt;
@javax.jws.WebService(serviceName = &amp;quot;SOAPService&amp;quot;, &lt;br /&gt;
                      portName = &amp;quot;SOAPPort&amp;quot;,&lt;br /&gt;
                      targetNamespace = &amp;quot;http://apache.org/callback&amp;quot;,&lt;br /&gt;
                      endpointInterface = &amp;quot;org.apache.callback.ServerPortType&amp;quot;) &lt;br /&gt;
                  &lt;br /&gt;
public class ServerImpl implements ServerPortType  {&lt;br /&gt;
    &lt;br /&gt;
    public String registerCallback(EndpointReferenceType callback) {&lt;br /&gt;
        &lt;br /&gt;
        try {&lt;br /&gt;
            WSDLManager manager = new WSDLManagerImpl();&lt;br /&gt;
        &lt;br /&gt;
            QName interfaceName = EndpointReferenceUtils.getInterfaceName(callback);&lt;br /&gt;
            String wsdlLocation = EndpointReferenceUtils.getWSDLLocation(callback);&lt;br /&gt;
            QName serviceName = EndpointReferenceUtils.getServiceName(callback);&lt;br /&gt;
            String portString = EndpointReferenceUtils.getPortName(callback);&lt;br /&gt;
            &lt;br /&gt;
            QName portName = new QName(serviceName.getNamespaceURI(), portString);&lt;br /&gt;
            &lt;br /&gt;
            StringBuffer seiName = new StringBuffer();&lt;br /&gt;
            seiName.append(JAXBUtils.namespaceURIToPackage(interfaceName.getNamespaceURI()));&lt;br /&gt;
            seiName.append(&amp;quot;.&amp;quot;);&lt;br /&gt;
            seiName.append(JAXBUtils.nameToIdentifier(interfaceName.getLocalPart(),&lt;br /&gt;
                                                      JAXBUtils.IdentifierType.INTERFACE));&lt;br /&gt;
            System.out.println(&amp;quot;the seiname is &amp;quot; + seiName.toString()); &lt;br /&gt;
            Class&amp;lt;?&amp;gt; sei = null;    &lt;br /&gt;
            try {&lt;br /&gt;
                sei = Class.forName(seiName.toString(), &lt;br /&gt;
                                    true, manager.getClass().getClassLoader());&lt;br /&gt;
            } catch (ClassNotFoundException ex) {&lt;br /&gt;
                ex.printStackTrace();&lt;br /&gt;
            }&lt;br /&gt;
            &lt;br /&gt;
            URL wsdlURL = new URL(wsdlLocation);            &lt;br /&gt;
            &lt;br /&gt;
            Service service = Service.create(wsdlURL, serviceName);&lt;br /&gt;
            CallbackPortType port =  (CallbackPortType)service.getPort(portName, sei);&lt;br /&gt;
            System.out.println(&amp;quot;Invoking on callback object&amp;quot;);&lt;br /&gt;
            String resp = port.serverSayHi(System.getProperty(&amp;quot;user.name&amp;quot;));&lt;br /&gt;
            System.out.println(&amp;quot;Response from callback object: &amp;quot; + resp);&lt;br /&gt;
  &lt;br /&gt;
            &lt;br /&gt;
        } catch (Exception ex) {&lt;br /&gt;
            ex.printStackTrace();&lt;br /&gt;
            return null;&lt;br /&gt;
        }&lt;br /&gt;
        &lt;br /&gt;
        return &amp;quot;registerCallback called&amp;quot;;     &lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
///////////////////////////////////////////////////////////////////&lt;br /&gt;
&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot;?&amp;gt;&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
  Licensed to the Apache Software Foundation (ASF) under one&lt;br /&gt;
  or more contributor license agreements. See the NOTICE file&lt;br /&gt;
  distributed with this work for additional information&lt;br /&gt;
  regarding copyright ownership. The ASF licenses this file&lt;br /&gt;
  to you under the Apache License, Version 2.0 (the&lt;br /&gt;
  &amp;quot;License&amp;quot;); you may not use this file except in compliance&lt;br /&gt;
  with the License. You may obtain a copy of the License at&lt;br /&gt;
                                                                                                                                                             &lt;br /&gt;
  http://www.apache.org/licenses/LICENSE-2.0&lt;br /&gt;
                                                                                                                                                             &lt;br /&gt;
  Unless required by applicable law or agreed to in writing,&lt;br /&gt;
  software distributed under the License is distributed on an&lt;br /&gt;
  &amp;quot;AS IS&amp;quot; BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY&lt;br /&gt;
  KIND, either express or implied. See the License for the&lt;br /&gt;
  specific language governing permissions and limitations&lt;br /&gt;
  under the License.&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&amp;lt;wsdl:definitions name=&amp;quot;basic_callback&amp;quot; targetNamespace=&amp;quot;http://apache.org/callback&amp;quot;&lt;br /&gt;
      xmlns=&amp;quot;http://schemas.xmlsoap.org/wsdl/&amp;quot; &lt;br /&gt;
      xmlns:references=&amp;quot;http://www.w3.org/2005/08/addressing&amp;quot; &lt;br /&gt;
      xmlns:soap=&amp;quot;http://schemas.xmlsoap.org/wsdl/soap/&amp;quot; &lt;br /&gt;
      xmlns:tns=&amp;quot;http://apache.org/callback&amp;quot; &lt;br /&gt;
      xmlns:wsdl=&amp;quot;http://schemas.xmlsoap.org/wsdl/&amp;quot; &lt;br /&gt;
      xmlns:xsd=&amp;quot;http://www.w3.org/2001/XMLSchema&amp;quot;&lt;br /&gt;
      xmlns:jaxb=&amp;quot;http://java.sun.ru/xml/ns/jaxb&amp;quot; jaxb:version=&amp;quot;2.0&amp;quot;&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
&lt;br /&gt;
    &amp;lt;wsdl:types&amp;gt; &lt;br /&gt;
  &amp;lt;schema targetNamespace=&amp;quot;http://apache.org/callback&amp;quot; &lt;br /&gt;
    xmlns=&amp;quot;http://www.w3.org/2001/XMLSchema&amp;quot; &lt;br /&gt;
    xmlns:wsdl=&amp;quot;http://schemas.xmlsoap.org/wsdl/&amp;quot;&lt;br /&gt;
    xmlns:jaxb=&amp;quot;http://java.sun.ru/xml/ns/jaxb&amp;quot; &lt;br /&gt;
    jaxb:version=&amp;quot;2.0&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;xsd:import namespace=&amp;quot;http://www.w3.org/2005/08/addressing&amp;quot; schemaLocation=&amp;quot;/schemas/wsdl/ws-addr.xsd&amp;quot;/&amp;gt;&lt;br /&gt;
      &amp;lt;element name=&amp;quot;callback_message&amp;quot; type=&amp;quot;xsd:string&amp;quot;/&amp;gt;&lt;br /&gt;
      &amp;lt;element name=&amp;quot;RegisterCallback&amp;quot; type=&amp;quot;references:EndpointReferenceType&amp;quot;/&amp;gt;&lt;br /&gt;
      &amp;lt;element name=&amp;quot;returnType&amp;quot; type=&amp;quot;xsd:string&amp;quot;/&amp;gt;&lt;br /&gt;
  &amp;lt;/schema&amp;gt;&lt;br /&gt;
    &amp;lt;/wsdl:types&amp;gt;&lt;br /&gt;
    &amp;lt;wsdl:message name=&amp;quot;server_sayHi&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;wsdl:part element=&amp;quot;tns:callback_message&amp;quot; name=&amp;quot;return_message&amp;quot;/&amp;gt;&lt;br /&gt;
    &amp;lt;/wsdl:message&amp;gt;&lt;br /&gt;
    &amp;lt;wsdl:message name=&amp;quot;register_callback&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;wsdl:part element=&amp;quot;tns:RegisterCallback&amp;quot; name=&amp;quot;callback_object&amp;quot;/&amp;gt;&lt;br /&gt;
    &amp;lt;/wsdl:message&amp;gt;&lt;br /&gt;
    &amp;lt;wsdl:message name=&amp;quot;returnMessage&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;wsdl:part element=&amp;quot;tns:returnType&amp;quot; name=&amp;quot;the_return&amp;quot;/&amp;gt;&lt;br /&gt;
    &amp;lt;/wsdl:message&amp;gt;&lt;br /&gt;
    &amp;lt;wsdl:portType name=&amp;quot;CallbackPortType&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;wsdl:operation name=&amp;quot;ServerSayHi&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;wsdl:input message=&amp;quot;tns:server_sayHi&amp;quot; name=&amp;quot;ServerSayHiRequest&amp;quot;/&amp;gt;&lt;br /&gt;
      &amp;lt;wsdl:output message=&amp;quot;tns:returnMessage&amp;quot; name=&amp;quot;ServerSayHiResponse&amp;quot;/&amp;gt;&lt;br /&gt;
  &amp;lt;/wsdl:operation&amp;gt;&lt;br /&gt;
    &amp;lt;/wsdl:portType&amp;gt;&lt;br /&gt;
    &amp;lt;wsdl:portType name=&amp;quot;ServerPortType&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;wsdl:operation name=&amp;quot;RegisterCallback&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;wsdl:input message=&amp;quot;tns:register_callback&amp;quot; name=&amp;quot;RegisterCallbackRequest&amp;quot;/&amp;gt;&lt;br /&gt;
      &amp;lt;wsdl:output message=&amp;quot;tns:returnMessage&amp;quot; name=&amp;quot;RegisterCallbackResponse&amp;quot;/&amp;gt;&lt;br /&gt;
  &amp;lt;/wsdl:operation&amp;gt;&lt;br /&gt;
    &amp;lt;/wsdl:portType&amp;gt;&lt;br /&gt;
    &amp;lt;wsdl:binding name=&amp;quot;CallbackPortType_SOAPBinding&amp;quot; type=&amp;quot;tns:CallbackPortType&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;soap:binding style=&amp;quot;document&amp;quot; transport=&amp;quot;http://schemas.xmlsoap.org/soap/http&amp;quot;/&amp;gt;&lt;br /&gt;
  &amp;lt;wsdl:operation name=&amp;quot;ServerSayHi&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;soap:operation soapAction=&amp;quot;&amp;quot; style=&amp;quot;document&amp;quot;/&amp;gt;&lt;br /&gt;
      &amp;lt;wsdl:input name=&amp;quot;ServerSayHiRequest&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;soap:body use=&amp;quot;literal&amp;quot;/&amp;gt;&lt;br /&gt;
      &amp;lt;/wsdl:input&amp;gt;&lt;br /&gt;
      &amp;lt;wsdl:output name=&amp;quot;ServerSayHiResponse&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;soap:body use=&amp;quot;literal&amp;quot;/&amp;gt;&lt;br /&gt;
      &amp;lt;/wsdl:output&amp;gt;&lt;br /&gt;
  &amp;lt;/wsdl:operation&amp;gt;&lt;br /&gt;
    &amp;lt;/wsdl:binding&amp;gt;&lt;br /&gt;
    &amp;lt;wsdl:binding name=&amp;quot;ServerPortType_SOAPBinding&amp;quot; type=&amp;quot;tns:ServerPortType&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;soap:binding style=&amp;quot;document&amp;quot; transport=&amp;quot;http://schemas.xmlsoap.org/soap/http&amp;quot;/&amp;gt;&lt;br /&gt;
  &amp;lt;wsdl:operation name=&amp;quot;RegisterCallback&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;soap:operation soapAction=&amp;quot;&amp;quot; style=&amp;quot;document&amp;quot;/&amp;gt;&lt;br /&gt;
      &amp;lt;wsdl:input name=&amp;quot;RegisterCallbackRequest&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;soap:body use=&amp;quot;literal&amp;quot;/&amp;gt;&lt;br /&gt;
      &amp;lt;/wsdl:input&amp;gt;&lt;br /&gt;
      &amp;lt;wsdl:output name=&amp;quot;RegisterCallbackResponse&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;soap:body use=&amp;quot;literal&amp;quot;/&amp;gt;&lt;br /&gt;
      &amp;lt;/wsdl:output&amp;gt;&lt;br /&gt;
  &amp;lt;/wsdl:operation&amp;gt;&lt;br /&gt;
    &amp;lt;/wsdl:binding&amp;gt;&lt;br /&gt;
    &amp;lt;wsdl:service name=&amp;quot;CallbackService&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;wsdl:port binding=&amp;quot;tns:CallbackPortType_SOAPBinding&amp;quot; name=&amp;quot;CallbackPort&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;soap:address location=&amp;quot;http://localhost:9005/CallbackContext/CallbackPort&amp;quot;/&amp;gt;&lt;br /&gt;
  &amp;lt;/wsdl:port&amp;gt;&lt;br /&gt;
    &amp;lt;/wsdl:service&amp;gt;&lt;br /&gt;
    &amp;lt;wsdl:service name=&amp;quot;SOAPService&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;wsdl:port binding=&amp;quot;tns:ServerPortType_SOAPBinding&amp;quot; name=&amp;quot;SOAPPort&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;soap:address location=&amp;quot;http://localhost:9000/SoapContext/SoapPort&amp;quot;/&amp;gt;&lt;br /&gt;
  &amp;lt;/wsdl:port&amp;gt;&lt;br /&gt;
    &amp;lt;/wsdl:service&amp;gt;&lt;br /&gt;
&amp;lt;/wsdl:definitions&amp;gt;&lt;br /&gt;
        &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== This demo shows how JAX-WS handlers are used ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
Handler Demo&lt;br /&gt;
============&lt;br /&gt;
This demo shows how JAX-WS handlers are used.  The server uses a&lt;br /&gt;
SOAP protocol handler which logs incoming and outgoing messages&lt;br /&gt;
to the console.  &lt;br /&gt;
The server code registers a handler using the @HandlerChain annotation&lt;br /&gt;
within the service implementation class. For this demo, LoggingHandler&lt;br /&gt;
is SOAPHandler that logs the entire SOAP message content to stdout.&lt;br /&gt;
The client includes a logical handler that checks the parameters on&lt;br /&gt;
outbound requests and short-circuits the invocation in certain&lt;br /&gt;
circumstances. This handler is specified programatically.&lt;br /&gt;
Please review the README in the samples directory before continuing.&lt;br /&gt;
&lt;br /&gt;
Prerequisite&lt;br /&gt;
------------&lt;br /&gt;
If your environment already includes cxf-manifest-incubator.jar on the CLASSPATH,&lt;br /&gt;
and the JDK and ant bin directories on the PATH, it is not necessary to&lt;br /&gt;
set the environment as described in the samples directory&amp;quot;s README.&lt;br /&gt;
If your environment is not properly configured, or if you are planning&lt;br /&gt;
on using wsdl2java, javac, and java to build and run the demos, you must&lt;br /&gt;
set the environment.&lt;br /&gt;
&lt;br /&gt;
Building and running the demo using ant&lt;br /&gt;
---------------------------------------&lt;br /&gt;
From the samples/handlers directory, the ant build script can be used to&lt;br /&gt;
build and run the demo. The server and client targets automatically build&lt;br /&gt;
the demo.&lt;br /&gt;
Using either UNIX or Windows:&lt;br /&gt;
  ant server &lt;br /&gt;
  ant client&lt;br /&gt;
When using these ant targets, the server process uses the LoggingHandler&lt;br /&gt;
and the client process uses the SmallNumberHandler. Notice that both&lt;br /&gt;
the client and server consoles display short informative messages. The &lt;br /&gt;
client handler examines the operation parameters and, based on the &lt;br /&gt;
parameter values, may decide not to forward the request to the server. The server &lt;br /&gt;
handler displays the entire content of each message in its console. &lt;br /&gt;
The @HandlerChain annotation in the implementation class indicates that &lt;br /&gt;
the file demo_handler.xml includes the information needed to identify the&lt;br /&gt;
handler class.&lt;br /&gt;
  @HandlerChain(file = &amp;quot;../common/demo_handlers.xml&amp;quot;, name = &amp;quot;DemoHandlerChain&amp;quot;)&lt;br /&gt;
The client side SmallNumberHandler is specified programatically:&lt;br /&gt;
    SmallNumberHandler sh = new SmallNumberHandler();&lt;br /&gt;
    List&amp;lt;Handler&amp;gt; newHandlerChain = new ArrayList&amp;lt;Handler&amp;gt;();&lt;br /&gt;
    newHandlerChain.add(sh);&lt;br /&gt;
    ((BindingProvider)port).getBinding().setHandlerChain(newHandlerChain);&lt;br /&gt;
&lt;br /&gt;
After running the client, terminate the server process.&lt;br /&gt;
To remove the code generated from the WSDL file and the .class&lt;br /&gt;
files, run:&lt;br /&gt;
  ant clean&lt;br /&gt;
&lt;br /&gt;
Building the demo using wsdl2java and javac&lt;br /&gt;
-------------------------------------------&lt;br /&gt;
From the samples/handlers directory, first create the target directory&lt;br /&gt;
build/classes and then generate code from the WSDL file.&lt;br /&gt;
For UNIX:&lt;br /&gt;
  mkdir -p build/classes&lt;br /&gt;
  wsdl2java -d build/classes -compile ./wsdl/addNumbers.wsdl&lt;br /&gt;
For Windows:&lt;br /&gt;
  mkdir build\classes&lt;br /&gt;
    Must use back slashes.&lt;br /&gt;
  wsdl2java -d build\classes -compile .\wsdl\addNumbers.wsdl&lt;br /&gt;
    May use either forward or back slashes.&lt;br /&gt;
Now compile the provided client and server applications with the commands:&lt;br /&gt;
For UNIX:  &lt;br /&gt;
  &lt;br /&gt;
  export CLASSPATH=$CLASSPATH:$CXF_HOME/lib/cxf-manifest-incubator.jar:./build/classes&lt;br /&gt;
  javac -d build/classes src/demo/handlers/common/*.java&lt;br /&gt;
  javac -d build/classes src/demo/handlers/client/*.java&lt;br /&gt;
  javac -d build/classes src/demo/handlers/server/*.java&lt;br /&gt;
For Windows:&lt;br /&gt;
  set classpath=%classpath%;%CXF_HOME%\lib\cxf-manifest-incubator.jar;.\build\classes&lt;br /&gt;
  javac -d build\classes src\demo\handlers\common\*.java&lt;br /&gt;
  javac -d build\classes src\demo\handlers\client\*.java&lt;br /&gt;
  javac -d build\classes src\demo\handlers\server\*.java&lt;br /&gt;
Finally, copy the demo_handlers.xml file from the src/demo/handlers/common&lt;br /&gt;
directory into the build/classes/demo/handlers/common directory.&lt;br /&gt;
For UNIX:&lt;br /&gt;
  cp ./src/demo/handlers/common/demo_handlers.xml ./build/classes/demo/handlers/common&lt;br /&gt;
For Windows:&lt;br /&gt;
  copy src\demo\handlers\common\demo_handlers.xml build\classes\demo\handlers\common&lt;br /&gt;
&lt;br /&gt;
Running the demo using java&lt;br /&gt;
---------------------------&lt;br /&gt;
From the samples/handlers directory run the commands (entered on a single command line):&lt;br /&gt;
For UNIX (must use forward slashes):&lt;br /&gt;
    java -Djava.util.logging.config.file=$CXF_HOME%/etc/logging.properties&lt;br /&gt;
         demo.handlers.server.Server &amp;amp;&lt;br /&gt;
    java -Djava.util.logging.config.file=$CXF_HOME%/etc/logging.properties&lt;br /&gt;
         demo.handlers.client.Client ./wsdl/addNumbers.wsdl&lt;br /&gt;
The server process starts in the background.&lt;br /&gt;
For Windows (may use either forward or back slashes):&lt;br /&gt;
  start &lt;br /&gt;
    java -Djava.util.logging.config.file=%CXF_HOME%\etc\logging.properties&lt;br /&gt;
         demo.handlers.server.Server&lt;br /&gt;
    java -Djava.util.logging.config.file=%CXF_HOME%\etc\logging.properties&lt;br /&gt;
         demo.handlers.client.Client .\wsdl\addNumbers.wsdl&lt;br /&gt;
The server process starts in a new command window.&lt;br /&gt;
After running the client, terminate the server process.&lt;br /&gt;
To remove the code generated from the WSDL file and the .class&lt;br /&gt;
files, either delete the build directory and its contents or run:&lt;br /&gt;
  ant clean&lt;br /&gt;
&lt;br /&gt;
        &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== This demo shows how to develope an user interceptor and add the interceptor into the interceptor chain through configuration ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
Stream GZIP Interceptor Demo &lt;br /&gt;
============================&lt;br /&gt;
This demo shows how to develope an user interceptor and add&lt;br /&gt;
the interceptor into the interceptor chain through configuration.&lt;br /&gt;
Please review the README in the samples directory before&lt;br /&gt;
continuing.&lt;br /&gt;
Prerequisite&lt;br /&gt;
------------&lt;br /&gt;
If your environment already includes cxf-manifest-incubator.jar on the&lt;br /&gt;
CLASSPATH, and the JDK and ant bin directories on the PATH&lt;br /&gt;
it is not necessary to set the environment as described in&lt;br /&gt;
the samples directory README.  If your environment is not&lt;br /&gt;
properly configured, or if you are planning on using wsdl2java,&lt;br /&gt;
javac, and java to build and run the demos, you must set the&lt;br /&gt;
environment.&lt;br /&gt;
&lt;br /&gt;
Building and running the demo using ant&lt;br /&gt;
---------------------------------------&lt;br /&gt;
From the samples/streamInterceptor directory, the ant build script&lt;br /&gt;
can be used to build and run the demo.&lt;br /&gt;
Using either UNIX or Windows:&lt;br /&gt;
  ant build&lt;br /&gt;
  ant server&lt;br /&gt;
  ant client&lt;br /&gt;
    &lt;br /&gt;
To remove the code generated from the WSDL file and the .class&lt;br /&gt;
files, run:&lt;br /&gt;
  ant clean&lt;br /&gt;
Building the demo using wsdl2java and javac&lt;br /&gt;
-------------------------------------------&lt;br /&gt;
From the samples/streamInterceptor directory, first create the target&lt;br /&gt;
directory build/classes and then generate code from the WSDL file.&lt;br /&gt;
For UNIX:&lt;br /&gt;
  mkdir -p build/classes&lt;br /&gt;
  wsdl2java -d build/classes -compile ./wsdl/hello_world.wsdl&lt;br /&gt;
For Windows:&lt;br /&gt;
  mkdir build\classes&lt;br /&gt;
    Must use back slashes.&lt;br /&gt;
  wsdl2java -d build\classes -compile .\wsdl\hello_world.wsdl&lt;br /&gt;
    May use either forward or back slashes.&lt;br /&gt;
Now compile the provided client and server applications with the commands:&lt;br /&gt;
For UNIX:  &lt;br /&gt;
  &lt;br /&gt;
  export CLASSPATH=$CLASSPATH:$CXF_HOME/lib/cxf-manifest-incubator.jar:./build/classes&lt;br /&gt;
  javac -d build/classes src/demo/stream/interceptor/*.java&lt;br /&gt;
  javac -d build/classes src/demo/stream/client/*.java&lt;br /&gt;
  javac -d build/classes src/demo/stream/server/*.java&lt;br /&gt;
For Windows:&lt;br /&gt;
  set classpath=%classpath%;%CXF_HOME%\lib\cxf-manifest-incubator.jar;.\build\classes&lt;br /&gt;
  javac -d build\classes src\demo\stream\interceptor\*.java&lt;br /&gt;
  javac -d build\classes src\demo\stream\client\*.java&lt;br /&gt;
  javac -d build\classes src\demo\stream\server\*.java&lt;br /&gt;
&lt;br /&gt;
Running the demo using java&lt;br /&gt;
---------------------------&lt;br /&gt;
From the samples/streamInterceptor directory run the commands, entered on a&lt;br /&gt;
single command line:&lt;br /&gt;
For UNIX (must use forward slashes):&lt;br /&gt;
    java -Dcxf.config.file=server.xml&lt;br /&gt;
         demo.stream.server.Server &amp;amp;&lt;br /&gt;
    java -Dcxf.config.file=client.xml&lt;br /&gt;
         demo.stream.client.Client ./wsdl/hello_world.wsdl&lt;br /&gt;
The server process starts in the background.  After running the client,&lt;br /&gt;
use the kill command to terminate the server process.&lt;br /&gt;
For Windows (may use either forward or back slashes):&lt;br /&gt;
  start &lt;br /&gt;
    java -Dcxf.config.file=server.xml&lt;br /&gt;
         demo.stream.server.Server&lt;br /&gt;
    java -Dcxf.config.file=client.xml&lt;br /&gt;
       demo.stream.client.Client .\wsdl\hello_world.wsdl&lt;br /&gt;
A new command windows opens for the server process.  After running the&lt;br /&gt;
client, terminate the server process by issuing Ctrl-C in its command window.&lt;br /&gt;
To remove the code generated from the WSDL file and the .class&lt;br /&gt;
files, either delete the build directory and its contents or run:&lt;br /&gt;
  ant clean&lt;br /&gt;
&lt;br /&gt;
        &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;/div&gt;</summary>
		<author><name>Admin</name></author>	</entry>

	<entry>
		<id>http://jexp.ru/index.php?title=Java/Web_Services_SOA/JiBX&amp;diff=9211</id>
		<title>Java/Web Services SOA/JiBX</title>
		<link rel="alternate" type="text/html" href="http://jexp.ru/index.php?title=Java/Web_Services_SOA/JiBX&amp;diff=9211"/>
				<updated>2010-06-01T07:27:40Z</updated>
		
		<summary type="html">&lt;p&gt;Admin: 1 версия&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Deploying a JiBX generated service ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
Axis2 Quick Start Guide- (JiBX)&lt;br /&gt;
======================================&lt;br /&gt;
Introduction&lt;br /&gt;
============&lt;br /&gt;
In this sample, we are deploying a JiBX generated service. The service&lt;br /&gt;
is tested using generated client stubs.&lt;br /&gt;
Pre-Requisites&lt;br /&gt;
==============&lt;br /&gt;
Apache Ant 1.6.2 or later&lt;br /&gt;
Building the Service&lt;br /&gt;
====================&lt;br /&gt;
Type &amp;quot;ant generate.service&amp;quot; from Axis2_HOME/samples/quickstartjibx&lt;br /&gt;
directory and then deploy the &lt;br /&gt;
Axis2_HOME/samples/quickstartjibx/build/service/build/lib/StockQuoteService.aar&lt;br /&gt;
Running the Client&lt;br /&gt;
==================&lt;br /&gt;
type ant run.client in the Axis2_HOME/samples/quickstartadb directory&lt;br /&gt;
Help&lt;br /&gt;
====&lt;br /&gt;
Please contact axis-user list (axis-user@ws.apache.org) if you&lt;br /&gt;
have any trouble running the sample.&lt;br /&gt;
        &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== JiBX, AXIS2 web services 1 ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== JiBX, AXIS2 web services 2 ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== JiBX, AXIS2 web services 3 ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== JiBX, AXIS2 web services: JiBX to WSDL ==&lt;/div&gt;</summary>
		<author><name>Admin</name></author>	</entry>

	<entry>
		<id>http://jexp.ru/index.php?title=Java/Web_Services_SOA/JavaScript_SOAP&amp;diff=9207</id>
		<title>Java/Web Services SOA/JavaScript SOAP</title>
		<link rel="alternate" type="text/html" href="http://jexp.ru/index.php?title=Java/Web_Services_SOA/JavaScript_SOAP&amp;diff=9207"/>
				<updated>2010-06-01T07:27:37Z</updated>
		
		<summary type="html">&lt;p&gt;Admin: 1 версия&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Axis2 client API has facilities to accept responses in JSON ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
Sample for Yahoo - Search - JSON&lt;br /&gt;
=================================&lt;br /&gt;
Introduction&lt;br /&gt;
============&lt;br /&gt;
Axis2 client API has facilities to accept responses in JSON.&lt;br /&gt;
Yahoo provides an API to call its search service and retrieve JSON responses. This sample demonstrates how to call Yahoo&lt;br /&gt;
search service using an Axis2 client which accepts a JSON response.&lt;br /&gt;
Pre-Requisites&lt;br /&gt;
==============&lt;br /&gt;
Apache Ant 1.6.2 or later&lt;br /&gt;
Running The Sample&lt;br /&gt;
==================&lt;br /&gt;
Type &amp;quot;ant&amp;quot; from Axis2_HOME/samples/yahoojsonsearch directory.&lt;br /&gt;
Help&lt;br /&gt;
====&lt;br /&gt;
Please contact axis-user list (axis-user@ws.apache.org) if you have any trouble running the sample.&lt;br /&gt;
&lt;br /&gt;
        &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== The client demo demonstrates the use of (non-browser) JavaScript to call a CXF server ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
Hello World Client Demo using JavaScript &lt;br /&gt;
=========================================================&lt;br /&gt;
The client demo demonstrates the use of (non-browser)&lt;br /&gt;
JavaScript to call a CXF server.&lt;br /&gt;
The client side makes call by JAXWS. It uses the Mozilla Rhino library &lt;br /&gt;
to read the JavaScript file and run it.&lt;br /&gt;
&lt;br /&gt;
Building and running the demo server using ant&lt;br /&gt;
---------------------------------------&lt;br /&gt;
From the samples/hello_world directory, the ant build script&lt;br /&gt;
can be used to build and run the demo.&lt;br /&gt;
Using either UNIX or Windows:&lt;br /&gt;
  ant build&lt;br /&gt;
  ant server  (in the background or another window)&lt;br /&gt;
To remove the code generated from the WSDL file and the .class&lt;br /&gt;
files, run:&lt;br /&gt;
  ant clean&lt;br /&gt;
Running the JavaScript client&lt;br /&gt;
-----------------------------&lt;br /&gt;
In another command line window, run the ant &amp;quot;client&amp;quot; target from &lt;br /&gt;
the build.xml file located in the same directory as this README.&lt;br /&gt;
Using either UNIX or Windows:&lt;br /&gt;
  ant client&lt;br /&gt;
When running the client, you can terminate the server process by issuing &lt;br /&gt;
Ctrl-C in its command window.&lt;br /&gt;
The client will show this output:&lt;br /&gt;
invoke sayHi().   return Bonjour&lt;br /&gt;
invoke greetMe(String).   return Hello Jeff&lt;br /&gt;
The same time, the server will give this output:&lt;br /&gt;
     [java] Executing operation sayHi&lt;br /&gt;
     [java] Executing operation greetMe&lt;br /&gt;
     [java] Message received: Jeff&lt;br /&gt;
&lt;br /&gt;
////////////////////////////////////////////////////////////////&lt;br /&gt;
/**&lt;br /&gt;
 * Licensed to the Apache Software Foundation (ASF) under one&lt;br /&gt;
 * or more contributor license agreements. See the NOTICE file&lt;br /&gt;
 * distributed with this work for additional information&lt;br /&gt;
 * regarding copyright ownership. The ASF licenses this file&lt;br /&gt;
 * to you under the Apache License, Version 2.0 (the&lt;br /&gt;
 * &amp;quot;License&amp;quot;); you may not use this file except in compliance&lt;br /&gt;
 * with the License. You may obtain a copy of the License at&lt;br /&gt;
 *&lt;br /&gt;
 * http://www.apache.org/licenses/LICENSE-2.0&lt;br /&gt;
 *&lt;br /&gt;
 * Unless required by applicable law or agreed to in writing,&lt;br /&gt;
 * software distributed under the License is distributed on an&lt;br /&gt;
 * &amp;quot;AS IS&amp;quot; BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY&lt;br /&gt;
 * KIND, either express or implied. See the License for the&lt;br /&gt;
 * specific language governing permissions and limitations&lt;br /&gt;
 * under the License.&lt;br /&gt;
 */&lt;br /&gt;
importPackage(Packages.java.io);&lt;br /&gt;
importPackage(Packages.javax.xml.namespace);&lt;br /&gt;
importPackage(Packages.org.apache.hello_world_soap_http);&lt;br /&gt;
var qname=new Packages.javax.xml.namespace.QName(&amp;quot;http://apache.org/hello_world_soap_http&amp;quot;, &amp;quot;SOAPService&amp;quot;);&lt;br /&gt;
var curpath=new File(&amp;quot;..&amp;quot;);&lt;br /&gt;
var sepa=File.separator;&lt;br /&gt;
var hwpath=curpath.getAbsolutePath()+sepa+&amp;quot;hello_world&amp;quot;+sepa+&amp;quot;wsdl&amp;quot;+sepa+&amp;quot;hello_world.wsdl&amp;quot;;&lt;br /&gt;
var url = new File(hwpath).toURL();&lt;br /&gt;
var ss=new SOAPService(url,qname);&lt;br /&gt;
var port = ss.getSoapPort();&lt;br /&gt;
var resp=port.sayHi();&lt;br /&gt;
print(&amp;quot;invoke sayHi().   return &amp;quot; + resp);&lt;br /&gt;
resp=port.greetMe(&amp;quot;Jeff&amp;quot;);&lt;br /&gt;
print(&amp;quot;invoke greetMe(String).   return &amp;quot; + resp);&lt;br /&gt;
        &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== The demo demonstrates the use of the JavaScript and E4X dynamic languages to implement JAX-WS Providers ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
Hello World Demo using JavaScript and E4X Implementations&lt;br /&gt;
=========================================================&lt;br /&gt;
The demo demonstrates the use of the JavaScript and E4X dynamic&lt;br /&gt;
languages to implement JAX-WS Providers.&lt;br /&gt;
The client side makes two Dispatch-based invocations. The first uses&lt;br /&gt;
SOAPMessage data in MESSAGE mode, and the second uses DOMSource in&lt;br /&gt;
PAYLOAD mode. The first service is implemented using E4X, the second&lt;br /&gt;
using JavaScript.&lt;br /&gt;
The two messages are constructed by reading in the XML files found in&lt;br /&gt;
the demo/hwDispatch/client directory.&lt;br /&gt;
Please review the README in the samples directory before&lt;br /&gt;
continuing.&lt;br /&gt;
&lt;br /&gt;
Prerequisite&lt;br /&gt;
------------&lt;br /&gt;
If your environment already includes cxf-manifest-incubator.jar on the&lt;br /&gt;
CLASSPATH, and the JDK and ant bin directories on the PATH&lt;br /&gt;
it is not necessary to set the environment as described in&lt;br /&gt;
the samples directory&amp;quot;s README.  If your environment is not&lt;br /&gt;
properly configured, or if you are planning on using wsdl2java,&lt;br /&gt;
javac, and java to build and run the demos, you must set the&lt;br /&gt;
environment.&lt;br /&gt;
&lt;br /&gt;
Building and running the demo using ant&lt;br /&gt;
---------------------------------------&lt;br /&gt;
From the samples/js_provider directory, the ant build script&lt;br /&gt;
can be used to build and run the demo.&lt;br /&gt;
Using either UNIX or Windows:&lt;br /&gt;
  ant build&lt;br /&gt;
  ant server  (in the background or another window)&lt;br /&gt;
  ant client&lt;br /&gt;
    &lt;br /&gt;
To remove the code generated from the WSDL file and the .class&lt;br /&gt;
files, run:&lt;br /&gt;
  ant clean&lt;br /&gt;
&lt;br /&gt;
Building the demo using wsdl2java and javac&lt;br /&gt;
-------------------------------------------&lt;br /&gt;
From the samples/dispatch_provider directory, first create the target&lt;br /&gt;
directory build/classes and then generate code from the WSDL file.&lt;br /&gt;
For UNIX:&lt;br /&gt;
  mkdir -p build/classes&lt;br /&gt;
  wsdl2java -d build/classes ./wsdl/hello_world.wsdl&lt;br /&gt;
For Windows:&lt;br /&gt;
  mkdir build\classes&lt;br /&gt;
    Must use back slashes.&lt;br /&gt;
  wsdl2java -d build\classes .\wsdl\hello_world.wsdl&lt;br /&gt;
    May use either forward or back slashes.&lt;br /&gt;
Now compile both the generated code and the provided client&lt;br /&gt;
application with the commands:&lt;br /&gt;
For UNIX:&lt;br /&gt;
  export CLASSPATH=$CLASSPATH:$CXF_HOME/lib/cxf-manifest-incubator.jar:&lt;br /&gt;
  $CXF_HOME/lib/js-1.6R5.jar:$CXF_HOME/lib/xbean-2.2.0.jar:&lt;br /&gt;
  build/classes&lt;br /&gt;
  javac -d build/classes src/demo/hwDispatch/client/*.java&lt;br /&gt;
For Windows:&lt;br /&gt;
  set CLASSPATH=%CLASSPATH%;%CXF_HOME%\lib\cxf-manifest-incubator.jar;&lt;br /&gt;
  %CXF_HOME%\lib\js-1.6R5.jar;%CXF_HOME%\lib\xbean-2.2.0.jar;&lt;br /&gt;
  build\classes&lt;br /&gt;
  javac -d build\classes src\demo\hwDispatch\client\*.java&lt;br /&gt;
Windows may use either forward or back slashes.&lt;br /&gt;
Since JavaScript and E4X are interpreted at runtime and do not require&lt;br /&gt;
compilation, there is no server-side java code requiring compilation.&lt;br /&gt;
&lt;br /&gt;
Finally, copy resource files into the build/classes directory with the commands:&lt;br /&gt;
For UNIX:    &lt;br /&gt;
  cp ./src/demo/hwDispatch/client/*.xml ./build/classes/demo/hwDispatch/client&lt;br /&gt;
For Windows:&lt;br /&gt;
  copy src\demo\hwDispatch\client\*.xml build\classes\demo\hwDispatch\client&lt;br /&gt;
&lt;br /&gt;
Running the demo using java&lt;br /&gt;
---------------------------&lt;br /&gt;
From the samples/js_dispatch directory run the commands, entered on a&lt;br /&gt;
single command line:&lt;br /&gt;
For UNIX (must use forward slashes):&lt;br /&gt;
    java -Djava.util.logging.config.file=$CXF_HOME/etc/logging.properties&lt;br /&gt;
         org.apache.cxf.js.rhino.ServerApp -v&lt;br /&gt;
         -b http://localhost:9000/SoapContext impl.jsx impl.js&lt;br /&gt;
    java -Djava.util.logging.config.file=$CXF_HOME/etc/logging.properties&lt;br /&gt;
         demo.hwDispatch.client.Client ./wsdl/hello_world.wsdl&lt;br /&gt;
The server process starts in the background.  After running the client,&lt;br /&gt;
use the kill command to terminate the server process.&lt;br /&gt;
For Windows (may use either forward or back slashes):&lt;br /&gt;
  start &lt;br /&gt;
    java -Djava.util.logging.config.file=%CXF_HOME%\etc\logging.properties&lt;br /&gt;
         org.apache.cxf.js.rhino.ServerApp -v&lt;br /&gt;
         -b http://localhost:9000/SoapContext impl.jsx impl.js&lt;br /&gt;
    java -Djava.util.logging.config.file=%CXF_HOME%\etc\logging.properties&lt;br /&gt;
       demo.hwDispatch.client.Client .\wsdl\hello_world.wsdl&lt;br /&gt;
A new command windows opens for the server process.  After running the&lt;br /&gt;
client, terminate the server process by issuing Ctrl-C in its command window.&lt;br /&gt;
To remove the code generated from the WSDL file and the .class&lt;br /&gt;
files, either delete the build directory and its contents or run:&lt;br /&gt;
  ant clean&lt;br /&gt;
&lt;br /&gt;
///////////////////////////////////////////////////////////////////////&lt;br /&gt;
/**&lt;br /&gt;
 * Licensed to the Apache Software Foundation (ASF) under one&lt;br /&gt;
 * or more contributor license agreements. See the NOTICE file&lt;br /&gt;
 * distributed with this work for additional information&lt;br /&gt;
 * regarding copyright ownership. The ASF licenses this file&lt;br /&gt;
 * to you under the Apache License, Version 2.0 (the&lt;br /&gt;
 * &amp;quot;License&amp;quot;); you may not use this file except in compliance&lt;br /&gt;
 * with the License. You may obtain a copy of the License at&lt;br /&gt;
 *&lt;br /&gt;
 * http://www.apache.org/licenses/LICENSE-2.0&lt;br /&gt;
 *&lt;br /&gt;
 * Unless required by applicable law or agreed to in writing,&lt;br /&gt;
 * software distributed under the License is distributed on an&lt;br /&gt;
 * &amp;quot;AS IS&amp;quot; BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY&lt;br /&gt;
 * KIND, either express or implied. See the License for the&lt;br /&gt;
 * specific language governing permissions and limitations&lt;br /&gt;
 * under the License.&lt;br /&gt;
 */&lt;br /&gt;
package demo.hwDispatch.client;&lt;br /&gt;
import java.io.File;&lt;br /&gt;
import java.io.InputStream;&lt;br /&gt;
import java.net.URL;&lt;br /&gt;
import javax.xml.namespace.QName;&lt;br /&gt;
import javax.xml.soap.MessageFactory;&lt;br /&gt;
import javax.xml.soap.SOAPMessage;&lt;br /&gt;
import javax.xml.transform.dom.DOMSource;&lt;br /&gt;
import javax.xml.ws.Dispatch;&lt;br /&gt;
import javax.xml.ws.Service.Mode;&lt;br /&gt;
import org.apache.hello_world_soap_http.SOAPService1;&lt;br /&gt;
import org.apache.hello_world_soap_http.SOAPService3;&lt;br /&gt;
public final class Client {&lt;br /&gt;
    private Client() {&lt;br /&gt;
    }&lt;br /&gt;
    public static void main(String args[]) throws Exception {&lt;br /&gt;
        if (args.length == 0) {&lt;br /&gt;
            System.out.println(&amp;quot;please specify wsdl&amp;quot;);&lt;br /&gt;
            System.exit(1);&lt;br /&gt;
        }&lt;br /&gt;
        URL wsdlURL;&lt;br /&gt;
        File wsdlFile = new File(args[0]);&lt;br /&gt;
        if (wsdlFile.exists()) {&lt;br /&gt;
            wsdlURL = wsdlFile.toURL();&lt;br /&gt;
        } else {&lt;br /&gt;
            wsdlURL = new URL(args[0]);&lt;br /&gt;
        }&lt;br /&gt;
        MessageFactory factory = MessageFactory.newInstance();&lt;br /&gt;
        System.out.println(wsdlURL + &amp;quot;\n\n&amp;quot;);&lt;br /&gt;
        final String ns = &amp;quot;http://apache.org/hello_world_soap_http&amp;quot;;&lt;br /&gt;
        QName serviceName1 = new QName(ns, &amp;quot;SOAPService1&amp;quot;);&lt;br /&gt;
        QName portName1 = new QName(ns, &amp;quot;SoapPort1&amp;quot;);&lt;br /&gt;
        SOAPService1 service1 = new SOAPService1(wsdlURL, serviceName1);&lt;br /&gt;
        InputStream is1 =  Client.class.getResourceAsStream(&amp;quot;GreetMeDocLiteralReq1.xml&amp;quot;);&lt;br /&gt;
        SOAPMessage soapReq1 = factory.createMessage(null, is1);&lt;br /&gt;
        Dispatch&amp;lt;SOAPMessage&amp;gt; dispSOAPMsg = service1.createDispatch(portName1,&lt;br /&gt;
                                                                    SOAPMessage.class, Mode.MESSAGE);&lt;br /&gt;
        System.out.println(&amp;quot;Invoking server through Dispatch interface using SOAPMessage&amp;quot;);&lt;br /&gt;
        SOAPMessage soapResp = dispSOAPMsg.invoke(soapReq1);&lt;br /&gt;
        System.out.println(&amp;quot;Response from server: &amp;quot; + soapResp.getSOAPBody().getTextContent());&lt;br /&gt;
        QName serviceName3 = new QName(ns, &amp;quot;SOAPService3&amp;quot;);&lt;br /&gt;
        QName portName3 = new QName(ns, &amp;quot;SoapPort3&amp;quot;);&lt;br /&gt;
        SOAPService3 service3 = new SOAPService3(wsdlURL, serviceName3);&lt;br /&gt;
        InputStream is3 =  Client.class.getResourceAsStream(&amp;quot;GreetMeDocLiteralReq3.xml&amp;quot;);&lt;br /&gt;
        SOAPMessage soapReq3 = MessageFactory.newInstance().createMessage(null, is3);&lt;br /&gt;
        DOMSource domReqPayload = new DOMSource(soapReq3.getSOAPBody().extractContentAsDocument());&lt;br /&gt;
        Dispatch&amp;lt;DOMSource&amp;gt; dispDOMSrcPayload = service3.createDispatch(portName3,&lt;br /&gt;
                                                                        DOMSource.class, Mode.PAYLOAD);&lt;br /&gt;
        System.out.println(&amp;quot;Invoking server through Dispatch interface using DOMSource in PAYLOAD Mode&amp;quot;);&lt;br /&gt;
        DOMSource domRespPayload = dispDOMSrcPayload.invoke(domReqPayload);&lt;br /&gt;
        System.out.println(&amp;quot;Response from server: &amp;quot;&lt;br /&gt;
                           + domRespPayload.getNode().getFirstChild().getTextContent());&lt;br /&gt;
        System.exit(0);&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
////////////////////////////////////////////////////////////////////////////////&lt;br /&gt;
&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot;?&amp;gt;&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
  Licensed to the Apache Software Foundation (ASF) under one&lt;br /&gt;
  or more contributor license agreements. See the NOTICE file&lt;br /&gt;
  distributed with this work for additional information&lt;br /&gt;
  regarding copyright ownership. The ASF licenses this file&lt;br /&gt;
  to you under the Apache License, Version 2.0 (the&lt;br /&gt;
  &amp;quot;License&amp;quot;); you may not use this file except in compliance&lt;br /&gt;
  with the License. You may obtain a copy of the License at&lt;br /&gt;
 &lt;br /&gt;
  http://www.apache.org/licenses/LICENSE-2.0&lt;br /&gt;
 &lt;br /&gt;
  Unless required by applicable law or agreed to in writing,&lt;br /&gt;
  software distributed under the License is distributed on an&lt;br /&gt;
  &amp;quot;AS IS&amp;quot; BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY&lt;br /&gt;
  KIND, either express or implied. See the License for the&lt;br /&gt;
  specific language governing permissions and limitations&lt;br /&gt;
  under the License.&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&amp;lt;wsdl:definitions name=&amp;quot;HelloWorld&amp;quot; targetNamespace=&amp;quot;http://apache.org/hello_world_soap_http&amp;quot; &lt;br /&gt;
    xmlns=&amp;quot;http://schemas.xmlsoap.org/wsdl/&amp;quot; &lt;br /&gt;
    xmlns:soap=&amp;quot;http://schemas.xmlsoap.org/wsdl/soap/&amp;quot; &lt;br /&gt;
    xmlns:tns=&amp;quot;http://apache.org/hello_world_soap_http&amp;quot;&lt;br /&gt;
    xmlns:x1=&amp;quot;http://apache.org/hello_world_soap_http/types&amp;quot;&lt;br /&gt;
    xmlns:wsdl=&amp;quot;http://schemas.xmlsoap.org/wsdl/&amp;quot; &lt;br /&gt;
    xmlns:xsd=&amp;quot;http://www.w3.org/2001/XMLSchema&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;wsdl:types&amp;gt;&lt;br /&gt;
        &amp;lt;schema targetNamespace=&amp;quot;http://apache.org/hello_world_soap_http/types&amp;quot; &lt;br /&gt;
            xmlns=&amp;quot;http://www.w3.org/2001/XMLSchema&amp;quot; elementFormDefault=&amp;quot;qualified&amp;quot;&amp;gt;&lt;br /&gt;
            &amp;lt;element name=&amp;quot;sayHi&amp;quot;&amp;gt;&lt;br /&gt;
                &amp;lt;complexType/&amp;gt;&lt;br /&gt;
            &amp;lt;/element&amp;gt;&lt;br /&gt;
            &amp;lt;element name=&amp;quot;sayHiResponse&amp;quot;&amp;gt;&lt;br /&gt;
                &amp;lt;complexType&amp;gt;&lt;br /&gt;
                    &amp;lt;sequence&amp;gt;&lt;br /&gt;
                        &amp;lt;element name=&amp;quot;responseType&amp;quot; type=&amp;quot;xsd:string&amp;quot;/&amp;gt;&lt;br /&gt;
                    &amp;lt;/sequence&amp;gt;&lt;br /&gt;
                &amp;lt;/complexType&amp;gt;&lt;br /&gt;
            &amp;lt;/element&amp;gt;&lt;br /&gt;
            &amp;lt;element name=&amp;quot;greetMe&amp;quot;&amp;gt;&lt;br /&gt;
                &amp;lt;complexType&amp;gt;&lt;br /&gt;
                    &amp;lt;sequence&amp;gt;&lt;br /&gt;
                        &amp;lt;element name=&amp;quot;requestType&amp;quot; type=&amp;quot;xsd:string&amp;quot;/&amp;gt;&lt;br /&gt;
                    &amp;lt;/sequence&amp;gt;&lt;br /&gt;
                &amp;lt;/complexType&amp;gt;&lt;br /&gt;
            &amp;lt;/element&amp;gt;&lt;br /&gt;
            &amp;lt;element name=&amp;quot;greetMeResponse&amp;quot;&amp;gt;&lt;br /&gt;
                &amp;lt;complexType&amp;gt;&lt;br /&gt;
                    &amp;lt;sequence&amp;gt;&lt;br /&gt;
                        &amp;lt;element name=&amp;quot;responseType&amp;quot; type=&amp;quot;xsd:string&amp;quot;/&amp;gt;&lt;br /&gt;
                    &amp;lt;/sequence&amp;gt;&lt;br /&gt;
                &amp;lt;/complexType&amp;gt;&lt;br /&gt;
            &amp;lt;/element&amp;gt;&lt;br /&gt;
            &amp;lt;element name=&amp;quot;greetMeOneWay&amp;quot;&amp;gt;&lt;br /&gt;
                &amp;lt;complexType&amp;gt;&lt;br /&gt;
                    &amp;lt;sequence&amp;gt;&lt;br /&gt;
                        &amp;lt;element name=&amp;quot;requestType&amp;quot; type=&amp;quot;xsd:string&amp;quot;/&amp;gt;&lt;br /&gt;
                    &amp;lt;/sequence&amp;gt;&lt;br /&gt;
                &amp;lt;/complexType&amp;gt;&lt;br /&gt;
            &amp;lt;/element&amp;gt;&lt;br /&gt;
          &amp;lt;element name=&amp;quot;pingMe&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;complexType/&amp;gt;&lt;br /&gt;
      &amp;lt;/element&amp;gt;&lt;br /&gt;
      &amp;lt;element name=&amp;quot;pingMeResponse&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;complexType/&amp;gt;&lt;br /&gt;
      &amp;lt;/element&amp;gt;&lt;br /&gt;
      &amp;lt;element name=&amp;quot;faultDetail&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;complexType&amp;gt;&lt;br /&gt;
          &amp;lt;sequence&amp;gt;&lt;br /&gt;
            &amp;lt;element name=&amp;quot;minor&amp;quot; type=&amp;quot;xsd:short&amp;quot;/&amp;gt;&lt;br /&gt;
            &amp;lt;element name=&amp;quot;major&amp;quot; type=&amp;quot;xsd:short&amp;quot;/&amp;gt;&lt;br /&gt;
          &amp;lt;/sequence&amp;gt;&lt;br /&gt;
        &amp;lt;/complexType&amp;gt;&lt;br /&gt;
      &amp;lt;/element&amp;gt;&lt;br /&gt;
        &amp;lt;/schema&amp;gt;&lt;br /&gt;
    &amp;lt;/wsdl:types&amp;gt;&lt;br /&gt;
    &amp;lt;wsdl:message name=&amp;quot;sayHiRequest&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;wsdl:part element=&amp;quot;x1:sayHi&amp;quot; name=&amp;quot;in&amp;quot;/&amp;gt;&lt;br /&gt;
    &amp;lt;/wsdl:message&amp;gt;&lt;br /&gt;
    &amp;lt;wsdl:message name=&amp;quot;sayHiResponse&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;wsdl:part element=&amp;quot;x1:sayHiResponse&amp;quot; name=&amp;quot;out&amp;quot;/&amp;gt;&lt;br /&gt;
    &amp;lt;/wsdl:message&amp;gt;&lt;br /&gt;
    &amp;lt;wsdl:message name=&amp;quot;greetMeRequest&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;wsdl:part element=&amp;quot;x1:greetMe&amp;quot; name=&amp;quot;in&amp;quot;/&amp;gt;&lt;br /&gt;
    &amp;lt;/wsdl:message&amp;gt;&lt;br /&gt;
    &amp;lt;wsdl:message name=&amp;quot;greetMeResponse&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;wsdl:part element=&amp;quot;x1:greetMeResponse&amp;quot; name=&amp;quot;out&amp;quot;/&amp;gt;&lt;br /&gt;
    &amp;lt;/wsdl:message&amp;gt;&lt;br /&gt;
    &amp;lt;wsdl:message name=&amp;quot;greetMeOneWayRequest&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;wsdl:part element=&amp;quot;x1:greetMeOneWay&amp;quot; name=&amp;quot;in&amp;quot;/&amp;gt;&lt;br /&gt;
    &amp;lt;/wsdl:message&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
    &amp;lt;wsdl:portType name=&amp;quot;Greeter&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;wsdl:operation name=&amp;quot;sayHi&amp;quot;&amp;gt;&lt;br /&gt;
            &amp;lt;wsdl:input message=&amp;quot;tns:sayHiRequest&amp;quot; name=&amp;quot;sayHiRequest&amp;quot;/&amp;gt;&lt;br /&gt;
            &amp;lt;wsdl:output message=&amp;quot;tns:sayHiResponse&amp;quot; name=&amp;quot;sayHiResponse&amp;quot;/&amp;gt;&lt;br /&gt;
        &amp;lt;/wsdl:operation&amp;gt;&lt;br /&gt;
        &lt;br /&gt;
        &amp;lt;wsdl:operation name=&amp;quot;greetMe&amp;quot;&amp;gt;&lt;br /&gt;
            &amp;lt;wsdl:input message=&amp;quot;tns:greetMeRequest&amp;quot; name=&amp;quot;greetMeRequest&amp;quot;/&amp;gt;&lt;br /&gt;
            &amp;lt;wsdl:output message=&amp;quot;tns:greetMeResponse&amp;quot; name=&amp;quot;greetMeResponse&amp;quot;/&amp;gt;&lt;br /&gt;
        &amp;lt;/wsdl:operation&amp;gt;&lt;br /&gt;
        &lt;br /&gt;
        &amp;lt;wsdl:operation name=&amp;quot;greetMeOneWay&amp;quot;&amp;gt;&lt;br /&gt;
            &amp;lt;wsdl:input message=&amp;quot;tns:greetMeOneWayRequest&amp;quot; name=&amp;quot;greetMeOneWayRequest&amp;quot;/&amp;gt;&lt;br /&gt;
        &amp;lt;/wsdl:operation&amp;gt;&lt;br /&gt;
    &amp;lt;/wsdl:portType&amp;gt;&lt;br /&gt;
    &amp;lt;wsdl:binding name=&amp;quot;Greeter_SOAPBinding&amp;quot; type=&amp;quot;tns:Greeter&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;soap:binding style=&amp;quot;document&amp;quot; transport=&amp;quot;http://schemas.xmlsoap.org/soap/http&amp;quot;/&amp;gt;&lt;br /&gt;
        &lt;br /&gt;
        &amp;lt;wsdl:operation name=&amp;quot;sayHi&amp;quot;&amp;gt;&lt;br /&gt;
            &amp;lt;soap:operation soapAction=&amp;quot;&amp;quot; style=&amp;quot;document&amp;quot;/&amp;gt;&lt;br /&gt;
            &amp;lt;wsdl:input name=&amp;quot;sayHiRequest&amp;quot;&amp;gt;&lt;br /&gt;
                &amp;lt;soap:body use=&amp;quot;literal&amp;quot;/&amp;gt;&lt;br /&gt;
            &amp;lt;/wsdl:input&amp;gt;&lt;br /&gt;
            &amp;lt;wsdl:output name=&amp;quot;sayHiResponse&amp;quot;&amp;gt;&lt;br /&gt;
                &amp;lt;soap:body use=&amp;quot;literal&amp;quot;/&amp;gt;&lt;br /&gt;
            &amp;lt;/wsdl:output&amp;gt;&lt;br /&gt;
        &amp;lt;/wsdl:operation&amp;gt;&lt;br /&gt;
        &lt;br /&gt;
        &amp;lt;wsdl:operation name=&amp;quot;greetMe&amp;quot;&amp;gt;&lt;br /&gt;
            &amp;lt;soap:operation soapAction=&amp;quot;&amp;quot; style=&amp;quot;document&amp;quot;/&amp;gt;&lt;br /&gt;
            &amp;lt;wsdl:input name=&amp;quot;greetMeRequest&amp;quot;&amp;gt;&lt;br /&gt;
                &amp;lt;soap:body use=&amp;quot;literal&amp;quot;/&amp;gt;&lt;br /&gt;
            &amp;lt;/wsdl:input&amp;gt;&lt;br /&gt;
            &amp;lt;wsdl:output name=&amp;quot;greetMeResponse&amp;quot;&amp;gt;&lt;br /&gt;
                &amp;lt;soap:body use=&amp;quot;literal&amp;quot;/&amp;gt;&lt;br /&gt;
            &amp;lt;/wsdl:output&amp;gt;&lt;br /&gt;
        &amp;lt;/wsdl:operation&amp;gt;&lt;br /&gt;
        &lt;br /&gt;
        &amp;lt;wsdl:operation name=&amp;quot;greetMeOneWay&amp;quot;&amp;gt;&lt;br /&gt;
            &amp;lt;soap:operation soapAction=&amp;quot;&amp;quot; style=&amp;quot;document&amp;quot;/&amp;gt;&lt;br /&gt;
            &amp;lt;wsdl:input name=&amp;quot;greetMeOneWayRequest&amp;quot;&amp;gt;&lt;br /&gt;
                &amp;lt;soap:body use=&amp;quot;literal&amp;quot;/&amp;gt;&lt;br /&gt;
            &amp;lt;/wsdl:input&amp;gt;&lt;br /&gt;
        &amp;lt;/wsdl:operation&amp;gt;&lt;br /&gt;
    &amp;lt;/wsdl:binding&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
    &amp;lt;wsdl:service name=&amp;quot;SOAPService1&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;wsdl:port binding=&amp;quot;tns:Greeter_SOAPBinding&amp;quot; name=&amp;quot;SoapPort1&amp;quot;&amp;gt;&lt;br /&gt;
            &amp;lt;soap:address location=&amp;quot;http://localhost:9000/SoapContext/SoapPort1&amp;quot;/&amp;gt;&lt;br /&gt;
        &amp;lt;/wsdl:port&amp;gt;&lt;br /&gt;
    &amp;lt;/wsdl:service&amp;gt;&lt;br /&gt;
    &amp;lt;wsdl:service name=&amp;quot;SOAPService2&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;wsdl:port binding=&amp;quot;tns:Greeter_SOAPBinding&amp;quot; name=&amp;quot;SoapPort2&amp;quot;&amp;gt;&lt;br /&gt;
            &amp;lt;soap:address location=&amp;quot;http://localhost:9000/SoapContext/SoapPort2&amp;quot;/&amp;gt;&lt;br /&gt;
        &amp;lt;/wsdl:port&amp;gt;&lt;br /&gt;
    &amp;lt;/wsdl:service&amp;gt;&lt;br /&gt;
    &amp;lt;wsdl:service name=&amp;quot;SOAPService3&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;wsdl:port binding=&amp;quot;tns:Greeter_SOAPBinding&amp;quot; name=&amp;quot;SoapPort3&amp;quot;&amp;gt;&lt;br /&gt;
            &amp;lt;soap:address location=&amp;quot;http://localhost:9000/SoapContext/SoapPort3&amp;quot;/&amp;gt;&lt;br /&gt;
        &amp;lt;/wsdl:port&amp;gt;&lt;br /&gt;
    &amp;lt;/wsdl:service&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
&amp;lt;/wsdl:definitions&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
        &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;/div&gt;</summary>
		<author><name>Admin</name></author>	</entry>

	<entry>
		<id>http://jexp.ru/index.php?title=Java/Web_Services_SOA/Spring&amp;diff=9203</id>
		<title>Java/Web Services SOA/Spring</title>
		<link rel="alternate" type="text/html" href="http://jexp.ru/index.php?title=Java/Web_Services_SOA/Spring&amp;diff=9203"/>
				<updated>2010-06-01T07:27:36Z</updated>
		
		<summary type="html">&lt;p&gt;Admin: 1 версия&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== This example will lead you through creating your first service with Spring ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
Spring HTTP demo&lt;br /&gt;
=============================================&lt;br /&gt;
This example will lead you through creating your first service with&lt;br /&gt;
Spring. You&amp;quot;ll learn how to:&lt;br /&gt;
    * Writing a simple JAX-WS &amp;quot;code-first&amp;quot; service&lt;br /&gt;
    * Set up the HTTP servlet transport&lt;br /&gt;
    * Use CXF&amp;quot;s Spring beans&lt;br /&gt;
For more information see the documentation for this example in the&lt;br /&gt;
user&amp;quot;s guide.&lt;br /&gt;
&lt;br /&gt;
Prerequisite&lt;br /&gt;
------------&lt;br /&gt;
If your environment already includes cxf-manifest-incubator.jar on the&lt;br /&gt;
CLASSPATH, and the JDK and ant bin directories on the PATH&lt;br /&gt;
it is not necessary to set the environment as described in&lt;br /&gt;
the samples directory README.  If your environment is not&lt;br /&gt;
properly configured, or if you are planning on using wsdl2java,&lt;br /&gt;
javac, and java to build and run the demos, you must set the&lt;br /&gt;
environment.&lt;br /&gt;
&lt;br /&gt;
Building and running the demo using ant&lt;br /&gt;
---------------------------------------&lt;br /&gt;
From the samples/hello_world directory, the ant build script&lt;br /&gt;
can be used to build and run the demo.&lt;br /&gt;
Using either UNIX or Windows:&lt;br /&gt;
  ant build&lt;br /&gt;
  ant server&lt;br /&gt;
  ant client&lt;br /&gt;
    &lt;br /&gt;
To remove the code generated from the WSDL file and the .class&lt;br /&gt;
files, run:&lt;br /&gt;
  ant clean&lt;br /&gt;
&lt;br /&gt;
        &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;/div&gt;</summary>
		<author><name>Admin</name></author>	</entry>

	<entry>
		<id>http://jexp.ru/index.php?title=Java/Web_Services_SOA/Code_First&amp;diff=9205</id>
		<title>Java/Web Services SOA/Code First</title>
		<link rel="alternate" type="text/html" href="http://jexp.ru/index.php?title=Java/Web_Services_SOA/Code_First&amp;diff=9205"/>
				<updated>2010-06-01T07:27:36Z</updated>
		
		<summary type="html">&lt;p&gt;Admin: 1 версия&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== This demo illustrates how to develop a service use the &amp;quot;code first&amp;quot; approach using the JAX-WS APIs ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
  Licensed to the Apache Software Foundation (ASF) under one&lt;br /&gt;
  or more contributor license agreements. See the NOTICE file&lt;br /&gt;
  distributed with this work for additional information&lt;br /&gt;
  regarding copyright ownership. The ASF licenses this file&lt;br /&gt;
  to you under the Apache License, Version 2.0 (the&lt;br /&gt;
  &amp;quot;License&amp;quot;); you may not use this file except in compliance&lt;br /&gt;
  with the License. You may obtain a copy of the License at&lt;br /&gt;
 &lt;br /&gt;
  http://www.apache.org/licenses/LICENSE-2.0&lt;br /&gt;
 &lt;br /&gt;
  Unless required by applicable law or agreed to in writing,&lt;br /&gt;
  software distributed under the License is distributed on an&lt;br /&gt;
  &amp;quot;AS IS&amp;quot; BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY&lt;br /&gt;
  KIND, either express or implied. See the License for the&lt;br /&gt;
  specific language governing permissions and limitations&lt;br /&gt;
  under the License.&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
Hello World Demo using Document/Literal Style&lt;br /&gt;
=============================================&lt;br /&gt;
This demo illustrates how to develop a service use the &amp;quot;code first&amp;quot;&lt;br /&gt;
approach using the JAX-WS APIs.&lt;br /&gt;
Prerequisite&lt;br /&gt;
------------&lt;br /&gt;
If your environment already includes cxf-manifest-incubator.jar on the&lt;br /&gt;
CLASSPATH, and the JDK and ant bin directories on the PATH&lt;br /&gt;
it is not necessary to set the environment as described in&lt;br /&gt;
the samples directory README.  If your environment is not&lt;br /&gt;
properly configured, or if you are planning on using wsdl2java,&lt;br /&gt;
javac, and java to build and run the demos, you must set the&lt;br /&gt;
environment.&lt;br /&gt;
&lt;br /&gt;
Building and running the demo using ant&lt;br /&gt;
---------------------------------------&lt;br /&gt;
From the samples/hello_world directory, the ant build script&lt;br /&gt;
can be used to build and run the demo.&lt;br /&gt;
Using either UNIX or Windows:&lt;br /&gt;
  ant build&lt;br /&gt;
  ant server&lt;br /&gt;
  ant client&lt;br /&gt;
    &lt;br /&gt;
To remove the code generated from the WSDL file and the .class&lt;br /&gt;
files, run:&lt;br /&gt;
  ant clean&lt;br /&gt;
&lt;br /&gt;
Building the demo using wsdl2java and javac&lt;br /&gt;
-------------------------------------------&lt;br /&gt;
From the samples/hello_world directory, first create the target&lt;br /&gt;
directory build/classes and then generate code from the WSDL file.&lt;br /&gt;
For UNIX:&lt;br /&gt;
  mkdir -p build/classes&lt;br /&gt;
  wsdl2java -d build/classes -compile ./wsdl/hello_world.wsdl&lt;br /&gt;
For Windows:&lt;br /&gt;
  mkdir build\classes&lt;br /&gt;
    Must use back slashes.&lt;br /&gt;
  wsdl2java -d build\classes -compile .\wsdl\hello_world.wsdl&lt;br /&gt;
    May use either forward or back slashes.&lt;br /&gt;
Now compile the provided client and server applications with the commands:&lt;br /&gt;
For UNIX:  &lt;br /&gt;
  &lt;br /&gt;
  export CLASSPATH=$CLASSPATH:$CXF_HOME/lib/cxf-manifest-incubator.jar:./build/classes&lt;br /&gt;
  javac -d build/classes src/demo/hw/client/*.java&lt;br /&gt;
  javac -d build/classes src/demo/hw/server/*.java&lt;br /&gt;
For Windows:&lt;br /&gt;
  set classpath=%classpath%;%CXF_HOME%\lib\cxf-manifest-incubator.jar;.\build\classes&lt;br /&gt;
  javac -d build\classes src\demo\hw\client\*.java&lt;br /&gt;
  javac -d build\classes src\demo\hw\server\*.java&lt;br /&gt;
&lt;br /&gt;
Running the demo using java&lt;br /&gt;
---------------------------&lt;br /&gt;
From the samples/hello_world directory run the commands, entered on a&lt;br /&gt;
single command line:&lt;br /&gt;
For UNIX (must use forward slashes):&lt;br /&gt;
    java -Djava.util.logging.config.file=$CXF_HOME/etc/logging.properties&lt;br /&gt;
         demo.hw.server.Server &amp;amp;&lt;br /&gt;
    java -Djava.util.logging.config.file=$CXF_HOME/etc/logging.properties&lt;br /&gt;
         demo.hw.client.Client ./wsdl/hello_world.wsdl&lt;br /&gt;
The server process starts in the background.  After running the client,&lt;br /&gt;
use the kill command to terminate the server process.&lt;br /&gt;
For Windows (may use either forward or back slashes):&lt;br /&gt;
  start &lt;br /&gt;
    java -Djava.util.logging.config.file=%CXF_HOME%\etc\logging.properties&lt;br /&gt;
         demo.hw.server.Server&lt;br /&gt;
    java -Djava.util.logging.config.file=%CXF_HOME%\etc\logging.properties&lt;br /&gt;
       demo.hw.client.Client .\wsdl\hello_world.wsdl&lt;br /&gt;
A new command windows opens for the server process.  After running the&lt;br /&gt;
client, terminate the server process by issuing Ctrl-C in its command window.&lt;br /&gt;
To remove the code generated from the WSDL file and the .class&lt;br /&gt;
files, either delete the build directory and its contents or run:&lt;br /&gt;
  ant clean&lt;br /&gt;
&lt;br /&gt;
Building and running the demo in a servlet container&lt;br /&gt;
----------------------------------------------------&lt;br /&gt;
From the samples/hello_world directory, the ant build script&lt;br /&gt;
can be used to create the war file that is deployed into the&lt;br /&gt;
servlet container.&lt;br /&gt;
Build the war file with the command:&lt;br /&gt;
  ant war&lt;br /&gt;
    &lt;br /&gt;
Preparing deploy to APACHE TOMCAT&lt;br /&gt;
* set CATALINA_HOME environment to your TOMCAT home directory&lt;br /&gt;
    &lt;br /&gt;
Deploy the application into APACHE TOMCAT with the commond:&lt;br /&gt;
[NOTE] This step will check if the cxf jars present in Tomcat, &lt;br /&gt;
       if not, it will automatically copy all the jars into CATALINA_HOME/shared/lib&lt;br /&gt;
  &lt;br /&gt;
  ant deploy -Dtomcat=true&lt;br /&gt;
The servlet container will extract the war and deploy the application.&lt;br /&gt;
&lt;br /&gt;
Using ant, run the client application with the command:&lt;br /&gt;
  ant client-servlet -Dbase.url=http://localhost:#&lt;br /&gt;
Where # is the TCP/IP port used by the servlet container,&lt;br /&gt;
e.g., 8080.&lt;br /&gt;
Or&lt;br /&gt;
  ant client-servlet -Dhost=localhost -Dport=8080&lt;br /&gt;
You can ignore the -Dhost and -Dport if your tomcat setup is same, i.e ant client-servlet&lt;br /&gt;
Using java, run the client application with the command:&lt;br /&gt;
  For UNIX:&lt;br /&gt;
    &lt;br /&gt;
    java -Djava.util.logging.config.file=$CXF_HOME/etc/logging.properties&lt;br /&gt;
         demo.hw.client.Client http://localhost:#/helloworld/services/hello_world?wsdl&lt;br /&gt;
  For Windows:&lt;br /&gt;
    java -Djava.util.logging.config.file=%CXF_HOME%\etc\logging.properties&lt;br /&gt;
       demo.hw.client.Client http://localhost:#/helloworld/services/hello_world?wsdl&lt;br /&gt;
Where # is the TCP/IP port used by the servlet container,&lt;br /&gt;
e.g., 8080.&lt;br /&gt;
Undeploy the application from the APACHE TOMCAT with the command:&lt;br /&gt;
   ant undeploy -Dtomcat=true&lt;br /&gt;
&lt;br /&gt;
Running demo with HTTP GET&lt;br /&gt;
----------------------------------------------------&lt;br /&gt;
APACHE CXF support HTTP GET to invoke the service, instead of running &lt;br /&gt;
   ant client&lt;br /&gt;
you can use &lt;br /&gt;
   ant client.get &lt;br /&gt;
to invoke the service with simple HttpURLConnection, or you can even&lt;br /&gt;
use your favoriate browser to get the results back.&lt;br /&gt;
&lt;br /&gt;
////////////////////////////////////////////////////////////////////////&lt;br /&gt;
&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot;?&amp;gt;&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
  Licensed to the Apache Software Foundation (ASF) under one&lt;br /&gt;
  or more contributor license agreements. See the NOTICE file&lt;br /&gt;
  distributed with this work for additional information&lt;br /&gt;
  regarding copyright ownership. The ASF licenses this file&lt;br /&gt;
  to you under the Apache License, Version 2.0 (the&lt;br /&gt;
  &amp;quot;License&amp;quot;); you may not use this file except in compliance&lt;br /&gt;
  with the License. You may obtain a copy of the License at&lt;br /&gt;
 &lt;br /&gt;
  http://www.apache.org/licenses/LICENSE-2.0&lt;br /&gt;
 &lt;br /&gt;
  Unless required by applicable law or agreed to in writing,&lt;br /&gt;
  software distributed under the License is distributed on an&lt;br /&gt;
  &amp;quot;AS IS&amp;quot; BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY&lt;br /&gt;
  KIND, either express or implied. See the License for the&lt;br /&gt;
  specific language governing permissions and limitations&lt;br /&gt;
  under the License.&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&amp;lt;project name=&amp;quot;hello world code first demo&amp;quot; default=&amp;quot;build&amp;quot; basedir=&amp;quot;.&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;import file=&amp;quot;common_build.xml&amp;quot;/&amp;gt;        &lt;br /&gt;
        &lt;br /&gt;
    &amp;lt;target name=&amp;quot;client&amp;quot; description=&amp;quot;run demo client&amp;quot; depends=&amp;quot;build&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;property name=&amp;quot;param&amp;quot; value=&amp;quot;&amp;quot;/&amp;gt;&lt;br /&gt;
        &amp;lt;cxfrun classname=&amp;quot;demo.hw.client.Client&amp;quot;&lt;br /&gt;
            param1=&amp;quot;&amp;quot; &lt;br /&gt;
            param2=&amp;quot;${op}&amp;quot; &lt;br /&gt;
            param3=&amp;quot;${param}&amp;quot;/&amp;gt;&lt;br /&gt;
    &amp;lt;/target&amp;gt; &lt;br /&gt;
        &lt;br /&gt;
    &amp;lt;target name=&amp;quot;server&amp;quot; description=&amp;quot;run demo server&amp;quot; depends=&amp;quot;build&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;cxfrun classname=&amp;quot;demo.hw.server.Server&amp;quot;/&amp;gt;&lt;br /&gt;
    &amp;lt;/target&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
    &amp;lt;property name=&amp;quot;cxf.war.file.name&amp;quot; value=&amp;quot;helloworld&amp;quot;/&amp;gt;&lt;br /&gt;
    &amp;lt;target name=&amp;quot;war&amp;quot; depends=&amp;quot;build&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;cxfwar wsdl=&amp;quot;hello_world.wsdl&amp;quot; filename=&amp;quot;${cxf.war.file.name}.war&amp;quot;/&amp;gt;&lt;br /&gt;
    &amp;lt;/target&amp;gt;&lt;br /&gt;
    &amp;lt;target name=&amp;quot;client-servlet&amp;quot; description=&amp;quot;run demo client hitting servlet&amp;quot; depends=&amp;quot;build&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;property name=&amp;quot;param&amp;quot; value=&amp;quot;&amp;quot;/&amp;gt;&lt;br /&gt;
        &amp;lt;cxfrun classname=&amp;quot;demo.hw.client.Client&amp;quot; param1=&amp;quot;${base.url}/helloworld/services/hello_world?wsdl&amp;quot; param2=&amp;quot;${op}&amp;quot; param3=&amp;quot;${param}&amp;quot;/&amp;gt;&lt;br /&gt;
    &amp;lt;/target&amp;gt; &lt;br /&gt;
&amp;lt;/project&amp;gt;&lt;br /&gt;
&lt;br /&gt;
////////////////////////////////////////////////////////////////////////&lt;br /&gt;
/**&lt;br /&gt;
 * Licensed to the Apache Software Foundation (ASF) under one&lt;br /&gt;
 * or more contributor license agreements. See the NOTICE file&lt;br /&gt;
 * distributed with this work for additional information&lt;br /&gt;
 * regarding copyright ownership. The ASF licenses this file&lt;br /&gt;
 * to you under the Apache License, Version 2.0 (the&lt;br /&gt;
 * &amp;quot;License&amp;quot;); you may not use this file except in compliance&lt;br /&gt;
 * with the License. You may obtain a copy of the License at&lt;br /&gt;
 *&lt;br /&gt;
 * http://www.apache.org/licenses/LICENSE-2.0&lt;br /&gt;
 *&lt;br /&gt;
 * Unless required by applicable law or agreed to in writing,&lt;br /&gt;
 * software distributed under the License is distributed on an&lt;br /&gt;
 * &amp;quot;AS IS&amp;quot; BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY&lt;br /&gt;
 * KIND, either express or implied. See the License for the&lt;br /&gt;
 * specific language governing permissions and limitations&lt;br /&gt;
 * under the License.&lt;br /&gt;
 */&lt;br /&gt;
package demo.hw.client;&lt;br /&gt;
import javax.xml.namespace.QName;&lt;br /&gt;
import javax.xml.ws.Service;&lt;br /&gt;
import javax.xml.ws.soap.SOAPBinding;&lt;br /&gt;
import demo.hw.server.HelloWorld;&lt;br /&gt;
public final class Client {&lt;br /&gt;
    private static final QName SERVICE_NAME &lt;br /&gt;
        = new QName(&amp;quot;http://server.hw.demo/&amp;quot;, &amp;quot;HelloWorld&amp;quot;);&lt;br /&gt;
    private static final QName PORT_NAME &lt;br /&gt;
        = new QName(&amp;quot;http://server.hw.demo/&amp;quot;, &amp;quot;HelloWorldPort&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
    private Client() {&lt;br /&gt;
    } &lt;br /&gt;
    public static void main(String args[]) throws Exception {&lt;br /&gt;
        Service service = Service.create(SERVICE_NAME);&lt;br /&gt;
        // Endpoint Address&lt;br /&gt;
        String endpointAddress = &amp;quot;http://localhost:9000/helloWorld&amp;quot;;&lt;br /&gt;
        // Add a port to the Service&lt;br /&gt;
        service.addPort(PORT_NAME, SOAPBinding.SOAP11HTTP_BINDING, endpointAddress);&lt;br /&gt;
        &lt;br /&gt;
        HelloWorld hw = service.getPort(HelloWorld.class);&lt;br /&gt;
        System.out.println(hw.sayHi(&amp;quot;World&amp;quot;));&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
////////////////////////////////////////////////////////////////////////&lt;br /&gt;
/**&lt;br /&gt;
 * Licensed to the Apache Software Foundation (ASF) under one&lt;br /&gt;
 * or more contributor license agreements. See the NOTICE file&lt;br /&gt;
 * distributed with this work for additional information&lt;br /&gt;
 * regarding copyright ownership. The ASF licenses this file&lt;br /&gt;
 * to you under the Apache License, Version 2.0 (the&lt;br /&gt;
 * &amp;quot;License&amp;quot;); you may not use this file except in compliance&lt;br /&gt;
 * with the License. You may obtain a copy of the License at&lt;br /&gt;
 *&lt;br /&gt;
 * http://www.apache.org/licenses/LICENSE-2.0&lt;br /&gt;
 *&lt;br /&gt;
 * Unless required by applicable law or agreed to in writing,&lt;br /&gt;
 * software distributed under the License is distributed on an&lt;br /&gt;
 * &amp;quot;AS IS&amp;quot; BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY&lt;br /&gt;
 * KIND, either express or implied. See the License for the&lt;br /&gt;
 * specific language governing permissions and limitations&lt;br /&gt;
 * under the License.&lt;br /&gt;
 */&lt;br /&gt;
// START SNIPPET: service&lt;br /&gt;
package demo.hw.server;&lt;br /&gt;
import javax.jws.WebService;&lt;br /&gt;
@WebService&lt;br /&gt;
public interface HelloWorld {&lt;br /&gt;
    String sayHi(String text);&lt;br /&gt;
}&lt;br /&gt;
// END SNIPPET: service&lt;br /&gt;
&lt;br /&gt;
////////////////////////////////////////////////////////////////////////&lt;br /&gt;
/**&lt;br /&gt;
 * Licensed to the Apache Software Foundation (ASF) under one&lt;br /&gt;
 * or more contributor license agreements. See the NOTICE file&lt;br /&gt;
 * distributed with this work for additional information&lt;br /&gt;
 * regarding copyright ownership. The ASF licenses this file&lt;br /&gt;
 * to you under the Apache License, Version 2.0 (the&lt;br /&gt;
 * &amp;quot;License&amp;quot;); you may not use this file except in compliance&lt;br /&gt;
 * with the License. You may obtain a copy of the License at&lt;br /&gt;
 *&lt;br /&gt;
 * http://www.apache.org/licenses/LICENSE-2.0&lt;br /&gt;
 *&lt;br /&gt;
 * Unless required by applicable law or agreed to in writing,&lt;br /&gt;
 * software distributed under the License is distributed on an&lt;br /&gt;
 * &amp;quot;AS IS&amp;quot; BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY&lt;br /&gt;
 * KIND, either express or implied. See the License for the&lt;br /&gt;
 * specific language governing permissions and limitations&lt;br /&gt;
 * under the License.&lt;br /&gt;
 */&lt;br /&gt;
// START SNIPPET: service&lt;br /&gt;
package demo.hw.server;&lt;br /&gt;
import javax.jws.WebService;&lt;br /&gt;
@WebService(endpointInterface = &amp;quot;demo.hw.server.HelloWorld&amp;quot;, &lt;br /&gt;
            serviceName = &amp;quot;HelloWorld&amp;quot;)&lt;br /&gt;
public class HelloWorldImpl implements HelloWorld {&lt;br /&gt;
    public String sayHi(String text) {&lt;br /&gt;
        return &amp;quot;Hello &amp;quot; + text;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
// END SNIPPET: service&lt;br /&gt;
&lt;br /&gt;
////////////////////////////////////////////////////////////////////////&lt;br /&gt;
/**&lt;br /&gt;
 * Licensed to the Apache Software Foundation (ASF) under one&lt;br /&gt;
 * or more contributor license agreements. See the NOTICE file&lt;br /&gt;
 * distributed with this work for additional information&lt;br /&gt;
 * regarding copyright ownership. The ASF licenses this file&lt;br /&gt;
 * to you under the Apache License, Version 2.0 (the&lt;br /&gt;
 * &amp;quot;License&amp;quot;); you may not use this file except in compliance&lt;br /&gt;
 * with the License. You may obtain a copy of the License at&lt;br /&gt;
 *&lt;br /&gt;
 * http://www.apache.org/licenses/LICENSE-2.0&lt;br /&gt;
 *&lt;br /&gt;
 * Unless required by applicable law or agreed to in writing,&lt;br /&gt;
 * software distributed under the License is distributed on an&lt;br /&gt;
 * &amp;quot;AS IS&amp;quot; BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY&lt;br /&gt;
 * KIND, either express or implied. See the License for the&lt;br /&gt;
 * specific language governing permissions and limitations&lt;br /&gt;
 * under the License.&lt;br /&gt;
 */&lt;br /&gt;
package demo.hw.server;&lt;br /&gt;
import javax.xml.ws.Endpoint;&lt;br /&gt;
public class Server {&lt;br /&gt;
    protected Server() throws Exception {&lt;br /&gt;
        // START SNIPPET: publish&lt;br /&gt;
        System.out.println(&amp;quot;Starting Server&amp;quot;);&lt;br /&gt;
        HelloWorldImpl implementor = new HelloWorldImpl();&lt;br /&gt;
        String address = &amp;quot;http://localhost:9000/helloWorld&amp;quot;;&lt;br /&gt;
        Endpoint.publish(address, implementor);&lt;br /&gt;
        // END SNIPPET: publish&lt;br /&gt;
    }&lt;br /&gt;
    public static void main(String args[]) throws Exception {&lt;br /&gt;
        new Server();&lt;br /&gt;
        System.out.println(&amp;quot;Server ready...&amp;quot;);&lt;br /&gt;
        Thread.sleep(5 * 60 * 1000);&lt;br /&gt;
        System.out.println(&amp;quot;Server exiting&amp;quot;);&lt;br /&gt;
        System.exit(0);&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
        &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;/div&gt;</summary>
		<author><name>Admin</name></author>	</entry>

	<entry>
		<id>http://jexp.ru/index.php?title=Java/Web_Services_SOA/SOAP&amp;diff=9201</id>
		<title>Java/Web Services SOA/SOAP</title>
		<link rel="alternate" type="text/html" href="http://jexp.ru/index.php?title=Java/Web_Services_SOA/SOAP&amp;diff=9201"/>
				<updated>2010-06-01T07:27:35Z</updated>
		
		<summary type="html">&lt;p&gt;Admin: 1 версия&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== A SOAP message with an attachment and XML-binary Optimized Packaging ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
MTOM Demo for SWA &amp;amp; XOP&lt;br /&gt;
=============================================&lt;br /&gt;
This demo illustrates the use of a SOAP message &lt;br /&gt;
with an attachment and XML-binary Optimized Packaging.&lt;br /&gt;
Please review the README in the samples directory before&lt;br /&gt;
continuing.&lt;br /&gt;
&lt;br /&gt;
Prerequisite&lt;br /&gt;
------------&lt;br /&gt;
If your environment already includes cxf-manifest-incubator.jar on the&lt;br /&gt;
CLASSPATH, and the JDK and ant bin directories on the PATH&lt;br /&gt;
it is not necessary to set the environment as described in&lt;br /&gt;
the samples directory&amp;quot;s README.  If your environment is not&lt;br /&gt;
properly configured, or if you are planning on using wsdl2java,&lt;br /&gt;
javac, and java to build and run the demos, you must set the&lt;br /&gt;
environment.&lt;br /&gt;
&lt;br /&gt;
Building and running the demo using ant&lt;br /&gt;
---------------------------------------&lt;br /&gt;
From the samples/mtom directory, the ant build script&lt;br /&gt;
can be used to build and run the demo.&lt;br /&gt;
Using either UNIX or Windows:&lt;br /&gt;
  ant build&lt;br /&gt;
  ant server&lt;br /&gt;
  ant client&lt;br /&gt;
    &lt;br /&gt;
To remove the code generated from the WSDL file and the .class&lt;br /&gt;
files, run:&lt;br /&gt;
  ant clean&lt;br /&gt;
&lt;br /&gt;
Building the demo using wsdl2java and javac&lt;br /&gt;
-------------------------------------------&lt;br /&gt;
From the samples/mtom directory, first create the target&lt;br /&gt;
directory build/classes and then generate code from the WSDL file.&lt;br /&gt;
For UNIX:&lt;br /&gt;
  mkdir -p build/classes&lt;br /&gt;
  wsdl2java -d build/classes -compile ./wsdl/mtom_xop.wsdl&lt;br /&gt;
For Windows:&lt;br /&gt;
  mkdir build\classes&lt;br /&gt;
    Must use back slashes.&lt;br /&gt;
  wsdl2java -d build\classes -compile .\wsdl\mtom_xop.wsdl&lt;br /&gt;
    May use either forward or back slashes.&lt;br /&gt;
Now compile the provided client and server applications with the commands:&lt;br /&gt;
For UNIX:  &lt;br /&gt;
  &lt;br /&gt;
  export CLASSPATH=$CLASSPATH:$CXF_HOME/lib/cxf-manifest-incubator.jar:./build/classes&lt;br /&gt;
  javac -d build/classes src/demo/mtom/client/*.java&lt;br /&gt;
  javac -d build/classes src/demo/mtom/server/*.java&lt;br /&gt;
  cp src/demo/mtom/client/me.bmp build/classes/demo/mtom/client/me.bmp&lt;br /&gt;
For Windows:&lt;br /&gt;
  set classpath=%classpath%;%CXF_HOME%\lib\cxf-manifest-incubator.jar;.\build\classes&lt;br /&gt;
  javac -d build\classes src\demo\mtom\client\*.java&lt;br /&gt;
  javac -d build\classes src\demo\mtom\server\*.java&lt;br /&gt;
  copy src\demo\mtom\client\me.bmp build\classes\demo\mtom\client\me.bmp&lt;br /&gt;
&lt;br /&gt;
Running the demo using java&lt;br /&gt;
---------------------------&lt;br /&gt;
From the samples/mtom directory run the following commands. &lt;br /&gt;
They are entered on a single command line.&lt;br /&gt;
For UNIX (must use forward slashes):&lt;br /&gt;
    java -Djava.util.logging.config.file=$CXF_HOME/etc/logging.properties&lt;br /&gt;
         demo.mtom.server.Server &amp;amp;&lt;br /&gt;
    java -Djava.util.logging.config.file=$CXF_HOME/etc/logging.properties&lt;br /&gt;
         demo.mtom.client.Client ./wsdl/mtom_xop.wsdl&lt;br /&gt;
The server process starts in the background.  After running the client,&lt;br /&gt;
use the kill command to terminate the server process.&lt;br /&gt;
For Windows (may use either forward or back slashes):&lt;br /&gt;
  start &lt;br /&gt;
    java -Djava.util.logging.config.file=%CXF_HOME%\etc\logging.properties&lt;br /&gt;
         demo.mtom.server.Server&lt;br /&gt;
    java -Djava.util.logging.config.file=%CXF_HOME%\etc\logging.properties&lt;br /&gt;
       demo.mtom.client.Client .\wsdl\mtom_xop.wsdl&lt;br /&gt;
A new command windows opens for the server process.  After running the&lt;br /&gt;
client, terminate the server process by issuing Ctrl-C in its command window.&lt;br /&gt;
To remove the code generated from the WSDL file and the .class&lt;br /&gt;
files, either delete the build directory and its contents or run:&lt;br /&gt;
  ant clean&lt;br /&gt;
&lt;br /&gt;
Building and running the demo in a servlet container&lt;br /&gt;
----------------------------------------------------&lt;br /&gt;
From the samples/mtom directory, the ant build script&lt;br /&gt;
can be used to create the war file that is deployed into the&lt;br /&gt;
servlet container.&lt;br /&gt;
Build the war file with the command:&lt;br /&gt;
  ant war&lt;br /&gt;
    &lt;br /&gt;
The war file will be included in the directory&lt;br /&gt;
samples/mtom/build/war.  Simply copy the war file into&lt;br /&gt;
the servlet container&amp;quot;s deployment directory.  For example,&lt;br /&gt;
with Tomcat copy the war file into the directory&lt;br /&gt;
&amp;lt;installationDirectory&amp;gt;/webapps.  The servlet container will&lt;br /&gt;
extract the war and deploy the application.&lt;br /&gt;
Make sure already copy all jars from CXF_HOME/lib to&lt;br /&gt;
&amp;lt;TomcatInstallationDirectory&amp;gt;/shared/lib&lt;br /&gt;
Using ant, run the client application with the command:&lt;br /&gt;
  ant client-servlet -Dbase.url=http://localhost:#&lt;br /&gt;
Where # is the TCP/IP port used by the servlet container,&lt;br /&gt;
e.g., 8080.&lt;br /&gt;
Using java, run the client application with the command:&lt;br /&gt;
  For UNIX:&lt;br /&gt;
    &lt;br /&gt;
    java -Djava.util.logging.config.file=$CXF_HOME/etc/logging.properties&lt;br /&gt;
         demo.mtom.client.Client http://localhost:#/mtom/services/mtom?wsdl&lt;br /&gt;
  For Windows:&lt;br /&gt;
    java -Djava.util.logging.config.file=%CXF_HOME%\etc\logging.properties&lt;br /&gt;
       demo.mtom.client.Client http://localhost:#/mtom/services/mtom?wsdl&lt;br /&gt;
Where # is the TCP/IP port used by the servlet container,&lt;br /&gt;
e.g., 8080.&lt;br /&gt;
&lt;br /&gt;
//////////////////////////////////////////////////////////////////&lt;br /&gt;
&lt;br /&gt;
/**&lt;br /&gt;
 * Licensed to the Apache Software Foundation (ASF) under one&lt;br /&gt;
 * or more contributor license agreements. See the NOTICE file&lt;br /&gt;
 * distributed with this work for additional information&lt;br /&gt;
 * regarding copyright ownership. The ASF licenses this file&lt;br /&gt;
 * to you under the Apache License, Version 2.0 (the&lt;br /&gt;
 * &amp;quot;License&amp;quot;); you may not use this file except in compliance&lt;br /&gt;
 * with the License. You may obtain a copy of the License at&lt;br /&gt;
 *&lt;br /&gt;
 * http://www.apache.org/licenses/LICENSE-2.0&lt;br /&gt;
 *&lt;br /&gt;
 * Unless required by applicable law or agreed to in writing,&lt;br /&gt;
 * software distributed under the License is distributed on an&lt;br /&gt;
 * &amp;quot;AS IS&amp;quot; BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY&lt;br /&gt;
 * KIND, either express or implied. See the License for the&lt;br /&gt;
 * specific language governing permissions and limitations&lt;br /&gt;
 * under the License.&lt;br /&gt;
 */&lt;br /&gt;
package demo.mtom.client;&lt;br /&gt;
import java.awt.Image;&lt;br /&gt;
import java.io.ByteArrayInputStream;&lt;br /&gt;
import java.io.File;&lt;br /&gt;
import java.io.FileInputStream;&lt;br /&gt;
import java.io.InputStream;&lt;br /&gt;
import java.net.URL;&lt;br /&gt;
import javax.activation.DataHandler;&lt;br /&gt;
import javax.imageio.ImageIO;&lt;br /&gt;
import javax.mail.util.ByteArrayDataSource;&lt;br /&gt;
import javax.xml.namespace.QName;&lt;br /&gt;
import javax.xml.ws.Binding;&lt;br /&gt;
import javax.xml.ws.BindingProvider;&lt;br /&gt;
import javax.xml.ws.Holder;&lt;br /&gt;
import javax.xml.ws.soap.SOAPBinding;&lt;br /&gt;
import org.apache.cxf.mime.TestMtom;&lt;br /&gt;
import org.apache.cxf.mime.TestMtomService;&lt;br /&gt;
public final class Client {&lt;br /&gt;
    private static final QName SERVICE_NAME = new QName(&amp;quot;http://cxf.apache.org/mime&amp;quot;, &amp;quot;TestMtomService&amp;quot;);&lt;br /&gt;
    private static final QName PORT_NAME = new QName(&amp;quot;http://cxf.apache.org/mime&amp;quot;, &amp;quot;TestMtomPort&amp;quot;);&lt;br /&gt;
    private Client() {&lt;br /&gt;
    }&lt;br /&gt;
    public static void main(String args[]) throws Exception {&lt;br /&gt;
        Client client = new Client();&lt;br /&gt;
        if (args.length == 0) {&lt;br /&gt;
            System.out.println(&amp;quot;please specify wsdl&amp;quot;);&lt;br /&gt;
            System.exit(1);&lt;br /&gt;
        }&lt;br /&gt;
        URL wsdlURL;&lt;br /&gt;
        File wsdlFile = new File(args[0]);&lt;br /&gt;
        if (wsdlFile.exists()) {&lt;br /&gt;
            wsdlURL = wsdlFile.toURL();&lt;br /&gt;
        } else {&lt;br /&gt;
            wsdlURL = new URL(args[0]);&lt;br /&gt;
        }&lt;br /&gt;
        System.out.println(wsdlURL);&lt;br /&gt;
        TestMtomService tms = new TestMtomService(wsdlURL, SERVICE_NAME);&lt;br /&gt;
        TestMtom port = (TestMtom) tms.getPort(PORT_NAME, TestMtom.class);&lt;br /&gt;
        Binding binding = ((BindingProvider)port).getBinding();&lt;br /&gt;
        ((SOAPBinding)binding).setMTOMEnabled(true);&lt;br /&gt;
        InputStream pre = client.getClass().getResourceAsStream(&amp;quot;me.bmp&amp;quot;);&lt;br /&gt;
        long fileSize = 0;&lt;br /&gt;
        for (int i = pre.read(); i != -1; i = pre.read()) {&lt;br /&gt;
            fileSize++;&lt;br /&gt;
        }&lt;br /&gt;
        Holder&amp;lt;byte[]&amp;gt; param = new Holder&amp;lt;byte[]&amp;gt;();&lt;br /&gt;
        param.value = new byte[(int) fileSize];&lt;br /&gt;
        System.out.println(&amp;quot;Start test without Mtom enable!&amp;quot;);&lt;br /&gt;
        System.out.println(&amp;quot;Sending out the me.bmp Image content to server, data size is &amp;quot; + fileSize);&lt;br /&gt;
        InputStream in = client.getClass().getResourceAsStream(&amp;quot;me.bmp&amp;quot;);&lt;br /&gt;
        in.read(param.value);&lt;br /&gt;
        Holder&amp;lt;String&amp;gt; name = new Holder&amp;lt;String&amp;gt;(&amp;quot;call detail&amp;quot;);&lt;br /&gt;
        port.testXop(name, param);&lt;br /&gt;
        System.out.println(&amp;quot;received byte[] back from server, the size is &amp;quot; + param.value.length);&lt;br /&gt;
        Image image = ImageIO.read(new ByteArrayInputStream(param.value));&lt;br /&gt;
        System.out.println(&amp;quot;build image with the returned byte[] back from server successfully, hashCode=&amp;quot;&lt;br /&gt;
                + image.hashCode());&lt;br /&gt;
        System.out.println(&amp;quot;Successfully run demo without mtom enable&amp;quot;);&lt;br /&gt;
        System.out.println(&amp;quot;Start test with Mtom enable!&amp;quot;);        &lt;br /&gt;
        System.out.println(&amp;quot;Sending out the me.bmp Image content to server, data size is &amp;quot; + fileSize);&lt;br /&gt;
        Holder&amp;lt;DataHandler&amp;gt; handler = new Holder&amp;lt;DataHandler&amp;gt;();&lt;br /&gt;
        byte[] data = new byte[(int) fileSize];&lt;br /&gt;
        client.getClass().getResourceAsStream(&amp;quot;me.bmp&amp;quot;).read(data);&lt;br /&gt;
        handler.value = new DataHandler(new ByteArrayDataSource(data, &amp;quot;application/octet-stream&amp;quot;));&lt;br /&gt;
        port.testMtom(name, handler);&lt;br /&gt;
        InputStream mtomIn = handler.value.getInputStream();&lt;br /&gt;
        fileSize = 0;&lt;br /&gt;
        &lt;br /&gt;
        for (int i = mtomIn.read(); i != -1; i = mtomIn.read()) {&lt;br /&gt;
            fileSize++;&lt;br /&gt;
        }&lt;br /&gt;
        System.out.println(&amp;quot;received DataHandler back from server, the size is &amp;quot; + fileSize);&lt;br /&gt;
        System.out.println(&amp;quot;Successfully run demo with mtom enable&amp;quot;);&lt;br /&gt;
        System.exit(0);&lt;br /&gt;
    }&lt;br /&gt;
    private static InputStream getResourceStream(File file) throws Exception {&lt;br /&gt;
        InputStream in = new FileInputStream(file);&lt;br /&gt;
        return in;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
/////////////////////////////////////////////////////////////////////////////&lt;br /&gt;
/**&lt;br /&gt;
 * Licensed to the Apache Software Foundation (ASF) under one&lt;br /&gt;
 * or more contributor license agreements. See the NOTICE file&lt;br /&gt;
 * distributed with this work for additional information&lt;br /&gt;
 * regarding copyright ownership. The ASF licenses this file&lt;br /&gt;
 * to you under the Apache License, Version 2.0 (the&lt;br /&gt;
 * &amp;quot;License&amp;quot;); you may not use this file except in compliance&lt;br /&gt;
 * with the License. You may obtain a copy of the License at&lt;br /&gt;
 *&lt;br /&gt;
 * http://www.apache.org/licenses/LICENSE-2.0&lt;br /&gt;
 *&lt;br /&gt;
 * Unless required by applicable law or agreed to in writing,&lt;br /&gt;
 * software distributed under the License is distributed on an&lt;br /&gt;
 * &amp;quot;AS IS&amp;quot; BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY&lt;br /&gt;
 * KIND, either express or implied. See the License for the&lt;br /&gt;
 * specific language governing permissions and limitations&lt;br /&gt;
 * under the License.&lt;br /&gt;
 */&lt;br /&gt;
package demo.mtom.server;&lt;br /&gt;
import javax.xml.ws.Binding;&lt;br /&gt;
import javax.xml.ws.Endpoint;&lt;br /&gt;
import javax.xml.ws.soap.SOAPBinding;&lt;br /&gt;
public class Server {&lt;br /&gt;
    protected Server() throws Exception {&lt;br /&gt;
        System.out.println(&amp;quot;Starting Server&amp;quot;);&lt;br /&gt;
        Object implementor = new TestMtomImpl();&lt;br /&gt;
        String address = &amp;quot;http://localhost:9000/mime-test&amp;quot;;&lt;br /&gt;
        Endpoint ep = Endpoint.publish(address, implementor);&lt;br /&gt;
        Binding binding = ep.getBinding();        &lt;br /&gt;
        ((SOAPBinding)binding).setMTOMEnabled(true);        &lt;br /&gt;
    }&lt;br /&gt;
    public static void main(String args[]) throws Exception {&lt;br /&gt;
        new Server();&lt;br /&gt;
        System.out.println(&amp;quot;Server ready...&amp;quot;);&lt;br /&gt;
        Thread.sleep(5 * 60 * 1000);&lt;br /&gt;
        System.out.println(&amp;quot;Server exiting&amp;quot;);&lt;br /&gt;
        System.exit(0);&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
/////////////////////////////////////////////////////////////////////////////&lt;br /&gt;
/**&lt;br /&gt;
 * Licensed to the Apache Software Foundation (ASF) under one&lt;br /&gt;
 * or more contributor license agreements. See the NOTICE file&lt;br /&gt;
 * distributed with this work for additional information&lt;br /&gt;
 * regarding copyright ownership. The ASF licenses this file&lt;br /&gt;
 * to you under the Apache License, Version 2.0 (the&lt;br /&gt;
 * &amp;quot;License&amp;quot;); you may not use this file except in compliance&lt;br /&gt;
 * with the License. You may obtain a copy of the License at&lt;br /&gt;
 *&lt;br /&gt;
 * http://www.apache.org/licenses/LICENSE-2.0&lt;br /&gt;
 *&lt;br /&gt;
 * Unless required by applicable law or agreed to in writing,&lt;br /&gt;
 * software distributed under the License is distributed on an&lt;br /&gt;
 * &amp;quot;AS IS&amp;quot; BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY&lt;br /&gt;
 * KIND, either express or implied. See the License for the&lt;br /&gt;
 * specific language governing permissions and limitations&lt;br /&gt;
 * under the License.&lt;br /&gt;
 */&lt;br /&gt;
package demo.mtom.server;&lt;br /&gt;
import java.io.InputStream;&lt;br /&gt;
import javax.activation.DataHandler;&lt;br /&gt;
import javax.jws.WebService;&lt;br /&gt;
import javax.xml.ws.Holder;&lt;br /&gt;
import org.apache.cxf.mime.TestMtom;&lt;br /&gt;
@WebService(serviceName = &amp;quot;TestMtomService&amp;quot;,&lt;br /&gt;
                portName = &amp;quot;TestMtomPort&amp;quot;,&lt;br /&gt;
                endpointInterface = &amp;quot;org.apache.cxf.mime.TestMtom&amp;quot;,&lt;br /&gt;
                targetNamespace = &amp;quot;http://cxf.apache.org/mime&amp;quot;)&lt;br /&gt;
public class TestMtomImpl implements TestMtom {&lt;br /&gt;
&lt;br /&gt;
    public void testXop(Holder&amp;lt;String&amp;gt; name, Holder&amp;lt;byte[]&amp;gt; attachinfo) {&lt;br /&gt;
        System.out.println(&amp;quot;Received image holder data from client&amp;quot;);&lt;br /&gt;
        System.out.println(&amp;quot;The image holder data length is &amp;quot; + attachinfo.value.length);        &lt;br /&gt;
        name.value = &amp;quot;return detail + &amp;quot; + name.value;        &lt;br /&gt;
    }&lt;br /&gt;
    public void testMtom(Holder&amp;lt;String&amp;gt; name, Holder&amp;lt;DataHandler&amp;gt; attachinfo) {&lt;br /&gt;
        try {&lt;br /&gt;
            System.out.println(&amp;quot;Received image holder data with mtom enable from client&amp;quot;);&lt;br /&gt;
            InputStream mtomIn = attachinfo.value.getInputStream();&lt;br /&gt;
            long fileSize = 0;&lt;br /&gt;
            System.out.println(&amp;quot;The image holder data length is &amp;quot; + mtomIn.available());&lt;br /&gt;
            name.value = &amp;quot;return detail + &amp;quot; + name.value;&lt;br /&gt;
        } catch (Exception e) {&lt;br /&gt;
            e.printStackTrace();&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
/////////////////////////////////////////////////////////////////////////////&lt;br /&gt;
&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;utf-8&amp;quot;?&amp;gt;&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
  Licensed to the Apache Software Foundation (ASF) under one&lt;br /&gt;
  or more contributor license agreements. See the NOTICE file&lt;br /&gt;
  distributed with this work for additional information&lt;br /&gt;
  regarding copyright ownership. The ASF licenses this file&lt;br /&gt;
  to you under the Apache License, Version 2.0 (the&lt;br /&gt;
  &amp;quot;License&amp;quot;); you may not use this file except in compliance&lt;br /&gt;
  with the License. You may obtain a copy of the License at&lt;br /&gt;
&lt;br /&gt;
  http://www.apache.org/licenses/LICENSE-2.0&lt;br /&gt;
&lt;br /&gt;
  Unless required by applicable law or agreed to in writing,&lt;br /&gt;
  software distributed under the License is distributed on an&lt;br /&gt;
  &amp;quot;AS IS&amp;quot; BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY&lt;br /&gt;
  KIND, either express or implied. See the License for the&lt;br /&gt;
  specific language governing permissions and limitations&lt;br /&gt;
  under the License.&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&amp;lt;wsdl:definitions name=&amp;quot;SOAPBuilders-mime-cr-test&amp;quot; xmlns:types=&amp;quot;http://cxf.apache.org/mime/types&amp;quot;&lt;br /&gt;
    xmlns:xsd=&amp;quot;http://www.w3.org/2001/XMLSchema&amp;quot; xmlns:soap=&amp;quot;http://schemas.xmlsoap.org/wsdl/soap/&amp;quot;&lt;br /&gt;
    xmlns:wsdl=&amp;quot;http://schemas.xmlsoap.org/wsdl/&amp;quot; xmlns:tns=&amp;quot;http://cxf.apache.org/mime&amp;quot;&lt;br /&gt;
    xmlns:mime=&amp;quot;http://schemas.xmlsoap.org/wsdl/mime/&amp;quot; &lt;br /&gt;
    xmlns:xmime=&amp;quot;http://www.w3.org/2005/05/xmlmime&amp;quot;    &lt;br /&gt;
    targetNamespace=&amp;quot;http://cxf.apache.org/mime&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;wsdl:types&amp;gt;&lt;br /&gt;
        &amp;lt;schema xmlns=&amp;quot;http://www.w3.org/2001/XMLSchema&amp;quot; targetNamespace=&amp;quot;http://cxf.apache.org/mime/types&amp;quot;&lt;br /&gt;
            xmlns:xmime=&amp;quot;http://www.w3.org/2005/05/xmlmime&amp;quot; elementFormDefault=&amp;quot;qualified&amp;quot;&amp;gt;&lt;br /&gt;
            &amp;lt;complexType name=&amp;quot;XopType&amp;quot;&amp;gt;&lt;br /&gt;
                &amp;lt;sequence&amp;gt;&lt;br /&gt;
                    &amp;lt;element name=&amp;quot;name&amp;quot; type=&amp;quot;xsd:string&amp;quot; /&amp;gt;&lt;br /&gt;
                    &amp;lt;element name=&amp;quot;attachinfo&amp;quot; type=&amp;quot;xsd:base64Binary&amp;quot;/&amp;gt;&lt;br /&gt;
                &amp;lt;/sequence&amp;gt;&lt;br /&gt;
            &amp;lt;/complexType&amp;gt;&lt;br /&gt;
            &amp;lt;element name=&amp;quot;testXop&amp;quot; type=&amp;quot;types:XopType&amp;quot; /&amp;gt;&lt;br /&gt;
            &amp;lt;element name=&amp;quot;testXopResponse&amp;quot; type=&amp;quot;types:XopType&amp;quot; /&amp;gt;&lt;br /&gt;
            &lt;br /&gt;
            &amp;lt;complexType name=&amp;quot;MtomType&amp;quot;&amp;gt;&lt;br /&gt;
                &amp;lt;sequence&amp;gt;&lt;br /&gt;
                    &amp;lt;element name=&amp;quot;name&amp;quot; type=&amp;quot;xsd:string&amp;quot; /&amp;gt;&lt;br /&gt;
                    &amp;lt;element name=&amp;quot;attachinfo&amp;quot; type=&amp;quot;xsd:base64Binary&amp;quot; xmime:expectedContentTypes=&amp;quot;application/octet-stream&amp;quot;/&amp;gt;&lt;br /&gt;
                &amp;lt;/sequence&amp;gt;&lt;br /&gt;
            &amp;lt;/complexType&amp;gt;&lt;br /&gt;
            &amp;lt;element name=&amp;quot;testMtom&amp;quot; type=&amp;quot;types:MtomType&amp;quot; /&amp;gt;&lt;br /&gt;
            &amp;lt;element name=&amp;quot;testMtomResponse&amp;quot; type=&amp;quot;types:MtomType&amp;quot; /&amp;gt;&lt;br /&gt;
        &amp;lt;/schema&amp;gt;&lt;br /&gt;
    &amp;lt;/wsdl:types&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;wsdl:message name=&amp;quot;testXopIn&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;wsdl:part name=&amp;quot;data&amp;quot; element=&amp;quot;types:testXop&amp;quot; /&amp;gt;&lt;br /&gt;
    &amp;lt;/wsdl:message&amp;gt;&lt;br /&gt;
    &amp;lt;wsdl:message name=&amp;quot;testXopOut&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;wsdl:part name=&amp;quot;data&amp;quot; element=&amp;quot;types:testXopResponse&amp;quot; /&amp;gt;&lt;br /&gt;
    &amp;lt;/wsdl:message&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;wsdl:message name=&amp;quot;testMtomIn&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;wsdl:part name=&amp;quot;data&amp;quot; element=&amp;quot;types:testMtom&amp;quot; /&amp;gt;&lt;br /&gt;
    &amp;lt;/wsdl:message&amp;gt;&lt;br /&gt;
    &amp;lt;wsdl:message name=&amp;quot;testMtomOut&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;wsdl:part name=&amp;quot;data&amp;quot; element=&amp;quot;types:testMtomResponse&amp;quot; /&amp;gt;&lt;br /&gt;
    &amp;lt;/wsdl:message&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;wsdl:portType name=&amp;quot;TestMtom&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;wsdl:operation name=&amp;quot;testXop&amp;quot;&amp;gt;&lt;br /&gt;
            &amp;lt;wsdl:input message=&amp;quot;tns:testXopIn&amp;quot; /&amp;gt;&lt;br /&gt;
            &amp;lt;wsdl:output message=&amp;quot;tns:testXopOut&amp;quot; /&amp;gt;&lt;br /&gt;
        &amp;lt;/wsdl:operation&amp;gt;&lt;br /&gt;
        &amp;lt;wsdl:operation name=&amp;quot;testMtom&amp;quot;&amp;gt;&lt;br /&gt;
            &amp;lt;wsdl:input message=&amp;quot;tns:testMtomIn&amp;quot; /&amp;gt;&lt;br /&gt;
            &amp;lt;wsdl:output message=&amp;quot;tns:testMtomOut&amp;quot; /&amp;gt;&lt;br /&gt;
        &amp;lt;/wsdl:operation&amp;gt;&lt;br /&gt;
    &amp;lt;/wsdl:portType&amp;gt;&lt;br /&gt;
    &amp;lt;wsdl:binding name=&amp;quot;TestMtomBinding&amp;quot; type=&amp;quot;tns:TestMtom&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;soap:binding style=&amp;quot;document&amp;quot; transport=&amp;quot;http://schemas.xmlsoap.org/soap/http&amp;quot; /&amp;gt;&lt;br /&gt;
        &amp;lt;wsdl:operation name=&amp;quot;testXop&amp;quot;&amp;gt;&lt;br /&gt;
            &amp;lt;soap:operation soapAction=&amp;quot;&amp;quot; /&amp;gt;&lt;br /&gt;
            &amp;lt;wsdl:input&amp;gt;&lt;br /&gt;
                &amp;lt;soap:body use=&amp;quot;literal&amp;quot; /&amp;gt;&lt;br /&gt;
            &amp;lt;/wsdl:input&amp;gt;&lt;br /&gt;
            &amp;lt;wsdl:output&amp;gt;&lt;br /&gt;
                &amp;lt;soap:body use=&amp;quot;literal&amp;quot; /&amp;gt;&lt;br /&gt;
            &amp;lt;/wsdl:output&amp;gt;&lt;br /&gt;
        &amp;lt;/wsdl:operation&amp;gt;&lt;br /&gt;
        &amp;lt;wsdl:operation name=&amp;quot;testMtom&amp;quot;&amp;gt;&lt;br /&gt;
            &amp;lt;soap:operation soapAction=&amp;quot;&amp;quot; /&amp;gt;&lt;br /&gt;
            &amp;lt;wsdl:input&amp;gt;&lt;br /&gt;
                &amp;lt;soap:body use=&amp;quot;literal&amp;quot; /&amp;gt;&lt;br /&gt;
            &amp;lt;/wsdl:input&amp;gt;&lt;br /&gt;
            &amp;lt;wsdl:output&amp;gt;&lt;br /&gt;
                &amp;lt;soap:body use=&amp;quot;literal&amp;quot; /&amp;gt;&lt;br /&gt;
            &amp;lt;/wsdl:output&amp;gt;&lt;br /&gt;
        &amp;lt;/wsdl:operation&amp;gt;&lt;br /&gt;
    &amp;lt;/wsdl:binding&amp;gt;&lt;br /&gt;
    &amp;lt;wsdl:service name=&amp;quot;TestMtomService&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;wsdl:port name=&amp;quot;TestMtomPort&amp;quot; binding=&amp;quot;tns:TestMtomBinding&amp;quot;&amp;gt;&lt;br /&gt;
            &amp;lt;soap:address location=&amp;quot;http://localhost:9000/mime-test&amp;quot; /&amp;gt;&lt;br /&gt;
        &amp;lt;/wsdl:port&amp;gt;&lt;br /&gt;
    &amp;lt;/wsdl:service&amp;gt;&lt;br /&gt;
&amp;lt;/wsdl:definitions&amp;gt;&lt;br /&gt;
&lt;br /&gt;
        &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Demonstrates the capabilities and power of SOAP with Attachment support and the Attachment API of AXIS2 ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
Sample: SOAP with Attachments&lt;br /&gt;
================================&lt;br /&gt;
Introduction&lt;br /&gt;
============&lt;br /&gt;
This sample demonstrates the capabilities and power of SOAP with Attachment support and the&lt;br /&gt;
Attachment API of AXIS2. More information about Axis2 attachment implementation can be found at &lt;br /&gt;
http://ws.apache.org/axis2/1_1/mtom-guide.html. &lt;br /&gt;
This sample includes a service and a client which can be used to upload a file to the server using &lt;br /&gt;
SOAP message containing a SOAP with Attachment type binary attachment. The service is written and &lt;br /&gt;
deployed using the RCPMessageReceiver and a POJO(Plain Old Java Object). The POJO service class uses &lt;br /&gt;
the Attachment API of the MessageContext to retrieve the received attachment.The client program is &lt;br /&gt;
written using the OperationClient API of Axis2 together with the Attachment API of MessageContext.&lt;br /&gt;
&lt;br /&gt;
Objectives&lt;br /&gt;
==========&lt;br /&gt;
 * Writing a POJO (Plain Old Java Object) based service to access attachments.&lt;br /&gt;
 * Implement a Axis2 OperationClient based Web Service client to invoke the service with SOAP &lt;br /&gt;
   with Attachment type attachments.&lt;br /&gt;
 * Invoke the deployed service.&lt;br /&gt;
Prerequisites&lt;br /&gt;
=============&lt;br /&gt;
Install Apache Ant 1.6.2 or later&lt;br /&gt;
&lt;br /&gt;
Running the Sample:&lt;br /&gt;
===================&lt;br /&gt;
The files belonging to this sample are contained in the samples/soapwithattachments folder of the &lt;br /&gt;
extracted Axis2 binary distribution, which will be called here after as SWA_SAMPLE_DIR. The &lt;br /&gt;
location of the extracted binary distribution will be refered as AXIS2_DIST. There is a &lt;br /&gt;
&amp;quot;build.xml&amp;quot; Ant script in the SWA_SAMPLE_DIR that contains build targets for building the service &lt;br /&gt;
archive and running the client application - all described in steps below. &lt;br /&gt;
1. Generate the service&lt;br /&gt;
Use &amp;quot;ant generate.service&amp;quot; command in the SWA_SAMPLE_DIR to build the service. Generated service &lt;br /&gt;
will automatically gets copied in to the AXIS2_DIST/repository/services directory. Source file &lt;br /&gt;
ralating to this service can be found at &lt;br /&gt;
SWA_SAMPLE_DIR/src/sample/soapwithattachments/service/AttachmentService.java. The services.xml used&lt;br /&gt;
when building this service can be found at SWA_SAMPLE_DIR/resources directory. &lt;br /&gt;
2. Deploy the service&lt;br /&gt;
Run the AXIS2_DIST/bin/axis2server.{sh.bat} script to start the standalone axis2 server. This server &lt;br /&gt;
will deploy all the srvices available at AXIS2_DIST/repository/services directory. Alternatively you&lt;br /&gt;
can drop the sample-swa.aar service archive to the services directory of a running Axis2 servlet)&lt;br /&gt;
3. Running the client&lt;br /&gt;
Use &amp;quot;ant run.client -Dfile &amp;lt;file to be send&amp;gt; -Ddest &amp;lt;destination file name&amp;gt;&amp;quot; command in the &lt;br /&gt;
SWA_SAMPLE_DIR to build and run the client. Source file ralating to the client can be found at &lt;br /&gt;
SWA_SAMPLE_DIR/src/sample/soapwithattachments/client/SWAClient.java.&lt;br /&gt;
Help&lt;br /&gt;
====&lt;br /&gt;
Please contact axis-user list (axis-user@ws.apache.org) if you have any trouble running the sample.&lt;br /&gt;
&lt;br /&gt;
        &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Hello World SOAP12 Demo using Document/Literal Style: the use of Apache CXF&amp;quot;s SOAP 1.2 capabilities ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
Hello World SOAP12 Demo using Document/Literal Style&lt;br /&gt;
====================================================&lt;br /&gt;
This demo shows the use of Apache CXF&amp;quot;s SOAP 1.2 capabilities.&lt;br /&gt;
Please review the README in the samples directory before&lt;br /&gt;
continuing.&lt;br /&gt;
&lt;br /&gt;
Prerequisites&lt;br /&gt;
-------------&lt;br /&gt;
If your environment already includes cxf-manifest-incubator.jar on the&lt;br /&gt;
CLASSPATH, and the JDK and ant bin directories on the PATH&lt;br /&gt;
it is not necessary to set the environment as described in&lt;br /&gt;
the samples directory&amp;quot;s README.  If your environment is not&lt;br /&gt;
properly configured, or if you are planning on using wsdl2java,&lt;br /&gt;
javac, and java to build and run the demos, you must set the&lt;br /&gt;
environment.&lt;br /&gt;
&lt;br /&gt;
Building and running the demo using ant&lt;br /&gt;
---------------------------------------&lt;br /&gt;
From the samples/hello_world directory, the ant build script&lt;br /&gt;
can be used to build and run the demo.&lt;br /&gt;
Using either UNIX or Windows:&lt;br /&gt;
  ant build&lt;br /&gt;
  ant server&lt;br /&gt;
  ant client&lt;br /&gt;
    &lt;br /&gt;
To remove the code generated from the WSDL file and the .class&lt;br /&gt;
files, run:&lt;br /&gt;
  ant clean&lt;br /&gt;
&lt;br /&gt;
Building the demo using wsdl2java and javac&lt;br /&gt;
-------------------------------------------&lt;br /&gt;
From the samples/hello_world directory, first create the target&lt;br /&gt;
directory build/classes and then generate code from the WSDL file.&lt;br /&gt;
For UNIX:&lt;br /&gt;
  mkdir -p build/classes&lt;br /&gt;
  wsdl2java -d build/classes -compile ./wsdl/hello_world_soap12.wsdl&lt;br /&gt;
For Windows:&lt;br /&gt;
  mkdir build\classes&lt;br /&gt;
    Must use back slashes.&lt;br /&gt;
  wsdl2java -d build\classes -compile .\wsdl\hello_world_soap12.wsdl&lt;br /&gt;
    May use either forward or back slashes.&lt;br /&gt;
Now compile the provided client and server applications with the commands:&lt;br /&gt;
For UNIX:  &lt;br /&gt;
  &lt;br /&gt;
  export CLASSPATH=$CLASSPATH:$CXF_HOME/lib/cxf-manifest-incubator.jar:./build/classes&lt;br /&gt;
  javac -d build/classes src/demo/hw/client/*.java&lt;br /&gt;
  javac -d build/classes src/demo/hw/server/*.java&lt;br /&gt;
For Windows:&lt;br /&gt;
  set classpath=%classpath%;%CXF_HOME%\lib\cxf-manifest-incubator.jar;.\build\classes&lt;br /&gt;
  javac -d build\classes src\demo\hw\client\*.java&lt;br /&gt;
  javac -d build\classes src\demo\hw\server\*.java&lt;br /&gt;
&lt;br /&gt;
Running the demo using java&lt;br /&gt;
---------------------------&lt;br /&gt;
From the samples/hello_world directory run the following commands. &lt;br /&gt;
They are entered on a single command line:&lt;br /&gt;
For UNIX (must use forward slashes):&lt;br /&gt;
    java -Djava.util.logging.config.file=$CXF_HOME/etc/logging.properties&lt;br /&gt;
         demo.hw.server.Server &amp;amp;&lt;br /&gt;
    java -Djava.util.logging.config.file=$CXF_HOME/etc/logging.properties&lt;br /&gt;
         demo.hw.client.Client ./wsdl/hello_world_soap12.wsdl&lt;br /&gt;
The server process starts in the background.  After running the client,&lt;br /&gt;
use the kill command to terminate the server process.&lt;br /&gt;
For Windows (may use either forward or back slashes):&lt;br /&gt;
  start &lt;br /&gt;
    java -Djava.util.logging.config.file=%CXF_HOME%\etc\logging.properties&lt;br /&gt;
         demo.hw.server.Server&lt;br /&gt;
    java -Djava.util.logging.config.file=%CXF_HOME%\etc\logging.properties&lt;br /&gt;
       demo.hw.client.Client .\wsdl\hello_world_soap12.wsdl&lt;br /&gt;
A new command windows opens for the server process.  After running the&lt;br /&gt;
client, terminate the server process by issuing Ctrl-C in its command window.&lt;br /&gt;
To remove the code generated from the WSDL file and the .class&lt;br /&gt;
files, either delete the build directory and its contents or run:&lt;br /&gt;
  ant clean&lt;br /&gt;
&lt;br /&gt;
Building and running the demo in a servlet container&lt;br /&gt;
----------------------------------------------------&lt;br /&gt;
From the samples/hello_world directory, the ant build script&lt;br /&gt;
can be used to create the war file that is deployed into the&lt;br /&gt;
servlet container.&lt;br /&gt;
Build the war file with the command:&lt;br /&gt;
  ant war&lt;br /&gt;
    &lt;br /&gt;
Preparing deploy to APACHE TOMCAT&lt;br /&gt;
* set CATALINA_HOME environment to your TOMCAT home directory&lt;br /&gt;
    &lt;br /&gt;
Deploy the application into APACHE TOMCAT with the commond:&lt;br /&gt;
[NOTE] This step will check if the cxf jars present in Tomcat, &lt;br /&gt;
       if not, it will automatically copy all the jars into CATALINA_HOME/shared/lib&lt;br /&gt;
  &lt;br /&gt;
  ant deploy -Dtomcat=true&lt;br /&gt;
The servlet container will extract the war and deploy the application.&lt;br /&gt;
&lt;br /&gt;
Using ant, run the client application with the command:&lt;br /&gt;
  ant client-servlet -Dbase.url=http://localhost:#&lt;br /&gt;
Where # is the TCP/IP port used by the servlet container,&lt;br /&gt;
e.g., 8080.&lt;br /&gt;
Or&lt;br /&gt;
  ant client-servlet -Dhost=localhost -Dport=8080&lt;br /&gt;
You can ignore the -Dhost and -Dport if your tomcat setup is same, i.e ant client-servlet&lt;br /&gt;
Using java, run the client application with the command:&lt;br /&gt;
  For UNIX:&lt;br /&gt;
    &lt;br /&gt;
    java -Djava.util.logging.config.file=$CXF_HOME/etc/logging.properties&lt;br /&gt;
         demo.hw.client.Client http://localhost:#/helloworld/services/hello_world_soap12?wsdl&lt;br /&gt;
  For Windows:&lt;br /&gt;
    java -Djava.util.logging.config.file=%CXF_HOME%\etc\logging.properties&lt;br /&gt;
       demo.hw.client.Client http://localhost:#/helloworld/services/hello_world_soap12?wsdl&lt;br /&gt;
Where # is the TCP/IP port used by the servlet container,&lt;br /&gt;
e.g., 8080.&lt;br /&gt;
Undeploy the application from the APACHE TOMCAT with the command:&lt;br /&gt;
   ant undeploy -Dtomcat=true&lt;br /&gt;
&lt;br /&gt;
Running demo with HTTP GET&lt;br /&gt;
----------------------------------------------------&lt;br /&gt;
APACHE CXF support HTTP GET to invoke the service, instead of running &lt;br /&gt;
   ant client&lt;br /&gt;
you can use &lt;br /&gt;
   ant client.get &lt;br /&gt;
to invoke the service with simple HttpURLConnection, or you can even&lt;br /&gt;
use your favorite browser to get the results back.&lt;br /&gt;
&lt;br /&gt;
////////////////////////////////////////////////////////////////////////////&lt;br /&gt;
&lt;br /&gt;
/**&lt;br /&gt;
 * Licensed to the Apache Software Foundation (ASF) under one&lt;br /&gt;
 * or more contributor license agreements. See the NOTICE file&lt;br /&gt;
 * distributed with this work for additional information&lt;br /&gt;
 * regarding copyright ownership. The ASF licenses this file&lt;br /&gt;
 * to you under the Apache License, Version 2.0 (the&lt;br /&gt;
 * &amp;quot;License&amp;quot;); you may not use this file except in compliance&lt;br /&gt;
 * with the License. You may obtain a copy of the License at&lt;br /&gt;
 *&lt;br /&gt;
 * http://www.apache.org/licenses/LICENSE-2.0&lt;br /&gt;
 *&lt;br /&gt;
 * Unless required by applicable law or agreed to in writing,&lt;br /&gt;
 * software distributed under the License is distributed on an&lt;br /&gt;
 * &amp;quot;AS IS&amp;quot; BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY&lt;br /&gt;
 * KIND, either express or implied. See the License for the&lt;br /&gt;
 * specific language governing permissions and limitations&lt;br /&gt;
 * under the License.&lt;br /&gt;
 */&lt;br /&gt;
package demo.hw.client;&lt;br /&gt;
import java.io.File;&lt;br /&gt;
import java.net.URL;&lt;br /&gt;
import javax.xml.namespace.QName;&lt;br /&gt;
import javax.xml.ws.ProtocolException;&lt;br /&gt;
import org.apache.hello_world_soap12_http.Greeter;&lt;br /&gt;
import org.apache.hello_world_soap12_http.PingMeFault;&lt;br /&gt;
import org.apache.hello_world_soap12_http.SOAPService;&lt;br /&gt;
import org.apache.hello_world_soap12_http.types.FaultDetail;&lt;br /&gt;
public final class Client {&lt;br /&gt;
    private static final QName SERVICE_NAME &lt;br /&gt;
        = new QName(&amp;quot;http://apache.org/hello_world_soap12_http&amp;quot;, &amp;quot;SOAPService&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
    private Client() {&lt;br /&gt;
    } &lt;br /&gt;
    public static void main(String args[]) throws Exception {&lt;br /&gt;
        &lt;br /&gt;
        if (args.length == 0) { &lt;br /&gt;
            System.out.println(&amp;quot;please specify wsdl&amp;quot;);&lt;br /&gt;
            System.exit(1); &lt;br /&gt;
        }&lt;br /&gt;
        URL wsdlURL;&lt;br /&gt;
        File wsdlFile = new File(args[0]);&lt;br /&gt;
        if (wsdlFile.exists()) {&lt;br /&gt;
            wsdlURL = wsdlFile.toURL();&lt;br /&gt;
        } else {&lt;br /&gt;
            wsdlURL = new URL(args[0]);&lt;br /&gt;
        }&lt;br /&gt;
        &lt;br /&gt;
        System.out.println(wsdlURL);&lt;br /&gt;
        SOAPService ss = new SOAPService(wsdlURL, SERVICE_NAME);&lt;br /&gt;
        Greeter port = ss.getSoapPort();&lt;br /&gt;
        String resp; &lt;br /&gt;
        System.out.println(&amp;quot;Invoking sayHi...&amp;quot;);&lt;br /&gt;
        resp = port.sayHi();&lt;br /&gt;
        System.out.println(&amp;quot;Server responded with: &amp;quot; + resp);&lt;br /&gt;
        System.out.println();&lt;br /&gt;
        System.out.println(&amp;quot;Invoking greetMe...&amp;quot;);&lt;br /&gt;
        resp = port.greetMe(System.getProperty(&amp;quot;user.name&amp;quot;));&lt;br /&gt;
        System.out.println(&amp;quot;Server responded with: &amp;quot; + resp);&lt;br /&gt;
        System.out.println();&lt;br /&gt;
        System.out.println(&amp;quot;Invoking greetMe with invalid length string, expecting exception...&amp;quot;);&lt;br /&gt;
        try {&lt;br /&gt;
            resp = port.greetMe(&amp;quot;Invoking greetMe with invalid length string, expecting exception...&amp;quot;);&lt;br /&gt;
        } catch (ProtocolException e) {&lt;br /&gt;
            System.out.println(&amp;quot;Expected exception has occurred: &amp;quot; + e.getClass().getName());&lt;br /&gt;
        }&lt;br /&gt;
        System.out.println();&lt;br /&gt;
        System.out.println(&amp;quot;Invoking greetMeOneWay...&amp;quot;);&lt;br /&gt;
        port.greetMeOneWay(System.getProperty(&amp;quot;user.name&amp;quot;));&lt;br /&gt;
        System.out.println(&amp;quot;No response from server as method is OneWay&amp;quot;);&lt;br /&gt;
        System.out.println();&lt;br /&gt;
        try {&lt;br /&gt;
            System.out.println(&amp;quot;Invoking pingMe, expecting exception...&amp;quot;);&lt;br /&gt;
            port.pingMe();&lt;br /&gt;
        } catch (PingMeFault ex) {&lt;br /&gt;
            System.out.println(&amp;quot;Expected exception: PingMeFault has occurred: &amp;quot; + ex.getMessage());&lt;br /&gt;
            FaultDetail detail = ex.getFaultInfo();&lt;br /&gt;
            System.out.println(&amp;quot;FaultDetail major:&amp;quot; + detail.getMajor());&lt;br /&gt;
            System.out.println(&amp;quot;FaultDetail minor:&amp;quot; + detail.getMinor());            &lt;br /&gt;
        }          &lt;br /&gt;
        System.exit(0); &lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
/////////////////////////////////////////////////////////////////////////////&lt;br /&gt;
/**&lt;br /&gt;
 * Licensed to the Apache Software Foundation (ASF) under one&lt;br /&gt;
 * or more contributor license agreements. See the NOTICE file&lt;br /&gt;
 * distributed with this work for additional information&lt;br /&gt;
 * regarding copyright ownership. The ASF licenses this file&lt;br /&gt;
 * to you under the Apache License, Version 2.0 (the&lt;br /&gt;
 * &amp;quot;License&amp;quot;); you may not use this file except in compliance&lt;br /&gt;
 * with the License. You may obtain a copy of the License at&lt;br /&gt;
 *&lt;br /&gt;
 * http://www.apache.org/licenses/LICENSE-2.0&lt;br /&gt;
 *&lt;br /&gt;
 * Unless required by applicable law or agreed to in writing,&lt;br /&gt;
 * software distributed under the License is distributed on an&lt;br /&gt;
 * &amp;quot;AS IS&amp;quot; BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY&lt;br /&gt;
 * KIND, either express or implied. See the License for the&lt;br /&gt;
 * specific language governing permissions and limitations&lt;br /&gt;
 * under the License.&lt;br /&gt;
 */&lt;br /&gt;
package demo.hw.client;&lt;br /&gt;
import java.io.ByteArrayOutputStream;&lt;br /&gt;
import java.io.InputStream;&lt;br /&gt;
import java.net.HttpURLConnection;&lt;br /&gt;
import java.net.URL;&lt;br /&gt;
import java.util.Properties;&lt;br /&gt;
import javax.xml.transform.OutputKeys;&lt;br /&gt;
import javax.xml.transform.Source;&lt;br /&gt;
import javax.xml.transform.Transformer;&lt;br /&gt;
import javax.xml.transform.TransformerFactory;&lt;br /&gt;
import javax.xml.transform.stream.StreamResult;&lt;br /&gt;
import javax.xml.transform.stream.StreamSource;&lt;br /&gt;
public final class Get {&lt;br /&gt;
    private Get() {&lt;br /&gt;
    } &lt;br /&gt;
    public static void main(String args[]) throws Exception {&lt;br /&gt;
        // Sent HTTP GET request to invoke sayHi&lt;br /&gt;
        String target = &amp;quot;http://localhost:9000/SoapContext/SoapPort/sayHi&amp;quot;;&lt;br /&gt;
        URL url = new URL(target);&lt;br /&gt;
        HttpURLConnection httpConnection = (HttpURLConnection) url.openConnection();&lt;br /&gt;
        httpConnection.connect();&lt;br /&gt;
        System.out.println(&amp;quot;Invoking server through HTTP GET to invoke sayHi&amp;quot;);&lt;br /&gt;
        InputStream in = httpConnection.getInputStream();&lt;br /&gt;
        StreamSource source = new StreamSource(in);&lt;br /&gt;
        printSource(source);&lt;br /&gt;
        // Sent HTTP GET request to invoke greetMe FAULT&lt;br /&gt;
        target = &amp;quot;http://localhost:9000/SoapContext/SoapPort/greetMe/me/CXF&amp;quot;;&lt;br /&gt;
        url = new URL(target);&lt;br /&gt;
        httpConnection = (HttpURLConnection) url.openConnection();&lt;br /&gt;
        httpConnection.connect();&lt;br /&gt;
        System.out.println(&amp;quot;Invoking server through HTTP GET to invoke greetMe&amp;quot;);&lt;br /&gt;
        try {&lt;br /&gt;
            in = httpConnection.getInputStream();&lt;br /&gt;
            source = new StreamSource(in);&lt;br /&gt;
            printSource(source);&lt;br /&gt;
        } catch (Exception e) {&lt;br /&gt;
            System.err.println(&amp;quot;GreetMe Fault: &amp;quot; + e.getMessage());&lt;br /&gt;
        }&lt;br /&gt;
        InputStream err = httpConnection.getErrorStream();&lt;br /&gt;
        source = new StreamSource(err);&lt;br /&gt;
        printSource(source);&lt;br /&gt;
        // Sent HTTP GET request to invoke greetMe&lt;br /&gt;
        target = &amp;quot;http://localhost:9000/SoapContext/SoapPort/greetMe/requestType/CXF&amp;quot;;&lt;br /&gt;
        url = new URL(target);&lt;br /&gt;
        httpConnection = (HttpURLConnection) url.openConnection();&lt;br /&gt;
        httpConnection.connect();&lt;br /&gt;
        System.out.println(&amp;quot;Invoking server through HTTP GET to invoke greetMe&amp;quot;);&lt;br /&gt;
        in = httpConnection.getInputStream();&lt;br /&gt;
        source = new StreamSource(in);&lt;br /&gt;
        printSource(source);&lt;br /&gt;
        // Sent HTTP GET request to invoke pingMe&lt;br /&gt;
        target = &amp;quot;http://localhost:9000/SoapContext/SoapPort/pingMe&amp;quot;;&lt;br /&gt;
        url = new URL(target);&lt;br /&gt;
        httpConnection = (HttpURLConnection) url.openConnection();&lt;br /&gt;
        httpConnection.connect();&lt;br /&gt;
        System.out.println(&amp;quot;Invoking server through HTTP GET to invoke pingMe&amp;quot;);&lt;br /&gt;
        try {&lt;br /&gt;
            in = httpConnection.getInputStream();&lt;br /&gt;
        } catch (Exception e) {&lt;br /&gt;
            System.out.println(&amp;quot;PingMe fault raised&amp;quot;);&lt;br /&gt;
        }&lt;br /&gt;
        err = httpConnection.getErrorStream();&lt;br /&gt;
        source = new StreamSource(err);&lt;br /&gt;
        printSource(source);&lt;br /&gt;
    }&lt;br /&gt;
    private static void printSource(Source source) {&lt;br /&gt;
        try {&lt;br /&gt;
            ByteArrayOutputStream bos = new ByteArrayOutputStream();&lt;br /&gt;
            StreamResult sr = new StreamResult(bos);&lt;br /&gt;
            Transformer trans = TransformerFactory.newInstance().newTransformer();&lt;br /&gt;
            Properties oprops = new Properties();&lt;br /&gt;
            oprops.put(OutputKeys.OMIT_XML_DECLARATION, &amp;quot;yes&amp;quot;);&lt;br /&gt;
            trans.setOutputProperties(oprops);&lt;br /&gt;
            trans.transform(source, sr);&lt;br /&gt;
            System.out.println();&lt;br /&gt;
            System.out.println(&amp;quot;**** Response ******&amp;quot;);&lt;br /&gt;
            System.out.println();&lt;br /&gt;
            System.out.println(bos.toString());&lt;br /&gt;
            bos.close();&lt;br /&gt;
            System.out.println();&lt;br /&gt;
        } catch (Exception e) {&lt;br /&gt;
            e.printStackTrace();&lt;br /&gt;
        }&lt;br /&gt;
    }    &lt;br /&gt;
}&lt;br /&gt;
/////////////////////////////////////////////////////////////////////////////&lt;br /&gt;
/**&lt;br /&gt;
 * Licensed to the Apache Software Foundation (ASF) under one&lt;br /&gt;
 * or more contributor license agreements. See the NOTICE file&lt;br /&gt;
 * distributed with this work for additional information&lt;br /&gt;
 * regarding copyright ownership. The ASF licenses this file&lt;br /&gt;
 * to you under the Apache License, Version 2.0 (the&lt;br /&gt;
 * &amp;quot;License&amp;quot;); you may not use this file except in compliance&lt;br /&gt;
 * with the License. You may obtain a copy of the License at&lt;br /&gt;
 *&lt;br /&gt;
 * http://www.apache.org/licenses/LICENSE-2.0&lt;br /&gt;
 *&lt;br /&gt;
 * Unless required by applicable law or agreed to in writing,&lt;br /&gt;
 * software distributed under the License is distributed on an&lt;br /&gt;
 * &amp;quot;AS IS&amp;quot; BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY&lt;br /&gt;
 * KIND, either express or implied. See the License for the&lt;br /&gt;
 * specific language governing permissions and limitations&lt;br /&gt;
 * under the License.&lt;br /&gt;
 */&lt;br /&gt;
package demo.hw.server;&lt;br /&gt;
import java.util.logging.Logger;&lt;br /&gt;
import org.apache.hello_world_soap12_http.Greeter;&lt;br /&gt;
import org.apache.hello_world_soap12_http.PingMeFault;&lt;br /&gt;
import org.apache.hello_world_soap12_http.types.FaultDetail;&lt;br /&gt;
@javax.jws.WebService(portName = &amp;quot;SoapPort&amp;quot;, serviceName = &amp;quot;SOAPService&amp;quot;, &lt;br /&gt;
                      targetNamespace = &amp;quot;http://apache.org/hello_world_soap12_http&amp;quot;, &lt;br /&gt;
                      endpointInterface = &amp;quot;org.apache.hello_world_soap12_http.Greeter&amp;quot;)&lt;br /&gt;
@javax.xml.ws.BindingType(value = &amp;quot;http://www.w3.org/2003/05/soap/bindings/HTTP/&amp;quot;)                  &lt;br /&gt;
public class GreeterImpl implements Greeter {&lt;br /&gt;
    private static final Logger LOG = &lt;br /&gt;
        Logger.getLogger(GreeterImpl.class.getPackage().getName());&lt;br /&gt;
    &lt;br /&gt;
    public String greetMe(String me) {&lt;br /&gt;
        LOG.info(&amp;quot;Executing operation greetMe&amp;quot;);&lt;br /&gt;
        System.out.println(&amp;quot;Executing operation greetMe&amp;quot;);&lt;br /&gt;
        System.out.println(&amp;quot;Message received: &amp;quot; + me + &amp;quot;\n&amp;quot;);&lt;br /&gt;
        return &amp;quot;Hello &amp;quot; + me;&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    public void greetMeOneWay(String me) {&lt;br /&gt;
        LOG.info(&amp;quot;Executing operation greetMeOneWay&amp;quot;);&lt;br /&gt;
        System.out.println(&amp;quot;Executing operation greetMeOneWay\n&amp;quot;);&lt;br /&gt;
        System.out.println(&amp;quot;Hello there &amp;quot; + me);&lt;br /&gt;
    }&lt;br /&gt;
    public String sayHi() {&lt;br /&gt;
        LOG.info(&amp;quot;Executing operation sayHi&amp;quot;);&lt;br /&gt;
        System.out.println(&amp;quot;Executing operation sayHi\n&amp;quot;);&lt;br /&gt;
        return &amp;quot;Bonjour&amp;quot;;&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    public void pingMe() throws PingMeFault {&lt;br /&gt;
        FaultDetail faultDetail = new FaultDetail();&lt;br /&gt;
        faultDetail.setMajor((short)2);&lt;br /&gt;
        faultDetail.setMinor((short)1);&lt;br /&gt;
        LOG.info(&amp;quot;Executing operation pingMe, throwing PingMeFault exception&amp;quot;);&lt;br /&gt;
        System.out.println(&amp;quot;Executing operation pingMe, throwing PingMeFault exception\n&amp;quot;);&lt;br /&gt;
        throw new PingMeFault(&amp;quot;PingMeFault raised by server&amp;quot;, faultDetail);&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
}&lt;br /&gt;
/////////////////////////////////////////////////////////////////////////////&lt;br /&gt;
/**&lt;br /&gt;
 * Licensed to the Apache Software Foundation (ASF) under one&lt;br /&gt;
 * or more contributor license agreements. See the NOTICE file&lt;br /&gt;
 * distributed with this work for additional information&lt;br /&gt;
 * regarding copyright ownership. The ASF licenses this file&lt;br /&gt;
 * to you under the Apache License, Version 2.0 (the&lt;br /&gt;
 * &amp;quot;License&amp;quot;); you may not use this file except in compliance&lt;br /&gt;
 * with the License. You may obtain a copy of the License at&lt;br /&gt;
 *&lt;br /&gt;
 * http://www.apache.org/licenses/LICENSE-2.0&lt;br /&gt;
 *&lt;br /&gt;
 * Unless required by applicable law or agreed to in writing,&lt;br /&gt;
 * software distributed under the License is distributed on an&lt;br /&gt;
 * &amp;quot;AS IS&amp;quot; BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY&lt;br /&gt;
 * KIND, either express or implied. See the License for the&lt;br /&gt;
 * specific language governing permissions and limitations&lt;br /&gt;
 * under the License.&lt;br /&gt;
 */&lt;br /&gt;
package demo.hw.server;&lt;br /&gt;
import javax.xml.ws.Endpoint;&lt;br /&gt;
public class Server {&lt;br /&gt;
    protected Server() throws Exception {&lt;br /&gt;
        System.out.println(&amp;quot;Starting Server&amp;quot;);&lt;br /&gt;
        Object implementor = new GreeterImpl();&lt;br /&gt;
        String address = &amp;quot;http://localhost:9000/SoapContext/SoapPort&amp;quot;;&lt;br /&gt;
        Endpoint.publish(address, implementor);&lt;br /&gt;
    }&lt;br /&gt;
    public static void main(String args[]) throws Exception {&lt;br /&gt;
        new Server();&lt;br /&gt;
        System.out.println(&amp;quot;Server ready...&amp;quot;);&lt;br /&gt;
        Thread.sleep(5 * 60 * 1000);&lt;br /&gt;
        System.out.println(&amp;quot;Server exiting&amp;quot;);&lt;br /&gt;
        System.exit(0);&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
////////////////////////////////////////////////////////////////////////////////&lt;br /&gt;
&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot;?&amp;gt;&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
  Licensed to the Apache Software Foundation (ASF) under one&lt;br /&gt;
  or more contributor license agreements. See the NOTICE file&lt;br /&gt;
  distributed with this work for additional information&lt;br /&gt;
  regarding copyright ownership. The ASF licenses this file&lt;br /&gt;
  to you under the Apache License, Version 2.0 (the&lt;br /&gt;
  &amp;quot;License&amp;quot;); you may not use this file except in compliance&lt;br /&gt;
  with the License. You may obtain a copy of the License at&lt;br /&gt;
 &lt;br /&gt;
  http://www.apache.org/licenses/LICENSE-2.0&lt;br /&gt;
 &lt;br /&gt;
  Unless required by applicable law or agreed to in writing,&lt;br /&gt;
  software distributed under the License is distributed on an&lt;br /&gt;
  &amp;quot;AS IS&amp;quot; BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY&lt;br /&gt;
  KIND, either express or implied. See the License for the&lt;br /&gt;
  specific language governing permissions and limitations&lt;br /&gt;
  under the License.&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&amp;lt;definitions name=&amp;quot;HelloWorld&amp;quot;&lt;br /&gt;
       xmlns=&amp;quot;http://schemas.xmlsoap.org/wsdl/&amp;quot;&lt;br /&gt;
       xmlns:tns=&amp;quot;http://apache.org/hello_world_soap12_http&amp;quot;&lt;br /&gt;
       xmlns:x1=&amp;quot;http://apache.org/hello_world_soap12_http/types&amp;quot;&lt;br /&gt;
       xmlns:wsdl=&amp;quot;http://schemas.xmlsoap.org/wsdl/&amp;quot;&lt;br /&gt;
       xmlns:xsd=&amp;quot;http://www.w3.org/2001/XMLSchema&amp;quot;&lt;br /&gt;
       targetNamespace=&amp;quot;http://apache.org/hello_world_soap12_http&amp;quot;&lt;br /&gt;
       xmlns:soap12=&amp;quot;http://schemas.xmlsoap.org/wsdl/soap12/&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;wsdl:types&amp;gt;&lt;br /&gt;
  &amp;lt;schema targetNamespace=&amp;quot;http://apache.org/hello_world_soap12_http/types&amp;quot; &lt;br /&gt;
    xmlns=&amp;quot;http://www.w3.org/2001/XMLSchema&amp;quot; &lt;br /&gt;
    xmlns:x1=&amp;quot;http://apache.org/hello_world_soap12_http/types&amp;quot; &lt;br /&gt;
    elementFormDefault=&amp;quot;qualified&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;simpleType name=&amp;quot;MyStringType&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;restriction base=&amp;quot;string&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;maxLength value=&amp;quot;30&amp;quot; /&amp;gt;&lt;br /&gt;
    &amp;lt;/restriction&amp;gt;&lt;br /&gt;
      &amp;lt;/simpleType&amp;gt;&lt;br /&gt;
      &amp;lt;element name=&amp;quot;sayHi&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;complexType/&amp;gt;&lt;br /&gt;
      &amp;lt;/element&amp;gt;&lt;br /&gt;
      &amp;lt;element name=&amp;quot;sayHiResponse&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;complexType&amp;gt;&lt;br /&gt;
        &amp;lt;sequence&amp;gt;&lt;br /&gt;
      &amp;lt;element name=&amp;quot;responseType&amp;quot; type=&amp;quot;string&amp;quot;/&amp;gt;&lt;br /&gt;
        &amp;lt;/sequence&amp;gt;&lt;br /&gt;
    &amp;lt;/complexType&amp;gt;&lt;br /&gt;
      &amp;lt;/element&amp;gt;&lt;br /&gt;
            &amp;lt;element name=&amp;quot;greetMe&amp;quot;&amp;gt;&lt;br /&gt;
                &amp;lt;complexType&amp;gt;&lt;br /&gt;
                    &amp;lt;sequence&amp;gt;&lt;br /&gt;
                        &amp;lt;element name=&amp;quot;requestType&amp;quot; type=&amp;quot;x1:MyStringType&amp;quot;/&amp;gt;&lt;br /&gt;
                    &amp;lt;/sequence&amp;gt;&lt;br /&gt;
                &amp;lt;/complexType&amp;gt;&lt;br /&gt;
            &amp;lt;/element&amp;gt;&lt;br /&gt;
            &amp;lt;element name=&amp;quot;greetMeResponse&amp;quot;&amp;gt;&lt;br /&gt;
                &amp;lt;complexType&amp;gt;&lt;br /&gt;
                    &amp;lt;sequence&amp;gt;&lt;br /&gt;
                        &amp;lt;element name=&amp;quot;responseType&amp;quot; type=&amp;quot;string&amp;quot;/&amp;gt;&lt;br /&gt;
                    &amp;lt;/sequence&amp;gt;&lt;br /&gt;
                &amp;lt;/complexType&amp;gt;&lt;br /&gt;
            &amp;lt;/element&amp;gt;&lt;br /&gt;
            &amp;lt;element name=&amp;quot;greetMeOneWay&amp;quot;&amp;gt;&lt;br /&gt;
                &amp;lt;complexType&amp;gt;&lt;br /&gt;
                    &amp;lt;sequence&amp;gt;&lt;br /&gt;
                        &amp;lt;element name=&amp;quot;requestType&amp;quot; type=&amp;quot;string&amp;quot;/&amp;gt;&lt;br /&gt;
                    &amp;lt;/sequence&amp;gt;&lt;br /&gt;
                &amp;lt;/complexType&amp;gt;&lt;br /&gt;
            &amp;lt;/element&amp;gt;&lt;br /&gt;
      &amp;lt;element name=&amp;quot;pingMe&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;complexType/&amp;gt;&lt;br /&gt;
      &amp;lt;/element&amp;gt;&lt;br /&gt;
      &amp;lt;element name=&amp;quot;pingMeResponse&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;complexType/&amp;gt;&lt;br /&gt;
      &amp;lt;/element&amp;gt;&lt;br /&gt;
      &amp;lt;element name=&amp;quot;faultDetail&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;complexType&amp;gt;&lt;br /&gt;
        &amp;lt;sequence&amp;gt;&lt;br /&gt;
      &amp;lt;element name=&amp;quot;minor&amp;quot; type=&amp;quot;short&amp;quot;/&amp;gt;&lt;br /&gt;
      &amp;lt;element name=&amp;quot;major&amp;quot; type=&amp;quot;short&amp;quot;/&amp;gt;&lt;br /&gt;
        &amp;lt;/sequence&amp;gt;&lt;br /&gt;
                &amp;lt;/complexType&amp;gt;&lt;br /&gt;
      &amp;lt;/element&amp;gt;&lt;br /&gt;
        &amp;lt;/schema&amp;gt;&lt;br /&gt;
    &amp;lt;/wsdl:types&amp;gt;&lt;br /&gt;
    &amp;lt;wsdl:message name=&amp;quot;sayHiRequest&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;wsdl:part name=&amp;quot;in&amp;quot; element=&amp;quot;x1:sayHi&amp;quot;/&amp;gt;&lt;br /&gt;
    &amp;lt;/wsdl:message&amp;gt;&lt;br /&gt;
    &amp;lt;wsdl:message name=&amp;quot;sayHiResponse&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;wsdl:part name=&amp;quot;out&amp;quot; element=&amp;quot;x1:sayHiResponse&amp;quot;/&amp;gt;&lt;br /&gt;
    &amp;lt;/wsdl:message&amp;gt;&lt;br /&gt;
    &amp;lt;wsdl:message name=&amp;quot;greetMeRequest&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;wsdl:part element=&amp;quot;x1:greetMe&amp;quot; name=&amp;quot;in&amp;quot;/&amp;gt;&lt;br /&gt;
    &amp;lt;/wsdl:message&amp;gt;&lt;br /&gt;
    &amp;lt;wsdl:message name=&amp;quot;greetMeResponse&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;wsdl:part element=&amp;quot;x1:greetMeResponse&amp;quot; name=&amp;quot;out&amp;quot;/&amp;gt;&lt;br /&gt;
    &amp;lt;/wsdl:message&amp;gt;&lt;br /&gt;
    &amp;lt;wsdl:message name=&amp;quot;greetMeOneWayRequest&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;wsdl:part element=&amp;quot;x1:greetMeOneWay&amp;quot; name=&amp;quot;in&amp;quot;/&amp;gt;&lt;br /&gt;
    &amp;lt;/wsdl:message&amp;gt;&lt;br /&gt;
    &amp;lt;wsdl:message name=&amp;quot;pingMeRequest&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;wsdl:part name=&amp;quot;in&amp;quot; element=&amp;quot;x1:pingMe&amp;quot;/&amp;gt;&lt;br /&gt;
    &amp;lt;/wsdl:message&amp;gt;&lt;br /&gt;
    &amp;lt;wsdl:message name=&amp;quot;pingMeResponse&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;wsdl:part name=&amp;quot;out&amp;quot; element=&amp;quot;x1:pingMeResponse&amp;quot;/&amp;gt;&lt;br /&gt;
    &amp;lt;/wsdl:message&amp;gt;    &lt;br /&gt;
    &amp;lt;wsdl:message name=&amp;quot;pingMeFault&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;wsdl:part name=&amp;quot;faultDetail&amp;quot; element=&amp;quot;x1:faultDetail&amp;quot;/&amp;gt;&lt;br /&gt;
    &amp;lt;/wsdl:message&amp;gt;&lt;br /&gt;
    &amp;lt;wsdl:portType name=&amp;quot;Greeter&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;wsdl:operation name=&amp;quot;sayHi&amp;quot;&amp;gt;&lt;br /&gt;
            &amp;lt;wsdl:input name=&amp;quot;sayHiRequest&amp;quot; message=&amp;quot;tns:sayHiRequest&amp;quot;/&amp;gt;&lt;br /&gt;
            &amp;lt;wsdl:output name=&amp;quot;sayHiResponse&amp;quot; message=&amp;quot;tns:sayHiResponse&amp;quot;/&amp;gt;&lt;br /&gt;
        &amp;lt;/wsdl:operation&amp;gt;&lt;br /&gt;
        &amp;lt;wsdl:operation name=&amp;quot;greetMe&amp;quot;&amp;gt;&lt;br /&gt;
            &amp;lt;wsdl:input message=&amp;quot;tns:greetMeRequest&amp;quot; name=&amp;quot;greetMeRequest&amp;quot;/&amp;gt;&lt;br /&gt;
            &amp;lt;wsdl:output message=&amp;quot;tns:greetMeResponse&amp;quot; name=&amp;quot;greetMeResponse&amp;quot;/&amp;gt;&lt;br /&gt;
        &amp;lt;/wsdl:operation&amp;gt;&lt;br /&gt;
        &lt;br /&gt;
        &amp;lt;wsdl:operation name=&amp;quot;greetMeOneWay&amp;quot;&amp;gt;&lt;br /&gt;
            &amp;lt;wsdl:input message=&amp;quot;tns:greetMeOneWayRequest&amp;quot; name=&amp;quot;greetMeOneWayRequest&amp;quot;/&amp;gt;&lt;br /&gt;
        &amp;lt;/wsdl:operation&amp;gt;&lt;br /&gt;
  &amp;lt;wsdl:operation name=&amp;quot;pingMe&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;wsdl:input name=&amp;quot;pingMeRequest&amp;quot; message=&amp;quot;tns:pingMeRequest&amp;quot;/&amp;gt;&lt;br /&gt;
      &amp;lt;wsdl:output name=&amp;quot;pingMeResponse&amp;quot; message=&amp;quot;tns:pingMeResponse&amp;quot;/&amp;gt;&lt;br /&gt;
      &amp;lt;wsdl:fault name=&amp;quot;pingMeFault&amp;quot; message=&amp;quot;tns:pingMeFault&amp;quot;/&amp;gt;&lt;br /&gt;
        &amp;lt;/wsdl:operation&amp;gt; &lt;br /&gt;
    &amp;lt;/wsdl:portType&amp;gt;&lt;br /&gt;
    &amp;lt;wsdl:binding name=&amp;quot;Greeter_SOAPBinding&amp;quot; type=&amp;quot;tns:Greeter&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;soap12:binding transport=&amp;quot;http://www.w3.org/2003/05/soap/bindings/HTTP/&amp;quot; style=&amp;quot;document&amp;quot; /&amp;gt;&lt;br /&gt;
  &amp;lt;operation name=&amp;quot;sayHi&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;soap12:operation style=&amp;quot;document&amp;quot; soapAction=&amp;quot;&amp;quot;/&amp;gt;&lt;br /&gt;
      &amp;lt;input&amp;gt;&lt;br /&gt;
    &amp;lt;soap12:body use=&amp;quot;literal&amp;quot; /&amp;gt;&lt;br /&gt;
      &amp;lt;/input&amp;gt;&lt;br /&gt;
      &amp;lt;output&amp;gt;&lt;br /&gt;
    &amp;lt;soap12:body use=&amp;quot;literal&amp;quot; /&amp;gt;&lt;br /&gt;
      &amp;lt;/output&amp;gt;&lt;br /&gt;
  &amp;lt;/operation&amp;gt;&lt;br /&gt;
        &amp;lt;wsdl:operation name=&amp;quot;greetMe&amp;quot;&amp;gt;&lt;br /&gt;
            &amp;lt;soap12:operation soapAction=&amp;quot;&amp;quot; style=&amp;quot;document&amp;quot;/&amp;gt;&lt;br /&gt;
            &amp;lt;wsdl:input name=&amp;quot;greetMeRequest&amp;quot;&amp;gt;&lt;br /&gt;
                &amp;lt;soap12:body use=&amp;quot;literal&amp;quot;/&amp;gt;&lt;br /&gt;
            &amp;lt;/wsdl:input&amp;gt;&lt;br /&gt;
            &amp;lt;wsdl:output name=&amp;quot;greetMeResponse&amp;quot;&amp;gt;&lt;br /&gt;
                &amp;lt;soap12:body use=&amp;quot;literal&amp;quot;/&amp;gt;&lt;br /&gt;
            &amp;lt;/wsdl:output&amp;gt;&lt;br /&gt;
        &amp;lt;/wsdl:operation&amp;gt;&lt;br /&gt;
        &lt;br /&gt;
        &amp;lt;wsdl:operation name=&amp;quot;greetMeOneWay&amp;quot;&amp;gt;&lt;br /&gt;
            &amp;lt;soap12:operation soapAction=&amp;quot;&amp;quot; style=&amp;quot;document&amp;quot;/&amp;gt;&lt;br /&gt;
            &amp;lt;wsdl:input name=&amp;quot;greetMeOneWayRequest&amp;quot;&amp;gt;&lt;br /&gt;
                &amp;lt;soap12:body use=&amp;quot;literal&amp;quot;/&amp;gt;&lt;br /&gt;
            &amp;lt;/wsdl:input&amp;gt;&lt;br /&gt;
        &amp;lt;/wsdl:operation&amp;gt;&lt;br /&gt;
  &amp;lt;operation name=&amp;quot;pingMe&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;soap12:operation style=&amp;quot;document&amp;quot;/&amp;gt;&lt;br /&gt;
      &amp;lt;input&amp;gt;&lt;br /&gt;
                &amp;lt;soap12:body use=&amp;quot;literal&amp;quot;/&amp;gt;&lt;br /&gt;
            &amp;lt;/input&amp;gt;&lt;br /&gt;
            &amp;lt;output&amp;gt;&lt;br /&gt;
                &amp;lt;soap12:body use=&amp;quot;literal&amp;quot;/&amp;gt;&lt;br /&gt;
            &amp;lt;/output&amp;gt;&lt;br /&gt;
            &amp;lt;fault name=&amp;quot;pingMeFault&amp;quot;&amp;gt;&lt;br /&gt;
                &amp;lt;soap12:fault name=&amp;quot;pingMeFault&amp;quot; use=&amp;quot;literal&amp;quot;/&amp;gt;&lt;br /&gt;
            &amp;lt;/fault&amp;gt;&lt;br /&gt;
        &amp;lt;/operation&amp;gt;&lt;br /&gt;
    &amp;lt;/wsdl:binding&amp;gt;&lt;br /&gt;
    &amp;lt;wsdl:service name=&amp;quot;SOAPService&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;wsdl:port name=&amp;quot;SoapPort&amp;quot; binding=&amp;quot;tns:Greeter_SOAPBinding&amp;quot;&amp;gt;&lt;br /&gt;
            &amp;lt;soap12:address location=&amp;quot;http://localhost:9000/SoapContext/SoapPort&amp;quot;/&amp;gt;&lt;br /&gt;
        &amp;lt;/wsdl:port&amp;gt;&lt;br /&gt;
    &amp;lt;/wsdl:service&amp;gt;&lt;br /&gt;
&amp;lt;/definitions&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
        &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== JAX-WS: SOAP Element ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== JAX-WS: SOAP Element Any Type ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== This demo illustrates Apache CXF&amp;quot;s support for SOAP headers ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
SOAP Headers&lt;br /&gt;
============&lt;br /&gt;
This demo illustrates Apache CXF&amp;quot;s support for SOAP headers.  In the&lt;br /&gt;
WSDL file, the SOAP header is included as an additional part within&lt;br /&gt;
the message and binding definitions.  Using this approach to defining a&lt;br /&gt;
SOAP header, Apache CXF treats the header content as another parameter&lt;br /&gt;
to the operation.  Consequently, the header content is simply&lt;br /&gt;
manipulated within the method body.&lt;br /&gt;
The client application creates the header content, which is simply&lt;br /&gt;
a string value.  The server application views the supplied values&lt;br /&gt;
and may set these values into the operation&amp;quot;s return values or&lt;br /&gt;
out/inout headers.&lt;br /&gt;
Please review the README in the samples directory before&lt;br /&gt;
continuing.&lt;br /&gt;
&lt;br /&gt;
Prerequisites&lt;br /&gt;
-------------&lt;br /&gt;
If your environment already includes cxf.jar on the&lt;br /&gt;
CLASSPATH, and the JDK and ant bin directories on the PATH&lt;br /&gt;
it is not necessary to set the environment as described in&lt;br /&gt;
the samples directory&amp;quot;s README.  If your environment is not&lt;br /&gt;
properly configured, or if you are planning on using wsdl2java,&lt;br /&gt;
javac, and java to build and run the demos, you must set the&lt;br /&gt;
environment.&lt;br /&gt;
&lt;br /&gt;
Building and running the demo using ant&lt;br /&gt;
---------------------------------------&lt;br /&gt;
From the samples/soap_header directory, the ant build script&lt;br /&gt;
can be used to build and run the demo.&lt;br /&gt;
Using either UNIX or Windows:&lt;br /&gt;
  ant build&lt;br /&gt;
  ant server &lt;br /&gt;
  ant client&lt;br /&gt;
    &lt;br /&gt;
To remove the code generated from the WSDL file and the .class&lt;br /&gt;
files, run:&lt;br /&gt;
  ant clean&lt;br /&gt;
&lt;br /&gt;
Building the demo using wsdl2java and javac&lt;br /&gt;
------------------------------------------&lt;br /&gt;
From the samples/soap_header directory, first create the target&lt;br /&gt;
directory build/classes and then generate code from the WSDL file.&lt;br /&gt;
For UNIX:&lt;br /&gt;
  mkdir -p build/classes&lt;br /&gt;
  wsdl2java -d build/classes -compile ./wsdl/soap_header.wsdl&lt;br /&gt;
For Windows:&lt;br /&gt;
  mkdir build\classes&lt;br /&gt;
    Must use back slashes.&lt;br /&gt;
  wsdl2java -d build\classes -compile .\wsdl\soap_header.wsdl&lt;br /&gt;
    May use either forward or back slashes.&lt;br /&gt;
Now compile the provided client and server applications with the commands:&lt;br /&gt;
For UNIX:  &lt;br /&gt;
  &lt;br /&gt;
  export CLASSPATH=$CLASSPATH:$CXF_HOME/lib/cxf.jar:./build/classes&lt;br /&gt;
  javac -d build/classes src/demo/soap_header/client/*.java&lt;br /&gt;
  javac -d build/classes src/demo/soap_header/server/*.java&lt;br /&gt;
For Windows:&lt;br /&gt;
  set classpath=%classpath%;%CXF_HOME%\lib\cxf.jar;.\build\classes&lt;br /&gt;
  javac -d build\classes src\demo\soap_header\client\*.java&lt;br /&gt;
  javac -d build\classes src\demo\soap_header\server\*.java&lt;br /&gt;
Running the demo using java&lt;br /&gt;
---------------------------&lt;br /&gt;
From the samples/soap_header directory run the following commands.&lt;br /&gt;
They are entered on a single command line:&lt;br /&gt;
For UNIX (must use forward slashes):&lt;br /&gt;
    java -Djava.util.logging.config.file=$CXF_HOME/etc/logging.properties&lt;br /&gt;
         demo.soap_header.server.Server &amp;amp;&lt;br /&gt;
    java -Djava.util.logging.config.file=$CXF_HOME/etc/logging.properties&lt;br /&gt;
         demo.soap_header.client.Client ./wsdl/soap_header.wsdl&lt;br /&gt;
The server process starts in the background.  After running the client,&lt;br /&gt;
use the kill command to terminate the server process.&lt;br /&gt;
For Windows (may use either forward or back slashes):&lt;br /&gt;
  start &lt;br /&gt;
    java -Djava.util.logging.config.file=%CXF_HOME%\etc\logging.properties&lt;br /&gt;
         demo.soap_header.server.Server&lt;br /&gt;
    java -Djava.util.logging.config.file=%CXF_HOME%\etc\logging.properties&lt;br /&gt;
       demo.soap_header.client.Client .\wsdl\soap_header.wsdl&lt;br /&gt;
A new command windows opens for the server process.  After running the&lt;br /&gt;
client, terminate the server process by issuing Ctrl-C in its command window.&lt;br /&gt;
To remove the code generated from the WSDL file and the .class&lt;br /&gt;
files, either delete the build directory and its contents or run:&lt;br /&gt;
  ant clean&lt;br /&gt;
&lt;br /&gt;
Building and running the demo in a servlet container&lt;br /&gt;
----------------------------------------------------&lt;br /&gt;
From the samples/soap_header directory, the ant build script&lt;br /&gt;
can be used to create the war file that is deployed into the&lt;br /&gt;
servlet container.&lt;br /&gt;
Build the war file with the command:&lt;br /&gt;
  ant war&lt;br /&gt;
Preparing deploy to APACHE TOMCAT&lt;br /&gt;
* set CATALINA_HOME environment to your TOMCAT home directory&lt;br /&gt;
    &lt;br /&gt;
Deploy the war file into APACHE TOMCAT with the commond:&lt;br /&gt;
[NOTE] This step will check if the cxf jars present in Tomcat, &lt;br /&gt;
       if not, it will automatically copy all the jars into CATALINA_HOME/shared/lib&lt;br /&gt;
  &lt;br /&gt;
  ant deploy -Dtomcat=true&lt;br /&gt;
The servlet container will extract the war and deploy the application.&lt;br /&gt;
&lt;br /&gt;
Using ant, run the client application with the command:&lt;br /&gt;
  ant client-servlet -Dbase.url=http://localhost:#&lt;br /&gt;
Where # is the TCP/IP port used by the servlet container,&lt;br /&gt;
e.g., 8080.&lt;br /&gt;
Or&lt;br /&gt;
  ant client-servlet -Dhost=localhost -Dport=8080&lt;br /&gt;
You can ignore the -Dhost and -Dport if your tomcat setup is same, i.e ant client-servlet&lt;br /&gt;
Using java, run the client application with the command:&lt;br /&gt;
  For UNIX:&lt;br /&gt;
    &lt;br /&gt;
    java -Djava.util.logging.config.file=$CXF_HOME/etc/logging.properties&lt;br /&gt;
         demo.soap_header.client.Client http://localhost:#/soapheader/services/soap_header?wsdl&lt;br /&gt;
  For Windows:&lt;br /&gt;
    java -Djava.util.logging.config.file=%CXF_HOME%\etc\logging.properties&lt;br /&gt;
       demo.soap_header.client.Client http://localhost:#/soapheader/services/soap_header?wsdl&lt;br /&gt;
Where # is the TCP/IP port used by the servlet container,&lt;br /&gt;
e.g., 8080.&lt;br /&gt;
Undeploy the application from the APACHE TOMCAT with the command:&lt;br /&gt;
   ant undeploy -Dtomcat=true&lt;br /&gt;
&lt;br /&gt;
/////////////////////////////////////////////////////////////////////////&lt;br /&gt;
/**&lt;br /&gt;
 * Licensed to the Apache Software Foundation (ASF) under one&lt;br /&gt;
 * or more contributor license agreements. See the NOTICE file&lt;br /&gt;
 * distributed with this work for additional information&lt;br /&gt;
 * regarding copyright ownership. The ASF licenses this file&lt;br /&gt;
 * to you under the Apache License, Version 2.0 (the&lt;br /&gt;
 * &amp;quot;License&amp;quot;); you may not use this file except in compliance&lt;br /&gt;
 * with the License. You may obtain a copy of the License at&lt;br /&gt;
 *&lt;br /&gt;
 * http://www.apache.org/licenses/LICENSE-2.0&lt;br /&gt;
 *&lt;br /&gt;
 * Unless required by applicable law or agreed to in writing,&lt;br /&gt;
 * software distributed under the License is distributed on an&lt;br /&gt;
 * &amp;quot;AS IS&amp;quot; BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY&lt;br /&gt;
 * KIND, either express or implied. See the License for the&lt;br /&gt;
 * specific language governing permissions and limitations&lt;br /&gt;
 * under the License.&lt;br /&gt;
 */&lt;br /&gt;
&lt;br /&gt;
package demo.soap_header.client;&lt;br /&gt;
import java.io.File;&lt;br /&gt;
import java.net.URL;&lt;br /&gt;
import javax.xml.namespace.QName;&lt;br /&gt;
import javax.xml.ws.Holder;&lt;br /&gt;
import org.apache.headers.HeaderService;&lt;br /&gt;
import org.apache.headers.HeaderTester;&lt;br /&gt;
import org.apache.headers.InHeader;&lt;br /&gt;
import org.apache.headers.InHeaderResponse;&lt;br /&gt;
import org.apache.headers.InoutHeader;&lt;br /&gt;
import org.apache.headers.InoutHeaderResponse;&lt;br /&gt;
import org.apache.headers.OutHeader;&lt;br /&gt;
import org.apache.headers.OutHeaderResponse;&lt;br /&gt;
import org.apache.headers.SOAPHeaderData;&lt;br /&gt;
public final class Client {&lt;br /&gt;
    private static final QName SERVICE_NAME&lt;br /&gt;
        = new QName(&amp;quot;http://apache.org/headers&amp;quot;, &amp;quot;HeaderService&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
    private Client() {&lt;br /&gt;
    }&lt;br /&gt;
    public static void main(String args[]) throws Exception {&lt;br /&gt;
        if (args.length == 0) {&lt;br /&gt;
            System.out.println(&amp;quot;please specify wsdl&amp;quot;);&lt;br /&gt;
            System.exit(1);&lt;br /&gt;
        }&lt;br /&gt;
        URL wsdlURL;&lt;br /&gt;
        File wsdlFile = new File(args[0]);&lt;br /&gt;
        if (wsdlFile.exists()) {&lt;br /&gt;
            wsdlURL = wsdlFile.toURL();&lt;br /&gt;
        } else {&lt;br /&gt;
            wsdlURL = new URL(args[0]);&lt;br /&gt;
        }&lt;br /&gt;
        &lt;br /&gt;
        HeaderService hs = new HeaderService(wsdlURL, SERVICE_NAME);&lt;br /&gt;
        HeaderTester proxy = hs.getSoapPort();&lt;br /&gt;
        invokeInHeader(proxy);&lt;br /&gt;
        invokeOutHeader(proxy);  &lt;br /&gt;
        invokeInOutHeader(proxy);  &lt;br /&gt;
    }&lt;br /&gt;
     &lt;br /&gt;
    private static void invokeInHeader(HeaderTester proxy) {&lt;br /&gt;
        // invoke inHeader operation&lt;br /&gt;
        System.out.println(&amp;quot;Invoking inHeader operation&amp;quot;);&lt;br /&gt;
        InHeader me = new InHeader();&lt;br /&gt;
        me.setRequestType(&amp;quot;CXF user&amp;quot;);&lt;br /&gt;
        SOAPHeaderData headerInfo = new SOAPHeaderData();&lt;br /&gt;
        headerInfo.setOriginator(&amp;quot;CXF client&amp;quot;);&lt;br /&gt;
        headerInfo.setMessage(&amp;quot;Invoking inHeader operation&amp;quot;);&lt;br /&gt;
        InHeaderResponse response = proxy.inHeader(me, headerInfo);&lt;br /&gt;
        System.out.println(&amp;quot;\tinHeader invocation returned: &amp;quot;);&lt;br /&gt;
        System.out.println(&amp;quot;\t\tResult: &amp;quot; + response.getResponseType());&lt;br /&gt;
    }&lt;br /&gt;
    private static void invokeOutHeader(HeaderTester proxy) {    &lt;br /&gt;
        // invoke outHeaderoperation&lt;br /&gt;
        System.out.println(&amp;quot;Invoking outHeader operation&amp;quot;);&lt;br /&gt;
        OutHeader me = new OutHeader();&lt;br /&gt;
        me.setRequestType(&amp;quot;CXF user&amp;quot;);&lt;br /&gt;
        Holder&amp;lt;OutHeaderResponse&amp;gt; theResponse = new Holder&amp;lt;OutHeaderResponse&amp;gt;();&lt;br /&gt;
        Holder&amp;lt;SOAPHeaderData&amp;gt; headerInfo = new Holder&amp;lt;SOAPHeaderData&amp;gt;();&lt;br /&gt;
        proxy.outHeader(me, theResponse, headerInfo);&lt;br /&gt;
        System.out.println(&amp;quot;\toutHeader invocation returned: &amp;quot;);&lt;br /&gt;
        System.out.println(&amp;quot;\t\tOut parameter: &amp;quot; + theResponse.value.getResponseType());&lt;br /&gt;
        System.out.println(&amp;quot;\t\tHeader content:&amp;quot;);&lt;br /&gt;
        System.out.println(&amp;quot;\t\t\tOriginator: &amp;quot; + headerInfo.value.getOriginator());&lt;br /&gt;
        System.out.println(&amp;quot;\t\t\tMessage: &amp;quot; + headerInfo.value.getMessage());&lt;br /&gt;
    }&lt;br /&gt;
    private static void invokeInOutHeader(HeaderTester proxy) {&lt;br /&gt;
        System.out.println(&amp;quot;Invoking inoutHeader operation&amp;quot;);&lt;br /&gt;
        InoutHeader me = new InoutHeader();&lt;br /&gt;
        me.setRequestType(&amp;quot;CXF user&amp;quot;);&lt;br /&gt;
        Holder&amp;lt;SOAPHeaderData&amp;gt; headerInfo = new Holder&amp;lt;SOAPHeaderData&amp;gt;();&lt;br /&gt;
        SOAPHeaderData shd = new SOAPHeaderData();&lt;br /&gt;
        shd.setOriginator(&amp;quot;CXF client&amp;quot;);&lt;br /&gt;
        shd.setMessage(&amp;quot;Invoking inoutHeader operation&amp;quot;);&lt;br /&gt;
        headerInfo.value = shd;&lt;br /&gt;
        InoutHeaderResponse response = proxy.inoutHeader(me, headerInfo);&lt;br /&gt;
        System.out.println(&amp;quot;\tinoutHeader invocation returned: &amp;quot;);&lt;br /&gt;
        System.out.println(&amp;quot;\t\tResult: &amp;quot; + response.getResponseType());&lt;br /&gt;
        System.out.println(&amp;quot;\t\tHeader content:&amp;quot;);&lt;br /&gt;
        System.out.println(&amp;quot;\t\t\tOriginator: &amp;quot; + headerInfo.value.getOriginator());&lt;br /&gt;
        System.out.println(&amp;quot;\t\t\tMessage: &amp;quot; + headerInfo.value.getMessage());&lt;br /&gt;
        System.exit(0);&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
//////////////////////////////////////////////////////////////////////////////&lt;br /&gt;
/**&lt;br /&gt;
 * Licensed to the Apache Software Foundation (ASF) under one&lt;br /&gt;
 * or more contributor license agreements. See the NOTICE file&lt;br /&gt;
 * distributed with this work for additional information&lt;br /&gt;
 * regarding copyright ownership. The ASF licenses this file&lt;br /&gt;
 * to you under the Apache License, Version 2.0 (the&lt;br /&gt;
 * &amp;quot;License&amp;quot;); you may not use this file except in compliance&lt;br /&gt;
 * with the License. You may obtain a copy of the License at&lt;br /&gt;
 *&lt;br /&gt;
 * http://www.apache.org/licenses/LICENSE-2.0&lt;br /&gt;
 *&lt;br /&gt;
 * Unless required by applicable law or agreed to in writing,&lt;br /&gt;
 * software distributed under the License is distributed on an&lt;br /&gt;
 * &amp;quot;AS IS&amp;quot; BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY&lt;br /&gt;
 * KIND, either express or implied. See the License for the&lt;br /&gt;
 * specific language governing permissions and limitations&lt;br /&gt;
 * under the License.&lt;br /&gt;
 */&lt;br /&gt;
&lt;br /&gt;
package demo.soap_header.server;&lt;br /&gt;
import javax.xml.ws.Holder;&lt;br /&gt;
import org.apache.headers.HeaderTester;&lt;br /&gt;
import org.apache.headers.InHeader;&lt;br /&gt;
import org.apache.headers.InHeaderResponse;&lt;br /&gt;
import org.apache.headers.InoutHeader;&lt;br /&gt;
import org.apache.headers.InoutHeaderResponse;&lt;br /&gt;
import org.apache.headers.OutHeader;&lt;br /&gt;
import org.apache.headers.OutHeaderResponse;&lt;br /&gt;
import org.apache.headers.SOAPHeaderData;&lt;br /&gt;
&lt;br /&gt;
@javax.jws.WebService(serviceName = &amp;quot;HeaderService&amp;quot;, &lt;br /&gt;
            portName = &amp;quot;SoapPort&amp;quot;, &lt;br /&gt;
            endpointInterface = &amp;quot;org.apache.headers.HeaderTester&amp;quot;,&lt;br /&gt;
            targetNamespace = &amp;quot;http://apache.org/headers&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
public class HeaderTesterImpl implements HeaderTester {&lt;br /&gt;
    public InHeaderResponse inHeader(InHeader me,&lt;br /&gt;
                                     SOAPHeaderData headerInfo) {&lt;br /&gt;
        System.out.println(&amp;quot;inHeader invoked&amp;quot;);&lt;br /&gt;
        System.out.println(&amp;quot;\tGetting Originator: &amp;quot; + headerInfo.getOriginator());&lt;br /&gt;
        System.out.println(&amp;quot;\tGetting Message: &amp;quot; + headerInfo.getMessage());&lt;br /&gt;
        InHeaderResponse ihr = new InHeaderResponse();&lt;br /&gt;
        ihr.setResponseType(&amp;quot;Hello &amp;quot; + me.getRequestType());&lt;br /&gt;
        return ihr;&lt;br /&gt;
    }&lt;br /&gt;
    public void outHeader(OutHeader me, &lt;br /&gt;
                          Holder&amp;lt;OutHeaderResponse&amp;gt; theResponse,&lt;br /&gt;
                          Holder&amp;lt;SOAPHeaderData&amp;gt; headerInfo) {&lt;br /&gt;
        System.out.println(&amp;quot;outHeader invoked&amp;quot;);&lt;br /&gt;
        System.out.println(&amp;quot;\tSetting originator: CXF server&amp;quot;);&lt;br /&gt;
        System.out.println(&amp;quot;\tSetting message: outHeader invocation succeeded&amp;quot;);&lt;br /&gt;
        SOAPHeaderData sh = new SOAPHeaderData();&lt;br /&gt;
        sh.setOriginator(&amp;quot;CXF server&amp;quot;);&lt;br /&gt;
        sh.setMessage(&amp;quot;outHeader invocation succeeded&amp;quot;);&lt;br /&gt;
        headerInfo.value = sh;&lt;br /&gt;
        OutHeaderResponse ohr = new OutHeaderResponse();&lt;br /&gt;
        ohr.setResponseType(&amp;quot;Hello &amp;quot; + me.getRequestType());&lt;br /&gt;
        theResponse.value = ohr;&lt;br /&gt;
    }&lt;br /&gt;
    public InoutHeaderResponse inoutHeader(InoutHeader me,&lt;br /&gt;
                                           Holder&amp;lt;SOAPHeaderData&amp;gt; headerInfo) {&lt;br /&gt;
        System.out.println(&amp;quot;inoutHeader invoked&amp;quot;);&lt;br /&gt;
        System.out.println(&amp;quot;\tGetting Originator: &amp;quot; + headerInfo.value.getOriginator());&lt;br /&gt;
        System.out.println(&amp;quot;\tGetting Message: &amp;quot; + headerInfo.value.getMessage());&lt;br /&gt;
        System.out.println(&amp;quot;\tSetting originator: CXF server&amp;quot;);&lt;br /&gt;
        System.out.println(&amp;quot;\tSetting message: inoutHeader invocation succeeded&amp;quot;);&lt;br /&gt;
        headerInfo.value.setOriginator(&amp;quot;CXF server&amp;quot;);&lt;br /&gt;
        headerInfo.value.setMessage(&amp;quot;inoutHeader invocation succeeded&amp;quot;);&lt;br /&gt;
        InoutHeaderResponse iohr = new InoutHeaderResponse();&lt;br /&gt;
        iohr.setResponseType(&amp;quot;Hello &amp;quot; + me.getRequestType());&lt;br /&gt;
        return iohr;&lt;br /&gt;
    }    &lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
//////////////////////////////////////////////////////////////////////////////&lt;br /&gt;
/**&lt;br /&gt;
 * Licensed to the Apache Software Foundation (ASF) under one&lt;br /&gt;
 * or more contributor license agreements. See the NOTICE file&lt;br /&gt;
 * distributed with this work for additional information&lt;br /&gt;
 * regarding copyright ownership. The ASF licenses this file&lt;br /&gt;
 * to you under the Apache License, Version 2.0 (the&lt;br /&gt;
 * &amp;quot;License&amp;quot;); you may not use this file except in compliance&lt;br /&gt;
 * with the License. You may obtain a copy of the License at&lt;br /&gt;
 *&lt;br /&gt;
 * http://www.apache.org/licenses/LICENSE-2.0&lt;br /&gt;
 *&lt;br /&gt;
 * Unless required by applicable law or agreed to in writing,&lt;br /&gt;
 * software distributed under the License is distributed on an&lt;br /&gt;
 * &amp;quot;AS IS&amp;quot; BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY&lt;br /&gt;
 * KIND, either express or implied. See the License for the&lt;br /&gt;
 * specific language governing permissions and limitations&lt;br /&gt;
 * under the License.&lt;br /&gt;
 */&lt;br /&gt;
&lt;br /&gt;
package demo.soap_header.server;&lt;br /&gt;
import javax.xml.ws.Endpoint;&lt;br /&gt;
public class Server {&lt;br /&gt;
    protected Server() throws Exception {&lt;br /&gt;
        System.out.println(&amp;quot;Starting Server&amp;quot;);&lt;br /&gt;
        Object implementor = new HeaderTesterImpl();&lt;br /&gt;
        String address = &amp;quot;http://localhost:9000/headers&amp;quot;;&lt;br /&gt;
        Endpoint.publish(address, implementor);&lt;br /&gt;
    }&lt;br /&gt;
    public static void main(String args[]) throws Exception {&lt;br /&gt;
        new Server();&lt;br /&gt;
        System.out.println(&amp;quot;Server ready...&amp;quot;);&lt;br /&gt;
        Thread.sleep(5 * 60 * 1000);&lt;br /&gt;
        System.out.println(&amp;quot;Server exiting&amp;quot;);&lt;br /&gt;
        System.exit(0);&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
//////////////////////////////////////////////////////////////////////////////&lt;br /&gt;
&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot;?&amp;gt;&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
  Licensed to the Apache Software Foundation (ASF) under one&lt;br /&gt;
  or more contributor license agreements. See the NOTICE file&lt;br /&gt;
  distributed with this work for additional information&lt;br /&gt;
  regarding copyright ownership. The ASF licenses this file&lt;br /&gt;
  to you under the Apache License, Version 2.0 (the&lt;br /&gt;
  &amp;quot;License&amp;quot;); you may not use this file except in compliance&lt;br /&gt;
  with the License. You may obtain a copy of the License at&lt;br /&gt;
                                                                                                                                                             &lt;br /&gt;
  http://www.apache.org/licenses/LICENSE-2.0&lt;br /&gt;
                                                                                                                                                             &lt;br /&gt;
  Unless required by applicable law or agreed to in writing,&lt;br /&gt;
  software distributed under the License is distributed on an&lt;br /&gt;
  &amp;quot;AS IS&amp;quot; BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY&lt;br /&gt;
  KIND, either express or implied. See the License for the&lt;br /&gt;
  specific language governing permissions and limitations&lt;br /&gt;
  under the License.&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&amp;lt;definitions name=&amp;quot;soap_header&amp;quot; targetNamespace=&amp;quot;http://apache.org/headers&amp;quot; &lt;br /&gt;
    xmlns=&amp;quot;http://schemas.xmlsoap.org/wsdl/&amp;quot; &lt;br /&gt;
    xmlns:http=&amp;quot;http://schemas.xmlsoap.org/wsdl/http/&amp;quot; &lt;br /&gt;
    xmlns:soap=&amp;quot;http://schemas.xmlsoap.org/wsdl/soap/&amp;quot; &lt;br /&gt;
    xmlns:tns=&amp;quot;http://apache.org/headers&amp;quot; &lt;br /&gt;
    xmlns:wsdl=&amp;quot;http://schemas.xmlsoap.org/wsdl/&amp;quot; &lt;br /&gt;
    xmlns:xsd=&amp;quot;http://www.w3.org/2001/XMLSchema&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;types&amp;gt;&lt;br /&gt;
        &amp;lt;schema targetNamespace=&amp;quot;http://apache.org/headers&amp;quot; &lt;br /&gt;
            xmlns=&amp;quot;http://www.w3.org/2001/XMLSchema&amp;quot; &lt;br /&gt;
            xmlns:wsdl=&amp;quot;http://schemas.xmlsoap.org/wsdl/&amp;quot;&amp;gt;&lt;br /&gt;
            &amp;lt;complexType name=&amp;quot;SOAPHeaderData&amp;quot;&amp;gt;&lt;br /&gt;
                &amp;lt;sequence&amp;gt;&lt;br /&gt;
                    &amp;lt;element maxOccurs=&amp;quot;1&amp;quot; minOccurs=&amp;quot;1&amp;quot; name=&amp;quot;originator&amp;quot; type=&amp;quot;string&amp;quot;/&amp;gt;&lt;br /&gt;
                    &amp;lt;element maxOccurs=&amp;quot;1&amp;quot; minOccurs=&amp;quot;1&amp;quot; name=&amp;quot;message&amp;quot; type=&amp;quot;string&amp;quot;/&amp;gt;&lt;br /&gt;
                &amp;lt;/sequence&amp;gt;&lt;br /&gt;
            &amp;lt;/complexType&amp;gt;&lt;br /&gt;
            &amp;lt;element name=&amp;quot;SOAPHeaderInfo&amp;quot; type=&amp;quot;tns:SOAPHeaderData&amp;quot;/&amp;gt;&lt;br /&gt;
        &amp;lt;element name=&amp;quot;inHeader&amp;quot;&amp;gt;&lt;br /&gt;
           &amp;lt;complexType&amp;gt;&lt;br /&gt;
                    &amp;lt;sequence&amp;gt;&lt;br /&gt;
                        &amp;lt;element name=&amp;quot;requestType&amp;quot; type=&amp;quot;xsd:string&amp;quot;/&amp;gt;&lt;br /&gt;
                    &amp;lt;/sequence&amp;gt;&lt;br /&gt;
                &amp;lt;/complexType&amp;gt;&lt;br /&gt;
        &amp;lt;/element&amp;gt;&lt;br /&gt;
        &amp;lt;element name=&amp;quot;inHeaderResponse&amp;quot;&amp;gt;&lt;br /&gt;
           &amp;lt;complexType&amp;gt;&lt;br /&gt;
                    &amp;lt;sequence&amp;gt;&lt;br /&gt;
                        &amp;lt;element name=&amp;quot;responseType&amp;quot; type=&amp;quot;xsd:string&amp;quot;/&amp;gt;&lt;br /&gt;
                    &amp;lt;/sequence&amp;gt;&lt;br /&gt;
                &amp;lt;/complexType&amp;gt;&lt;br /&gt;
        &amp;lt;/element&amp;gt;&lt;br /&gt;
        &amp;lt;element name=&amp;quot;outHeader&amp;quot;&amp;gt;&lt;br /&gt;
           &amp;lt;complexType&amp;gt;&lt;br /&gt;
                    &amp;lt;sequence&amp;gt;&lt;br /&gt;
                        &amp;lt;element name=&amp;quot;requestType&amp;quot; type=&amp;quot;xsd:string&amp;quot;/&amp;gt;&lt;br /&gt;
                    &amp;lt;/sequence&amp;gt;&lt;br /&gt;
                &amp;lt;/complexType&amp;gt;&lt;br /&gt;
        &amp;lt;/element&amp;gt;&lt;br /&gt;
        &amp;lt;element name=&amp;quot;outHeaderResponse&amp;quot;&amp;gt;&lt;br /&gt;
           &amp;lt;complexType&amp;gt;&lt;br /&gt;
                    &amp;lt;sequence&amp;gt;&lt;br /&gt;
                        &amp;lt;element name=&amp;quot;responseType&amp;quot; type=&amp;quot;xsd:string&amp;quot;/&amp;gt;&lt;br /&gt;
                    &amp;lt;/sequence&amp;gt;&lt;br /&gt;
                &amp;lt;/complexType&amp;gt;&lt;br /&gt;
        &amp;lt;/element&amp;gt;&lt;br /&gt;
        &amp;lt;element name=&amp;quot;inoutHeader&amp;quot;&amp;gt;&lt;br /&gt;
           &amp;lt;complexType&amp;gt;&lt;br /&gt;
                    &amp;lt;sequence&amp;gt;&lt;br /&gt;
                        &amp;lt;element name=&amp;quot;requestType&amp;quot; type=&amp;quot;xsd:string&amp;quot;/&amp;gt;&lt;br /&gt;
                    &amp;lt;/sequence&amp;gt;&lt;br /&gt;
                &amp;lt;/complexType&amp;gt;&lt;br /&gt;
        &amp;lt;/element&amp;gt;&lt;br /&gt;
        &amp;lt;element name=&amp;quot;inoutHeaderResponse&amp;quot;&amp;gt;&lt;br /&gt;
           &amp;lt;complexType&amp;gt;&lt;br /&gt;
                    &amp;lt;sequence&amp;gt;&lt;br /&gt;
                        &amp;lt;element name=&amp;quot;responseType&amp;quot; type=&amp;quot;xsd:string&amp;quot;/&amp;gt;&lt;br /&gt;
                    &amp;lt;/sequence&amp;gt;&lt;br /&gt;
                &amp;lt;/complexType&amp;gt;&lt;br /&gt;
        &amp;lt;/element&amp;gt;&lt;br /&gt;
        &amp;lt;/schema&amp;gt;&lt;br /&gt;
    &amp;lt;/types&amp;gt;&lt;br /&gt;
    &amp;lt;message name=&amp;quot;inHeaderRequest&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;part element=&amp;quot;tns:inHeader&amp;quot; name=&amp;quot;me&amp;quot;/&amp;gt;&lt;br /&gt;
        &amp;lt;part element=&amp;quot;tns:SOAPHeaderInfo&amp;quot; name=&amp;quot;header_info&amp;quot;/&amp;gt;&lt;br /&gt;
    &amp;lt;/message&amp;gt;&lt;br /&gt;
    &amp;lt;message name=&amp;quot;inHeaderResponse&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;part element=&amp;quot;tns:inHeaderResponse&amp;quot; name=&amp;quot;the_response&amp;quot;/&amp;gt;&lt;br /&gt;
    &amp;lt;/message&amp;gt;&lt;br /&gt;
    &amp;lt;message name=&amp;quot;outHeaderRequest&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;part element=&amp;quot;tns:outHeader&amp;quot; name=&amp;quot;me&amp;quot;/&amp;gt;&lt;br /&gt;
    &amp;lt;/message&amp;gt;&lt;br /&gt;
    &amp;lt;message name=&amp;quot;outHeaderResponse&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;part element=&amp;quot;tns:outHeaderResponse&amp;quot; name=&amp;quot;the_response&amp;quot;/&amp;gt;&lt;br /&gt;
        &amp;lt;part element=&amp;quot;tns:SOAPHeaderInfo&amp;quot; name=&amp;quot;header_info&amp;quot;/&amp;gt;&lt;br /&gt;
    &amp;lt;/message&amp;gt;&lt;br /&gt;
    &amp;lt;message name=&amp;quot;inoutHeaderRequest&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;part element=&amp;quot;tns:inoutHeader&amp;quot; name=&amp;quot;me&amp;quot;/&amp;gt;&lt;br /&gt;
        &amp;lt;part element=&amp;quot;tns:SOAPHeaderInfo&amp;quot; name=&amp;quot;header_info&amp;quot;/&amp;gt;&lt;br /&gt;
    &amp;lt;/message&amp;gt;&lt;br /&gt;
    &amp;lt;message name=&amp;quot;inoutHeaderResponse&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;part element=&amp;quot;tns:inoutHeaderResponse&amp;quot; name=&amp;quot;the_response&amp;quot;/&amp;gt;&lt;br /&gt;
        &amp;lt;part element=&amp;quot;tns:SOAPHeaderInfo&amp;quot; name=&amp;quot;header_info&amp;quot;/&amp;gt;&lt;br /&gt;
    &amp;lt;/message&amp;gt;&lt;br /&gt;
    &amp;lt;portType name=&amp;quot;headerTester&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;operation name=&amp;quot;inHeader&amp;quot;&amp;gt;&lt;br /&gt;
            &amp;lt;input message=&amp;quot;tns:inHeaderRequest&amp;quot; name=&amp;quot;inHeaderRequest&amp;quot;/&amp;gt;&lt;br /&gt;
            &amp;lt;output message=&amp;quot;tns:inHeaderResponse&amp;quot; name=&amp;quot;inHeaderResponse&amp;quot;/&amp;gt;&lt;br /&gt;
        &amp;lt;/operation&amp;gt;&lt;br /&gt;
        &amp;lt;operation name=&amp;quot;outHeader&amp;quot;&amp;gt;&lt;br /&gt;
            &amp;lt;input message=&amp;quot;tns:outHeaderRequest&amp;quot; name=&amp;quot;outHeaderRequest&amp;quot;/&amp;gt;&lt;br /&gt;
            &amp;lt;output message=&amp;quot;tns:outHeaderResponse&amp;quot; name=&amp;quot;outHeaderResponse&amp;quot;/&amp;gt;&lt;br /&gt;
        &amp;lt;/operation&amp;gt;&lt;br /&gt;
        &amp;lt;operation name=&amp;quot;inoutHeader&amp;quot;&amp;gt;&lt;br /&gt;
            &amp;lt;input message=&amp;quot;tns:inoutHeaderRequest&amp;quot; name=&amp;quot;inoutHeaderRequest&amp;quot;/&amp;gt;&lt;br /&gt;
            &amp;lt;output message=&amp;quot;tns:inoutHeaderResponse&amp;quot; name=&amp;quot;inoutHeaderResponse&amp;quot;/&amp;gt;&lt;br /&gt;
        &amp;lt;/operation&amp;gt;&lt;br /&gt;
    &amp;lt;/portType&amp;gt;&lt;br /&gt;
    &amp;lt;binding name=&amp;quot;headerTesterSOAPBinding&amp;quot; type=&amp;quot;tns:headerTester&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;soap:binding style=&amp;quot;document&amp;quot; transport=&amp;quot;http://schemas.xmlsoap.org/soap/http&amp;quot;/&amp;gt;&lt;br /&gt;
        &amp;lt;operation name=&amp;quot;inHeader&amp;quot;&amp;gt;&lt;br /&gt;
            &amp;lt;soap:operation soapAction=&amp;quot;&amp;quot; style=&amp;quot;document&amp;quot;/&amp;gt;&lt;br /&gt;
            &amp;lt;input name=&amp;quot;inHeaderRequest&amp;quot;&amp;gt;&lt;br /&gt;
                &amp;lt;soap:body parts=&amp;quot;me&amp;quot; use=&amp;quot;literal&amp;quot;/&amp;gt;&lt;br /&gt;
                &amp;lt;soap:header message=&amp;quot;tns:inHeaderRequest&amp;quot; part=&amp;quot;header_info&amp;quot; &lt;br /&gt;
                    use=&amp;quot;literal&amp;quot;/&amp;gt;&lt;br /&gt;
            &amp;lt;/input&amp;gt;&lt;br /&gt;
            &amp;lt;output name=&amp;quot;inHeaderResponse&amp;quot;&amp;gt;&lt;br /&gt;
                &amp;lt;soap:body use=&amp;quot;literal&amp;quot;/&amp;gt;&lt;br /&gt;
            &amp;lt;/output&amp;gt;&lt;br /&gt;
        &amp;lt;/operation&amp;gt;&lt;br /&gt;
        &amp;lt;operation name=&amp;quot;outHeader&amp;quot;&amp;gt;&lt;br /&gt;
            &amp;lt;soap:operation soapAction=&amp;quot;&amp;quot; style=&amp;quot;document&amp;quot;/&amp;gt;&lt;br /&gt;
            &amp;lt;input name=&amp;quot;outHeaderRequest&amp;quot;&amp;gt;&lt;br /&gt;
                &amp;lt;soap:body use=&amp;quot;literal&amp;quot;/&amp;gt;&lt;br /&gt;
            &amp;lt;/input&amp;gt;&lt;br /&gt;
            &amp;lt;output name=&amp;quot;outHeaderResponse&amp;quot;&amp;gt;&lt;br /&gt;
                &amp;lt;soap:body parts=&amp;quot;the_response&amp;quot; use=&amp;quot;literal&amp;quot;/&amp;gt;&lt;br /&gt;
                &amp;lt;soap:header message=&amp;quot;tns:outHeaderResponse&amp;quot; part=&amp;quot;header_info&amp;quot; &lt;br /&gt;
                    use=&amp;quot;literal&amp;quot;/&amp;gt;&lt;br /&gt;
            &amp;lt;/output&amp;gt;&lt;br /&gt;
        &amp;lt;/operation&amp;gt;&lt;br /&gt;
        &amp;lt;operation name=&amp;quot;inoutHeader&amp;quot;&amp;gt;&lt;br /&gt;
            &amp;lt;soap:operation soapAction=&amp;quot;&amp;quot; style=&amp;quot;document&amp;quot;/&amp;gt;&lt;br /&gt;
            &amp;lt;input name=&amp;quot;inoutHeaderRequest&amp;quot;&amp;gt;&lt;br /&gt;
                &amp;lt;soap:body parts=&amp;quot;me&amp;quot; use=&amp;quot;literal&amp;quot;/&amp;gt;&lt;br /&gt;
                &amp;lt;soap:header message=&amp;quot;tns:inoutHeaderRequest&amp;quot; part=&amp;quot;header_info&amp;quot; &lt;br /&gt;
                    use=&amp;quot;literal&amp;quot;/&amp;gt;&lt;br /&gt;
            &amp;lt;/input&amp;gt;&lt;br /&gt;
            &amp;lt;output name=&amp;quot;inoutHeaderResponse&amp;quot;&amp;gt;&lt;br /&gt;
                &amp;lt;soap:body parts=&amp;quot;the_response&amp;quot; use=&amp;quot;literal&amp;quot;/&amp;gt;&lt;br /&gt;
                &amp;lt;soap:header message=&amp;quot;tns:inoutHeaderResponse&amp;quot; part=&amp;quot;header_info&amp;quot; &lt;br /&gt;
                    use=&amp;quot;literal&amp;quot;/&amp;gt;&lt;br /&gt;
            &amp;lt;/output&amp;gt;&lt;br /&gt;
        &amp;lt;/operation&amp;gt;&lt;br /&gt;
    &amp;lt;/binding&amp;gt;&lt;br /&gt;
    &amp;lt;service name=&amp;quot;HeaderService&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;port binding=&amp;quot;tns:headerTesterSOAPBinding&amp;quot; name=&amp;quot;SoapPort&amp;quot;&amp;gt;&lt;br /&gt;
            &amp;lt;soap:address location=&amp;quot;http://localhost:9000/headers&amp;quot;/&amp;gt;&lt;br /&gt;
        &amp;lt;/port&amp;gt;&lt;br /&gt;
    &amp;lt;/service&amp;gt;&lt;br /&gt;
&amp;lt;/definitions&amp;gt;&lt;br /&gt;
&lt;br /&gt;
        &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;/div&gt;</summary>
		<author><name>Admin</name></author>	</entry>

	<entry>
		<id>http://jexp.ru/index.php?title=Java/Web_Services_SOA/CXF_XFire_Document_Literal&amp;diff=9199</id>
		<title>Java/Web Services SOA/CXF XFire Document Literal</title>
		<link rel="alternate" type="text/html" href="http://jexp.ru/index.php?title=Java/Web_Services_SOA/CXF_XFire_Document_Literal&amp;diff=9199"/>
				<updated>2010-06-01T07:27:33Z</updated>
		
		<summary type="html">&lt;p&gt;Admin: 1 версия&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Apache CXF&amp;quot;s xml binding: how xml binding works with the doc-lit wrapped style ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
Hello World Demo using WRAPPED Style in XML Binding&lt;br /&gt;
=============================================&lt;br /&gt;
This demo illustrates the use of Apache CXF&amp;quot;s xml binding. This &lt;br /&gt;
specific demo shows you how xml binding works with the &lt;br /&gt;
doc-lit wrapped style.&lt;br /&gt;
Please review the README in the samples directory before&lt;br /&gt;
continuing.&lt;br /&gt;
&lt;br /&gt;
Prerequisite&lt;br /&gt;
------------&lt;br /&gt;
If your environment already includes cxf-manifest-incubator.jar on the&lt;br /&gt;
CLASSPATH, and the JDK and ant bin directories on the PATH&lt;br /&gt;
it is not necessary to set the environment as described in&lt;br /&gt;
the samples directory&amp;quot;s README.  If your environment is not&lt;br /&gt;
properly configured, or if you are planning on using wsdl2java,&lt;br /&gt;
javac, and java to build and run the demos, you must set the&lt;br /&gt;
environment.&lt;br /&gt;
&lt;br /&gt;
Building and running the demo using ant&lt;br /&gt;
---------------------------------------&lt;br /&gt;
From the samples/hello_world_xml_wrapped directory, the ant build script&lt;br /&gt;
can be used to build and run the demo.&lt;br /&gt;
Using either UNIX or Windows:&lt;br /&gt;
  ant build&lt;br /&gt;
  ant server&lt;br /&gt;
  ant client&lt;br /&gt;
    &lt;br /&gt;
To remove the code generated from the WSDL file and the .class&lt;br /&gt;
files, run:&lt;br /&gt;
  ant clean&lt;br /&gt;
&lt;br /&gt;
Building the demo using wsdl2java and javac&lt;br /&gt;
-------------------------------------------&lt;br /&gt;
From the samples/hello_world_xml_wrapped directory, first create the target&lt;br /&gt;
directory build/classes and then generate code from the WSDL file.&lt;br /&gt;
For UNIX:&lt;br /&gt;
  mkdir -p build/classes&lt;br /&gt;
  wsdl2java -d build/classes -compile ./wsdl/hello_world.wsdl&lt;br /&gt;
For Windows:&lt;br /&gt;
  mkdir build\classes&lt;br /&gt;
    Must use back slashes.&lt;br /&gt;
  wsdl2java -d build\classes -compile .\wsdl\hello_world.wsdl&lt;br /&gt;
    May use either forward or back slashes.&lt;br /&gt;
Now compile the provided client and server applications with the commands:&lt;br /&gt;
For UNIX:  &lt;br /&gt;
  &lt;br /&gt;
  export CLASSPATH=$CLASSPATH:$CXF_HOME/lib/cxf-manifest-incubator.jar:./build/classes&lt;br /&gt;
  javac -d build/classes src/demo/hw/client/*.java&lt;br /&gt;
  javac -d build/classes src/demo/hw/server/*.java&lt;br /&gt;
For Windows:&lt;br /&gt;
  set classpath=%classpath%;%CXF_HOME%\lib\cxf-manifest-incubator.jar;.\build\classes&lt;br /&gt;
  javac -d build\classes src\demo\hw\client\*.java&lt;br /&gt;
  javac -d build\classes src\demo\hw\server\*.java&lt;br /&gt;
&lt;br /&gt;
Running the demo using java&lt;br /&gt;
---------------------------&lt;br /&gt;
From the samples/hello_world_xml_wrapped directory run the commands, entered &lt;br /&gt;
on a single command line:&lt;br /&gt;
For UNIX (must use forward slashes):&lt;br /&gt;
    java -Djava.util.logging.config.file=$CXF_HOME/etc/logging.properties&lt;br /&gt;
         demo.hw.server.Server &amp;amp;&lt;br /&gt;
    java -Djava.util.logging.config.file=$CXF_HOME/etc/logging.properties&lt;br /&gt;
         demo.hw.client.Client ./wsdl/hello_world.wsdl&lt;br /&gt;
The server process starts in the background.  After running the client,&lt;br /&gt;
use the kill command to terminate the server process.&lt;br /&gt;
For Windows (may use either forward or back slashes):&lt;br /&gt;
  start &lt;br /&gt;
    java -Djava.util.logging.config.file=%CXF_HOME%\etc\logging.properties&lt;br /&gt;
         demo.hw.server.Server&lt;br /&gt;
    java -Djava.util.logging.config.file=%CXF_HOME%\etc\logging.properties&lt;br /&gt;
       demo.hw.client.Client .\wsdl\hello_world.wsdl&lt;br /&gt;
A new command windows opens for the server process.  After running the&lt;br /&gt;
client, terminate the server process by issuing Ctrl-C in its command window.&lt;br /&gt;
To remove the code generated from the WSDL file and the .class&lt;br /&gt;
files, either delete the build directory and its contents or run:&lt;br /&gt;
  ant clean&lt;br /&gt;
&lt;br /&gt;
Building and running the demo in a servlet container&lt;br /&gt;
----------------------------------------------------&lt;br /&gt;
From the samples/hello_world_xml_wrapped directory, the ant build script&lt;br /&gt;
can be used to create the war file that is deployed into the&lt;br /&gt;
servlet container.&lt;br /&gt;
Build the war file with the command:&lt;br /&gt;
  ant war&lt;br /&gt;
    &lt;br /&gt;
Preparing deploy to APACHE TOMCAT&lt;br /&gt;
* set CATALINA_HOME environment to your TOMCAT home directory&lt;br /&gt;
    &lt;br /&gt;
Deploy the application into APACHE TOMCAT with the commond:&lt;br /&gt;
[NOTE] This step will check if the cxf jars present in Tomcat, &lt;br /&gt;
       if not, it will automatically copy all the jars into CATALINA_HOME/shared/lib&lt;br /&gt;
  &lt;br /&gt;
  ant deploy -Dtomcat=true&lt;br /&gt;
The servlet container will extract the war and deploy the application.&lt;br /&gt;
&lt;br /&gt;
Using ant, run the client application with the command:&lt;br /&gt;
  ant client-servlet -Dbase.url=http://localhost:#&lt;br /&gt;
Where # is the TCP/IP port used by the servlet container,&lt;br /&gt;
e.g., 8080.&lt;br /&gt;
Or&lt;br /&gt;
  ant client-servlet -Dhost=localhost -Dport=8080&lt;br /&gt;
Using java, run the client application with the command:&lt;br /&gt;
  For UNIX:&lt;br /&gt;
    &lt;br /&gt;
    java -Djava.util.logging.config.file=$CXF_HOME/etc/logging.properties&lt;br /&gt;
         demo.hw.client.Client http://localhost:#/helloworld/services/hello_world?wsdl&lt;br /&gt;
  For Windows:&lt;br /&gt;
    java -Djava.util.logging.config.file=%CXF_HOME%\etc\logging.properties&lt;br /&gt;
       demo.hw.client.Client http://localhost:#/helloworld/services/hello_world?wsdl&lt;br /&gt;
Where # is the TCP/IP port used by the servlet container,&lt;br /&gt;
e.g., 8080.&lt;br /&gt;
Undeploy the application from the APACHE TOMCAT with the command:&lt;br /&gt;
   ant undeploy -Dtomcat=true&lt;br /&gt;
&lt;br /&gt;
Running demo with HTTP GET&lt;br /&gt;
----------------------------------------------------&lt;br /&gt;
APACHE CXF support HTTP GET to invoke the service, instead of running &lt;br /&gt;
   ant client&lt;br /&gt;
you can use &lt;br /&gt;
   ant client.get &lt;br /&gt;
to invoke the service with simple HttpURLConnection, or you can even&lt;br /&gt;
use your favoriate browser to get the results back.&lt;br /&gt;
&lt;br /&gt;
///////////////////////////////////////////////////////////////////&lt;br /&gt;
/**&lt;br /&gt;
 * Licensed to the Apache Software Foundation (ASF) under one&lt;br /&gt;
 * or more contributor license agreements. See the NOTICE file&lt;br /&gt;
 * distributed with this work for additional information&lt;br /&gt;
 * regarding copyright ownership. The ASF licenses this file&lt;br /&gt;
 * to you under the Apache License, Version 2.0 (the&lt;br /&gt;
 * &amp;quot;License&amp;quot;); you may not use this file except in compliance&lt;br /&gt;
 * with the License. You may obtain a copy of the License at&lt;br /&gt;
 *&lt;br /&gt;
 * http://www.apache.org/licenses/LICENSE-2.0&lt;br /&gt;
 *&lt;br /&gt;
 * Unless required by applicable law or agreed to in writing,&lt;br /&gt;
 * software distributed under the License is distributed on an&lt;br /&gt;
 * &amp;quot;AS IS&amp;quot; BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY&lt;br /&gt;
 * KIND, either express or implied. See the License for the&lt;br /&gt;
 * specific language governing permissions and limitations&lt;br /&gt;
 * under the License.&lt;br /&gt;
 */&lt;br /&gt;
package demo.hw.client;&lt;br /&gt;
import java.io.File;&lt;br /&gt;
import java.net.URL;&lt;br /&gt;
import javax.xml.namespace.QName;&lt;br /&gt;
import org.apache.hello_world_xml_http.wrapped.Greeter;&lt;br /&gt;
import org.apache.hello_world_xml_http.wrapped.PingMeFault;&lt;br /&gt;
import org.apache.hello_world_xml_http.wrapped.XMLService;&lt;br /&gt;
public final class Client {&lt;br /&gt;
    public static final QName SERVICE_NAME = new QName(&amp;quot;http://apache.org/hello_world_xml_http/wrapped&amp;quot;,&lt;br /&gt;
            &amp;quot;XMLService&amp;quot;);&lt;br /&gt;
    public static final QName PORT_NAME = &lt;br /&gt;
        new QName(&amp;quot;http://apache.org/hello_world_xml_http/wrapped&amp;quot;, &amp;quot;XMLPort&amp;quot;);&lt;br /&gt;
    private Client() {&lt;br /&gt;
    }&lt;br /&gt;
    public static void main(String args[]) throws Exception {&lt;br /&gt;
        if (args.length == 0) {&lt;br /&gt;
            System.out.println(&amp;quot;please specify wsdl&amp;quot;);&lt;br /&gt;
            System.exit(1);&lt;br /&gt;
        }&lt;br /&gt;
        URL wsdlURL;&lt;br /&gt;
        File wsdlFile = new File(args[0]);&lt;br /&gt;
        if (wsdlFile.exists()) {&lt;br /&gt;
            wsdlURL = wsdlFile.toURL();&lt;br /&gt;
        } else {&lt;br /&gt;
            wsdlURL = new URL(args[0]);&lt;br /&gt;
        }&lt;br /&gt;
        System.out.println(wsdlURL);&lt;br /&gt;
        XMLService ss = new XMLService(wsdlURL, SERVICE_NAME);&lt;br /&gt;
        Greeter port = ss.getXMLPort();&lt;br /&gt;
        String resp;&lt;br /&gt;
        System.out.println(&amp;quot;Invoking sayHi...&amp;quot;);&lt;br /&gt;
        resp = port.sayHi();&lt;br /&gt;
        System.out.println(&amp;quot;Server responded with: &amp;quot; + resp);&lt;br /&gt;
        System.out.println();&lt;br /&gt;
        System.out.println(&amp;quot;Invoking greetMe...&amp;quot;);&lt;br /&gt;
        resp = port.greetMe(System.getProperty(&amp;quot;user.name&amp;quot;));&lt;br /&gt;
        System.out.println(&amp;quot;Server responded with: &amp;quot; + resp);&lt;br /&gt;
        System.out.println();&lt;br /&gt;
        System.out.println(&amp;quot;Invoking greetMeOneWay...&amp;quot;);&lt;br /&gt;
        port.greetMeOneWay(System.getProperty(&amp;quot;user.name&amp;quot;));&lt;br /&gt;
        System.out.println(&amp;quot;No response from server as method is OneWay&amp;quot;);&lt;br /&gt;
        System.out.println();&lt;br /&gt;
        try {&lt;br /&gt;
            System.out.println(&amp;quot;Invoking pingMe, expecting exception...&amp;quot;);&lt;br /&gt;
            port.pingMe();&lt;br /&gt;
        } catch (PingMeFault ex) {&lt;br /&gt;
            System.out.println(&amp;quot;Expected exception: &amp;quot; + ex.getMessage());&lt;br /&gt;
        }&lt;br /&gt;
    &lt;br /&gt;
        System.exit(0);&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
///////////////////////////////////////////////////////////////////&lt;br /&gt;
/**&lt;br /&gt;
 * Licensed to the Apache Software Foundation (ASF) under one&lt;br /&gt;
 * or more contributor license agreements. See the NOTICE file&lt;br /&gt;
 * distributed with this work for additional information&lt;br /&gt;
 * regarding copyright ownership. The ASF licenses this file&lt;br /&gt;
 * to you under the Apache License, Version 2.0 (the&lt;br /&gt;
 * &amp;quot;License&amp;quot;); you may not use this file except in compliance&lt;br /&gt;
 * with the License. You may obtain a copy of the License at&lt;br /&gt;
 *&lt;br /&gt;
 * http://www.apache.org/licenses/LICENSE-2.0&lt;br /&gt;
 *&lt;br /&gt;
 * Unless required by applicable law or agreed to in writing,&lt;br /&gt;
 * software distributed under the License is distributed on an&lt;br /&gt;
 * &amp;quot;AS IS&amp;quot; BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY&lt;br /&gt;
 * KIND, either express or implied. See the License for the&lt;br /&gt;
 * specific language governing permissions and limitations&lt;br /&gt;
 * under the License.&lt;br /&gt;
 */&lt;br /&gt;
package demo.hw.client;&lt;br /&gt;
import java.io.ByteArrayOutputStream;&lt;br /&gt;
import java.io.InputStream;&lt;br /&gt;
import java.net.HttpURLConnection;&lt;br /&gt;
import java.net.URL;&lt;br /&gt;
import java.util.Properties;&lt;br /&gt;
import javax.xml.transform.OutputKeys;&lt;br /&gt;
import javax.xml.transform.Source;&lt;br /&gt;
import javax.xml.transform.Transformer;&lt;br /&gt;
import javax.xml.transform.TransformerFactory;&lt;br /&gt;
import javax.xml.transform.stream.StreamResult;&lt;br /&gt;
import javax.xml.transform.stream.StreamSource;&lt;br /&gt;
public final class Get {&lt;br /&gt;
    private Get() {&lt;br /&gt;
    } &lt;br /&gt;
    public static void main(String args[]) throws Exception {&lt;br /&gt;
        // Sent HTTP GET request to invoke sayHi&lt;br /&gt;
        String target = &amp;quot;http://localhost:9000/XMLService/XMLPort/sayHi&amp;quot;;&lt;br /&gt;
        URL url = new URL(target);&lt;br /&gt;
        HttpURLConnection httpConnection = (HttpURLConnection) url.openConnection();&lt;br /&gt;
        httpConnection.connect();&lt;br /&gt;
        System.out.println(&amp;quot;Invoking server through HTTP GET to invoke sayHi&amp;quot;);&lt;br /&gt;
        InputStream in = httpConnection.getInputStream();&lt;br /&gt;
        StreamSource source = new StreamSource(in);&lt;br /&gt;
        printSource(source);&lt;br /&gt;
        // Sent HTTP GET request to invoke greetMe FAULT&lt;br /&gt;
        target = &amp;quot;http://localhost:9000/XMLService/XMLPort/greetMe/me/CXF&amp;quot;;&lt;br /&gt;
        url = new URL(target);&lt;br /&gt;
        httpConnection = (HttpURLConnection) url.openConnection();&lt;br /&gt;
        httpConnection.connect();&lt;br /&gt;
        System.out.println(&amp;quot;Invoking server through HTTP GET to invoke greetMe&amp;quot;);&lt;br /&gt;
        try {&lt;br /&gt;
            in = httpConnection.getInputStream();&lt;br /&gt;
            source = new StreamSource(in);&lt;br /&gt;
            printSource(source);&lt;br /&gt;
        } catch (Exception e) {&lt;br /&gt;
            System.err.println(&amp;quot;GreetMe Fault: &amp;quot; + e.getMessage());&lt;br /&gt;
        }&lt;br /&gt;
        InputStream err = httpConnection.getErrorStream();&lt;br /&gt;
        source = new StreamSource(err);&lt;br /&gt;
        printSource(source);&lt;br /&gt;
        // Sent HTTP GET request to invoke greetMe&lt;br /&gt;
        target = &amp;quot;http://localhost:9000/XMLService/XMLPort/greetMe/requestType/CXF&amp;quot;;&lt;br /&gt;
        url = new URL(target);&lt;br /&gt;
        httpConnection = (HttpURLConnection) url.openConnection();&lt;br /&gt;
        httpConnection.connect();&lt;br /&gt;
        System.out.println(&amp;quot;Invoking server through HTTP GET to invoke greetMe&amp;quot;);&lt;br /&gt;
        in = httpConnection.getInputStream();&lt;br /&gt;
        source = new StreamSource(in);&lt;br /&gt;
        printSource(source);&lt;br /&gt;
        // Sent HTTP GET request to invoke pingMe&lt;br /&gt;
        target = &amp;quot;http://localhost:9000/XMLService/XMLPort/pingMe&amp;quot;;&lt;br /&gt;
        url = new URL(target);&lt;br /&gt;
        httpConnection = (HttpURLConnection) url.openConnection();&lt;br /&gt;
        httpConnection.connect();&lt;br /&gt;
        System.out.println(&amp;quot;Invoking server through HTTP GET to invoke pingMe&amp;quot;);&lt;br /&gt;
        try {&lt;br /&gt;
            in = httpConnection.getInputStream();&lt;br /&gt;
        } catch (Exception e) {&lt;br /&gt;
            System.out.println(&amp;quot;PingMe fault raised&amp;quot;);&lt;br /&gt;
        }&lt;br /&gt;
        err = httpConnection.getErrorStream();&lt;br /&gt;
        source = new StreamSource(err);&lt;br /&gt;
        printSource(source);&lt;br /&gt;
    }&lt;br /&gt;
    private static void printSource(Source source) {&lt;br /&gt;
        try {&lt;br /&gt;
            ByteArrayOutputStream bos = new ByteArrayOutputStream();&lt;br /&gt;
            StreamResult sr = new StreamResult(bos);&lt;br /&gt;
            Transformer trans = TransformerFactory.newInstance().newTransformer();&lt;br /&gt;
            Properties oprops = new Properties();&lt;br /&gt;
            oprops.put(OutputKeys.OMIT_XML_DECLARATION, &amp;quot;yes&amp;quot;);&lt;br /&gt;
            trans.setOutputProperties(oprops);&lt;br /&gt;
            trans.transform(source, sr);&lt;br /&gt;
            System.out.println();&lt;br /&gt;
            System.out.println(&amp;quot;**** Response ******&amp;quot;);&lt;br /&gt;
            System.out.println();&lt;br /&gt;
            System.out.println(bos.toString());&lt;br /&gt;
            bos.close();&lt;br /&gt;
            System.out.println();&lt;br /&gt;
        } catch (Exception e) {&lt;br /&gt;
            e.printStackTrace();&lt;br /&gt;
        }&lt;br /&gt;
    }    &lt;br /&gt;
}&lt;br /&gt;
///////////////////////////////////////////////////////////////////&lt;br /&gt;
/**&lt;br /&gt;
 * Licensed to the Apache Software Foundation (ASF) under one&lt;br /&gt;
 * or more contributor license agreements. See the NOTICE file&lt;br /&gt;
 * distributed with this work for additional information&lt;br /&gt;
 * regarding copyright ownership. The ASF licenses this file&lt;br /&gt;
 * to you under the Apache License, Version 2.0 (the&lt;br /&gt;
 * &amp;quot;License&amp;quot;); you may not use this file except in compliance&lt;br /&gt;
 * with the License. You may obtain a copy of the License at&lt;br /&gt;
 *&lt;br /&gt;
 * http://www.apache.org/licenses/LICENSE-2.0&lt;br /&gt;
 *&lt;br /&gt;
 * Unless required by applicable law or agreed to in writing,&lt;br /&gt;
 * software distributed under the License is distributed on an&lt;br /&gt;
 * &amp;quot;AS IS&amp;quot; BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY&lt;br /&gt;
 * KIND, either express or implied. See the License for the&lt;br /&gt;
 * specific language governing permissions and limitations&lt;br /&gt;
 * under the License.&lt;br /&gt;
 */&lt;br /&gt;
package demo.hw.server;&lt;br /&gt;
import org.apache.hello_world_xml_http.wrapped.Greeter;&lt;br /&gt;
import org.apache.hello_world_xml_http.wrapped.PingMeFault;&lt;br /&gt;
import org.apache.hello_world_xml_http.wrapped.types.FaultDetail;&lt;br /&gt;
@javax.jws.WebService(serviceName = &amp;quot;XMLService&amp;quot;, &lt;br /&gt;
                      portName = &amp;quot;XMLPort&amp;quot;,&lt;br /&gt;
                      endpointInterface = &amp;quot;org.apache.hello_world_xml_http.wrapped.Greeter&amp;quot;,&lt;br /&gt;
                      targetNamespace = &amp;quot;http://apache.org/hello_world_xml_http/wrapped&amp;quot;)&lt;br /&gt;
@javax.xml.ws.BindingType(value = &amp;quot;http://cxf.apache.org/bindings/xformat&amp;quot;)&lt;br /&gt;
public class GreeterImpl implements Greeter {&lt;br /&gt;
    public String greetMe(String me) {&lt;br /&gt;
        System.out.println(&amp;quot;received calling greetMe!&amp;quot;);&lt;br /&gt;
        return &amp;quot;Hello &amp;quot; + me;&lt;br /&gt;
    }&lt;br /&gt;
    public void greetMeOneWay(String me) {&lt;br /&gt;
        System.out.println(&amp;quot;Executing operation greetMeOneWay\n&amp;quot;);&lt;br /&gt;
        System.out.println(&amp;quot;Hello there &amp;quot; + me);&lt;br /&gt;
    }&lt;br /&gt;
    public String sayHi() {&lt;br /&gt;
        System.out.println(&amp;quot;received calling sayHi!&amp;quot;);&lt;br /&gt;
        return &amp;quot;Bonjour&amp;quot;;&lt;br /&gt;
    }&lt;br /&gt;
    public void pingMe() throws PingMeFault {&lt;br /&gt;
        System.out.println(&amp;quot;received calling PingMeFault!&amp;quot;);&lt;br /&gt;
        FaultDetail faultDetail = new FaultDetail();&lt;br /&gt;
        faultDetail.setMajor((short)2);&lt;br /&gt;
        faultDetail.setMinor((short)1);&lt;br /&gt;
        throw new PingMeFault(&amp;quot;PingMeFault raised by server&amp;quot;, faultDetail);&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
///////////////////////////////////////////////////////////////////&lt;br /&gt;
/**&lt;br /&gt;
 * Licensed to the Apache Software Foundation (ASF) under one&lt;br /&gt;
 * or more contributor license agreements. See the NOTICE file&lt;br /&gt;
 * distributed with this work for additional information&lt;br /&gt;
 * regarding copyright ownership. The ASF licenses this file&lt;br /&gt;
 * to you under the Apache License, Version 2.0 (the&lt;br /&gt;
 * &amp;quot;License&amp;quot;); you may not use this file except in compliance&lt;br /&gt;
 * with the License. You may obtain a copy of the License at&lt;br /&gt;
 *&lt;br /&gt;
 * http://www.apache.org/licenses/LICENSE-2.0&lt;br /&gt;
 *&lt;br /&gt;
 * Unless required by applicable law or agreed to in writing,&lt;br /&gt;
 * software distributed under the License is distributed on an&lt;br /&gt;
 * &amp;quot;AS IS&amp;quot; BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY&lt;br /&gt;
 * KIND, either express or implied. See the License for the&lt;br /&gt;
 * specific language governing permissions and limitations&lt;br /&gt;
 * under the License.&lt;br /&gt;
 */&lt;br /&gt;
package demo.hw.server;&lt;br /&gt;
import javax.xml.ws.Endpoint;&lt;br /&gt;
public class Server {&lt;br /&gt;
    protected Server() throws Exception {&lt;br /&gt;
        System.out.println(&amp;quot;Starting Server&amp;quot;);&lt;br /&gt;
        Object implementor = new GreeterImpl();&lt;br /&gt;
        String address = &amp;quot;http://localhost:9000/XMLService/XMLPort&amp;quot;;&lt;br /&gt;
        Endpoint.publish(address, implementor);&lt;br /&gt;
    }&lt;br /&gt;
    public static void main(String args[]) throws Exception {&lt;br /&gt;
        new Server();&lt;br /&gt;
        System.out.println(&amp;quot;Server ready...&amp;quot;);&lt;br /&gt;
        Thread.sleep(5 * 60 * 1000);&lt;br /&gt;
        System.out.println(&amp;quot;Server exiting&amp;quot;);&lt;br /&gt;
        System.exit(0);&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
///////////////////////////////////////////////////////////////////&lt;br /&gt;
&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot;?&amp;gt;&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
  Licensed to the Apache Software Foundation (ASF) under one&lt;br /&gt;
  or more contributor license agreements. See the NOTICE file&lt;br /&gt;
  distributed with this work for additional information&lt;br /&gt;
  regarding copyright ownership. The ASF licenses this file&lt;br /&gt;
  to you under the Apache License, Version 2.0 (the&lt;br /&gt;
  &amp;quot;License&amp;quot;); you may not use this file except in compliance&lt;br /&gt;
  with the License. You may obtain a copy of the License at&lt;br /&gt;
  &lt;br /&gt;
  http://www.apache.org/licenses/LICENSE-2.0&lt;br /&gt;
  &lt;br /&gt;
  Unless required by applicable law or agreed to in writing,&lt;br /&gt;
  software distributed under the License is distributed on an&lt;br /&gt;
  &amp;quot;AS IS&amp;quot; BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY&lt;br /&gt;
  KIND, either express or implied. See the License for the&lt;br /&gt;
  specific language governing permissions and limitations&lt;br /&gt;
  under the License.&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&amp;lt;wsdl:definitions name=&amp;quot;HelloWorld&amp;quot;&lt;br /&gt;
  targetNamespace=&amp;quot;http://apache.org/hello_world_xml_http/wrapped&amp;quot;&lt;br /&gt;
  xmlns=&amp;quot;http://schemas.xmlsoap.org/wsdl/&amp;quot;&lt;br /&gt;
  xmlns:http=&amp;quot;http://schemas.xmlsoap.org/wsdl/http/&amp;quot;&lt;br /&gt;
  xmlns:tns=&amp;quot;http://apache.org/hello_world_xml_http/wrapped&amp;quot;&lt;br /&gt;
  xmlns:x1=&amp;quot;http://apache.org/hello_world_xml_http/wrapped/types&amp;quot;&lt;br /&gt;
  xmlns:wsdl=&amp;quot;http://schemas.xmlsoap.org/wsdl/&amp;quot;&lt;br /&gt;
  xmlns:xformat=&amp;quot;http://cxf.apache.org/bindings/xformat&amp;quot;&lt;br /&gt;
  xmlns:xsd=&amp;quot;http://www.w3.org/2001/XMLSchema&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;wsdl:types&amp;gt;&lt;br /&gt;
    &amp;lt;schema&lt;br /&gt;
      targetNamespace=&amp;quot;http://apache.org/hello_world_xml_http/wrapped/types&amp;quot;&lt;br /&gt;
      xmlns=&amp;quot;http://www.w3.org/2001/XMLSchema&amp;quot;&lt;br /&gt;
      elementFormDefault=&amp;quot;qualified&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;element name=&amp;quot;sayHi&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;complexType /&amp;gt;&lt;br /&gt;
      &amp;lt;/element&amp;gt;&lt;br /&gt;
      &amp;lt;element name=&amp;quot;sayHiResponse&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;complexType&amp;gt;&lt;br /&gt;
          &amp;lt;sequence&amp;gt;&lt;br /&gt;
            &amp;lt;element name=&amp;quot;responseType&amp;quot; type=&amp;quot;xsd:string&amp;quot; /&amp;gt;&lt;br /&gt;
          &amp;lt;/sequence&amp;gt;&lt;br /&gt;
        &amp;lt;/complexType&amp;gt;&lt;br /&gt;
      &amp;lt;/element&amp;gt;&lt;br /&gt;
      &amp;lt;element name=&amp;quot;greetMe&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;complexType&amp;gt;&lt;br /&gt;
          &amp;lt;sequence&amp;gt;&lt;br /&gt;
            &amp;lt;element name=&amp;quot;requestType&amp;quot; type=&amp;quot;xsd:string&amp;quot; /&amp;gt;&lt;br /&gt;
          &amp;lt;/sequence&amp;gt;&lt;br /&gt;
        &amp;lt;/complexType&amp;gt;&lt;br /&gt;
      &amp;lt;/element&amp;gt;&lt;br /&gt;
      &amp;lt;element name=&amp;quot;greetMeResponse&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;complexType&amp;gt;&lt;br /&gt;
          &amp;lt;sequence&amp;gt;&lt;br /&gt;
            &amp;lt;element name=&amp;quot;responseType&amp;quot; type=&amp;quot;xsd:string&amp;quot; /&amp;gt;&lt;br /&gt;
          &amp;lt;/sequence&amp;gt;&lt;br /&gt;
        &amp;lt;/complexType&amp;gt;&lt;br /&gt;
      &amp;lt;/element&amp;gt;&lt;br /&gt;
      &amp;lt;element name=&amp;quot;greetMeOneWay&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;complexType&amp;gt;&lt;br /&gt;
          &amp;lt;sequence&amp;gt;&lt;br /&gt;
            &amp;lt;element name=&amp;quot;requestType&amp;quot; type=&amp;quot;xsd:string&amp;quot; /&amp;gt;&lt;br /&gt;
          &amp;lt;/sequence&amp;gt;&lt;br /&gt;
        &amp;lt;/complexType&amp;gt;&lt;br /&gt;
      &amp;lt;/element&amp;gt;&lt;br /&gt;
      &amp;lt;element name=&amp;quot;pingMe&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;complexType /&amp;gt;&lt;br /&gt;
      &amp;lt;/element&amp;gt;&lt;br /&gt;
      &amp;lt;element name=&amp;quot;pingMeResponse&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;complexType /&amp;gt;&lt;br /&gt;
      &amp;lt;/element&amp;gt;&lt;br /&gt;
      &amp;lt;element name=&amp;quot;faultDetail&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;complexType&amp;gt;&lt;br /&gt;
          &amp;lt;sequence&amp;gt;&lt;br /&gt;
            &amp;lt;element name=&amp;quot;minor&amp;quot; type=&amp;quot;xsd:short&amp;quot; /&amp;gt;&lt;br /&gt;
            &amp;lt;element name=&amp;quot;major&amp;quot; type=&amp;quot;xsd:short&amp;quot; /&amp;gt;&lt;br /&gt;
          &amp;lt;/sequence&amp;gt;&lt;br /&gt;
        &amp;lt;/complexType&amp;gt;&lt;br /&gt;
      &amp;lt;/element&amp;gt;&lt;br /&gt;
    &amp;lt;/schema&amp;gt;&lt;br /&gt;
  &amp;lt;/wsdl:types&amp;gt;&lt;br /&gt;
  &amp;lt;wsdl:message name=&amp;quot;sayHiRequest&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;wsdl:part element=&amp;quot;x1:sayHi&amp;quot; name=&amp;quot;in&amp;quot; /&amp;gt;&lt;br /&gt;
  &amp;lt;/wsdl:message&amp;gt;&lt;br /&gt;
  &amp;lt;wsdl:message name=&amp;quot;sayHiResponse&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;wsdl:part element=&amp;quot;x1:sayHiResponse&amp;quot; name=&amp;quot;out&amp;quot; /&amp;gt;&lt;br /&gt;
  &amp;lt;/wsdl:message&amp;gt;&lt;br /&gt;
  &amp;lt;wsdl:message name=&amp;quot;greetMeRequest&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;wsdl:part element=&amp;quot;x1:greetMe&amp;quot; name=&amp;quot;in&amp;quot; /&amp;gt;&lt;br /&gt;
  &amp;lt;/wsdl:message&amp;gt;&lt;br /&gt;
  &amp;lt;wsdl:message name=&amp;quot;greetMeResponse&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;wsdl:part element=&amp;quot;x1:greetMeResponse&amp;quot; name=&amp;quot;out&amp;quot; /&amp;gt;&lt;br /&gt;
  &amp;lt;/wsdl:message&amp;gt;&lt;br /&gt;
  &amp;lt;wsdl:message name=&amp;quot;greetMeOneWayRequest&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;wsdl:part element=&amp;quot;x1:greetMeOneWay&amp;quot; name=&amp;quot;in&amp;quot; /&amp;gt;&lt;br /&gt;
  &amp;lt;/wsdl:message&amp;gt;&lt;br /&gt;
  &amp;lt;wsdl:message name=&amp;quot;pingMeRequest&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;wsdl:part name=&amp;quot;in&amp;quot; element=&amp;quot;x1:pingMe&amp;quot; /&amp;gt;&lt;br /&gt;
  &amp;lt;/wsdl:message&amp;gt;&lt;br /&gt;
  &amp;lt;wsdl:message name=&amp;quot;pingMeResponse&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;wsdl:part name=&amp;quot;out&amp;quot; element=&amp;quot;x1:pingMeResponse&amp;quot; /&amp;gt;&lt;br /&gt;
  &amp;lt;/wsdl:message&amp;gt;&lt;br /&gt;
  &amp;lt;wsdl:message name=&amp;quot;pingMeFault&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;wsdl:part name=&amp;quot;faultDetail&amp;quot; element=&amp;quot;x1:faultDetail&amp;quot; /&amp;gt;&lt;br /&gt;
  &amp;lt;/wsdl:message&amp;gt;&lt;br /&gt;
  &amp;lt;wsdl:portType name=&amp;quot;Greeter&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;wsdl:operation name=&amp;quot;sayHi&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;wsdl:input message=&amp;quot;tns:sayHiRequest&amp;quot; name=&amp;quot;sayHiRequest&amp;quot; /&amp;gt;&lt;br /&gt;
      &amp;lt;wsdl:output message=&amp;quot;tns:sayHiResponse&amp;quot;&lt;br /&gt;
        name=&amp;quot;sayHiResponse&amp;quot; /&amp;gt;&lt;br /&gt;
    &amp;lt;/wsdl:operation&amp;gt;&lt;br /&gt;
    &amp;lt;wsdl:operation name=&amp;quot;greetMe&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;wsdl:input message=&amp;quot;tns:greetMeRequest&amp;quot;&lt;br /&gt;
        name=&amp;quot;greetMeRequest&amp;quot; /&amp;gt;&lt;br /&gt;
      &amp;lt;wsdl:output message=&amp;quot;tns:greetMeResponse&amp;quot;&lt;br /&gt;
        name=&amp;quot;greetMeResponse&amp;quot; /&amp;gt;&lt;br /&gt;
    &amp;lt;/wsdl:operation&amp;gt;&lt;br /&gt;
    &amp;lt;wsdl:operation name=&amp;quot;greetMeOneWay&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;wsdl:input message=&amp;quot;tns:greetMeOneWayRequest&amp;quot;&lt;br /&gt;
        name=&amp;quot;greetMeOneWayRequest&amp;quot; /&amp;gt;&lt;br /&gt;
    &amp;lt;/wsdl:operation&amp;gt;&lt;br /&gt;
    &amp;lt;wsdl:operation name=&amp;quot;pingMe&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;wsdl:input name=&amp;quot;pingMeRequest&amp;quot;&lt;br /&gt;
        message=&amp;quot;tns:pingMeRequest&amp;quot; /&amp;gt;&lt;br /&gt;
      &amp;lt;wsdl:output name=&amp;quot;pingMeResponse&amp;quot;&lt;br /&gt;
        message=&amp;quot;tns:pingMeResponse&amp;quot; /&amp;gt;&lt;br /&gt;
      &amp;lt;wsdl:fault name=&amp;quot;pingMeFault&amp;quot; message=&amp;quot;tns:pingMeFault&amp;quot; /&amp;gt;&lt;br /&gt;
    &amp;lt;/wsdl:operation&amp;gt;&lt;br /&gt;
  &amp;lt;/wsdl:portType&amp;gt;&lt;br /&gt;
  &amp;lt;wsdl:binding name=&amp;quot;Greeter_XMLBinding&amp;quot; type=&amp;quot;tns:Greeter&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;xformat:binding /&amp;gt;&lt;br /&gt;
    &amp;lt;wsdl:operation name=&amp;quot;sayHi&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;wsdl:input name=&amp;quot;sayHiRequest&amp;quot; /&amp;gt;&lt;br /&gt;
      &amp;lt;wsdl:output name=&amp;quot;sayHiResponse&amp;quot; /&amp;gt;&lt;br /&gt;
    &amp;lt;/wsdl:operation&amp;gt;&lt;br /&gt;
    &amp;lt;wsdl:operation name=&amp;quot;greetMe&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;wsdl:input name=&amp;quot;greetMeRequest&amp;quot; /&amp;gt;&lt;br /&gt;
      &amp;lt;wsdl:output name=&amp;quot;greetMeResponse&amp;quot; /&amp;gt;&lt;br /&gt;
    &amp;lt;/wsdl:operation&amp;gt;&lt;br /&gt;
    &amp;lt;wsdl:operation name=&amp;quot;greetMeOneWay&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;wsdl:input name=&amp;quot;greetMeOneWayRequest&amp;quot; /&amp;gt;&lt;br /&gt;
    &amp;lt;/wsdl:operation&amp;gt;&lt;br /&gt;
    &amp;lt;wsdl:operation name=&amp;quot;pingMe&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;wsdl:input /&amp;gt;&lt;br /&gt;
      &amp;lt;wsdl:output /&amp;gt;&lt;br /&gt;
      &amp;lt;wsdl:fault name=&amp;quot;pingMeFault&amp;quot; /&amp;gt;&lt;br /&gt;
    &amp;lt;/wsdl:operation&amp;gt;&lt;br /&gt;
  &amp;lt;/wsdl:binding&amp;gt;&lt;br /&gt;
  &amp;lt;wsdl:service name=&amp;quot;XMLService&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;wsdl:port binding=&amp;quot;tns:Greeter_XMLBinding&amp;quot; name=&amp;quot;XMLPort&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;http:address&lt;br /&gt;
        location=&amp;quot;http://localhost:9000/XMLService/XMLPort&amp;quot; /&amp;gt;&lt;br /&gt;
    &amp;lt;/wsdl:port&amp;gt;    &lt;br /&gt;
  &amp;lt;/wsdl:service&amp;gt;&lt;br /&gt;
&amp;lt;/wsdl:definitions&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
        &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Colocated Demo using Document/Literal Style ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
/**&lt;br /&gt;
 * Licensed to the Apache Software Foundation (ASF) under one&lt;br /&gt;
 * or more contributor license agreements. See the NOTICE file&lt;br /&gt;
 * distributed with this work for additional information&lt;br /&gt;
 * regarding copyright ownership. The ASF licenses this file&lt;br /&gt;
 * to you under the Apache License, Version 2.0 (the&lt;br /&gt;
 * &amp;quot;License&amp;quot;); you may not use this file except in compliance&lt;br /&gt;
 * with the License. You may obtain a copy of the License at&lt;br /&gt;
 *&lt;br /&gt;
 * http://www.apache.org/licenses/LICENSE-2.0&lt;br /&gt;
 *&lt;br /&gt;
 * Unless required by applicable law or agreed to in writing,&lt;br /&gt;
 * software distributed under the License is distributed on an&lt;br /&gt;
 * &amp;quot;AS IS&amp;quot; BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY&lt;br /&gt;
 * KIND, either express or implied. See the License for the&lt;br /&gt;
 * specific language governing permissions and limitations&lt;br /&gt;
 * under the License.&lt;br /&gt;
 */&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
Colocated Demo using Document/Literal Style&lt;br /&gt;
=============================================&lt;br /&gt;
Please review the README in the samples directory before&lt;br /&gt;
continuing.&lt;br /&gt;
&lt;br /&gt;
Prerequisite&lt;br /&gt;
------------&lt;br /&gt;
If your environment already includes cxf-incubator.jar on the&lt;br /&gt;
CLASSPATH, and the JDK and ant bin directories on the PATH&lt;br /&gt;
it is not necessary to set the environment as described in&lt;br /&gt;
the samples directory README.  If your environment is not&lt;br /&gt;
properly configured, or if you are planning on using wsdl2java,&lt;br /&gt;
javac, and java to build and run the demos, you must set the&lt;br /&gt;
environment.&lt;br /&gt;
&lt;br /&gt;
Building and running the demo using ant&lt;br /&gt;
---------------------------------------&lt;br /&gt;
From the samples/colocated directory, the ant build script&lt;br /&gt;
can be used to build and run the demo.&lt;br /&gt;
Using either UNIX or Windows:&lt;br /&gt;
  ant build&lt;br /&gt;
  ant client&lt;br /&gt;
&lt;br /&gt;
To remove the code generated from the WSDL file and the .class&lt;br /&gt;
files, run:&lt;br /&gt;
  ant clean&lt;br /&gt;
&lt;br /&gt;
Building the demo using wsdl2java and javac&lt;br /&gt;
-------------------------------------------&lt;br /&gt;
From the samples/colocated directory, first create the target&lt;br /&gt;
directory build/classes and then generate code from the WSDL file.&lt;br /&gt;
For UNIX:&lt;br /&gt;
  mkdir -p build/classes&lt;br /&gt;
  wsdl2java -d build/classes -compile ./wsdl/hello_world.wsdl&lt;br /&gt;
For Windows:&lt;br /&gt;
  mkdir build\classes&lt;br /&gt;
    Must use back slashes.&lt;br /&gt;
  wsdl2java -d build\classes -compile .\wsdl\hello_world.wsdl&lt;br /&gt;
    May use either forward or back slashes.&lt;br /&gt;
Now compile the provided client and server applications with the commands:&lt;br /&gt;
For UNIX:&lt;br /&gt;
  export CLASSPATH=$CLASSPATH:$CXF_HOME/lib/cxf-incubator.jar:./build/classes&lt;br /&gt;
  javac -d build/classes src/demo/colocated/server/*.java&lt;br /&gt;
  javac -d build/classes src/demo/colocated/client/*.java&lt;br /&gt;
For Windows:&lt;br /&gt;
  set classpath=%classpath%;%CXF_HOME%\lib\cxf-incubator.jar;.\build\classes&lt;br /&gt;
  javac -d build\classes src\demo\colocated\server\*.java&lt;br /&gt;
  javac -d build\classes src\demo\colocated\client\*.java&lt;br /&gt;
&lt;br /&gt;
Running the demo using java&lt;br /&gt;
---------------------------&lt;br /&gt;
From the samples/colocated directory run the commands, entered on a&lt;br /&gt;
single command line:&lt;br /&gt;
For UNIX (must use forward slashes):&lt;br /&gt;
    java -Djava.util.logging.config.file=$CXF_HOME/etc/logging.properties&lt;br /&gt;
         -Dcxf.config.file=./coloc.xml&lt;br /&gt;
         demo.colocated.client.Client ./wsdl/hello_world.wsdl&lt;br /&gt;
For Windows (may use either forward or back slashes):&lt;br /&gt;
  start&lt;br /&gt;
    java -Djava.util.logging.config.file=%CXF_HOME%\etc\logging.properties&lt;br /&gt;
         -Dcxf.config.file=.\coloc.xml&lt;br /&gt;
         demo.colocated.client.Client .\wsdl\hello_world.wsdl&lt;br /&gt;
To remove the code generated from the WSDL file and the .class&lt;br /&gt;
files, either delete the build directory and its contents or run:&lt;br /&gt;
  ant clean&lt;br /&gt;
&lt;br /&gt;
////////////////////////////////////////////////////////////////////&lt;br /&gt;
/**&lt;br /&gt;
 * Licensed to the Apache Software Foundation (ASF) under one&lt;br /&gt;
 * or more contributor license agreements. See the NOTICE file&lt;br /&gt;
 * distributed with this work for additional information&lt;br /&gt;
 * regarding copyright ownership. The ASF licenses this file&lt;br /&gt;
 * to you under the Apache License, Version 2.0 (the&lt;br /&gt;
 * &amp;quot;License&amp;quot;); you may not use this file except in compliance&lt;br /&gt;
 * with the License. You may obtain a copy of the License at&lt;br /&gt;
 *&lt;br /&gt;
 * http://www.apache.org/licenses/LICENSE-2.0&lt;br /&gt;
 *&lt;br /&gt;
 * Unless required by applicable law or agreed to in writing,&lt;br /&gt;
 * software distributed under the License is distributed on an&lt;br /&gt;
 * &amp;quot;AS IS&amp;quot; BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY&lt;br /&gt;
 * KIND, either express or implied. See the License for the&lt;br /&gt;
 * specific language governing permissions and limitations&lt;br /&gt;
 * under the License.&lt;br /&gt;
 */&lt;br /&gt;
package demo.colocated.client;&lt;br /&gt;
import java.io.File;&lt;br /&gt;
import java.net.URL;&lt;br /&gt;
import javax.xml.namespace.QName;&lt;br /&gt;
import demo.colocated.server.Server;&lt;br /&gt;
import org.apache.hello_world_soap_http.Greeter;&lt;br /&gt;
import org.apache.hello_world_soap_http.PingMeFault;&lt;br /&gt;
import org.apache.hello_world_soap_http.SOAPService;&lt;br /&gt;
import org.apache.hello_world_soap_http.types.FaultDetail;&lt;br /&gt;
public final class Client {&lt;br /&gt;
    private static final QName SERVICE_NAME&lt;br /&gt;
        = new QName(&amp;quot;http://apache.org/hello_world_soap_http&amp;quot;, &amp;quot;SOAPService&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
    private Client() {&lt;br /&gt;
    }&lt;br /&gt;
    public static void main(String args[]) throws Exception {&lt;br /&gt;
        if (args.length == 0) {&lt;br /&gt;
            System.out.println(&amp;quot;please specify wsdl&amp;quot;);&lt;br /&gt;
            System.exit(1);&lt;br /&gt;
        }&lt;br /&gt;
        Server.main(new String[]{&amp;quot;inProcess&amp;quot;});&lt;br /&gt;
        URL wsdlURL;&lt;br /&gt;
        File wsdlFile = new File(args[0]);&lt;br /&gt;
        if (wsdlFile.exists()) {&lt;br /&gt;
            wsdlURL = wsdlFile.toURL();&lt;br /&gt;
        } else {&lt;br /&gt;
            wsdlURL = new URL(args[0]);&lt;br /&gt;
        }&lt;br /&gt;
        System.out.println(wsdlURL);&lt;br /&gt;
        SOAPService ss = new SOAPService(wsdlURL, SERVICE_NAME);&lt;br /&gt;
        Greeter port = ss.getSoapPort();&lt;br /&gt;
        String resp;&lt;br /&gt;
        System.out.println(&amp;quot;Invoking sayHi...&amp;quot;);&lt;br /&gt;
        resp = port.sayHi();&lt;br /&gt;
        System.out.println(&amp;quot;Server responded with: &amp;quot; + resp);&lt;br /&gt;
        System.out.println();&lt;br /&gt;
        System.out.println(&amp;quot;Invoking greetMe...&amp;quot;);&lt;br /&gt;
        resp = port.greetMe(System.getProperty(&amp;quot;user.name&amp;quot;));&lt;br /&gt;
        System.out.println(&amp;quot;Server responded with: &amp;quot; + resp);&lt;br /&gt;
        System.out.println();&lt;br /&gt;
        try {&lt;br /&gt;
            System.out.println(&amp;quot;Invoking pingMe, expecting exception...&amp;quot;);&lt;br /&gt;
            port.pingMe();&lt;br /&gt;
        } catch (PingMeFault ex) {&lt;br /&gt;
            System.out.println(&amp;quot;Expected exception: PingMeFault has occurred: &amp;quot; + ex.getMessage());&lt;br /&gt;
            FaultDetail detail = ex.getFaultInfo();&lt;br /&gt;
            System.out.println(&amp;quot;FaultDetail major:&amp;quot; + detail.getMajor());&lt;br /&gt;
            System.out.println(&amp;quot;FaultDetail minor:&amp;quot; + detail.getMinor());&lt;br /&gt;
        }&lt;br /&gt;
        System.exit(0);&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
///////////////////////////////////////////////////////////////////////////&lt;br /&gt;
/**&lt;br /&gt;
 * Licensed to the Apache Software Foundation (ASF) under one&lt;br /&gt;
 * or more contributor license agreements. See the NOTICE file&lt;br /&gt;
 * distributed with this work for additional information&lt;br /&gt;
 * regarding copyright ownership. The ASF licenses this file&lt;br /&gt;
 * to you under the Apache License, Version 2.0 (the&lt;br /&gt;
 * &amp;quot;License&amp;quot;); you may not use this file except in compliance&lt;br /&gt;
 * with the License. You may obtain a copy of the License at&lt;br /&gt;
 *&lt;br /&gt;
 * http://www.apache.org/licenses/LICENSE-2.0&lt;br /&gt;
 *&lt;br /&gt;
 * Unless required by applicable law or agreed to in writing,&lt;br /&gt;
 * software distributed under the License is distributed on an&lt;br /&gt;
 * &amp;quot;AS IS&amp;quot; BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY&lt;br /&gt;
 * KIND, either express or implied. See the License for the&lt;br /&gt;
 * specific language governing permissions and limitations&lt;br /&gt;
 * under the License.&lt;br /&gt;
 */&lt;br /&gt;
package demo.colocated.rumon;&lt;br /&gt;
import javax.xml.ws.ProtocolException;&lt;br /&gt;
import org.apache.cxf.interceptor.Fault;&lt;br /&gt;
import org.apache.cxf.message.Message;&lt;br /&gt;
import org.apache.cxf.phase.AbstractPhaseInterceptor;&lt;br /&gt;
import org.apache.cxf.phase.Phase;&lt;br /&gt;
public class ThrowFaultInterceptor extends AbstractPhaseInterceptor&amp;lt;Message&amp;gt; {&lt;br /&gt;
    public ThrowFaultInterceptor() {&lt;br /&gt;
        super(Phase.PREPARE_SEND);&lt;br /&gt;
    }&lt;br /&gt;
    public void handleMessage(Message message) throws Fault {&lt;br /&gt;
        Boolean isColoc = (Boolean)message.get(&amp;quot;org.apache.cxf.message.Message.COLOCATED&amp;quot;);&lt;br /&gt;
        if (isColoc == null || isColoc == Boolean.FALSE) {&lt;br /&gt;
            String str = new String(&amp;quot;Collocated Invocation should have been detected.&amp;quot;);&lt;br /&gt;
            throw new ProtocolException(str);&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
///////////////////////////////////////////////////////////////////////////&lt;br /&gt;
/**&lt;br /&gt;
 * Licensed to the Apache Software Foundation (ASF) under one&lt;br /&gt;
 * or more contributor license agreements. See the NOTICE file&lt;br /&gt;
 * distributed with this work for additional information&lt;br /&gt;
 * regarding copyright ownership. The ASF licenses this file&lt;br /&gt;
 * to you under the Apache License, Version 2.0 (the&lt;br /&gt;
 * &amp;quot;License&amp;quot;); you may not use this file except in compliance&lt;br /&gt;
 * with the License. You may obtain a copy of the License at&lt;br /&gt;
 *&lt;br /&gt;
 * http://www.apache.org/licenses/LICENSE-2.0&lt;br /&gt;
 *&lt;br /&gt;
 * Unless required by applicable law or agreed to in writing,&lt;br /&gt;
 * software distributed under the License is distributed on an&lt;br /&gt;
 * &amp;quot;AS IS&amp;quot; BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY&lt;br /&gt;
 * KIND, either express or implied. See the License for the&lt;br /&gt;
 * specific language governing permissions and limitations&lt;br /&gt;
 * under the License.&lt;br /&gt;
 */&lt;br /&gt;
package demo.colocated.server;&lt;br /&gt;
import java.util.logging.Logger;&lt;br /&gt;
import org.apache.hello_world_soap_http.Greeter;&lt;br /&gt;
import org.apache.hello_world_soap_http.PingMeFault;&lt;br /&gt;
import org.apache.hello_world_soap_http.types.FaultDetail;&lt;br /&gt;
@javax.jws.WebService(portName = &amp;quot;SoapPort&amp;quot;, serviceName = &amp;quot;SOAPService&amp;quot;,&lt;br /&gt;
                      targetNamespace = &amp;quot;http://apache.org/hello_world_soap_http&amp;quot;,&lt;br /&gt;
                      endpointInterface = &amp;quot;org.apache.hello_world_soap_http.Greeter&amp;quot;)&lt;br /&gt;
public class GreeterImpl implements Greeter {&lt;br /&gt;
    private static final Logger LOG =&lt;br /&gt;
        Logger.getLogger(GreeterImpl.class.getPackage().getName());&lt;br /&gt;
    /* (non-Javadoc)&lt;br /&gt;
     * @see org.apache.hello_world_soap_http.Greeter#greetMe(java.lang.String)&lt;br /&gt;
     */&lt;br /&gt;
    public String greetMe(String me) {&lt;br /&gt;
        LOG.info(&amp;quot;Executing operation greetMe&amp;quot;);&lt;br /&gt;
        System.out.println(&amp;quot;Executing operation greetMe&amp;quot;);&lt;br /&gt;
        System.out.println(&amp;quot;Message received: &amp;quot; + me + &amp;quot;\n&amp;quot;);&lt;br /&gt;
        return &amp;quot;Hello &amp;quot; + me;&lt;br /&gt;
    }&lt;br /&gt;
    /* (non-Javadoc)&lt;br /&gt;
     * @see org.apache.hello_world_soap_http.Greeter#greetMeOneWay(java.lang.String)&lt;br /&gt;
     */&lt;br /&gt;
    public void greetMeOneWay(String me) {&lt;br /&gt;
        LOG.info(&amp;quot;Executing operation greetMeOneWay&amp;quot;);&lt;br /&gt;
        System.out.println(&amp;quot;Executing operation greetMeOneWay\n&amp;quot;);&lt;br /&gt;
        System.out.println(&amp;quot;Hello there &amp;quot; + me);&lt;br /&gt;
    }&lt;br /&gt;
    /* (non-Javadoc)&lt;br /&gt;
     * @see org.apache.hello_world_soap_http.Greeter#sayHi()&lt;br /&gt;
     */&lt;br /&gt;
    public String sayHi() {&lt;br /&gt;
        LOG.info(&amp;quot;Executing operation sayHi&amp;quot;);&lt;br /&gt;
        System.out.println(&amp;quot;Executing operation sayHi\n&amp;quot;);&lt;br /&gt;
        return &amp;quot;Bonjour&amp;quot;;&lt;br /&gt;
    }&lt;br /&gt;
    public void pingMe() throws PingMeFault {&lt;br /&gt;
        FaultDetail faultDetail = new FaultDetail();&lt;br /&gt;
        faultDetail.setMajor((short)2);&lt;br /&gt;
        faultDetail.setMinor((short)1);&lt;br /&gt;
        LOG.info(&amp;quot;Executing operation pingMe, throwing PingMeFault exception&amp;quot;);&lt;br /&gt;
        System.out.println(&amp;quot;Executing operation pingMe, throwing PingMeFault exception\n&amp;quot;);&lt;br /&gt;
        throw new PingMeFault(&amp;quot;PingMeFault raised by server&amp;quot;, faultDetail);&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
///////////////////////////////////////////////////////////////////////////&lt;br /&gt;
/**&lt;br /&gt;
 * Licensed to the Apache Software Foundation (ASF) under one&lt;br /&gt;
 * or more contributor license agreements. See the NOTICE file&lt;br /&gt;
 * distributed with this work for additional information&lt;br /&gt;
 * regarding copyright ownership. The ASF licenses this file&lt;br /&gt;
 * to you under the Apache License, Version 2.0 (the&lt;br /&gt;
 * &amp;quot;License&amp;quot;); you may not use this file except in compliance&lt;br /&gt;
 * with the License. You may obtain a copy of the License at&lt;br /&gt;
 *&lt;br /&gt;
 * http://www.apache.org/licenses/LICENSE-2.0&lt;br /&gt;
 *&lt;br /&gt;
 * Unless required by applicable law or agreed to in writing,&lt;br /&gt;
 * software distributed under the License is distributed on an&lt;br /&gt;
 * &amp;quot;AS IS&amp;quot; BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY&lt;br /&gt;
 * KIND, either express or implied. See the License for the&lt;br /&gt;
 * specific language governing permissions and limitations&lt;br /&gt;
 * under the License.&lt;br /&gt;
 */&lt;br /&gt;
package demo.colocated.server;&lt;br /&gt;
import javax.xml.ws.Endpoint;&lt;br /&gt;
public class Server {&lt;br /&gt;
    protected Server() throws Exception {&lt;br /&gt;
        System.out.println(&amp;quot;Starting Server&amp;quot;);&lt;br /&gt;
        Object implementor = new GreeterImpl();&lt;br /&gt;
        String address = &amp;quot;http://localhost:9000/SoapContext/SoapPort&amp;quot;;&lt;br /&gt;
        Endpoint.publish(address, implementor);&lt;br /&gt;
    }&lt;br /&gt;
    public static void main(String args[]) throws Exception {&lt;br /&gt;
        new Server();&lt;br /&gt;
        System.out.println(&amp;quot;Server ready...&amp;quot;);&lt;br /&gt;
        if (!&amp;quot;inProcess&amp;quot;.equals(args[0])) {&lt;br /&gt;
            Thread.sleep(5 * 60 * 1000);&lt;br /&gt;
            System.out.println(&amp;quot;Server exiting&amp;quot;);&lt;br /&gt;
            System.exit(0);&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
///////////////////////////////////////////////////////////////////////////&lt;br /&gt;
&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot;?&amp;gt;&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
  Licensed to the Apache Software Foundation (ASF) under one&lt;br /&gt;
  or more contributor license agreements. See the NOTICE file&lt;br /&gt;
  distributed with this work for additional information&lt;br /&gt;
  regarding copyright ownership. The ASF licenses this file&lt;br /&gt;
  to you under the Apache License, Version 2.0 (the&lt;br /&gt;
  &amp;quot;License&amp;quot;); you may not use this file except in compliance&lt;br /&gt;
  with the License. You may obtain a copy of the License at&lt;br /&gt;
 &lt;br /&gt;
  http://www.apache.org/licenses/LICENSE-2.0&lt;br /&gt;
 &lt;br /&gt;
  Unless required by applicable law or agreed to in writing,&lt;br /&gt;
  software distributed under the License is distributed on an&lt;br /&gt;
  &amp;quot;AS IS&amp;quot; BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY&lt;br /&gt;
  KIND, either express or implied. See the License for the&lt;br /&gt;
  specific language governing permissions and limitations&lt;br /&gt;
  under the License.&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&amp;lt;wsdl:definitions name=&amp;quot;HelloWorld&amp;quot; &lt;br /&gt;
    targetNamespace=&amp;quot;http://apache.org/hello_world_soap_http&amp;quot; &lt;br /&gt;
    xmlns=&amp;quot;http://schemas.xmlsoap.org/wsdl/&amp;quot; &lt;br /&gt;
    xmlns:soap=&amp;quot;http://schemas.xmlsoap.org/wsdl/soap/&amp;quot; &lt;br /&gt;
    xmlns:tns=&amp;quot;http://apache.org/hello_world_soap_http&amp;quot;&lt;br /&gt;
    xmlns:x1=&amp;quot;http://apache.org/hello_world_soap_http/types&amp;quot;&lt;br /&gt;
    xmlns:wsdl=&amp;quot;http://schemas.xmlsoap.org/wsdl/&amp;quot; &lt;br /&gt;
    xmlns:xsd=&amp;quot;http://www.w3.org/2001/XMLSchema&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;wsdl:types&amp;gt;&lt;br /&gt;
        &amp;lt;schema targetNamespace=&amp;quot;http://apache.org/hello_world_soap_http/types&amp;quot; &lt;br /&gt;
            xmlns=&amp;quot;http://www.w3.org/2001/XMLSchema&amp;quot;&lt;br /&gt;
        xmlns:tns=&amp;quot;http://apache.org/hello_world_soap_http/types&amp;quot;&lt;br /&gt;
            elementFormDefault=&amp;quot;qualified&amp;quot;&amp;gt;&lt;br /&gt;
            &amp;lt;element name=&amp;quot;sayHi&amp;quot;&amp;gt;&lt;br /&gt;
                &amp;lt;complexType/&amp;gt;&lt;br /&gt;
            &amp;lt;/element&amp;gt;&lt;br /&gt;
            &amp;lt;element name=&amp;quot;sayHiResponse&amp;quot;&amp;gt;&lt;br /&gt;
                &amp;lt;complexType&amp;gt;&lt;br /&gt;
                    &amp;lt;sequence&amp;gt;&lt;br /&gt;
                        &amp;lt;element name=&amp;quot;responseType&amp;quot; type=&amp;quot;string&amp;quot;/&amp;gt;&lt;br /&gt;
                    &amp;lt;/sequence&amp;gt;&lt;br /&gt;
                &amp;lt;/complexType&amp;gt;&lt;br /&gt;
            &amp;lt;/element&amp;gt;&lt;br /&gt;
            &amp;lt;element name=&amp;quot;greetMe&amp;quot;&amp;gt;&lt;br /&gt;
                &amp;lt;complexType&amp;gt;&lt;br /&gt;
                    &amp;lt;sequence&amp;gt;&lt;br /&gt;
                        &amp;lt;element name=&amp;quot;requestType&amp;quot; type=&amp;quot;string&amp;quot;/&amp;gt;&lt;br /&gt;
                    &amp;lt;/sequence&amp;gt;&lt;br /&gt;
                &amp;lt;/complexType&amp;gt;&lt;br /&gt;
            &amp;lt;/element&amp;gt;&lt;br /&gt;
            &amp;lt;element name=&amp;quot;greetMeResponse&amp;quot;&amp;gt;&lt;br /&gt;
                &amp;lt;complexType&amp;gt;&lt;br /&gt;
                    &amp;lt;sequence&amp;gt;&lt;br /&gt;
                        &amp;lt;element name=&amp;quot;responseType&amp;quot; type=&amp;quot;string&amp;quot;/&amp;gt;&lt;br /&gt;
                    &amp;lt;/sequence&amp;gt;&lt;br /&gt;
                &amp;lt;/complexType&amp;gt;&lt;br /&gt;
            &amp;lt;/element&amp;gt;&lt;br /&gt;
            &amp;lt;element name=&amp;quot;greetMeOneWay&amp;quot;&amp;gt;&lt;br /&gt;
                &amp;lt;complexType&amp;gt;&lt;br /&gt;
                    &amp;lt;sequence&amp;gt;&lt;br /&gt;
                        &amp;lt;element name=&amp;quot;requestType&amp;quot; type=&amp;quot;string&amp;quot;/&amp;gt;&lt;br /&gt;
                    &amp;lt;/sequence&amp;gt;&lt;br /&gt;
                &amp;lt;/complexType&amp;gt;&lt;br /&gt;
            &amp;lt;/element&amp;gt;&lt;br /&gt;
            &amp;lt;element name=&amp;quot;pingMe&amp;quot;&amp;gt;&lt;br /&gt;
                &amp;lt;complexType/&amp;gt;&lt;br /&gt;
            &amp;lt;/element&amp;gt;&lt;br /&gt;
            &amp;lt;element name=&amp;quot;pingMeResponse&amp;quot;&amp;gt;&lt;br /&gt;
                &amp;lt;complexType/&amp;gt;&lt;br /&gt;
            &amp;lt;/element&amp;gt;&lt;br /&gt;
            &amp;lt;element name=&amp;quot;faultDetail&amp;quot;&amp;gt;&lt;br /&gt;
                &amp;lt;complexType&amp;gt;&lt;br /&gt;
                    &amp;lt;sequence&amp;gt;&lt;br /&gt;
                        &amp;lt;element name=&amp;quot;minor&amp;quot; type=&amp;quot;short&amp;quot;/&amp;gt;&lt;br /&gt;
                        &amp;lt;element name=&amp;quot;major&amp;quot; type=&amp;quot;short&amp;quot;/&amp;gt;&lt;br /&gt;
                    &amp;lt;/sequence&amp;gt;&lt;br /&gt;
                &amp;lt;/complexType&amp;gt;&lt;br /&gt;
            &amp;lt;/element&amp;gt;&lt;br /&gt;
        &amp;lt;/schema&amp;gt;&lt;br /&gt;
    &amp;lt;/wsdl:types&amp;gt;&lt;br /&gt;
    &amp;lt;wsdl:message name=&amp;quot;sayHiRequest&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;wsdl:part element=&amp;quot;x1:sayHi&amp;quot; name=&amp;quot;in&amp;quot;/&amp;gt;&lt;br /&gt;
    &amp;lt;/wsdl:message&amp;gt;&lt;br /&gt;
    &amp;lt;wsdl:message name=&amp;quot;sayHiResponse&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;wsdl:part element=&amp;quot;x1:sayHiResponse&amp;quot; name=&amp;quot;out&amp;quot;/&amp;gt;&lt;br /&gt;
    &amp;lt;/wsdl:message&amp;gt;&lt;br /&gt;
    &amp;lt;wsdl:message name=&amp;quot;greetMeRequest&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;wsdl:part element=&amp;quot;x1:greetMe&amp;quot; name=&amp;quot;in&amp;quot;/&amp;gt;&lt;br /&gt;
    &amp;lt;/wsdl:message&amp;gt;&lt;br /&gt;
    &amp;lt;wsdl:message name=&amp;quot;greetMeResponse&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;wsdl:part element=&amp;quot;x1:greetMeResponse&amp;quot; name=&amp;quot;out&amp;quot;/&amp;gt;&lt;br /&gt;
    &amp;lt;/wsdl:message&amp;gt;&lt;br /&gt;
    &amp;lt;wsdl:message name=&amp;quot;greetMeOneWayRequest&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;wsdl:part element=&amp;quot;x1:greetMeOneWay&amp;quot; name=&amp;quot;in&amp;quot;/&amp;gt;&lt;br /&gt;
    &amp;lt;/wsdl:message&amp;gt;&lt;br /&gt;
    &amp;lt;wsdl:message name=&amp;quot;pingMeRequest&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;wsdl:part name=&amp;quot;in&amp;quot; element=&amp;quot;x1:pingMe&amp;quot;/&amp;gt;&lt;br /&gt;
    &amp;lt;/wsdl:message&amp;gt;&lt;br /&gt;
    &amp;lt;wsdl:message name=&amp;quot;pingMeResponse&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;wsdl:part name=&amp;quot;out&amp;quot; element=&amp;quot;x1:pingMeResponse&amp;quot;/&amp;gt;&lt;br /&gt;
    &amp;lt;/wsdl:message&amp;gt;     &lt;br /&gt;
    &amp;lt;wsdl:message name=&amp;quot;pingMeFault&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;wsdl:part name=&amp;quot;faultDetail&amp;quot; element=&amp;quot;x1:faultDetail&amp;quot;/&amp;gt;&lt;br /&gt;
    &amp;lt;/wsdl:message&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
    &amp;lt;wsdl:portType name=&amp;quot;Greeter&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;wsdl:operation name=&amp;quot;sayHi&amp;quot;&amp;gt;&lt;br /&gt;
            &amp;lt;wsdl:input message=&amp;quot;tns:sayHiRequest&amp;quot; name=&amp;quot;sayHiRequest&amp;quot;/&amp;gt;&lt;br /&gt;
            &amp;lt;wsdl:output message=&amp;quot;tns:sayHiResponse&amp;quot; name=&amp;quot;sayHiResponse&amp;quot;/&amp;gt;&lt;br /&gt;
        &amp;lt;/wsdl:operation&amp;gt;&lt;br /&gt;
        &lt;br /&gt;
        &amp;lt;wsdl:operation name=&amp;quot;greetMe&amp;quot;&amp;gt;&lt;br /&gt;
            &amp;lt;wsdl:input message=&amp;quot;tns:greetMeRequest&amp;quot; name=&amp;quot;greetMeRequest&amp;quot;/&amp;gt;&lt;br /&gt;
            &amp;lt;wsdl:output message=&amp;quot;tns:greetMeResponse&amp;quot; name=&amp;quot;greetMeResponse&amp;quot;/&amp;gt;&lt;br /&gt;
        &amp;lt;/wsdl:operation&amp;gt;&lt;br /&gt;
        &lt;br /&gt;
        &amp;lt;wsdl:operation name=&amp;quot;greetMeOneWay&amp;quot;&amp;gt;&lt;br /&gt;
            &amp;lt;wsdl:input message=&amp;quot;tns:greetMeOneWayRequest&amp;quot; name=&amp;quot;greetMeOneWayRequest&amp;quot;/&amp;gt;&lt;br /&gt;
        &amp;lt;/wsdl:operation&amp;gt;&lt;br /&gt;
        &amp;lt;wsdl:operation name=&amp;quot;pingMe&amp;quot;&amp;gt;&lt;br /&gt;
            &amp;lt;wsdl:input name=&amp;quot;pingMeRequest&amp;quot; message=&amp;quot;tns:pingMeRequest&amp;quot;/&amp;gt;&lt;br /&gt;
            &amp;lt;wsdl:output name=&amp;quot;pingMeResponse&amp;quot; message=&amp;quot;tns:pingMeResponse&amp;quot;/&amp;gt;&lt;br /&gt;
            &amp;lt;wsdl:fault name=&amp;quot;pingMeFault&amp;quot; message=&amp;quot;tns:pingMeFault&amp;quot;/&amp;gt;&lt;br /&gt;
        &amp;lt;/wsdl:operation&amp;gt; &lt;br /&gt;
    &amp;lt;/wsdl:portType&amp;gt;&lt;br /&gt;
    &amp;lt;wsdl:binding name=&amp;quot;Greeter_SOAPBinding&amp;quot; type=&amp;quot;tns:Greeter&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;soap:binding style=&amp;quot;document&amp;quot; transport=&amp;quot;http://schemas.xmlsoap.org/soap/http&amp;quot;/&amp;gt;&lt;br /&gt;
        &lt;br /&gt;
        &amp;lt;wsdl:operation name=&amp;quot;sayHi&amp;quot;&amp;gt;&lt;br /&gt;
            &amp;lt;soap:operation soapAction=&amp;quot;&amp;quot; style=&amp;quot;document&amp;quot;/&amp;gt;&lt;br /&gt;
            &amp;lt;wsdl:input name=&amp;quot;sayHiRequest&amp;quot;&amp;gt;&lt;br /&gt;
                &amp;lt;soap:body use=&amp;quot;literal&amp;quot;/&amp;gt;&lt;br /&gt;
            &amp;lt;/wsdl:input&amp;gt;&lt;br /&gt;
            &amp;lt;wsdl:output name=&amp;quot;sayHiResponse&amp;quot;&amp;gt;&lt;br /&gt;
                &amp;lt;soap:body use=&amp;quot;literal&amp;quot;/&amp;gt;&lt;br /&gt;
            &amp;lt;/wsdl:output&amp;gt;&lt;br /&gt;
        &amp;lt;/wsdl:operation&amp;gt;&lt;br /&gt;
        &lt;br /&gt;
        &amp;lt;wsdl:operation name=&amp;quot;greetMe&amp;quot;&amp;gt;&lt;br /&gt;
            &amp;lt;soap:operation soapAction=&amp;quot;&amp;quot; style=&amp;quot;document&amp;quot;/&amp;gt;&lt;br /&gt;
            &amp;lt;wsdl:input name=&amp;quot;greetMeRequest&amp;quot;&amp;gt;&lt;br /&gt;
                &amp;lt;soap:body use=&amp;quot;literal&amp;quot;/&amp;gt;&lt;br /&gt;
            &amp;lt;/wsdl:input&amp;gt;&lt;br /&gt;
            &amp;lt;wsdl:output name=&amp;quot;greetMeResponse&amp;quot;&amp;gt;&lt;br /&gt;
                &amp;lt;soap:body use=&amp;quot;literal&amp;quot;/&amp;gt;&lt;br /&gt;
            &amp;lt;/wsdl:output&amp;gt;&lt;br /&gt;
        &amp;lt;/wsdl:operation&amp;gt;&lt;br /&gt;
        &lt;br /&gt;
        &amp;lt;wsdl:operation name=&amp;quot;greetMeOneWay&amp;quot;&amp;gt;&lt;br /&gt;
            &amp;lt;soap:operation soapAction=&amp;quot;&amp;quot; style=&amp;quot;document&amp;quot;/&amp;gt;&lt;br /&gt;
            &amp;lt;wsdl:input name=&amp;quot;greetMeOneWayRequest&amp;quot;&amp;gt;&lt;br /&gt;
                &amp;lt;soap:body use=&amp;quot;literal&amp;quot;/&amp;gt;&lt;br /&gt;
            &amp;lt;/wsdl:input&amp;gt;&lt;br /&gt;
        &amp;lt;/wsdl:operation&amp;gt;&lt;br /&gt;
        &amp;lt;wsdl:operation name=&amp;quot;pingMe&amp;quot;&amp;gt;&lt;br /&gt;
            &amp;lt;soap:operation style=&amp;quot;document&amp;quot;/&amp;gt;&lt;br /&gt;
            &amp;lt;wsdl:input&amp;gt;&lt;br /&gt;
                &amp;lt;soap:body use=&amp;quot;literal&amp;quot;/&amp;gt;&lt;br /&gt;
            &amp;lt;/wsdl:input&amp;gt;&lt;br /&gt;
            &amp;lt;wsdl:output&amp;gt;&lt;br /&gt;
                &amp;lt;soap:body use=&amp;quot;literal&amp;quot;/&amp;gt;&lt;br /&gt;
            &amp;lt;/wsdl:output&amp;gt;&lt;br /&gt;
            &amp;lt;wsdl:fault name=&amp;quot;pingMeFault&amp;quot;&amp;gt;&lt;br /&gt;
                &amp;lt;soap:fault name=&amp;quot;pingMeFault&amp;quot; use=&amp;quot;literal&amp;quot;/&amp;gt;&lt;br /&gt;
            &amp;lt;/wsdl:fault&amp;gt;&lt;br /&gt;
        &amp;lt;/wsdl:operation&amp;gt;&lt;br /&gt;
        &lt;br /&gt;
    &amp;lt;/wsdl:binding&amp;gt;&lt;br /&gt;
    &amp;lt;wsdl:service name=&amp;quot;SOAPService&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;wsdl:port binding=&amp;quot;tns:Greeter_SOAPBinding&amp;quot; name=&amp;quot;SoapPort&amp;quot;&amp;gt;&lt;br /&gt;
            &amp;lt;soap:address location=&amp;quot;http://localhost:9000/SoapContext/SoapPort&amp;quot;/&amp;gt;&lt;br /&gt;
        &amp;lt;/wsdl:port&amp;gt;&lt;br /&gt;
    &amp;lt;/wsdl:service&amp;gt;&lt;br /&gt;
&amp;lt;/wsdl:definitions&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
        &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Hello World Dispatch Demo using Document/Literal Style ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
/**&lt;br /&gt;
 * Licensed to the Apache Software Foundation (ASF) under one&lt;br /&gt;
 * or more contributor license agreements. See the NOTICE file&lt;br /&gt;
 * distributed with this work for additional information&lt;br /&gt;
 * regarding copyright ownership. The ASF licenses this file&lt;br /&gt;
 * to you under the Apache License, Version 2.0 (the&lt;br /&gt;
 * &amp;quot;License&amp;quot;); you may not use this file except in compliance&lt;br /&gt;
 * with the License. You may obtain a copy of the License at&lt;br /&gt;
 *&lt;br /&gt;
 * http://www.apache.org/licenses/LICENSE-2.0&lt;br /&gt;
 *&lt;br /&gt;
 * Unless required by applicable law or agreed to in writing,&lt;br /&gt;
 * software distributed under the License is distributed on an&lt;br /&gt;
 * &amp;quot;AS IS&amp;quot; BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY&lt;br /&gt;
 * KIND, either express or implied. See the License for the&lt;br /&gt;
 * specific language governing permissions and limitations&lt;br /&gt;
 * under the License.&lt;br /&gt;
 */&lt;br /&gt;
&lt;br /&gt;
Hello World Dispatch Demo using Document/Literal Style&lt;br /&gt;
======================================================&lt;br /&gt;
The demo demonstrates the use of JAX-WS Dispatch and Provider interface.&lt;br /&gt;
The client side Dispatch instance invokes upon an endpoint using a JAX-WS &lt;br /&gt;
Provider implementor. There are three differnt invocations from the client. &lt;br /&gt;
The first uses the SOAPMessage data in MESSAGE mode. The second uses the DOMSource &lt;br /&gt;
data in MESSAGE mode. The third uses the DOMSource in PAYLOAD mode. The three &lt;br /&gt;
different messages are constructed by reading in the XML files found in the &lt;br /&gt;
src/demo/hwDispatch/client directory.&lt;br /&gt;
Please review the README in the samples directory before&lt;br /&gt;
continuing.&lt;br /&gt;
&lt;br /&gt;
Prerequisite&lt;br /&gt;
------------&lt;br /&gt;
If your environment already includes cxf-manifest-incubator.jar on the&lt;br /&gt;
CLASSPATH, and the JDK and ant bin directories on the PATH&lt;br /&gt;
it is not necessary to set the environment as described in&lt;br /&gt;
the samples directory&amp;quot;s README.  If your environment is not&lt;br /&gt;
properly configured, or if you are planning on using wsdl2java,&lt;br /&gt;
javac, and java to build and run the demos, you must set the&lt;br /&gt;
environment.&lt;br /&gt;
&lt;br /&gt;
Building and running the demo using ant&lt;br /&gt;
---------------------------------------&lt;br /&gt;
From the samples/dispatch_provider directory, the ant build script&lt;br /&gt;
can be used to build and run the demo.&lt;br /&gt;
Using either UNIX or Windows:&lt;br /&gt;
  ant build&lt;br /&gt;
  ant server&lt;br /&gt;
  ant client&lt;br /&gt;
    &lt;br /&gt;
To remove the code generated from the WSDL file and the .class&lt;br /&gt;
files, run:&lt;br /&gt;
  ant clean&lt;br /&gt;
&lt;br /&gt;
Building the demo using wsdl2java and javac&lt;br /&gt;
-------------------------------------------&lt;br /&gt;
From the samples/dispatch_provider directory, first create the target&lt;br /&gt;
directory build/classes and then generate code from the WSDL file.&lt;br /&gt;
For UNIX:&lt;br /&gt;
  mkdir -p build/classes&lt;br /&gt;
  wsdl2java -d build/classes -compile ./wsdl/hello_world.wsdl&lt;br /&gt;
For Windows:&lt;br /&gt;
  mkdir build\classes&lt;br /&gt;
    Must use back slashes.&lt;br /&gt;
  wsdl2java -d build\classes -compile .\wsdl\hello_world.wsdl&lt;br /&gt;
    May use either forward or back slashes.&lt;br /&gt;
Now compile the provided client and server applications with the commands:&lt;br /&gt;
For UNIX:  &lt;br /&gt;
  &lt;br /&gt;
  export CLASSPATH=$CLASSPATH:$CXF_HOME/lib/cxf-manifest-incubator.jar:./build/classes&lt;br /&gt;
  javac -d build/classes src/demo/hwDispatch/client/*.java&lt;br /&gt;
  javac -d build/classes src/demo/hwDispatch/server/*.java&lt;br /&gt;
For Windows:&lt;br /&gt;
  set classpath=%classpath%;%CXF_HOME%\lib\cxf-manifest-incubator.jar;.\build\classes&lt;br /&gt;
  javac -d build\classes src\demo\hwDispatch\client\*.java&lt;br /&gt;
  javac -d build\classes src\demo\hwDispatch\server\*.java&lt;br /&gt;
  &lt;br /&gt;
Finally, copy resource files into the build/classes directory with the commands:&lt;br /&gt;
For UNIX:    &lt;br /&gt;
  cp ./src/demo/hwDispatch/client/*.xml ./build/classes/demo/hwDispatch/client&lt;br /&gt;
  cp ./src/demo/hwDispatch/server/*.xml ./build/classes/demo/hwDispatch/server&lt;br /&gt;
For Windows:&lt;br /&gt;
  copy src\demo\hwDispatch\client\*.xml build\classes\demo\hwDispatch\client&lt;br /&gt;
  copy src\demo\hwDispatch\server\*.xml build\classes\demo\hwDispatch\server&lt;br /&gt;
&lt;br /&gt;
Running the demo using java&lt;br /&gt;
---------------------------&lt;br /&gt;
From the samples/hello_world_dispatch directory run the commands, entered on a&lt;br /&gt;
single command line:&lt;br /&gt;
For UNIX (must use forward slashes):&lt;br /&gt;
    java -Djava.util.logging.config.file=$CXF_HOME/etc/logging.properties&lt;br /&gt;
         demo.hwDispatch.server.Server &amp;amp;&lt;br /&gt;
    java -Djava.util.logging.config.file=$CXF_HOME/etc/logging.properties&lt;br /&gt;
         demo.hwDispatch.client.Client ./wsdl/hello_world.wsdl&lt;br /&gt;
The server process starts in the background.  After running the client,&lt;br /&gt;
use the kill command to terminate the server process.&lt;br /&gt;
For Windows (may use either forward or back slashes):&lt;br /&gt;
  start &lt;br /&gt;
    java -Djava.util.logging.config.file=%CXF_HOME%\etc\logging.properties&lt;br /&gt;
         demo.hwDispatch.server.Server&lt;br /&gt;
    java -Djava.util.logging.config.file=%CXF_HOME%\etc\logging.properties&lt;br /&gt;
       demo.hwDispatch.client.Client .\wsdl\hello_world.wsdl&lt;br /&gt;
A new command windows opens for the server process.  After running the&lt;br /&gt;
client, terminate the server process by issuing Ctrl-C in its command window.&lt;br /&gt;
To remove the code generated from the WSDL file and the .class&lt;br /&gt;
files, either delete the build directory and its contents or run:&lt;br /&gt;
  ant clean&lt;br /&gt;
        &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== The use of Apache CXF&amp;quot;s xml binding: how xml binding works with the doc-lit bare style ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
Hello World Demo using BARE Style in XML Binding&lt;br /&gt;
=============================================&lt;br /&gt;
This demo illustrates the use of Apache CXF&amp;quot;s xml binding. This &lt;br /&gt;
specific demo shows you how xml binding works with the &lt;br /&gt;
doc-lit bare style&lt;br /&gt;
Please review the README in the samples directory before&lt;br /&gt;
continuing.&lt;br /&gt;
&lt;br /&gt;
Prerequisite&lt;br /&gt;
------------&lt;br /&gt;
If your environment already includes cxf-manifest-incubator.jar on the&lt;br /&gt;
CLASSPATH, and the JDK and ant bin directories on the PATH&lt;br /&gt;
it is not necessary to set the environment as described in&lt;br /&gt;
the samples directory&amp;quot;s README.  If your environment is not&lt;br /&gt;
properly configured, or if you are planning on using wsdl2java,&lt;br /&gt;
javac, and java to build and run the demos, you must set the&lt;br /&gt;
environment.&lt;br /&gt;
&lt;br /&gt;
Building and running the demo using ant&lt;br /&gt;
---------------------------------------&lt;br /&gt;
From the samples/hello_world_xml_bare directory, the ant build script&lt;br /&gt;
can be used to build and run the demo.&lt;br /&gt;
Using either UNIX or Windows:&lt;br /&gt;
  ant build&lt;br /&gt;
  ant server&lt;br /&gt;
  ant client&lt;br /&gt;
    &lt;br /&gt;
To remove the code generated from the WSDL file and the .class&lt;br /&gt;
files, run:&lt;br /&gt;
  ant clean&lt;br /&gt;
&lt;br /&gt;
Building the demo using wsdl2java and javac&lt;br /&gt;
-------------------------------------------&lt;br /&gt;
From the samples/hello_world_xml_bare directory, first create the target&lt;br /&gt;
directory build/classes and then generate code from the WSDL file.&lt;br /&gt;
For UNIX:&lt;br /&gt;
  mkdir -p build/classes&lt;br /&gt;
  wsdl2java -d build/classes -compile ./wsdl/hello_world.wsdl&lt;br /&gt;
For Windows:&lt;br /&gt;
  mkdir build\classes&lt;br /&gt;
    Must use back slashes.&lt;br /&gt;
  wsdl2java -d build\classes -compile .\wsdl\hello_world.wsdl&lt;br /&gt;
    May use either forward or back slashes.&lt;br /&gt;
Now compile the provided client and server applications with the commands:&lt;br /&gt;
For UNIX:  &lt;br /&gt;
  &lt;br /&gt;
  export CLASSPATH=$CLASSPATH:$CXF_HOME/lib/cxf-manifest-incubator.jar:./build/classes&lt;br /&gt;
  javac -d build/classes src/demo/hw/client/*.java&lt;br /&gt;
  javac -d build/classes src/demo/hw/server/*.java&lt;br /&gt;
For Windows:&lt;br /&gt;
  set classpath=%classpath%;%CXF_HOME%\lib\cxf-manifest-incubator.jar;.\build\classes&lt;br /&gt;
  javac -d build\classes src\demo\hw\client\*.java&lt;br /&gt;
  javac -d build\classes src\demo\hw\server\*.java&lt;br /&gt;
&lt;br /&gt;
Running the demo using java&lt;br /&gt;
---------------------------&lt;br /&gt;
From the samples/hello_world_xml_bare directory run the following &lt;br /&gt;
commands. They are entered on a single command line.&lt;br /&gt;
For UNIX (must use forward slashes):&lt;br /&gt;
    java -Djava.util.logging.config.file=$CXF_HOME/etc/logging.properties&lt;br /&gt;
         demo.hw.server.Server &amp;amp;&lt;br /&gt;
    java -Djava.util.logging.config.file=$CXF_HOME/etc/logging.properties&lt;br /&gt;
         demo.hw.client.Client ./wsdl/hello_world.wsdl&lt;br /&gt;
The server process starts in the background.  After running the client,&lt;br /&gt;
use the kill command to terminate the server process.&lt;br /&gt;
For Windows (may use either forward or back slashes):&lt;br /&gt;
  start &lt;br /&gt;
    java -Djava.util.logging.config.file=%CXF_HOME%\etc\logging.properties&lt;br /&gt;
         demo.hw.server.Server&lt;br /&gt;
    java -Djava.util.logging.config.file=%CXF_HOME%\etc\logging.properties&lt;br /&gt;
       demo.hw.client.Client .\wsdl\hello_world.wsdl&lt;br /&gt;
A new command windows opens for the server process.  After running the&lt;br /&gt;
client, terminate the server process by issuing Ctrl-C in its command window.&lt;br /&gt;
To remove the code generated from the WSDL file and the .class&lt;br /&gt;
files, either delete the build directory and its contents or run:&lt;br /&gt;
  ant clean&lt;br /&gt;
&lt;br /&gt;
Building and running the demo in a servlet container&lt;br /&gt;
----------------------------------------------------&lt;br /&gt;
From the samples/hello_world_xml_bare directory, the ant build script&lt;br /&gt;
can be used to create the war file that is deployed into the&lt;br /&gt;
servlet container.&lt;br /&gt;
Build the war file with the command:&lt;br /&gt;
  ant war&lt;br /&gt;
    &lt;br /&gt;
Preparing deploy to APACHE TOMCAT&lt;br /&gt;
* set CATALINA_HOME environment to your TOMCAT home directory&lt;br /&gt;
    &lt;br /&gt;
Deploy the application into APACHE TOMCAT with the commond:&lt;br /&gt;
[NOTE] This step will check if the cxf jars present in Tomcat, &lt;br /&gt;
       if not, it will automatically copy all the jars into CATALINA_HOME/shared/lib&lt;br /&gt;
  &lt;br /&gt;
  ant deploy -Dtomcat=true&lt;br /&gt;
The servlet container will extract the war and deploy the application.&lt;br /&gt;
&lt;br /&gt;
Using ant, run the client application with the command:&lt;br /&gt;
  ant client-servlet -Dbase.url=http://localhost:#&lt;br /&gt;
Where # is the TCP/IP port used by the servlet container,&lt;br /&gt;
e.g., 8080.&lt;br /&gt;
Or&lt;br /&gt;
  ant client-servlet -Dhost=localhost -Dport=8080&lt;br /&gt;
You can ignore the -Dhost and -Dport if your tomcat setup is same, i.e ant client-servlet&lt;br /&gt;
Using java, run the client application with the command:&lt;br /&gt;
  For UNIX:&lt;br /&gt;
    &lt;br /&gt;
    java -Djava.util.logging.config.file=$CXF_HOME/etc/logging.properties&lt;br /&gt;
         demo.hw.client.Client http://localhost:#/helloworld/services/hello_world?wsdl&lt;br /&gt;
  For Windows:&lt;br /&gt;
    java -Djava.util.logging.config.file=%CXF_HOME%\etc\logging.properties&lt;br /&gt;
       demo.hw.client.Client http://localhost:#/helloworld/services/hello_world?wsdl&lt;br /&gt;
Where # is the TCP/IP port used by the servlet container,&lt;br /&gt;
e.g., 8080.&lt;br /&gt;
Undeploy the application from the APACHE TOMCAT with the command:&lt;br /&gt;
   ant undeploy -Dtomcat=true&lt;br /&gt;
&lt;br /&gt;
Running demo with HTTP GET&lt;br /&gt;
----------------------------------------------------&lt;br /&gt;
APACHE CXF support HTTP GET to invoke the service, instead of running &lt;br /&gt;
   ant client&lt;br /&gt;
you can use &lt;br /&gt;
   ant client.get &lt;br /&gt;
to invoke the service with simple HttpURLConnection, or you can even&lt;br /&gt;
use your favoriate browser to get the results back.&lt;br /&gt;
&lt;br /&gt;
///////////////////////////////////////////////////////////////////&lt;br /&gt;
/**&lt;br /&gt;
 * Licensed to the Apache Software Foundation (ASF) under one&lt;br /&gt;
 * or more contributor license agreements. See the NOTICE file&lt;br /&gt;
 * distributed with this work for additional information&lt;br /&gt;
 * regarding copyright ownership. The ASF licenses this file&lt;br /&gt;
 * to you under the Apache License, Version 2.0 (the&lt;br /&gt;
 * &amp;quot;License&amp;quot;); you may not use this file except in compliance&lt;br /&gt;
 * with the License. You may obtain a copy of the License at&lt;br /&gt;
 *&lt;br /&gt;
 * http://www.apache.org/licenses/LICENSE-2.0&lt;br /&gt;
 *&lt;br /&gt;
 * Unless required by applicable law or agreed to in writing,&lt;br /&gt;
 * software distributed under the License is distributed on an&lt;br /&gt;
 * &amp;quot;AS IS&amp;quot; BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY&lt;br /&gt;
 * KIND, either express or implied. See the License for the&lt;br /&gt;
 * specific language governing permissions and limitations&lt;br /&gt;
 * under the License.&lt;br /&gt;
 */&lt;br /&gt;
package demo.hw.client;&lt;br /&gt;
import java.io.File;&lt;br /&gt;
import java.net.URL;&lt;br /&gt;
import javax.xml.namespace.QName;&lt;br /&gt;
import org.apache.hello_world_xml_http.bare.Greeter;&lt;br /&gt;
import org.apache.hello_world_xml_http.bare.XMLService;&lt;br /&gt;
import org.apache.hello_world_xml_http.bare.types.MyComplexStructType;&lt;br /&gt;
// import org.apache.hello_world_xml_http.bare.PingMeFault;&lt;br /&gt;
public final class Client {&lt;br /&gt;
    private static final QName SERVICE_NAME = new QName(&amp;quot;http://apache.org/hello_world_xml_http/bare&amp;quot;,&lt;br /&gt;
            &amp;quot;XMLService&amp;quot;);&lt;br /&gt;
    private static final QName PORT_NAME = &lt;br /&gt;
        new QName(&amp;quot;http://apache.org/hello_world_xml_http/bare&amp;quot;, &amp;quot;XMLPort&amp;quot;);&lt;br /&gt;
    private Client() {&lt;br /&gt;
    }&lt;br /&gt;
    public static void main(String args[]) throws Exception {&lt;br /&gt;
        if (args.length == 0) {&lt;br /&gt;
            System.out.println(&amp;quot;please specify wsdl&amp;quot;);&lt;br /&gt;
            System.exit(1);&lt;br /&gt;
        }&lt;br /&gt;
        URL wsdlURL;&lt;br /&gt;
        File wsdlFile = new File(args[0]);&lt;br /&gt;
        if (wsdlFile.exists()) {&lt;br /&gt;
            wsdlURL = wsdlFile.toURL();&lt;br /&gt;
        } else {&lt;br /&gt;
            wsdlURL = new URL(args[0]);&lt;br /&gt;
        }&lt;br /&gt;
        System.out.println(wsdlURL);&lt;br /&gt;
        XMLService service = new XMLService(wsdlURL, SERVICE_NAME);&lt;br /&gt;
        Greeter greeter = (Greeter) service.getPort(PORT_NAME, Greeter.class);&lt;br /&gt;
        System.out.println(&amp;quot;Invoking sayHi...&amp;quot;);&lt;br /&gt;
        System.out.println(&amp;quot;server responded with: &amp;quot; + greeter.sayHi());&lt;br /&gt;
        System.out.println();&lt;br /&gt;
        System.out.println(&amp;quot;Invoking greetMe...&amp;quot;);&lt;br /&gt;
        System.out.println(&amp;quot;server responded with: &amp;quot; + greeter.greetMe(System.getProperty(&amp;quot;user.name&amp;quot;)));&lt;br /&gt;
        System.out.println();&lt;br /&gt;
        MyComplexStructType argument = new MyComplexStructType();&lt;br /&gt;
        MyComplexStructType retVal = null;&lt;br /&gt;
        String str1 = &amp;quot;this is element 1&amp;quot;;&lt;br /&gt;
        String str2 = &amp;quot;this is element 2&amp;quot;;&lt;br /&gt;
        int int1 = 42;&lt;br /&gt;
        argument.setElem1(str1);&lt;br /&gt;
        argument.setElem2(str2);&lt;br /&gt;
        argument.setElem3(int1);&lt;br /&gt;
        System.out.println(&amp;quot;Invoking sendReceiveData...&amp;quot;);&lt;br /&gt;
        retVal = greeter.sendReceiveData(argument);&lt;br /&gt;
        System.out.println(&amp;quot;Response from sendReceiveData operation :&amp;quot;);&lt;br /&gt;
        System.out.println(&amp;quot;Element-1 : &amp;quot; + retVal.getElem1());&lt;br /&gt;
        System.out.println(&amp;quot;Element-2 : &amp;quot; + retVal.getElem2());&lt;br /&gt;
        System.out.println(&amp;quot;Element-3 : &amp;quot; + retVal.getElem3());&lt;br /&gt;
        System.out.println();&lt;br /&gt;
        /*&lt;br /&gt;
         * try { System.out.println(&amp;quot;Invoking pingMe, expecting exception...&amp;quot;);&lt;br /&gt;
         * port.pingMe(); } catch (PingMeFault ex) {&lt;br /&gt;
         * System.out.println(&amp;quot;Expected exception: PingMeFault has occurred: &amp;quot; +&lt;br /&gt;
         * ex.getMessage()); }&lt;br /&gt;
         */&lt;br /&gt;
        System.exit(0);&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
///////////////////////////////////////////////////////////////////&lt;br /&gt;
/**&lt;br /&gt;
 * Licensed to the Apache Software Foundation (ASF) under one&lt;br /&gt;
 * or more contributor license agreements. See the NOTICE file&lt;br /&gt;
 * distributed with this work for additional information&lt;br /&gt;
 * regarding copyright ownership. The ASF licenses this file&lt;br /&gt;
 * to you under the Apache License, Version 2.0 (the&lt;br /&gt;
 * &amp;quot;License&amp;quot;); you may not use this file except in compliance&lt;br /&gt;
 * with the License. You may obtain a copy of the License at&lt;br /&gt;
 *&lt;br /&gt;
 * http://www.apache.org/licenses/LICENSE-2.0&lt;br /&gt;
 *&lt;br /&gt;
 * Unless required by applicable law or agreed to in writing,&lt;br /&gt;
 * software distributed under the License is distributed on an&lt;br /&gt;
 * &amp;quot;AS IS&amp;quot; BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY&lt;br /&gt;
 * KIND, either express or implied. See the License for the&lt;br /&gt;
 * specific language governing permissions and limitations&lt;br /&gt;
 * under the License.&lt;br /&gt;
 */&lt;br /&gt;
package demo.hw.client;&lt;br /&gt;
import java.io.ByteArrayOutputStream;&lt;br /&gt;
import java.io.InputStream;&lt;br /&gt;
import java.net.HttpURLConnection;&lt;br /&gt;
import java.net.URL;&lt;br /&gt;
import java.util.Properties;&lt;br /&gt;
import javax.xml.transform.OutputKeys;&lt;br /&gt;
import javax.xml.transform.Source;&lt;br /&gt;
import javax.xml.transform.Transformer;&lt;br /&gt;
import javax.xml.transform.TransformerFactory;&lt;br /&gt;
import javax.xml.transform.stream.StreamResult;&lt;br /&gt;
import javax.xml.transform.stream.StreamSource;&lt;br /&gt;
public final class Get {&lt;br /&gt;
    private Get() {&lt;br /&gt;
    } &lt;br /&gt;
    public static void main(String args[]) throws Exception {&lt;br /&gt;
        // Sent HTTP GET request to invoke sayHi&lt;br /&gt;
        String target = &amp;quot;http://localhost:9000/XMLService/XMLPort/sayHi&amp;quot;;&lt;br /&gt;
        URL url = new URL(target);&lt;br /&gt;
        HttpURLConnection httpConnection = (HttpURLConnection) url.openConnection();&lt;br /&gt;
        httpConnection.connect();&lt;br /&gt;
        System.out.println(&amp;quot;Invoking server through HTTP GET to invoke sayHi&amp;quot;);&lt;br /&gt;
        InputStream in = httpConnection.getInputStream();&lt;br /&gt;
        StreamSource source = new StreamSource(in);&lt;br /&gt;
        printSource(source);&lt;br /&gt;
        // Sent HTTP GET request to invoke greetMe FAULT&lt;br /&gt;
        target = &amp;quot;http://localhost:9000/XMLService/XMLPort/greetMe/me/CXF&amp;quot;;&lt;br /&gt;
        url = new URL(target);&lt;br /&gt;
        httpConnection = (HttpURLConnection) url.openConnection();&lt;br /&gt;
        httpConnection.connect();&lt;br /&gt;
        System.out.println(&amp;quot;Invoking server through HTTP GET to invoke greetMe&amp;quot;);&lt;br /&gt;
        try {&lt;br /&gt;
            in = httpConnection.getInputStream();&lt;br /&gt;
            source = new StreamSource(in);&lt;br /&gt;
            printSource(source);&lt;br /&gt;
        } catch (Exception e) {&lt;br /&gt;
            System.err.println(&amp;quot;GreetMe Fault: &amp;quot; + e.getMessage());&lt;br /&gt;
        }&lt;br /&gt;
        InputStream err = httpConnection.getErrorStream();&lt;br /&gt;
        source = new StreamSource(err);&lt;br /&gt;
        printSource(source);&lt;br /&gt;
        // Sent HTTP GET request to invoke greetMe&lt;br /&gt;
        target = &amp;quot;http://localhost:9000/XMLService/XMLPort/greetMe/requestType/CXF&amp;quot;;&lt;br /&gt;
        url = new URL(target);&lt;br /&gt;
        httpConnection = (HttpURLConnection) url.openConnection();&lt;br /&gt;
        httpConnection.connect();&lt;br /&gt;
        System.out.println(&amp;quot;Invoking server through HTTP GET to invoke greetMe&amp;quot;);&lt;br /&gt;
        in = httpConnection.getInputStream();&lt;br /&gt;
        source = new StreamSource(in);&lt;br /&gt;
        printSource(source);&lt;br /&gt;
    }&lt;br /&gt;
    private static void printSource(Source source) {&lt;br /&gt;
        try {&lt;br /&gt;
            ByteArrayOutputStream bos = new ByteArrayOutputStream();&lt;br /&gt;
            StreamResult sr = new StreamResult(bos);&lt;br /&gt;
            Transformer trans = TransformerFactory.newInstance().newTransformer();&lt;br /&gt;
            Properties oprops = new Properties();&lt;br /&gt;
            oprops.put(OutputKeys.OMIT_XML_DECLARATION, &amp;quot;yes&amp;quot;);&lt;br /&gt;
            trans.setOutputProperties(oprops);&lt;br /&gt;
            trans.transform(source, sr);&lt;br /&gt;
            System.out.println();&lt;br /&gt;
            System.out.println(&amp;quot;**** Response ******&amp;quot;);&lt;br /&gt;
            System.out.println();&lt;br /&gt;
            System.out.println(bos.toString());&lt;br /&gt;
            bos.close();&lt;br /&gt;
            System.out.println();&lt;br /&gt;
        } catch (Exception e) {&lt;br /&gt;
            e.printStackTrace();&lt;br /&gt;
        }&lt;br /&gt;
    }    &lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
///////////////////////////////////////////////////////////////////&lt;br /&gt;
/**&lt;br /&gt;
 * Licensed to the Apache Software Foundation (ASF) under one&lt;br /&gt;
 * or more contributor license agreements. See the NOTICE file&lt;br /&gt;
 * distributed with this work for additional information&lt;br /&gt;
 * regarding copyright ownership. The ASF licenses this file&lt;br /&gt;
 * to you under the Apache License, Version 2.0 (the&lt;br /&gt;
 * &amp;quot;License&amp;quot;); you may not use this file except in compliance&lt;br /&gt;
 * with the License. You may obtain a copy of the License at&lt;br /&gt;
 *&lt;br /&gt;
 * http://www.apache.org/licenses/LICENSE-2.0&lt;br /&gt;
 *&lt;br /&gt;
 * Unless required by applicable law or agreed to in writing,&lt;br /&gt;
 * software distributed under the License is distributed on an&lt;br /&gt;
 * &amp;quot;AS IS&amp;quot; BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY&lt;br /&gt;
 * KIND, either express or implied. See the License for the&lt;br /&gt;
 * specific language governing permissions and limitations&lt;br /&gt;
 * under the License.&lt;br /&gt;
 */&lt;br /&gt;
package demo.hw.server;&lt;br /&gt;
import org.apache.hello_world_xml_http.bare.Greeter;&lt;br /&gt;
import org.apache.hello_world_xml_http.bare.types.MyComplexStructType;&lt;br /&gt;
@javax.jws.WebService(serviceName = &amp;quot;XMLService&amp;quot;, &lt;br /&gt;
                portName = &amp;quot;XMLPort&amp;quot;,&lt;br /&gt;
                endpointInterface = &amp;quot;org.apache.hello_world_xml_http.bare.Greeter&amp;quot;,&lt;br /&gt;
                targetNamespace = &amp;quot;http://apache.org/hello_world_xml_http/bare&amp;quot;)&lt;br /&gt;
@javax.xml.ws.BindingType(value = &amp;quot;http://cxf.apache.org/bindings/xformat&amp;quot;)&lt;br /&gt;
public class GreeterImpl implements Greeter {&lt;br /&gt;
    public String greetMe(String me) {&lt;br /&gt;
        // TODO Auto-generated method stub&lt;br /&gt;
        System.out.println(&amp;quot;received calling greetMe!&amp;quot;);&lt;br /&gt;
        return &amp;quot;Hello &amp;quot; + me;        &lt;br /&gt;
    }&lt;br /&gt;
    public String sayHi() {&lt;br /&gt;
        // TODO Auto-generated method stub&lt;br /&gt;
        System.out.println(&amp;quot;received calling sayHi!&amp;quot;);&lt;br /&gt;
        return &amp;quot;Bonjour&amp;quot;;&lt;br /&gt;
    }&lt;br /&gt;
    public MyComplexStructType sendReceiveData(MyComplexStructType in) {&lt;br /&gt;
        // TODO Auto-generated method stub&lt;br /&gt;
        System.out.println(&amp;quot;received calling sendReceiveData!&amp;quot;);&lt;br /&gt;
        return in;&lt;br /&gt;
    }&lt;br /&gt;
    public String testMultiParamPart(MyComplexStructType in2, String in1) {&lt;br /&gt;
        // TODO Auto-generated method stub&lt;br /&gt;
        in2.setElem1(in1);&lt;br /&gt;
        return &amp;quot;Bonjour&amp;quot;;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
///////////////////////////////////////////////////////////////////&lt;br /&gt;
/**&lt;br /&gt;
 * Licensed to the Apache Software Foundation (ASF) under one&lt;br /&gt;
 * or more contributor license agreements. See the NOTICE file&lt;br /&gt;
 * distributed with this work for additional information&lt;br /&gt;
 * regarding copyright ownership. The ASF licenses this file&lt;br /&gt;
 * to you under the Apache License, Version 2.0 (the&lt;br /&gt;
 * &amp;quot;License&amp;quot;); you may not use this file except in compliance&lt;br /&gt;
 * with the License. You may obtain a copy of the License at&lt;br /&gt;
 *&lt;br /&gt;
 * http://www.apache.org/licenses/LICENSE-2.0&lt;br /&gt;
 *&lt;br /&gt;
 * Unless required by applicable law or agreed to in writing,&lt;br /&gt;
 * software distributed under the License is distributed on an&lt;br /&gt;
 * &amp;quot;AS IS&amp;quot; BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY&lt;br /&gt;
 * KIND, either express or implied. See the License for the&lt;br /&gt;
 * specific language governing permissions and limitations&lt;br /&gt;
 * under the License.&lt;br /&gt;
 */&lt;br /&gt;
package demo.hw.server;&lt;br /&gt;
import javax.xml.ws.Endpoint;&lt;br /&gt;
public class Server {&lt;br /&gt;
    protected Server() throws Exception {&lt;br /&gt;
        System.out.println(&amp;quot;Starting Server&amp;quot;);&lt;br /&gt;
        Object implementor = new GreeterImpl();&lt;br /&gt;
        String address = &amp;quot;http://localhost:9000/XMLService/XMLPort&amp;quot;;&lt;br /&gt;
        Endpoint.publish(address, implementor);&lt;br /&gt;
    }&lt;br /&gt;
    public static void main(String args[]) throws Exception {&lt;br /&gt;
        new Server();&lt;br /&gt;
        System.out.println(&amp;quot;Server ready...&amp;quot;);&lt;br /&gt;
        Thread.sleep(5 * 60 * 1000);&lt;br /&gt;
        System.out.println(&amp;quot;Server exiting&amp;quot;);&lt;br /&gt;
        System.exit(0);&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
///////////////////////////////////////////////////////////////////&lt;br /&gt;
&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot;?&amp;gt;&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
Licensed to the Apache Software Foundation (ASF) under one&lt;br /&gt;
or more contributor license agreements. See the NOTICE file&lt;br /&gt;
distributed with this work for additional information&lt;br /&gt;
regarding copyright ownership. The ASF licenses this file&lt;br /&gt;
to you under the Apache License, Version 2.0 (the&lt;br /&gt;
&amp;quot;License&amp;quot;); you may not use this file except in compliance&lt;br /&gt;
with the License. You may obtain a copy of the License at&lt;br /&gt;
http://www.apache.org/licenses/LICENSE-2.0&lt;br /&gt;
Unless required by applicable law or agreed to in writing,&lt;br /&gt;
software distributed under the License is distributed on an&lt;br /&gt;
&amp;quot;AS IS&amp;quot; BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY&lt;br /&gt;
KIND, either express or implied. See the License for the&lt;br /&gt;
specific language governing permissions and limitations&lt;br /&gt;
under the License.&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&amp;lt;wsdl:definitions name=&amp;quot;HelloWorld&amp;quot; targetNamespace=&amp;quot;http://apache.org/hello_world_xml_http/bare&amp;quot; &lt;br /&gt;
      xmlns=&amp;quot;http://schemas.xmlsoap.org/wsdl/&amp;quot;&lt;br /&gt;
      xmlns:http=&amp;quot;http://schemas.xmlsoap.org/wsdl/http/&amp;quot;&lt;br /&gt;
      xmlns:xformat=&amp;quot;http://cxf.apache.org/bindings/xformat&amp;quot; &lt;br /&gt;
      xmlns:tns=&amp;quot;http://apache.org/hello_world_xml_http/bare&amp;quot;&lt;br /&gt;
      xmlns:x1=&amp;quot;http://apache.org/hello_world_xml_http/bare/types&amp;quot;&lt;br /&gt;
      xmlns:wsdl=&amp;quot;http://schemas.xmlsoap.org/wsdl/&amp;quot; &lt;br /&gt;
      xmlns:xsd=&amp;quot;http://www.w3.org/2001/XMLSchema&amp;quot;&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
    &amp;lt;wsdl:types&amp;gt;&lt;br /&gt;
  &amp;lt;schema targetNamespace=&amp;quot;http://apache.org/hello_world_xml_http/bare/types&amp;quot; &lt;br /&gt;
    xmlns=&amp;quot;http://www.w3.org/2001/XMLSchema&amp;quot; &lt;br /&gt;
    elementFormDefault=&amp;quot;qualified&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;element name=&amp;quot;responseType&amp;quot; type=&amp;quot;xsd:string&amp;quot;/&amp;gt;&lt;br /&gt;
      &amp;lt;element name=&amp;quot;requestType&amp;quot; type=&amp;quot;xsd:string&amp;quot;/&amp;gt;      &lt;br /&gt;
      &amp;lt;element name=&amp;quot;myComplexStruct&amp;quot; type=&amp;quot;x1:myComplexStructType&amp;quot;/&amp;gt;     &lt;br /&gt;
      &lt;br /&gt;
      &amp;lt;complexType name=&amp;quot;myComplexStructType&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;sequence&amp;gt;&lt;br /&gt;
        &amp;lt;element name=&amp;quot;elem1&amp;quot; type=&amp;quot;xsd:string&amp;quot;/&amp;gt;&lt;br /&gt;
        &amp;lt;element name=&amp;quot;elem2&amp;quot; type=&amp;quot;xsd:string&amp;quot;/&amp;gt;&lt;br /&gt;
        &amp;lt;element name=&amp;quot;elem3&amp;quot; type=&amp;quot;xsd:int&amp;quot;/&amp;gt;&lt;br /&gt;
    &amp;lt;/sequence&amp;gt;&lt;br /&gt;
      &amp;lt;/complexType&amp;gt;&lt;br /&gt;
  &amp;lt;/schema&amp;gt;&lt;br /&gt;
    &amp;lt;/wsdl:types&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
    &amp;lt;wsdl:message name=&amp;quot;sayHiRequest&amp;quot;/&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
    &amp;lt;wsdl:message name=&amp;quot;sayHiResponse&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;wsdl:part type=&amp;quot;xsd:string&amp;quot; name=&amp;quot;out&amp;quot;/&amp;gt;&lt;br /&gt;
    &amp;lt;/wsdl:message&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
    &amp;lt;wsdl:message name=&amp;quot;greetMeRequest&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;wsdl:part element=&amp;quot;x1:requestType&amp;quot; name=&amp;quot;me&amp;quot;/&amp;gt;&lt;br /&gt;
    &amp;lt;/wsdl:message&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
    &amp;lt;wsdl:message name=&amp;quot;greetMeResponse&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;wsdl:part element=&amp;quot;x1:responseType&amp;quot; name=&amp;quot;theResponse&amp;quot;/&amp;gt;&lt;br /&gt;
    &amp;lt;/wsdl:message&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
    &amp;lt;wsdl:message name=&amp;quot;sendReceiveDataRequest&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;wsdl:part type=&amp;quot;x1:myComplexStructType&amp;quot; name=&amp;quot;in&amp;quot;/&amp;gt;&lt;br /&gt;
    &amp;lt;/wsdl:message&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
    &amp;lt;wsdl:message name=&amp;quot;sendReceiveDataResponse&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;wsdl:part type=&amp;quot;x1:myComplexStructType&amp;quot; name=&amp;quot;out&amp;quot;/&amp;gt;&lt;br /&gt;
    &amp;lt;/wsdl:message&amp;gt;&lt;br /&gt;
    &amp;lt;wsdl:message name=&amp;quot;multiParamPartRequest&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;wsdl:part element=&amp;quot;x1:requestType&amp;quot; name=&amp;quot;in1&amp;quot;/&amp;gt;&lt;br /&gt;
  &amp;lt;wsdl:part element=&amp;quot;x1:myComplexStruct&amp;quot; name=&amp;quot;in2&amp;quot;/&amp;gt;&lt;br /&gt;
    &amp;lt;/wsdl:message&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
    &amp;lt;wsdl:message name=&amp;quot;multiParamPartResponse&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;wsdl:part element=&amp;quot;x1:responseType&amp;quot; name=&amp;quot;out1&amp;quot;/&amp;gt;&lt;br /&gt;
    &amp;lt;/wsdl:message&amp;gt;&lt;br /&gt;
    &amp;lt;wsdl:portType name=&amp;quot;Greeter&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;wsdl:operation name=&amp;quot;sayHi&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;wsdl:input message=&amp;quot;tns:sayHiRequest&amp;quot; name=&amp;quot;sayHiRequest&amp;quot;/&amp;gt;&lt;br /&gt;
      &amp;lt;wsdl:output message=&amp;quot;tns:sayHiResponse&amp;quot; name=&amp;quot;sayHiResponse&amp;quot;/&amp;gt;&lt;br /&gt;
  &amp;lt;/wsdl:operation&amp;gt;&lt;br /&gt;
  &amp;lt;wsdl:operation name=&amp;quot;greetMe&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;wsdl:input message=&amp;quot;tns:greetMeRequest&amp;quot; name=&amp;quot;greetMeRequest&amp;quot;/&amp;gt;&lt;br /&gt;
      &amp;lt;wsdl:output message=&amp;quot;tns:greetMeResponse&amp;quot; name=&amp;quot;greetMeResponse&amp;quot;/&amp;gt;&lt;br /&gt;
  &amp;lt;/wsdl:operation&amp;gt;&lt;br /&gt;
  &amp;lt;wsdl:operation name=&amp;quot;sendReceiveData&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;wsdl:input message=&amp;quot;tns:sendReceiveDataRequest&amp;quot; name=&amp;quot;SendReceiveDataRequest&amp;quot;/&amp;gt;&lt;br /&gt;
      &amp;lt;wsdl:output message=&amp;quot;tns:sendReceiveDataResponse&amp;quot; name=&amp;quot;SendReceiveDataResponse&amp;quot;/&amp;gt;&lt;br /&gt;
  &amp;lt;/wsdl:operation&amp;gt;&lt;br /&gt;
  &amp;lt;wsdl:operation name=&amp;quot;testMultiParamPart&amp;quot; parameterOrder=&amp;quot;in2 in1&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;wsdl:input message=&amp;quot;tns:multiParamPartRequest&amp;quot; name=&amp;quot;multiParamPartRequest&amp;quot;/&amp;gt;&lt;br /&gt;
      &amp;lt;wsdl:output message=&amp;quot;tns:multiParamPartResponse&amp;quot; name=&amp;quot;multiParamPartResponse&amp;quot;/&amp;gt;&lt;br /&gt;
  &amp;lt;/wsdl:operation&amp;gt;&lt;br /&gt;
    &amp;lt;/wsdl:portType&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
    &amp;lt;wsdl:binding name=&amp;quot;Greeter_XMLBinding&amp;quot; type=&amp;quot;tns:Greeter&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;xformat:binding/&amp;gt;&lt;br /&gt;
  &amp;lt;wsdl:operation name=&amp;quot;sayHi&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;wsdl:input&amp;gt;&lt;br /&gt;
    &amp;lt;xformat:body rootNode=&amp;quot;tns:sayHi&amp;quot;/&amp;gt;&lt;br /&gt;
      &amp;lt;/wsdl:input&amp;gt;&lt;br /&gt;
      &amp;lt;wsdl:output/&amp;gt;&lt;br /&gt;
  &amp;lt;/wsdl:operation&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
  &amp;lt;wsdl:operation name=&amp;quot;greetMe&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;wsdl:input/&amp;gt;&lt;br /&gt;
      &amp;lt;wsdl:output/&amp;gt;&lt;br /&gt;
  &amp;lt;/wsdl:operation&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
  &amp;lt;wsdl:operation name=&amp;quot;sendReceiveData&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;wsdl:input/&amp;gt;&lt;br /&gt;
      &amp;lt;wsdl:output/&amp;gt;&lt;br /&gt;
  &amp;lt;/wsdl:operation&amp;gt;&lt;br /&gt;
  &amp;lt;wsdl:operation name=&amp;quot;testMultiParamPart&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;wsdl:input&amp;gt;&lt;br /&gt;
    &amp;lt;xformat:body rootNode=&amp;quot;tns:multiParamRootReq&amp;quot;/&amp;gt;&lt;br /&gt;
      &amp;lt;/wsdl:input&amp;gt;&lt;br /&gt;
      &amp;lt;wsdl:output/&amp;gt;&lt;br /&gt;
  &amp;lt;/wsdl:operation&amp;gt;&lt;br /&gt;
    &amp;lt;/wsdl:binding&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
    &amp;lt;wsdl:service name=&amp;quot;XMLService&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;wsdl:port binding=&amp;quot;tns:Greeter_XMLBinding&amp;quot; name=&amp;quot;XMLPort&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;http:address location=&amp;quot;http://localhost:9000/XMLService/XMLPort&amp;quot;/&amp;gt;&lt;br /&gt;
  &amp;lt;/wsdl:port&amp;gt;&lt;br /&gt;
    &amp;lt;/wsdl:service&amp;gt;&lt;br /&gt;
&amp;lt;/wsdl:definitions&amp;gt;&lt;br /&gt;
&lt;br /&gt;
        &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== XFire CXF integration ==&lt;/div&gt;</summary>
		<author><name>Admin</name></author>	</entry>

	<entry>
		<id>http://jexp.ru/index.php?title=Java/Web_Services_SOA/REST&amp;diff=9197</id>
		<title>Java/Web Services SOA/REST</title>
		<link rel="alternate" type="text/html" href="http://jexp.ru/index.php?title=Java/Web_Services_SOA/REST&amp;diff=9197"/>
				<updated>2010-06-01T07:27:31Z</updated>
		
		<summary type="html">&lt;p&gt;Admin: 1 версия&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Axis2 client API has facilities to invoke REST interfaces ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
Sample for Yahoo - Search - REST&lt;br /&gt;
=================================&lt;br /&gt;
Introduction&lt;br /&gt;
============&lt;br /&gt;
Axis2 client API has facilities to invoke REST interfaces. The API to be used is almost the same&lt;br /&gt;
as the one we use while invoking with REST.&lt;br /&gt;
Yahoo provides a REST API to call its search service. This sample demonstrates how to call Yahoo&lt;br /&gt;
search service using an Axis2 client.&lt;br /&gt;
Pre-Requisites&lt;br /&gt;
==============&lt;br /&gt;
Apache Ant 1.6.2 or later&lt;br /&gt;
Running The Sample&lt;br /&gt;
==================&lt;br /&gt;
Type &amp;quot;ant&amp;quot; from Axis2_HOME/samples/yahoorestsearch directory.&lt;br /&gt;
Help&lt;br /&gt;
====&lt;br /&gt;
Please contact axis-user list (axis-user@ws.apache.org) if you have any trouble running the sample.&lt;br /&gt;
        &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== REST based Web Services using the HTTP binding and JAX-WS Provider/Dispatch ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
RESTful Hello World Demo &lt;br /&gt;
========================&lt;br /&gt;
The demo shows REST based Web Services using the HTTP binding and &lt;br /&gt;
JAX-WS Provider/Dispatch. The REST server provides the following services: &lt;br /&gt;
A RESTful customer service is provided on URL http://localhost:9000/customerservice/customer. &lt;br /&gt;
Users access this URI to query or update customer info.&lt;br /&gt;
A HTTP GET request to URL http://localhost:9000/customerservice/customer returns &lt;br /&gt;
a list of customer hyperlinks. This allows client navigates through the &lt;br /&gt;
application states. The XML document returned:&lt;br /&gt;
&amp;lt;Customers&amp;gt;&lt;br /&gt;
  &amp;lt;Customer href=&amp;quot;http://localhost/customerservice/customer?id=1234&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;id&amp;gt;1234&amp;lt;/id&amp;gt;&lt;br /&gt;
  &amp;lt;/Customer&amp;gt;&lt;br /&gt;
  &amp;lt;Customer href=&amp;quot;http://localhost/customerservice/customer?id=1235&amp;quot;&amp;gt; &lt;br /&gt;
      &amp;lt;id&amp;gt;1235&amp;lt;/id&amp;gt;&lt;br /&gt;
  &amp;lt;/Customer&amp;gt;&lt;br /&gt;
  &amp;lt;Customer href=&amp;quot;http://localhost/customerservice/customer?id=1236&amp;quot;&amp;gt; &lt;br /&gt;
      &amp;lt;id&amp;gt;1236&amp;lt;/id&amp;gt;&lt;br /&gt;
  &amp;lt;/Customer&amp;gt;&lt;br /&gt;
&amp;lt;/Customers&amp;gt;&lt;br /&gt;
A HTTP GET request to URL http://localhost:9000/customerservice/customer?id=1234 &lt;br /&gt;
returns a customer instance whose id is 1234. The XML document returned:&lt;br /&gt;
&amp;lt;Customer&amp;gt;&lt;br /&gt;
  &amp;lt;id&amp;gt;1234&amp;lt;/id&amp;gt;&lt;br /&gt;
  &amp;lt;name&amp;gt;John&amp;lt;/name&amp;gt;&lt;br /&gt;
  &amp;lt;phoneNumber&amp;gt;123456&amp;lt;/phoneNumber&amp;gt;&lt;br /&gt;
&amp;lt;/Customer&amp;gt;&lt;br /&gt;
A HTTP POST request to URL http://localhost:9000/customerservice/customer &lt;br /&gt;
with the data:&lt;br /&gt;
&amp;lt;Customer&amp;gt;&lt;br /&gt;
  &amp;lt;id&amp;gt;1234&amp;lt;/id&amp;gt;&lt;br /&gt;
  &amp;lt;name&amp;gt;John&amp;lt;/name&amp;gt;&lt;br /&gt;
  &amp;lt;phoneNumber&amp;gt;123456&amp;lt;/phoneNumber&amp;gt;&lt;br /&gt;
&amp;lt;/Customer&amp;gt;&lt;br /&gt;
updates customer 1234 with the data provided. &lt;br /&gt;
The client code demonstrates how to send HTTP POST with XML data using &lt;br /&gt;
JAX-WS Dispatch and how to send HTTP GET using URL.openStream(). The &lt;br /&gt;
server code demonstrates how to build a RESTful endpoints through &lt;br /&gt;
JAX-WS Provider interface.&lt;br /&gt;
&lt;br /&gt;
Please review the README in the samples directory before&lt;br /&gt;
continuing.&lt;br /&gt;
&lt;br /&gt;
Prerequisites&lt;br /&gt;
------------&lt;br /&gt;
If your environment already includes cxf-manifest-incubator.jar on the&lt;br /&gt;
CLASSPATH, and the JDK and ant bin directories on the PATH&lt;br /&gt;
it is not necessary to set the environment as described in&lt;br /&gt;
the samples directory README.  If your environment is not&lt;br /&gt;
properly configured, or if you are planning on using wsdl2java,&lt;br /&gt;
javac, and java to build and run the demos, you must set the&lt;br /&gt;
environment.&lt;br /&gt;
&lt;br /&gt;
Building and running the demo using ant&lt;br /&gt;
---------------------------------------&lt;br /&gt;
From the samples/restful directory, the ant build script&lt;br /&gt;
can be used to build and run the demo.&lt;br /&gt;
Using either UNIX or Windows:&lt;br /&gt;
  ant build&lt;br /&gt;
  ant server&lt;br /&gt;
  ant client&lt;br /&gt;
    &lt;br /&gt;
To remove the code generated from the WSDL file and the .class&lt;br /&gt;
files, run:&lt;br /&gt;
  ant clean&lt;br /&gt;
&lt;br /&gt;
Building the demo using wsdl2java and javac&lt;br /&gt;
-------------------------------------------&lt;br /&gt;
From the samples/restful directory, first create the target&lt;br /&gt;
directory build/classes and then compile the provided client &lt;br /&gt;
and server applications with the commands:&lt;br /&gt;
For UNIX:  &lt;br /&gt;
  mkdir -p build/classes&lt;br /&gt;
  &lt;br /&gt;
  export CLASSPATH=$CLASSPATH:$CXF_HOME/lib/cxf-manifest-incubator.jar:./build/classes&lt;br /&gt;
  javac -d build/classes src/demo/restful/client/*.java&lt;br /&gt;
  javac -d build/classes src/demo/restful/server/*.java&lt;br /&gt;
For Windows:&lt;br /&gt;
  mkdir build\classes&lt;br /&gt;
    Must use back slashes.&lt;br /&gt;
  set classpath=%classpath%;%CXF_HOME%\lib\cxf-manifest-incubator.jar;.\build\classes&lt;br /&gt;
  javac -d build\classes src\demo\restful\client\*.java&lt;br /&gt;
  javac -d build\classes src\demo\restful\server\*.java&lt;br /&gt;
&lt;br /&gt;
Finally, copy resource files into the build/classes directory with the commands:&lt;br /&gt;
For UNIX:    &lt;br /&gt;
  cp ./src/demo/restful/client/*.xml ./build/classes/demo/restful/client&lt;br /&gt;
  cp ./src/demo/restful/server/*.xml ./build/classes/demo/restful/server&lt;br /&gt;
For Windows:&lt;br /&gt;
  copy src\demo\restful\client\*.xml build\classes\demo\restful\client&lt;br /&gt;
  copy src\demo\restful\server\*.xml build\classes\demo\restful\server&lt;br /&gt;
&lt;br /&gt;
Running the demo using java&lt;br /&gt;
---------------------------&lt;br /&gt;
From the samples/restful directory run the following commands. They &lt;br /&gt;
are entered on a single command line.&lt;br /&gt;
For UNIX (must use forward slashes):&lt;br /&gt;
    java -Djava.util.logging.config.file=$CXF_HOME/etc/logging.properties&lt;br /&gt;
         demo.restful.server.Server &amp;amp;&lt;br /&gt;
    java -Djava.util.logging.config.file=$CXF_HOME/etc/logging.properties&lt;br /&gt;
         demo.restful.client.Client&lt;br /&gt;
The server process starts in the background.  After running the client,&lt;br /&gt;
use the kill command to terminate the server process.&lt;br /&gt;
For Windows (may use either forward or back slashes):&lt;br /&gt;
  start &lt;br /&gt;
    java -Djava.util.logging.config.file=%CXF_HOME%\etc\logging.properties&lt;br /&gt;
         demo.restful.server.Server&lt;br /&gt;
    java -Djava.util.logging.config.file=%CXF_HOME%\etc\logging.properties&lt;br /&gt;
       demo.restful.client.Client&lt;br /&gt;
A new command windows opens for the server process.  After running the&lt;br /&gt;
client, terminate the server process by issuing Ctrl-C in its command window.&lt;br /&gt;
To remove the code generated from the WSDL file and the .class&lt;br /&gt;
files, either delete the build directory and its contents or run:&lt;br /&gt;
  ant clean&lt;br /&gt;
//////////////////////////////////////////////////////////////////////////&lt;br /&gt;
/**&lt;br /&gt;
 * Licensed to the Apache Software Foundation (ASF) under one&lt;br /&gt;
 * or more contributor license agreements. See the NOTICE file&lt;br /&gt;
 * distributed with this work for additional information&lt;br /&gt;
 * regarding copyright ownership. The ASF licenses this file&lt;br /&gt;
 * to you under the Apache License, Version 2.0 (the&lt;br /&gt;
 * &amp;quot;License&amp;quot;); you may not use this file except in compliance&lt;br /&gt;
 * with the License. You may obtain a copy of the License at&lt;br /&gt;
 *&lt;br /&gt;
 * http://www.apache.org/licenses/LICENSE-2.0&lt;br /&gt;
 *&lt;br /&gt;
 * Unless required by applicable law or agreed to in writing,&lt;br /&gt;
 * software distributed under the License is distributed on an&lt;br /&gt;
 * &amp;quot;AS IS&amp;quot; BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY&lt;br /&gt;
 * KIND, either express or implied. See the License for the&lt;br /&gt;
 * specific language governing permissions and limitations&lt;br /&gt;
 * under the License.&lt;br /&gt;
 */&lt;br /&gt;
package demo.restful.client;&lt;br /&gt;
import java.io.ByteArrayOutputStream;&lt;br /&gt;
import java.io.InputStream;&lt;br /&gt;
import java.net.URI;&lt;br /&gt;
import java.net.URL;&lt;br /&gt;
import java.util.Map;&lt;br /&gt;
import java.util.Properties;&lt;br /&gt;
import javax.xml.namespace.QName;&lt;br /&gt;
import javax.xml.transform.OutputKeys;&lt;br /&gt;
import javax.xml.transform.Source;&lt;br /&gt;
import javax.xml.transform.Transformer;&lt;br /&gt;
import javax.xml.transform.TransformerFactory;&lt;br /&gt;
import javax.xml.transform.dom.DOMSource;&lt;br /&gt;
import javax.xml.transform.stream.StreamResult;&lt;br /&gt;
import javax.xml.transform.stream.StreamSource;&lt;br /&gt;
import javax.xml.ws.Dispatch;&lt;br /&gt;
import javax.xml.ws.Service;&lt;br /&gt;
import javax.xml.ws.handler.MessageContext;&lt;br /&gt;
import javax.xml.ws.http.HTTPBinding;&lt;br /&gt;
import org.w3c.dom.Document;&lt;br /&gt;
import org.apache.cxf.helpers.XMLUtils;&lt;br /&gt;
public final class Client {&lt;br /&gt;
    private Client() {&lt;br /&gt;
    }&lt;br /&gt;
    public static void main(String args[]) throws Exception {&lt;br /&gt;
        QName serviceName = new QName(&amp;quot;http://apache.org/hello_world_xml_http/wrapped&amp;quot;,&lt;br /&gt;
                                                &amp;quot;cutomerservice&amp;quot;);&lt;br /&gt;
        QName portName = new QName(&amp;quot;http://apache.org/hello_world_xml_http/wrapped&amp;quot;,&lt;br /&gt;
                                             &amp;quot;RestProviderPort&amp;quot;);&lt;br /&gt;
        String endpointAddress = &amp;quot;http://localhost:9000/customerservice/customer&amp;quot;;&lt;br /&gt;
        // Sent HTTP GET request to query all customer info&lt;br /&gt;
        URL url = new URL(endpointAddress);&lt;br /&gt;
        System.out.println(&amp;quot;Invoking server through HTTP GET to query all customer info&amp;quot;);&lt;br /&gt;
        InputStream in = url.openStream();&lt;br /&gt;
        StreamSource source = new StreamSource(in);&lt;br /&gt;
        printSource(source);&lt;br /&gt;
        // Sent HTTP GET request to query customer info&lt;br /&gt;
        url = new URL(endpointAddress + &amp;quot;?id=1234&amp;quot;);&lt;br /&gt;
        System.out.println(&amp;quot;Invoking server through HTTP GET to query customer info&amp;quot;);&lt;br /&gt;
        in = url.openStream();&lt;br /&gt;
        source = new StreamSource(in);&lt;br /&gt;
        printSource(source);&lt;br /&gt;
        // Sent HTTP POST request to update customer info using JAX-WS Dispatch&lt;br /&gt;
        URI endpointURI = new URI(endpointAddress.toString());&lt;br /&gt;
        String path = null;&lt;br /&gt;
        if (endpointURI != null) {&lt;br /&gt;
            path = endpointURI.getPath();&lt;br /&gt;
        }&lt;br /&gt;
        Service service = Service.create(serviceName);&lt;br /&gt;
        service.addPort(portName, HTTPBinding.HTTP_BINDING,  endpointAddress);&lt;br /&gt;
        Dispatch&amp;lt;DOMSource&amp;gt; dispatcher = service.createDispatch(portName,&lt;br /&gt;
                                                                DOMSource.class, Service.Mode.PAYLOAD);&lt;br /&gt;
        Map&amp;lt;String, Object&amp;gt; requestContext = dispatcher.getRequestContext();&lt;br /&gt;
        Client client = new Client();&lt;br /&gt;
        InputStream is = client.getClass().getResourceAsStream(&amp;quot;CustomerJohnReq.xml&amp;quot;);&lt;br /&gt;
        Document doc = XMLUtils.parse(is);&lt;br /&gt;
        DOMSource reqMsg = new DOMSource(doc);&lt;br /&gt;
        requestContext.put(MessageContext.HTTP_REQUEST_METHOD, &amp;quot;POST&amp;quot;);&lt;br /&gt;
        System.out.println(&amp;quot;Invoking through HTTP POST to update customer using JAX-WS Dispatch&amp;quot;);&lt;br /&gt;
        DOMSource result = dispatcher.invoke(reqMsg);&lt;br /&gt;
        printSource(result);&lt;br /&gt;
        System.out.println(&amp;quot;Client Invoking is succeeded!&amp;quot;);&lt;br /&gt;
        System.exit(0);&lt;br /&gt;
    }&lt;br /&gt;
    private static void printSource(Source source) {&lt;br /&gt;
        try {&lt;br /&gt;
            ByteArrayOutputStream bos = new ByteArrayOutputStream();&lt;br /&gt;
            StreamResult sr = new StreamResult(bos);&lt;br /&gt;
            Transformer trans = TransformerFactory.newInstance().newTransformer();&lt;br /&gt;
            Properties oprops = new Properties();&lt;br /&gt;
            oprops.put(OutputKeys.OMIT_XML_DECLARATION, &amp;quot;yes&amp;quot;);&lt;br /&gt;
            trans.setOutputProperties(oprops);&lt;br /&gt;
            trans.transform(source, sr);&lt;br /&gt;
            System.out.println(&amp;quot;**** Response ******&amp;quot;);&lt;br /&gt;
            System.out.println(bos.toString());&lt;br /&gt;
            bos.close();&lt;br /&gt;
            System.out.println();&lt;br /&gt;
        } catch (Exception e) {&lt;br /&gt;
            e.printStackTrace();&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
//////////////////////////////////////////////////////////////////////////&lt;br /&gt;
/**&lt;br /&gt;
 * Licensed to the Apache Software Foundation (ASF) under one&lt;br /&gt;
 * or more contributor license agreements. See the NOTICE file&lt;br /&gt;
 * distributed with this work for additional information&lt;br /&gt;
 * regarding copyright ownership. The ASF licenses this file&lt;br /&gt;
 * to you under the Apache License, Version 2.0 (the&lt;br /&gt;
 * &amp;quot;License&amp;quot;); you may not use this file except in compliance&lt;br /&gt;
 * with the License. You may obtain a copy of the License at&lt;br /&gt;
 *&lt;br /&gt;
 * http://www.apache.org/licenses/LICENSE-2.0&lt;br /&gt;
 *&lt;br /&gt;
 * Unless required by applicable law or agreed to in writing,&lt;br /&gt;
 * software distributed under the License is distributed on an&lt;br /&gt;
 * &amp;quot;AS IS&amp;quot; BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY&lt;br /&gt;
 * KIND, either express or implied. See the License for the&lt;br /&gt;
 * specific language governing permissions and limitations&lt;br /&gt;
 * under the License.&lt;br /&gt;
 */&lt;br /&gt;
package demo.restful.server;&lt;br /&gt;
import java.io.InputStream;&lt;br /&gt;
import javax.annotation.Resource;&lt;br /&gt;
import javax.xml.parsers.DocumentBuilder;&lt;br /&gt;
import javax.xml.parsers.DocumentBuilderFactory;&lt;br /&gt;
import javax.xml.transform.dom.DOMSource;&lt;br /&gt;
import javax.xml.ws.Provider;&lt;br /&gt;
import javax.xml.ws.Service;&lt;br /&gt;
import javax.xml.ws.ServiceMode;&lt;br /&gt;
import javax.xml.ws.WebServiceContext;&lt;br /&gt;
import javax.xml.ws.WebServiceProvider;&lt;br /&gt;
import javax.xml.ws.handler.MessageContext;&lt;br /&gt;
import org.w3c.dom.Document;&lt;br /&gt;
import org.apache.cxf.message.Message;&lt;br /&gt;
@WebServiceProvider()&lt;br /&gt;
@ServiceMode(value = Service.Mode.PAYLOAD)&lt;br /&gt;
public class RestSourcePayloadProvider implements Provider&amp;lt;DOMSource&amp;gt; {&lt;br /&gt;
    @Resource&lt;br /&gt;
    protected WebServiceContext wsContext;&lt;br /&gt;
    public RestSourcePayloadProvider() {&lt;br /&gt;
    }&lt;br /&gt;
    public DOMSource invoke(DOMSource request) {&lt;br /&gt;
        MessageContext mc = wsContext.getMessageContext();&lt;br /&gt;
        String path = (String)mc.get(Message.PATH_INFO);&lt;br /&gt;
        String query = (String)mc.get(Message.QUERY_STRING);&lt;br /&gt;
        String httpMethod = (String)mc.get(Message.HTTP_REQUEST_METHOD);&lt;br /&gt;
        System.out.println(&amp;quot;--path--- &amp;quot; + path);&lt;br /&gt;
        System.out.println(&amp;quot;--query--- &amp;quot; + query);&lt;br /&gt;
        System.out.println(&amp;quot;--httpMethod--- &amp;quot; + httpMethod);&lt;br /&gt;
        if (httpMethod.equalsIgnoreCase(&amp;quot;POST&amp;quot;)) {&lt;br /&gt;
            // TBD: parse query info from DOMSource&lt;br /&gt;
            System.out.println(&amp;quot;---Invoking updateCustomer---&amp;quot;);&lt;br /&gt;
            return updateCustomer(request);&lt;br /&gt;
        } else if (httpMethod.equalsIgnoreCase(&amp;quot;GET&amp;quot;)) {&lt;br /&gt;
            if (path.equals(&amp;quot;/customerservice/customer&amp;quot;) &amp;amp;&amp;amp; query == null) {&lt;br /&gt;
                System.out.println(&amp;quot;---Invoking getAllCustomers---&amp;quot;);&lt;br /&gt;
                return getAllCustomers();&lt;br /&gt;
            } else if (path.equals(&amp;quot;/customerservice/customer&amp;quot;) &amp;amp;&amp;amp; query != null) {&lt;br /&gt;
                System.out.println(&amp;quot;---Invoking getCustomer---&amp;quot;);&lt;br /&gt;
                return getCustomer(query);&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
        return null;&lt;br /&gt;
    }&lt;br /&gt;
    private DOMSource getAllCustomers() {&lt;br /&gt;
        return createDOMSource(&amp;quot;CustomerAllResp.xml&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
    private DOMSource getCustomer(String customerID) {&lt;br /&gt;
        return createDOMSource(&amp;quot;CustomerJohnResp.xml&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
    private DOMSource updateCustomer(DOMSource request) {&lt;br /&gt;
        // TBD: returned update customer info&lt;br /&gt;
        return createDOMSource(&amp;quot;CustomerJohnResp.xml&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
    private DOMSource createDOMSource(String fileName) {&lt;br /&gt;
        DocumentBuilderFactory factory;&lt;br /&gt;
        DocumentBuilder builder;&lt;br /&gt;
        Document document = null;&lt;br /&gt;
        DOMSource response = null;&lt;br /&gt;
        try {&lt;br /&gt;
            factory = DocumentBuilderFactory.newInstance();&lt;br /&gt;
            //factory.setValidating(true);&lt;br /&gt;
            builder = factory.newDocumentBuilder();&lt;br /&gt;
            InputStream greetMeResponse = getClass().getResourceAsStream(fileName);&lt;br /&gt;
            document = builder.parse(greetMeResponse);&lt;br /&gt;
            response = new DOMSource(document);&lt;br /&gt;
        } catch (Exception e) {&lt;br /&gt;
            e.printStackTrace();&lt;br /&gt;
        }&lt;br /&gt;
        return response;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
//////////////////////////////////////////////////////////////////////////&lt;br /&gt;
/**&lt;br /&gt;
 * Licensed to the Apache Software Foundation (ASF) under one&lt;br /&gt;
 * or more contributor license agreements. See the NOTICE file&lt;br /&gt;
 * distributed with this work for additional information&lt;br /&gt;
 * regarding copyright ownership. The ASF licenses this file&lt;br /&gt;
 * to you under the Apache License, Version 2.0 (the&lt;br /&gt;
 * &amp;quot;License&amp;quot;); you may not use this file except in compliance&lt;br /&gt;
 * with the License. You may obtain a copy of the License at&lt;br /&gt;
 *&lt;br /&gt;
 * http://www.apache.org/licenses/LICENSE-2.0&lt;br /&gt;
 *&lt;br /&gt;
 * Unless required by applicable law or agreed to in writing,&lt;br /&gt;
 * software distributed under the License is distributed on an&lt;br /&gt;
 * &amp;quot;AS IS&amp;quot; BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY&lt;br /&gt;
 * KIND, either express or implied. See the License for the&lt;br /&gt;
 * specific language governing permissions and limitations&lt;br /&gt;
 * under the License.&lt;br /&gt;
 */&lt;br /&gt;
package demo.restful.server;&lt;br /&gt;
import javax.xml.ws.Endpoint;&lt;br /&gt;
import javax.xml.ws.http.HTTPBinding;&lt;br /&gt;
public class Server {&lt;br /&gt;
    protected Server() throws Exception {&lt;br /&gt;
        System.out.println(&amp;quot;Starting Server&amp;quot;);&lt;br /&gt;
        Endpoint e = Endpoint.create(HTTPBinding.HTTP_BINDING, new RestSourcePayloadProvider());&lt;br /&gt;
        String address = &amp;quot;http://localhost:9000/customerservice/customer&amp;quot;;&lt;br /&gt;
        e.publish(address);&lt;br /&gt;
    }&lt;br /&gt;
    public static void main(String args[]) throws Exception {&lt;br /&gt;
        new Server();&lt;br /&gt;
        System.out.println(&amp;quot;Server ready...&amp;quot;);&lt;br /&gt;
        Thread.sleep(5 * 60 * 1000);&lt;br /&gt;
        System.out.println(&amp;quot;Server exiting&amp;quot;);&lt;br /&gt;
        System.exit(0);&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
        &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== This demo shows how to create RESTful services using CXF&amp;quot;s HTTP binding ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
This demo shows how to create RESTful services using CXF&amp;quot;s HTTP binding.&lt;br /&gt;
The server in the demo creates 3 different endpoints: a RESTful XML&lt;br /&gt;
endpoint, a RESTful JSON endpoint, and a SOAP endpoint.&lt;br /&gt;
[RUNNING THE DEMO]&lt;br /&gt;
The demo has a class called com.acme.customer.Main which starts up various&lt;br /&gt;
endpoints. To start this server run the command:&lt;br /&gt;
$ ant server&lt;br /&gt;
Once it is running try going to the following URLs:&lt;br /&gt;
http://localhost:8080/xml/customers&lt;br /&gt;
http://localhost:8080/json/customers&lt;br /&gt;
http://localhost:8080/xml/customers/123&lt;br /&gt;
http://localhost:8080/json/customers/123&lt;br /&gt;
These will serve out XML and JSON representation of the resources.&lt;br /&gt;
There is an HTML page that is served by CXF so you can try using the&lt;br /&gt;
JSON service via Javascript. Just go to:&lt;br /&gt;
http://localhost:8080/test.html&lt;br /&gt;
Included are some example JSON and XML files so you can add or update&lt;br /&gt;
customers using wget. Try the following commands and look at the results:&lt;br /&gt;
wget --post-file add.json http://localhost:8080/json/customers&lt;br /&gt;
wget --post-file add.xml http://localhost:8080/xml/customers&lt;br /&gt;
wget --post-file update.xml http://localhost:8080/xml/customers/123&lt;br /&gt;
And if you are interested in SOAP you can try the SOAP endpoint:&lt;br /&gt;
http://localhost:8080/soap?wsdl&lt;br /&gt;
[RUNNING THE CLIENT]&lt;br /&gt;
The demo also includes a Client class which accesses data using &lt;br /&gt;
HTTP. To run this demo, do:&lt;br /&gt;
$ ant client&lt;br /&gt;
&lt;br /&gt;
        &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;/div&gt;</summary>
		<author><name>Admin</name></author>	</entry>

	<entry>
		<id>http://jexp.ru/index.php?title=Java/Web_Services_SOA/WS_Policy&amp;diff=9193</id>
		<title>Java/Web Services SOA/WS Policy</title>
		<link rel="alternate" type="text/html" href="http://jexp.ru/index.php?title=Java/Web_Services_SOA/WS_Policy&amp;diff=9193"/>
				<updated>2010-06-01T07:27:30Z</updated>
		
		<summary type="html">&lt;p&gt;Admin: 1 версия&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== This demo shows how the CXF WS-Policy framework in Apache CXF uses WSDL 1.1 Policy attachments to enable the use of WS-Addressing ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
WS-Policy Demo&lt;br /&gt;
==============&lt;br /&gt;
This demo shows how the CXF WS-Policy framework in Apache CXF uses&lt;br /&gt;
WSDL 1.1 Policy attachments to enable the use of WS-Addressing.&lt;br /&gt;
While most of the demo is very similar to the ws_addressing demo, there&lt;br /&gt;
are two major differences:&lt;br /&gt;
1. � Policy element containing an Addressing assertion is attached to &lt;br /&gt;
the port element in the demo&amp;quot;s wsdl.&lt;br /&gt;
2. The configuration files for the client and server specify that the &lt;br /&gt;
CXF policy engine should be enabled. &lt;br /&gt;
In addition, the configuration file for the server tells the policy&lt;br /&gt;
engine where to look for external policy attachments. This is necessary&lt;br /&gt;
since neither the implementor not the interface specify wsdlLocation&lt;br /&gt;
in their WebService annotation (the client could also use external policy&lt;br /&gt;
attachments instead of WSDL 1.1 attachments).&lt;br /&gt;
Note that, apart from the configuration of the decoupled http endpoint &lt;br /&gt;
on which the client receives responses from the server, nothing else&lt;br /&gt;
needs to be configured. In particular, there is no need to specify the&lt;br /&gt;
WS-Addressing interceptors. The internals of what is involved in&lt;br /&gt;
ensuring that addressing headers are added to the messages (namely:&lt;br /&gt;
the addition of two addressing interceptors to the inbound and outbound&lt;br /&gt;
fault and message processing chains) are left to the policy framework,&lt;br /&gt;
or rather: its built-in support for the Addressing assertion.&lt;br /&gt;
Please review the README in the samples directory before continuing.&lt;br /&gt;
&lt;br /&gt;
Prerequisite&lt;br /&gt;
------------&lt;br /&gt;
If your environment already includes cxf-manifest-incubator.jar on the CLASSPATH,&lt;br /&gt;
and the JDK and ant bin directories on the PATH, it is not necessary to&lt;br /&gt;
run the environment script described in the samples directory README.&lt;br /&gt;
If your environment is not properly configured, or if you are planning&lt;br /&gt;
on using wsdl2java, javac, and java to build and run the demos, you must&lt;br /&gt;
set the environment by running the script.&lt;br /&gt;
&lt;br /&gt;
Building and running the demo using ant&lt;br /&gt;
---------------------------------------&lt;br /&gt;
From the samples/ws_policy directory, the ant build script can be used to&lt;br /&gt;
build and run the demo.  The server and client targets automatically build&lt;br /&gt;
the demo.&lt;br /&gt;
Using either UNIX or Windows:&lt;br /&gt;
  ant server&lt;br /&gt;
  ant client&lt;br /&gt;
Although not explicitly instructed to use these interceptors, &lt;br /&gt;
both client and server will use the MAPAggregator and MAPCodec&lt;br /&gt;
interceptors to aggregate and encode the WS-Addressing MAPs.&lt;br /&gt;
To remove the code generated from the WSDL file and the .class&lt;br /&gt;
files, run:&lt;br /&gt;
  ant clean&lt;br /&gt;
&lt;br /&gt;
Buildng the demo using wsdl2java and javac&lt;br /&gt;
------------------------------------------&lt;br /&gt;
From the samples/ws_policy directory, first create the target directory&lt;br /&gt;
build/classes and then generate code from the WSDL file.&lt;br /&gt;
For UNIX:&lt;br /&gt;
  mkdir -p build/classes&lt;br /&gt;
  wsdl2java -d build/classes -compile ./wsdl/hello_world_addr.wsdl&lt;br /&gt;
For Windows:&lt;br /&gt;
  mkdir build\classes&lt;br /&gt;
    Must use back slashes.&lt;br /&gt;
  wsdl2java -d build\classes -compile .\wsdl\hello_world_addr.wsdl&lt;br /&gt;
    May use either forward or back slashes.&lt;br /&gt;
Now compile the provided client and server applications with the commands:&lt;br /&gt;
For UNIX:  &lt;br /&gt;
  &lt;br /&gt;
  export CLASSPATH=$CLASSPATH:$CXF_HOME/lib/cxf-manifest-incubator.jar:./build/classes:.&lt;br /&gt;
  javac -d build/classes src/demo/ws_policy/common/*.java&lt;br /&gt;
  javac -d build/classes src/demo/ws_policy/client/*.java&lt;br /&gt;
  javac -d build/classes src/demo/ws_policy/server/*.java&lt;br /&gt;
For Windows:&lt;br /&gt;
  set classpath=%classpath%;%CXF_HOME%\lib\cxf-manifest-incubator.jar;.\build\classes;.&lt;br /&gt;
  javac -d build\classes src\demo\ws_policy\common\*.java&lt;br /&gt;
  javac -d build\classes src\demo\ws_policy\client\*.java&lt;br /&gt;
  javac -d build\classes src\demo\ws_policy\server\*.java&lt;br /&gt;
Running the demo using java&lt;br /&gt;
---------------------------&lt;br /&gt;
From the samples/ws_policy directory run the commands (entered on a single command line):&lt;br /&gt;
For UNIX (must use forward slashes):&lt;br /&gt;
    java -Djava.util.logging.config.file=./logging.properties&lt;br /&gt;
         -Dcxf.config.file=server.xml&lt;br /&gt;
         demo.ws_policy.server.Server &amp;amp;&lt;br /&gt;
    java -Djava.util.logging.config.file=./logging.properties&lt;br /&gt;
         -Dcxf.config.file=client.xml&lt;br /&gt;
         demo.ws_policy.client.Client&lt;br /&gt;
The server process starts in the background.&lt;br /&gt;
For Windows (may use either forward or back slashes):&lt;br /&gt;
  start &lt;br /&gt;
    java -Djava.util.logging.config.file=.\logging.properties&lt;br /&gt;
         -Dcxf.config.file=server.xml&lt;br /&gt;
         demo.ws_policy.server.Server&lt;br /&gt;
    java -Djava.util.logging.config.file=.\logging.properties&lt;br /&gt;
         -Dcxf.config.file=client.xml&lt;br /&gt;
         demo.ws_policy.client.Client&lt;br /&gt;
The server process starts in a new command window.&lt;br /&gt;
After running the client, terminate the server process.&lt;br /&gt;
To remove the code generated from the WSDL file and the .class&lt;br /&gt;
files, either delete the build directory and its contents or run:&lt;br /&gt;
  ant clean&lt;br /&gt;
&lt;br /&gt;
/////////////////////////////////////////////////////////////////////&lt;br /&gt;
/**&lt;br /&gt;
 * Licensed to the Apache Software Foundation (ASF) under one&lt;br /&gt;
 * or more contributor license agreements. See the NOTICE file&lt;br /&gt;
 * distributed with this work for additional information&lt;br /&gt;
 * regarding copyright ownership. The ASF licenses this file&lt;br /&gt;
 * to you under the Apache License, Version 2.0 (the&lt;br /&gt;
 * &amp;quot;License&amp;quot;); you may not use this file except in compliance&lt;br /&gt;
 * with the License. You may obtain a copy of the License at&lt;br /&gt;
 *&lt;br /&gt;
 * http://www.apache.org/licenses/LICENSE-2.0&lt;br /&gt;
 *&lt;br /&gt;
 * Unless required by applicable law or agreed to in writing,&lt;br /&gt;
 * software distributed under the License is distributed on an&lt;br /&gt;
 * &amp;quot;AS IS&amp;quot; BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY&lt;br /&gt;
 * KIND, either express or implied. See the License for the&lt;br /&gt;
 * specific language governing permissions and limitations&lt;br /&gt;
 * under the License.&lt;br /&gt;
 */&lt;br /&gt;
package demo.ws_policy.client;&lt;br /&gt;
import org.apache.hello_world_soap_http.Greeter;&lt;br /&gt;
import org.apache.hello_world_soap_http.PingMeFault;&lt;br /&gt;
import org.apache.hello_world_soap_http.SOAPService;&lt;br /&gt;
public final class Client {&lt;br /&gt;
    &lt;br /&gt;
    private static final String USER_NAME = System.getProperty(&amp;quot;user.name&amp;quot;);&lt;br /&gt;
    private Client() {&lt;br /&gt;
    } &lt;br /&gt;
    public static void main(String args[]) {&lt;br /&gt;
        try { &lt;br /&gt;
            SOAPService service = new SOAPService();&lt;br /&gt;
            Greeter port = service.getSoapPort();&lt;br /&gt;
            System.out.println(&amp;quot;Invoking sayHi...&amp;quot;);&lt;br /&gt;
            String resp = port.sayHi();&lt;br /&gt;
            System.out.println(&amp;quot;Server responded with: &amp;quot; + resp + &amp;quot;\n&amp;quot;);&lt;br /&gt;
    &lt;br /&gt;
            System.out.println(&amp;quot;Invoking greetMe...&amp;quot;);&lt;br /&gt;
            resp = port.greetMe(USER_NAME);&lt;br /&gt;
            System.out.println(&amp;quot;Server responded with: &amp;quot; + resp + &amp;quot;\n&amp;quot;);&lt;br /&gt;
    &lt;br /&gt;
            System.out.println(&amp;quot;Invoking greetMeOneWay...&amp;quot;);&lt;br /&gt;
            port.greetMeOneWay(USER_NAME);&lt;br /&gt;
            System.out.println(&amp;quot;No response from server as method is OneWay\n&amp;quot;);&lt;br /&gt;
    &lt;br /&gt;
            try {&lt;br /&gt;
                System.out.println(&amp;quot;Invoking pingMe, expecting exception...&amp;quot;);&lt;br /&gt;
                port.pingMe();&lt;br /&gt;
            } catch (PingMeFault ex) {&lt;br /&gt;
                System.out.println(&amp;quot;Expected exception occurred: &amp;quot; + ex);&lt;br /&gt;
            }&lt;br /&gt;
        } catch (Exception ex) { &lt;br /&gt;
            ex.printStackTrace();&lt;br /&gt;
        }  finally { &lt;br /&gt;
            System.exit(0); &lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
////////////////////////////////////////////////////////////////////&lt;br /&gt;
/**&lt;br /&gt;
 * Licensed to the Apache Software Foundation (ASF) under one&lt;br /&gt;
 * or more contributor license agreements. See the NOTICE file&lt;br /&gt;
 * distributed with this work for additional information&lt;br /&gt;
 * regarding copyright ownership. The ASF licenses this file&lt;br /&gt;
 * to you under the Apache License, Version 2.0 (the&lt;br /&gt;
 * &amp;quot;License&amp;quot;); you may not use this file except in compliance&lt;br /&gt;
 * with the License. You may obtain a copy of the License at&lt;br /&gt;
 *&lt;br /&gt;
 * http://www.apache.org/licenses/LICENSE-2.0&lt;br /&gt;
 *&lt;br /&gt;
 * Unless required by applicable law or agreed to in writing,&lt;br /&gt;
 * software distributed under the License is distributed on an&lt;br /&gt;
 * &amp;quot;AS IS&amp;quot; BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY&lt;br /&gt;
 * KIND, either express or implied. See the License for the&lt;br /&gt;
 * specific language governing permissions and limitations&lt;br /&gt;
 * under the License.&lt;br /&gt;
 */&lt;br /&gt;
package demo.ws_policy.rumon;&lt;br /&gt;
import java.util.logging.LogRecord;&lt;br /&gt;
import java.util.logging.SimpleFormatter;&lt;br /&gt;
public class ConciseFormatter extends SimpleFormatter {&lt;br /&gt;
    public synchronized String format(LogRecord record) {&lt;br /&gt;
        String longForm = super.format(record);&lt;br /&gt;
        String shortForm = longForm.indexOf(&amp;quot;INFO: &amp;quot;) &amp;gt; 0&lt;br /&gt;
                           ? longForm.substring(longForm.indexOf(&amp;quot;INFO: &amp;quot;) + 6)&lt;br /&gt;
                           : longForm;&lt;br /&gt;
        return shortForm;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
/////////////////////////////////////////////////////////////////////&lt;br /&gt;
/**&lt;br /&gt;
 * Licensed to the Apache Software Foundation (ASF) under one&lt;br /&gt;
 * or more contributor license agreements. See the NOTICE file&lt;br /&gt;
 * distributed with this work for additional information&lt;br /&gt;
 * regarding copyright ownership. The ASF licenses this file&lt;br /&gt;
 * to you under the Apache License, Version 2.0 (the&lt;br /&gt;
 * &amp;quot;License&amp;quot;); you may not use this file except in compliance&lt;br /&gt;
 * with the License. You may obtain a copy of the License at&lt;br /&gt;
 *&lt;br /&gt;
 * http://www.apache.org/licenses/LICENSE-2.0&lt;br /&gt;
 *&lt;br /&gt;
 * Unless required by applicable law or agreed to in writing,&lt;br /&gt;
 * software distributed under the License is distributed on an&lt;br /&gt;
 * &amp;quot;AS IS&amp;quot; BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY&lt;br /&gt;
 * KIND, either express or implied. See the License for the&lt;br /&gt;
 * specific language governing permissions and limitations&lt;br /&gt;
 * under the License.&lt;br /&gt;
 */&lt;br /&gt;
package demo.ws_policy.server;&lt;br /&gt;
import java.util.logging.Logger;&lt;br /&gt;
import javax.jws.WebService;&lt;br /&gt;
import org.apache.hello_world_soap_http.Greeter;&lt;br /&gt;
import org.apache.hello_world_soap_http.PingMeFault;&lt;br /&gt;
import org.apache.hello_world_soap_http.types.FaultDetail;&lt;br /&gt;
&lt;br /&gt;
@WebService(name = &amp;quot;Greeter&amp;quot;,&lt;br /&gt;
            serviceName = &amp;quot;SOAPService&amp;quot;, &lt;br /&gt;
            targetNamespace = &amp;quot;http://apache.org/hello_world_soap_http&amp;quot;)&lt;br /&gt;
                  &lt;br /&gt;
public class GreeterImpl implements Greeter {&lt;br /&gt;
    private static final Logger LOG = &lt;br /&gt;
        Logger.getLogger(GreeterImpl.class.getPackage().getName());&lt;br /&gt;
    &lt;br /&gt;
    /* (non-Javadoc)&lt;br /&gt;
     * @see org.apache.hello_world_soap_http.Greeter#greetMe(java.lang.String)&lt;br /&gt;
     */&lt;br /&gt;
    public String greetMe(String me) {&lt;br /&gt;
        LOG.info(&amp;quot;Executing operation greetMe&amp;quot;);&lt;br /&gt;
        System.out.println(&amp;quot;Executing operation greetMe&amp;quot;);&lt;br /&gt;
        System.out.println(&amp;quot;Message received: &amp;quot; + me + &amp;quot;\n&amp;quot;);&lt;br /&gt;
        return &amp;quot;Hello &amp;quot; + me;&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    /* (non-Javadoc)&lt;br /&gt;
     * @see org.apache.hello_world_soap_http.Greeter#greetMeOneWay(java.lang.String)&lt;br /&gt;
     */&lt;br /&gt;
    public void greetMeOneWay(String me) {&lt;br /&gt;
        LOG.info(&amp;quot;Executing operation greetMeOneWay&amp;quot;);&lt;br /&gt;
        System.out.println(&amp;quot;Executing operation greetMeOneWay\n&amp;quot;);&lt;br /&gt;
        System.out.println(&amp;quot;Hello there &amp;quot; + me);&lt;br /&gt;
    }&lt;br /&gt;
    /* (non-Javadoc)&lt;br /&gt;
     * @see org.apache.hello_world_soap_http.Greeter#sayHi()&lt;br /&gt;
     */&lt;br /&gt;
    public String sayHi() {&lt;br /&gt;
        LOG.info(&amp;quot;Executing operation sayHi&amp;quot;);&lt;br /&gt;
        System.out.println(&amp;quot;Executing operation sayHi\n&amp;quot;);&lt;br /&gt;
        return &amp;quot;Bonjour&amp;quot;;&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    public void pingMe() throws PingMeFault {&lt;br /&gt;
        FaultDetail faultDetail = new FaultDetail();&lt;br /&gt;
        faultDetail.setMajor((short)2);&lt;br /&gt;
        faultDetail.setMinor((short)1);&lt;br /&gt;
        LOG.info(&amp;quot;Executing operation pingMe, throwing PingMeFault exception&amp;quot;);&lt;br /&gt;
        System.out.println(&amp;quot;Executing operation pingMe, throwing PingMeFault exception\n&amp;quot;);&lt;br /&gt;
        throw new PingMeFault(&amp;quot;PingMeFault raised by server&amp;quot;, faultDetail);&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
/////////////////////////////////////////////////////////////////////////&lt;br /&gt;
/**&lt;br /&gt;
 * Licensed to the Apache Software Foundation (ASF) under one&lt;br /&gt;
 * or more contributor license agreements. See the NOTICE file&lt;br /&gt;
 * distributed with this work for additional information&lt;br /&gt;
 * regarding copyright ownership. The ASF licenses this file&lt;br /&gt;
 * to you under the Apache License, Version 2.0 (the&lt;br /&gt;
 * &amp;quot;License&amp;quot;); you may not use this file except in compliance&lt;br /&gt;
 * with the License. You may obtain a copy of the License at&lt;br /&gt;
 *&lt;br /&gt;
 * http://www.apache.org/licenses/LICENSE-2.0&lt;br /&gt;
 *&lt;br /&gt;
 * Unless required by applicable law or agreed to in writing,&lt;br /&gt;
 * software distributed under the License is distributed on an&lt;br /&gt;
 * &amp;quot;AS IS&amp;quot; BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY&lt;br /&gt;
 * KIND, either express or implied. See the License for the&lt;br /&gt;
 * specific language governing permissions and limitations&lt;br /&gt;
 * under the License.&lt;br /&gt;
 */&lt;br /&gt;
package demo.ws_policy.server;&lt;br /&gt;
import javax.xml.ws.Endpoint;&lt;br /&gt;
public class Server {&lt;br /&gt;
    protected Server() throws Exception {&lt;br /&gt;
        System.out.println(&amp;quot;Starting Server&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
        Object implementor = new GreeterImpl();&lt;br /&gt;
        String address = &amp;quot;http://localhost:9000/SoapContext/SoapPort&amp;quot;;&lt;br /&gt;
        Endpoint.publish(address, implementor);&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    public static void main(String args[]) throws Exception {&lt;br /&gt;
        new Server();&lt;br /&gt;
        System.out.println(&amp;quot;Server ready...&amp;quot;); &lt;br /&gt;
        &lt;br /&gt;
        Thread.sleep(5 * 60 * 1000); &lt;br /&gt;
        System.out.println(&amp;quot;Server exiting&amp;quot;);&lt;br /&gt;
        System.exit(0);&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
////////////////////////////////////////////////////////////////////////&lt;br /&gt;
&lt;br /&gt;
&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot;?&amp;gt;&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
  Licensed to the Apache Software Foundation (ASF) under one&lt;br /&gt;
  or more contributor license agreements. See the NOTICE file&lt;br /&gt;
  distributed with this work for additional information&lt;br /&gt;
  regarding copyright ownership. The ASF licenses this file&lt;br /&gt;
  to you under the Apache License, Version 2.0 (the&lt;br /&gt;
  &amp;quot;License&amp;quot;); you may not use this file except in compliance&lt;br /&gt;
  with the License. You may obtain a copy of the License at&lt;br /&gt;
 &lt;br /&gt;
  http://www.apache.org/licenses/LICENSE-2.0&lt;br /&gt;
 &lt;br /&gt;
  Unless required by applicable law or agreed to in writing,&lt;br /&gt;
  software distributed under the License is distributed on an&lt;br /&gt;
  &amp;quot;AS IS&amp;quot; BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY&lt;br /&gt;
  KIND, either express or implied. See the License for the&lt;br /&gt;
  specific language governing permissions and limitations&lt;br /&gt;
  under the License.&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&amp;lt;wsdl:definitions name=&amp;quot;HelloWorld&amp;quot; targetNamespace=&amp;quot;http://apache.org/hello_world_soap_http&amp;quot; &lt;br /&gt;
    xmlns=&amp;quot;http://schemas.xmlsoap.org/wsdl/&amp;quot; &lt;br /&gt;
    xmlns:soap=&amp;quot;http://schemas.xmlsoap.org/wsdl/soap/&amp;quot; &lt;br /&gt;
    xmlns:tns=&amp;quot;http://apache.org/hello_world_soap_http&amp;quot;&lt;br /&gt;
    xmlns:x1=&amp;quot;http://apache.org/hello_world_soap_http/types&amp;quot;&lt;br /&gt;
    xmlns:wsdl=&amp;quot;http://schemas.xmlsoap.org/wsdl/&amp;quot; &lt;br /&gt;
    xmlns:xsd=&amp;quot;http://www.w3.org/2001/XMLSchema&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;wsdl:types&amp;gt;&lt;br /&gt;
        &amp;lt;schema targetNamespace=&amp;quot;http://apache.org/hello_world_soap_http/types&amp;quot; &lt;br /&gt;
            xmlns=&amp;quot;http://www.w3.org/2001/XMLSchema&amp;quot; elementFormDefault=&amp;quot;qualified&amp;quot;&amp;gt;&lt;br /&gt;
            &amp;lt;element name=&amp;quot;sayHi&amp;quot;&amp;gt;&lt;br /&gt;
                &amp;lt;complexType/&amp;gt;&lt;br /&gt;
            &amp;lt;/element&amp;gt;&lt;br /&gt;
            &amp;lt;element name=&amp;quot;sayHiResponse&amp;quot;&amp;gt;&lt;br /&gt;
                &amp;lt;complexType&amp;gt;&lt;br /&gt;
                    &amp;lt;sequence&amp;gt;&lt;br /&gt;
                        &amp;lt;element name=&amp;quot;responseType&amp;quot; type=&amp;quot;xsd:string&amp;quot;/&amp;gt;&lt;br /&gt;
                    &amp;lt;/sequence&amp;gt;&lt;br /&gt;
                &amp;lt;/complexType&amp;gt;&lt;br /&gt;
            &amp;lt;/element&amp;gt;&lt;br /&gt;
            &amp;lt;element name=&amp;quot;greetMe&amp;quot;&amp;gt;&lt;br /&gt;
                &amp;lt;complexType&amp;gt;&lt;br /&gt;
                    &amp;lt;sequence&amp;gt;&lt;br /&gt;
                        &amp;lt;element name=&amp;quot;requestType&amp;quot; type=&amp;quot;xsd:string&amp;quot;/&amp;gt;&lt;br /&gt;
                    &amp;lt;/sequence&amp;gt;&lt;br /&gt;
                &amp;lt;/complexType&amp;gt;&lt;br /&gt;
            &amp;lt;/element&amp;gt;&lt;br /&gt;
            &amp;lt;element name=&amp;quot;greetMeResponse&amp;quot;&amp;gt;&lt;br /&gt;
                &amp;lt;complexType&amp;gt;&lt;br /&gt;
                    &amp;lt;sequence&amp;gt;&lt;br /&gt;
                        &amp;lt;element name=&amp;quot;responseType&amp;quot; type=&amp;quot;xsd:string&amp;quot;/&amp;gt;&lt;br /&gt;
                    &amp;lt;/sequence&amp;gt;&lt;br /&gt;
                &amp;lt;/complexType&amp;gt;&lt;br /&gt;
            &amp;lt;/element&amp;gt;&lt;br /&gt;
            &amp;lt;element name=&amp;quot;greetMeOneWay&amp;quot;&amp;gt;&lt;br /&gt;
                &amp;lt;complexType&amp;gt;&lt;br /&gt;
                    &amp;lt;sequence&amp;gt;&lt;br /&gt;
                        &amp;lt;element name=&amp;quot;requestType&amp;quot; type=&amp;quot;xsd:string&amp;quot;/&amp;gt;&lt;br /&gt;
                    &amp;lt;/sequence&amp;gt;&lt;br /&gt;
                &amp;lt;/complexType&amp;gt;&lt;br /&gt;
            &amp;lt;/element&amp;gt;&lt;br /&gt;
            &amp;lt;element name=&amp;quot;pingMe&amp;quot;&amp;gt;&lt;br /&gt;
                &amp;lt;complexType/&amp;gt;&lt;br /&gt;
            &amp;lt;/element&amp;gt;&lt;br /&gt;
            &amp;lt;element name=&amp;quot;pingMeResponse&amp;quot;&amp;gt;&lt;br /&gt;
                &amp;lt;complexType/&amp;gt;&lt;br /&gt;
            &amp;lt;/element&amp;gt;&lt;br /&gt;
            &amp;lt;element name=&amp;quot;faultDetail&amp;quot;&amp;gt;&lt;br /&gt;
                &amp;lt;complexType&amp;gt;&lt;br /&gt;
                    &amp;lt;sequence&amp;gt;&lt;br /&gt;
                        &amp;lt;element name=&amp;quot;minor&amp;quot; type=&amp;quot;xsd:short&amp;quot;/&amp;gt;&lt;br /&gt;
                        &amp;lt;element name=&amp;quot;major&amp;quot; type=&amp;quot;xsd:short&amp;quot;/&amp;gt;&lt;br /&gt;
                    &amp;lt;/sequence&amp;gt;&lt;br /&gt;
                &amp;lt;/complexType&amp;gt;&lt;br /&gt;
            &amp;lt;/element&amp;gt;&lt;br /&gt;
        &amp;lt;/schema&amp;gt;&lt;br /&gt;
    &amp;lt;/wsdl:types&amp;gt;&lt;br /&gt;
    &amp;lt;wsdl:message name=&amp;quot;sayHiRequest&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;wsdl:part element=&amp;quot;x1:sayHi&amp;quot; name=&amp;quot;in&amp;quot;/&amp;gt;&lt;br /&gt;
    &amp;lt;/wsdl:message&amp;gt;&lt;br /&gt;
    &amp;lt;wsdl:message name=&amp;quot;sayHiResponse&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;wsdl:part element=&amp;quot;x1:sayHiResponse&amp;quot; name=&amp;quot;out&amp;quot;/&amp;gt;&lt;br /&gt;
    &amp;lt;/wsdl:message&amp;gt;&lt;br /&gt;
    &amp;lt;wsdl:message name=&amp;quot;greetMeRequest&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;wsdl:part element=&amp;quot;x1:greetMe&amp;quot; name=&amp;quot;in&amp;quot;/&amp;gt;&lt;br /&gt;
    &amp;lt;/wsdl:message&amp;gt;&lt;br /&gt;
    &amp;lt;wsdl:message name=&amp;quot;greetMeResponse&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;wsdl:part element=&amp;quot;x1:greetMeResponse&amp;quot; name=&amp;quot;out&amp;quot;/&amp;gt;&lt;br /&gt;
    &amp;lt;/wsdl:message&amp;gt;&lt;br /&gt;
    &amp;lt;wsdl:message name=&amp;quot;greetMeOneWayRequest&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;wsdl:part element=&amp;quot;x1:greetMeOneWay&amp;quot; name=&amp;quot;in&amp;quot;/&amp;gt;&lt;br /&gt;
    &amp;lt;/wsdl:message&amp;gt;&lt;br /&gt;
    &amp;lt;wsdl:message name=&amp;quot;pingMeRequest&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;wsdl:part name=&amp;quot;in&amp;quot; element=&amp;quot;x1:pingMe&amp;quot;/&amp;gt;&lt;br /&gt;
    &amp;lt;/wsdl:message&amp;gt;&lt;br /&gt;
    &amp;lt;wsdl:message name=&amp;quot;pingMeResponse&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;wsdl:part name=&amp;quot;out&amp;quot; element=&amp;quot;x1:pingMeResponse&amp;quot;/&amp;gt;&lt;br /&gt;
    &amp;lt;/wsdl:message&amp;gt;        &lt;br /&gt;
    &amp;lt;wsdl:message name=&amp;quot;pingMeFault&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;wsdl:part name=&amp;quot;faultDetail&amp;quot; element=&amp;quot;x1:faultDetail&amp;quot;/&amp;gt;&lt;br /&gt;
    &amp;lt;/wsdl:message&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
    &amp;lt;wsdl:portType name=&amp;quot;Greeter&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;wsdl:operation name=&amp;quot;sayHi&amp;quot;&amp;gt;&lt;br /&gt;
            &amp;lt;wsdl:input message=&amp;quot;tns:sayHiRequest&amp;quot; name=&amp;quot;sayHiRequest&amp;quot;/&amp;gt;&lt;br /&gt;
            &amp;lt;wsdl:output message=&amp;quot;tns:sayHiResponse&amp;quot; name=&amp;quot;sayHiResponse&amp;quot;/&amp;gt;&lt;br /&gt;
        &amp;lt;/wsdl:operation&amp;gt;&lt;br /&gt;
        &lt;br /&gt;
        &amp;lt;wsdl:operation name=&amp;quot;greetMe&amp;quot;&amp;gt;&lt;br /&gt;
            &amp;lt;wsdl:input message=&amp;quot;tns:greetMeRequest&amp;quot; name=&amp;quot;greetMeRequest&amp;quot;/&amp;gt;&lt;br /&gt;
            &amp;lt;wsdl:output message=&amp;quot;tns:greetMeResponse&amp;quot; name=&amp;quot;greetMeResponse&amp;quot;/&amp;gt;&lt;br /&gt;
        &amp;lt;/wsdl:operation&amp;gt;&lt;br /&gt;
        &lt;br /&gt;
        &amp;lt;wsdl:operation name=&amp;quot;greetMeOneWay&amp;quot;&amp;gt;&lt;br /&gt;
            &amp;lt;wsdl:input message=&amp;quot;tns:greetMeOneWayRequest&amp;quot; name=&amp;quot;greetMeOneWayRequest&amp;quot;/&amp;gt;&lt;br /&gt;
        &amp;lt;/wsdl:operation&amp;gt;&lt;br /&gt;
        &amp;lt;wsdl:operation name=&amp;quot;pingMe&amp;quot;&amp;gt;&lt;br /&gt;
            &amp;lt;wsdl:input name=&amp;quot;pingMeRequest&amp;quot; message=&amp;quot;tns:pingMeRequest&amp;quot;/&amp;gt;&lt;br /&gt;
            &amp;lt;wsdl:output name=&amp;quot;pingMeResponse&amp;quot; message=&amp;quot;tns:pingMeResponse&amp;quot;/&amp;gt;&lt;br /&gt;
            &amp;lt;wsdl:fault name=&amp;quot;pingMeFault&amp;quot; message=&amp;quot;tns:pingMeFault&amp;quot;/&amp;gt;&lt;br /&gt;
        &amp;lt;/wsdl:operation&amp;gt; &lt;br /&gt;
    &amp;lt;/wsdl:portType&amp;gt;&lt;br /&gt;
    &amp;lt;wsdl:binding name=&amp;quot;Greeter_SOAPBinding&amp;quot; type=&amp;quot;tns:Greeter&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;soap:binding style=&amp;quot;document&amp;quot; transport=&amp;quot;http://schemas.xmlsoap.org/soap/http&amp;quot;/&amp;gt;&lt;br /&gt;
        &lt;br /&gt;
        &amp;lt;wsdl:operation name=&amp;quot;sayHi&amp;quot;&amp;gt;&lt;br /&gt;
            &amp;lt;soap:operation soapAction=&amp;quot;&amp;quot; style=&amp;quot;document&amp;quot;/&amp;gt;&lt;br /&gt;
            &amp;lt;wsdl:input name=&amp;quot;sayHiRequest&amp;quot;&amp;gt;&lt;br /&gt;
                &amp;lt;soap:body use=&amp;quot;literal&amp;quot;/&amp;gt;&lt;br /&gt;
            &amp;lt;/wsdl:input&amp;gt;&lt;br /&gt;
            &amp;lt;wsdl:output name=&amp;quot;sayHiResponse&amp;quot;&amp;gt;&lt;br /&gt;
                &amp;lt;soap:body use=&amp;quot;literal&amp;quot;/&amp;gt;&lt;br /&gt;
            &amp;lt;/wsdl:output&amp;gt;&lt;br /&gt;
        &amp;lt;/wsdl:operation&amp;gt;&lt;br /&gt;
        &lt;br /&gt;
        &amp;lt;wsdl:operation name=&amp;quot;greetMe&amp;quot;&amp;gt;&lt;br /&gt;
            &amp;lt;soap:operation soapAction=&amp;quot;&amp;quot; style=&amp;quot;document&amp;quot;/&amp;gt;&lt;br /&gt;
            &amp;lt;wsdl:input name=&amp;quot;greetMeRequest&amp;quot;&amp;gt;&lt;br /&gt;
                &amp;lt;soap:body use=&amp;quot;literal&amp;quot;/&amp;gt;&lt;br /&gt;
            &amp;lt;/wsdl:input&amp;gt;&lt;br /&gt;
            &amp;lt;wsdl:output name=&amp;quot;greetMeResponse&amp;quot;&amp;gt;&lt;br /&gt;
                &amp;lt;soap:body use=&amp;quot;literal&amp;quot;/&amp;gt;&lt;br /&gt;
            &amp;lt;/wsdl:output&amp;gt;&lt;br /&gt;
        &amp;lt;/wsdl:operation&amp;gt;&lt;br /&gt;
        &lt;br /&gt;
        &amp;lt;wsdl:operation name=&amp;quot;greetMeOneWay&amp;quot;&amp;gt;&lt;br /&gt;
            &amp;lt;soap:operation soapAction=&amp;quot;&amp;quot; style=&amp;quot;document&amp;quot;/&amp;gt;&lt;br /&gt;
            &amp;lt;wsdl:input name=&amp;quot;greetMeOneWayRequest&amp;quot;&amp;gt;&lt;br /&gt;
                &amp;lt;soap:body use=&amp;quot;literal&amp;quot;/&amp;gt;&lt;br /&gt;
            &amp;lt;/wsdl:input&amp;gt;&lt;br /&gt;
        &amp;lt;/wsdl:operation&amp;gt;&lt;br /&gt;
            &amp;lt;wsdl:operation name=&amp;quot;pingMe&amp;quot;&amp;gt;&lt;br /&gt;
            &amp;lt;soap:operation style=&amp;quot;document&amp;quot;/&amp;gt;&lt;br /&gt;
            &amp;lt;wsdl:input&amp;gt;&lt;br /&gt;
                &amp;lt;soap:body use=&amp;quot;literal&amp;quot;/&amp;gt;&lt;br /&gt;
            &amp;lt;/wsdl:input&amp;gt;&lt;br /&gt;
            &amp;lt;wsdl:output&amp;gt;&lt;br /&gt;
                &amp;lt;soap:body use=&amp;quot;literal&amp;quot;/&amp;gt;&lt;br /&gt;
            &amp;lt;/wsdl:output&amp;gt;&lt;br /&gt;
            &amp;lt;wsdl:fault name=&amp;quot;pingMeFault&amp;quot;&amp;gt;&lt;br /&gt;
                &amp;lt;soap:fault name=&amp;quot;pingMeFault&amp;quot; use=&amp;quot;literal&amp;quot;/&amp;gt;&lt;br /&gt;
            &amp;lt;/wsdl:fault&amp;gt;&lt;br /&gt;
        &amp;lt;/wsdl:operation&amp;gt;&lt;br /&gt;
        &lt;br /&gt;
    &amp;lt;/wsdl:binding&amp;gt;&lt;br /&gt;
    &amp;lt;wsdl:service name=&amp;quot;SOAPService&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;wsdl:port binding=&amp;quot;tns:Greeter_SOAPBinding&amp;quot; name=&amp;quot;SoapPort&amp;quot;&amp;gt;&lt;br /&gt;
            &amp;lt;soap:address location=&amp;quot;http://localhost:9000/SoapContext/SoapPort&amp;quot;/&amp;gt;&lt;br /&gt;
            &amp;lt;wsp:Policy xmlns:wsp=&amp;quot;http://www.w3.org/2006/07/ws-policy&amp;quot;&amp;gt;&lt;br /&gt;
                &amp;lt;wsam:Addressing xmlns:wsam=&amp;quot;http://www.w3.org/2007/02/addressing/metadata&amp;quot;&amp;gt;&lt;br /&gt;
                    &amp;lt;wsp:Policy/&amp;gt;&lt;br /&gt;
                &amp;lt;/wsam:Addressing&amp;gt;&lt;br /&gt;
            &amp;lt;/wsp:Policy&amp;gt;&lt;br /&gt;
            &amp;lt;wswa:UsingAddressing xmlns:wswa=&amp;quot;http://www.w3.org/2005/02/addressing/wsdl&amp;quot;/&amp;gt;&lt;br /&gt;
        &amp;lt;/wsdl:port&amp;gt;&lt;br /&gt;
    &amp;lt;/wsdl:service&amp;gt;&lt;br /&gt;
&amp;lt;/wsdl:definitions&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
        &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;/div&gt;</summary>
		<author><name>Admin</name></author>	</entry>

	<entry>
		<id>http://jexp.ru/index.php?title=Java/Web_Services_SOA/POJO_Web_service&amp;diff=9195</id>
		<title>Java/Web Services SOA/POJO Web service</title>
		<link rel="alternate" type="text/html" href="http://jexp.ru/index.php?title=Java/Web_Services_SOA/POJO_Web_service&amp;diff=9195"/>
				<updated>2010-06-01T07:27:30Z</updated>
		
		<summary type="html">&lt;p&gt;Admin: 1 версия&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== An example POJO Web service: how to expose the methods of a Java class as a Web service using Axis2. ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
Sample: POJO (Plain Old Java Object)&lt;br /&gt;
====================================&lt;br /&gt;
Introduction&lt;br /&gt;
============&lt;br /&gt;
This is an example POJO Web service. It shows how to expose the methods of a Java class as a Web&lt;br /&gt;
service using Aixs2.&lt;br /&gt;
&lt;br /&gt;
Prerequisites  &lt;br /&gt;
=============&lt;br /&gt;
To build the sample service you must have ant-1.6.x installed in your system. &lt;br /&gt;
To set AXIS2_HOME in Unix/Linux type:&lt;br /&gt;
$export AXIS2_HOME=&amp;lt;path to axis2 distribution&amp;gt;&lt;br /&gt;
Building the Service&lt;br /&gt;
====================&lt;br /&gt;
To build the sample service, type: $ant generate.service or just ant&lt;br /&gt;
This will build the AddressBookService.aar in the build directory and copy it to the&lt;br /&gt;
&amp;lt;AXIS2_HOME&amp;gt;/repository/services directory.&lt;br /&gt;
You can start the Axis2 server by running either axis2server.bat (on Windows) or axis2server.sh&lt;br /&gt;
(on Linux)that are located in &amp;lt;AXIS2_HOME&amp;gt;/bin directory.&lt;br /&gt;
The WSDL for this service should be viewable at:&lt;br /&gt;
http://&amp;lt;yourhost&amp;gt;:&amp;lt;yourport&amp;gt;/axis2/services/AddressBookService?wsdl &lt;br /&gt;
(e.g. http://localhost:8080/axis2/services/AddressBookService?wsdl)&lt;br /&gt;
src/sample/addressbook/rpcclient/AddressBookRPCClient.java is a Client that uses RPCServiceClient&lt;br /&gt;
to invoke the methods of this web services just like the method invocations of a Java object.&lt;br /&gt;
&lt;br /&gt;
Running the Client&lt;br /&gt;
==================&lt;br /&gt;
To compile and run, type&lt;br /&gt;
$ant rpc.client&lt;br /&gt;
src/sample/addressbook/adbclient/AddressBookADBClient is Client that uses a generated stub with ADB&lt;br /&gt;
to invoke the methods of this web service.&lt;br /&gt;
To generate the stub, compile and run, type&lt;br /&gt;
$ant adb.client -Dwsdl=http://&amp;lt;yourhost&amp;gt;:&amp;lt;yourport&amp;gt;/axis2/services/AddressBookService?wsdl&lt;br /&gt;
Help&lt;br /&gt;
====&lt;br /&gt;
Please contact axis-user list (axis-user@ws.apache.org) if you have any trouble running the sample.&lt;br /&gt;
        &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== How to expose the getters and setters of a Service: this demo uses the Spring to initialize the property of the Service ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
POJO Web Services using Apache Axis2- Sample 2&lt;br /&gt;
==============================================&lt;br /&gt;
This sample contains source code for the xdocs/1_1/pojoguide.html document found in &lt;br /&gt;
the extracted Axis2 Documents Distribution. For a more detailed description on the &lt;br /&gt;
source code kindly see this &amp;quot;POJO Web Services using Apache Axis2&amp;quot; document.&lt;br /&gt;
In this specific sample you&amp;quot;ll be shown how to take a POJO  (Plain Old Java Object) &lt;br /&gt;
based on the Spring Framework, and deploy that as an AAR packaged Web service on Tomcat. &lt;br /&gt;
This is a quick way to get a Web service up and running in no time. &lt;br /&gt;
Introduction&lt;br /&gt;
============&lt;br /&gt;
This sample shows how to expose the getters and setters of WeatherSpringService that &lt;br /&gt;
takes Weather type Java Object as the argument and the return type. It uses the Spring &lt;br /&gt;
framework to initialize the weather property of the WeatherSpringService.&lt;br /&gt;
&lt;br /&gt;
Pre-Requisites&lt;br /&gt;
==============&lt;br /&gt;
Apache Ant 1.6.2 or later&lt;br /&gt;
Spring-1.2.6.jar or later &lt;br /&gt;
You need to have this jar in your build and runtime class path. The easiest way to do this &lt;br /&gt;
is to copy it to Axis2_HOME/lib directory.&lt;br /&gt;
Building the Service&lt;br /&gt;
====================&lt;br /&gt;
Type $ant from Axis2_HOME/samples/pojoguidespring&lt;br /&gt;
&lt;br /&gt;
Running the Client&lt;br /&gt;
==================&lt;br /&gt;
Type $ant rpc.client from from Axis2_HOME/samples/pojoguidespring&lt;br /&gt;
Help&lt;br /&gt;
====&lt;br /&gt;
Please contact axis-user list (axis-user@ws.apache.org) if you have any trouble running the sample.&lt;br /&gt;
        &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== In this sample, we are deploying a POJO after writing a services.xml and creating an aar ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
Axis2 Quick Start Guide- Sample 1&lt;br /&gt;
=================================&lt;br /&gt;
This sample contains source code for the xdocs/1_1/quickstartguide.html document found in &lt;br /&gt;
the extracted Axis2 Documents Distribution. For a more detailed description on the &lt;br /&gt;
source code kindly see this &amp;quot;Axis2 Quick Start Guide&amp;quot; document.&lt;br /&gt;
Introduction&lt;br /&gt;
============&lt;br /&gt;
In this sample, we are deploying a POJO after writing a services.xml and&lt;br /&gt;
creating an aar. We also test the getPrice and update methods using a browser.&lt;br /&gt;
Pre-Requisites&lt;br /&gt;
==============&lt;br /&gt;
Apache Ant 1.6.2 or later&lt;br /&gt;
Building the Service&lt;br /&gt;
====================&lt;br /&gt;
Type &amp;quot;ant generate.service&amp;quot; or just &amp;quot;ant&amp;quot; from Axis2_HOME/samples/quickstart directory &lt;br /&gt;
and then deploy the Axis2_HOME/samples/quickstart/build/StockQuoteService.aar&lt;br /&gt;
Generate WSDL&lt;br /&gt;
==============&lt;br /&gt;
Type &amp;quot;ant generate.wsdl&amp;quot; from Axis2_HOME/samples/quickstart directory which generates a &lt;br /&gt;
WSDL file for the above Web service and it will be placed in Axis2_HOME/samples/quickstart/build &lt;br /&gt;
directory.&lt;br /&gt;
Running the Client&lt;br /&gt;
==================&lt;br /&gt;
- From your browser, If you point to the following URL:&lt;br /&gt;
http://localhost:8080/axis2/services/StockQuoteService/getPrice?symbol=IBM&lt;br /&gt;
You will get the following response:&lt;br /&gt;
&amp;lt;ns:getPriceResponse&amp;gt;&amp;lt;ns:return&amp;gt;42.0&amp;lt;/ns:return&amp;gt;&amp;lt;/ns:getPriceResponse&amp;gt;&lt;br /&gt;
- If you invoke the update method like so:&lt;br /&gt;
http://localhost:8080/axis2/services/StockQuoteService/update?symbol=IBM&amp;amp;price=100&lt;br /&gt;
And then execute the first getPrice url. You can see that the price got updated.&lt;br /&gt;
Help&lt;br /&gt;
====&lt;br /&gt;
Please contact axis-user list (axis-user@ws.apache.org) if you have any trouble running the sample.&lt;br /&gt;
        &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== This sample shows how to expose a Java class as a web service ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
POJO Web Services using Apache Axis2- Sample 1&lt;br /&gt;
=============================================&lt;br /&gt;
This sample contains source code for the xdocs/1_1/pojoguide.html document found in &lt;br /&gt;
the extracted Axis2 Documents Distribution. For a more detailed description on the &lt;br /&gt;
source code kindly see this &amp;quot;POJO Web Services using Apache Axis2&amp;quot; document.&lt;br /&gt;
The above mentioned document shows you how to take a simple POJO (Plain Old Java &lt;br /&gt;
Object), and deploy it on Apache Tomcat as a Web service in the exploded directory &lt;br /&gt;
format. This is a quick way to get a Web service up and running in no time. &lt;br /&gt;
Introduction&lt;br /&gt;
============&lt;br /&gt;
This sample shows how to expose a Java class as a web service.  &lt;br /&gt;
The WeatherService Java class provides methods to get and set a Weather &lt;br /&gt;
type Java objects. The client uses RPCServiceClient to invoke those two &lt;br /&gt;
methods just as Java object method invocation.&lt;br /&gt;
Prerequisites&lt;br /&gt;
==============&lt;br /&gt;
Apache Ant 1.6.2 or later&lt;br /&gt;
Building the Service&lt;br /&gt;
====================&lt;br /&gt;
Type $ant from Axis2_HOME/samples/pojoguide&lt;br /&gt;
&lt;br /&gt;
Running the Client&lt;br /&gt;
==================&lt;br /&gt;
Type $ant rpc.client&lt;br /&gt;
&lt;br /&gt;
Help&lt;br /&gt;
====&lt;br /&gt;
Please contact axis-user list (axis-user@ws.apache.org) if you have any trouble running the sample.&lt;br /&gt;
        &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;/div&gt;</summary>
		<author><name>Admin</name></author>	</entry>

	<entry>
		<id>http://jexp.ru/index.php?title=Java/Generics/Generic_Class&amp;diff=9187</id>
		<title>Java/Generics/Generic Class</title>
		<link rel="alternate" type="text/html" href="http://jexp.ru/index.php?title=Java/Generics/Generic_Class&amp;diff=9187"/>
				<updated>2010-06-01T07:27:29Z</updated>
		
		<summary type="html">&lt;p&gt;Admin: 1 версия&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== A nongeneric class can be the superclass of a generic subclass. ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
/*&lt;br /&gt;
Java 2, v5.0 (Tiger) New Features&lt;br /&gt;
by Herbert Schildt&lt;br /&gt;
ISBN: 0072258543&lt;br /&gt;
Publisher: McGraw-Hill/Osborne, 2004&lt;br /&gt;
*/&lt;br /&gt;
 &lt;br /&gt;
// A nongeneric class. &lt;br /&gt;
class NonGen { &lt;br /&gt;
  int num; &lt;br /&gt;
 &lt;br /&gt;
  NonGen(int i) { &lt;br /&gt;
    num = i; &lt;br /&gt;
  } &lt;br /&gt;
 &lt;br /&gt;
  int getnum() { &lt;br /&gt;
    return num; &lt;br /&gt;
  } &lt;br /&gt;
} &lt;br /&gt;
 &lt;br /&gt;
// A generic subclass. &lt;br /&gt;
class Gen&amp;lt;T&amp;gt; extends NonGen {  &lt;br /&gt;
  T ob; // declare an object of type T  &lt;br /&gt;
    &lt;br /&gt;
  // Pass the constructor a reference to   &lt;br /&gt;
  // an object of type T.  &lt;br /&gt;
  Gen(T o, int i) {  &lt;br /&gt;
    super(i); &lt;br /&gt;
    ob = o;  &lt;br /&gt;
  }  &lt;br /&gt;
  &lt;br /&gt;
  // Return ob.  &lt;br /&gt;
  T getob() {  &lt;br /&gt;
    return ob;  &lt;br /&gt;
  }  &lt;br /&gt;
}  &lt;br /&gt;
  &lt;br /&gt;
// Create a Gen object. &lt;br /&gt;
public class HierDemo2 {  &lt;br /&gt;
  public static void main(String args[]) {  &lt;br /&gt;
    &lt;br /&gt;
    // Create a Gen object for String. &lt;br /&gt;
    Gen&amp;lt;String&amp;gt; w = new Gen&amp;lt;String&amp;gt;(&amp;quot;Hello&amp;quot;, 47); &lt;br /&gt;
    &lt;br /&gt;
    System.out.print(w.getob() + &amp;quot; &amp;quot;); &lt;br /&gt;
    System.out.println(w.getnum()); &lt;br /&gt;
  }  &lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
           &lt;br /&gt;
         &lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== A simple generic class.   ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
class Gen&amp;lt;T&amp;gt; {&lt;br /&gt;
  T ob; // declare an object of type T&lt;br /&gt;
  Gen(T o) {&lt;br /&gt;
    ob = o;&lt;br /&gt;
  }&lt;br /&gt;
  T getob() {&lt;br /&gt;
    return ob;&lt;br /&gt;
  }&lt;br /&gt;
  void showType() {&lt;br /&gt;
    System.out.println(&amp;quot;Type of T is &amp;quot; + ob.getClass().getName());&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
public class GenDemo {&lt;br /&gt;
  public static void main(String args[]) {&lt;br /&gt;
    Gen&amp;lt;Integer&amp;gt; iOb;&lt;br /&gt;
    iOb = new Gen&amp;lt;Integer&amp;gt;(88);&lt;br /&gt;
    iOb.showType();&lt;br /&gt;
    int v = iOb.getob();&lt;br /&gt;
    System.out.println(&amp;quot;value: &amp;quot; + v);&lt;br /&gt;
    System.out.println();&lt;br /&gt;
    Gen&amp;lt;String&amp;gt; strOb = new Gen&amp;lt;String&amp;gt;(&amp;quot;Generics Test&amp;quot;);&lt;br /&gt;
    strOb.showType();&lt;br /&gt;
    String str = strOb.getob();&lt;br /&gt;
    System.out.println(&amp;quot;value: &amp;quot; + str);&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
           &lt;br /&gt;
         &lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== A simple generic class hierarchy. ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
/*&lt;br /&gt;
Java 2, v5.0 (Tiger) New Features&lt;br /&gt;
by Herbert Schildt&lt;br /&gt;
ISBN: 0072258543&lt;br /&gt;
Publisher: McGraw-Hill/Osborne, 2004&lt;br /&gt;
*/&lt;br /&gt;
class Gen&amp;lt;T&amp;gt; {  &lt;br /&gt;
  T ob; &lt;br /&gt;
    &lt;br /&gt;
  Gen(T o) {  &lt;br /&gt;
    ob = o;  &lt;br /&gt;
  }  &lt;br /&gt;
  &lt;br /&gt;
  // Return ob.  &lt;br /&gt;
  T getob() {  &lt;br /&gt;
    return ob;  &lt;br /&gt;
  }  &lt;br /&gt;
}  &lt;br /&gt;
 &lt;br /&gt;
// A subclass of Gen that defines a second &lt;br /&gt;
// type parameter, called V. &lt;br /&gt;
class Gen2&amp;lt;T, V&amp;gt; extends Gen&amp;lt;T&amp;gt; { &lt;br /&gt;
  V ob2; &lt;br /&gt;
 &lt;br /&gt;
  Gen2(T o, V o2) { &lt;br /&gt;
    super(o); &lt;br /&gt;
    ob2 = o2; &lt;br /&gt;
  } &lt;br /&gt;
 &lt;br /&gt;
  V getob2() { &lt;br /&gt;
    return ob2; &lt;br /&gt;
  } &lt;br /&gt;
} &lt;br /&gt;
  &lt;br /&gt;
// Create an object of type Gen2. &lt;br /&gt;
public class HierDemo {  &lt;br /&gt;
  public static void main(String args[]) {  &lt;br /&gt;
    &lt;br /&gt;
    // Create a Gen2 object for String and Integer. &lt;br /&gt;
    Gen2&amp;lt;String, Integer&amp;gt; x = &lt;br /&gt;
      new Gen2&amp;lt;String, Integer&amp;gt;(&amp;quot;Value is: &amp;quot;, 99);  &lt;br /&gt;
 &lt;br /&gt;
    System.out.print(x.getob()); &lt;br /&gt;
    System.out.println(x.getob2()); &lt;br /&gt;
  }  &lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
           &lt;br /&gt;
         &lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Custom Generic Object Tester ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
/*&lt;br /&gt;
License for Java 1.5 &amp;quot;Tiger&amp;quot;: A Developer&amp;quot;s Notebook&lt;br /&gt;
     (O&amp;quot;Reilly) example package&lt;br /&gt;
Java 1.5 &amp;quot;Tiger&amp;quot;: A Developer&amp;quot;s Notebook (O&amp;quot;Reilly) &lt;br /&gt;
by Brett McLaughlin and David Flanagan.&lt;br /&gt;
ISBN: 0-596-00738-8&lt;br /&gt;
You can use the examples and the source code any way you want, but&lt;br /&gt;
please include a reference to where it comes from if you use it in&lt;br /&gt;
your own products or services. Also note that this software is&lt;br /&gt;
provided by the author &amp;quot;as is&amp;quot;, with no expressed or implied warranties. &lt;br /&gt;
In no event shall the author be liable for any direct or indirect&lt;br /&gt;
damages arising in any way out of the use of this software.&lt;br /&gt;
*/&lt;br /&gt;
&lt;br /&gt;
import java.io.IOException;&lt;br /&gt;
import java.io.PrintStream;&lt;br /&gt;
&lt;br /&gt;
import java.util.LinkedList;&lt;br /&gt;
import java.util.List;&lt;br /&gt;
class GuitarManufacturerList extends LinkedList&amp;lt;String&amp;gt; {&lt;br /&gt;
  public GuitarManufacturerList() {&lt;br /&gt;
    super();&lt;br /&gt;
  }&lt;br /&gt;
  public boolean add(String manufacturer) {&lt;br /&gt;
    if (manufacturer.indexOf(&amp;quot;Guitars&amp;quot;) == -1) {&lt;br /&gt;
      return false;&lt;br /&gt;
    } else {&lt;br /&gt;
      super.add(manufacturer);&lt;br /&gt;
      return true;&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
public class CustomObjectTester {&lt;br /&gt;
  /** A custom object that extends List */&lt;br /&gt;
  private GuitarManufacturerList manufacturers;&lt;br /&gt;
  public CustomObjectTester() {&lt;br /&gt;
    this.manufacturers = new GuitarManufacturerList();&lt;br /&gt;
  }&lt;br /&gt;
  /**&lt;br /&gt;
   * &amp;lt;p&amp;gt;Test iterating over an object that extends List&amp;lt;/p&amp;gt;&lt;br /&gt;
   */&lt;br /&gt;
  public void testListExtension(PrintStream out) throws IOException {&lt;br /&gt;
    // Add some items for good measure&lt;br /&gt;
    manufacturers.add(&amp;quot;Epiphone Guitars&amp;quot;);&lt;br /&gt;
    manufacturers.add(&amp;quot;Gibson Guitars&amp;quot;);&lt;br /&gt;
    // Iterate with for/in&lt;br /&gt;
    for (String manufacturer : manufacturers) {&lt;br /&gt;
      out.println(manufacturer);&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
  public static void main(String[] args) {&lt;br /&gt;
    try {&lt;br /&gt;
      CustomObjectTester tester = new CustomObjectTester();&lt;br /&gt;
      tester.testListExtension(System.out);&lt;br /&gt;
    } catch (Exception e) {&lt;br /&gt;
      e.printStackTrace();&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
           &lt;br /&gt;
         &lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Demonstrate the non generic class ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
class NonGen {  &lt;br /&gt;
  Object ob; &lt;br /&gt;
    &lt;br /&gt;
  NonGen(Object o) {  &lt;br /&gt;
    ob = o;  &lt;br /&gt;
  }  &lt;br /&gt;
  &lt;br /&gt;
  Object getob() {  &lt;br /&gt;
    return ob;  &lt;br /&gt;
  }  &lt;br /&gt;
  void showType() {  &lt;br /&gt;
    System.out.println(&amp;quot;Type of ob is &amp;quot; +  &lt;br /&gt;
                       ob.getClass().getName());  &lt;br /&gt;
  }  &lt;br /&gt;
}  &lt;br /&gt;
  &lt;br /&gt;
 &lt;br /&gt;
public class NonGenDemo {  &lt;br /&gt;
  public static void main(String args[]) {  &lt;br /&gt;
    NonGen integerObject;   &lt;br /&gt;
    integerObject = new NonGen(88);  &lt;br /&gt;
  &lt;br /&gt;
    integerObject.showType(); &lt;br /&gt;
 &lt;br /&gt;
    int v = (Integer) integerObject.getob();  &lt;br /&gt;
    System.out.println(&amp;quot;value: &amp;quot; + v);  &lt;br /&gt;
  &lt;br /&gt;
 &lt;br /&gt;
    NonGen strOb = new NonGen(&amp;quot;Non-Generics Test&amp;quot;);  &lt;br /&gt;
    strOb.showType(); &lt;br /&gt;
 &lt;br /&gt;
    String str = (String) strOb.getob();  &lt;br /&gt;
    System.out.println(&amp;quot;value: &amp;quot; + str);  &lt;br /&gt;
 &lt;br /&gt;
    integerObject = strOb; &lt;br /&gt;
    v = (Integer) integerObject.getob(); &lt;br /&gt;
  }  &lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
           &lt;br /&gt;
         &lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Java hierarchy generic class ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
/*&lt;br /&gt;
Java 2, v5.0 (Tiger) New Features&lt;br /&gt;
by Herbert Schildt&lt;br /&gt;
ISBN: 0072258543&lt;br /&gt;
Publisher: McGraw-Hill/Osborne, 2004&lt;br /&gt;
*/&lt;br /&gt;
// Here, T is bound by Object by default. &lt;br /&gt;
class Gen&amp;lt;T&amp;gt; {  &lt;br /&gt;
  T ob; // here, T will be replaced by Object &lt;br /&gt;
    &lt;br /&gt;
  Gen(T o) {  &lt;br /&gt;
    ob = o;  &lt;br /&gt;
  }  &lt;br /&gt;
  &lt;br /&gt;
  // Return ob.  &lt;br /&gt;
  T getob() {  &lt;br /&gt;
    return ob;  &lt;br /&gt;
  }  &lt;br /&gt;
}  &lt;br /&gt;
 &lt;br /&gt;
// Here, T is bound by String. &lt;br /&gt;
class GenStr&amp;lt;T extends String&amp;gt; { &lt;br /&gt;
  T str; // here, T will be replaced by String &lt;br /&gt;
 &lt;br /&gt;
  GenStr(T o) {  &lt;br /&gt;
    str = o;  &lt;br /&gt;
  }  &lt;br /&gt;
 &lt;br /&gt;
  T getstr() { return str; } &lt;br /&gt;
}&lt;br /&gt;
public class GenTypeDemo {  &lt;br /&gt;
  public static void main(String args[]) {  &lt;br /&gt;
    Gen&amp;lt;Integer&amp;gt; iOb = new Gen&amp;lt;Integer&amp;gt;(99);  &lt;br /&gt;
    Gen&amp;lt;Float&amp;gt; fOb = new Gen&amp;lt;Float&amp;gt;(102.2F); &lt;br /&gt;
 &lt;br /&gt;
    System.out.println(iOb.getClass().getName()); &lt;br /&gt;
    System.out.println(fOb.getClass().getName()); &lt;br /&gt;
  } &lt;br /&gt;
}&lt;br /&gt;
           &lt;br /&gt;
         &lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Pair of template arguments ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
/* $Id$&lt;br /&gt;
 *&lt;br /&gt;
 * Behavior Protocols Tools - Parsers, Transformations&lt;br /&gt;
 * Copyright (C) 2006-2007  DSRG, Charles University in Prague&lt;br /&gt;
 *                          http://dsrg.mff.cuni.cz/&lt;br /&gt;
 *&lt;br /&gt;
 * This library is free software; you can redistribute it and/or&lt;br /&gt;
 * modify it under the terms of the GNU Lesser General Public&lt;br /&gt;
 * License as published by the Free Software Foundation; either&lt;br /&gt;
 * version 2.1 of the License, or (at your option) any later version.&lt;br /&gt;
 *&lt;br /&gt;
 * This library is distributed in the hope that it will be useful,&lt;br /&gt;
 * but WITHOUT ANY WARRANTY; without even the implied warranty of&lt;br /&gt;
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU&lt;br /&gt;
 * Lesser General Public License for more details.&lt;br /&gt;
 *&lt;br /&gt;
 * You should have received a copy of the GNU Lesser General Public&lt;br /&gt;
 * License along with this library; if not, write to the Free Software&lt;br /&gt;
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,&lt;br /&gt;
 * MA 02110-1301 USA&lt;br /&gt;
 *&lt;br /&gt;
 */&lt;br /&gt;
package org.ow2.dsrg.fm.bptools.util;&lt;br /&gt;
&lt;br /&gt;
/**&lt;br /&gt;
 * Keeps pair of values whose type is given by template arguments&lt;br /&gt;
 * @author thorm&lt;br /&gt;
 */&lt;br /&gt;
public class Pair&amp;lt;T1, T2&amp;gt; {&lt;br /&gt;
    &lt;br /&gt;
    /**&lt;br /&gt;
     * Creates a new instance of Pair&lt;br /&gt;
     * @param first first value&lt;br /&gt;
     * @param second second value&lt;br /&gt;
     */&lt;br /&gt;
    public Pair(T1 first, T2 second) {&lt;br /&gt;
        this.first = first;&lt;br /&gt;
        this.second = second;&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    public boolean equals(Object obj) {&lt;br /&gt;
        if (obj instanceof Pair) {&lt;br /&gt;
            Pair other = (Pair)obj;&lt;br /&gt;
             return (other.first == null ? this.first == null : other.first.equals(this.first)) &amp;amp;&amp;amp; &lt;br /&gt;
                     (other.second == null ? this.second == null : other.second.equals(this.second));&lt;br /&gt;
        }&lt;br /&gt;
        else&lt;br /&gt;
            return false;&lt;br /&gt;
    }&lt;br /&gt;
    public String toString(){&lt;br /&gt;
        return first.toString() +&amp;quot;::&amp;quot;+second.toString() ;&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    /**&lt;br /&gt;
     * first value&lt;br /&gt;
     */&lt;br /&gt;
    public T1 first;&lt;br /&gt;
    /**&lt;br /&gt;
     * second value&lt;br /&gt;
     */&lt;br /&gt;
    public T2 second;&lt;br /&gt;
}&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Stats attempts (unsuccessfully) to create a generic class ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
/*&lt;br /&gt;
Java 2, v5.0 (Tiger) New Features&lt;br /&gt;
by Herbert Schildt&lt;br /&gt;
ISBN: 0072258543&lt;br /&gt;
Publisher: McGraw-Hill/Osborne, 2004&lt;br /&gt;
*/&lt;br /&gt;
// Stats attempts (unsuccessfully) to create a generic class that can compute &lt;br /&gt;
// the average of an array of numbers of any given type. &lt;br /&gt;
// The class contains an error! &lt;br /&gt;
public class Stats&amp;lt;T&amp;gt; {  &lt;br /&gt;
  T[] nums; // nums is an array of type T &lt;br /&gt;
    &lt;br /&gt;
  // Pass the constructor a reference to   &lt;br /&gt;
  // an array of type T. &lt;br /&gt;
  Stats(T[] o) {  &lt;br /&gt;
    nums = o;  &lt;br /&gt;
  }  &lt;br /&gt;
  &lt;br /&gt;
  // Return type double in all cases. &lt;br /&gt;
  double average() {  &lt;br /&gt;
    double sum = 0.0; &lt;br /&gt;
 &lt;br /&gt;
    for(int i=0; i &amp;lt; nums.length; i++)  &lt;br /&gt;
      sum += nums[i].doubleValue(); // Error!!! &lt;br /&gt;
 &lt;br /&gt;
    return sum / nums.length; &lt;br /&gt;
  }  &lt;br /&gt;
}&lt;br /&gt;
           &lt;br /&gt;
         &lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Use the instanceof operator with a generic class hierarchy.   ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
/*&lt;br /&gt;
Java 2, v5.0 (Tiger) New Features&lt;br /&gt;
by Herbert Schildt&lt;br /&gt;
ISBN: 0072258543&lt;br /&gt;
Publisher: McGraw-Hill/Osborne, 2004&lt;br /&gt;
*/&lt;br /&gt;
class Gen&amp;lt;T&amp;gt; {   &lt;br /&gt;
  T ob;  &lt;br /&gt;
     &lt;br /&gt;
  Gen(T o) {   &lt;br /&gt;
    ob = o;   &lt;br /&gt;
  }   &lt;br /&gt;
   &lt;br /&gt;
  // Return ob.   &lt;br /&gt;
  T getob() {   &lt;br /&gt;
    return ob;   &lt;br /&gt;
  }   &lt;br /&gt;
}   &lt;br /&gt;
  &lt;br /&gt;
// A subclass of Gen.  &lt;br /&gt;
class Gen2&amp;lt;T&amp;gt; extends Gen&amp;lt;T&amp;gt; {  &lt;br /&gt;
  Gen2(T o) {  &lt;br /&gt;
    super(o);  &lt;br /&gt;
  }  &lt;br /&gt;
}  &lt;br /&gt;
  &lt;br /&gt;
 // Demonstrate runtime type ID implications of generic class hierarchy.  &lt;br /&gt;
public class HierDemo3 {   &lt;br /&gt;
  public static void main(String args[]) {   &lt;br /&gt;
     &lt;br /&gt;
    // Create a Gen object for Integers.  &lt;br /&gt;
    Gen&amp;lt;Integer&amp;gt; iOb = new Gen&amp;lt;Integer&amp;gt;(88);  &lt;br /&gt;
  &lt;br /&gt;
    // Create a Gen2 object for Integers.  &lt;br /&gt;
    Gen2&amp;lt;Integer&amp;gt; iOb2 = new Gen2&amp;lt;Integer&amp;gt;(99);   &lt;br /&gt;
    &lt;br /&gt;
    // Create a Gen2 object for Strings.  &lt;br /&gt;
    Gen2&amp;lt;String&amp;gt; strOb2 = new Gen2&amp;lt;String&amp;gt;(&amp;quot;Generics Test&amp;quot;);   &lt;br /&gt;
  &lt;br /&gt;
    // See if iOb2 is some form of Gen2. &lt;br /&gt;
    if(iOb2 instanceof Gen2&amp;lt;?&amp;gt;)   &lt;br /&gt;
      System.out.println(&amp;quot;iOb2 is instance of Gen2&amp;quot;);  &lt;br /&gt;
 &lt;br /&gt;
    // See if iOb2 is some form of Gen. &lt;br /&gt;
    if(iOb2 instanceof Gen&amp;lt;?&amp;gt;)   &lt;br /&gt;
      System.out.println(&amp;quot;iOb2 is instance of Gen&amp;quot;);  &lt;br /&gt;
  &lt;br /&gt;
    System.out.println();  &lt;br /&gt;
  &lt;br /&gt;
    // See if strOb2 is a Gen2. &lt;br /&gt;
    if(strOb2 instanceof Gen2&amp;lt;?&amp;gt;)   &lt;br /&gt;
      System.out.println(&amp;quot;strOb is instance of Gen2&amp;quot;);  &lt;br /&gt;
  &lt;br /&gt;
    // See if strOb2 is a Gen. &lt;br /&gt;
    if(strOb2 instanceof Gen&amp;lt;?&amp;gt;)   &lt;br /&gt;
      System.out.println(&amp;quot;strOb is instance of Gen&amp;quot;);  &lt;br /&gt;
 &lt;br /&gt;
    System.out.println();  &lt;br /&gt;
  &lt;br /&gt;
    // See if iOb is an instance of Gen2, which its not. &lt;br /&gt;
    if(iOb instanceof Gen2&amp;lt;?&amp;gt;)   &lt;br /&gt;
      System.out.println(&amp;quot;iOb is instance of Gen2&amp;quot;);  &lt;br /&gt;
  &lt;br /&gt;
    // See if iOb is an instance of Gen, which it is. &lt;br /&gt;
    if(iOb instanceof Gen&amp;lt;?&amp;gt;)   &lt;br /&gt;
      System.out.println(&amp;quot;iOb is instance of Gen&amp;quot;);  &lt;br /&gt;
  &lt;br /&gt;
    // The following can&amp;quot;t be compiled because  &lt;br /&gt;
    // generic type info does not exist at runtime. &lt;br /&gt;
//    if(iOb2 instanceof Gen2&amp;lt;Integer&amp;gt;)   &lt;br /&gt;
//      System.out.println(&amp;quot;iOb2 is instance of Gen2&amp;lt;Integer&amp;gt;&amp;quot;);  &lt;br /&gt;
  }   &lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
           &lt;br /&gt;
         &lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;/div&gt;</summary>
		<author><name>Admin</name></author>	</entry>

	<entry>
		<id>http://jexp.ru/index.php?title=Java/Generics&amp;diff=9189</id>
		<title>Java/Generics</title>
		<link rel="alternate" type="text/html" href="http://jexp.ru/index.php?title=Java/Generics&amp;diff=9189"/>
				<updated>2010-06-01T07:27:29Z</updated>
		
		<summary type="html">&lt;p&gt;Admin: 1 версия&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;* [[Java/Generics/Constraints | Constraints]]&lt;br /&gt;
* [[Java/Generics/Generic Class | Generic Class]]&lt;br /&gt;
* [[Java/Generics/Generic Collection | Generic Collection]]&lt;br /&gt;
* [[Java/Generics/Generic Constructor | Generic Constructor]]&lt;br /&gt;
* [[Java/Generics/Generic Interface | Generic Interface]]&lt;br /&gt;
* [[Java/Generics/Generic Method | Generic Method]]&lt;br /&gt;
* [[Java/Generics/Generic Parameter | Generic Parameter]]&lt;/div&gt;</summary>
		<author><name>Admin</name></author>	</entry>

	<entry>
		<id>http://jexp.ru/index.php?title=Java/Web_Services_SOA/WS_Addressing&amp;diff=9191</id>
		<title>Java/Web Services SOA/WS Addressing</title>
		<link rel="alternate" type="text/html" href="http://jexp.ru/index.php?title=Java/Web_Services_SOA/WS_Addressing&amp;diff=9191"/>
				<updated>2010-06-01T07:27:29Z</updated>
		
		<summary type="html">&lt;p&gt;Admin: 1 версия&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== This demo shows how WS-Addressing support in Apache CXF may be enabled ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
WS-Addressing Demo&lt;br /&gt;
==================&lt;br /&gt;
This demo shows how WS-Addressing support in Apache CXF may be enabled.  &lt;br /&gt;
The client and server both use interceptor configuration to install the&lt;br /&gt;
WS-Addressing interceptor, comprising a logical interceptor (MAPAggregator)&lt;br /&gt;
responsible for aggregating the WS-A MessageAddressingProperties for&lt;br /&gt;
the current message, and a protocol interceptor (MAPCodec) responsible for&lt;br /&gt;
encoding/decoding these properties as SOAP Headers. &lt;br /&gt;
A demo-specific logging.properties file is used to snoop the log messages&lt;br /&gt;
relating to WS-A Headers and display these to the console in concise form.&lt;br /&gt;
Normally the WS-Addressing MessageAddressProperties are generated and&lt;br /&gt;
propagated implicitly, without any intravention from the&lt;br /&gt;
application. In certain circumstances however, the application may wish&lt;br /&gt;
to participate in MAP assembly, for example to associate a sequence of&lt;br /&gt;
requests via the RelatesTo header. This demo illustrates both implicit&lt;br /&gt;
and explicit MAP propagation.&lt;br /&gt;
This demo also illustrates usage of the decoupled HTTP transport, whereby&lt;br /&gt;
a seperate server-&amp;gt;client HTTP connection is used to deliver the responses.&lt;br /&gt;
Note the normal HTTP mode (where the response is delivered on the back-&lt;br /&gt;
channel of the original client-&amp;gt;server HTTP connection) may of course also&lt;br /&gt;
be used  with WS-Addressing; in this case the &amp;lt;wsa:ReplyTo&amp;gt; header is set to&lt;br /&gt;
a well-known anonymous URI, &amp;quot;http://www.w3.org/2005/08/addressing/anonymous&amp;quot;.&lt;br /&gt;
In all other respects this demo is based on the basic hello_world sample,&lt;br /&gt;
illustrating that WS-Addressing usage is independent of the application.&lt;br /&gt;
One notable addition to the familiar hello_world WSDL is the usage&lt;br /&gt;
of the &amp;lt;wsaw:UsingAddressing&amp;gt; extension element to indicate the&lt;br /&gt;
WS-Addressing support is enabled for the service endpoint.&lt;br /&gt;
Please review the README in the samples directory before continuing.&lt;br /&gt;
&lt;br /&gt;
Prerequisite&lt;br /&gt;
------------&lt;br /&gt;
If your environment already includes cxf-manifest-incubator.jar on the CLASSPATH,&lt;br /&gt;
and the JDK and ant bin directories on the PATH, it is not necessary to&lt;br /&gt;
run the environment script described in the samples directory README.&lt;br /&gt;
If your environment is not properly configured, or if you are planning&lt;br /&gt;
on using wsdl2java, javac, and java to build and run the demos, you must&lt;br /&gt;
set the environment by running the script.&lt;br /&gt;
&lt;br /&gt;
Building and running the demo using ant&lt;br /&gt;
---------------------------------------&lt;br /&gt;
From the samples/ws_addressing directory, the ant build script can be used to&lt;br /&gt;
build and run the demo.  The server and client targets automatically build&lt;br /&gt;
the demo.&lt;br /&gt;
Using either UNIX or Windows:&lt;br /&gt;
  ant server&lt;br /&gt;
  ant client&lt;br /&gt;
Both client and server will use the MAPAggregator and MAPCodec&lt;br /&gt;
handlers to aggregate and encode the WS-Addressing MAPs.&lt;br /&gt;
To remove the code generated from the WSDL file and the .class&lt;br /&gt;
files, run:&lt;br /&gt;
  ant clean&lt;br /&gt;
&lt;br /&gt;
Buildng the demo using wsdl2java and javac&lt;br /&gt;
------------------------------------------&lt;br /&gt;
From the samples/ws_addressing directory, first create the target directory&lt;br /&gt;
build/classes and then generate code from the WSDL file.&lt;br /&gt;
For UNIX:&lt;br /&gt;
  mkdir -p build/classes&lt;br /&gt;
  wsdl2java -d build/classes -compile ./wsdl/hello_world_addr.wsdl&lt;br /&gt;
For Windows:&lt;br /&gt;
  mkdir build\classes&lt;br /&gt;
    Must use back slashes.&lt;br /&gt;
  wsdl2java -d build\classes -compile .\wsdl\hello_world_addr.wsdl&lt;br /&gt;
    May use either forward or back slashes.&lt;br /&gt;
Now compile the provided client and server applications with the commands:&lt;br /&gt;
For UNIX:  &lt;br /&gt;
  &lt;br /&gt;
  export CLASSPATH=$CLASSPATH:$CXF_HOME/lib/cxf-manifest-incubator.jar:./build/classes:.&lt;br /&gt;
  javac -d build/classes src/demo/ws_addressing/common/*.java&lt;br /&gt;
  javac -d build/classes src/demo/ws_addressing/client/*.java&lt;br /&gt;
  javac -d build/classes src/demo/ws_addressing/server/*.java&lt;br /&gt;
For Windows:&lt;br /&gt;
  set classpath=%classpath%;%CXF_HOME%\lib\cxf-manifest-incubator.jar;.\build\classes;.&lt;br /&gt;
  javac -d build\classes src\demo\ws_addressing\common\*.java&lt;br /&gt;
  javac -d build\classes src\demo\ws_addressing\client\*.java&lt;br /&gt;
  javac -d build\classes src\demo\ws_addressing\server\*.java&lt;br /&gt;
Running the demo using java&lt;br /&gt;
---------------------------&lt;br /&gt;
From the samples/ws_addressing directory run the commands (entered on a single command line):&lt;br /&gt;
For UNIX (must use forward slashes):&lt;br /&gt;
    java -Djava.util.logging.config.file=./logging.properties&lt;br /&gt;
         -Dcxf.config.file=server.xml&lt;br /&gt;
         demo.ws_addressing.server.Server &amp;amp;&lt;br /&gt;
    java -Djava.util.logging.config.file=./logging.properties&lt;br /&gt;
         -Dcxf.config.file=client.xml&lt;br /&gt;
         demo.ws_addressing.client.Client ./wsdl/hello_world_addr.wsdl&lt;br /&gt;
The server process starts in the background.&lt;br /&gt;
For Windows (may use either forward or back slashes):&lt;br /&gt;
  start &lt;br /&gt;
    java -Djava.util.logging.config.file=.\logging.properties&lt;br /&gt;
         -Dcxf.config.file=server.xml&lt;br /&gt;
         demo.ws_addressing.server.Server&lt;br /&gt;
    java -Djava.util.logging.config.file=.\logging.properties&lt;br /&gt;
         -Dcxf.config.file=client.xml&lt;br /&gt;
         demo.ws_addressing.client.Client .\wsdl\hello_world_addr.wsdl&lt;br /&gt;
The server process starts in a new command window.&lt;br /&gt;
After running the client, terminate the server process.&lt;br /&gt;
To remove the code generated from the WSDL file and the .class&lt;br /&gt;
files, either delete the build directory and its contents or run:&lt;br /&gt;
  ant clean&lt;br /&gt;
&lt;br /&gt;
        &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;/div&gt;</summary>
		<author><name>Admin</name></author>	</entry>

	<entry>
		<id>http://jexp.ru/index.php?title=Java/Generics/Generic_Method&amp;diff=9185</id>
		<title>Java/Generics/Generic Method</title>
		<link rel="alternate" type="text/html" href="http://jexp.ru/index.php?title=Java/Generics/Generic_Method&amp;diff=9185"/>
				<updated>2010-06-01T07:27:27Z</updated>
		
		<summary type="html">&lt;p&gt;Admin: 1 версия&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Demonstrate a simple generic method. ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
/*&lt;br /&gt;
Java 2, v5.0 (Tiger) New Features&lt;br /&gt;
by Herbert Schildt&lt;br /&gt;
ISBN: 0072258543&lt;br /&gt;
Publisher: McGraw-Hill/Osborne, 2004&lt;br /&gt;
*/&lt;br /&gt;
 &lt;br /&gt;
public class GenMethDemo {  &lt;br /&gt;
 &lt;br /&gt;
  // Determine if an object is in an array. &lt;br /&gt;
  static &amp;lt;T, V extends T&amp;gt; boolean isIn(T x, V[] y) { &lt;br /&gt;
 &lt;br /&gt;
    for(int i=0; i &amp;lt; y.length; i++) &lt;br /&gt;
      if(x.equals(y[i])) return true; &lt;br /&gt;
 &lt;br /&gt;
    return false; &lt;br /&gt;
  } &lt;br /&gt;
 &lt;br /&gt;
  public static void main(String args[]) {  &lt;br /&gt;
 &lt;br /&gt;
    // Use isIn() on Integers. &lt;br /&gt;
    Integer nums[] = { 1, 2, 3, 4, 5 }; &lt;br /&gt;
 &lt;br /&gt;
    if(isIn(2, nums)) &lt;br /&gt;
      System.out.println(&amp;quot;2 is in nums&amp;quot;); &lt;br /&gt;
 &lt;br /&gt;
    if(!isIn(7, nums)) &lt;br /&gt;
      System.out.println(&amp;quot;7 is not in nums&amp;quot;); &lt;br /&gt;
 &lt;br /&gt;
    System.out.println(); &lt;br /&gt;
 &lt;br /&gt;
    // Use isIn() on Strings. &lt;br /&gt;
    String strs[] = { &amp;quot;one&amp;quot;, &amp;quot;two&amp;quot;, &amp;quot;three&amp;quot;, &lt;br /&gt;
                      &amp;quot;four&amp;quot;, &amp;quot;five&amp;quot; }; &lt;br /&gt;
 &lt;br /&gt;
    if(isIn(&amp;quot;two&amp;quot;, strs)) &lt;br /&gt;
      System.out.println(&amp;quot;two is in strs&amp;quot;); &lt;br /&gt;
 &lt;br /&gt;
    if(!isIn(&amp;quot;seven&amp;quot;, strs)) &lt;br /&gt;
      System.out.println(&amp;quot;seven is not in strs&amp;quot;); &lt;br /&gt;
 &lt;br /&gt;
    // Opps! Won&amp;quot;t compile! Types must be compatible. &lt;br /&gt;
//    if(isIn(&amp;quot;two&amp;quot;, nums)) &lt;br /&gt;
//      System.out.println(&amp;quot;two is in strs&amp;quot;); &lt;br /&gt;
  }  &lt;br /&gt;
}&lt;br /&gt;
           &lt;br /&gt;
       &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Java generic: Ambiguity caused by erasure on overloaded methods.  ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
/*&lt;br /&gt;
Java 2, v5.0 (Tiger) New Features&lt;br /&gt;
by Herbert Schildt&lt;br /&gt;
ISBN: 0072258543&lt;br /&gt;
Publisher: McGraw-Hill/Osborne, 2004&lt;br /&gt;
*/&lt;br /&gt;
class MyGenClass&amp;lt;T, V&amp;gt; {  &lt;br /&gt;
  T ob1;  &lt;br /&gt;
  V ob2;  &lt;br /&gt;
 &lt;br /&gt;
  // ... &lt;br /&gt;
 &lt;br /&gt;
  // These two overloaded methods are ambiguous.  &lt;br /&gt;
  // and will not compile. &lt;br /&gt;
  void set(T o) { &lt;br /&gt;
    ob1 = o; &lt;br /&gt;
  } &lt;br /&gt;
 &lt;br /&gt;
  void set(V o) { &lt;br /&gt;
    ob2 = o; &lt;br /&gt;
  } &lt;br /&gt;
}&lt;br /&gt;
// Can&amp;quot;t create an instance of T. &lt;br /&gt;
class Gen&amp;lt;T&amp;gt; {  &lt;br /&gt;
  T ob;  &lt;br /&gt;
  Gen() {  &lt;br /&gt;
    ob = new T(); // Illegal!!! &lt;br /&gt;
  }  &lt;br /&gt;
} &lt;br /&gt;
public class Wrong&amp;lt;T&amp;gt; {  &lt;br /&gt;
  // Wrong, no static variables of type T. &lt;br /&gt;
  static T ob; &lt;br /&gt;
    &lt;br /&gt;
  // Wrong, no static method can use T. &lt;br /&gt;
  static T getob() { &lt;br /&gt;
    return ob; &lt;br /&gt;
  } &lt;br /&gt;
 &lt;br /&gt;
  // Wrong, no static method can access object &lt;br /&gt;
  // of type T. &lt;br /&gt;
  static void showob() { &lt;br /&gt;
    System.out.println(ob); &lt;br /&gt;
 } &lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
           &lt;br /&gt;
       &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Java generic: A situation that creates a bridge method. ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
/*&lt;br /&gt;
Java 2, v5.0 (Tiger) New Features&lt;br /&gt;
by Herbert Schildt&lt;br /&gt;
ISBN: 0072258543&lt;br /&gt;
Publisher: McGraw-Hill/Osborne, 2004&lt;br /&gt;
*/&lt;br /&gt;
//  &lt;br /&gt;
class Gen&amp;lt;T&amp;gt; {  &lt;br /&gt;
  T ob; // declare an object of type T  &lt;br /&gt;
    &lt;br /&gt;
  // Pass the constructor a reference to   &lt;br /&gt;
  // an object of type T.  &lt;br /&gt;
  Gen(T o) {  &lt;br /&gt;
    ob = o;  &lt;br /&gt;
  }  &lt;br /&gt;
  &lt;br /&gt;
  // Return ob.  &lt;br /&gt;
  T getob() {  &lt;br /&gt;
    return ob;  &lt;br /&gt;
  }  &lt;br /&gt;
}  &lt;br /&gt;
 &lt;br /&gt;
// A subclass of Gen. &lt;br /&gt;
class Gen2 extends Gen&amp;lt;String&amp;gt; { &lt;br /&gt;
 &lt;br /&gt;
  Gen2(String o) { &lt;br /&gt;
    super(o); &lt;br /&gt;
  } &lt;br /&gt;
 &lt;br /&gt;
  // A String-specific override of getob(). &lt;br /&gt;
  String getob() { &lt;br /&gt;
    System.out.print(&amp;quot;You called String getob(): &amp;quot;); &lt;br /&gt;
    return ob; &lt;br /&gt;
  } &lt;br /&gt;
} &lt;br /&gt;
  &lt;br /&gt;
// Demonstrate a situation that requires a bridge method. &lt;br /&gt;
public class BridgeDemo {  &lt;br /&gt;
  public static void main(String args[]) {  &lt;br /&gt;
 &lt;br /&gt;
    // Create a Gen2 object for Strings. &lt;br /&gt;
    Gen2 strOb2 = new Gen2(&amp;quot;Generics Test&amp;quot;);  &lt;br /&gt;
 &lt;br /&gt;
    System.out.println(strOb2.getob()); &lt;br /&gt;
  }  &lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
           &lt;br /&gt;
       &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Overriding a generic method in a generic class.  ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
/*&lt;br /&gt;
Java 2, v5.0 (Tiger) New Features&lt;br /&gt;
by Herbert Schildt&lt;br /&gt;
ISBN: 0072258543&lt;br /&gt;
Publisher: McGraw-Hill/Osborne, 2004&lt;br /&gt;
*/&lt;br /&gt;
class Gen&amp;lt;T&amp;gt; {  &lt;br /&gt;
  T ob; // declare an object of type T  &lt;br /&gt;
    &lt;br /&gt;
  // Pass the constructor a reference to   &lt;br /&gt;
  // an object of type T.  &lt;br /&gt;
  Gen(T o) {  &lt;br /&gt;
    ob = o;  &lt;br /&gt;
  }  &lt;br /&gt;
  &lt;br /&gt;
  // Return ob.  &lt;br /&gt;
  T getob() {  &lt;br /&gt;
    System.out.print(&amp;quot;Gen&amp;quot;s getob(): &amp;quot; ); &lt;br /&gt;
    return ob;  &lt;br /&gt;
  }  &lt;br /&gt;
}  &lt;br /&gt;
 &lt;br /&gt;
// A subclass of Gen that overrides getob(). &lt;br /&gt;
class Gen2&amp;lt;T&amp;gt; extends Gen&amp;lt;T&amp;gt; { &lt;br /&gt;
 &lt;br /&gt;
  Gen2(T o) { &lt;br /&gt;
    super(o); &lt;br /&gt;
  } &lt;br /&gt;
   &lt;br /&gt;
  // Override getob(). &lt;br /&gt;
  T getob() {  &lt;br /&gt;
    System.out.print(&amp;quot;Gen2&amp;quot;s getob(): &amp;quot;); &lt;br /&gt;
    return ob;  &lt;br /&gt;
  }  &lt;br /&gt;
} &lt;br /&gt;
  &lt;br /&gt;
// Demonstrate generic method override. &lt;br /&gt;
public class OverrideDemo {  &lt;br /&gt;
  public static void main(String args[]) {  &lt;br /&gt;
    &lt;br /&gt;
    // Create a Gen object for Integers. &lt;br /&gt;
    Gen&amp;lt;Integer&amp;gt; iOb = new Gen&amp;lt;Integer&amp;gt;(88); &lt;br /&gt;
 &lt;br /&gt;
    // Create a Gen2 object for Integers. &lt;br /&gt;
    Gen2&amp;lt;Integer&amp;gt; iOb2 = new Gen2&amp;lt;Integer&amp;gt;(99);  &lt;br /&gt;
   &lt;br /&gt;
    // Create a Gen2 object for Strings. &lt;br /&gt;
    Gen2&amp;lt;String&amp;gt; strOb2 = new Gen2&amp;lt;String&amp;gt;(&amp;quot;Generics Test&amp;quot;);  &lt;br /&gt;
 &lt;br /&gt;
    System.out.println(iOb.getob()); &lt;br /&gt;
    System.out.println(iOb2.getob()); &lt;br /&gt;
    System.out.println(strOb2.getob()); &lt;br /&gt;
  }  &lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
           &lt;br /&gt;
       &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Return generic value from method ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
import java.io.Serializable;&lt;br /&gt;
class Base {&lt;br /&gt;
}&lt;br /&gt;
class Sub1 extends Base implements Serializable {&lt;br /&gt;
  public void run() {&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
class Sub2 extends Base implements Serializable {&lt;br /&gt;
  public void run() {&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
public class TypeInference {&lt;br /&gt;
  static &amp;lt;T extends Base&amp;gt; T infer(T t1, T t2) {&lt;br /&gt;
    return null;&lt;br /&gt;
  }&lt;br /&gt;
  public static void main(String[] args) {&lt;br /&gt;
    Base base = infer(new Sub1(), new Sub2());&lt;br /&gt;
    Serializable runnable = infer(new Sub1(), new Sub2());&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
 &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;/div&gt;</summary>
		<author><name>Admin</name></author>	</entry>

	<entry>
		<id>http://jexp.ru/index.php?title=Java/Generics/Constraints&amp;diff=9183</id>
		<title>Java/Generics/Constraints</title>
		<link rel="alternate" type="text/html" href="http://jexp.ru/index.php?title=Java/Generics/Constraints&amp;diff=9183"/>
				<updated>2010-06-01T07:27:26Z</updated>
		
		<summary type="html">&lt;p&gt;Admin: 1 версия&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Bounded Wildcard arguments. ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
   &lt;br /&gt;
class TwoD {&lt;br /&gt;
  int x, y;&lt;br /&gt;
  TwoD(int a, int b) {&lt;br /&gt;
    x = a;&lt;br /&gt;
    y = b;&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
class ThreeD extends TwoD {&lt;br /&gt;
  int z;&lt;br /&gt;
  ThreeD(int a, int b, int c) {&lt;br /&gt;
    super(a, b);&lt;br /&gt;
    z = c;&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
class FourD extends ThreeD {&lt;br /&gt;
  int t;&lt;br /&gt;
  FourD(int a, int b, int c, int d) {&lt;br /&gt;
    super(a, b, c);&lt;br /&gt;
    t = d;&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
class Coords&amp;lt;T extends TwoD&amp;gt; {&lt;br /&gt;
  T[] coords;&lt;br /&gt;
  Coords(T[] o) {&lt;br /&gt;
    coords = o;&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
class BoundedWildcard {&lt;br /&gt;
  static void showXY(Coords&amp;lt;?&amp;gt; c) {&lt;br /&gt;
    System.out.println(&amp;quot;X Y Coordinates:&amp;quot;);&lt;br /&gt;
    for (int i = 0; i &amp;lt; c.coords.length; i++)&lt;br /&gt;
      System.out.println(c.coords[i].x + &amp;quot; &amp;quot; + c.coords[i].y);&lt;br /&gt;
    System.out.println();&lt;br /&gt;
  }&lt;br /&gt;
  static void showXYZ(Coords&amp;lt;? extends ThreeD&amp;gt; c) {&lt;br /&gt;
    System.out.println(&amp;quot;X Y Z Coordinates:&amp;quot;);&lt;br /&gt;
    for (int i = 0; i &amp;lt; c.coords.length; i++)&lt;br /&gt;
      System.out.println(c.coords[i].x + &amp;quot; &amp;quot; + c.coords[i].y + &amp;quot; &amp;quot; + c.coords[i].z);&lt;br /&gt;
    System.out.println();&lt;br /&gt;
  }&lt;br /&gt;
  static void showAll(Coords&amp;lt;? extends FourD&amp;gt; c) {&lt;br /&gt;
    System.out.println(&amp;quot;X Y Z T Coordinates:&amp;quot;);&lt;br /&gt;
    for (int i = 0; i &amp;lt; c.coords.length; i++)&lt;br /&gt;
      System.out.println(c.coords[i].x + &amp;quot; &amp;quot; + c.coords[i].y + &amp;quot; &amp;quot; + c.coords[i].z + &amp;quot; &amp;quot;&lt;br /&gt;
          + c.coords[i].t);&lt;br /&gt;
    System.out.println();&lt;br /&gt;
  }&lt;br /&gt;
  public static void main(String args[]) {&lt;br /&gt;
    TwoD td[] = { new TwoD(0, 0), new TwoD(7, 9), new TwoD(18, 4), new TwoD(-1, -23) };&lt;br /&gt;
    Coords&amp;lt;TwoD&amp;gt; tdlocs = new Coords&amp;lt;TwoD&amp;gt;(td);&lt;br /&gt;
    System.out.println(&amp;quot;Contents of tdlocs.&amp;quot;);&lt;br /&gt;
    showXY(tdlocs); // OK, is a TwoD&lt;br /&gt;
    FourD fd[] = { new FourD(1, 2, 3, 4), new FourD(6, 8, 14, 8), new FourD(22, 9, 4, 9),&lt;br /&gt;
        new FourD(3, -2, -23, 17) };&lt;br /&gt;
    Coords&amp;lt;FourD&amp;gt; fdlocs = new Coords&amp;lt;FourD&amp;gt;(fd);&lt;br /&gt;
    System.out.println(&amp;quot;Contents of fdlocs.&amp;quot;);&lt;br /&gt;
    // These are all OK.&lt;br /&gt;
    showXY(fdlocs);&lt;br /&gt;
    showXYZ(fdlocs);&lt;br /&gt;
    showAll(fdlocs);&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Generic cast ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
/*&lt;br /&gt;
 * Copyright (C) 2001-2003 Colin Bell&lt;br /&gt;
 * colbell@users.sourceforge.net&lt;br /&gt;
 *&lt;br /&gt;
 * This library is free software; you can redistribute it and/or&lt;br /&gt;
 * modify it under the terms of the GNU Lesser General Public&lt;br /&gt;
 * License as published by the Free Software Foundation; either&lt;br /&gt;
 * version 2.1 of the License, or (at your option) any later version.&lt;br /&gt;
 *&lt;br /&gt;
 * This library is distributed in the hope that it will be useful,&lt;br /&gt;
 * but WITHOUT ANY WARRANTY; without even the implied warranty of&lt;br /&gt;
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU&lt;br /&gt;
 * Lesser General Public License for more details.&lt;br /&gt;
 *&lt;br /&gt;
 * You should have received a copy of the GNU Lesser General Public&lt;br /&gt;
 * License along with this library; if not, write to the Free Software&lt;br /&gt;
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA&lt;br /&gt;
 */&lt;br /&gt;
import java.io.*;&lt;br /&gt;
import java.text.NumberFormat;&lt;br /&gt;
import java.util.regex.Matcher;&lt;br /&gt;
import java.util.regex.Pattern;&lt;br /&gt;
/**&lt;br /&gt;
 * General purpose utilities functions.&lt;br /&gt;
 *&lt;br /&gt;
 * @author &lt;br /&gt;
 */&lt;br /&gt;
public class Utilities&lt;br /&gt;
{&lt;br /&gt;
  &lt;br /&gt;
  /**&lt;br /&gt;
  * This is taken from Eammon McManus&amp;quot; blog:&lt;br /&gt;
  * http://weblogs.java.net/blog/emcmanus/archive/2007/03/getting_rid_of.html This prevents you from having&lt;br /&gt;
  * to place SuppressWarnings throughout your code.&lt;br /&gt;
  * &lt;br /&gt;
  * @param &amp;lt;T&amp;gt;&lt;br /&gt;
  *           the return type to cast the object to&lt;br /&gt;
  * @param x&lt;br /&gt;
  *           the object to cast.&lt;br /&gt;
  * @return a type-casted version of the specified object.&lt;br /&gt;
  */&lt;br /&gt;
 @SuppressWarnings(&amp;quot;unchecked&amp;quot;)&lt;br /&gt;
 public static &amp;lt;T&amp;gt; T cast(Object x) {&lt;br /&gt;
     return (T) x;&lt;br /&gt;
 }&lt;br /&gt;
}&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Java generic: Bounded Wildcard arguments ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
/*&lt;br /&gt;
Java 2, v5.0 (Tiger) New Features&lt;br /&gt;
by Herbert Schildt&lt;br /&gt;
ISBN: 0072258543&lt;br /&gt;
Publisher: McGraw-Hill/Osborne, 2004&lt;br /&gt;
*/&lt;br /&gt;
 &lt;br /&gt;
// Two-dimensional coordinates. &lt;br /&gt;
class TwoD { &lt;br /&gt;
  int x, y; &lt;br /&gt;
 &lt;br /&gt;
  TwoD(int a, int b) { &lt;br /&gt;
    x = a; &lt;br /&gt;
    y = b; &lt;br /&gt;
  } &lt;br /&gt;
} &lt;br /&gt;
 &lt;br /&gt;
// Three-dimensional coordinates. &lt;br /&gt;
class ThreeD extends TwoD { &lt;br /&gt;
  int z; &lt;br /&gt;
   &lt;br /&gt;
  ThreeD(int a, int b, int c) { &lt;br /&gt;
    super(a, b); &lt;br /&gt;
    z = c; &lt;br /&gt;
  } &lt;br /&gt;
} &lt;br /&gt;
 &lt;br /&gt;
// Four-dimensional coordinates. &lt;br /&gt;
class FourD extends ThreeD { &lt;br /&gt;
  int t; &lt;br /&gt;
 &lt;br /&gt;
  FourD(int a, int b, int c, int d) { &lt;br /&gt;
    super(a, b, c); &lt;br /&gt;
    t = d;  &lt;br /&gt;
  } &lt;br /&gt;
} &lt;br /&gt;
 &lt;br /&gt;
// This class holds an array of coordinate objects. &lt;br /&gt;
class Coords&amp;lt;T extends TwoD&amp;gt; { &lt;br /&gt;
  T[] coords; &lt;br /&gt;
 &lt;br /&gt;
  Coords(T[] o) { coords = o; } &lt;br /&gt;
} &lt;br /&gt;
 &lt;br /&gt;
// Demonstrate a bounded wildcard. &lt;br /&gt;
public class BoundedWildcard { &lt;br /&gt;
  static void showXY(Coords&amp;lt;?&amp;gt; c) { &lt;br /&gt;
    System.out.println(&amp;quot;X Y Coordinates:&amp;quot;); &lt;br /&gt;
    for(int i=0; i &amp;lt; c.coords.length; i++) &lt;br /&gt;
      System.out.println(c.coords[i].x + &amp;quot; &amp;quot; + &lt;br /&gt;
                         c.coords[i].y); &lt;br /&gt;
    System.out.println(); &lt;br /&gt;
  } &lt;br /&gt;
 &lt;br /&gt;
  static void showXYZ(Coords&amp;lt;? extends ThreeD&amp;gt; c) { &lt;br /&gt;
    System.out.println(&amp;quot;X Y Z Coordinates:&amp;quot;); &lt;br /&gt;
    for(int i=0; i &amp;lt; c.coords.length; i++) &lt;br /&gt;
      System.out.println(c.coords[i].x + &amp;quot; &amp;quot; + &lt;br /&gt;
                         c.coords[i].y + &amp;quot; &amp;quot; + &lt;br /&gt;
                         c.coords[i].z); &lt;br /&gt;
    System.out.println(); &lt;br /&gt;
  } &lt;br /&gt;
 &lt;br /&gt;
  static void showAll(Coords&amp;lt;? extends FourD&amp;gt; c) { &lt;br /&gt;
    System.out.println(&amp;quot;X Y Z T Coordinates:&amp;quot;); &lt;br /&gt;
    for(int i=0; i &amp;lt; c.coords.length; i++) &lt;br /&gt;
      System.out.println(c.coords[i].x + &amp;quot; &amp;quot; + &lt;br /&gt;
                         c.coords[i].y + &amp;quot; &amp;quot; + &lt;br /&gt;
                         c.coords[i].z + &amp;quot; &amp;quot; + &lt;br /&gt;
                         c.coords[i].t); &lt;br /&gt;
    System.out.println(); &lt;br /&gt;
  } &lt;br /&gt;
 &lt;br /&gt;
  public static void main(String args[]) { &lt;br /&gt;
    TwoD td[] = { &lt;br /&gt;
      new TwoD(0, 0), &lt;br /&gt;
      new TwoD(7, 9), &lt;br /&gt;
      new TwoD(18, 4), &lt;br /&gt;
      new TwoD(-1, -23) &lt;br /&gt;
    }; &lt;br /&gt;
 &lt;br /&gt;
    Coords&amp;lt;TwoD&amp;gt; tdlocs = new Coords&amp;lt;TwoD&amp;gt;(td);     &lt;br /&gt;
 &lt;br /&gt;
    System.out.println(&amp;quot;Contents of tdlocs.&amp;quot;); &lt;br /&gt;
    showXY(tdlocs); // OK, is a TwoD &lt;br /&gt;
//  showXYZ(tdlocs); // Error, not a ThreeD &lt;br /&gt;
//  showAll(tdlocs); // Erorr, not a FourD &lt;br /&gt;
 &lt;br /&gt;
    // Now, create some FourD objects. &lt;br /&gt;
    FourD fd[] = { &lt;br /&gt;
      new FourD(1, 2, 3, 4), &lt;br /&gt;
      new FourD(6, 8, 14, 8), &lt;br /&gt;
      new FourD(22, 9, 4, 9), &lt;br /&gt;
      new FourD(3, -2, -23, 17) &lt;br /&gt;
    }; &lt;br /&gt;
 &lt;br /&gt;
    Coords&amp;lt;FourD&amp;gt; fdlocs = new Coords&amp;lt;FourD&amp;gt;(fd);     &lt;br /&gt;
 &lt;br /&gt;
    System.out.println(&amp;quot;Contents of fdlocs.&amp;quot;); &lt;br /&gt;
    // These are all OK. &lt;br /&gt;
    showXY(fdlocs);  &lt;br /&gt;
    showXYZ(fdlocs); &lt;br /&gt;
    showAll(fdlocs); &lt;br /&gt;
  } &lt;br /&gt;
}&lt;br /&gt;
           &lt;br /&gt;
         &lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Java generic: Use a wildcard. ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
/*&lt;br /&gt;
Java 2, v5.0 (Tiger) New Features&lt;br /&gt;
by Herbert Schildt&lt;br /&gt;
ISBN: 0072258543&lt;br /&gt;
Publisher: McGraw-Hill/Osborne, 2004&lt;br /&gt;
*/&lt;br /&gt;
&lt;br /&gt;
class Stats&amp;lt;T extends Number&amp;gt; {   &lt;br /&gt;
  T[] nums; // array of Number or subclass  &lt;br /&gt;
     &lt;br /&gt;
  // Pass the constructor a reference to    &lt;br /&gt;
  // an array of type Number or subclass.  &lt;br /&gt;
  Stats(T[] o) {   &lt;br /&gt;
    nums = o;   &lt;br /&gt;
  }   &lt;br /&gt;
   &lt;br /&gt;
  // Return type double in all cases.  &lt;br /&gt;
  double average() {   &lt;br /&gt;
    double sum = 0.0;  &lt;br /&gt;
  &lt;br /&gt;
    for(int i=0; i &amp;lt; nums.length; i++)   &lt;br /&gt;
      sum += nums[i].doubleValue();  &lt;br /&gt;
  &lt;br /&gt;
    return sum / nums.length;  &lt;br /&gt;
  } &lt;br /&gt;
 &lt;br /&gt;
  // Determine if two averages are the same. &lt;br /&gt;
  // Notice the use of the wildcard. &lt;br /&gt;
  boolean sameAvg(Stats&amp;lt;?&amp;gt; ob) { &lt;br /&gt;
    if(average() == ob.average())  &lt;br /&gt;
      return true; &lt;br /&gt;
 &lt;br /&gt;
    return false; &lt;br /&gt;
  } &lt;br /&gt;
}   &lt;br /&gt;
   &lt;br /&gt;
// Demonstrate wildcard. &lt;br /&gt;
public class WildcardDemo {   &lt;br /&gt;
  public static void main(String args[]) {   &lt;br /&gt;
    Integer inums[] = { 1, 2, 3, 4, 5 };  &lt;br /&gt;
    Stats&amp;lt;Integer&amp;gt; iob = new Stats&amp;lt;Integer&amp;gt;(inums);    &lt;br /&gt;
    double v = iob.average();  &lt;br /&gt;
    System.out.println(&amp;quot;iob average is &amp;quot; + v);  &lt;br /&gt;
  &lt;br /&gt;
    Double dnums[] = { 1.1, 2.2, 3.3, 4.4, 5.5 };  &lt;br /&gt;
    Stats&amp;lt;Double&amp;gt; dob = new Stats&amp;lt;Double&amp;gt;(dnums);    &lt;br /&gt;
    double w = dob.average();  &lt;br /&gt;
    System.out.println(&amp;quot;dob average is &amp;quot; + w);  &lt;br /&gt;
  &lt;br /&gt;
    Float fnums[] = { 1.0F, 2.0F, 3.0F, 4.0F, 5.0F };  &lt;br /&gt;
    Stats&amp;lt;Float&amp;gt; fob = new Stats&amp;lt;Float&amp;gt;(fnums);    &lt;br /&gt;
    double x = fob.average();  &lt;br /&gt;
    System.out.println(&amp;quot;fob average is &amp;quot; + x);  &lt;br /&gt;
  &lt;br /&gt;
    // See which arrays have same average. &lt;br /&gt;
    System.out.print(&amp;quot;Averages of iob and dob &amp;quot;); &lt;br /&gt;
    if(iob.sameAvg(dob)) &lt;br /&gt;
      System.out.println(&amp;quot;are the same.&amp;quot;);  &lt;br /&gt;
    else &lt;br /&gt;
      System.out.println(&amp;quot;differ.&amp;quot;);  &lt;br /&gt;
 &lt;br /&gt;
    System.out.print(&amp;quot;Averages of iob and fob &amp;quot;); &lt;br /&gt;
    if(iob.sameAvg(fob)) &lt;br /&gt;
      System.out.println(&amp;quot;are the same.&amp;quot;);  &lt;br /&gt;
    else &lt;br /&gt;
      System.out.println(&amp;quot;differ.&amp;quot;);  &lt;br /&gt;
  }   &lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
           &lt;br /&gt;
         &lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Use a wildcard. ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
class Stats&amp;lt;T extends Number&amp;gt; {&lt;br /&gt;
  T[] nums;&lt;br /&gt;
  Stats(T[] o) {&lt;br /&gt;
    nums = o;&lt;br /&gt;
  }&lt;br /&gt;
  double average() {&lt;br /&gt;
    double sum = 0.0;&lt;br /&gt;
    for (int i = 0; i &amp;lt; nums.length; i++)&lt;br /&gt;
      sum += nums[i].doubleValue();&lt;br /&gt;
    return sum / nums.length;&lt;br /&gt;
  }&lt;br /&gt;
  boolean sameAvg(Stats&amp;lt;?&amp;gt; ob) {&lt;br /&gt;
    if (average() == ob.average())&lt;br /&gt;
      return true;&lt;br /&gt;
    return false;&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
class WildcardDemo {&lt;br /&gt;
  public static void main(String args[]) {&lt;br /&gt;
    Integer inums[] = { 1, 2, 3, 4, 5 };&lt;br /&gt;
    Stats&amp;lt;Integer&amp;gt; iob = new Stats&amp;lt;Integer&amp;gt;(inums);&lt;br /&gt;
    double v = iob.average();&lt;br /&gt;
    System.out.println(&amp;quot;iob average is &amp;quot; + v);&lt;br /&gt;
    Double dnums[] = { 1.1, 2.2, 3.3, 4.4, 5.5 };&lt;br /&gt;
    Stats&amp;lt;Double&amp;gt; dob = new Stats&amp;lt;Double&amp;gt;(dnums);&lt;br /&gt;
    double w = dob.average();&lt;br /&gt;
    System.out.println(&amp;quot;dob average is &amp;quot; + w);&lt;br /&gt;
    Float fnums[] = { 1.0F, 2.0F, 3.0F, 4.0F, 5.0F };&lt;br /&gt;
    Stats&amp;lt;Float&amp;gt; fob = new Stats&amp;lt;Float&amp;gt;(fnums);&lt;br /&gt;
    double x = fob.average();&lt;br /&gt;
    System.out.println(&amp;quot;fob average is &amp;quot; + x);&lt;br /&gt;
    // See which arrays have same average.&lt;br /&gt;
    System.out.print(&amp;quot;Averages of iob and dob &amp;quot;);&lt;br /&gt;
    if (iob.sameAvg(dob))&lt;br /&gt;
      System.out.println(&amp;quot;are the same.&amp;quot;);&lt;br /&gt;
    else&lt;br /&gt;
      System.out.println(&amp;quot;differ.&amp;quot;);&lt;br /&gt;
    System.out.print(&amp;quot;Averages of iob and fob &amp;quot;);&lt;br /&gt;
    if (iob.sameAvg(fob))&lt;br /&gt;
      System.out.println(&amp;quot;are the same.&amp;quot;);&lt;br /&gt;
    else&lt;br /&gt;
      System.out.println(&amp;quot;differ.&amp;quot;);&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;/div&gt;</summary>
		<author><name>Admin</name></author>	</entry>

	<entry>
		<id>http://jexp.ru/index.php?title=Java/Generics/Generic_Parameter&amp;diff=9181</id>
		<title>Java/Generics/Generic Parameter</title>
		<link rel="alternate" type="text/html" href="http://jexp.ru/index.php?title=Java/Generics/Generic_Parameter&amp;diff=9181"/>
				<updated>2010-06-01T07:27:25Z</updated>
		
		<summary type="html">&lt;p&gt;Admin: 1 версия&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== A simple generic class with two type parameters: T and V. ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
class TwoGen&amp;lt;T, V&amp;gt; {&lt;br /&gt;
  T ob1;&lt;br /&gt;
  V ob2;&lt;br /&gt;
  TwoGen(T o1, V o2) {&lt;br /&gt;
    ob1 = o1;&lt;br /&gt;
    ob2 = o2;&lt;br /&gt;
  }&lt;br /&gt;
  void showTypes() {&lt;br /&gt;
    System.out.println(&amp;quot;Type of T is &amp;quot; + ob1.getClass().getName());&lt;br /&gt;
    System.out.println(&amp;quot;Type of V is &amp;quot; + ob2.getClass().getName());&lt;br /&gt;
  }&lt;br /&gt;
  T getob1() {&lt;br /&gt;
    return ob1;&lt;br /&gt;
  }&lt;br /&gt;
  V getob2() {&lt;br /&gt;
    return ob2;&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
public class SimpGen {&lt;br /&gt;
  public static void main(String args[]) {&lt;br /&gt;
    TwoGen&amp;lt;Integer, String&amp;gt; tgObj = new TwoGen&amp;lt;Integer, String&amp;gt;(88, &amp;quot;Generics&amp;quot;);&lt;br /&gt;
    tgObj.showTypes();&lt;br /&gt;
    int v = tgObj.getob1();&lt;br /&gt;
    System.out.println(&amp;quot;value: &amp;quot; + v);&lt;br /&gt;
    String str = tgObj.getob2();&lt;br /&gt;
    System.out.println(&amp;quot;value: &amp;quot; + str);&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
           &lt;br /&gt;
       &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== A subclass can add its own type parameters. ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
class Gen&amp;lt;T&amp;gt; {&lt;br /&gt;
  T ob; // declare an object of type T&lt;br /&gt;
  Gen(T o) {&lt;br /&gt;
    ob = o;&lt;br /&gt;
  }&lt;br /&gt;
  // Return ob.&lt;br /&gt;
  T getob() {&lt;br /&gt;
    return ob;&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
// A subclass of Gen that defines a second type parameter, called V.&lt;br /&gt;
class Gen2&amp;lt;T, V&amp;gt; extends Gen&amp;lt;T&amp;gt; {&lt;br /&gt;
  V ob2;&lt;br /&gt;
  Gen2(T o, V o2) {&lt;br /&gt;
    super(o);&lt;br /&gt;
    ob2 = o2;&lt;br /&gt;
  }&lt;br /&gt;
  V getob2() {&lt;br /&gt;
    return ob2;&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
class HierDemo {&lt;br /&gt;
  public static void main(String args[]) {&lt;br /&gt;
    Gen2&amp;lt;String, Integer&amp;gt; x = new Gen2&amp;lt;String, Integer&amp;gt;(&amp;quot;Value is: &amp;quot;, 99);&lt;br /&gt;
    System.out.print(x.getob());&lt;br /&gt;
    System.out.println(x.getob2());&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
 &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Boxing Generic Example ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
import java.util.*;&lt;br /&gt;
public class BoxingGenericsExample {&lt;br /&gt;
    public static void main(String args[])&lt;br /&gt;
    {&lt;br /&gt;
        HashMap&amp;lt;String,Integer&amp;gt; hm = new HashMap&amp;lt;String,Integer&amp;gt;();&lt;br /&gt;
        hm.put(&amp;quot;speed&amp;quot;, 20);&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
           &lt;br /&gt;
       &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Create a generic class that can compute the average of an array of numbers of any given type. ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
class Stats&amp;lt;T&amp;gt; {&lt;br /&gt;
  T[] nums;&lt;br /&gt;
  Stats(T[] o) {&lt;br /&gt;
    nums = o;&lt;br /&gt;
  }&lt;br /&gt;
  double average() {&lt;br /&gt;
    double sum = 0.0;&lt;br /&gt;
    for (int i = 0; i &amp;lt; nums.length; i++)&lt;br /&gt;
      sum += nums[i].doubleValue(); // Error!!!&lt;br /&gt;
    return sum / nums.length;&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
 &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Demonstrate a raw generic type.  ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
/*&lt;br /&gt;
Java 2, v5.0 (Tiger) New Features&lt;br /&gt;
by Herbert Schildt&lt;br /&gt;
ISBN: 0072258543&lt;br /&gt;
Publisher: McGraw-Hill/Osborne, 2004&lt;br /&gt;
*/&lt;br /&gt;
class Gen&amp;lt;T&amp;gt; {  &lt;br /&gt;
  T ob; // declare an object of type T  &lt;br /&gt;
    &lt;br /&gt;
  // Pass the constructor a reference to   &lt;br /&gt;
  // an object of type T.  &lt;br /&gt;
  Gen(T o) {  &lt;br /&gt;
    ob = o;  &lt;br /&gt;
  }  &lt;br /&gt;
  &lt;br /&gt;
  // Return ob.  &lt;br /&gt;
  T getob() {  &lt;br /&gt;
    return ob;  &lt;br /&gt;
  }  &lt;br /&gt;
}  &lt;br /&gt;
  &lt;br /&gt;
// Demonstrate raw type. &lt;br /&gt;
public class RawDemo {  &lt;br /&gt;
  public static void main(String args[]) {  &lt;br /&gt;
 &lt;br /&gt;
    // Create a Gen object for Integers. &lt;br /&gt;
    Gen&amp;lt;Integer&amp;gt; iOb = new Gen&amp;lt;Integer&amp;gt;(88);  &lt;br /&gt;
   &lt;br /&gt;
    // Create a Gen object for Strings. &lt;br /&gt;
    Gen&amp;lt;String&amp;gt; strOb = new Gen&amp;lt;String&amp;gt;(&amp;quot;Generics Test&amp;quot;);  &lt;br /&gt;
  &lt;br /&gt;
    // Create a raw-type Gen object and give it &lt;br /&gt;
    // a Double value. &lt;br /&gt;
    Gen raw = new Gen(new Double(98.6)); &lt;br /&gt;
 &lt;br /&gt;
    // Cast here is necessary because type is unknown. &lt;br /&gt;
    double d = (Double) raw.getob(); &lt;br /&gt;
    System.out.println(&amp;quot;value: &amp;quot; + d); &lt;br /&gt;
 &lt;br /&gt;
    // The use of a raw type can lead to runtime. &lt;br /&gt;
    // exceptions.  Here are some examples. &lt;br /&gt;
 &lt;br /&gt;
    // The following cast causes a runtime error! &lt;br /&gt;
//    int i = (Integer) raw.getob(); // runtime error &lt;br /&gt;
 &lt;br /&gt;
    // This assigment overrides type safety. &lt;br /&gt;
    strOb = raw; // OK, but potentially wrong &lt;br /&gt;
//    String str = strOb.getob(); // runtime error  &lt;br /&gt;
     &lt;br /&gt;
    // This assignment also overrides type safety. &lt;br /&gt;
    raw = iOb; // OK, but potentially wrong &lt;br /&gt;
//    d = (Double) raw.getob(); // runtime error &lt;br /&gt;
  }  &lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
           &lt;br /&gt;
       &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Demonstrate a raw type. ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
class Gen&amp;lt;T&amp;gt; {&lt;br /&gt;
  T ob; // declare an object of type T&lt;br /&gt;
  Gen(T o) {&lt;br /&gt;
    ob = o;&lt;br /&gt;
  }&lt;br /&gt;
  T getob() {&lt;br /&gt;
    return ob;&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
class RawDemo {&lt;br /&gt;
  public static void main(String args[]) {&lt;br /&gt;
    Gen&amp;lt;Integer&amp;gt; iOb = new Gen&amp;lt;Integer&amp;gt;(88);&lt;br /&gt;
    Gen&amp;lt;String&amp;gt; strOb = new Gen&amp;lt;String&amp;gt;(&amp;quot;Generics Test&amp;quot;);&lt;br /&gt;
    Gen raw = new Gen(new Double(98.6));&lt;br /&gt;
    double d = (Double) raw.getob();&lt;br /&gt;
    System.out.println(&amp;quot;value: &amp;quot; + d);&lt;br /&gt;
    strOb = raw; // OK, but potentially wrong&lt;br /&gt;
    raw = iOb; // OK, but potentially wrong&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
 &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Java generic: Hierarchy argument ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
class Stats&amp;lt;T extends Number&amp;gt; {&lt;br /&gt;
  T[] nums;&lt;br /&gt;
  Stats(T[] o) {&lt;br /&gt;
    nums = o;&lt;br /&gt;
  }&lt;br /&gt;
  double average() {&lt;br /&gt;
    double sum = 0.0;&lt;br /&gt;
    for (int i = 0; i &amp;lt; nums.length; i++)&lt;br /&gt;
      sum += nums[i].doubleValue();&lt;br /&gt;
    return sum / nums.length;&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
public class BoundsDemo {&lt;br /&gt;
  public static void main(String args[]) {&lt;br /&gt;
    Integer inums[] = { 1, 2, 3, 4, 5 };&lt;br /&gt;
    Stats&amp;lt;Integer&amp;gt; iob = new Stats&amp;lt;Integer&amp;gt;(inums);&lt;br /&gt;
    double v = iob.average();&lt;br /&gt;
    System.out.println(&amp;quot;iob average is &amp;quot; + v);&lt;br /&gt;
    Double dnums[] = { 1.1, 2.2, 3.3, 4.4, 5.5 };&lt;br /&gt;
    Stats&amp;lt;Double&amp;gt; dob = new Stats&amp;lt;Double&amp;gt;(dnums);&lt;br /&gt;
    double w = dob.average();&lt;br /&gt;
    System.out.println(&amp;quot;dob average is &amp;quot; + w);&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
          &lt;br /&gt;
       &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== the type argument for T must be either Number, or a class derived from Number. ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
class Stats&amp;lt;T extends Number&amp;gt; {&lt;br /&gt;
  T[] nums;&lt;br /&gt;
  Stats(T[] o) {&lt;br /&gt;
    nums = o;&lt;br /&gt;
  }&lt;br /&gt;
  double average() {&lt;br /&gt;
    double sum = 0.0;&lt;br /&gt;
    for (int i = 0; i &amp;lt; nums.length; i++)&lt;br /&gt;
      sum += nums[i].doubleValue();&lt;br /&gt;
    return sum / nums.length;&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
class BoundsDemo {&lt;br /&gt;
  public static void main(String args[]) {&lt;br /&gt;
    Integer inums[] = { 1, 2, 3, 4, 5 };&lt;br /&gt;
    Stats&amp;lt;Integer&amp;gt; iob = new Stats&amp;lt;Integer&amp;gt;(inums);&lt;br /&gt;
    double v = iob.average();&lt;br /&gt;
    System.out.println(&amp;quot;iob average is &amp;quot; + v);&lt;br /&gt;
    Double dnums[] = { 1.1, 2.2, 3.3, 4.4, 5.5 };&lt;br /&gt;
    Stats&amp;lt;Double&amp;gt; dob = new Stats&amp;lt;Double&amp;gt;(dnums);&lt;br /&gt;
    double w = dob.average();&lt;br /&gt;
    System.out.println(&amp;quot;dob average is &amp;quot; + w);&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
 &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== T is a type parameter that will be replaced by a real type when an object of type Gen is created. ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
class Gen&amp;lt;T&amp;gt; {&lt;br /&gt;
  T ob;&lt;br /&gt;
  Gen(T o) {&lt;br /&gt;
    ob = o;&lt;br /&gt;
  }&lt;br /&gt;
  T getob() {&lt;br /&gt;
    return ob;&lt;br /&gt;
  }&lt;br /&gt;
  void showType() {&lt;br /&gt;
    System.out.println(&amp;quot;Type of T is &amp;quot; + ob.getClass().getName());&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
class GenDemo {&lt;br /&gt;
  public static void main(String args[]) {&lt;br /&gt;
    Gen&amp;lt;Integer&amp;gt; iOb;&lt;br /&gt;
    iOb = new Gen&amp;lt;Integer&amp;gt;(88);&lt;br /&gt;
    iOb.showType();&lt;br /&gt;
    int v = iOb.getob();&lt;br /&gt;
    System.out.println(&amp;quot;value: &amp;quot; + v);&lt;br /&gt;
    System.out.println();&lt;br /&gt;
    Gen&amp;lt;String&amp;gt; strOb = new Gen&amp;lt;String&amp;gt;(&amp;quot;Generics Test&amp;quot;);&lt;br /&gt;
    strOb.showType();&lt;br /&gt;
    String str = strOb.getob();&lt;br /&gt;
    System.out.println(&amp;quot;value: &amp;quot; + str);&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
 &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;/div&gt;</summary>
		<author><name>Admin</name></author>	</entry>

	<entry>
		<id>http://jexp.ru/index.php?title=Java/Generics/Generic_Collection&amp;diff=9179</id>
		<title>Java/Generics/Generic Collection</title>
		<link rel="alternate" type="text/html" href="http://jexp.ru/index.php?title=Java/Generics/Generic_Collection&amp;diff=9179"/>
				<updated>2010-06-01T07:27:23Z</updated>
		
		<summary type="html">&lt;p&gt;Admin: 1 версия&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== A list declared to hold objects of a type T can also hold objects that extend from T. ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
import java.util.ArrayList;&lt;br /&gt;
import java.util.List;&lt;br /&gt;
public class Main {&lt;br /&gt;
  public static void main(String[] argv) {&lt;br /&gt;
    List&amp;lt;Number&amp;gt; numlist = new ArrayList&amp;lt;Number&amp;gt;();&lt;br /&gt;
    numlist.add(new Integer(123));&lt;br /&gt;
    numlist.add(new Float(123));&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
   &lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== A value retrieved from a type-specific list does not need to be casted ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
import java.net.MalformedURLException;&lt;br /&gt;
import java.net.URL;&lt;br /&gt;
import java.util.ArrayList;&lt;br /&gt;
import java.util.List;&lt;br /&gt;
public class Main {&lt;br /&gt;
  public static void main(String[] argv) {&lt;br /&gt;
    List&amp;lt;URL&amp;gt; urlList = new ArrayList&amp;lt;URL&amp;gt;();&lt;br /&gt;
    try {&lt;br /&gt;
      urlList.add(new URL(&amp;quot;http://www.jexp.ru&amp;quot;));&lt;br /&gt;
    } catch (MalformedURLException e) {&lt;br /&gt;
    }&lt;br /&gt;
    String s = urlList.get(0).getHost();&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
   &lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Circular Object Buffer ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
/*&lt;br /&gt;
 * Circular Object Buffer&lt;br /&gt;
 * Copyright (C) 2002-2004 Stephen Ostermiller&lt;br /&gt;
 * http://ostermiller.org/contact.pl?regarding=Java+Utilities&lt;br /&gt;
 *&lt;br /&gt;
 * This program is free software; you can redistribute it and/or modify&lt;br /&gt;
 * it under the terms of the GNU General Public License as published by&lt;br /&gt;
 * the Free Software Foundation; either version 2 of the License, or&lt;br /&gt;
 * (at your option) any later version.&lt;br /&gt;
 *&lt;br /&gt;
 * This program is distributed in the hope that it will be useful,&lt;br /&gt;
 * but WITHOUT ANY WARRANTY; without even the implied warranty of&lt;br /&gt;
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the&lt;br /&gt;
 * GNU General Public License for more details.&lt;br /&gt;
 *&lt;br /&gt;
 * See COPYING.TXT for details.&lt;br /&gt;
 */&lt;br /&gt;
/**&lt;br /&gt;
 * Implements the Circular Buffer producer/consumer model for Objects.&lt;br /&gt;
 * More information about this class is available from .&lt;br /&gt;
 * &amp;lt;p&amp;gt;&lt;br /&gt;
 * This class is thread safe.&lt;br /&gt;
 *&lt;br /&gt;
 * @see CircularCharBuffer&lt;br /&gt;
 * @see CircularByteBuffer&lt;br /&gt;
 *&lt;br /&gt;
 * @author Stephen Ostermiller http://ostermiller.org/contact.pl?regarding=Java+Utilities&lt;br /&gt;
 * @param &amp;lt;ElementType&amp;gt; Type of object allowed in this circular buffer&lt;br /&gt;
 * @since ostermillerutils 1.00.00&lt;br /&gt;
 */&lt;br /&gt;
public class CircularObjectBuffer &amp;lt;ElementType&amp;gt; {&lt;br /&gt;
  /**&lt;br /&gt;
   * The default size for a circular object buffer.&lt;br /&gt;
   *&lt;br /&gt;
   * @since ostermillerutils 1.00.00&lt;br /&gt;
   */&lt;br /&gt;
  private final static int DEFAULT_SIZE = 1024;&lt;br /&gt;
  /**&lt;br /&gt;
   * A buffer that will grow as things are added.&lt;br /&gt;
   *&lt;br /&gt;
   * @since ostermillerutils 1.00.00&lt;br /&gt;
   */&lt;br /&gt;
  public final static int INFINITE_SIZE = -1;&lt;br /&gt;
  /**&lt;br /&gt;
   * The circular buffer.&lt;br /&gt;
   * &amp;lt;p&amp;gt;&lt;br /&gt;
   * The actual capacity of the buffer is one less than the actual length&lt;br /&gt;
   * of the buffer so that an empty and a full buffer can be&lt;br /&gt;
   * distinguished.  An empty buffer will have the readPostion and the&lt;br /&gt;
   * writePosition equal to each other.  A full buffer will have&lt;br /&gt;
   * the writePosition one less than the readPostion.&lt;br /&gt;
   * &amp;lt;p&amp;gt;&lt;br /&gt;
   * There are two important indexes into the buffer:&lt;br /&gt;
   * The readPosition, and the writePosition. The Objects&lt;br /&gt;
   * available to be read go from the readPosition to the writePosition,&lt;br /&gt;
   * wrapping around the end of the buffer.  The space available for writing&lt;br /&gt;
   * goes from the write position to one less than the readPosition,&lt;br /&gt;
   * wrapping around the end of the buffer.&lt;br /&gt;
   *&lt;br /&gt;
   * @since ostermillerutils 1.00.00&lt;br /&gt;
   */&lt;br /&gt;
  protected ElementType[] buffer;&lt;br /&gt;
  /**&lt;br /&gt;
   * Index of the first Object available to be read.&lt;br /&gt;
   *&lt;br /&gt;
   * @since ostermillerutils 1.00.00&lt;br /&gt;
   */&lt;br /&gt;
  protected volatile int readPosition = 0;&lt;br /&gt;
  /**&lt;br /&gt;
   * Index of the first Object available to be written.&lt;br /&gt;
   *&lt;br /&gt;
   * @since ostermillerutils 1.00.00&lt;br /&gt;
   */&lt;br /&gt;
  protected volatile int writePosition = 0;&lt;br /&gt;
  /**&lt;br /&gt;
   * If this buffer is infinite (should resize itself when full)&lt;br /&gt;
   *&lt;br /&gt;
   * @since ostermillerutils 1.00.00&lt;br /&gt;
   */&lt;br /&gt;
  protected volatile boolean infinite = false;&lt;br /&gt;
  /**&lt;br /&gt;
   * True if a write to a full buffer should block until the buffer&lt;br /&gt;
   * has room, false if the write method should throw an IOException&lt;br /&gt;
   *&lt;br /&gt;
   * @since ostermillerutils 1.00.00&lt;br /&gt;
   */&lt;br /&gt;
  protected boolean blockingWrite = true;&lt;br /&gt;
  /**&lt;br /&gt;
   * True when no more input is coming into this buffer.  At that&lt;br /&gt;
   * point reading from the buffer may return  null if the buffer&lt;br /&gt;
   * is empty, otherwise a read will block until an Object is available.&lt;br /&gt;
   *&lt;br /&gt;
   * @since ostermillerutils 1.00.00&lt;br /&gt;
   */&lt;br /&gt;
  protected boolean inputDone = false;&lt;br /&gt;
  /**&lt;br /&gt;
   * Make this buffer ready for reuse.  The contents of the buffer&lt;br /&gt;
   * will be cleared and the streams associated with this buffer&lt;br /&gt;
   * will be reopened if they had been closed.&lt;br /&gt;
   *&lt;br /&gt;
   * @since ostermillerutils 1.00.00&lt;br /&gt;
   */&lt;br /&gt;
  public void clear(){&lt;br /&gt;
    synchronized (this){&lt;br /&gt;
      readPosition = 0;&lt;br /&gt;
      writePosition = 0;&lt;br /&gt;
      inputDone = false;&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
  /**&lt;br /&gt;
   * Get number of Objects that are available to be read.&lt;br /&gt;
   * &amp;lt;p&amp;gt;&lt;br /&gt;
   * Note that the number of Objects available plus&lt;br /&gt;
   * the number of Objects free may not add up to the&lt;br /&gt;
   * capacity of this buffer, as the buffer may reserve some&lt;br /&gt;
   * space for other purposes.&lt;br /&gt;
   *&lt;br /&gt;
   * @return the size in Objects of this buffer&lt;br /&gt;
   *&lt;br /&gt;
   * @since ostermillerutils 1.00.00&lt;br /&gt;
   */&lt;br /&gt;
  public int getAvailable(){&lt;br /&gt;
    synchronized (this){&lt;br /&gt;
      return available();&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
  /**&lt;br /&gt;
   * Get the number of Objects this buffer has free for&lt;br /&gt;
   * writing.&lt;br /&gt;
   * &amp;lt;p&amp;gt;&lt;br /&gt;
   * Note that the number of Objects available plus&lt;br /&gt;
   * the number of Objects free may not add up to the&lt;br /&gt;
   * capacity of this buffer, as the buffer may reserve some&lt;br /&gt;
   * space for other purposes.&lt;br /&gt;
   *&lt;br /&gt;
   * @return the available space in Objects of this buffer&lt;br /&gt;
   *&lt;br /&gt;
   * @since ostermillerutils 1.00.00&lt;br /&gt;
   */&lt;br /&gt;
  public int getSpaceLeft(){&lt;br /&gt;
    synchronized (this){&lt;br /&gt;
      return spaceLeft();&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
  /**&lt;br /&gt;
   * Get the capacity of this buffer.&lt;br /&gt;
   * &amp;lt;p&amp;gt;&lt;br /&gt;
   * Note that the number of Objects available plus&lt;br /&gt;
   * the number of Objects free may not add up to the&lt;br /&gt;
   * capacity of this buffer, as the buffer may reserve some&lt;br /&gt;
   * space for other purposes.&lt;br /&gt;
   *&lt;br /&gt;
   * @return the size in Objects of this buffer&lt;br /&gt;
   *&lt;br /&gt;
   * @since ostermillerutils 1.00.00&lt;br /&gt;
   */&lt;br /&gt;
  public int getSize(){&lt;br /&gt;
    synchronized (this){&lt;br /&gt;
      return buffer.length;&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
  @SuppressWarnings(&amp;quot;unchecked&amp;quot;) private ElementType[] createArray(int size){&lt;br /&gt;
    return (ElementType[]) new Object[size];&lt;br /&gt;
  }&lt;br /&gt;
  /**&lt;br /&gt;
   * double the size of the buffer&lt;br /&gt;
   *&lt;br /&gt;
   * @since ostermillerutils 1.00.00&lt;br /&gt;
   */&lt;br /&gt;
  private void resize(){&lt;br /&gt;
    ElementType[] newBuffer = createArray(buffer.length * 2);&lt;br /&gt;
    int available = available();&lt;br /&gt;
    if (readPosition &amp;lt;= writePosition){&lt;br /&gt;
      // any space between the read and&lt;br /&gt;
      // the first write needs to be saved.&lt;br /&gt;
      // In this case it is all in one piece.&lt;br /&gt;
      int length = writePosition - readPosition;&lt;br /&gt;
      System.arraycopy(buffer, readPosition, newBuffer, 0, length);&lt;br /&gt;
    } else {&lt;br /&gt;
      int length1 = buffer.length - readPosition;&lt;br /&gt;
      System.arraycopy(buffer, readPosition, newBuffer, 0, length1);&lt;br /&gt;
      int length2 = writePosition;&lt;br /&gt;
      System.arraycopy(buffer, 0, newBuffer, length1, length2);&lt;br /&gt;
    }&lt;br /&gt;
    buffer = newBuffer;&lt;br /&gt;
    readPosition = 0;&lt;br /&gt;
    writePosition = available;&lt;br /&gt;
  }&lt;br /&gt;
  /**&lt;br /&gt;
   * Space available in the buffer which can be written.&lt;br /&gt;
   *&lt;br /&gt;
   * @since ostermillerutils 1.00.00&lt;br /&gt;
   */&lt;br /&gt;
  private int spaceLeft(){&lt;br /&gt;
    if (writePosition &amp;lt; readPosition){&lt;br /&gt;
      // any space between the first write and&lt;br /&gt;
      // the read except one Object is available.&lt;br /&gt;
      // In this case it is all in one piece.&lt;br /&gt;
      return (readPosition - writePosition - 1);&lt;br /&gt;
    }&lt;br /&gt;
    // space at the beginning and end.&lt;br /&gt;
    return ((buffer.length - 1) - (writePosition - readPosition));&lt;br /&gt;
  }&lt;br /&gt;
  /**&lt;br /&gt;
   * Objects available for reading.&lt;br /&gt;
   *&lt;br /&gt;
   * @since ostermillerutils 1.00.00&lt;br /&gt;
   */&lt;br /&gt;
  private int available(){&lt;br /&gt;
    if (readPosition &amp;lt;= writePosition){&lt;br /&gt;
      // any space between the first read and&lt;br /&gt;
      // the first write is available.  In this case i&lt;br /&gt;
      // is all in one piece.&lt;br /&gt;
      return (writePosition - readPosition);&lt;br /&gt;
    }&lt;br /&gt;
    // space at the beginning and end.&lt;br /&gt;
    return (buffer.length - (readPosition - writePosition));&lt;br /&gt;
  }&lt;br /&gt;
  /**&lt;br /&gt;
   * Create a new buffer with a default capacity.&lt;br /&gt;
   * Writing to a full buffer will block until space&lt;br /&gt;
   * is available rather than throw an exception.&lt;br /&gt;
   *&lt;br /&gt;
   * @since ostermillerutils 1.00.00&lt;br /&gt;
   */&lt;br /&gt;
  public CircularObjectBuffer(){&lt;br /&gt;
    this (DEFAULT_SIZE, true);&lt;br /&gt;
  }&lt;br /&gt;
  /**&lt;br /&gt;
   * Create a new buffer with given capacity.&lt;br /&gt;
   * Writing to a full buffer will block until space&lt;br /&gt;
   * is available rather than throw an exception.&lt;br /&gt;
   * &amp;lt;p&amp;gt;&lt;br /&gt;
   * Note that the buffer may reserve some Objects for&lt;br /&gt;
   * special purposes and capacity number of Objects may&lt;br /&gt;
   * not be able to be written to the buffer.&lt;br /&gt;
   * &amp;lt;p&amp;gt;&lt;br /&gt;
   * Note that if the buffer is of INFINITE_SIZE it will&lt;br /&gt;
   * neither block or throw exceptions, but rather grow&lt;br /&gt;
   * without bound.&lt;br /&gt;
   *&lt;br /&gt;
   * @param size desired capacity of the buffer in Objects or CircularObjectBuffer.INFINITE_SIZE.&lt;br /&gt;
   *&lt;br /&gt;
   * @since ostermillerutils 1.00.00&lt;br /&gt;
   */&lt;br /&gt;
  public CircularObjectBuffer(int size){&lt;br /&gt;
    this (size, true);&lt;br /&gt;
  }&lt;br /&gt;
  /**&lt;br /&gt;
   * Create a new buffer with a default capacity and&lt;br /&gt;
   * given blocking behavior.&lt;br /&gt;
   *&lt;br /&gt;
   * @param blockingWrite true writing to a full buffer should block&lt;br /&gt;
   *        until space is available, false if an exception should&lt;br /&gt;
   *        be thrown instead.&lt;br /&gt;
   *&lt;br /&gt;
   * @since ostermillerutils 1.00.00&lt;br /&gt;
   */&lt;br /&gt;
  public CircularObjectBuffer(boolean blockingWrite){&lt;br /&gt;
    this (DEFAULT_SIZE, blockingWrite);&lt;br /&gt;
  }&lt;br /&gt;
  /**&lt;br /&gt;
   * Create a new buffer with the given capacity and&lt;br /&gt;
   * blocking behavior.&lt;br /&gt;
   * &amp;lt;p&amp;gt;&lt;br /&gt;
   * Note that the buffer may reserve some Objects for&lt;br /&gt;
   * special purposes and capacity number of Objects may&lt;br /&gt;
   * not be able to be written to the buffer.&lt;br /&gt;
   * &amp;lt;p&amp;gt;&lt;br /&gt;
   * Note that if the buffer is of INFINITE_SIZE it will&lt;br /&gt;
   * neither block or throw exceptions, but rather grow&lt;br /&gt;
   * without bound.&lt;br /&gt;
   *&lt;br /&gt;
   * @param size desired capacity of the buffer in Objects or CircularObjectBuffer.INFINITE_SIZE.&lt;br /&gt;
   * @param blockingWrite true writing to a full buffer should block&lt;br /&gt;
   *        until space is available, false if an exception should&lt;br /&gt;
   *        be thrown instead.&lt;br /&gt;
   *&lt;br /&gt;
   * @since ostermillerutils 1.00.00&lt;br /&gt;
   */&lt;br /&gt;
  public CircularObjectBuffer(int size, boolean blockingWrite){&lt;br /&gt;
    if (size == INFINITE_SIZE){&lt;br /&gt;
      buffer = createArray(DEFAULT_SIZE);&lt;br /&gt;
      infinite = true;&lt;br /&gt;
    } else {&lt;br /&gt;
      buffer = createArray(size);&lt;br /&gt;
      infinite = false;&lt;br /&gt;
    }&lt;br /&gt;
    this.blockingWrite = blockingWrite;&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  /**&lt;br /&gt;
   * Get a single Object from this buffer.  This method should be called&lt;br /&gt;
   * by the consumer.&lt;br /&gt;
   * This method will block until a Object is available or no more&lt;br /&gt;
   * objects are available.&lt;br /&gt;
   *&lt;br /&gt;
   * @return The Object read, or null if there are no more objects&lt;br /&gt;
   * @throws InterruptedException if the thread is interrupted while waiting.&lt;br /&gt;
   *&lt;br /&gt;
   * @since ostermillerutils 1.00.00&lt;br /&gt;
   */&lt;br /&gt;
  public ElementType read() throws InterruptedException {&lt;br /&gt;
    while (true){&lt;br /&gt;
      synchronized (this){&lt;br /&gt;
        int available = available();&lt;br /&gt;
        if (available &amp;gt; 0){&lt;br /&gt;
          ElementType result = buffer[readPosition];&lt;br /&gt;
          readPosition++;&lt;br /&gt;
          if (readPosition == buffer.length){&lt;br /&gt;
            readPosition = 0;&lt;br /&gt;
          }&lt;br /&gt;
          return result;&lt;br /&gt;
        } else if (inputDone){&lt;br /&gt;
          return null;&lt;br /&gt;
        }&lt;br /&gt;
      }&lt;br /&gt;
      Thread.sleep(100);&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
  /**&lt;br /&gt;
   * Get Objects into an array from this buffer.  This method should&lt;br /&gt;
   * be called by the consumer.&lt;br /&gt;
   * This method will block until some input is available,&lt;br /&gt;
   * or there is no more input.&lt;br /&gt;
   *&lt;br /&gt;
   * @param buf Destination buffer.&lt;br /&gt;
   * @return The number of Objects read, or -1 there will&lt;br /&gt;
   *     be no more objects available.&lt;br /&gt;
   * @throws InterruptedException if the thread is interrupted while waiting.&lt;br /&gt;
   *&lt;br /&gt;
   * @since ostermillerutils 1.00.00&lt;br /&gt;
   */&lt;br /&gt;
  public int read(ElementType[] buf) throws InterruptedException {&lt;br /&gt;
    return read(buf, 0, buf.length);&lt;br /&gt;
  }&lt;br /&gt;
  /**&lt;br /&gt;
   * Get Objects into a portion of an array from this buffer.  This&lt;br /&gt;
   * method should be called by the consumer.&lt;br /&gt;
   * This method will block until some input is available,&lt;br /&gt;
   * an I/O error occurs, or the end of the stream is reached.&lt;br /&gt;
   *&lt;br /&gt;
   * @param buf Destination buffer.&lt;br /&gt;
   * @param off Offset at which to start storing Objects.&lt;br /&gt;
   * @param len Maximum number of Objects to read.&lt;br /&gt;
   * @return The number of Objects read, or -1 there will&lt;br /&gt;
   *     be no more objects available.&lt;br /&gt;
   * @throws InterruptedException if the thread is interrupted while waiting.&lt;br /&gt;
   *&lt;br /&gt;
   * @since ostermillerutils 1.00.00&lt;br /&gt;
   */&lt;br /&gt;
  public int read(ElementType[] buf, int off, int len) throws InterruptedException {&lt;br /&gt;
    while (true){&lt;br /&gt;
      synchronized (this){&lt;br /&gt;
        int available = available();&lt;br /&gt;
        if (available &amp;gt; 0){&lt;br /&gt;
          int length = Math.min(len, available);&lt;br /&gt;
          int firstLen = Math.min(length, buffer.length - readPosition);&lt;br /&gt;
          int secondLen = length - firstLen;&lt;br /&gt;
          System.arraycopy(buffer, readPosition, buf, off, firstLen);&lt;br /&gt;
          if (secondLen &amp;gt; 0){&lt;br /&gt;
            System.arraycopy(buffer, 0, buf, off+firstLen,  secondLen);&lt;br /&gt;
            readPosition = secondLen;&lt;br /&gt;
          } else {&lt;br /&gt;
            readPosition += length;&lt;br /&gt;
          }&lt;br /&gt;
          if (readPosition == buffer.length) {&lt;br /&gt;
            readPosition = 0;&lt;br /&gt;
          }&lt;br /&gt;
          return length;&lt;br /&gt;
        } else if (inputDone){&lt;br /&gt;
          return -1;&lt;br /&gt;
        }&lt;br /&gt;
      }&lt;br /&gt;
      Thread.sleep(100);&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  /**&lt;br /&gt;
   * Skip Objects.  This method should be used by the consumer&lt;br /&gt;
   * when it does not care to examine some number of Objects.&lt;br /&gt;
   * This method will block until some Objects are available,&lt;br /&gt;
   * or there will be no more Objects available.&lt;br /&gt;
   *&lt;br /&gt;
   * @param n The number of Objects to skip&lt;br /&gt;
   * @return The number of Objects actually skipped&lt;br /&gt;
   * @throws IllegalArgumentException if n is negative.&lt;br /&gt;
   * @throws InterruptedException if the thread is interrupted while waiting.&lt;br /&gt;
   *&lt;br /&gt;
   * @since ostermillerutils 1.00.00&lt;br /&gt;
   */&lt;br /&gt;
  public long skip(long n) throws InterruptedException, IllegalArgumentException {&lt;br /&gt;
    while (true){&lt;br /&gt;
      synchronized (this){&lt;br /&gt;
        int available = available();&lt;br /&gt;
        if (available &amp;gt; 0){&lt;br /&gt;
          int length = Math.min((int)n, available);&lt;br /&gt;
          int firstLen = Math.min(length, buffer.length - readPosition);&lt;br /&gt;
          int secondLen = length - firstLen;&lt;br /&gt;
          if (secondLen &amp;gt; 0){&lt;br /&gt;
            readPosition = secondLen;&lt;br /&gt;
          } else {&lt;br /&gt;
            readPosition += length;&lt;br /&gt;
          }&lt;br /&gt;
          if (readPosition == buffer.length) {&lt;br /&gt;
            readPosition = 0;&lt;br /&gt;
          }&lt;br /&gt;
          return length;&lt;br /&gt;
        } else if (inputDone){&lt;br /&gt;
          return 0;&lt;br /&gt;
        }&lt;br /&gt;
      }&lt;br /&gt;
      Thread.sleep(100);&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
  /**&lt;br /&gt;
   * This method should be used by the producer to signal to the consumer&lt;br /&gt;
   * that the producer is done producing objects and that the consumer&lt;br /&gt;
   * should stop asking for objects once it has used up buffered objects.&lt;br /&gt;
   * &amp;lt;p&amp;gt;&lt;br /&gt;
   * Once the producer has signaled that it is done, further write() invocations&lt;br /&gt;
   * will cause an IllegalStateException to be thrown. Calling done() multiple times,&lt;br /&gt;
   * however, has no effect.&lt;br /&gt;
   *&lt;br /&gt;
   * @since ostermillerutils 1.00.00&lt;br /&gt;
   */&lt;br /&gt;
  public void done(){&lt;br /&gt;
    synchronized (this){&lt;br /&gt;
      inputDone = true;&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
  /**&lt;br /&gt;
   * Fill this buffer with array of Objects.  This method should be called&lt;br /&gt;
   * by the producer.&lt;br /&gt;
   * If the buffer allows blocking writes, this method will block until&lt;br /&gt;
   * all the data has been written rather than throw a BufferOverflowException.&lt;br /&gt;
   *&lt;br /&gt;
   * @param buf Array of Objects to be written&lt;br /&gt;
   * @throws BufferOverflowException if buffer does not allow blocking writes&lt;br /&gt;
   *   and the buffer is full.  If the exception is thrown, no data&lt;br /&gt;
   *   will have been written since the buffer was set to be non-blocking.&lt;br /&gt;
   * @throws IllegalStateException if done() has been called.&lt;br /&gt;
   * @throws InterruptedException if the write is interrupted.&lt;br /&gt;
   *&lt;br /&gt;
   * @since ostermillerutils 1.00.00&lt;br /&gt;
   */&lt;br /&gt;
  public void write(ElementType[] buf) throws Exception{&lt;br /&gt;
    write(buf, 0, buf.length);&lt;br /&gt;
  }&lt;br /&gt;
  /**&lt;br /&gt;
   * Fill this buffer with a portion of an array of Objects.&lt;br /&gt;
   * This method should be called by the producer.&lt;br /&gt;
   * If the buffer allows blocking writes, this method will block until&lt;br /&gt;
   * all the data has been written rather than throw an IOException.&lt;br /&gt;
   *&lt;br /&gt;
   * @param buf Array of Objects&lt;br /&gt;
   * @param off Offset from which to start writing Objects&lt;br /&gt;
   * @param len - Number of Objects to write&lt;br /&gt;
   * @throws BufferOverflowException if buffer does not allow blocking writes&lt;br /&gt;
   *   and the buffer is full.  If the exception is thrown, no data&lt;br /&gt;
   *   will have been written since the buffer was set to be non-blocking.&lt;br /&gt;
   * @throws IllegalStateException if done() has been called.&lt;br /&gt;
   * @throws InterruptedException if the write is interrupted.&lt;br /&gt;
   *&lt;br /&gt;
   * @since ostermillerutils 1.00.00&lt;br /&gt;
   */&lt;br /&gt;
  public void write(ElementType[] buf, int off, int len) throws Exception{&lt;br /&gt;
    while (len &amp;gt; 0){&lt;br /&gt;
      synchronized (CircularObjectBuffer.this){&lt;br /&gt;
        if (inputDone) throw new IllegalStateException(&amp;quot;CircularObjectBuffer.done() has been called, CircularObjectBuffer.write() failed.&amp;quot;);&lt;br /&gt;
        int spaceLeft = spaceLeft();&lt;br /&gt;
        while (infinite &amp;amp;&amp;amp; spaceLeft &amp;lt; len){&lt;br /&gt;
          resize();&lt;br /&gt;
          spaceLeft = spaceLeft();&lt;br /&gt;
        }&lt;br /&gt;
        if (!blockingWrite &amp;amp;&amp;amp; spaceLeft &amp;lt; len) throw new Exception(&amp;quot;CircularObjectBuffer is full; cannot write &amp;quot; + len + &amp;quot; Objects&amp;quot;);&lt;br /&gt;
        int realLen = Math.min(len, spaceLeft);&lt;br /&gt;
        int firstLen = Math.min(realLen, buffer.length - writePosition);&lt;br /&gt;
        int secondLen = Math.min(realLen - firstLen, buffer.length - readPosition - 1);&lt;br /&gt;
        int written = firstLen + secondLen;&lt;br /&gt;
        if (firstLen &amp;gt; 0){&lt;br /&gt;
          System.arraycopy(buf, off, buffer, writePosition, firstLen);&lt;br /&gt;
        }&lt;br /&gt;
        if (secondLen &amp;gt; 0){&lt;br /&gt;
          System.arraycopy(buf, off+firstLen, buffer, 0, secondLen);&lt;br /&gt;
          writePosition = secondLen;&lt;br /&gt;
        } else {&lt;br /&gt;
          writePosition += written;&lt;br /&gt;
        }&lt;br /&gt;
        if (writePosition == buffer.length) {&lt;br /&gt;
          writePosition = 0;&lt;br /&gt;
        }&lt;br /&gt;
        off += written;&lt;br /&gt;
        len -= written;&lt;br /&gt;
      }&lt;br /&gt;
      if (len &amp;gt; 0){&lt;br /&gt;
        Thread.sleep(100);&lt;br /&gt;
      }&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
  /**&lt;br /&gt;
   * Add a single Object to this buffer.  This method should be&lt;br /&gt;
   * called by the producer.&lt;br /&gt;
   * If the buffer allows blocking writes, this method will block until&lt;br /&gt;
   * all the data has been written rather than throw an IOException.&lt;br /&gt;
   *&lt;br /&gt;
   * @param o Object to be written.&lt;br /&gt;
   * @throws BufferOverflowException if buffer does not allow blocking writes&lt;br /&gt;
   *   and the buffer is full.  If the exception is thrown, no data&lt;br /&gt;
   *   will have been written since the buffer was set to be non-blocking.&lt;br /&gt;
   * @throws IllegalStateException if done() has been called.&lt;br /&gt;
   * @throws InterruptedException if the write is interrupted.&lt;br /&gt;
   *&lt;br /&gt;
   * @since ostermillerutils 1.00.00&lt;br /&gt;
   */&lt;br /&gt;
  public void write(ElementType o) throws Exception{&lt;br /&gt;
    boolean written = false;&lt;br /&gt;
    while (!written){&lt;br /&gt;
      synchronized (CircularObjectBuffer.this){&lt;br /&gt;
        if (inputDone) throw new IllegalStateException(&amp;quot;CircularObjectBuffer.done() has been called, CircularObjectBuffer.write() failed.&amp;quot;);&lt;br /&gt;
        int spaceLeft = spaceLeft();&lt;br /&gt;
        while (infinite &amp;amp;&amp;amp; spaceLeft &amp;lt; 1){&lt;br /&gt;
          resize();&lt;br /&gt;
          spaceLeft = spaceLeft();&lt;br /&gt;
        }&lt;br /&gt;
        if (!blockingWrite &amp;amp;&amp;amp; spaceLeft &amp;lt; 1) throw new Exception(&amp;quot;CircularObjectBuffer is full; cannot write 1 Object&amp;quot;);&lt;br /&gt;
        if (spaceLeft &amp;gt; 0){&lt;br /&gt;
          buffer[writePosition] = o;&lt;br /&gt;
          writePosition++;&lt;br /&gt;
          if (writePosition == buffer.length) {&lt;br /&gt;
            writePosition = 0;&lt;br /&gt;
          }&lt;br /&gt;
          written = true;&lt;br /&gt;
        }&lt;br /&gt;
      }&lt;br /&gt;
      if (!written){&lt;br /&gt;
        Thread.sleep(100);&lt;br /&gt;
      }&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Collections and Data structure: the generic way ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
/*&lt;br /&gt;
License for Java 1.5 &amp;quot;Tiger&amp;quot;: A Developer&amp;quot;s Notebook&lt;br /&gt;
     (O&amp;quot;Reilly) example package&lt;br /&gt;
Java 1.5 &amp;quot;Tiger&amp;quot;: A Developer&amp;quot;s Notebook (O&amp;quot;Reilly) &lt;br /&gt;
by Brett McLaughlin and David Flanagan.&lt;br /&gt;
ISBN: 0-596-00738-8&lt;br /&gt;
You can use the examples and the source code any way you want, but&lt;br /&gt;
please include a reference to where it comes from if you use it in&lt;br /&gt;
your own products or services. Also note that this software is&lt;br /&gt;
provided by the author &amp;quot;as is&amp;quot;, with no expressed or implied warranties. &lt;br /&gt;
In no event shall the author be liable for any direct or indirect&lt;br /&gt;
damages arising in any way out of the use of this software.&lt;br /&gt;
*/&lt;br /&gt;
import java.util.ArrayList;&lt;br /&gt;
import java.io.IOException;&lt;br /&gt;
import java.io.PrintStream;&lt;br /&gt;
import java.util.HashMap;&lt;br /&gt;
import java.util.Iterator;&lt;br /&gt;
import java.util.LinkedList;&lt;br /&gt;
import java.util.List;&lt;br /&gt;
import java.util.Map;&lt;br /&gt;
public class GenericsTester {&lt;br /&gt;
  public GenericsTester() {&lt;br /&gt;
  }&lt;br /&gt;
  public void testTypeSafeMaps(PrintStream out) throws IOException {&lt;br /&gt;
    Map&amp;lt;Integer, Integer&amp;gt; squares = new HashMap&amp;lt;Integer, Integer&amp;gt;();&lt;br /&gt;
    for (int i=0; i&amp;lt;100; i++) {&lt;br /&gt;
      squares.put(i, i*i);&lt;br /&gt;
    }&lt;br /&gt;
    for (int i=0; i&amp;lt;10; i++) {&lt;br /&gt;
      int n = i*3;&lt;br /&gt;
      out.println(&amp;quot;The square of &amp;quot; + n + &amp;quot; is &amp;quot; + squares.get(n));&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
  public void testTypeSafeLists(PrintStream out) throws IOException {&lt;br /&gt;
    List listOfStrings = getListOfStrings();&lt;br /&gt;
    for (Iterator i = listOfStrings.iterator(); i.hasNext(); ) {&lt;br /&gt;
      String item = (String)i.next();&lt;br /&gt;
 &lt;br /&gt;
      // Work with that string&lt;br /&gt;
    }&lt;br /&gt;
    List&amp;lt;String&amp;gt; onlyStrings = new LinkedList&amp;lt;String&amp;gt;();&lt;br /&gt;
    onlyStrings.add(&amp;quot;Legal addition&amp;quot;);&lt;br /&gt;
    /**&lt;br /&gt;
     * Uncomment these two lines for an error&lt;br /&gt;
    onlyStrings.add(new StringBuilder(&amp;quot;Illegal Addition&amp;quot;));&lt;br /&gt;
    onlyStrings.add(25);&lt;br /&gt;
     */&lt;br /&gt;
  }&lt;br /&gt;
  public void testTypeSafeIterators(PrintStream out) throws IOException {&lt;br /&gt;
    List&amp;lt;String&amp;gt; listOfStrings = new LinkedList&amp;lt;String&amp;gt;();&lt;br /&gt;
    listOfStrings.add(&amp;quot;Happy&amp;quot;);&lt;br /&gt;
    listOfStrings.add(&amp;quot;Birthday&amp;quot;);&lt;br /&gt;
    listOfStrings.add(&amp;quot;To&amp;quot;);&lt;br /&gt;
    listOfStrings.add(&amp;quot;You&amp;quot;);&lt;br /&gt;
    for (Iterator&amp;lt;String&amp;gt; i = listOfStrings.iterator(); i.hasNext(); ) {&lt;br /&gt;
      String s = i.next();&lt;br /&gt;
      out.println(s);&lt;br /&gt;
    }&lt;br /&gt;
    printListOfStrings(getListOfStrings(), out);&lt;br /&gt;
  }&lt;br /&gt;
  private List getList() {&lt;br /&gt;
    List list = new LinkedList();&lt;br /&gt;
    list.add(3);&lt;br /&gt;
    list.add(&amp;quot;Blind&amp;quot;);&lt;br /&gt;
    list.add(&amp;quot;Mice&amp;quot;);&lt;br /&gt;
    return list;&lt;br /&gt;
  }&lt;br /&gt;
  private List&amp;lt;String&amp;gt; getListOfStrings() {&lt;br /&gt;
    List&amp;lt;String&amp;gt; list = new LinkedList&amp;lt;String&amp;gt;();&lt;br /&gt;
    list.add(&amp;quot;Hello&amp;quot;);&lt;br /&gt;
    list.add(&amp;quot;World&amp;quot;);&lt;br /&gt;
    list.add(&amp;quot;How&amp;quot;);&lt;br /&gt;
    list.add(&amp;quot;Are&amp;quot;);&lt;br /&gt;
    list.add(&amp;quot;You?&amp;quot;);&lt;br /&gt;
    return list;&lt;br /&gt;
  }&lt;br /&gt;
  public void testTypeSafeReturnValues(PrintStream out) throws IOException {&lt;br /&gt;
    List&amp;lt;String&amp;gt; strings = getListOfStrings();&lt;br /&gt;
 &lt;br /&gt;
    for (String s : strings) {&lt;br /&gt;
      out.println(s);&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
  private void printListOfStrings(List&amp;lt;String&amp;gt; list, PrintStream out)&lt;br /&gt;
    throws IOException {&lt;br /&gt;
    for (Iterator&amp;lt;String&amp;gt; i = list.iterator(); i.hasNext(); ) {&lt;br /&gt;
      out.println(i.next());&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
  public void printList(List&amp;lt;?&amp;gt; list, PrintStream out) throws IOException {&lt;br /&gt;
    for (Iterator&amp;lt;?&amp;gt; i = list.iterator(); i.hasNext(); ) {&lt;br /&gt;
      out.println(i.next().toString());&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
  public static void main(String[] args) {&lt;br /&gt;
    GenericsTester tester = new GenericsTester();&lt;br /&gt;
    try {&lt;br /&gt;
      tester.testTypeSafeLists(System.out);&lt;br /&gt;
      tester.testTypeSafeMaps(System.out);&lt;br /&gt;
      tester.testTypeSafeIterators(System.out);&lt;br /&gt;
      tester.testTypeSafeReturnValues(System.out);&lt;br /&gt;
      List&amp;lt;Integer&amp;gt; ints = new LinkedList&amp;lt;Integer&amp;gt;();&lt;br /&gt;
      ints.add(1);&lt;br /&gt;
      ints.add(2);&lt;br /&gt;
      ints.add(3);&lt;br /&gt;
      tester.printList(ints, System.out);&lt;br /&gt;
      /** Uncomment for an error&lt;br /&gt;
      NumberBox&amp;lt;String&amp;gt; illegal = new NumberBox&amp;lt;String&amp;gt;();&lt;br /&gt;
       */&lt;br /&gt;
    } catch (Exception e) {&lt;br /&gt;
      e.printStackTrace();&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
class NumberBox&amp;lt;N extends Number&amp;gt; extends Box&amp;lt;N&amp;gt; {&lt;br /&gt;
  public NumberBox() {&lt;br /&gt;
    super();&lt;br /&gt;
  }&lt;br /&gt;
 &lt;br /&gt;
  // Sum everything in the box&lt;br /&gt;
  public double sum() {&lt;br /&gt;
    double total = 0;&lt;br /&gt;
    for (Iterator&amp;lt;N&amp;gt; i = contents.iterator(); i.hasNext(); ) {&lt;br /&gt;
      total = total + i.next().doubleValue();&lt;br /&gt;
    }&lt;br /&gt;
    return total;&lt;br /&gt;
  }  &lt;br /&gt;
  public static &amp;lt;A extends Number&amp;gt; double sum(Box&amp;lt;A&amp;gt; box1,&lt;br /&gt;
                                              Box&amp;lt;A&amp;gt; box2) {&lt;br /&gt;
    double total = 0;&lt;br /&gt;
    for (Iterator&amp;lt;A&amp;gt; i = box1.contents.iterator(); i.hasNext(); ) {&lt;br /&gt;
      total = total + i.next().doubleValue();&lt;br /&gt;
    }&lt;br /&gt;
    for (Iterator&amp;lt;A&amp;gt; i = box2.contents.iterator(); i.hasNext(); ) {&lt;br /&gt;
      total = total + i.next().doubleValue();&lt;br /&gt;
    }&lt;br /&gt;
    return total;&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
class Box&amp;lt;T&amp;gt; {&lt;br /&gt;
  protected List&amp;lt;T&amp;gt; contents;&lt;br /&gt;
  public Box() {&lt;br /&gt;
    contents = new ArrayList&amp;lt;T&amp;gt;();&lt;br /&gt;
  }&lt;br /&gt;
  public int getSize() {&lt;br /&gt;
    return contents.size();&lt;br /&gt;
  }&lt;br /&gt;
  public boolean isEmpty() {&lt;br /&gt;
    return (contents.size() == 0);&lt;br /&gt;
  }&lt;br /&gt;
  public void add(T o) {&lt;br /&gt;
    contents.add(o);&lt;br /&gt;
  }&lt;br /&gt;
 &lt;br /&gt;
  public T grab() {&lt;br /&gt;
    if (!isEmpty()) {&lt;br /&gt;
      return contents.remove(0);&lt;br /&gt;
    } else&lt;br /&gt;
      return null;&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
           &lt;br /&gt;
         &lt;br /&gt;
    &lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Create a typesafe copy of a raw list. ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
/*&lt;br /&gt;
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.&lt;br /&gt;
 *&lt;br /&gt;
 * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.&lt;br /&gt;
 *&lt;br /&gt;
 * The contents of this file are subject to the terms of either the GNU&lt;br /&gt;
 * General Public License Version 2 only (&amp;quot;GPL&amp;quot;) or the Common&lt;br /&gt;
 * Development and Distribution License(&amp;quot;CDDL&amp;quot;) (collectively, the&lt;br /&gt;
 * &amp;quot;License&amp;quot;). You may not use this file except in compliance with the&lt;br /&gt;
 * License. You can obtain a copy of the License at&lt;br /&gt;
 * http://www.netbeans.org/cddl-gplv2.html&lt;br /&gt;
 * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the&lt;br /&gt;
 * specific language governing permissions and limitations under the&lt;br /&gt;
 * License.  When distributing the software, include this License Header&lt;br /&gt;
 * Notice in each file and include the License file at&lt;br /&gt;
 * nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this&lt;br /&gt;
 * particular file as subject to the &amp;quot;Classpath&amp;quot; exception as provided&lt;br /&gt;
 * by Sun in the GPL Version 2 section of the License file that&lt;br /&gt;
 * accompanied this code. If applicable, add the following below the&lt;br /&gt;
 * License Header, with the fields enclosed by brackets [] replaced by&lt;br /&gt;
 * your own identifying information:&lt;br /&gt;
 * &amp;quot;Portions Copyrighted [year] [name of copyright owner]&amp;quot;&lt;br /&gt;
 *&lt;br /&gt;
 * Contributor(s):&lt;br /&gt;
 *&lt;br /&gt;
 * The Original Software is NetBeans. The Initial Developer of the Original&lt;br /&gt;
 * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun&lt;br /&gt;
 * Microsystems, Inc. All Rights Reserved.&lt;br /&gt;
 *&lt;br /&gt;
 * If you wish your version of this file to be governed by only the CDDL&lt;br /&gt;
 * or only the GPL Version 2, indicate your decision by adding&lt;br /&gt;
 * &amp;quot;[Contributor] elects to include this software in this distribution&lt;br /&gt;
 * under the [CDDL or GPL Version 2] license.&amp;quot; If you do not indicate a&lt;br /&gt;
 * single choice of license, a recipient has the option to distribute&lt;br /&gt;
 * your version of this file under either the CDDL, the GPL Version 2 or&lt;br /&gt;
 * to extend the choice of license to its licensees as provided above.&lt;br /&gt;
 * However, if you add GPL Version 2 code and therefore, elected the GPL&lt;br /&gt;
 * Version 2 license, then the option applies only if the new code is&lt;br /&gt;
 * made subject to such option by the copyright holder.&lt;br /&gt;
 */&lt;br /&gt;
&lt;br /&gt;
import java.util.ArrayList;&lt;br /&gt;
import java.util.Iterator;&lt;br /&gt;
import java.util.LinkedList;&lt;br /&gt;
import java.util.List;&lt;br /&gt;
import java.util.RandomAccess;&lt;br /&gt;
/**&lt;br /&gt;
 * @since 4.37&lt;br /&gt;
 * @author Jaroslav Tulach&lt;br /&gt;
 */&lt;br /&gt;
&lt;br /&gt;
public class Utils {&lt;br /&gt;
  /**&lt;br /&gt;
   * Create a typesafe copy of a raw list.&lt;br /&gt;
   * @param rawList an unchecked list&lt;br /&gt;
   * @param type the desired supertype of the entries&lt;br /&gt;
   * @param strict true to throw a &amp;lt;code&amp;gt;ClassCastException&amp;lt;/code&amp;gt; if the raw list has an invalid entry,&lt;br /&gt;
   *               false to skip over such entries (warnings may be logged)&lt;br /&gt;
   * @return a typed list guaranteed to contain only entries assignable&lt;br /&gt;
   *         to the named type (or they may be null)&lt;br /&gt;
   * @throws ClassCastException if some entry in the raw list was not well-typed, and only if &amp;lt;code&amp;gt;strict&amp;lt;/code&amp;gt; was true&lt;br /&gt;
   */&lt;br /&gt;
  public static &amp;lt;E&amp;gt; List&amp;lt;E&amp;gt; checkedListByCopy(List rawList, Class&amp;lt;E&amp;gt; type, boolean strict) throws ClassCastException {&lt;br /&gt;
      List&amp;lt;E&amp;gt; l = (rawList instanceof RandomAccess) ? new ArrayList&amp;lt;E&amp;gt;(rawList.size()) : new LinkedList&amp;lt;E&amp;gt;();&lt;br /&gt;
      Iterator it = rawList.iterator();&lt;br /&gt;
      while (it.hasNext()) {&lt;br /&gt;
          Object e = it.next();&lt;br /&gt;
          try {&lt;br /&gt;
              l.add(type.cast(e));&lt;br /&gt;
          } catch (ClassCastException x) {&lt;br /&gt;
              if (strict) {&lt;br /&gt;
                  throw x;&lt;br /&gt;
              } else {&lt;br /&gt;
                  System.out.println(&amp;quot;not assignable &amp;quot;);&lt;br /&gt;
              }&lt;br /&gt;
          }&lt;br /&gt;
      }&lt;br /&gt;
      return l;&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
   &lt;br /&gt;
    &lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Create a typesafe copy of a raw map. ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
/*&lt;br /&gt;
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.&lt;br /&gt;
 *&lt;br /&gt;
 * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.&lt;br /&gt;
 *&lt;br /&gt;
 * The contents of this file are subject to the terms of either the GNU&lt;br /&gt;
 * General Public License Version 2 only (&amp;quot;GPL&amp;quot;) or the Common&lt;br /&gt;
 * Development and Distribution License(&amp;quot;CDDL&amp;quot;) (collectively, the&lt;br /&gt;
 * &amp;quot;License&amp;quot;). You may not use this file except in compliance with the&lt;br /&gt;
 * License. You can obtain a copy of the License at&lt;br /&gt;
 * http://www.netbeans.org/cddl-gplv2.html&lt;br /&gt;
 * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the&lt;br /&gt;
 * specific language governing permissions and limitations under the&lt;br /&gt;
 * License.  When distributing the software, include this License Header&lt;br /&gt;
 * Notice in each file and include the License file at&lt;br /&gt;
 * nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this&lt;br /&gt;
 * particular file as subject to the &amp;quot;Classpath&amp;quot; exception as provided&lt;br /&gt;
 * by Sun in the GPL Version 2 section of the License file that&lt;br /&gt;
 * accompanied this code. If applicable, add the following below the&lt;br /&gt;
 * License Header, with the fields enclosed by brackets [] replaced by&lt;br /&gt;
 * your own identifying information:&lt;br /&gt;
 * &amp;quot;Portions Copyrighted [year] [name of copyright owner]&amp;quot;&lt;br /&gt;
 *&lt;br /&gt;
 * Contributor(s):&lt;br /&gt;
 *&lt;br /&gt;
 * The Original Software is NetBeans. The Initial Developer of the Original&lt;br /&gt;
 * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun&lt;br /&gt;
 * Microsystems, Inc. All Rights Reserved.&lt;br /&gt;
 *&lt;br /&gt;
 * If you wish your version of this file to be governed by only the CDDL&lt;br /&gt;
 * or only the GPL Version 2, indicate your decision by adding&lt;br /&gt;
 * &amp;quot;[Contributor] elects to include this software in this distribution&lt;br /&gt;
 * under the [CDDL or GPL Version 2] license.&amp;quot; If you do not indicate a&lt;br /&gt;
 * single choice of license, a recipient has the option to distribute&lt;br /&gt;
 * your version of this file under either the CDDL, the GPL Version 2 or&lt;br /&gt;
 * to extend the choice of license to its licensees as provided above.&lt;br /&gt;
 * However, if you add GPL Version 2 code and therefore, elected the GPL&lt;br /&gt;
 * Version 2 license, then the option applies only if the new code is&lt;br /&gt;
 * made subject to such option by the copyright holder.&lt;br /&gt;
 */&lt;br /&gt;
&lt;br /&gt;
import java.util.HashMap;&lt;br /&gt;
import java.util.Iterator;&lt;br /&gt;
import java.util.Map;&lt;br /&gt;
/**&lt;br /&gt;
 * @since 4.37&lt;br /&gt;
 * @author Jaroslav Tulach&lt;br /&gt;
 */&lt;br /&gt;
&lt;br /&gt;
public class Utils {&lt;br /&gt;
  /**&lt;br /&gt;
   * Create a typesafe copy of a raw map.&lt;br /&gt;
   * @param rawMap an unchecked map&lt;br /&gt;
   * @param keyType the desired supertype of the keys&lt;br /&gt;
   * @param valueType the desired supertype of the values&lt;br /&gt;
   * @param strict true to throw a &amp;lt;code&amp;gt;ClassCastException&amp;lt;/code&amp;gt; if the raw map has an invalid key or value,&lt;br /&gt;
   *               false to skip over such map entries (warnings may be logged)&lt;br /&gt;
   * @return a typed map guaranteed to contain only keys and values assignable&lt;br /&gt;
   *         to the named types (or they may be null)&lt;br /&gt;
   * @throws ClassCastException if some key or value in the raw map was not well-typed, and only if &amp;lt;code&amp;gt;strict&amp;lt;/code&amp;gt; was true&lt;br /&gt;
   */&lt;br /&gt;
  public static &amp;lt;K,V&amp;gt; Map&amp;lt;K,V&amp;gt; checkedMapByCopy(Map rawMap, Class&amp;lt;K&amp;gt; keyType, Class&amp;lt;V&amp;gt; valueType, boolean strict) throws ClassCastException {&lt;br /&gt;
      Map&amp;lt;K,V&amp;gt; m2 = new HashMap&amp;lt;K,V&amp;gt;(rawMap.size() * 4 / 3 + 1);&lt;br /&gt;
      Iterator it = rawMap.entrySet().iterator();&lt;br /&gt;
      while (it.hasNext()) {&lt;br /&gt;
          Map.Entry e = (Map.Entry) it.next();&lt;br /&gt;
          try {&lt;br /&gt;
              m2.put(keyType.cast(e.getKey()), valueType.cast(e.getValue()));&lt;br /&gt;
          } catch (ClassCastException x) {&lt;br /&gt;
              if (strict) {&lt;br /&gt;
                  throw x;&lt;br /&gt;
              } else {&lt;br /&gt;
                  System.out.println(&amp;quot;not assignable&amp;quot;);&lt;br /&gt;
              }&lt;br /&gt;
          }&lt;br /&gt;
      }&lt;br /&gt;
      return m2;&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
   &lt;br /&gt;
    &lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Create a typesafe copy of a raw set. ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
/*&lt;br /&gt;
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.&lt;br /&gt;
 *&lt;br /&gt;
 * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.&lt;br /&gt;
 *&lt;br /&gt;
 * The contents of this file are subject to the terms of either the GNU&lt;br /&gt;
 * General Public License Version 2 only (&amp;quot;GPL&amp;quot;) or the Common&lt;br /&gt;
 * Development and Distribution License(&amp;quot;CDDL&amp;quot;) (collectively, the&lt;br /&gt;
 * &amp;quot;License&amp;quot;). You may not use this file except in compliance with the&lt;br /&gt;
 * License. You can obtain a copy of the License at&lt;br /&gt;
 * http://www.netbeans.org/cddl-gplv2.html&lt;br /&gt;
 * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the&lt;br /&gt;
 * specific language governing permissions and limitations under the&lt;br /&gt;
 * License.  When distributing the software, include this License Header&lt;br /&gt;
 * Notice in each file and include the License file at&lt;br /&gt;
 * nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this&lt;br /&gt;
 * particular file as subject to the &amp;quot;Classpath&amp;quot; exception as provided&lt;br /&gt;
 * by Sun in the GPL Version 2 section of the License file that&lt;br /&gt;
 * accompanied this code. If applicable, add the following below the&lt;br /&gt;
 * License Header, with the fields enclosed by brackets [] replaced by&lt;br /&gt;
 * your own identifying information:&lt;br /&gt;
 * &amp;quot;Portions Copyrighted [year] [name of copyright owner]&amp;quot;&lt;br /&gt;
 *&lt;br /&gt;
 * Contributor(s):&lt;br /&gt;
 *&lt;br /&gt;
 * The Original Software is NetBeans. The Initial Developer of the Original&lt;br /&gt;
 * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun&lt;br /&gt;
 * Microsystems, Inc. All Rights Reserved.&lt;br /&gt;
 *&lt;br /&gt;
 * If you wish your version of this file to be governed by only the CDDL&lt;br /&gt;
 * or only the GPL Version 2, indicate your decision by adding&lt;br /&gt;
 * &amp;quot;[Contributor] elects to include this software in this distribution&lt;br /&gt;
 * under the [CDDL or GPL Version 2] license.&amp;quot; If you do not indicate a&lt;br /&gt;
 * single choice of license, a recipient has the option to distribute&lt;br /&gt;
 * your version of this file under either the CDDL, the GPL Version 2 or&lt;br /&gt;
 * to extend the choice of license to its licensees as provided above.&lt;br /&gt;
 * However, if you add GPL Version 2 code and therefore, elected the GPL&lt;br /&gt;
 * Version 2 license, then the option applies only if the new code is&lt;br /&gt;
 * made subject to such option by the copyright holder.&lt;br /&gt;
 */&lt;br /&gt;
&lt;br /&gt;
import java.util.HashSet;&lt;br /&gt;
import java.util.Iterator;&lt;br /&gt;
import java.util.Set;&lt;br /&gt;
/**&lt;br /&gt;
 * @since 4.37&lt;br /&gt;
 * @author Jaroslav Tulach&lt;br /&gt;
 */&lt;br /&gt;
&lt;br /&gt;
public class Utils {&lt;br /&gt;
  /**&lt;br /&gt;
   * Create a typesafe copy of a raw set.&lt;br /&gt;
   * @param rawSet an unchecked set&lt;br /&gt;
   * @param type the desired supertype of the entries&lt;br /&gt;
   * @param strict true to throw a &amp;lt;code&amp;gt;ClassCastException&amp;lt;/code&amp;gt; if the raw set has an invalid entry,&lt;br /&gt;
   *               false to skip over such entries (warnings may be logged)&lt;br /&gt;
   * @return a typed set guaranteed to contain only entries assignable&lt;br /&gt;
   *         to the named type (or they may be null)&lt;br /&gt;
   * @throws ClassCastException if some entry in the raw set was not well-typed, and only if &amp;lt;code&amp;gt;strict&amp;lt;/code&amp;gt; was true&lt;br /&gt;
   */&lt;br /&gt;
  public static &amp;lt;E&amp;gt; Set&amp;lt;E&amp;gt; checkedSetByCopy(Set rawSet, Class&amp;lt;E&amp;gt; type, boolean strict) throws ClassCastException {&lt;br /&gt;
      Set&amp;lt;E&amp;gt; s = new HashSet&amp;lt;E&amp;gt;(rawSet.size() * 4 / 3 + 1);&lt;br /&gt;
      Iterator it = rawSet.iterator();&lt;br /&gt;
      while (it.hasNext()) {&lt;br /&gt;
          Object e = it.next();&lt;br /&gt;
          try {&lt;br /&gt;
              s.add(type.cast(e));&lt;br /&gt;
          } catch (ClassCastException x) {&lt;br /&gt;
              if (strict) {&lt;br /&gt;
                  throw x;&lt;br /&gt;
              } else {&lt;br /&gt;
                 System.out.println(&amp;quot;not assignable &amp;quot;);&lt;br /&gt;
              }&lt;br /&gt;
          }&lt;br /&gt;
      }&lt;br /&gt;
      return s;&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
   &lt;br /&gt;
    &lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Create a typesafe filter of an unchecked enumeration. ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
/*&lt;br /&gt;
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.&lt;br /&gt;
 *&lt;br /&gt;
 * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.&lt;br /&gt;
 *&lt;br /&gt;
 * The contents of this file are subject to the terms of either the GNU&lt;br /&gt;
 * General Public License Version 2 only (&amp;quot;GPL&amp;quot;) or the Common&lt;br /&gt;
 * Development and Distribution License(&amp;quot;CDDL&amp;quot;) (collectively, the&lt;br /&gt;
 * &amp;quot;License&amp;quot;). You may not use this file except in compliance with the&lt;br /&gt;
 * License. You can obtain a copy of the License at&lt;br /&gt;
 * http://www.netbeans.org/cddl-gplv2.html&lt;br /&gt;
 * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the&lt;br /&gt;
 * specific language governing permissions and limitations under the&lt;br /&gt;
 * License.  When distributing the software, include this License Header&lt;br /&gt;
 * Notice in each file and include the License file at&lt;br /&gt;
 * nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this&lt;br /&gt;
 * particular file as subject to the &amp;quot;Classpath&amp;quot; exception as provided&lt;br /&gt;
 * by Sun in the GPL Version 2 section of the License file that&lt;br /&gt;
 * accompanied this code. If applicable, add the following below the&lt;br /&gt;
 * License Header, with the fields enclosed by brackets [] replaced by&lt;br /&gt;
 * your own identifying information:&lt;br /&gt;
 * &amp;quot;Portions Copyrighted [year] [name of copyright owner]&amp;quot;&lt;br /&gt;
 *&lt;br /&gt;
 * Contributor(s):&lt;br /&gt;
 *&lt;br /&gt;
 * The Original Software is NetBeans. The Initial Developer of the Original&lt;br /&gt;
 * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun&lt;br /&gt;
 * Microsystems, Inc. All Rights Reserved.&lt;br /&gt;
 *&lt;br /&gt;
 * If you wish your version of this file to be governed by only the CDDL&lt;br /&gt;
 * or only the GPL Version 2, indicate your decision by adding&lt;br /&gt;
 * &amp;quot;[Contributor] elects to include this software in this distribution&lt;br /&gt;
 * under the [CDDL or GPL Version 2] license.&amp;quot; If you do not indicate a&lt;br /&gt;
 * single choice of license, a recipient has the option to distribute&lt;br /&gt;
 * your version of this file under either the CDDL, the GPL Version 2 or&lt;br /&gt;
 * to extend the choice of license to its licensees as provided above.&lt;br /&gt;
 * However, if you add GPL Version 2 code and therefore, elected the GPL&lt;br /&gt;
 * Version 2 license, then the option applies only if the new code is&lt;br /&gt;
 * made subject to such option by the copyright holder.&lt;br /&gt;
 */&lt;br /&gt;
import java.io.Serializable;&lt;br /&gt;
import java.util.AbstractMap;&lt;br /&gt;
import java.util.AbstractSet;&lt;br /&gt;
import java.util.Collection;&lt;br /&gt;
import java.util.Enumeration;&lt;br /&gt;
import java.util.Iterator;&lt;br /&gt;
import java.util.Map;&lt;br /&gt;
import java.util.NoSuchElementException;&lt;br /&gt;
import java.util.Set;&lt;br /&gt;
/**&lt;br /&gt;
 * @since 4.37&lt;br /&gt;
 * @author Jaroslav Tulach&lt;br /&gt;
 */&lt;br /&gt;
&lt;br /&gt;
public class Utils {&lt;br /&gt;
  /**&lt;br /&gt;
   * Create a typesafe filter of an unchecked enumeration.&lt;br /&gt;
   * @param rawEnum an unchecked enumeration&lt;br /&gt;
   * @param type the desired enumeration type&lt;br /&gt;
   * @param strict if false, elements which are not null but not assignable to the requested type are omitted;&lt;br /&gt;
   *               if true, {@link ClassCastException} may be thrown from an enumeration operation&lt;br /&gt;
   * @return an enumeration guaranteed to contain only objects of the requested type (or null)&lt;br /&gt;
   */&lt;br /&gt;
  public static &amp;lt;E&amp;gt; Enumeration&amp;lt;E&amp;gt; checkedEnumerationByFilter(Enumeration rawEnum, final Class&amp;lt;E&amp;gt; type, final boolean strict) {&lt;br /&gt;
      @SuppressWarnings(&amp;quot;unchecked&amp;quot;)&lt;br /&gt;
      Enumeration&amp;lt;Object&amp;gt; _rawEnum = rawEnum;&lt;br /&gt;
      return Enumerations.&amp;lt;Object,E&amp;gt;filter(_rawEnum, new Enumerations.Processor&amp;lt;Object,E&amp;gt;() {&lt;br /&gt;
          public E process(Object o, Collection&amp;lt;Object&amp;gt; ignore) {&lt;br /&gt;
              if (o == null) {&lt;br /&gt;
                  return null;&lt;br /&gt;
              } else {&lt;br /&gt;
                  try {&lt;br /&gt;
                      return type.cast(o);&lt;br /&gt;
                  } catch (ClassCastException x) {&lt;br /&gt;
                      if (strict) {&lt;br /&gt;
                          throw x;&lt;br /&gt;
                      } else {&lt;br /&gt;
                          return null;&lt;br /&gt;
                      }&lt;br /&gt;
                  }&lt;br /&gt;
              }&lt;br /&gt;
          }&lt;br /&gt;
      });&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
abstract class CheckedIterator&amp;lt;E&amp;gt; implements Iterator&amp;lt;E&amp;gt; {&lt;br /&gt;
  static final Object WAITING = new Object();&lt;br /&gt;
  private final Iterator it;&lt;br /&gt;
  private Object next = WAITING;&lt;br /&gt;
  public CheckedIterator(Iterator it) {&lt;br /&gt;
    this.it = it;&lt;br /&gt;
  }&lt;br /&gt;
  protected abstract boolean accept(Object o);&lt;br /&gt;
  public boolean hasNext() {&lt;br /&gt;
    if (next != WAITING) {&lt;br /&gt;
      return true;&lt;br /&gt;
    }&lt;br /&gt;
    while (it.hasNext()) {&lt;br /&gt;
      next = it.next();&lt;br /&gt;
      if (accept(next)) {&lt;br /&gt;
        return true;&lt;br /&gt;
      }&lt;br /&gt;
    }&lt;br /&gt;
    next = WAITING;&lt;br /&gt;
    return false;&lt;br /&gt;
  }&lt;br /&gt;
  public E next() {&lt;br /&gt;
    if (next == WAITING &amp;amp;&amp;amp; !hasNext()) {&lt;br /&gt;
      throw new NoSuchElementException();&lt;br /&gt;
    }&lt;br /&gt;
    assert next != WAITING;&lt;br /&gt;
    @SuppressWarnings(&amp;quot;unchecked&amp;quot;)&lt;br /&gt;
    // type-checking is done by accept()&lt;br /&gt;
    E x = (E) next;&lt;br /&gt;
    next = WAITING;&lt;br /&gt;
    return x;&lt;br /&gt;
  }&lt;br /&gt;
  public void remove() {&lt;br /&gt;
    it.remove();&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
   &lt;br /&gt;
    &lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Create a typesafe filter of an unchecked iterator. ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
/*&lt;br /&gt;
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.&lt;br /&gt;
 *&lt;br /&gt;
 * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.&lt;br /&gt;
 *&lt;br /&gt;
 * The contents of this file are subject to the terms of either the GNU&lt;br /&gt;
 * General Public License Version 2 only (&amp;quot;GPL&amp;quot;) or the Common&lt;br /&gt;
 * Development and Distribution License(&amp;quot;CDDL&amp;quot;) (collectively, the&lt;br /&gt;
 * &amp;quot;License&amp;quot;). You may not use this file except in compliance with the&lt;br /&gt;
 * License. You can obtain a copy of the License at&lt;br /&gt;
 * http://www.netbeans.org/cddl-gplv2.html&lt;br /&gt;
 * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the&lt;br /&gt;
 * specific language governing permissions and limitations under the&lt;br /&gt;
 * License.  When distributing the software, include this License Header&lt;br /&gt;
 * Notice in each file and include the License file at&lt;br /&gt;
 * nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this&lt;br /&gt;
 * particular file as subject to the &amp;quot;Classpath&amp;quot; exception as provided&lt;br /&gt;
 * by Sun in the GPL Version 2 section of the License file that&lt;br /&gt;
 * accompanied this code. If applicable, add the following below the&lt;br /&gt;
 * License Header, with the fields enclosed by brackets [] replaced by&lt;br /&gt;
 * your own identifying information:&lt;br /&gt;
 * &amp;quot;Portions Copyrighted [year] [name of copyright owner]&amp;quot;&lt;br /&gt;
 *&lt;br /&gt;
 * Contributor(s):&lt;br /&gt;
 *&lt;br /&gt;
 * The Original Software is NetBeans. The Initial Developer of the Original&lt;br /&gt;
 * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun&lt;br /&gt;
 * Microsystems, Inc. All Rights Reserved.&lt;br /&gt;
 *&lt;br /&gt;
 * If you wish your version of this file to be governed by only the CDDL&lt;br /&gt;
 * or only the GPL Version 2, indicate your decision by adding&lt;br /&gt;
 * &amp;quot;[Contributor] elects to include this software in this distribution&lt;br /&gt;
 * under the [CDDL or GPL Version 2] license.&amp;quot; If you do not indicate a&lt;br /&gt;
 * single choice of license, a recipient has the option to distribute&lt;br /&gt;
 * your version of this file under either the CDDL, the GPL Version 2 or&lt;br /&gt;
 * to extend the choice of license to its licensees as provided above.&lt;br /&gt;
 * However, if you add GPL Version 2 code and therefore, elected the GPL&lt;br /&gt;
 * Version 2 license, then the option applies only if the new code is&lt;br /&gt;
 * made subject to such option by the copyright holder.&lt;br /&gt;
 */&lt;br /&gt;
import java.util.Iterator;&lt;br /&gt;
import java.util.NoSuchElementException;&lt;br /&gt;
/**&lt;br /&gt;
 * @since 4.37&lt;br /&gt;
 * @author Jaroslav Tulach&lt;br /&gt;
 */&lt;br /&gt;
public class Utils {&lt;br /&gt;
  /**&lt;br /&gt;
   * Create a typesafe filter of an unchecked iterator. {@link Iterator#remove}&lt;br /&gt;
   * will work if it does in the unchecked iterator.&lt;br /&gt;
   * &lt;br /&gt;
   * @param rawIterator&lt;br /&gt;
   *          an unchecked iterator&lt;br /&gt;
   * @param type&lt;br /&gt;
   *          the desired enumeration type&lt;br /&gt;
   * @param strict&lt;br /&gt;
   *          if false, elements which are not null but not assignable to the&lt;br /&gt;
   *          requested type are omitted; if true, {@link ClassCastException}&lt;br /&gt;
   *          may be thrown from an iterator operation&lt;br /&gt;
   * @return an iterator guaranteed to contain only objects of the requested&lt;br /&gt;
   *         type (or null)&lt;br /&gt;
   */&lt;br /&gt;
  public static &amp;lt;E&amp;gt; Iterator&amp;lt;E&amp;gt; checkedIteratorByFilter(Iterator rawIterator, final Class&amp;lt;E&amp;gt; type,&lt;br /&gt;
      final boolean strict) {&lt;br /&gt;
    return new CheckedIterator&amp;lt;E&amp;gt;(rawIterator) {&lt;br /&gt;
      protected boolean accept(Object o) {&lt;br /&gt;
        if (o == null) {&lt;br /&gt;
          return true;&lt;br /&gt;
        } else if (type.isInstance(o)) {&lt;br /&gt;
          return true;&lt;br /&gt;
        } else if (strict) {&lt;br /&gt;
          throw new ClassCastException(o + &amp;quot; was not a &amp;quot; + type.getName()); // NOI18N&lt;br /&gt;
        } else {&lt;br /&gt;
          return false;&lt;br /&gt;
        }&lt;br /&gt;
      }&lt;br /&gt;
    };&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
abstract class CheckedIterator&amp;lt;E&amp;gt; implements Iterator&amp;lt;E&amp;gt; {&lt;br /&gt;
  static final Object WAITING = new Object();&lt;br /&gt;
  private final Iterator it;&lt;br /&gt;
  private Object next = WAITING;&lt;br /&gt;
  public CheckedIterator(Iterator it) {&lt;br /&gt;
    this.it = it;&lt;br /&gt;
  }&lt;br /&gt;
  protected abstract boolean accept(Object o);&lt;br /&gt;
  public boolean hasNext() {&lt;br /&gt;
    if (next != WAITING) {&lt;br /&gt;
      return true;&lt;br /&gt;
    }&lt;br /&gt;
    while (it.hasNext()) {&lt;br /&gt;
      next = it.next();&lt;br /&gt;
      if (accept(next)) {&lt;br /&gt;
        return true;&lt;br /&gt;
      }&lt;br /&gt;
    }&lt;br /&gt;
    next = WAITING;&lt;br /&gt;
    return false;&lt;br /&gt;
  }&lt;br /&gt;
  public E next() {&lt;br /&gt;
    if (next == WAITING &amp;amp;&amp;amp; !hasNext()) {&lt;br /&gt;
      throw new NoSuchElementException();&lt;br /&gt;
    }&lt;br /&gt;
    assert next != WAITING;&lt;br /&gt;
    @SuppressWarnings(&amp;quot;unchecked&amp;quot;)&lt;br /&gt;
    // type-checking is done by accept()&lt;br /&gt;
    E x = (E) next;&lt;br /&gt;
    next = WAITING;&lt;br /&gt;
    return x;&lt;br /&gt;
  }&lt;br /&gt;
  public void remove() {&lt;br /&gt;
    it.remove();&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
   &lt;br /&gt;
    &lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Create a typesafe view over an underlying raw map. ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
/*&lt;br /&gt;
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.&lt;br /&gt;
 *&lt;br /&gt;
 * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.&lt;br /&gt;
 *&lt;br /&gt;
 * The contents of this file are subject to the terms of either the GNU&lt;br /&gt;
 * General Public License Version 2 only (&amp;quot;GPL&amp;quot;) or the Common&lt;br /&gt;
 * Development and Distribution License(&amp;quot;CDDL&amp;quot;) (collectively, the&lt;br /&gt;
 * &amp;quot;License&amp;quot;). You may not use this file except in compliance with the&lt;br /&gt;
 * License. You can obtain a copy of the License at&lt;br /&gt;
 * http://www.netbeans.org/cddl-gplv2.html&lt;br /&gt;
 * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the&lt;br /&gt;
 * specific language governing permissions and limitations under the&lt;br /&gt;
 * License.  When distributing the software, include this License Header&lt;br /&gt;
 * Notice in each file and include the License file at&lt;br /&gt;
 * nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this&lt;br /&gt;
 * particular file as subject to the &amp;quot;Classpath&amp;quot; exception as provided&lt;br /&gt;
 * by Sun in the GPL Version 2 section of the License file that&lt;br /&gt;
 * accompanied this code. If applicable, add the following below the&lt;br /&gt;
 * License Header, with the fields enclosed by brackets [] replaced by&lt;br /&gt;
 * your own identifying information:&lt;br /&gt;
 * &amp;quot;Portions Copyrighted [year] [name of copyright owner]&amp;quot;&lt;br /&gt;
 *&lt;br /&gt;
 * Contributor(s):&lt;br /&gt;
 *&lt;br /&gt;
 * The Original Software is NetBeans. The Initial Developer of the Original&lt;br /&gt;
 * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun&lt;br /&gt;
 * Microsystems, Inc. All Rights Reserved.&lt;br /&gt;
 *&lt;br /&gt;
 * If you wish your version of this file to be governed by only the CDDL&lt;br /&gt;
 * or only the GPL Version 2, indicate your decision by adding&lt;br /&gt;
 * &amp;quot;[Contributor] elects to include this software in this distribution&lt;br /&gt;
 * under the [CDDL or GPL Version 2] license.&amp;quot; If you do not indicate a&lt;br /&gt;
 * single choice of license, a recipient has the option to distribute&lt;br /&gt;
 * your version of this file under either the CDDL, the GPL Version 2 or&lt;br /&gt;
 * to extend the choice of license to its licensees as provided above.&lt;br /&gt;
 * However, if you add GPL Version 2 code and therefore, elected the GPL&lt;br /&gt;
 * Version 2 license, then the option applies only if the new code is&lt;br /&gt;
 * made subject to such option by the copyright holder.&lt;br /&gt;
 */&lt;br /&gt;
import java.io.Serializable;&lt;br /&gt;
import java.util.AbstractMap;&lt;br /&gt;
import java.util.AbstractSet;&lt;br /&gt;
import java.util.Iterator;&lt;br /&gt;
import java.util.Map;&lt;br /&gt;
import java.util.NoSuchElementException;&lt;br /&gt;
import java.util.Set;&lt;br /&gt;
/**&lt;br /&gt;
 * @since 4.37&lt;br /&gt;
 * @author Jaroslav Tulach&lt;br /&gt;
 */&lt;br /&gt;
&lt;br /&gt;
public class Utils {&lt;br /&gt;
  /**&lt;br /&gt;
   * Create a typesafe view over an underlying raw map.&lt;br /&gt;
   * Mutations affect the underlying map (this is not a copy).&lt;br /&gt;
   * {@link Map#clear} will make the view empty but may not clear the underlying map.&lt;br /&gt;
   * You may add entries only of the requested type pair.&lt;br /&gt;
   * {@link Map#get}, {@link Map#containsKey}, and {@link Map#containsValue} also perform a type check&lt;br /&gt;
   * and will throw {@link ClassCastException} for an illegal argument.&lt;br /&gt;
   * The view is serializable if the underlying map is.&lt;br /&gt;
   * @param rawMap an unchecked map&lt;br /&gt;
   * @param keyType the desired entry key type&lt;br /&gt;
   * @param valueType the desired entry value type&lt;br /&gt;
   * @param strict if false, entries in the underlying map for which the key is not null but not assignable&lt;br /&gt;
   *               to the requested key type, and/or the value is not null but not assignable to&lt;br /&gt;
   *               the requested value type, are omitted from the view;&lt;br /&gt;
   *               if true, a {@link ClassCastException} may arise during some map operation&lt;br /&gt;
   * @return a view over the raw map guaranteed to match the specified type&lt;br /&gt;
   */&lt;br /&gt;
  public static &amp;lt;K,V&amp;gt; Map&amp;lt;K,V&amp;gt; checkedMapByFilter(Map rawMap, Class&amp;lt;K&amp;gt; keyType, Class&amp;lt;V&amp;gt; valueType, boolean strict) {&lt;br /&gt;
      return new CheckedMap&amp;lt;K,V&amp;gt;(rawMap, keyType, valueType, strict);&lt;br /&gt;
  }&lt;br /&gt;
  private static final class CheckedMap&amp;lt;K,V&amp;gt; extends AbstractMap&amp;lt;K,V&amp;gt; implements Serializable {&lt;br /&gt;
      private static final long serialVersionUID = 1L;&lt;br /&gt;
      private final Map rawMap;&lt;br /&gt;
      private final Class&amp;lt;K&amp;gt; keyType;&lt;br /&gt;
      private final Class&amp;lt;V&amp;gt; valueType;&lt;br /&gt;
      private final boolean strict;&lt;br /&gt;
      public CheckedMap(Map rawMap, Class&amp;lt;K&amp;gt; keyType, Class&amp;lt;V&amp;gt; valueType, boolean strict) {&lt;br /&gt;
          this.rawMap = rawMap;&lt;br /&gt;
          this.keyType = keyType;&lt;br /&gt;
          this.valueType = valueType;&lt;br /&gt;
          this.strict = strict;&lt;br /&gt;
      }&lt;br /&gt;
      private boolean acceptKey(Object o) {&lt;br /&gt;
          if (o == null) {&lt;br /&gt;
              return true;&lt;br /&gt;
          } else if (keyType.isInstance(o)) {&lt;br /&gt;
              return true;&lt;br /&gt;
          } else if (strict) {&lt;br /&gt;
              throw new ClassCastException(o + &amp;quot; was not a &amp;quot; + keyType.getName()); // NOI18N&lt;br /&gt;
          } else {&lt;br /&gt;
              return false;&lt;br /&gt;
          }&lt;br /&gt;
      }&lt;br /&gt;
      private boolean acceptValue(Object o) {&lt;br /&gt;
          if (o == null) {&lt;br /&gt;
              return true;&lt;br /&gt;
          } else if (valueType.isInstance(o)) {&lt;br /&gt;
              return true;&lt;br /&gt;
          } else if (strict) {&lt;br /&gt;
              throw new ClassCastException(o + &amp;quot; was not a &amp;quot; + valueType.getName()); // NOI18N&lt;br /&gt;
          } else {&lt;br /&gt;
              return false;&lt;br /&gt;
          }&lt;br /&gt;
      }&lt;br /&gt;
      private boolean acceptEntry(Map.Entry e) {&lt;br /&gt;
          return acceptKey(e.getKey()) &amp;amp;&amp;amp; acceptValue(e.getValue());&lt;br /&gt;
      }&lt;br /&gt;
      private final class EntrySet extends AbstractSet&amp;lt;Map.Entry&amp;lt;K, V&amp;gt;&amp;gt; {&lt;br /&gt;
          @Override&lt;br /&gt;
          public Iterator&amp;lt;Map.Entry&amp;lt;K,V&amp;gt;&amp;gt; iterator() {&lt;br /&gt;
              return new CheckedIterator&amp;lt;Map.Entry&amp;lt;K,V&amp;gt;&amp;gt;(rawMap.entrySet().iterator()) {&lt;br /&gt;
                  @Override&lt;br /&gt;
                  protected boolean accept(Object o) {&lt;br /&gt;
                      return acceptEntry((Map.Entry) o);&lt;br /&gt;
                  }&lt;br /&gt;
              };&lt;br /&gt;
          }&lt;br /&gt;
          @Override&lt;br /&gt;
          public int size() {&lt;br /&gt;
              int c = 0;&lt;br /&gt;
              Iterator it = rawMap.entrySet().iterator();&lt;br /&gt;
              while (it.hasNext()) {&lt;br /&gt;
                  if (acceptEntry((Map.Entry) it.next())) {&lt;br /&gt;
                      c++;&lt;br /&gt;
                  }&lt;br /&gt;
              }&lt;br /&gt;
              return c;&lt;br /&gt;
          }&lt;br /&gt;
      }&lt;br /&gt;
      @Override&lt;br /&gt;
      public Set&amp;lt;Map.Entry&amp;lt;K, V&amp;gt;&amp;gt; entrySet() {&lt;br /&gt;
          return new EntrySet();&lt;br /&gt;
      }&lt;br /&gt;
      @Override&lt;br /&gt;
      public V get(Object key) {&lt;br /&gt;
          Object o = rawMap.get(keyType.cast(key));&lt;br /&gt;
          if (acceptValue(o)) {&lt;br /&gt;
              @SuppressWarnings(&amp;quot;unchecked&amp;quot;)&lt;br /&gt;
              V v = (V) o;&lt;br /&gt;
              return v;&lt;br /&gt;
          } else {&lt;br /&gt;
              return null;&lt;br /&gt;
          }&lt;br /&gt;
      }&lt;br /&gt;
      @SuppressWarnings(&amp;quot;unchecked&amp;quot;)&lt;br /&gt;
      @Override&lt;br /&gt;
      public V put(K key, V value) {&lt;br /&gt;
          Object old = rawMap.put(keyType.cast(key), valueType.cast(value));&lt;br /&gt;
          if (acceptValue(old)) {&lt;br /&gt;
              return (V) old;&lt;br /&gt;
          } else {&lt;br /&gt;
              return null;&lt;br /&gt;
          }&lt;br /&gt;
      }&lt;br /&gt;
      @Override&lt;br /&gt;
      public V remove(Object key) {&lt;br /&gt;
          Object old = rawMap.remove(keyType.cast(key));&lt;br /&gt;
          if (acceptValue(old)) {&lt;br /&gt;
              @SuppressWarnings(&amp;quot;unchecked&amp;quot;)&lt;br /&gt;
              V v = (V) old;&lt;br /&gt;
              return v;&lt;br /&gt;
          } else {&lt;br /&gt;
              return null;&lt;br /&gt;
          }&lt;br /&gt;
      }&lt;br /&gt;
      @Override&lt;br /&gt;
      public boolean containsKey(Object key) {&lt;br /&gt;
          return rawMap.containsKey(keyType.cast(key)) &amp;amp;&amp;amp;&lt;br /&gt;
                  acceptValue(rawMap.get(key));&lt;br /&gt;
      }&lt;br /&gt;
      @Override&lt;br /&gt;
      public boolean containsValue(Object value) {&lt;br /&gt;
          // Cannot just ask rawMap since we could not check type of key.&lt;br /&gt;
          return super.containsValue(valueType.cast(value));&lt;br /&gt;
      }&lt;br /&gt;
      @Override&lt;br /&gt;
      public int size() {&lt;br /&gt;
          int c = 0;&lt;br /&gt;
          Iterator it = rawMap.entrySet().iterator();&lt;br /&gt;
          while (it.hasNext()) {&lt;br /&gt;
              if (acceptEntry((Map.Entry) it.next())) {&lt;br /&gt;
                  c++;&lt;br /&gt;
              }&lt;br /&gt;
          }&lt;br /&gt;
          return c;&lt;br /&gt;
      }&lt;br /&gt;
      // keySet, values cannot be so easily overridden because we type-check whole entries&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
abstract class CheckedIterator&amp;lt;E&amp;gt; implements Iterator&amp;lt;E&amp;gt; {&lt;br /&gt;
  static final Object WAITING = new Object();&lt;br /&gt;
  private final Iterator it;&lt;br /&gt;
  private Object next = WAITING;&lt;br /&gt;
  public CheckedIterator(Iterator it) {&lt;br /&gt;
    this.it = it;&lt;br /&gt;
  }&lt;br /&gt;
  protected abstract boolean accept(Object o);&lt;br /&gt;
  public boolean hasNext() {&lt;br /&gt;
    if (next != WAITING) {&lt;br /&gt;
      return true;&lt;br /&gt;
    }&lt;br /&gt;
    while (it.hasNext()) {&lt;br /&gt;
      next = it.next();&lt;br /&gt;
      if (accept(next)) {&lt;br /&gt;
        return true;&lt;br /&gt;
      }&lt;br /&gt;
    }&lt;br /&gt;
    next = WAITING;&lt;br /&gt;
    return false;&lt;br /&gt;
  }&lt;br /&gt;
  public E next() {&lt;br /&gt;
    if (next == WAITING &amp;amp;&amp;amp; !hasNext()) {&lt;br /&gt;
      throw new NoSuchElementException();&lt;br /&gt;
    }&lt;br /&gt;
    assert next != WAITING;&lt;br /&gt;
    @SuppressWarnings(&amp;quot;unchecked&amp;quot;)&lt;br /&gt;
    // type-checking is done by accept()&lt;br /&gt;
    E x = (E) next;&lt;br /&gt;
    next = WAITING;&lt;br /&gt;
    return x;&lt;br /&gt;
  }&lt;br /&gt;
  public void remove() {&lt;br /&gt;
    it.remove();&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
   &lt;br /&gt;
    &lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Create a typesafe view over an underlying raw set. ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
/*&lt;br /&gt;
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.&lt;br /&gt;
 *&lt;br /&gt;
 * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.&lt;br /&gt;
 *&lt;br /&gt;
 * The contents of this file are subject to the terms of either the GNU&lt;br /&gt;
 * General Public License Version 2 only (&amp;quot;GPL&amp;quot;) or the Common&lt;br /&gt;
 * Development and Distribution License(&amp;quot;CDDL&amp;quot;) (collectively, the&lt;br /&gt;
 * &amp;quot;License&amp;quot;). You may not use this file except in compliance with the&lt;br /&gt;
 * License. You can obtain a copy of the License at&lt;br /&gt;
 * http://www.netbeans.org/cddl-gplv2.html&lt;br /&gt;
 * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the&lt;br /&gt;
 * specific language governing permissions and limitations under the&lt;br /&gt;
 * License.  When distributing the software, include this License Header&lt;br /&gt;
 * Notice in each file and include the License file at&lt;br /&gt;
 * nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this&lt;br /&gt;
 * particular file as subject to the &amp;quot;Classpath&amp;quot; exception as provided&lt;br /&gt;
 * by Sun in the GPL Version 2 section of the License file that&lt;br /&gt;
 * accompanied this code. If applicable, add the following below the&lt;br /&gt;
 * License Header, with the fields enclosed by brackets [] replaced by&lt;br /&gt;
 * your own identifying information:&lt;br /&gt;
 * &amp;quot;Portions Copyrighted [year] [name of copyright owner]&amp;quot;&lt;br /&gt;
 *&lt;br /&gt;
 * Contributor(s):&lt;br /&gt;
 *&lt;br /&gt;
 * The Original Software is NetBeans. The Initial Developer of the Original&lt;br /&gt;
 * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun&lt;br /&gt;
 * Microsystems, Inc. All Rights Reserved.&lt;br /&gt;
 *&lt;br /&gt;
 * If you wish your version of this file to be governed by only the CDDL&lt;br /&gt;
 * or only the GPL Version 2, indicate your decision by adding&lt;br /&gt;
 * &amp;quot;[Contributor] elects to include this software in this distribution&lt;br /&gt;
 * under the [CDDL or GPL Version 2] license.&amp;quot; If you do not indicate a&lt;br /&gt;
 * single choice of license, a recipient has the option to distribute&lt;br /&gt;
 * your version of this file under either the CDDL, the GPL Version 2 or&lt;br /&gt;
 * to extend the choice of license to its licensees as provided above.&lt;br /&gt;
 * However, if you add GPL Version 2 code and therefore, elected the GPL&lt;br /&gt;
 * Version 2 license, then the option applies only if the new code is&lt;br /&gt;
 * made subject to such option by the copyright holder.&lt;br /&gt;
 */&lt;br /&gt;
import java.io.Serializable;&lt;br /&gt;
import java.util.AbstractSet;&lt;br /&gt;
import java.util.Iterator;&lt;br /&gt;
import java.util.NoSuchElementException;&lt;br /&gt;
import java.util.Set;&lt;br /&gt;
/**&lt;br /&gt;
 * @since 4.37&lt;br /&gt;
 * @author Jaroslav Tulach&lt;br /&gt;
 */&lt;br /&gt;
public class Utils {&lt;br /&gt;
  /**&lt;br /&gt;
   * Create a typesafe view over an underlying raw set.&lt;br /&gt;
   * Mutations affect the underlying set (this is not a copy).&lt;br /&gt;
   * {@link Set#clear} will make the view empty but may not clear the underlying set.&lt;br /&gt;
   * You may add elements only of the requested type.&lt;br /&gt;
   * {@link Set#contains} also performs a type check and will throw {@link ClassCastException}&lt;br /&gt;
   * for an illegal argument.&lt;br /&gt;
   * The view is serializable if the underlying set is.&lt;br /&gt;
   * @param rawSet an unchecked set&lt;br /&gt;
   * @param type the desired element type&lt;br /&gt;
   * @param strict if false, elements in the underlying set which are not null and which are not assignable&lt;br /&gt;
   *               to the requested type are omitted from the view;&lt;br /&gt;
   *               if true, a {@link ClassCastException} may arise during some set operation&lt;br /&gt;
   * @return a view over the raw set guaranteed to match the specified type&lt;br /&gt;
   */&lt;br /&gt;
  public static &amp;lt;E&amp;gt; Set&amp;lt;E&amp;gt; checkedSetByFilter(Set rawSet, Class&amp;lt;E&amp;gt; type, boolean strict) {&lt;br /&gt;
      return new CheckedSet&amp;lt;E&amp;gt;(rawSet, type, strict);&lt;br /&gt;
  }&lt;br /&gt;
  private static final class CheckedSet&amp;lt;E&amp;gt; extends AbstractSet&amp;lt;E&amp;gt; implements Serializable {&lt;br /&gt;
      private static final long serialVersionUID = 1L;&lt;br /&gt;
      private final Set rawSet;&lt;br /&gt;
      private final Class&amp;lt;E&amp;gt; type;&lt;br /&gt;
      private final boolean strict;&lt;br /&gt;
      public CheckedSet(Set rawSet, Class&amp;lt;E&amp;gt; type, boolean strict) {&lt;br /&gt;
          this.rawSet = rawSet;&lt;br /&gt;
          this.type = type;&lt;br /&gt;
          this.strict = strict;&lt;br /&gt;
      }&lt;br /&gt;
      private boolean acceptEntry(Object o) {&lt;br /&gt;
          if (o == null) {&lt;br /&gt;
              return true;&lt;br /&gt;
          } else if (type.isInstance(o)) {&lt;br /&gt;
              return true;&lt;br /&gt;
          } else if (strict) {&lt;br /&gt;
              throw new ClassCastException(o + &amp;quot; was not a &amp;quot; + type.getName()); // NOI18N&lt;br /&gt;
          } else {&lt;br /&gt;
              return false;&lt;br /&gt;
          }&lt;br /&gt;
      }&lt;br /&gt;
      @Override&lt;br /&gt;
      public Iterator&amp;lt;E&amp;gt; iterator() {&lt;br /&gt;
          return new CheckedIterator&amp;lt;E&amp;gt;(rawSet.iterator()) {&lt;br /&gt;
              @Override&lt;br /&gt;
              protected boolean accept(Object o) {&lt;br /&gt;
                  return acceptEntry(o);&lt;br /&gt;
              }&lt;br /&gt;
          };&lt;br /&gt;
      }&lt;br /&gt;
      @Override&lt;br /&gt;
      public int size() {&lt;br /&gt;
          int c = 0;&lt;br /&gt;
          Iterator it = rawSet.iterator();&lt;br /&gt;
          while (it.hasNext()) {&lt;br /&gt;
              if (acceptEntry(it.next())) {&lt;br /&gt;
                  c++;&lt;br /&gt;
              }&lt;br /&gt;
          }&lt;br /&gt;
          return c;&lt;br /&gt;
      }&lt;br /&gt;
      @Override&lt;br /&gt;
      @SuppressWarnings(&amp;quot;unchecked&amp;quot;) // complains about usage of raw set&lt;br /&gt;
      public boolean add(E o) {&lt;br /&gt;
          return rawSet.add(type.cast(o));&lt;br /&gt;
      }&lt;br /&gt;
      @Override&lt;br /&gt;
      public boolean contains(Object o) {&lt;br /&gt;
          return rawSet.contains(type.cast(o));&lt;br /&gt;
      }&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
abstract class CheckedIterator&amp;lt;E&amp;gt; implements Iterator&amp;lt;E&amp;gt; {&lt;br /&gt;
  static final Object WAITING = new Object();&lt;br /&gt;
  private final Iterator it;&lt;br /&gt;
  private Object next = WAITING;&lt;br /&gt;
  public CheckedIterator(Iterator it) {&lt;br /&gt;
    this.it = it;&lt;br /&gt;
  }&lt;br /&gt;
  protected abstract boolean accept(Object o);&lt;br /&gt;
  public boolean hasNext() {&lt;br /&gt;
    if (next != WAITING) {&lt;br /&gt;
      return true;&lt;br /&gt;
    }&lt;br /&gt;
    while (it.hasNext()) {&lt;br /&gt;
      next = it.next();&lt;br /&gt;
      if (accept(next)) {&lt;br /&gt;
        return true;&lt;br /&gt;
      }&lt;br /&gt;
    }&lt;br /&gt;
    next = WAITING;&lt;br /&gt;
    return false;&lt;br /&gt;
  }&lt;br /&gt;
  public E next() {&lt;br /&gt;
    if (next == WAITING &amp;amp;&amp;amp; !hasNext()) {&lt;br /&gt;
      throw new NoSuchElementException();&lt;br /&gt;
    }&lt;br /&gt;
    assert next != WAITING;&lt;br /&gt;
    @SuppressWarnings(&amp;quot;unchecked&amp;quot;)&lt;br /&gt;
    // type-checking is done by accept()&lt;br /&gt;
    E x = (E) next;&lt;br /&gt;
    next = WAITING;&lt;br /&gt;
    return x;&lt;br /&gt;
  }&lt;br /&gt;
  public void remove() {&lt;br /&gt;
    it.remove();&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
   &lt;br /&gt;
    &lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Creating a Type-Specific List ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
import java.util.ArrayList;&lt;br /&gt;
import java.util.List;&lt;br /&gt;
public class Main {&lt;br /&gt;
  public static void main(String[] argv) {&lt;br /&gt;
    List&amp;lt;Integer&amp;gt; intlist = new ArrayList&amp;lt;Integer&amp;gt;();&lt;br /&gt;
    intlist.add(new Integer(123));&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
   &lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Data structure and collections: Modern, generics version. ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
/*&lt;br /&gt;
Java 2, v5.0 (Tiger) New Features&lt;br /&gt;
by Herbert Schildt&lt;br /&gt;
ISBN: 0072258543&lt;br /&gt;
Publisher: McGraw-Hill/Osborne, 2004&lt;br /&gt;
*/&lt;br /&gt;
 &lt;br /&gt;
import java.util.*; &lt;br /&gt;
 &lt;br /&gt;
public class NewStyle {  &lt;br /&gt;
  public static void main(String args[]) { &lt;br /&gt;
 &lt;br /&gt;
    // Now, list holds references of type String. &lt;br /&gt;
    ArrayList&amp;lt;String&amp;gt; list = new ArrayList&amp;lt;String&amp;gt;(); &lt;br /&gt;
 &lt;br /&gt;
    list.add(&amp;quot;one&amp;quot;); &lt;br /&gt;
    list.add(&amp;quot;two&amp;quot;); &lt;br /&gt;
    list.add(&amp;quot;three&amp;quot;); &lt;br /&gt;
    list.add(&amp;quot;four&amp;quot;); &lt;br /&gt;
 &lt;br /&gt;
    // Notice that Iterator is also generic. &lt;br /&gt;
    Iterator&amp;lt;String&amp;gt; itr = list.iterator(); &lt;br /&gt;
 &lt;br /&gt;
    // The following statement will now cause a compile-time eror. &lt;br /&gt;
//    Iterator&amp;lt;Integer&amp;gt; itr = list.iterator(); // Error! &lt;br /&gt;
 &lt;br /&gt;
    while(itr.hasNext()) { &lt;br /&gt;
      String str = itr.next(); // no cast needed &lt;br /&gt;
 &lt;br /&gt;
      // Now, the following line is a compile-time, &lt;br /&gt;
      // rather than runtime, error. &lt;br /&gt;
//    Integer i = itr.next(); // this won&amp;quot;t compile &lt;br /&gt;
 &lt;br /&gt;
      System.out.println(str + &amp;quot; is &amp;quot; + str.length() + &amp;quot; chars long.&amp;quot;); &lt;br /&gt;
    } &lt;br /&gt;
  }  &lt;br /&gt;
}&lt;br /&gt;
           &lt;br /&gt;
         &lt;br /&gt;
    &lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Enum and Generic ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
/*&lt;br /&gt;
 * Copyright (c) Ian F. Darwin, http://www.darwinsys.ru/, 1996-2002.&lt;br /&gt;
 * All rights reserved. Software written by Ian F. Darwin and others.&lt;br /&gt;
 * $Id: LICENSE,v 1.8 2004/02/09 03:33:38 ian Exp $&lt;br /&gt;
 *&lt;br /&gt;
 * Redistribution and use in source and binary forms, with or without&lt;br /&gt;
 * modification, are permitted provided that the following conditions&lt;br /&gt;
 * are met:&lt;br /&gt;
 * 1. Redistributions of source code must retain the above copyright&lt;br /&gt;
 *    notice, this list of conditions and the following disclaimer.&lt;br /&gt;
 * 2. Redistributions in binary form must reproduce the above copyright&lt;br /&gt;
 *    notice, this list of conditions and the following disclaimer in the&lt;br /&gt;
 *    documentation and/or other materials provided with the distribution.&lt;br /&gt;
 *&lt;br /&gt;
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS&amp;quot;&amp;quot;&lt;br /&gt;
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED&lt;br /&gt;
 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR&lt;br /&gt;
 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS&lt;br /&gt;
 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR&lt;br /&gt;
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF&lt;br /&gt;
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS&lt;br /&gt;
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN&lt;br /&gt;
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)&lt;br /&gt;
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE&lt;br /&gt;
 * POSSIBILITY OF SUCH DAMAGE.&lt;br /&gt;
 * &lt;br /&gt;
 * Java, the Duke mascot, and all variants of Sun&amp;quot;s Java &amp;quot;steaming coffee&lt;br /&gt;
 * cup&amp;quot; logo are trademarks of Sun Microsystems. Sun&amp;quot;s, and James Gosling&amp;quot;s,&lt;br /&gt;
 * pioneering role in inventing and promulgating (and standardizing) the Java &lt;br /&gt;
 * language and environment is gratefully acknowledged.&lt;br /&gt;
 * &lt;br /&gt;
 * The pioneering role of Dennis Ritchie and Bjarne Stroustrup, of AT&amp;amp;T, for&lt;br /&gt;
 * inventing predecessor languages C and C++ is also gratefully acknowledged.&lt;br /&gt;
 */&lt;br /&gt;
import java.io.BufferedReader;&lt;br /&gt;
import java.io.IOException;&lt;br /&gt;
import java.io.InputStreamReader;&lt;br /&gt;
import java.io.InputStream;&lt;br /&gt;
import java.io.PrintStream;&lt;br /&gt;
import java.util.ArrayList;&lt;br /&gt;
import java.util.List;&lt;br /&gt;
import java.util.StringTokenizer;&lt;br /&gt;
/**&lt;br /&gt;
 * MediaInvoicer - Simple applicatin of Media, MediaFactory &amp;amp;c.&lt;br /&gt;
 * &lt;br /&gt;
 * @author ian&lt;br /&gt;
 * @version $Id: MediaInvoicer.java,v 1.2 2004/03/08 03:30:59 ian Exp $&lt;br /&gt;
 */&lt;br /&gt;
public class MediaInvoicer {&lt;br /&gt;
  public static void main(String[] args) throws IOException {&lt;br /&gt;
    MediaInvoicer mi = new MediaInvoicer(System.in);&lt;br /&gt;
    Invoice i = mi.getInvoice();&lt;br /&gt;
    i.print(System.out);&lt;br /&gt;
  }&lt;br /&gt;
  BufferedReader myFile;&lt;br /&gt;
  public MediaInvoicer(InputStream is) {&lt;br /&gt;
    myFile = new BufferedReader(new InputStreamReader(is));&lt;br /&gt;
  }&lt;br /&gt;
  public Invoice getInvoice() throws IOException {&lt;br /&gt;
    String line;&lt;br /&gt;
    List &amp;lt; Item &amp;gt; items = new ArrayList &amp;lt; Item &amp;gt; ();&lt;br /&gt;
    while ((line = myFile.readLine()) != null) {&lt;br /&gt;
      if (line.startsWith(&amp;quot;#&amp;quot;)) {&lt;br /&gt;
        continue;&lt;br /&gt;
      }&lt;br /&gt;
      StringTokenizer st = new StringTokenizer(line);&lt;br /&gt;
      st.nextToken();&lt;br /&gt;
      Media m = MediaFactory.getMedia(st.nextToken());&lt;br /&gt;
      int stock = Integer.parseInt(st.nextToken());&lt;br /&gt;
      int qty = Integer.parseInt(st.nextToken());&lt;br /&gt;
      Item tmp = new Item(m, stock, qty);&lt;br /&gt;
      items.add(tmp);&lt;br /&gt;
    }&lt;br /&gt;
    return new Invoice(1, 3,&lt;br /&gt;
      (Item[]) items.toArray(new Item[items.size()]));&lt;br /&gt;
  }&lt;br /&gt;
  /** Inner class for line order item */&lt;br /&gt;
  class Item {&lt;br /&gt;
    Media product;&lt;br /&gt;
    int stockNumber;&lt;br /&gt;
    int quantity;&lt;br /&gt;
    /**&lt;br /&gt;
     * @param product&lt;br /&gt;
     * @param stockNumber&lt;br /&gt;
     * @param quantity&lt;br /&gt;
     */&lt;br /&gt;
    public Item(Media product, int stockNumber, int quantity) {&lt;br /&gt;
      super();&lt;br /&gt;
      this.product = product;&lt;br /&gt;
      this.stockNumber = stockNumber;&lt;br /&gt;
      this.quantity = quantity;&lt;br /&gt;
    }&lt;br /&gt;
    public String toString() {&lt;br /&gt;
      return &amp;quot;Item[&amp;quot; + product + &amp;quot; &amp;quot; + stockNumber + &amp;quot;]&amp;quot;;&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
  /** Inner class for one invoice */&lt;br /&gt;
  class Invoice {&lt;br /&gt;
    int orderNumber;&lt;br /&gt;
    int custNumber;&lt;br /&gt;
    Item[] items;&lt;br /&gt;
    public Invoice(int orderNumber, int custNumber, Item[] items) {&lt;br /&gt;
      super();&lt;br /&gt;
      this.orderNumber = orderNumber;&lt;br /&gt;
      this.custNumber = custNumber;&lt;br /&gt;
      this.items = items;&lt;br /&gt;
    }&lt;br /&gt;
    public void print(PrintStream ps) {&lt;br /&gt;
      ps.println(&amp;quot;*** Invoice ***&amp;quot;);&lt;br /&gt;
      ps.println(&amp;quot;Customer: &amp;quot; + custNumber + &amp;quot;)&amp;quot;);&lt;br /&gt;
      ps.println(&amp;quot;Our order number: &amp;quot; + orderNumber);&lt;br /&gt;
      for (int i = 0; i &amp;lt; items.length; i++) {&lt;br /&gt;
        Item it = items[i];&lt;br /&gt;
        ps.println(it);&lt;br /&gt;
      }&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
enum Media {&lt;br /&gt;
  book, music_cd, music_vinyl, movie_vhs, movie_dvd;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
           &lt;br /&gt;
         &lt;br /&gt;
    &lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Foreach and generic data structure ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
/*&lt;br /&gt;
 * Copyright (c) Ian F. Darwin, http://www.darwinsys.ru/, 1996-2002.&lt;br /&gt;
 * All rights reserved. Software written by Ian F. Darwin and others.&lt;br /&gt;
 * $Id: LICENSE,v 1.8 2004/02/09 03:33:38 ian Exp $&lt;br /&gt;
 *&lt;br /&gt;
 * Redistribution and use in source and binary forms, with or without&lt;br /&gt;
 * modification, are permitted provided that the following conditions&lt;br /&gt;
 * are met:&lt;br /&gt;
 * 1. Redistributions of source code must retain the above copyright&lt;br /&gt;
 *    notice, this list of conditions and the following disclaimer.&lt;br /&gt;
 * 2. Redistributions in binary form must reproduce the above copyright&lt;br /&gt;
 *    notice, this list of conditions and the following disclaimer in the&lt;br /&gt;
 *    documentation and/or other materials provided with the distribution.&lt;br /&gt;
 *&lt;br /&gt;
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS&amp;quot;&amp;quot;&lt;br /&gt;
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED&lt;br /&gt;
 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR&lt;br /&gt;
 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS&lt;br /&gt;
 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR&lt;br /&gt;
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF&lt;br /&gt;
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS&lt;br /&gt;
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN&lt;br /&gt;
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)&lt;br /&gt;
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE&lt;br /&gt;
 * POSSIBILITY OF SUCH DAMAGE.&lt;br /&gt;
 * &lt;br /&gt;
 * Java, the Duke mascot, and all variants of Sun&amp;quot;s Java &amp;quot;steaming coffee&lt;br /&gt;
 * cup&amp;quot; logo are trademarks of Sun Microsystems. Sun&amp;quot;s, and James Gosling&amp;quot;s,&lt;br /&gt;
 * pioneering role in inventing and promulgating (and standardizing) the Java &lt;br /&gt;
 * language and environment is gratefully acknowledged.&lt;br /&gt;
 * &lt;br /&gt;
 * The pioneering role of Dennis Ritchie and Bjarne Stroustrup, of AT&amp;amp;T, for&lt;br /&gt;
 * inventing predecessor languages C and C++ is also gratefully acknowledged.&lt;br /&gt;
 */&lt;br /&gt;
import java.util.Collection;&lt;br /&gt;
import java.util.List;&lt;br /&gt;
import java.util.ArrayList;&lt;br /&gt;
public class ForeachDemo {&lt;br /&gt;
  static void iterate(Collection&amp;lt;String&amp;gt; c) {&lt;br /&gt;
      for (String s : c)&lt;br /&gt;
      System.out.println(s);&lt;br /&gt;
  }&lt;br /&gt;
  public static void main(String args[]) {&lt;br /&gt;
    List&amp;lt;String&amp;gt; l = new ArrayList&amp;lt;String&amp;gt;();&lt;br /&gt;
    l.add(&amp;quot;Toronto&amp;quot;);&lt;br /&gt;
    l.add(&amp;quot;Stockholm&amp;quot;);&lt;br /&gt;
    iterate(l);&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
           &lt;br /&gt;
         &lt;br /&gt;
    &lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Generic ArrayList ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
/*&lt;br /&gt;
 * Copyright (c) Ian F. Darwin, http://www.darwinsys.ru/, 1996-2002.&lt;br /&gt;
 * All rights reserved. Software written by Ian F. Darwin and others.&lt;br /&gt;
 * $Id: LICENSE,v 1.8 2004/02/09 03:33:38 ian Exp $&lt;br /&gt;
 *&lt;br /&gt;
 * Redistribution and use in source and binary forms, with or without&lt;br /&gt;
 * modification, are permitted provided that the following conditions&lt;br /&gt;
 * are met:&lt;br /&gt;
 * 1. Redistributions of source code must retain the above copyright&lt;br /&gt;
 *    notice, this list of conditions and the following disclaimer.&lt;br /&gt;
 * 2. Redistributions in binary form must reproduce the above copyright&lt;br /&gt;
 *    notice, this list of conditions and the following disclaimer in the&lt;br /&gt;
 *    documentation and/or other materials provided with the distribution.&lt;br /&gt;
 *&lt;br /&gt;
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS&amp;quot;&amp;quot;&lt;br /&gt;
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED&lt;br /&gt;
 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR&lt;br /&gt;
 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS&lt;br /&gt;
 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR&lt;br /&gt;
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF&lt;br /&gt;
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS&lt;br /&gt;
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN&lt;br /&gt;
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)&lt;br /&gt;
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE&lt;br /&gt;
 * POSSIBILITY OF SUCH DAMAGE.&lt;br /&gt;
 * &lt;br /&gt;
 * Java, the Duke mascot, and all variants of Sun&amp;quot;s Java &amp;quot;steaming coffee&lt;br /&gt;
 * cup&amp;quot; logo are trademarks of Sun Microsystems. Sun&amp;quot;s, and James Gosling&amp;quot;s,&lt;br /&gt;
 * pioneering role in inventing and promulgating (and standardizing) the Java &lt;br /&gt;
 * language and environment is gratefully acknowledged.&lt;br /&gt;
 * &lt;br /&gt;
 * The pioneering role of Dennis Ritchie and Bjarne Stroustrup, of AT&amp;amp;T, for&lt;br /&gt;
 * inventing predecessor languages C and C++ is also gratefully acknowledged.&lt;br /&gt;
 */&lt;br /&gt;
import java.util.*;&lt;br /&gt;
public class ArrayListGenericDemo {&lt;br /&gt;
  public static void main(String[] args) {&lt;br /&gt;
    ArrayList&amp;lt;String&amp;gt; data = new ArrayList&amp;lt;String&amp;gt;();&lt;br /&gt;
    data.add(&amp;quot;hello&amp;quot;);&lt;br /&gt;
    data.add(&amp;quot;goodbye&amp;quot;);&lt;br /&gt;
    // data.add(new Date()); This won&amp;quot;t compile!&lt;br /&gt;
    Iterator&amp;lt;String&amp;gt; it = data.iterator();&lt;br /&gt;
    while (it.hasNext()) {&lt;br /&gt;
      String s = it.next();&lt;br /&gt;
      System.out.println(s);&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
           &lt;br /&gt;
         &lt;br /&gt;
    &lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Generic Data Structure ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
import java.io.*;&lt;br /&gt;
interface Executor&amp;lt;E extends Exception&amp;gt; {&lt;br /&gt;
    void execute() throws E;&lt;br /&gt;
}&lt;br /&gt;
public class GenericExceptionTest {&lt;br /&gt;
    public static void main(String args[]) {&lt;br /&gt;
        try {&lt;br /&gt;
            Executor&amp;lt;IOException&amp;gt; e =&lt;br /&gt;
                new Executor&amp;lt;IOException&amp;gt;() {&lt;br /&gt;
                public void execute() throws IOException&lt;br /&gt;
                {&lt;br /&gt;
                    // code here that may throw an&lt;br /&gt;
                    // IOException or a subtype of&lt;br /&gt;
                    // IOException&lt;br /&gt;
                }&lt;br /&gt;
            };&lt;br /&gt;
            e.execute();&lt;br /&gt;
        } catch(IOException ioe) {&lt;br /&gt;
            System.out.println(&amp;quot;IOException: &amp;quot; + ioe);&lt;br /&gt;
            ioe.printStackTrace();&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
           &lt;br /&gt;
         &lt;br /&gt;
    &lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Generic HashMap ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
/*&lt;br /&gt;
 * Copyright (c) Ian F. Darwin, http://www.darwinsys.ru/, 1996-2002.&lt;br /&gt;
 * All rights reserved. Software written by Ian F. Darwin and others.&lt;br /&gt;
 * $Id: LICENSE,v 1.8 2004/02/09 03:33:38 ian Exp $&lt;br /&gt;
 *&lt;br /&gt;
 * Redistribution and use in source and binary forms, with or without&lt;br /&gt;
 * modification, are permitted provided that the following conditions&lt;br /&gt;
 * are met:&lt;br /&gt;
 * 1. Redistributions of source code must retain the above copyright&lt;br /&gt;
 *    notice, this list of conditions and the following disclaimer.&lt;br /&gt;
 * 2. Redistributions in binary form must reproduce the above copyright&lt;br /&gt;
 *    notice, this list of conditions and the following disclaimer in the&lt;br /&gt;
 *    documentation and/or other materials provided with the distribution.&lt;br /&gt;
 *&lt;br /&gt;
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS&amp;quot;&amp;quot;&lt;br /&gt;
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED&lt;br /&gt;
 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR&lt;br /&gt;
 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS&lt;br /&gt;
 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR&lt;br /&gt;
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF&lt;br /&gt;
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS&lt;br /&gt;
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN&lt;br /&gt;
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)&lt;br /&gt;
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE&lt;br /&gt;
 * POSSIBILITY OF SUCH DAMAGE.&lt;br /&gt;
 * &lt;br /&gt;
 * Java, the Duke mascot, and all variants of Sun&amp;quot;s Java &amp;quot;steaming coffee&lt;br /&gt;
 * cup&amp;quot; logo are trademarks of Sun Microsystems. Sun&amp;quot;s, and James Gosling&amp;quot;s,&lt;br /&gt;
 * pioneering role in inventing and promulgating (and standardizing) the Java &lt;br /&gt;
 * language and environment is gratefully acknowledged.&lt;br /&gt;
 * &lt;br /&gt;
 * The pioneering role of Dennis Ritchie and Bjarne Stroustrup, of AT&amp;amp;T, for&lt;br /&gt;
 * inventing predecessor languages C and C++ is also gratefully acknowledged.&lt;br /&gt;
 */&lt;br /&gt;
import java.util.HashMap;&lt;br /&gt;
public class HashDemoGeneric {&lt;br /&gt;
  public static void main(String[] args) {&lt;br /&gt;
    HashMap&amp;lt;Integer,String&amp;gt; map = new HashMap&amp;lt;Integer,String&amp;gt;();&lt;br /&gt;
    map.put(1, &amp;quot;Ian&amp;quot;);&lt;br /&gt;
    map.put(42, &amp;quot;Scott&amp;quot;);&lt;br /&gt;
    map.put(123, &amp;quot;Somebody else&amp;quot;);&lt;br /&gt;
    String name = map.get(42);&lt;br /&gt;
    System.out.println(name);&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
           &lt;br /&gt;
         &lt;br /&gt;
    &lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Generic Stack ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
/*&lt;br /&gt;
 * Copyright (c) Ian F. Darwin, http://www.darwinsys.ru/, 1996-2002.&lt;br /&gt;
 * All rights reserved. Software written by Ian F. Darwin and others.&lt;br /&gt;
 * $Id: LICENSE,v 1.8 2004/02/09 03:33:38 ian Exp $&lt;br /&gt;
 *&lt;br /&gt;
 * Redistribution and use in source and binary forms, with or without&lt;br /&gt;
 * modification, are permitted provided that the following conditions&lt;br /&gt;
 * are met:&lt;br /&gt;
 * 1. Redistributions of source code must retain the above copyright&lt;br /&gt;
 *    notice, this list of conditions and the following disclaimer.&lt;br /&gt;
 * 2. Redistributions in binary form must reproduce the above copyright&lt;br /&gt;
 *    notice, this list of conditions and the following disclaimer in the&lt;br /&gt;
 *    documentation and/or other materials provided with the distribution.&lt;br /&gt;
 *&lt;br /&gt;
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS&amp;quot;&amp;quot;&lt;br /&gt;
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED&lt;br /&gt;
 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR&lt;br /&gt;
 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS&lt;br /&gt;
 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR&lt;br /&gt;
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF&lt;br /&gt;
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS&lt;br /&gt;
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN&lt;br /&gt;
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)&lt;br /&gt;
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE&lt;br /&gt;
 * POSSIBILITY OF SUCH DAMAGE.&lt;br /&gt;
 * &lt;br /&gt;
 * Java, the Duke mascot, and all variants of Sun&amp;quot;s Java &amp;quot;steaming coffee&lt;br /&gt;
 * cup&amp;quot; logo are trademarks of Sun Microsystems. Sun&amp;quot;s, and James Gosling&amp;quot;s,&lt;br /&gt;
 * pioneering role in inventing and promulgating (and standardizing) the Java &lt;br /&gt;
 * language and environment is gratefully acknowledged.&lt;br /&gt;
 * &lt;br /&gt;
 * The pioneering role of Dennis Ritchie and Bjarne Stroustrup, of AT&amp;amp;T, for&lt;br /&gt;
 * inventing predecessor languages C and C++ is also gratefully acknowledged.&lt;br /&gt;
 */&lt;br /&gt;
public class MyStackDemo {&lt;br /&gt;
  public static void main(String[] args) {&lt;br /&gt;
    MyStack&amp;lt;String&amp;gt; ms1 = new MyStack&amp;lt;String&amp;gt;();&lt;br /&gt;
    ms1.push(&amp;quot;billg&amp;quot;);&lt;br /&gt;
    ms1.push(&amp;quot;scottm&amp;quot;);&lt;br /&gt;
    while (ms1.hasNext()) {&lt;br /&gt;
      String name = ms1.pop();&lt;br /&gt;
      System.out.println(name);&lt;br /&gt;
    }&lt;br /&gt;
    // Old way of using Collections: not type safe.&lt;br /&gt;
    MyStack ms2 = new MyStack();&lt;br /&gt;
    ms2.push(&amp;quot;billg&amp;quot;);               // EXPECT WARNING&lt;br /&gt;
    ms2.push(&amp;quot;scottm&amp;quot;);              // EXPECT WARNING&lt;br /&gt;
    ms2.push(new java.util.Date());  // EXPECT WARNING&lt;br /&gt;
    &lt;br /&gt;
    // Show that it is broken &lt;br /&gt;
    try {&lt;br /&gt;
      String bad = (String)ms2.pop();&lt;br /&gt;
      System.err.println(&amp;quot;Didn&amp;quot;t get expected exception!&amp;quot;);&lt;br /&gt;
    } catch (ClassCastException ex) {&lt;br /&gt;
      System.out.println(&amp;quot;Did get expected exception.&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
    // Removed the brokenness, print rest of it.&lt;br /&gt;
    while (ms2.hasNext()) {&lt;br /&gt;
      String name = (String)ms2.pop();&lt;br /&gt;
      System.out.println(name);&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
/** A lax Stack implementation.&lt;br /&gt;
 * @version $Id: MyStack.java,v 1.4 2004/03/07 23:18:59 ian Exp $&lt;br /&gt;
 */&lt;br /&gt;
class MyStack&amp;lt;T&amp;gt; {&lt;br /&gt;
  private int ix = 0;&lt;br /&gt;
  public static final int MAX = 10;&lt;br /&gt;
  private T[] data = (T[])new Object[MAX];&lt;br /&gt;
  public void push(T obj) {&lt;br /&gt;
    data[ix++] = obj;&lt;br /&gt;
  }&lt;br /&gt;
  public boolean hasNext() {&lt;br /&gt;
    return ix &amp;gt; 0;&lt;br /&gt;
  }&lt;br /&gt;
  public boolean hasRoom() {&lt;br /&gt;
    return ix &amp;lt; MAX;&lt;br /&gt;
  }&lt;br /&gt;
  public T pop() {&lt;br /&gt;
    if (hasNext()) {&lt;br /&gt;
      return data[--ix];&lt;br /&gt;
    }&lt;br /&gt;
    throw new ArrayIndexOutOfBoundsException(-1);&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
           &lt;br /&gt;
         &lt;br /&gt;
    &lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Java generic: Generics and arrays.  ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
class Gen&amp;lt;T extends Number&amp;gt; {  &lt;br /&gt;
  T ob;  &lt;br /&gt;
 &lt;br /&gt;
  T vals[]; &lt;br /&gt;
 &lt;br /&gt;
  Gen(T o, T[] nums) {  &lt;br /&gt;
    ob = o; &lt;br /&gt;
 &lt;br /&gt;
    vals = nums;  &lt;br /&gt;
  }  &lt;br /&gt;
}  &lt;br /&gt;
  &lt;br /&gt;
public class GenArrays {  &lt;br /&gt;
  public static void main(String args[]) {  &lt;br /&gt;
    Integer n[] = { 1, 2, 3, 4, 5 };   &lt;br /&gt;
 &lt;br /&gt;
    Gen&amp;lt;Integer&amp;gt; iOb = new Gen&amp;lt;Integer&amp;gt;(50, n); &lt;br /&gt;
 &lt;br /&gt;
    // Can&amp;quot;t create an array of type-specific generic references. &lt;br /&gt;
    // Gen&amp;lt;Integer&amp;gt; gens[] = new Gen&amp;lt;Integer&amp;gt;[10]; // Wrong! &lt;br /&gt;
 &lt;br /&gt;
    Gen&amp;lt;?&amp;gt; gens[] = new Gen&amp;lt;?&amp;gt;[10]; // OK&lt;br /&gt;
  } &lt;br /&gt;
}&lt;br /&gt;
           &lt;br /&gt;
         &lt;br /&gt;
    &lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Pre generics example that uses a collection. ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
/*&lt;br /&gt;
Java 2, v5.0 (Tiger) New Features&lt;br /&gt;
by Herbert Schildt&lt;br /&gt;
ISBN: 0072258543&lt;br /&gt;
Publisher: McGraw-Hill/Osborne, 2004&lt;br /&gt;
*/&lt;br /&gt;
 &lt;br /&gt;
import java.util.*; &lt;br /&gt;
 &lt;br /&gt;
public class OldStyle {  &lt;br /&gt;
  public static void main(String args[]) { &lt;br /&gt;
    ArrayList list = new ArrayList(); &lt;br /&gt;
 &lt;br /&gt;
    // These lines store strings, but any type of object &lt;br /&gt;
    // can be stored.  In old-style code, there is no  &lt;br /&gt;
    // convenient way restrict the type of objects stored &lt;br /&gt;
    // in a collection &lt;br /&gt;
    list.add(&amp;quot;one&amp;quot;); &lt;br /&gt;
    list.add(&amp;quot;two&amp;quot;); &lt;br /&gt;
    list.add(&amp;quot;three&amp;quot;); &lt;br /&gt;
    list.add(&amp;quot;four&amp;quot;); &lt;br /&gt;
 &lt;br /&gt;
    Iterator itr = list.iterator(); &lt;br /&gt;
    while(itr.hasNext()) { &lt;br /&gt;
 &lt;br /&gt;
      // To retrieve an element, an explicit type cast is needed &lt;br /&gt;
      // because the collection stores only Object. &lt;br /&gt;
      String str = (String) itr.next(); // explicit cast needed here. &lt;br /&gt;
 &lt;br /&gt;
      System.out.println(str + &amp;quot; is &amp;quot; + str.length() + &amp;quot; chars long.&amp;quot;); &lt;br /&gt;
    } &lt;br /&gt;
  }  &lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
           &lt;br /&gt;
         &lt;br /&gt;
    &lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== The GenStack Class ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
import java.util.LinkedList;&lt;br /&gt;
class GenStack&amp;lt;E&amp;gt; {&lt;br /&gt;
  private LinkedList&amp;lt;E&amp;gt; list = new LinkedList&amp;lt;E&amp;gt;();&lt;br /&gt;
  public void push(E item) {&lt;br /&gt;
    list.addFirst(item);&lt;br /&gt;
  }&lt;br /&gt;
  public E pop() {&lt;br /&gt;
    return list.poll();&lt;br /&gt;
  }&lt;br /&gt;
  public E peek() {&lt;br /&gt;
    return list.peek();&lt;br /&gt;
  }&lt;br /&gt;
  public boolean hasItems() {&lt;br /&gt;
    return !list.isEmpty();&lt;br /&gt;
  }&lt;br /&gt;
  public int size() {&lt;br /&gt;
    return list.size();&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
public class GenStackTest {&lt;br /&gt;
  public static void main(String[] args) {&lt;br /&gt;
    GenStack&amp;lt;String&amp;gt; gs = new GenStack&amp;lt;String&amp;gt;();&lt;br /&gt;
    gs.push(&amp;quot;One&amp;quot;);&lt;br /&gt;
    gs.push(&amp;quot;Two&amp;quot;);&lt;br /&gt;
    gs.push(&amp;quot;Three&amp;quot;);&lt;br /&gt;
    gs.push(&amp;quot;Four&amp;quot;);&lt;br /&gt;
    System.out.println(&amp;quot;There are &amp;quot; + gs.size() + &amp;quot; items in the stack.\n&amp;quot;);&lt;br /&gt;
    System.out.println(&amp;quot;The top item is: &amp;quot; + gs.peek() + &amp;quot;\n&amp;quot;);&lt;br /&gt;
    System.out.println(&amp;quot;There are still &amp;quot; + gs.size() + &amp;quot; items in the stack.\n&amp;quot;);&lt;br /&gt;
    System.out.println(&amp;quot;Popping everything:&amp;quot;);&lt;br /&gt;
    while (gs.hasItems())&lt;br /&gt;
      System.out.println(gs.pop());&lt;br /&gt;
    System.out.println(&amp;quot;There are now &amp;quot; + gs.size() + &amp;quot; items in the stack.\n&amp;quot;);&lt;br /&gt;
    System.out.println(&amp;quot;The top item is: &amp;quot; + gs.peek() + &amp;quot;\n&amp;quot;);&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
   &lt;br /&gt;
    &lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Unchecked Example  ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
import java.util.*;&lt;br /&gt;
public class UncheckedExample {&lt;br /&gt;
    public void processIntVector(Vector&amp;lt;Integer&amp;gt; v)&lt;br /&gt;
    {&lt;br /&gt;
        // perform some processing on the vector&lt;br /&gt;
    }&lt;br /&gt;
    public static void main(String args[])&lt;br /&gt;
    {&lt;br /&gt;
        Vector&amp;lt;Integer&amp;gt; intVector = new Vector&amp;lt;Integer&amp;gt;();&lt;br /&gt;
        Vector oldVector = new Vector();&lt;br /&gt;
        UncheckedExample ue = new UncheckedExample();&lt;br /&gt;
        // This is permitted&lt;br /&gt;
        oldVector = intVector;&lt;br /&gt;
        // This causes an unchecked warning&lt;br /&gt;
        intVector = oldVector;&lt;br /&gt;
        // This is permitted&lt;br /&gt;
        ue.processIntVector(intVector);&lt;br /&gt;
        // This causes an unchecked warning&lt;br /&gt;
        ue.processIntVector(oldVector);&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
           &lt;br /&gt;
         &lt;br /&gt;
    &lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;/div&gt;</summary>
		<author><name>Admin</name></author>	</entry>

	<entry>
		<id>http://jexp.ru/index.php?title=Java/Generics/Generic_Interface&amp;diff=9175</id>
		<title>Java/Generics/Generic Interface</title>
		<link rel="alternate" type="text/html" href="http://jexp.ru/index.php?title=Java/Generics/Generic_Interface&amp;diff=9175"/>
				<updated>2010-06-01T07:27:19Z</updated>
		
		<summary type="html">&lt;p&gt;Admin: 1 версия&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== A generic interface example.  ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
interface MinMax&amp;lt;T extends Comparable&amp;lt;T&amp;gt;&amp;gt; { &lt;br /&gt;
  T min(); &lt;br /&gt;
  T max(); &lt;br /&gt;
} &lt;br /&gt;
 &lt;br /&gt;
class MyClass&amp;lt;T extends Comparable&amp;lt;T&amp;gt;&amp;gt; implements MinMax&amp;lt;T&amp;gt; { &lt;br /&gt;
  T[] vals; &lt;br /&gt;
 &lt;br /&gt;
  MyClass(T[] o) { vals = o; } &lt;br /&gt;
 &lt;br /&gt;
  public T min() { &lt;br /&gt;
    T v = vals[0]; &lt;br /&gt;
    for(int i=1; i &amp;lt; vals.length; i++) &lt;br /&gt;
      if(vals[i].rupareTo(v) &amp;lt; 0) v = vals[i]; &lt;br /&gt;
 &lt;br /&gt;
    return v; &lt;br /&gt;
  } &lt;br /&gt;
 &lt;br /&gt;
  public T max() { &lt;br /&gt;
    T v = vals[0]; &lt;br /&gt;
 &lt;br /&gt;
    for(int i=1; i &amp;lt; vals.length; i++) &lt;br /&gt;
      if(vals[i].rupareTo(v) &amp;gt; 0) v = vals[i]; &lt;br /&gt;
 &lt;br /&gt;
    return v; &lt;br /&gt;
  } &lt;br /&gt;
} &lt;br /&gt;
 &lt;br /&gt;
public class GenIFDemo { &lt;br /&gt;
  public static void main(String args[]) { &lt;br /&gt;
    Integer inums[] = {3, 6, 2, 8, 6 }; &lt;br /&gt;
    Character chs[] = {&amp;quot;b&amp;quot;, &amp;quot;r&amp;quot;, &amp;quot;p&amp;quot;, &amp;quot;w&amp;quot; }; &lt;br /&gt;
 &lt;br /&gt;
    MyClass&amp;lt;Integer&amp;gt; iob = new MyClass&amp;lt;Integer&amp;gt;(inums); &lt;br /&gt;
    MyClass&amp;lt;Character&amp;gt; cob = new MyClass&amp;lt;Character&amp;gt;(chs); &lt;br /&gt;
 &lt;br /&gt;
    System.out.println(&amp;quot;Max value in inums: &amp;quot; + iob.max()); &lt;br /&gt;
    System.out.println(&amp;quot;Min value in inums: &amp;quot; + iob.min()); &lt;br /&gt;
 &lt;br /&gt;
    System.out.println(&amp;quot;Max value in chs: &amp;quot; + cob.max()); &lt;br /&gt;
    System.out.println(&amp;quot;Min value in chs: &amp;quot; + cob.min()); &lt;br /&gt;
  } &lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
           &lt;br /&gt;
       &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Interface Generic (Has compile error) ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
import java.util.*;&lt;br /&gt;
interface BaseInterface&amp;lt;A&amp;gt; {&lt;br /&gt;
    A getInfo();&lt;br /&gt;
}&lt;br /&gt;
class ParentClass implements BaseInterface&amp;lt;Integer&amp;gt; {&lt;br /&gt;
    public Integer getInfo()&lt;br /&gt;
    {&lt;br /&gt;
        return(null);&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
class ChildClass extends ParentClass implements BaseInterface&amp;lt;String&amp;gt; { }&lt;br /&gt;
public class BadParents {&lt;br /&gt;
    public static void main(String args[])&lt;br /&gt;
    {&lt;br /&gt;
        Vector&amp;lt;Integer&amp;gt; v1 = new Vector&amp;lt;Integer&amp;gt;();&lt;br /&gt;
        Vector v2;&lt;br /&gt;
        v1 = v2;&lt;br /&gt;
        v2 = v1;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
           &lt;br /&gt;
       &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;/div&gt;</summary>
		<author><name>Admin</name></author>	</entry>

	<entry>
		<id>http://jexp.ru/index.php?title=Java/Generics/Generic_Constructor&amp;diff=9177</id>
		<title>Java/Generics/Generic Constructor</title>
		<link rel="alternate" type="text/html" href="http://jexp.ru/index.php?title=Java/Generics/Generic_Constructor&amp;diff=9177"/>
				<updated>2010-06-01T07:27:19Z</updated>
		
		<summary type="html">&lt;p&gt;Admin: 1 версия&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Use a generic constructor.  ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
class GenCons {&lt;br /&gt;
  private double val;&lt;br /&gt;
  &amp;lt;T extends Number&amp;gt; GenCons(T arg) {&lt;br /&gt;
    val = arg.doubleValue();&lt;br /&gt;
  }&lt;br /&gt;
  void showval() {&lt;br /&gt;
    System.out.println(&amp;quot;val: &amp;quot; + val);&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
public class GenConsDemo {&lt;br /&gt;
  public static void main(String args[]) {&lt;br /&gt;
    GenCons test = new GenCons(100);&lt;br /&gt;
    GenCons test2 = new GenCons(123.5F);&lt;br /&gt;
    test.showval();&lt;br /&gt;
    test2.showval();&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
           &lt;br /&gt;
       &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;/div&gt;</summary>
		<author><name>Admin</name></author>	</entry>

	<entry>
		<id>http://jexp.ru/index.php?title=Java/Collections_Data_Structure&amp;diff=9173</id>
		<title>Java/Collections Data Structure</title>
		<link rel="alternate" type="text/html" href="http://jexp.ru/index.php?title=Java/Collections_Data_Structure&amp;diff=9173"/>
				<updated>2010-06-01T07:27:18Z</updated>
		
		<summary type="html">&lt;p&gt;Admin: 1 версия&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;* [[Java/Collections Data Structure/Algorithms | Algorithms]]&lt;br /&gt;
* [[Java/Collections Data Structure/Array | Array]]&lt;br /&gt;
* [[Java/Collections Data Structure/Array Collections | Array Collections]]&lt;br /&gt;
* [[Java/Collections Data Structure/Array Compare | Array Compare]]&lt;br /&gt;
* [[Java/Collections Data Structure/Array Convert | Array Convert]]&lt;br /&gt;
* [[Java/Collections Data Structure/Array Insert Remove | Array Insert Remove]]&lt;br /&gt;
* [[Java/Collections Data Structure/Array Sort Search | Array Sort Search]]&lt;br /&gt;
* [[Java/Collections Data Structure/Array SubArray | Array SubArray]]&lt;br /&gt;
* [[Java/Collections Data Structure/ArrayList | ArrayList]]&lt;br /&gt;
* [[Java/Collections Data Structure/Arrays | Arrays]]&lt;br /&gt;
* [[Java/Collections Data Structure/Auto Growth Array | Auto Growth Array]]&lt;br /&gt;
* [[Java/Collections Data Structure/BitSet | BitSet]]&lt;br /&gt;
* [[Java/Collections Data Structure/Collection | Collection]]&lt;br /&gt;
* [[Java/Collections Data Structure/Collections | Collections]]&lt;br /&gt;
* [[Java/Collections Data Structure/Comparator | Comparator]]&lt;br /&gt;
* [[Java/Collections Data Structure/Concurrent | Concurrent]]&lt;br /&gt;
* [[Java/Collections Data Structure/Custom List | Custom List]]&lt;br /&gt;
* [[Java/Collections Data Structure/Customized Map | Customized Map]]&lt;br /&gt;
* [[Java/Collections Data Structure/Deque | Deque]]&lt;br /&gt;
* [[Java/Collections Data Structure/Dictionary | Dictionary]]&lt;br /&gt;
* [[Java/Collections Data Structure/EnumMap | EnumMap]]&lt;br /&gt;
* [[Java/Collections Data Structure/EnumSet | EnumSet]]&lt;br /&gt;
* [[Java/Collections Data Structure/Enumerator | Enumerator]]&lt;br /&gt;
* [[Java/Collections Data Structure/General Collections | General Collections]]&lt;br /&gt;
* [[Java/Collections Data Structure/Graph | Graph]]&lt;br /&gt;
* [[Java/Collections Data Structure/HashMap | HashMap]]&lt;br /&gt;
* [[Java/Collections Data Structure/HashSet | HashSet]]&lt;br /&gt;
* [[Java/Collections Data Structure/HashTable Map | HashTable Map]]&lt;br /&gt;
* [[Java/Collections Data Structure/Heaps | Heaps]]&lt;br /&gt;
* [[Java/Collections Data Structure/History | History]]&lt;br /&gt;
* [[Java/Collections Data Structure/IdentityHashMap | IdentityHashMap]]&lt;br /&gt;
* [[Java/Collections Data Structure/Infix Postfix | Infix Postfix]]&lt;br /&gt;
* [[Java/Collections Data Structure/Iterator | Iterator]]&lt;br /&gt;
* [[Java/Collections Data Structure/Link List | Link List]]&lt;br /&gt;
* [[Java/Collections Data Structure/LinkedHashMap | LinkedHashMap]]&lt;br /&gt;
* [[Java/Collections Data Structure/LinkedHashSet | LinkedHashSet]]&lt;br /&gt;
* [[Java/Collections Data Structure/List | List]]&lt;br /&gt;
* [[Java/Collections Data Structure/Map | Map]]&lt;br /&gt;
* [[Java/Collections Data Structure/Paging | Paging]]&lt;br /&gt;
* [[Java/Collections Data Structure/Priority List | Priority List]]&lt;br /&gt;
* [[Java/Collections Data Structure/Queue | Queue]]&lt;br /&gt;
* [[Java/Collections Data Structure/Range | Range]]&lt;br /&gt;
* [[Java/Collections Data Structure/Set | Set]]&lt;br /&gt;
* [[Java/Collections Data Structure/Shuffle | Shuffle]]&lt;br /&gt;
* [[Java/Collections Data Structure/Soft Map | Soft Map]]&lt;br /&gt;
* [[Java/Collections Data Structure/SoftReference | SoftReference]]&lt;br /&gt;
* [[Java/Collections Data Structure/Sort Search | Sort Search]]&lt;br /&gt;
* [[Java/Collections Data Structure/SortedSet | SortedSet]]&lt;br /&gt;
* [[Java/Collections Data Structure/Stack | Stack]]&lt;br /&gt;
* [[Java/Collections Data Structure/State Machine | State Machine]]&lt;br /&gt;
* [[Java/Collections Data Structure/Tree | Tree]]&lt;br /&gt;
* [[Java/Collections Data Structure/TreeMap | TreeMap]]&lt;br /&gt;
* [[Java/Collections Data Structure/TreeSet | TreeSet]]&lt;br /&gt;
* [[Java/Collections Data Structure/Vector | Vector]]&lt;br /&gt;
* [[Java/Collections Data Structure/Weak List | Weak List]]&lt;br /&gt;
* [[Java/Collections Data Structure/Weak Set | Weak Set]]&lt;br /&gt;
* [[Java/Collections Data Structure/WeakHashMap | WeakHashMap]]&lt;/div&gt;</summary>
		<author><name>Admin</name></author>	</entry>

	<entry>
		<id>http://jexp.ru/index.php?title=Java/Collections_Data_Structure/Set&amp;diff=9171</id>
		<title>Java/Collections Data Structure/Set</title>
		<link rel="alternate" type="text/html" href="http://jexp.ru/index.php?title=Java/Collections_Data_Structure/Set&amp;diff=9171"/>
				<updated>2010-06-01T07:27:17Z</updated>
		
		<summary type="html">&lt;p&gt;Admin: 1 версия&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== An IdentitySet that uses reference-equality instead of object-equality ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
/*&lt;br /&gt;
 * Copyright 2005 Ralf Joachim&lt;br /&gt;
 *&lt;br /&gt;
 * Licensed under the Apache License, Version 2.0 (the &amp;quot;License&amp;quot;);&lt;br /&gt;
 * you may not use this file except in compliance with the License.&lt;br /&gt;
 * You may obtain a copy of the License at&lt;br /&gt;
 *&lt;br /&gt;
 * http://www.apache.org/licenses/LICENSE-2.0&lt;br /&gt;
 *&lt;br /&gt;
 * Unless required by applicable law or agreed to in writing, software&lt;br /&gt;
 * distributed under the License is distributed on an &amp;quot;AS IS&amp;quot; BASIS,&lt;br /&gt;
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.&lt;br /&gt;
 * See the License for the specific language governing permissions and&lt;br /&gt;
 * limitations under the License.&lt;br /&gt;
 */&lt;br /&gt;
import java.util.Collection;&lt;br /&gt;
import java.util.Iterator;&lt;br /&gt;
import java.util.NoSuchElementException;&lt;br /&gt;
import java.util.Set;&lt;br /&gt;
/**&lt;br /&gt;
 * An IdentitySet that uses reference-equality instead of object-equality. According&lt;br /&gt;
 * to its special function it violates some design contracts of the &amp;lt;code&amp;gt;Set&amp;lt;/code&amp;gt;&lt;br /&gt;
 * interface.&lt;br /&gt;
 * &lt;br /&gt;
 * @author &lt;br /&gt;
 * @version $Revision: 7491 $ $Date: 2006-04-13 10:49:49 -0600 (Thu, 13 Apr 2006) $&lt;br /&gt;
 * @since 0.9.9&lt;br /&gt;
 */&lt;br /&gt;
public final class IdentitySet implements Set {&lt;br /&gt;
    //--------------------------------------------------------------------------&lt;br /&gt;
    /** Default number of buckets. */&lt;br /&gt;
    private static final int    DEFAULT_CAPACITY = 17;&lt;br /&gt;
    &lt;br /&gt;
    /** Default load factor. */&lt;br /&gt;
    private static final float  DEFAULT_LOAD = 0.75f;&lt;br /&gt;
    &lt;br /&gt;
    /** Default number of entries. */&lt;br /&gt;
    private static final int    DEFAULT_ENTRIES = (int) (DEFAULT_CAPACITY * DEFAULT_LOAD);&lt;br /&gt;
    &lt;br /&gt;
    /** Default factor to increment capacity. */&lt;br /&gt;
    private static final int    DEFAULT_INCREMENT = 2;&lt;br /&gt;
    &lt;br /&gt;
    /** First prime number to check is 3 as we prevent 2 by design. */&lt;br /&gt;
    private static final int    FIRST_PRIME_TO_CHECK = 3;&lt;br /&gt;
    &lt;br /&gt;
    //--------------------------------------------------------------------------&lt;br /&gt;
    /** Number of buckets. */&lt;br /&gt;
    private int                     _capacity;&lt;br /&gt;
    &lt;br /&gt;
    /** Maximum number of entries before rehashing. */&lt;br /&gt;
    private int                     _maximum;&lt;br /&gt;
    /** Buckets. */&lt;br /&gt;
    private Entry[]                 _buckets;&lt;br /&gt;
    /** Number of map entries. */&lt;br /&gt;
    private int                     _entries = 0;&lt;br /&gt;
    //--------------------------------------------------------------------------&lt;br /&gt;
    /**&lt;br /&gt;
     * Construct a set with default capacity.&lt;br /&gt;
     */&lt;br /&gt;
    public IdentitySet() {&lt;br /&gt;
        _capacity = DEFAULT_CAPACITY;&lt;br /&gt;
        _maximum = DEFAULT_ENTRIES;&lt;br /&gt;
        _buckets = new Entry[DEFAULT_CAPACITY];&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    /**&lt;br /&gt;
     * Construct a set with given capacity.&lt;br /&gt;
     * &lt;br /&gt;
     * @param  capacity     The capacity of entries this set should be initialized with.&lt;br /&gt;
     */&lt;br /&gt;
    public IdentitySet(final int capacity) {&lt;br /&gt;
        _capacity = capacity;&lt;br /&gt;
        _maximum = (int) (capacity * DEFAULT_LOAD);&lt;br /&gt;
        _buckets = new Entry[capacity];&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    /**&lt;br /&gt;
     * {@inheritDoc}&lt;br /&gt;
     * @see java.util.Collection#clear()&lt;br /&gt;
     */&lt;br /&gt;
    public void clear() {&lt;br /&gt;
        _capacity = DEFAULT_CAPACITY;&lt;br /&gt;
        _maximum = DEFAULT_ENTRIES;&lt;br /&gt;
        _buckets = new Entry[DEFAULT_CAPACITY];&lt;br /&gt;
        _entries = 0;&lt;br /&gt;
    }&lt;br /&gt;
    /**&lt;br /&gt;
     * {@inheritDoc}&lt;br /&gt;
     * @see java.util.Collection#size()&lt;br /&gt;
     */&lt;br /&gt;
    public int size() { return _entries; }&lt;br /&gt;
    /**&lt;br /&gt;
     * {@inheritDoc}&lt;br /&gt;
     * @see java.util.Collection#isEmpty()&lt;br /&gt;
     */&lt;br /&gt;
    public boolean isEmpty() { return (_entries == 0); }&lt;br /&gt;
    /**&lt;br /&gt;
     * {@inheritDoc}&lt;br /&gt;
     * @see java.util.Collection#add(java.lang.Object)&lt;br /&gt;
     */&lt;br /&gt;
    public boolean add(final Object key) {&lt;br /&gt;
        int hash = System.identityHashCode(key);&lt;br /&gt;
        int index = hash % _capacity;&lt;br /&gt;
        if (index &amp;lt; 0) { index = -index; }&lt;br /&gt;
        Entry entry = _buckets[index];&lt;br /&gt;
        Entry prev = null;&lt;br /&gt;
        while (entry != null) {&lt;br /&gt;
            if (entry.getKey() == key) {&lt;br /&gt;
                // There is already a mapping for this key.&lt;br /&gt;
                return false;&lt;br /&gt;
            }&lt;br /&gt;
            prev = entry;&lt;br /&gt;
            entry = entry.getNext();&lt;br /&gt;
        }&lt;br /&gt;
        if (prev == null) {&lt;br /&gt;
            // There is no previous entry in this bucket.&lt;br /&gt;
            _buckets[index] = new Entry(key, hash);&lt;br /&gt;
        } else {&lt;br /&gt;
            // Next entry is empty so we have no mapping for this key.&lt;br /&gt;
            prev.setNext(new Entry(key, hash));&lt;br /&gt;
        }&lt;br /&gt;
        _entries++;&lt;br /&gt;
        if (_entries &amp;gt; _maximum) { rehash(); }&lt;br /&gt;
        return true;&lt;br /&gt;
    }&lt;br /&gt;
    /**&lt;br /&gt;
     * Rehash the map into a new array with increased capacity.&lt;br /&gt;
     */&lt;br /&gt;
    private void rehash() {&lt;br /&gt;
        long nextCapacity = _capacity * DEFAULT_INCREMENT;&lt;br /&gt;
        if (nextCapacity &amp;gt; Integer.MAX_VALUE) { return; }&lt;br /&gt;
        nextCapacity = nextPrime(nextCapacity);&lt;br /&gt;
        if (nextCapacity &amp;gt; Integer.MAX_VALUE) { return; }&lt;br /&gt;
        int newCapacity = (int) nextCapacity;&lt;br /&gt;
        Entry[] newBuckets = new Entry[newCapacity];&lt;br /&gt;
        Entry entry = null;&lt;br /&gt;
        Entry temp = null;&lt;br /&gt;
        Entry next = null;&lt;br /&gt;
        int newIndex = 0;&lt;br /&gt;
        for (int index = 0; index &amp;lt; _capacity; index++) {&lt;br /&gt;
            entry = _buckets[index];&lt;br /&gt;
            while (entry != null) {&lt;br /&gt;
                next = entry.getNext();&lt;br /&gt;
                newIndex = entry.getHash() % newCapacity;&lt;br /&gt;
                if (newIndex &amp;lt; 0) { newIndex = -newIndex; }&lt;br /&gt;
                temp = newBuckets[newIndex];&lt;br /&gt;
                if (temp == null) {&lt;br /&gt;
                    // First entry of the bucket.&lt;br /&gt;
                    entry.setNext(null);&lt;br /&gt;
                } else {&lt;br /&gt;
                    // Hook entry into beginning of the buckets chain.&lt;br /&gt;
                    entry.setNext(temp);&lt;br /&gt;
                }&lt;br /&gt;
                newBuckets[newIndex] = entry;&lt;br /&gt;
                entry = next;&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
        _capacity = newCapacity;&lt;br /&gt;
        _maximum = (int) (newCapacity * DEFAULT_LOAD);&lt;br /&gt;
        _buckets = newBuckets;&lt;br /&gt;
    }&lt;br /&gt;
    /**&lt;br /&gt;
     * Find next prime number greater than minimum.&lt;br /&gt;
     * &lt;br /&gt;
     * @param  minimum  The minimum (exclusive) value of the next prime number.&lt;br /&gt;
     * @return The next prime number greater than minimum.&lt;br /&gt;
     */&lt;br /&gt;
    private long nextPrime(final long minimum) {&lt;br /&gt;
        long candidate = ((minimum + 1) / 2) * 2 + 1;&lt;br /&gt;
        while (!isPrime(candidate)) { candidate += 2; }&lt;br /&gt;
        return candidate;&lt;br /&gt;
    }&lt;br /&gt;
    /**&lt;br /&gt;
     * Check for prime number.&lt;br /&gt;
     * &lt;br /&gt;
     * @param  candidate  Number to be checked for being a prime number.&lt;br /&gt;
     * @return &amp;lt;code&amp;gt;true&amp;lt;/code&amp;gt; if the given number is a prime number&lt;br /&gt;
     *         &amp;lt;code&amp;gt;false&amp;lt;/code&amp;gt; otherwise.&lt;br /&gt;
     */&lt;br /&gt;
    private boolean isPrime(final long candidate) {&lt;br /&gt;
        if ((candidate / 2) * 2 == candidate) { return false; }&lt;br /&gt;
        long stop = candidate / 2;&lt;br /&gt;
        for (long i = FIRST_PRIME_TO_CHECK; i &amp;lt; stop; i += 2) {&lt;br /&gt;
            if ((candidate / i) * i == candidate) { return false; }&lt;br /&gt;
        }&lt;br /&gt;
        return true;&lt;br /&gt;
    }&lt;br /&gt;
    /**&lt;br /&gt;
     * {@inheritDoc}&lt;br /&gt;
     * @see java.util.Collection#contains(java.lang.Object)&lt;br /&gt;
     */&lt;br /&gt;
    public boolean contains(final Object key) {&lt;br /&gt;
        int hash = System.identityHashCode(key);&lt;br /&gt;
        int index = hash % _capacity;&lt;br /&gt;
        if (index &amp;lt; 0) { index = -index; }&lt;br /&gt;
        Entry entry = _buckets[index];&lt;br /&gt;
        while (entry != null) {&lt;br /&gt;
            if (entry.getKey() == key) { return true; }&lt;br /&gt;
            entry = entry.getNext();&lt;br /&gt;
        }&lt;br /&gt;
        return false;&lt;br /&gt;
    }&lt;br /&gt;
    /**&lt;br /&gt;
     * {@inheritDoc}&lt;br /&gt;
     * @see java.util.Collection#remove(java.lang.Object)&lt;br /&gt;
     */&lt;br /&gt;
    public boolean remove(final Object key) {&lt;br /&gt;
        int hash = System.identityHashCode(key);&lt;br /&gt;
        int index = hash % _capacity;&lt;br /&gt;
        if (index &amp;lt; 0) { index = -index; }&lt;br /&gt;
        Entry entry = _buckets[index];&lt;br /&gt;
        Entry prev = null;&lt;br /&gt;
        while (entry != null) {&lt;br /&gt;
            if (entry.getKey() == key) {&lt;br /&gt;
                // Found the entry.&lt;br /&gt;
                if (prev == null) {&lt;br /&gt;
                    // First element in bucket matches.&lt;br /&gt;
                    _buckets[index] = entry.getNext();&lt;br /&gt;
                } else {&lt;br /&gt;
                    // Remove the entry from the chain.&lt;br /&gt;
                    prev.setNext(entry.getNext());&lt;br /&gt;
                }&lt;br /&gt;
                _entries--;&lt;br /&gt;
                return true;&lt;br /&gt;
            }&lt;br /&gt;
            prev = entry;&lt;br /&gt;
            entry = entry.getNext();&lt;br /&gt;
        }&lt;br /&gt;
        return false;&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    /**&lt;br /&gt;
     * {@inheritDoc}&lt;br /&gt;
     * @see java.util.Collection#iterator()&lt;br /&gt;
     */&lt;br /&gt;
    public Iterator iterator() {&lt;br /&gt;
        return new IdentityIterator();&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    /**&lt;br /&gt;
     * {@inheritDoc}&lt;br /&gt;
     * @see java.util.Collection#toArray()&lt;br /&gt;
     */&lt;br /&gt;
    public Object[] toArray() {&lt;br /&gt;
        Object[] result = new Object[_entries];&lt;br /&gt;
        int j = 0;&lt;br /&gt;
        for (int i = 0; i &amp;lt; _capacity; i++) {&lt;br /&gt;
            Entry entry = _buckets[i];&lt;br /&gt;
            while (entry != null) {&lt;br /&gt;
                result[j++] = entry.getKey();&lt;br /&gt;
                entry = entry.getNext();&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
        &lt;br /&gt;
        return result;&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    /**&lt;br /&gt;
     * {@inheritDoc}&lt;br /&gt;
     * @see java.util.Collection#toArray(java.lang.Object[])&lt;br /&gt;
     */&lt;br /&gt;
    public Object[] toArray(final Object[] a) {&lt;br /&gt;
        Object[] result = a;&lt;br /&gt;
        if (result.length &amp;lt; _entries) {&lt;br /&gt;
            result = (Object[]) java.lang.reflect.Array.newInstance(&lt;br /&gt;
                    result.getClass().getComponentType(), _entries);&lt;br /&gt;
        }&lt;br /&gt;
        &lt;br /&gt;
        int j = 0;&lt;br /&gt;
        for (int i = 0; i &amp;lt; _capacity; i++) {&lt;br /&gt;
            Entry entry = _buckets[i];&lt;br /&gt;
            while (entry != null) {&lt;br /&gt;
                result[j++] = entry.getKey();&lt;br /&gt;
                entry = entry.getNext();&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
        &lt;br /&gt;
        while (j &amp;lt; result.length) {&lt;br /&gt;
            result[j++] = null;&lt;br /&gt;
        }&lt;br /&gt;
        &lt;br /&gt;
        return result;&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    /**&lt;br /&gt;
     * In contrast with the design contract of the &amp;lt;code&amp;gt;Set&amp;lt;/code&amp;gt; interface this method&lt;br /&gt;
     * has not been implemented and throws a &amp;lt;code&amp;gt;UnsupportedOperationException&amp;lt;/code&amp;gt;.&lt;br /&gt;
     * &lt;br /&gt;
     * {@inheritDoc}&lt;br /&gt;
     * @see java.util.Set#containsAll&lt;br /&gt;
     */&lt;br /&gt;
    public boolean containsAll(final Collection c) {&lt;br /&gt;
        throw new UnsupportedOperationException();&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    /**&lt;br /&gt;
     * This optional method has not been implemented for &amp;lt;code&amp;gt;IdentitySet&amp;lt;/code&amp;gt; instead&lt;br /&gt;
     * it throws a &amp;lt;code&amp;gt;UnsupportedOperationException&amp;lt;/code&amp;gt; as defined in the&lt;br /&gt;
     * &amp;lt;code&amp;gt;Set&amp;lt;/code&amp;gt; interface.&lt;br /&gt;
     * &lt;br /&gt;
     * {@inheritDoc}&lt;br /&gt;
     * @see java.util.Set#addAll&lt;br /&gt;
     */&lt;br /&gt;
    public boolean addAll(final Collection c) {&lt;br /&gt;
        throw new UnsupportedOperationException();&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    /**&lt;br /&gt;
     * This optional method has not been implemented for &amp;lt;code&amp;gt;IdentitySet&amp;lt;/code&amp;gt; instead&lt;br /&gt;
     * it throws a &amp;lt;code&amp;gt;UnsupportedOperationException&amp;lt;/code&amp;gt; as defined in the&lt;br /&gt;
     * &amp;lt;code&amp;gt;Set&amp;lt;/code&amp;gt; interface.&lt;br /&gt;
     * &lt;br /&gt;
     * {@inheritDoc}&lt;br /&gt;
     * @see java.util.Set#removeAll&lt;br /&gt;
     */&lt;br /&gt;
    public boolean removeAll(final Collection c) {&lt;br /&gt;
        throw new UnsupportedOperationException();&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    /**&lt;br /&gt;
     * This optional method has not been implemented for &amp;lt;code&amp;gt;IdentitySet&amp;lt;/code&amp;gt; instead&lt;br /&gt;
     * it throws a &amp;lt;code&amp;gt;UnsupportedOperationException&amp;lt;/code&amp;gt; as defined in the&lt;br /&gt;
     * &amp;lt;code&amp;gt;Set&amp;lt;/code&amp;gt; interface.&lt;br /&gt;
     * &lt;br /&gt;
     * {@inheritDoc}&lt;br /&gt;
     * @see java.util.Set#retainAll&lt;br /&gt;
     */&lt;br /&gt;
    public boolean retainAll(final Collection c) {&lt;br /&gt;
        throw new UnsupportedOperationException();&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    //--------------------------------------------------------------------------&lt;br /&gt;
    /**&lt;br /&gt;
     * An entry of the &amp;lt;code&amp;gt;IdentitySet&amp;lt;/code&amp;gt;.&lt;br /&gt;
     */&lt;br /&gt;
    public final class Entry {&lt;br /&gt;
        /** Key of entry. */&lt;br /&gt;
        private Object  _key;&lt;br /&gt;
        &lt;br /&gt;
        /** Identity hashcode of key. */&lt;br /&gt;
        private int     _hash;&lt;br /&gt;
        &lt;br /&gt;
        /** Reference to next entry. */&lt;br /&gt;
        private Entry   _next = null;&lt;br /&gt;
        /**&lt;br /&gt;
         * Construct an entry.&lt;br /&gt;
         * &lt;br /&gt;
         * @param key    Key of entry.&lt;br /&gt;
         * @param hash   Identity hashcode of key.&lt;br /&gt;
         */&lt;br /&gt;
        public Entry(final Object key, final int hash) {&lt;br /&gt;
            _key = key;&lt;br /&gt;
            _hash = hash;&lt;br /&gt;
        }&lt;br /&gt;
        /**&lt;br /&gt;
         * Get key of entry.&lt;br /&gt;
         *&lt;br /&gt;
         * @return Key of entry.&lt;br /&gt;
         */&lt;br /&gt;
        public Object getKey() { return _key; }&lt;br /&gt;
        /**&lt;br /&gt;
         * Get identity hashcode of key.&lt;br /&gt;
         *&lt;br /&gt;
         * @return Identity hashcode of key.&lt;br /&gt;
         */&lt;br /&gt;
        public int getHash() { return _hash; }&lt;br /&gt;
        /**&lt;br /&gt;
         * Set reference to next entry.&lt;br /&gt;
         *&lt;br /&gt;
         * @param  next     New reference to next entry.&lt;br /&gt;
         */&lt;br /&gt;
        public void setNext(final Entry next) { _next = next; }&lt;br /&gt;
        /**&lt;br /&gt;
         * Get reference to next entry.&lt;br /&gt;
         *&lt;br /&gt;
         * @return Reference to next entry.&lt;br /&gt;
         */&lt;br /&gt;
        public Entry getNext() { return _next; }&lt;br /&gt;
    }&lt;br /&gt;
    //--------------------------------------------------------------------------&lt;br /&gt;
    /**&lt;br /&gt;
     * An iterator over all entries of the &amp;lt;code&amp;gt;IdentitySet&amp;lt;/code&amp;gt;.&lt;br /&gt;
     */&lt;br /&gt;
    private class IdentityIterator implements Iterator {&lt;br /&gt;
        /** Index of the current bucket. */&lt;br /&gt;
        private int     _index = 0; &lt;br /&gt;
        &lt;br /&gt;
        /** The next entry to be returned. &amp;lt;code&amp;gt;null&amp;lt;/code&amp;gt; when there is none. */&lt;br /&gt;
        private Entry   _next = _buckets[0];&lt;br /&gt;
        /**&lt;br /&gt;
         * Construct a iterator over all entries of the &amp;lt;code&amp;gt;IdentitySet&amp;lt;/code&amp;gt;.&lt;br /&gt;
         */&lt;br /&gt;
        public IdentityIterator() {&lt;br /&gt;
            if (_entries &amp;gt; 0) {&lt;br /&gt;
                while ((_next == null) &amp;amp;&amp;amp; (++_index &amp;lt; _capacity)) {&lt;br /&gt;
                    _next = _buckets[_index];&lt;br /&gt;
                }&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
        /**&lt;br /&gt;
         * {@inheritDoc}&lt;br /&gt;
         * @see java.util.Iterator#hasNext()&lt;br /&gt;
         */&lt;br /&gt;
        public boolean hasNext() {&lt;br /&gt;
            return (_next != null);&lt;br /&gt;
        }&lt;br /&gt;
        /**&lt;br /&gt;
         * {@inheritDoc}&lt;br /&gt;
         * @see java.util.Iterator#next()&lt;br /&gt;
         */&lt;br /&gt;
        public Object next() {&lt;br /&gt;
            Entry entry = _next;&lt;br /&gt;
            if (entry == null) { throw new NoSuchElementException(); }&lt;br /&gt;
            &lt;br /&gt;
            _next = entry.getNext();&lt;br /&gt;
            while ((_next == null) &amp;amp;&amp;amp; (++_index &amp;lt; _capacity)) {&lt;br /&gt;
                _next = _buckets[_index];&lt;br /&gt;
            }&lt;br /&gt;
            &lt;br /&gt;
            return entry.getKey();&lt;br /&gt;
        }&lt;br /&gt;
        &lt;br /&gt;
        /**&lt;br /&gt;
         * This optional method is not implemented for &amp;lt;code&amp;gt;IdentityIterator&amp;lt;/code&amp;gt;&lt;br /&gt;
         * instead it throws a &amp;lt;code&amp;gt;UnsupportedOperationException&amp;lt;/code&amp;gt; as defined&lt;br /&gt;
         * in the &amp;lt;code&amp;gt;Iterator&amp;lt;/code&amp;gt; interface.&lt;br /&gt;
         * &lt;br /&gt;
         * @see java.util.Iterator#remove()&lt;br /&gt;
         */&lt;br /&gt;
        public void remove() {&lt;br /&gt;
            throw new UnsupportedOperationException();&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    //--------------------------------------------------------------------------&lt;br /&gt;
}&lt;br /&gt;
   &lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== An implementation of the java.util.Stack based on an ArrayList instead of a Vector, so it is not synchronized to protect against multi-threaded access. ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
/*&lt;br /&gt;
 * Licensed to the Apache Software Foundation (ASF) under one or more&lt;br /&gt;
 * contributor license agreements.  See the NOTICE file distributed with&lt;br /&gt;
 * this work for additional information regarding copyright ownership.&lt;br /&gt;
 * The ASF licenses this file to You under the Apache License, Version 2.0&lt;br /&gt;
 * (the &amp;quot;License&amp;quot;); you may not use this file except in compliance with&lt;br /&gt;
 * the License.  You may obtain a copy of the License at&lt;br /&gt;
 *&lt;br /&gt;
 *      http://www.apache.org/licenses/LICENSE-2.0&lt;br /&gt;
 *&lt;br /&gt;
 * Unless required by applicable law or agreed to in writing, software&lt;br /&gt;
 * distributed under the License is distributed on an &amp;quot;AS IS&amp;quot; BASIS,&lt;br /&gt;
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.&lt;br /&gt;
 * See the License for the specific language governing permissions and&lt;br /&gt;
 * limitations under the License.&lt;br /&gt;
 */&lt;br /&gt;
&lt;br /&gt;
import java.util.ArrayList;&lt;br /&gt;
import java.util.Collection;&lt;br /&gt;
import java.util.EmptyStackException;&lt;br /&gt;
import java.util.NoSuchElementException;&lt;br /&gt;
/**&lt;br /&gt;
 * An implementation of the {@link java.util.Stack} API that is based on an&lt;br /&gt;
 * &amp;lt;code&amp;gt;ArrayList&amp;lt;/code&amp;gt; instead of a &amp;lt;code&amp;gt;Vector&amp;lt;/code&amp;gt;, so it is not&lt;br /&gt;
 * synchronized to protect against multi-threaded access.  The implementation&lt;br /&gt;
 * is therefore operates faster in environments where you do not need to&lt;br /&gt;
 * worry about multiple thread contention.&lt;br /&gt;
 * &amp;lt;p&amp;gt;&lt;br /&gt;
 * The removal order of an &amp;lt;code&amp;gt;ArrayStack&amp;lt;/code&amp;gt; is based on insertion &lt;br /&gt;
 * order: The most recently added element is removed first.  The iteration&lt;br /&gt;
 * order is &amp;lt;i&amp;gt;not&amp;lt;/i&amp;gt; the same as the removal order.  The iterator returns&lt;br /&gt;
 * elements from the bottom up, whereas the {@link #remove()} method removes&lt;br /&gt;
 * them from the top down.&lt;br /&gt;
 * &amp;lt;p&amp;gt;&lt;br /&gt;
 * Unlike &amp;lt;code&amp;gt;Stack&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;ArrayStack&amp;lt;/code&amp;gt; accepts null entries.&lt;br /&gt;
 * &amp;lt;p&amp;gt;&lt;br /&gt;
 * &amp;lt;strong&amp;gt;Note:&amp;lt;/strong&amp;gt; this class should be bytecode-identical to the &lt;br /&gt;
 * version in commons collections. This is required to allow backwards &lt;br /&gt;
 * compability with both previous versions of BeanUtils and also allow &lt;br /&gt;
 * coexistance with both collections 2.1 and 3.0.&lt;br /&gt;
 *&lt;br /&gt;
 * @see java.util.Stack&lt;br /&gt;
 * @since Commons Collections 1.0&lt;br /&gt;
 * @version $Revision: 555824 $ $Date: 2007-07-13 01:27:15 +0100 (Fri, 13 Jul 2007) $&lt;br /&gt;
 * &lt;br /&gt;
 * @author Craig R. McClanahan&lt;br /&gt;
 * @author Paul Jack&lt;br /&gt;
 * @author Stephen Colebourne&lt;br /&gt;
 */&lt;br /&gt;
public class ArrayStack extends ArrayList implements Buffer {&lt;br /&gt;
    /** Ensure serialization compatibility */    &lt;br /&gt;
    private static final long serialVersionUID = 2130079159931574599L;&lt;br /&gt;
    /**&lt;br /&gt;
     * Constructs a new empty &amp;lt;code&amp;gt;ArrayStack&amp;lt;/code&amp;gt;. The initial size&lt;br /&gt;
     * is controlled by &amp;lt;code&amp;gt;ArrayList&amp;lt;/code&amp;gt; and is currently 10.&lt;br /&gt;
     */&lt;br /&gt;
    public ArrayStack() {&lt;br /&gt;
        super();&lt;br /&gt;
    }&lt;br /&gt;
    /**&lt;br /&gt;
     * Constructs a new empty &amp;lt;code&amp;gt;ArrayStack&amp;lt;/code&amp;gt; with an initial size.&lt;br /&gt;
     * &lt;br /&gt;
     * @param initialSize  the initial size to use&lt;br /&gt;
     * @throws IllegalArgumentException  if the specified initial size&lt;br /&gt;
     *  is negative&lt;br /&gt;
     */&lt;br /&gt;
    public ArrayStack(int initialSize) {&lt;br /&gt;
        super(initialSize);&lt;br /&gt;
    }&lt;br /&gt;
    /**&lt;br /&gt;
     * Return &amp;lt;code&amp;gt;true&amp;lt;/code&amp;gt; if this stack is currently empty.&lt;br /&gt;
     * &amp;lt;p&amp;gt;&lt;br /&gt;
     * This method exists for compatibility with &amp;lt;code&amp;gt;java.util.Stack&amp;lt;/code&amp;gt;.&lt;br /&gt;
     * New users of this class should use &amp;lt;code&amp;gt;isEmpty&amp;lt;/code&amp;gt; instead.&lt;br /&gt;
     * &lt;br /&gt;
     * @return true if the stack is currently empty&lt;br /&gt;
     */&lt;br /&gt;
    public boolean empty() {&lt;br /&gt;
        return isEmpty();&lt;br /&gt;
    }&lt;br /&gt;
    /**&lt;br /&gt;
     * Returns the top item off of this stack without removing it.&lt;br /&gt;
     *&lt;br /&gt;
     * @return the top item on the stack&lt;br /&gt;
     * @throws EmptyStackException  if the stack is empty&lt;br /&gt;
     */&lt;br /&gt;
    public Object peek() throws EmptyStackException {&lt;br /&gt;
        int n = size();&lt;br /&gt;
        if (n &amp;lt;= 0) {&lt;br /&gt;
            throw new EmptyStackException();&lt;br /&gt;
        } else {&lt;br /&gt;
            return get(n - 1);&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
    /**&lt;br /&gt;
     * Returns the n&amp;quot;th item down (zero-relative) from the top of this&lt;br /&gt;
     * stack without removing it.&lt;br /&gt;
     *&lt;br /&gt;
     * @param n  the number of items down to go&lt;br /&gt;
     * @return the n&amp;quot;th item on the stack, zero relative&lt;br /&gt;
     * @throws EmptyStackException  if there are not enough items on the&lt;br /&gt;
     *  stack to satisfy this request&lt;br /&gt;
     */&lt;br /&gt;
    public Object peek(int n) throws EmptyStackException {&lt;br /&gt;
        int m = (size() - n) - 1;&lt;br /&gt;
        if (m &amp;lt; 0) {&lt;br /&gt;
            throw new EmptyStackException();&lt;br /&gt;
        } else {&lt;br /&gt;
            return get(m);&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
    /**&lt;br /&gt;
     * Pops the top item off of this stack and return it.&lt;br /&gt;
     *&lt;br /&gt;
     * @return the top item on the stack&lt;br /&gt;
     * @throws EmptyStackException  if the stack is empty&lt;br /&gt;
     */&lt;br /&gt;
    public Object pop() throws EmptyStackException {&lt;br /&gt;
        int n = size();&lt;br /&gt;
        if (n &amp;lt;= 0) {&lt;br /&gt;
            throw new EmptyStackException();&lt;br /&gt;
        } else {&lt;br /&gt;
            return remove(n - 1);&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
    /**&lt;br /&gt;
     * Pushes a new item onto the top of this stack. The pushed item is also&lt;br /&gt;
     * returned. This is equivalent to calling &amp;lt;code&amp;gt;add&amp;lt;/code&amp;gt;.&lt;br /&gt;
     *&lt;br /&gt;
     * @param item  the item to be added&lt;br /&gt;
     * @return the item just pushed&lt;br /&gt;
     */&lt;br /&gt;
    public Object push(Object item) {&lt;br /&gt;
        add(item);&lt;br /&gt;
        return item;&lt;br /&gt;
    }&lt;br /&gt;
    /**&lt;br /&gt;
     * Returns the one-based position of the distance from the top that the&lt;br /&gt;
     * specified object exists on this stack, where the top-most element is&lt;br /&gt;
     * considered to be at distance &amp;lt;code&amp;gt;1&amp;lt;/code&amp;gt;.  If the object is not&lt;br /&gt;
     * present on the stack, return &amp;lt;code&amp;gt;-1&amp;lt;/code&amp;gt; instead.  The&lt;br /&gt;
     * &amp;lt;code&amp;gt;equals()&amp;lt;/code&amp;gt; method is used to compare to the items&lt;br /&gt;
     * in this stack.&lt;br /&gt;
     *&lt;br /&gt;
     * @param object  the object to be searched for&lt;br /&gt;
     * @return the 1-based depth into the stack of the object, or -1 if not found&lt;br /&gt;
     */&lt;br /&gt;
    public int search(Object object) {&lt;br /&gt;
        int i = size() - 1;        // Current index&lt;br /&gt;
        int n = 1;                 // Current distance&lt;br /&gt;
        while (i &amp;gt;= 0) {&lt;br /&gt;
            Object current = get(i);&lt;br /&gt;
            if ((object == null &amp;amp;&amp;amp; current == null) ||&lt;br /&gt;
                (object != null &amp;amp;&amp;amp; object.equals(current))) {&lt;br /&gt;
                return n;&lt;br /&gt;
            }&lt;br /&gt;
            i--;&lt;br /&gt;
            n++;&lt;br /&gt;
        }&lt;br /&gt;
        return -1;&lt;br /&gt;
    }&lt;br /&gt;
    /**&lt;br /&gt;
     * Returns the element on the top of the stack.&lt;br /&gt;
     *&lt;br /&gt;
     * @return the element on the top of the stack&lt;br /&gt;
     * @throws BufferUnderflowException  if the stack is empty&lt;br /&gt;
     */&lt;br /&gt;
    public Object get() {&lt;br /&gt;
        int size = size();&lt;br /&gt;
        if (size == 0) {&lt;br /&gt;
            throw new BufferUnderflowException();&lt;br /&gt;
        }&lt;br /&gt;
        return get(size - 1);&lt;br /&gt;
    }&lt;br /&gt;
    /**&lt;br /&gt;
     * Removes the element on the top of the stack.&lt;br /&gt;
     *&lt;br /&gt;
     * @return the removed element &lt;br /&gt;
     * @throws BufferUnderflowException  if the stack is empty&lt;br /&gt;
     */&lt;br /&gt;
    public Object remove() {&lt;br /&gt;
        int size = size();&lt;br /&gt;
        if (size == 0) {&lt;br /&gt;
            throw new BufferUnderflowException();&lt;br /&gt;
        }&lt;br /&gt;
        return remove(size - 1);&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
/*&lt;br /&gt;
 * Licensed to the Apache Software Foundation (ASF) under one or more&lt;br /&gt;
 * contributor license agreements.  See the NOTICE file distributed with&lt;br /&gt;
 * this work for additional information regarding copyright ownership.&lt;br /&gt;
 * The ASF licenses this file to You under the Apache License, Version 2.0&lt;br /&gt;
 * (the &amp;quot;License&amp;quot;); you may not use this file except in compliance with&lt;br /&gt;
 * the License.  You may obtain a copy of the License at&lt;br /&gt;
 *&lt;br /&gt;
 *      http://www.apache.org/licenses/LICENSE-2.0&lt;br /&gt;
 *&lt;br /&gt;
 * Unless required by applicable law or agreed to in writing, software&lt;br /&gt;
 * distributed under the License is distributed on an &amp;quot;AS IS&amp;quot; BASIS,&lt;br /&gt;
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.&lt;br /&gt;
 * See the License for the specific language governing permissions and&lt;br /&gt;
 * limitations under the License.&lt;br /&gt;
 */&lt;br /&gt;
&lt;br /&gt;
/**&lt;br /&gt;
 * Defines a collection that allows objects to be removed in some well-defined order.&lt;br /&gt;
 * &amp;lt;p&amp;gt;&lt;br /&gt;
 * The removal order can be based on insertion order (eg, a FIFO queue or a&lt;br /&gt;
 * LIFO stack), on access order (eg, an LRU cache), on some arbitrary comparator&lt;br /&gt;
 * (eg, a priority queue) or on any other well-defined ordering.&lt;br /&gt;
 * &amp;lt;p&amp;gt;&lt;br /&gt;
 * Note that the removal order is not necessarily the same as the iteration&lt;br /&gt;
 * order.  A &amp;lt;code&amp;gt;Buffer&amp;lt;/code&amp;gt; implementation may have equivalent removal&lt;br /&gt;
 * and iteration orders, but this is not required.&lt;br /&gt;
 * &amp;lt;p&amp;gt;&lt;br /&gt;
 * This interface does not specify any behavior for &lt;br /&gt;
 * {@link Object#equals(Object)} and {@link Object#hashCode} methods.  It&lt;br /&gt;
 * is therefore possible for a &amp;lt;code&amp;gt;Buffer&amp;lt;/code&amp;gt; implementation to also&lt;br /&gt;
 * also implement {@link java.util.List}, {@link java.util.Set} or &lt;br /&gt;
 * {@link Bag}.&lt;br /&gt;
 * &amp;lt;p&amp;gt;&lt;br /&gt;
 * &amp;lt;strong&amp;gt;Note:&amp;lt;/strong&amp;gt; this class should be bytecode-identical to the &lt;br /&gt;
 * version in commons collections. This is required to allow backwards &lt;br /&gt;
 * compability with both previous versions of BeanUtils and also allow &lt;br /&gt;
 * coexistance with both collections 2.1 and 3.0.&lt;br /&gt;
 *&lt;br /&gt;
 * @since Commons Collections 2.1&lt;br /&gt;
 * @version $Revision: 555824 $ $Date: 2007-07-13 01:27:15 +0100 (Fri, 13 Jul 2007) $&lt;br /&gt;
 * &lt;br /&gt;
 * @author Avalon&lt;br /&gt;
 * @author Berin Loritsch&lt;br /&gt;
 * @author Paul Jack&lt;br /&gt;
 * @author Stephen Colebourne&lt;br /&gt;
 */&lt;br /&gt;
interface Buffer extends Collection {&lt;br /&gt;
    /**&lt;br /&gt;
     * Gets and removes the next object from the buffer.&lt;br /&gt;
     *&lt;br /&gt;
     * @return the next object in the buffer, which is also removed&lt;br /&gt;
     * @throws BufferUnderflowException if the buffer is already empty&lt;br /&gt;
     */&lt;br /&gt;
    Object remove();&lt;br /&gt;
    /**&lt;br /&gt;
     * Gets the next object from the buffer without removing it.&lt;br /&gt;
     *&lt;br /&gt;
     * @return the next object in the buffer, which is not removed&lt;br /&gt;
     * @throws BufferUnderflowException if the buffer is empty&lt;br /&gt;
     */&lt;br /&gt;
    Object get();&lt;br /&gt;
}&lt;br /&gt;
/*&lt;br /&gt;
 * Licensed to the Apache Software Foundation (ASF) under one or more&lt;br /&gt;
 * contributor license agreements.  See the NOTICE file distributed with&lt;br /&gt;
 * this work for additional information regarding copyright ownership.&lt;br /&gt;
 * The ASF licenses this file to You under the Apache License, Version 2.0&lt;br /&gt;
 * (the &amp;quot;License&amp;quot;); you may not use this file except in compliance with&lt;br /&gt;
 * the License.  You may obtain a copy of the License at&lt;br /&gt;
 *&lt;br /&gt;
 *      http://www.apache.org/licenses/LICENSE-2.0&lt;br /&gt;
 *&lt;br /&gt;
 * Unless required by applicable law or agreed to in writing, software&lt;br /&gt;
 * distributed under the License is distributed on an &amp;quot;AS IS&amp;quot; BASIS,&lt;br /&gt;
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.&lt;br /&gt;
 * See the License for the specific language governing permissions and&lt;br /&gt;
 * limitations under the License.&lt;br /&gt;
 */&lt;br /&gt;
&lt;br /&gt;
/**&lt;br /&gt;
 * The BufferUnderflowException is used when the buffer is already empty.&lt;br /&gt;
 * &amp;lt;p&amp;gt;&lt;br /&gt;
 * NOTE: From version 3.0, this exception extends NoSuchElementException.&lt;br /&gt;
 * &lt;br /&gt;
 * @since Commons Collections 2.1&lt;br /&gt;
 * @version $Revision: 555824 $ $Date: 2007-07-13 01:27:15 +0100 (Fri, 13 Jul 2007) $&lt;br /&gt;
 *&lt;br /&gt;
 * @author Avalon&lt;br /&gt;
 * @author Berin Loritsch&lt;br /&gt;
 * @author Jeff Turner&lt;br /&gt;
 * @author Paul Jack&lt;br /&gt;
 * @author Stephen Colebourne&lt;br /&gt;
 */&lt;br /&gt;
 class BufferUnderflowException extends NoSuchElementException {&lt;br /&gt;
    &lt;br /&gt;
    /** The root cause throwable */&lt;br /&gt;
    private final Throwable throwable;&lt;br /&gt;
    /**&lt;br /&gt;
     * Constructs a new &amp;lt;code&amp;gt;BufferUnderflowException&amp;lt;/code&amp;gt;.&lt;br /&gt;
     */&lt;br /&gt;
    public BufferUnderflowException() {&lt;br /&gt;
        super();&lt;br /&gt;
        throwable = null;&lt;br /&gt;
    }&lt;br /&gt;
    /** &lt;br /&gt;
     * Construct a new &amp;lt;code&amp;gt;BufferUnderflowException&amp;lt;/code&amp;gt;.&lt;br /&gt;
     * &lt;br /&gt;
     * @param message  the detail message for this exception&lt;br /&gt;
     */&lt;br /&gt;
    public BufferUnderflowException(String message) {&lt;br /&gt;
        this(message, null);&lt;br /&gt;
    }&lt;br /&gt;
    /** &lt;br /&gt;
     * Construct a new &amp;lt;code&amp;gt;BufferUnderflowException&amp;lt;/code&amp;gt;.&lt;br /&gt;
     * &lt;br /&gt;
     * @param message  the detail message for this exception&lt;br /&gt;
     * @param exception  the root cause of the exception&lt;br /&gt;
     */&lt;br /&gt;
    public BufferUnderflowException(String message, Throwable exception) {&lt;br /&gt;
        super(message);&lt;br /&gt;
        throwable = exception;&lt;br /&gt;
    }&lt;br /&gt;
    /**&lt;br /&gt;
     * Gets the root cause of the exception.&lt;br /&gt;
     *&lt;br /&gt;
     * @return the root cause&lt;br /&gt;
     */&lt;br /&gt;
    public final Throwable getCause() {&lt;br /&gt;
        return throwable;&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
}&lt;br /&gt;
   &lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Another Set demo ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
     &lt;br /&gt;
import java.util.Arrays;&lt;br /&gt;
import java.util.HashSet;&lt;br /&gt;
import java.util.Set;&lt;br /&gt;
public class SetMembership {&lt;br /&gt;
  final static String[] keywordarray = { &amp;quot;abstract&amp;quot;, &amp;quot;assert&amp;quot;, &amp;quot;boolean&amp;quot;,&lt;br /&gt;
      &amp;quot;break&amp;quot;, &amp;quot;byte&amp;quot;, &amp;quot;while&amp;quot; };&lt;br /&gt;
  final static Set keywords = new HashSet(Arrays.asList(keywordarray));&lt;br /&gt;
  static boolean isKeyword1(String id) {&lt;br /&gt;
    return keywords.contains(id);&lt;br /&gt;
  }&lt;br /&gt;
  static boolean isKeyword2(String id) {&lt;br /&gt;
    return Arrays.binarySearch(keywordarray, id) &amp;gt;= 0;&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
           &lt;br /&gt;
         &lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Array Set extends AbstractSet ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
     &lt;br /&gt;
import java.io.Serializable;&lt;br /&gt;
import java.util.*;&lt;br /&gt;
public class ArraySet extends AbstractSet&lt;br /&gt;
    implements Cloneable, Serializable {&lt;br /&gt;
  private ArrayList list;&lt;br /&gt;
  public ArraySet() {&lt;br /&gt;
    list = new ArrayList();&lt;br /&gt;
  }&lt;br /&gt;
  public ArraySet(Collection col) {&lt;br /&gt;
    list = new ArrayList();&lt;br /&gt;
    // No need to check for dups if col is a set&lt;br /&gt;
    Iterator itor = col.iterator();&lt;br /&gt;
    if (col instanceof Set) {&lt;br /&gt;
      while (itor.hasNext()) {&lt;br /&gt;
        list.add(itor.next());&lt;br /&gt;
      }&lt;br /&gt;
    } else {&lt;br /&gt;
      while(itor.hasNext()) {&lt;br /&gt;
        add(itor.next());&lt;br /&gt;
      }&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
  public Iterator iterator() {&lt;br /&gt;
    return list.iterator();&lt;br /&gt;
  }&lt;br /&gt;
  public int size() {&lt;br /&gt;
    return list.size();&lt;br /&gt;
  }&lt;br /&gt;
  public boolean add(Object element) {&lt;br /&gt;
    boolean modified;&lt;br /&gt;
    if (modified = !list.contains(element)) {&lt;br /&gt;
      list.add(element);&lt;br /&gt;
    }&lt;br /&gt;
    return modified;&lt;br /&gt;
  }&lt;br /&gt;
  public boolean remove(Object element) {&lt;br /&gt;
    return list.remove(element);&lt;br /&gt;
  }&lt;br /&gt;
  public boolean isEmpty() {&lt;br /&gt;
    return list.isEmpty();&lt;br /&gt;
  }&lt;br /&gt;
  public boolean contains(Object element) {&lt;br /&gt;
    return list.contains(element);&lt;br /&gt;
  }&lt;br /&gt;
  public void clear() {&lt;br /&gt;
    list.clear();&lt;br /&gt;
  }&lt;br /&gt;
  public Object clone() {&lt;br /&gt;
    try { &lt;br /&gt;
      ArraySet newSet = (ArraySet)super.clone();&lt;br /&gt;
      newSet.list = (ArrayList)list.clone();&lt;br /&gt;
      return newSet;&lt;br /&gt;
    } catch (CloneNotSupportedException e) { &lt;br /&gt;
      throw new InternalError();&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
           &lt;br /&gt;
         &lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== A thin wrapper around a List transforming it into a modifiable Set. ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
import java.io.Serializable;&lt;br /&gt;
import java.util.AbstractSet;&lt;br /&gt;
import java.util.ArrayList;&lt;br /&gt;
import java.util.Collection;&lt;br /&gt;
import java.util.Iterator;&lt;br /&gt;
import java.util.List;&lt;br /&gt;
import java.util.Set;&lt;br /&gt;
/**&lt;br /&gt;
 * A thin wrapper around a &amp;lt;code&amp;gt;List&amp;lt;/code&amp;gt; transforming it into a modifiable&lt;br /&gt;
 * &amp;lt;code&amp;gt;Set&amp;lt;/code&amp;gt;.&lt;br /&gt;
 * &lt;br /&gt;
 * @version &amp;lt;tt&amp;gt;$Revision: 2800 $&amp;lt;/tt&amp;gt;&lt;br /&gt;
 * @author &lt;br /&gt;
 */&lt;br /&gt;
@SuppressWarnings(&amp;quot;unchecked&amp;quot;)&lt;br /&gt;
public class ListSet extends AbstractSet implements Set, Cloneable, Serializable {&lt;br /&gt;
  /** The serialVersionUID */&lt;br /&gt;
  private static final long serialVersionUID = 7333619218072079496L;&lt;br /&gt;
  /** The &amp;lt;tt&amp;gt;List&amp;lt;/tt&amp;gt; which will be used for element storage. */&lt;br /&gt;
  protected final List list;&lt;br /&gt;
  /**&lt;br /&gt;
   * Construct a &amp;lt;tt&amp;gt;ListSet&amp;lt;/tt&amp;gt;.&lt;br /&gt;
   * &lt;br /&gt;
   * @param list&lt;br /&gt;
   *          The &amp;lt;tt&amp;gt;List&amp;lt;/tt&amp;gt; which will be used for element storage.&lt;br /&gt;
   * &lt;br /&gt;
   * @throws IllegalArgumentException&lt;br /&gt;
   *           List is &amp;lt;tt&amp;gt;null&amp;lt;/tt&amp;gt; or contains duplicate entries.&lt;br /&gt;
   */&lt;br /&gt;
  public ListSet(final List list) {&lt;br /&gt;
    if (list == null)&lt;br /&gt;
      throw new RuntimeException(&amp;quot;list&amp;quot;);&lt;br /&gt;
    // make sure there are no duplicates&lt;br /&gt;
    int size = list.size();&lt;br /&gt;
    for (int i = 0; i &amp;lt; size; i++) {&lt;br /&gt;
      Object obj = list.get(i);&lt;br /&gt;
      if (list.indexOf(obj) != list.lastIndexOf(obj)) {&lt;br /&gt;
        throw new IllegalArgumentException(&amp;quot;list contains duplicate entries&amp;quot;);&lt;br /&gt;
      }&lt;br /&gt;
    }&lt;br /&gt;
    this.list = list;&lt;br /&gt;
  }&lt;br /&gt;
  /**&lt;br /&gt;
   * Construct a &amp;lt;tt&amp;gt;ListSet&amp;lt;/tt&amp;gt; using an &amp;lt;tt&amp;gt;ArrayList&amp;lt;/tt&amp;gt; for backing.&lt;br /&gt;
   */&lt;br /&gt;
  public ListSet() {&lt;br /&gt;
    this(new ArrayList());&lt;br /&gt;
  }&lt;br /&gt;
  /**&lt;br /&gt;
   * Construct a &amp;lt;tt&amp;gt;ListSet&amp;lt;/tt&amp;gt; using an &amp;lt;tt&amp;gt;ArrayList&amp;lt;/tt&amp;gt; for backing&lt;br /&gt;
   * and populated with the given elements.&lt;br /&gt;
   * &lt;br /&gt;
   * @param elements&lt;br /&gt;
   *          The elements for the list.&lt;br /&gt;
   */&lt;br /&gt;
  public ListSet(final Collection elements) {&lt;br /&gt;
    this(new ArrayList(elements));&lt;br /&gt;
  }&lt;br /&gt;
  public List getList() {&lt;br /&gt;
    return list;&lt;br /&gt;
  }&lt;br /&gt;
  /**&lt;br /&gt;
   * Return the size of the set.&lt;br /&gt;
   * &lt;br /&gt;
   * @return The size of the set.&lt;br /&gt;
   */&lt;br /&gt;
  public int size() {&lt;br /&gt;
    return list.size();&lt;br /&gt;
  }&lt;br /&gt;
  /**&lt;br /&gt;
   * Return an iteration over the elements in the set.&lt;br /&gt;
   * &lt;br /&gt;
   * @return An iteration over the elements in the set.&lt;br /&gt;
   */&lt;br /&gt;
  public Iterator iterator() {&lt;br /&gt;
    return list.iterator();&lt;br /&gt;
  }&lt;br /&gt;
  /**&lt;br /&gt;
   * Add an element to the set.&lt;br /&gt;
   * &lt;br /&gt;
   * @param obj&lt;br /&gt;
   *          Element to add to the set.&lt;br /&gt;
   * @return True if the element was added.&lt;br /&gt;
   */&lt;br /&gt;
  public boolean add(final Object obj) {&lt;br /&gt;
    boolean added = false;&lt;br /&gt;
    if (!list.contains(obj)) {&lt;br /&gt;
      added = list.add(obj);&lt;br /&gt;
    }&lt;br /&gt;
    return added;&lt;br /&gt;
  }&lt;br /&gt;
  /**&lt;br /&gt;
   * Returns &amp;lt;tt&amp;gt;true&amp;lt;/tt&amp;gt; if this set contains no elements.&lt;br /&gt;
   * &lt;br /&gt;
   * @return &amp;lt;tt&amp;gt;true&amp;lt;/tt&amp;gt; if this set contains no elements.&lt;br /&gt;
   */&lt;br /&gt;
  public boolean isEmpty() {&lt;br /&gt;
    return list.isEmpty();&lt;br /&gt;
  }&lt;br /&gt;
  /**&lt;br /&gt;
   * Returns &amp;lt;tt&amp;gt;true&amp;lt;/tt&amp;gt; if this set contains the specified element.&lt;br /&gt;
   * &lt;br /&gt;
   * @param obj&lt;br /&gt;
   *          Element whose presence in this set is to be tested.&lt;br /&gt;
   * @return &amp;lt;tt&amp;gt;true&amp;lt;/tt&amp;gt; if this set contains the specified element.&lt;br /&gt;
   */&lt;br /&gt;
  public boolean contains(final Object obj) {&lt;br /&gt;
    return list.contains(obj);&lt;br /&gt;
  }&lt;br /&gt;
  /**&lt;br /&gt;
   * Removes the given element from this set if it is present.&lt;br /&gt;
   * &lt;br /&gt;
   * @param obj&lt;br /&gt;
   *          Object to be removed from this set, if present.&lt;br /&gt;
   * @return &amp;lt;tt&amp;gt;true&amp;lt;/tt&amp;gt; if the set contained the specified element.&lt;br /&gt;
   */&lt;br /&gt;
  public boolean remove(final Object obj) {&lt;br /&gt;
    return list.remove(obj);&lt;br /&gt;
  }&lt;br /&gt;
  /**&lt;br /&gt;
   * Removes all of the elements from this set.&lt;br /&gt;
   */&lt;br /&gt;
  public void clear() {&lt;br /&gt;
    list.clear();&lt;br /&gt;
  }&lt;br /&gt;
  /**&lt;br /&gt;
   * Returns a shallow copy of this &amp;lt;tt&amp;gt;ListSet&amp;lt;/tt&amp;gt; instance.&lt;br /&gt;
   * &lt;br /&gt;
   * @return A shallow copy of this set.&lt;br /&gt;
   */&lt;br /&gt;
  public Object clone() {&lt;br /&gt;
    try {&lt;br /&gt;
      return super.clone();&lt;br /&gt;
    } catch (CloneNotSupportedException e) {&lt;br /&gt;
      throw new InternalError();&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
   &lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== A thread-safe Set that manages canonical objects ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
/*&lt;br /&gt;
 *  Copyright 2004 Brian S O&amp;quot;Neill&lt;br /&gt;
 *&lt;br /&gt;
 *  Licensed under the Apache License, Version 2.0 (the &amp;quot;License&amp;quot;);&lt;br /&gt;
 *  you may not use this file except in compliance with the License.&lt;br /&gt;
 *  You may obtain a copy of the License at&lt;br /&gt;
 *&lt;br /&gt;
 *      http://www.apache.org/licenses/LICENSE-2.0&lt;br /&gt;
 *&lt;br /&gt;
 *  Unless required by applicable law or agreed to in writing, software&lt;br /&gt;
 *  distributed under the License is distributed on an &amp;quot;AS IS&amp;quot; BASIS,&lt;br /&gt;
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.&lt;br /&gt;
 *  See the License for the specific language governing permissions and&lt;br /&gt;
 *  limitations under the License.&lt;br /&gt;
 */&lt;br /&gt;
//revised from cojen&lt;br /&gt;
import java.lang.ref.Reference;&lt;br /&gt;
import java.lang.ref.ReferenceQueue;&lt;br /&gt;
import java.lang.ref.WeakReference;&lt;br /&gt;
import java.util.AbstractSet;&lt;br /&gt;
import java.util.Iterator;&lt;br /&gt;
import java.util.NoSuchElementException;&lt;br /&gt;
/**&lt;br /&gt;
 * A thread-safe Set that manages canonical objects: sharable objects that are&lt;br /&gt;
 * typically immutable. Call the {@link #put put} method for supplying the&lt;br /&gt;
 * WeakCanonicalSet with candidate canonical instances.&lt;br /&gt;
 * &amp;lt;p&amp;gt;&lt;br /&gt;
 * Objects that do not customize the hashCode and equals methods don&amp;quot;t make&lt;br /&gt;
 * sense to be canonicalized because each instance will be considered unique.&lt;br /&gt;
 * The object returned from the {@link #put put} method will always be the same&lt;br /&gt;
 * as the one passed in.&lt;br /&gt;
 *&lt;br /&gt;
 * @author Brian S O&amp;quot;Neill&lt;br /&gt;
 */&lt;br /&gt;
public class WeakCanonicalSet&amp;lt;T&amp;gt; extends AbstractSet&amp;lt;T&amp;gt; {&lt;br /&gt;
    private Entry&amp;lt;T&amp;gt;[] table;&lt;br /&gt;
    private int count;&lt;br /&gt;
    private int threshold;&lt;br /&gt;
    private final float loadFactor;&lt;br /&gt;
    private final ReferenceQueue&amp;lt;T&amp;gt; queue;&lt;br /&gt;
    public WeakCanonicalSet() {&lt;br /&gt;
        final int initialCapacity = 101;&lt;br /&gt;
        final float loadFactor = 0.75f;&lt;br /&gt;
        this.loadFactor = loadFactor;&lt;br /&gt;
        this.table = new Entry[initialCapacity];&lt;br /&gt;
        this.threshold = (int)(initialCapacity * loadFactor);&lt;br /&gt;
        this.queue = new ReferenceQueue&amp;lt;T&amp;gt;();&lt;br /&gt;
    }&lt;br /&gt;
    /**&lt;br /&gt;
     * Pass in a candidate canonical object and get a unique instance from this&lt;br /&gt;
     * set. The returned object will always be of the same type as that passed&lt;br /&gt;
     * in. If the object passed in does not equal any object currently in the&lt;br /&gt;
     * set, it will be added to the set, becoming canonical.&lt;br /&gt;
     *&lt;br /&gt;
     * @param obj candidate canonical object; null is also accepted&lt;br /&gt;
     */&lt;br /&gt;
    public synchronized &amp;lt;U extends T&amp;gt; U put(U obj) {&lt;br /&gt;
        // This implementation is based on the WeakIdentityMap.put method.&lt;br /&gt;
        if (obj == null) {&lt;br /&gt;
            return null;&lt;br /&gt;
        }&lt;br /&gt;
        Entry&amp;lt;T&amp;gt;[] tab = this.table;&lt;br /&gt;
        // Cleanup after cleared References.&lt;br /&gt;
        {&lt;br /&gt;
            ReferenceQueue queue = this.queue;&lt;br /&gt;
            Reference ref;&lt;br /&gt;
            while ((ref = queue.poll()) != null) {&lt;br /&gt;
                // Since buckets are single-linked, traverse entire list and&lt;br /&gt;
                // cleanup all cleared references in it.&lt;br /&gt;
                int index = (((Entry) ref).hash &amp;amp; 0x7fffffff) % tab.length;&lt;br /&gt;
                for (Entry&amp;lt;T&amp;gt; e = tab[index], prev = null; e != null; e = e.next) {&lt;br /&gt;
                    if (e.get() == null) {&lt;br /&gt;
                        if (prev != null) {&lt;br /&gt;
                            prev.next = e.next;&lt;br /&gt;
                        } else {&lt;br /&gt;
                            tab[index] = e.next;&lt;br /&gt;
                        }&lt;br /&gt;
                        this.count--;&lt;br /&gt;
                    } else {&lt;br /&gt;
                        prev = e;&lt;br /&gt;
                    }&lt;br /&gt;
                }&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
        int hash = hashCode(obj);&lt;br /&gt;
        int index = (hash &amp;amp; 0x7fffffff) % tab.length;&lt;br /&gt;
        for (Entry&amp;lt;T&amp;gt; e = tab[index], prev = null; e != null; e = e.next) {&lt;br /&gt;
            T iobj = e.get();&lt;br /&gt;
            if (iobj == null) {&lt;br /&gt;
                // Clean up after a cleared Reference.&lt;br /&gt;
                if (prev != null) {&lt;br /&gt;
                    prev.next = e.next;&lt;br /&gt;
                } else {&lt;br /&gt;
                    tab[index] = e.next;&lt;br /&gt;
                }&lt;br /&gt;
                this.count--;&lt;br /&gt;
            } else if (e.hash == hash &amp;amp;&amp;amp;&lt;br /&gt;
                       obj.getClass() == iobj.getClass() &amp;amp;&amp;amp;&lt;br /&gt;
                       equals(obj, iobj)) {&lt;br /&gt;
                // Found canonical instance.&lt;br /&gt;
                return (U) iobj;&lt;br /&gt;
            } else {&lt;br /&gt;
                prev = e;&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
        if (this.count &amp;gt;= this.threshold) {&lt;br /&gt;
            // Rehash the table if the threshold is exceeded.&lt;br /&gt;
            rehash();&lt;br /&gt;
            tab = this.table;&lt;br /&gt;
            index = (hash &amp;amp; 0x7fffffff) % tab.length;&lt;br /&gt;
        }&lt;br /&gt;
        // Create a new entry.&lt;br /&gt;
        tab[index] = new Entry&amp;lt;T&amp;gt;(obj, this.queue, hash, tab[index]);&lt;br /&gt;
        this.count++;&lt;br /&gt;
        return obj;&lt;br /&gt;
    }&lt;br /&gt;
    public Iterator&amp;lt;T&amp;gt; iterator() {&lt;br /&gt;
        return new SetIterator();&lt;br /&gt;
    }&lt;br /&gt;
    public int size() {&lt;br /&gt;
        return this.count;&lt;br /&gt;
    }&lt;br /&gt;
    public synchronized boolean contains(Object obj) {&lt;br /&gt;
        if (obj == null) {&lt;br /&gt;
            return false;&lt;br /&gt;
        }&lt;br /&gt;
        Entry&amp;lt;T&amp;gt;[] tab = this.table;&lt;br /&gt;
        int hash = hashCode(obj);&lt;br /&gt;
        int index = (hash &amp;amp; 0x7fffffff) % tab.length;&lt;br /&gt;
        for (Entry&amp;lt;T&amp;gt; e = tab[index], prev = null; e != null; e = e.next) {&lt;br /&gt;
            Object iobj = e.get();&lt;br /&gt;
            if (iobj == null) {&lt;br /&gt;
                // Clean up after a cleared Reference.&lt;br /&gt;
                if (prev != null) {&lt;br /&gt;
                    prev.next = e.next;&lt;br /&gt;
                } else {&lt;br /&gt;
                    tab[index] = e.next;&lt;br /&gt;
                }&lt;br /&gt;
                this.count--;&lt;br /&gt;
            } else if (e.hash == hash &amp;amp;&amp;amp;&lt;br /&gt;
                     obj.getClass() == iobj.getClass() &amp;amp;&amp;amp;&lt;br /&gt;
                     equals(obj, iobj)) {&lt;br /&gt;
                // Found canonical instance.&lt;br /&gt;
                return true;&lt;br /&gt;
            } else {&lt;br /&gt;
                prev = e;&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
        return false;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    protected int hashCode(Object obj) {&lt;br /&gt;
        return obj.hashCode();&lt;br /&gt;
    }&lt;br /&gt;
    protected boolean equals(Object a, Object b) {&lt;br /&gt;
        return a.equals(b);&lt;br /&gt;
    }&lt;br /&gt;
    private void rehash() {&lt;br /&gt;
        int oldCapacity = this.table.length;&lt;br /&gt;
        Entry&amp;lt;T&amp;gt;[] tab = this.table;&lt;br /&gt;
        int newCapacity = oldCapacity * 2 + 1;&lt;br /&gt;
        Entry&amp;lt;T&amp;gt;[] newTab = new Entry[newCapacity];&lt;br /&gt;
        this.threshold = (int)(newCapacity * this.loadFactor);&lt;br /&gt;
        this.table = newTab;&lt;br /&gt;
        for (int i = oldCapacity; i-- &amp;gt; 0; ) {&lt;br /&gt;
            for (Entry&amp;lt;T&amp;gt; old = tab[i]; old != null; ) {&lt;br /&gt;
                Entry&amp;lt;T&amp;gt; e = old;&lt;br /&gt;
                old = old.next;&lt;br /&gt;
                // Only copy entry if it hasn&amp;quot;t been cleared.&lt;br /&gt;
                if (e.get() == null) {&lt;br /&gt;
                    this.count--;&lt;br /&gt;
                } else {&lt;br /&gt;
                    int index = (e.hash &amp;amp; 0x7fffffff) % newCapacity;&lt;br /&gt;
                    e.next = newTab[index];&lt;br /&gt;
                    newTab[index] = e;&lt;br /&gt;
                }&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
    private static class Entry&amp;lt;T&amp;gt; extends WeakReference&amp;lt;T&amp;gt; {&lt;br /&gt;
        int hash;&lt;br /&gt;
        Entry&amp;lt;T&amp;gt; next;&lt;br /&gt;
        Entry(T canonical, ReferenceQueue&amp;lt;T&amp;gt; queue, int hash, Entry&amp;lt;T&amp;gt; next) {&lt;br /&gt;
            super(canonical, queue);&lt;br /&gt;
            this.hash = hash;&lt;br /&gt;
            this.next = next;&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
    private class SetIterator implements Iterator&amp;lt;T&amp;gt; {&lt;br /&gt;
        private final Entry&amp;lt;T&amp;gt;[] table;&lt;br /&gt;
        private int index;&lt;br /&gt;
        // To ensure that the iterator doesn&amp;quot;t return cleared entries, keep a&lt;br /&gt;
        // hard reference to the canonical object. Its existence will prevent&lt;br /&gt;
        // the weak reference from being cleared.&lt;br /&gt;
        private T entryCanonical;&lt;br /&gt;
        private Entry&amp;lt;T&amp;gt; entry;&lt;br /&gt;
        SetIterator() {&lt;br /&gt;
            this.table = WeakCanonicalSet.this.table;&lt;br /&gt;
            this.index = table.length;&lt;br /&gt;
        }&lt;br /&gt;
        public boolean hasNext() {&lt;br /&gt;
            while (this.entry == null || (this.entryCanonical = this.entry.get()) == null) {&lt;br /&gt;
                if (this.entry != null) {&lt;br /&gt;
                    // Skip past a cleared Reference.&lt;br /&gt;
                    this.entry = this.entry.next;&lt;br /&gt;
                } else {&lt;br /&gt;
                    if (this.index &amp;lt;= 0) {&lt;br /&gt;
                        return false;&lt;br /&gt;
                    } else {&lt;br /&gt;
                        this.entry = this.table[--this.index];&lt;br /&gt;
                    }&lt;br /&gt;
                }&lt;br /&gt;
            }&lt;br /&gt;
            return true;&lt;br /&gt;
        }&lt;br /&gt;
        public T next() {&lt;br /&gt;
            if (!hasNext()) {&lt;br /&gt;
                throw new NoSuchElementException();&lt;br /&gt;
            }&lt;br /&gt;
            this.entry = this.entry.next;&lt;br /&gt;
            return this.entryCanonical;&lt;br /&gt;
        }&lt;br /&gt;
        public void remove() {&lt;br /&gt;
            throw new UnsupportedOperationException();&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Converts a char array to a Set ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
/*&lt;br /&gt;
 * The contents of this file are subject to the Sapient Public License&lt;br /&gt;
 * Version 1.0 (the &amp;quot;License&amp;quot;); you may not use this file except in compliance&lt;br /&gt;
 * with the License. You may obtain a copy of the License at&lt;br /&gt;
 * http://carbon.sf.net/License.html.&lt;br /&gt;
 *&lt;br /&gt;
 * Software distributed under the License is distributed on an &amp;quot;AS IS&amp;quot; basis,&lt;br /&gt;
 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for&lt;br /&gt;
 * the specific language governing rights and limitations under the License.&lt;br /&gt;
 *&lt;br /&gt;
 * The Original Code is The Carbon Component Framework.&lt;br /&gt;
 *&lt;br /&gt;
 * The Initial Developer of the Original Code is Sapient Corporation&lt;br /&gt;
 *&lt;br /&gt;
 * Copyright (C) 2003 Sapient Corporation. All Rights Reserved.&lt;br /&gt;
 */&lt;br /&gt;
&lt;br /&gt;
import java.util.ArrayList;&lt;br /&gt;
import java.util.HashSet;&lt;br /&gt;
import java.util.List;&lt;br /&gt;
import java.util.Set;&lt;br /&gt;
import java.util.StringTokenizer;&lt;br /&gt;
/**&lt;br /&gt;
 * &amp;lt;p&amp;gt;Utilities for strings.&amp;lt;/p&amp;gt;&lt;br /&gt;
 *&lt;br /&gt;
 *&lt;br /&gt;
 * Copyright 2002 Sapient&lt;br /&gt;
 * @since carbon 1.0&lt;br /&gt;
 * @author Greg Hinkle, May 2002&lt;br /&gt;
 * @version $Revision: 1.5 $($Author: dvoet $ / $Date: 2003/05/05 21:21:24 $)&lt;br /&gt;
 */&lt;br /&gt;
public class StringUtil {&lt;br /&gt;
  /**&lt;br /&gt;
   * &amp;lt;p&amp;gt; Converts a string to a Set. Breaks the string to characters and store&lt;br /&gt;
   * each character in a Set.&lt;br /&gt;
   *&lt;br /&gt;
   * @param string the string to convert&lt;br /&gt;
   * @return a &amp;lt;code&amp;gt;Set&amp;lt;/code&amp;gt; containing all characters in the text string parameter&lt;br /&gt;
   */&lt;br /&gt;
  public static Set convertToSet(String string) {&lt;br /&gt;
      // Result hashset&lt;br /&gt;
      Set resultSet = new HashSet();&lt;br /&gt;
      for (int i = 0; i &amp;lt; string.length(); i++) {&lt;br /&gt;
          resultSet.add(new Character(string.charAt(i)));&lt;br /&gt;
      }&lt;br /&gt;
      // Return result&lt;br /&gt;
      return resultSet;&lt;br /&gt;
  }&lt;br /&gt;
  /**&lt;br /&gt;
   * &amp;lt;p&amp;gt; Converts a char array to a Set. Puts all characters in the array to a Set.&lt;br /&gt;
   *&lt;br /&gt;
   * @param charArray an array of &amp;lt;CODE&amp;gt;char&amp;lt;/CODE&amp;gt;s&lt;br /&gt;
   * @return a &amp;lt;code&amp;gt;set&amp;lt;/code&amp;gt; containing all characters in the char array&lt;br /&gt;
   */&lt;br /&gt;
  public static Set convertToSet(char[] charArray) {&lt;br /&gt;
      // Result hashset&lt;br /&gt;
      Set resultSet = new HashSet();&lt;br /&gt;
      for (int i = 0; i &amp;lt; charArray.length; i++) {&lt;br /&gt;
          resultSet.add(new Character(charArray[i]));&lt;br /&gt;
      }&lt;br /&gt;
      // Return result&lt;br /&gt;
      return resultSet;&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
   &lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Converts a string to a Set ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
/*&lt;br /&gt;
 * The contents of this file are subject to the Sapient Public License&lt;br /&gt;
 * Version 1.0 (the &amp;quot;License&amp;quot;); you may not use this file except in compliance&lt;br /&gt;
 * with the License. You may obtain a copy of the License at&lt;br /&gt;
 * http://carbon.sf.net/License.html.&lt;br /&gt;
 *&lt;br /&gt;
 * Software distributed under the License is distributed on an &amp;quot;AS IS&amp;quot; basis,&lt;br /&gt;
 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for&lt;br /&gt;
 * the specific language governing rights and limitations under the License.&lt;br /&gt;
 *&lt;br /&gt;
 * The Original Code is The Carbon Component Framework.&lt;br /&gt;
 *&lt;br /&gt;
 * The Initial Developer of the Original Code is Sapient Corporation&lt;br /&gt;
 *&lt;br /&gt;
 * Copyright (C) 2003 Sapient Corporation. All Rights Reserved.&lt;br /&gt;
 */&lt;br /&gt;
&lt;br /&gt;
import java.util.ArrayList;&lt;br /&gt;
import java.util.HashSet;&lt;br /&gt;
import java.util.List;&lt;br /&gt;
import java.util.Set;&lt;br /&gt;
import java.util.StringTokenizer;&lt;br /&gt;
/**&lt;br /&gt;
 * &amp;lt;p&amp;gt;Utilities for strings.&amp;lt;/p&amp;gt;&lt;br /&gt;
 *&lt;br /&gt;
 *&lt;br /&gt;
 * Copyright 2002 Sapient&lt;br /&gt;
 * @since carbon 1.0&lt;br /&gt;
 * @author Greg Hinkle, May 2002&lt;br /&gt;
 * @version $Revision: 1.5 $($Author: dvoet $ / $Date: 2003/05/05 21:21:24 $)&lt;br /&gt;
 */&lt;br /&gt;
public class StringUtil {&lt;br /&gt;
  /**&lt;br /&gt;
   * &amp;lt;p&amp;gt; Converts a string to a Set. Breaks the string to characters and store&lt;br /&gt;
   * each character in a Set.&lt;br /&gt;
   *&lt;br /&gt;
   * @param string the string to convert&lt;br /&gt;
   * @return a &amp;lt;code&amp;gt;Set&amp;lt;/code&amp;gt; containing all characters in the text string parameter&lt;br /&gt;
   */&lt;br /&gt;
  public static Set convertToSet(String string) {&lt;br /&gt;
      // Result hashset&lt;br /&gt;
      Set resultSet = new HashSet();&lt;br /&gt;
      for (int i = 0; i &amp;lt; string.length(); i++) {&lt;br /&gt;
          resultSet.add(new Character(string.charAt(i)));&lt;br /&gt;
      }&lt;br /&gt;
      // Return result&lt;br /&gt;
      return resultSet;&lt;br /&gt;
  }&lt;br /&gt;
  /**&lt;br /&gt;
   * &amp;lt;p&amp;gt; Converts a char array to a Set. Puts all characters in the array to a Set.&lt;br /&gt;
   *&lt;br /&gt;
   * @param charArray an array of &amp;lt;CODE&amp;gt;char&amp;lt;/CODE&amp;gt;s&lt;br /&gt;
   * @return a &amp;lt;code&amp;gt;set&amp;lt;/code&amp;gt; containing all characters in the char array&lt;br /&gt;
   */&lt;br /&gt;
  public static Set convertToSet(char[] charArray) {&lt;br /&gt;
      // Result hashset&lt;br /&gt;
      Set resultSet = new HashSet();&lt;br /&gt;
      for (int i = 0; i &amp;lt; charArray.length; i++) {&lt;br /&gt;
          resultSet.add(new Character(charArray[i]));&lt;br /&gt;
      }&lt;br /&gt;
      // Return result&lt;br /&gt;
      return resultSet;&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
   &lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Copy all the elements from set2 to set1 (set1 += set2), set1 becomes the union of set1 and set2 ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
     &lt;br /&gt;
import java.util.HashSet;&lt;br /&gt;
import java.util.Set;&lt;br /&gt;
public class Main {&lt;br /&gt;
  public static void main(String[] argv) throws Exception {&lt;br /&gt;
    Set set1 = new HashSet();&lt;br /&gt;
    Set set2 = new HashSet();&lt;br /&gt;
    set1.addAll(set2);&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
   &lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Demonstrate the Set interface ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
     &lt;br /&gt;
/*&lt;br /&gt;
 * Copyright (c) Ian F. Darwin, http://www.darwinsys.ru/, 1996-2002.&lt;br /&gt;
 * All rights reserved. Software written by Ian F. Darwin and others.&lt;br /&gt;
 * $Id: LICENSE,v 1.8 2004/02/09 03:33:38 ian Exp $&lt;br /&gt;
 *&lt;br /&gt;
 * Redistribution and use in source and binary forms, with or without&lt;br /&gt;
 * modification, are permitted provided that the following conditions&lt;br /&gt;
 * are met:&lt;br /&gt;
 * 1. Redistributions of source code must retain the above copyright&lt;br /&gt;
 *    notice, this list of conditions and the following disclaimer.&lt;br /&gt;
 * 2. Redistributions in binary form must reproduce the above copyright&lt;br /&gt;
 *    notice, this list of conditions and the following disclaimer in the&lt;br /&gt;
 *    documentation and/or other materials provided with the distribution.&lt;br /&gt;
 *&lt;br /&gt;
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS&amp;quot;&amp;quot;&lt;br /&gt;
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED&lt;br /&gt;
 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR&lt;br /&gt;
 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS&lt;br /&gt;
 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR&lt;br /&gt;
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF&lt;br /&gt;
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS&lt;br /&gt;
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN&lt;br /&gt;
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)&lt;br /&gt;
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE&lt;br /&gt;
 * POSSIBILITY OF SUCH DAMAGE.&lt;br /&gt;
 * &lt;br /&gt;
 * Java, the Duke mascot, and all variants of Sun&amp;quot;s Java &amp;quot;steaming coffee&lt;br /&gt;
 * cup&amp;quot; logo are trademarks of Sun Microsystems. Sun&amp;quot;s, and James Gosling&amp;quot;s,&lt;br /&gt;
 * pioneering role in inventing and promulgating (and standardizing) the Java &lt;br /&gt;
 * language and environment is gratefully acknowledged.&lt;br /&gt;
 * &lt;br /&gt;
 * The pioneering role of Dennis Ritchie and Bjarne Stroustrup, of AT&amp;amp;T, for&lt;br /&gt;
 * inventing predecessor languages C and C++ is also gratefully acknowledged.&lt;br /&gt;
 */&lt;br /&gt;
import java.util.*;&lt;br /&gt;
/**&lt;br /&gt;
 * Demonstrate the Set interface&lt;br /&gt;
 * @author Ian F. Darwin, http://www.darwinsys.ru/&lt;br /&gt;
 * @version $Id: SetDemo.java,v 1.4 2004/02/09 03:34:04 ian Exp $&lt;br /&gt;
 */&lt;br /&gt;
public class SetDemo {&lt;br /&gt;
  public static void main(String[] argv) {&lt;br /&gt;
    //+&lt;br /&gt;
    Set h = new HashSet();&lt;br /&gt;
    h.add(&amp;quot;One&amp;quot;);&lt;br /&gt;
    h.add(&amp;quot;Two&amp;quot;);&lt;br /&gt;
    h.add(&amp;quot;One&amp;quot;); // DUPLICATE&lt;br /&gt;
    h.add(&amp;quot;Three&amp;quot;);&lt;br /&gt;
    Iterator it = h.iterator();&lt;br /&gt;
    while (it.hasNext()) {&lt;br /&gt;
      System.out.println(it.next());&lt;br /&gt;
    }&lt;br /&gt;
    //-&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
           &lt;br /&gt;
         &lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Extend AbstractSet to Create Simple Set ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
/* SimpleSet Copyright (C) 1998-2002 Jochen Hoenicke.&lt;br /&gt;
 *&lt;br /&gt;
 * This program is free software; you can redistribute it and/or modify&lt;br /&gt;
 * it under the terms of the GNU Lesser General Public License as published by&lt;br /&gt;
 * the Free Software Foundation; either version 2, or (at your option)&lt;br /&gt;
 * any later version.&lt;br /&gt;
 *&lt;br /&gt;
 * This program is distributed in the hope that it will be useful,&lt;br /&gt;
 * but WITHOUT ANY WARRANTY; without even the implied warranty of&lt;br /&gt;
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the&lt;br /&gt;
 * GNU General Public License for more details.&lt;br /&gt;
 *&lt;br /&gt;
 * You should have received a copy of the GNU Lesser General Public License&lt;br /&gt;
 * along with this program; see the file COPYING.LESSER.  If not, write to&lt;br /&gt;
 * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.&lt;br /&gt;
 *&lt;br /&gt;
 * $Id: SimpleSet.java.in,v 1.1.2.1 2002/05/28 17:34:24 hoenicke Exp $&lt;br /&gt;
 */&lt;br /&gt;
import java.util.AbstractSet;&lt;br /&gt;
import java.util.Iterator;&lt;br /&gt;
public class SimpleSet extends AbstractSet implements Cloneable&lt;br /&gt;
{&lt;br /&gt;
    Object[] elementObjects;&lt;br /&gt;
    int count = 0;&lt;br /&gt;
    public SimpleSet() {&lt;br /&gt;
  this(2);&lt;br /&gt;
    }&lt;br /&gt;
    public SimpleSet(int initialSize) {&lt;br /&gt;
  elementObjects = new Object[initialSize];&lt;br /&gt;
    }&lt;br /&gt;
    public int size() {&lt;br /&gt;
  return count;&lt;br /&gt;
    }&lt;br /&gt;
    public boolean add(Object element) {&lt;br /&gt;
  if (element == null)&lt;br /&gt;
      throw new NullPointerException();&lt;br /&gt;
  for (int i=0; i&amp;lt; count; i++) {&lt;br /&gt;
      if (element.equals(elementObjects[i]))&lt;br /&gt;
    return false;&lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
  if (count == elementObjects.length) {&lt;br /&gt;
            Object[] newArray = new Object[(count+1)*3/2];&lt;br /&gt;
            System.arraycopy(elementObjects,0,newArray,0,count);&lt;br /&gt;
            elementObjects = newArray;&lt;br /&gt;
        }&lt;br /&gt;
        elementObjects[count++] = element;&lt;br /&gt;
  return true;&lt;br /&gt;
    }&lt;br /&gt;
  &lt;br /&gt;
    public Object clone() {&lt;br /&gt;
        try {&lt;br /&gt;
            SimpleSet other = (SimpleSet) super.clone();&lt;br /&gt;
      other.elementObjects = (Object[]) elementObjects.clone();&lt;br /&gt;
            return other;&lt;br /&gt;
        } catch (CloneNotSupportedException ex) {&lt;br /&gt;
           &lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
    public Iterator iterator() {&lt;br /&gt;
  return new Iterator() {&lt;br /&gt;
      int pos = 0;&lt;br /&gt;
      public boolean hasNext() {&lt;br /&gt;
    return pos &amp;lt; count;&lt;br /&gt;
      }&lt;br /&gt;
      &lt;br /&gt;
      public Object next() {&lt;br /&gt;
    return elementObjects[pos++];&lt;br /&gt;
      }&lt;br /&gt;
    &lt;br /&gt;
      public void remove() {&lt;br /&gt;
    if (pos &amp;lt; count)&lt;br /&gt;
        System.arraycopy(elementObjects, pos, &lt;br /&gt;
             elementObjects, pos-1, count - pos);&lt;br /&gt;
    count--;&lt;br /&gt;
    pos--;&lt;br /&gt;
      }&lt;br /&gt;
  };&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
   &lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Get the intersection of set1 and set2, set1 becomes the intersection of set1 and set2 ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
     &lt;br /&gt;
import java.util.HashSet;&lt;br /&gt;
import java.util.Set;&lt;br /&gt;
public class Main {&lt;br /&gt;
  public static void main(String[] argv) throws Exception {&lt;br /&gt;
    Set set1 = new HashSet();&lt;br /&gt;
    Set set2 = new HashSet();&lt;br /&gt;
    set1.retainAll(set2);&lt;br /&gt;
    // Remove all elements from a set&lt;br /&gt;
    set1.clear();&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
   &lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Implements the Set interface, backed by a ConcurrentHashMap instance ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
/*&lt;br /&gt;
 * Licensed to the Apache Software Foundation (ASF) under one or more&lt;br /&gt;
 * contributor license agreements.  See the NOTICE file distributed with&lt;br /&gt;
 * this work for additional information regarding copyright ownership.&lt;br /&gt;
 * The ASF licenses this file to You under the Apache License, Version 2.0&lt;br /&gt;
 * (the &amp;quot;License&amp;quot;); you may not use this file except in compliance with&lt;br /&gt;
 * the License.  You may obtain a copy of the License at&lt;br /&gt;
 *&lt;br /&gt;
 *      http://www.apache.org/licenses/LICENSE-2.0&lt;br /&gt;
 *&lt;br /&gt;
 * Unless required by applicable law or agreed to in writing, software&lt;br /&gt;
 * distributed under the License is distributed on an &amp;quot;AS IS&amp;quot; BASIS,&lt;br /&gt;
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.&lt;br /&gt;
 * See the License for the specific language governing permissions and&lt;br /&gt;
 * limitations under the License.&lt;br /&gt;
 */&lt;br /&gt;
import java.io.IOException;&lt;br /&gt;
import java.io.ObjectInputStream;&lt;br /&gt;
import java.util.AbstractSet;&lt;br /&gt;
import java.util.Collection;&lt;br /&gt;
import java.util.Iterator;&lt;br /&gt;
import java.util.Set;&lt;br /&gt;
import java.util.concurrent.ConcurrentHashMap;&lt;br /&gt;
/**&lt;br /&gt;
 * This class implements the &amp;lt;tt&amp;gt;Set&amp;lt;/tt&amp;gt; interface, backed by a ConcurrentHashMap instance.&lt;br /&gt;
 * &lt;br /&gt;
 * @author Matt Tucker&lt;br /&gt;
 * @param &amp;lt;E&amp;gt;&lt;br /&gt;
 */&lt;br /&gt;
public class ConcurrentHashSet&amp;lt;E&amp;gt; extends AbstractSet&amp;lt;E&amp;gt;&lt;br /&gt;
  implements&lt;br /&gt;
    Set&amp;lt;E&amp;gt;,&lt;br /&gt;
    Cloneable,&lt;br /&gt;
    java.io.Serializable&lt;br /&gt;
{&lt;br /&gt;
  /** */&lt;br /&gt;
  private static final long serialVersionUID = 1L;&lt;br /&gt;
  private transient ConcurrentHashMap&amp;lt;E, Object&amp;gt; map;&lt;br /&gt;
  // Dummy value to associate with an Object in the backing Map&lt;br /&gt;
  private static final Object PRESENT = new Object();&lt;br /&gt;
  /**&lt;br /&gt;
   * Constructs a new, empty set; the backing &amp;lt;tt&amp;gt;ConcurrentHashMap&amp;lt;/tt&amp;gt; instance has default&lt;br /&gt;
   * initial capacity (16) and load factor (0.75).&lt;br /&gt;
   */&lt;br /&gt;
  public ConcurrentHashSet()&lt;br /&gt;
  {&lt;br /&gt;
    map = new ConcurrentHashMap&amp;lt;E, Object&amp;gt;();&lt;br /&gt;
  }&lt;br /&gt;
  /**&lt;br /&gt;
   * Constructs a new set containing the elements in the specified collection. The&lt;br /&gt;
   * &amp;lt;tt&amp;gt;ConcurrentHashMap&amp;lt;/tt&amp;gt; is created with default load factor (0.75) and an initial capacity&lt;br /&gt;
   * sufficient to contain the elements in the specified collection.&lt;br /&gt;
   * &lt;br /&gt;
   * @param c&lt;br /&gt;
   *            the collection whose elements are to be placed into this set.&lt;br /&gt;
   * @throws NullPointerException&lt;br /&gt;
   *             if the specified collection is null.&lt;br /&gt;
   */&lt;br /&gt;
  public ConcurrentHashSet(Collection&amp;lt;? extends E&amp;gt; c)&lt;br /&gt;
  {&lt;br /&gt;
    map = new ConcurrentHashMap&amp;lt;E, Object&amp;gt;(Math.max((int)(c.size() / .75f) + 1, 16));&lt;br /&gt;
    addAll(c);&lt;br /&gt;
  }&lt;br /&gt;
  /**&lt;br /&gt;
   * Constructs a new, empty set; the backing &amp;lt;tt&amp;gt;ConcurrentHashMap&amp;lt;/tt&amp;gt; instance has the&lt;br /&gt;
   * specified initial capacity and the specified load factor.&lt;br /&gt;
   * &lt;br /&gt;
   * @param initialCapacity&lt;br /&gt;
   *            the initial capacity of the hash map.&lt;br /&gt;
   * @param loadFactor&lt;br /&gt;
   *            the load factor of the hash map.&lt;br /&gt;
   * @throws IllegalArgumentException&lt;br /&gt;
   *             if the initial capacity is less than zero, or if the load factor is nonpositive.&lt;br /&gt;
   */&lt;br /&gt;
  public ConcurrentHashSet(int initialCapacity, float loadFactor)&lt;br /&gt;
  {&lt;br /&gt;
    map = new ConcurrentHashMap&amp;lt;E, Object&amp;gt;(initialCapacity, loadFactor, 16);&lt;br /&gt;
  }&lt;br /&gt;
  /**&lt;br /&gt;
   * Constructs a new, empty set; the backing &amp;lt;tt&amp;gt;HashMap&amp;lt;/tt&amp;gt; instance has the specified initial&lt;br /&gt;
   * capacity and default load factor, which is &amp;lt;tt&amp;gt;0.75&amp;lt;/tt&amp;gt;.&lt;br /&gt;
   * &lt;br /&gt;
   * @param initialCapacity&lt;br /&gt;
   *            the initial capacity of the hash table.&lt;br /&gt;
   * @throws IllegalArgumentException&lt;br /&gt;
   *             if the initial capacity is less than zero.&lt;br /&gt;
   */&lt;br /&gt;
  public ConcurrentHashSet(int initialCapacity)&lt;br /&gt;
  {&lt;br /&gt;
    map = new ConcurrentHashMap&amp;lt;E, Object&amp;gt;(initialCapacity);&lt;br /&gt;
  }&lt;br /&gt;
  /**&lt;br /&gt;
   * &lt;br /&gt;
   * @see java.util.AbstractCollection#iterator()&lt;br /&gt;
   */&lt;br /&gt;
  @Override&lt;br /&gt;
  public Iterator&amp;lt;E&amp;gt; iterator()&lt;br /&gt;
  {&lt;br /&gt;
    return map.keySet().iterator();&lt;br /&gt;
  }&lt;br /&gt;
  /**&lt;br /&gt;
   * &lt;br /&gt;
   * @see java.util.AbstractCollection#size()&lt;br /&gt;
   */&lt;br /&gt;
  @Override&lt;br /&gt;
  public int size()&lt;br /&gt;
  {&lt;br /&gt;
    return map.size();&lt;br /&gt;
  }&lt;br /&gt;
  /**&lt;br /&gt;
   * &lt;br /&gt;
   * @see java.util.AbstractCollection#isEmpty()&lt;br /&gt;
   */&lt;br /&gt;
  @Override&lt;br /&gt;
  public boolean isEmpty()&lt;br /&gt;
  {&lt;br /&gt;
    return map.isEmpty();&lt;br /&gt;
  }&lt;br /&gt;
  /**&lt;br /&gt;
   * &lt;br /&gt;
   * @see java.util.AbstractCollection#contains(java.lang.Object)&lt;br /&gt;
   */&lt;br /&gt;
  @Override&lt;br /&gt;
  public boolean contains(Object o)&lt;br /&gt;
  {&lt;br /&gt;
    return map.containsKey(o);&lt;br /&gt;
  }&lt;br /&gt;
  /**&lt;br /&gt;
   * &lt;br /&gt;
   * @see java.util.AbstractCollection#add(java.lang.Object)&lt;br /&gt;
   */&lt;br /&gt;
  @Override&lt;br /&gt;
  public boolean add(E o)&lt;br /&gt;
  {&lt;br /&gt;
    return map.put(o, PRESENT) == null;&lt;br /&gt;
  }&lt;br /&gt;
  /**&lt;br /&gt;
   * &lt;br /&gt;
   * @see java.util.AbstractCollection#remove(java.lang.Object)&lt;br /&gt;
   */&lt;br /&gt;
  @Override&lt;br /&gt;
  public boolean remove(Object o)&lt;br /&gt;
  {&lt;br /&gt;
    return map.remove(o) == PRESENT;&lt;br /&gt;
  }&lt;br /&gt;
  /**&lt;br /&gt;
   * &lt;br /&gt;
   * @see java.util.AbstractCollection#clear()&lt;br /&gt;
   */&lt;br /&gt;
  @Override&lt;br /&gt;
  public void clear()&lt;br /&gt;
  {&lt;br /&gt;
    map.clear();&lt;br /&gt;
  }&lt;br /&gt;
  /**&lt;br /&gt;
   * &lt;br /&gt;
   * @see java.lang.Object#clone()&lt;br /&gt;
   */&lt;br /&gt;
  @SuppressWarnings(&amp;quot;unchecked&amp;quot;)&lt;br /&gt;
  @Override&lt;br /&gt;
  public Object clone()&lt;br /&gt;
  {&lt;br /&gt;
    try&lt;br /&gt;
    {&lt;br /&gt;
      ConcurrentHashSet&amp;lt;E&amp;gt; newSet = (ConcurrentHashSet&amp;lt;E&amp;gt;)super.clone();&lt;br /&gt;
      newSet.map.putAll(map);&lt;br /&gt;
      return newSet;&lt;br /&gt;
    }&lt;br /&gt;
    catch (CloneNotSupportedException e)&lt;br /&gt;
    {&lt;br /&gt;
      throw new InternalError();&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
  /**&lt;br /&gt;
   * &lt;br /&gt;
   * @param s&lt;br /&gt;
   * @throws java.io.IOException&lt;br /&gt;
   */&lt;br /&gt;
  private void writeObject(java.io.ObjectOutputStream s) throws java.io.IOException&lt;br /&gt;
  {&lt;br /&gt;
    s.defaultWriteObject();&lt;br /&gt;
    s.writeInt(map.size());&lt;br /&gt;
    for (Iterator&amp;lt;E&amp;gt; i = map.keySet().iterator(); i.hasNext();)&lt;br /&gt;
    {&lt;br /&gt;
      s.writeObject(i.next());&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
  /**&lt;br /&gt;
   * Re-constitute the &amp;lt;tt&amp;gt;HashSet&amp;lt;/tt&amp;gt; instance from a stream.&lt;br /&gt;
   * &lt;br /&gt;
   * @param inputStream&lt;br /&gt;
   * @throws ClassNotFoundException&lt;br /&gt;
   * @throws IOException&lt;br /&gt;
   */&lt;br /&gt;
  private void readObject(ObjectInputStream inputStream) throws ClassNotFoundException,&lt;br /&gt;
    IOException&lt;br /&gt;
  {&lt;br /&gt;
    inputStream.defaultReadObject();&lt;br /&gt;
    map = new ConcurrentHashMap&amp;lt;E, Object&amp;gt;();&lt;br /&gt;
    int size = inputStream.readInt();&lt;br /&gt;
    for (int i = 0; i &amp;lt; size; i++)&lt;br /&gt;
    {&lt;br /&gt;
      E e = (E)inputStream.readObject();&lt;br /&gt;
      map.put(e, PRESENT);&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
   &lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Int Set ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
/* Copyright (C) 2003 Vladimir Roubtsov. All rights reserved.&lt;br /&gt;
 * &lt;br /&gt;
 * This program and the accompanying materials are made available under&lt;br /&gt;
 * the terms of the Common Public License v1.0 which accompanies this distribution,&lt;br /&gt;
 * and is available at http://www.eclipse.org/legal/cpl-v10.html&lt;br /&gt;
 * &lt;br /&gt;
 * $Id: IntSet.java,v 1.1.1.1 2004/05/09 16:57:53 vlad_r Exp $&lt;br /&gt;
 */&lt;br /&gt;
// ----------------------------------------------------------------------------&lt;br /&gt;
/**&lt;br /&gt;
 *&lt;br /&gt;
 * MT-safety: an instance of this class is &amp;lt;I&amp;gt;not&amp;lt;/I&amp;gt; safe for access from&lt;br /&gt;
 * multiple concurrent threads [even if access is done by a single thread at a&lt;br /&gt;
 * time]. The caller is expected to synchronize externally on an instance [the&lt;br /&gt;
 * implementation does not do internal synchronization for the sake of efficiency].&lt;br /&gt;
 * java.util.ConcurrentModificationException is not supported either.&lt;br /&gt;
 *&lt;br /&gt;
 * @author Vlad Roubtsov, (C) 2001&lt;br /&gt;
 */&lt;br /&gt;
public&lt;br /&gt;
final class IntSet&lt;br /&gt;
{&lt;br /&gt;
    // public: ................................................................&lt;br /&gt;
    /**&lt;br /&gt;
     * Equivalent to &amp;lt;CODE&amp;gt;IntSet(11, 0.75F)&amp;lt;/CODE&amp;gt;.&lt;br /&gt;
     */&lt;br /&gt;
    public IntSet ()&lt;br /&gt;
    {&lt;br /&gt;
        this (11, 0.75F);&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    /**&lt;br /&gt;
     * Equivalent to &amp;lt;CODE&amp;gt;IntSet(capacity, 0.75F)&amp;lt;/CODE&amp;gt;.&lt;br /&gt;
     */&lt;br /&gt;
    public IntSet (final int initialCapacity)&lt;br /&gt;
    {&lt;br /&gt;
        this (initialCapacity, 0.75F);&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    /**&lt;br /&gt;
     * Constructs an IntSet with specified initial capacity and load factor.&lt;br /&gt;
     *&lt;br /&gt;
     * @param initialCapacity initial number of hash buckets in the table [may not be negative, 0 is equivalent to 1].&lt;br /&gt;
     * @param loadFactor the load factor to use to determine rehashing points [must be in (0.0, 1.0] range].&lt;br /&gt;
     */&lt;br /&gt;
    public IntSet (int initialCapacity, final float loadFactor)&lt;br /&gt;
    {&lt;br /&gt;
        if (initialCapacity &amp;lt; 0) throw new IllegalArgumentException (&amp;quot;negative input: initialCapacity [&amp;quot; + initialCapacity + &amp;quot;]&amp;quot;);&lt;br /&gt;
        if ((loadFactor &amp;lt;= 0.0) || (loadFactor &amp;gt;= 1.0 + 1.0E-6))&lt;br /&gt;
            throw new IllegalArgumentException (&amp;quot;loadFactor not in (0.0, 1.0] range: &amp;quot; + loadFactor);&lt;br /&gt;
        &lt;br /&gt;
        if (initialCapacity == 0) initialCapacity = 1;&lt;br /&gt;
        &lt;br /&gt;
        m_loadFactor = loadFactor &amp;gt; 1.0 ? 1.0F : loadFactor;        &lt;br /&gt;
        m_sizeThreshold = (int) (initialCapacity * loadFactor);&lt;br /&gt;
        m_buckets = new Entry [initialCapacity];&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
    /**&lt;br /&gt;
     * Overrides Object.toString() for debug purposes.&lt;br /&gt;
     */&lt;br /&gt;
    public String toString ()&lt;br /&gt;
    {&lt;br /&gt;
        final StringBuffer s = new StringBuffer ();&lt;br /&gt;
        debugDump (s);&lt;br /&gt;
        &lt;br /&gt;
        return s.toString ();&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    /**&lt;br /&gt;
     * Returns the number of key-value mappings in this map.&lt;br /&gt;
     */&lt;br /&gt;
    public int size ()&lt;br /&gt;
    {&lt;br /&gt;
        return m_size;&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    public boolean contains (final int key)&lt;br /&gt;
    {&lt;br /&gt;
        // index into the corresponding hash bucket:&lt;br /&gt;
        final Entry [] buckets = m_buckets;&lt;br /&gt;
        final int bucketIndex = (key &amp;amp; 0x7FFFFFFF) % buckets.length;&lt;br /&gt;
        &lt;br /&gt;
        // traverse the singly-linked list of entries in the bucket:&lt;br /&gt;
        for (Entry entry = buckets [bucketIndex]; entry != null; entry = entry.m_next)&lt;br /&gt;
        {&lt;br /&gt;
            if (key == entry.m_key)&lt;br /&gt;
                return true;&lt;br /&gt;
        }&lt;br /&gt;
        &lt;br /&gt;
        return false;&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    public int [] values ()&lt;br /&gt;
    {&lt;br /&gt;
        if (m_size == 0)&lt;br /&gt;
            return new int[0];&lt;br /&gt;
        else&lt;br /&gt;
        {&lt;br /&gt;
            final int [] result = new int [m_size];&lt;br /&gt;
            int scan = 0;&lt;br /&gt;
            &lt;br /&gt;
            for (int b = 0; b &amp;lt; m_buckets.length; ++ b)&lt;br /&gt;
            {&lt;br /&gt;
                for (Entry entry = m_buckets [b]; entry != null; entry = entry.m_next)&lt;br /&gt;
                {&lt;br /&gt;
                    result [scan ++] = entry.m_key;&lt;br /&gt;
                }&lt;br /&gt;
            }&lt;br /&gt;
            &lt;br /&gt;
            return result;&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    public void values (final int [] target, final int offset)&lt;br /&gt;
    {&lt;br /&gt;
        if (m_size != 0)&lt;br /&gt;
        {&lt;br /&gt;
            int scan = offset;&lt;br /&gt;
            &lt;br /&gt;
            for (int b = 0; b &amp;lt; m_buckets.length; ++ b)&lt;br /&gt;
            {&lt;br /&gt;
                for (Entry entry = m_buckets [b]; entry != null; entry = entry.m_next)&lt;br /&gt;
                {&lt;br /&gt;
                    target [scan ++] = entry.m_key;&lt;br /&gt;
                }&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    public boolean add (final int key)&lt;br /&gt;
    {&lt;br /&gt;
        Entry currentKeyEntry = null;&lt;br /&gt;
        &lt;br /&gt;
        // detect if &amp;quot;key&amp;quot; is already in the table [in which case, set &amp;quot;currentKeyEntry&amp;quot; to point to its entry]:&lt;br /&gt;
        &lt;br /&gt;
        // index into the corresponding hash bucket:&lt;br /&gt;
        int bucketIndex = (key &amp;amp; 0x7FFFFFFF) % m_buckets.length;&lt;br /&gt;
        &lt;br /&gt;
        // traverse the singly-linked list of entries in the bucket:&lt;br /&gt;
        Entry [] buckets = m_buckets;&lt;br /&gt;
        for (Entry entry = buckets [bucketIndex]; entry != null; entry = entry.m_next)&lt;br /&gt;
        {&lt;br /&gt;
            if (key == entry.m_key)&lt;br /&gt;
            {&lt;br /&gt;
                currentKeyEntry = entry;&lt;br /&gt;
                break;&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
        &lt;br /&gt;
        if (currentKeyEntry == null)&lt;br /&gt;
        {&lt;br /&gt;
            // add a new entry:&lt;br /&gt;
            &lt;br /&gt;
            if (m_size &amp;gt;= m_sizeThreshold) rehash ();&lt;br /&gt;
            &lt;br /&gt;
            buckets = m_buckets;&lt;br /&gt;
            bucketIndex = (key &amp;amp; 0x7FFFFFFF) % buckets.length;&lt;br /&gt;
            final Entry bucketListHead = buckets [bucketIndex];&lt;br /&gt;
            final Entry newEntry = new Entry (key, bucketListHead);&lt;br /&gt;
            buckets [bucketIndex] = newEntry;&lt;br /&gt;
            &lt;br /&gt;
            ++ m_size;&lt;br /&gt;
            &lt;br /&gt;
            return true;&lt;br /&gt;
        }&lt;br /&gt;
        else&lt;br /&gt;
            return false;&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    // protected: .............................................................&lt;br /&gt;
    // package: ...............................................................&lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
    void debugDump (final StringBuffer out)&lt;br /&gt;
    {&lt;br /&gt;
        if (out != null)&lt;br /&gt;
        {&lt;br /&gt;
            out.append (super.toString ()); out.append (EOL);&lt;br /&gt;
            out.append (&amp;quot;size = &amp;quot; + m_size + &amp;quot;, bucket table size = &amp;quot; + m_buckets.length + &amp;quot;, load factor = &amp;quot; + m_loadFactor + EOL);&lt;br /&gt;
            out.append (&amp;quot;size threshold = &amp;quot; + m_sizeThreshold + EOL);&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
    // private: ...............................................................&lt;br /&gt;
    &lt;br /&gt;
    /**&lt;br /&gt;
     * The structure used for chaining colliding keys.&lt;br /&gt;
     */&lt;br /&gt;
    private static final class Entry&lt;br /&gt;
    {&lt;br /&gt;
        Entry (final int key, final Entry next)&lt;br /&gt;
        {&lt;br /&gt;
            m_key = key; &lt;br /&gt;
            m_next = next;&lt;br /&gt;
        }&lt;br /&gt;
        &lt;br /&gt;
        final int m_key;&lt;br /&gt;
        &lt;br /&gt;
        Entry m_next; // singly-linked list link&lt;br /&gt;
        &lt;br /&gt;
    } // end of nested class&lt;br /&gt;
    &lt;br /&gt;
    /**&lt;br /&gt;
     * Re-hashes the table into a new array of buckets.&lt;br /&gt;
     */&lt;br /&gt;
    private void rehash ()&lt;br /&gt;
    {&lt;br /&gt;
        // TODO: it is possible to run this method twice, first time using the 2*k+1 prime sequencer for newBucketCount&lt;br /&gt;
        // and then with that value reduced to actually shrink capacity. As it is right now, the bucket table can&lt;br /&gt;
        // only grow in size&lt;br /&gt;
        &lt;br /&gt;
        final Entry [] buckets = m_buckets;&lt;br /&gt;
        &lt;br /&gt;
        final int newBucketCount = (m_buckets.length &amp;lt;&amp;lt; 1) + 1;&lt;br /&gt;
        final Entry [] newBuckets = new Entry [newBucketCount];&lt;br /&gt;
        // rehash all entry chains in every bucket:&lt;br /&gt;
        for (int b = 0; b &amp;lt; buckets.length; ++ b)&lt;br /&gt;
        {&lt;br /&gt;
            for (Entry entry = buckets [b]; entry != null; )&lt;br /&gt;
            {&lt;br /&gt;
                final Entry next = entry.m_next; // remember next pointer because we are going to reuse this entry&lt;br /&gt;
                final int entryKey = entry.m_key;&lt;br /&gt;
            &lt;br /&gt;
                // index into the corresponding new hash bucket:&lt;br /&gt;
                final int newBucketIndex = (entryKey &amp;amp; 0x7FFFFFFF) % newBucketCount;&lt;br /&gt;
                &lt;br /&gt;
                final Entry bucketListHead = newBuckets [newBucketIndex];&lt;br /&gt;
                entry.m_next = bucketListHead;&lt;br /&gt;
                newBuckets [newBucketIndex] = entry;                                &lt;br /&gt;
                &lt;br /&gt;
                entry = next;&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
        &lt;br /&gt;
        m_sizeThreshold = (int) (newBucketCount * m_loadFactor);&lt;br /&gt;
        m_buckets = newBuckets;&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
    private final float m_loadFactor; // determines the setting of m_sizeThreshold&lt;br /&gt;
    &lt;br /&gt;
    private Entry [] m_buckets; // table of buckets&lt;br /&gt;
    private int m_size; // number of keys in the table, not cleared as of last check&lt;br /&gt;
    private int m_sizeThreshold; // size threshold for rehashing&lt;br /&gt;
        &lt;br /&gt;
    private static final String EOL = System.getProperty (&amp;quot;line.separator&amp;quot;, &amp;quot;\n&amp;quot;);&lt;br /&gt;
    &lt;br /&gt;
} // end of class&lt;br /&gt;
// ----------------------------------------------------------------------------&lt;br /&gt;
   &lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== List Set implements Set ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
import java.io.Serializable;&lt;br /&gt;
import java.util.ArrayList;&lt;br /&gt;
import java.util.Collection;&lt;br /&gt;
import java.util.Iterator;&lt;br /&gt;
import java.util.List;&lt;br /&gt;
import java.util.Set;&lt;br /&gt;
/*&lt;br /&gt;
 * &lt;br /&gt;
 * JAFFA - Java Application Framework For All&lt;br /&gt;
 *&lt;br /&gt;
 * Copyright (C) 2002 JAFFA Development Group&lt;br /&gt;
 *&lt;br /&gt;
 *     This library is free software; you can redistribute it and/or&lt;br /&gt;
 *     modify it under the terms of the GNU Lesser General Public&lt;br /&gt;
 *     License as published by the Free Software Foundation; either&lt;br /&gt;
 *     version 2.1 of the License, or (at your option) any later version.&lt;br /&gt;
 *&lt;br /&gt;
 *     This library is distributed in the hope that it will be useful,&lt;br /&gt;
 *     but WITHOUT ANY WARRANTY; without even the implied warranty of&lt;br /&gt;
 *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU&lt;br /&gt;
 *     Lesser General Public License for more details.&lt;br /&gt;
 *&lt;br /&gt;
 *     You should have received a copy of the GNU Lesser General Public&lt;br /&gt;
 *     License along with this library; if not, write to the Free Software&lt;br /&gt;
 *     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA&lt;br /&gt;
 *&lt;br /&gt;
 * Redistribution and use of this software and associated documentation (&amp;quot;Software&amp;quot;),&lt;br /&gt;
 * with or without modification, are permitted provided that the following conditions are met:&lt;br /&gt;
 * 1. Redistributions of source code must retain copyright statements and notices.&lt;br /&gt;
 *         Redistributions must also contain a copy of this document.&lt;br /&gt;
 * 2. Redistributions in binary form must reproduce the above copyright notice,&lt;br /&gt;
 *  this list of conditions and the following disclaimer in the documentation&lt;br /&gt;
 *  and/or other materials provided with the distribution.&lt;br /&gt;
 * 3. The name &amp;quot;JAFFA&amp;quot; must not be used to endorse or promote products derived from&lt;br /&gt;
 *  this Software without prior written permission. For written permission,&lt;br /&gt;
 *  please contact mail to: jaffagroup@yahoo.ru.&lt;br /&gt;
 * 4. Products derived from this Software may not be called &amp;quot;JAFFA&amp;quot; nor may &amp;quot;JAFFA&amp;quot;&lt;br /&gt;
 *  appear in their names without prior written permission.&lt;br /&gt;
 * 5. Due credit should be given to the JAFFA Project (http://jaffa.sourceforge.net).&lt;br /&gt;
 *&lt;br /&gt;
 * THIS SOFTWARE IS PROVIDED &amp;quot;AS IS&amp;quot; AND ANY EXPRESSED OR IMPLIED&lt;br /&gt;
 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES&lt;br /&gt;
 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE&lt;br /&gt;
 * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR&lt;br /&gt;
 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,&lt;br /&gt;
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT&lt;br /&gt;
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF&lt;br /&gt;
 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND&lt;br /&gt;
 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,&lt;br /&gt;
 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT&lt;br /&gt;
 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF&lt;br /&gt;
 * SUCH DAMAGE.&lt;br /&gt;
 * &lt;br /&gt;
 */&lt;br /&gt;
&lt;br /&gt;
/**&lt;br /&gt;
 * This class is backed by an ArrayList. Features are&lt;br /&gt;
 * 1) Ensure the Set functionality of unique elements(including a null) in this data structure&lt;br /&gt;
 * 2) Iterate through the list in the order in which the entries were made&lt;br /&gt;
 */&lt;br /&gt;
class ListSet implements Set, Cloneable, Serializable {&lt;br /&gt;
    List m_set = null;&lt;br /&gt;
&lt;br /&gt;
    /** Creates new ListSet */&lt;br /&gt;
    public ListSet() {&lt;br /&gt;
        m_set = new ArrayList();&lt;br /&gt;
    }&lt;br /&gt;
    /** Creates new ListSet specifying the initial capacity.&lt;br /&gt;
     * @param initialCapacity The initial capacity.&lt;br /&gt;
     */&lt;br /&gt;
    public ListSet(int initialCapacity) {&lt;br /&gt;
        m_set = new ArrayList(initialCapacity);&lt;br /&gt;
    }&lt;br /&gt;
    /** Creates new ListSet from an existing Collection.&lt;br /&gt;
     * @param c An existing collection.&lt;br /&gt;
     */&lt;br /&gt;
    public ListSet(Collection c) {&lt;br /&gt;
        m_set = new ArrayList();&lt;br /&gt;
        if (c != null) {&lt;br /&gt;
            for (Iterator itr = c.iterator(); itr.hasNext();) {&lt;br /&gt;
                Object obj = itr.next();&lt;br /&gt;
                if ( !m_set.contains(obj) )&lt;br /&gt;
                    m_set.add(obj);&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    // *** Set Interface methods ***&lt;br /&gt;
    /** Retains only the elements in this set that are contained in the specified collection.&lt;br /&gt;
     * @param c collection that defines which elements this set will retain.&lt;br /&gt;
     * @return true if this collection changed as a result of the call.&lt;br /&gt;
     */&lt;br /&gt;
    public boolean retainAll(Collection c) {&lt;br /&gt;
        return m_set.retainAll(c);&lt;br /&gt;
    }&lt;br /&gt;
    /** Returns true if this set contains the specified element.&lt;br /&gt;
     * @param o element whose presence in this set is to be tested.&lt;br /&gt;
     * @return true if this set contains the specified element.&lt;br /&gt;
     */&lt;br /&gt;
    public boolean contains(Object o) {&lt;br /&gt;
        return m_set.contains(o);&lt;br /&gt;
    }&lt;br /&gt;
    /** Returns an array containing all of the elements in this set.&lt;br /&gt;
     * @return an array containing all of the elements in this set.&lt;br /&gt;
     */&lt;br /&gt;
    public Object[] toArray() {&lt;br /&gt;
        return m_set.toArray();&lt;br /&gt;
    }&lt;br /&gt;
    /** Returns an array containing all of the elements in this set; the runtime type of the returned array is that of the specified array.&lt;br /&gt;
     * @param a the array into which the elements of this set are to be stored, if it is big enough; otherwise, a new array of the same runtime type is allocated for this purpose.&lt;br /&gt;
     * @return an array containing all of the elements in this set; the runtime type of the returned array is that of the specified array&lt;br /&gt;
     */&lt;br /&gt;
    public Object[] toArray(Object[] a) {&lt;br /&gt;
        return m_set.toArray(a);&lt;br /&gt;
    }&lt;br /&gt;
    /** Returns an iterator over the elements in this set.&lt;br /&gt;
     * @return an iterator over the elements in this set.&lt;br /&gt;
     */&lt;br /&gt;
    public Iterator iterator() {&lt;br /&gt;
        return m_set.iterator();&lt;br /&gt;
    }&lt;br /&gt;
    /** Removes from this set all of its elements that are contained in the specified collection.&lt;br /&gt;
     * @param c collection that defines which elements will be removed from this set.&lt;br /&gt;
     * @return true if this set changed as a result of the call.&lt;br /&gt;
     */&lt;br /&gt;
    public boolean removeAll(Collection c) {&lt;br /&gt;
        return m_set.removeAll(c);&lt;br /&gt;
    }&lt;br /&gt;
    /** Removes the specified element from this set if it is present.&lt;br /&gt;
     * @param o object to be removed from this set, if present.&lt;br /&gt;
     * @return true if the set contained the specified element.&lt;br /&gt;
     */&lt;br /&gt;
    public boolean remove(Object o) {&lt;br /&gt;
        return m_set.remove(o);&lt;br /&gt;
    }&lt;br /&gt;
    /** Removes all of the elements from this set.*/&lt;br /&gt;
    public void clear() {&lt;br /&gt;
        m_set.clear();&lt;br /&gt;
    }&lt;br /&gt;
    /** Returns the hash code value for this set.&lt;br /&gt;
     * @return the hash code value for this set.&lt;br /&gt;
     */&lt;br /&gt;
    public int hashCode() {&lt;br /&gt;
        return m_set.hashCode();&lt;br /&gt;
    }&lt;br /&gt;
    /** Adds all of the elements in the specified collection to this set if they&amp;quot;re not already present.&lt;br /&gt;
     * @param c collection whose elements are to be added to this set.&lt;br /&gt;
     * @return true if this set changed as a result of the call.&lt;br /&gt;
     */&lt;br /&gt;
    public boolean addAll(Collection c) {&lt;br /&gt;
        boolean added = false;&lt;br /&gt;
        if (c != null) {&lt;br /&gt;
            for (Iterator itr = c.iterator(); itr.hasNext();) {&lt;br /&gt;
                Object obj = itr.next();&lt;br /&gt;
                if ( !m_set.contains(obj) ) {&lt;br /&gt;
                    m_set.add(obj);&lt;br /&gt;
                    added = true;&lt;br /&gt;
                }&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
        return added;&lt;br /&gt;
    }&lt;br /&gt;
    /** Returns the number of elements in this set.&lt;br /&gt;
     * @return the number of elements in this set.&lt;br /&gt;
     */&lt;br /&gt;
    public int size() {&lt;br /&gt;
        return m_set.size();&lt;br /&gt;
    }&lt;br /&gt;
    /** Returns true if this set contains all of the elements of the specified collection.&lt;br /&gt;
     * @param c collection to be checked for containment in this set.&lt;br /&gt;
     * @return true if this set contains all of the elements of the specified collection.&lt;br /&gt;
     */&lt;br /&gt;
    public boolean containsAll(Collection c) {&lt;br /&gt;
        return m_set.containsAll(c);&lt;br /&gt;
    }&lt;br /&gt;
    /** Adds the specified element to this set if it is not already present.&lt;br /&gt;
     * @param o element to be added to this set.&lt;br /&gt;
     * @return true if this set did not already contain the specified element.&lt;br /&gt;
     */&lt;br /&gt;
    public boolean add(Object o) {&lt;br /&gt;
        boolean added = false;&lt;br /&gt;
        if ( !m_set.contains(o) ) {&lt;br /&gt;
            m_set.add(o);&lt;br /&gt;
            added = true;&lt;br /&gt;
        }&lt;br /&gt;
        return added;&lt;br /&gt;
    }&lt;br /&gt;
    /** Compares the specified object with this set for equality.&lt;br /&gt;
     * @param o Object to be compared for equality with this set.&lt;br /&gt;
     * @return true if the specified Object is equal to this set.&lt;br /&gt;
     */&lt;br /&gt;
    public boolean equals(Object o) {&lt;br /&gt;
        return m_set.equals(o);&lt;br /&gt;
    }&lt;br /&gt;
    /** Returns true if this set contains no elements.&lt;br /&gt;
     * @return true if this set contains no elements.&lt;br /&gt;
     */&lt;br /&gt;
    public boolean isEmpty() {&lt;br /&gt;
        return m_set.isEmpty();&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    // *** Additional Methods ***&lt;br /&gt;
    /** Adds the specified element to this set if it is not already present, at the specified index.&lt;br /&gt;
     * @param index The position at which the element is to be added.&lt;br /&gt;
     * @param o element to be added to this set.&lt;br /&gt;
     */&lt;br /&gt;
    public void add(int index, Object o) {&lt;br /&gt;
        if ( !m_set.contains(o) )&lt;br /&gt;
            m_set.add(index, o);&lt;br /&gt;
    }&lt;br /&gt;
    /** Returns the element from the specified position.&lt;br /&gt;
     * @param index The position from which the element is to be retrieved.&lt;br /&gt;
     * @return the element from the specified position.&lt;br /&gt;
     */&lt;br /&gt;
    public Object get(int index) {&lt;br /&gt;
        return m_set.get(index);&lt;br /&gt;
    }&lt;br /&gt;
    /** Remove the element from the specified position.&lt;br /&gt;
     * @param index The position from which the element is to be removed.&lt;br /&gt;
     * @return the element being removed.&lt;br /&gt;
     */&lt;br /&gt;
    public Object remove(int index) {&lt;br /&gt;
        return m_set.remove(index);&lt;br /&gt;
    }&lt;br /&gt;
    /** Returns the index of the element in this set.&lt;br /&gt;
     * @param o The element whose index is to be found.&lt;br /&gt;
     * @return the index of the element in this set.&lt;br /&gt;
     */&lt;br /&gt;
    public int indexOf(Object o) {&lt;br /&gt;
        return m_set.indexOf(o);&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    // *** CLONEABLE INTERFACE METHODS ***&lt;br /&gt;
    /** Returns a clone of the Set.&lt;br /&gt;
     * @throws CloneNotSupportedException if cloning is not supported. Should never happen.&lt;br /&gt;
     * @return a clone of the Set.&lt;br /&gt;
     */&lt;br /&gt;
    public Object clone() throws CloneNotSupportedException {&lt;br /&gt;
        Object obj = super.clone();&lt;br /&gt;
        if (m_set != null &amp;amp;&amp;amp; m_set instanceof Cloneable)&lt;br /&gt;
            ( (ListSet) obj ).m_set = (List) ( (ArrayList) m_set ).clone();&lt;br /&gt;
        return obj;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
   &lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== One Item Set ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
/* $Id$&lt;br /&gt;
 *&lt;br /&gt;
 * Behavior Protocols Tools - Parsers, Transformations&lt;br /&gt;
 * Copyright (C) 2006-2007  DSRG, Charles University in Prague&lt;br /&gt;
 *                          http://dsrg.mff.cuni.cz/&lt;br /&gt;
 *&lt;br /&gt;
 * This library is free software; you can redistribute it and/or&lt;br /&gt;
 * modify it under the terms of the GNU Lesser General Public&lt;br /&gt;
 * License as published by the Free Software Foundation; either&lt;br /&gt;
 * version 2.1 of the License, or (at your option) any later version.&lt;br /&gt;
 *&lt;br /&gt;
 * This library is distributed in the hope that it will be useful,&lt;br /&gt;
 * but WITHOUT ANY WARRANTY; without even the implied warranty of&lt;br /&gt;
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU&lt;br /&gt;
 * Lesser General Public License for more details.&lt;br /&gt;
 *&lt;br /&gt;
 * You should have received a copy of the GNU Lesser General Public&lt;br /&gt;
 * License along with this library; if not, write to the Free Software&lt;br /&gt;
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,&lt;br /&gt;
 * MA 02110-1301 USA&lt;br /&gt;
 *&lt;br /&gt;
 */&lt;br /&gt;
&lt;br /&gt;
import java.io.Serializable;&lt;br /&gt;
import java.util.AbstractCollection;&lt;br /&gt;
import java.util.Iterator;&lt;br /&gt;
import java.util.NoSuchElementException;&lt;br /&gt;
&lt;br /&gt;
/**&lt;br /&gt;
 *&lt;br /&gt;
 * @author thorm&lt;br /&gt;
 */&lt;br /&gt;
public class OneItemSet&amp;lt;E&amp;gt; extends AbstractCollection&amp;lt;E&amp;gt; implements Serializable{&lt;br /&gt;
    &lt;br /&gt;
    public boolean add(E i) {&lt;br /&gt;
        if (item == i) {&lt;br /&gt;
            return false;&lt;br /&gt;
        }&lt;br /&gt;
        if (item == null) {&lt;br /&gt;
            item = i;&lt;br /&gt;
            return true;&lt;br /&gt;
        }&lt;br /&gt;
        throw new IllegalArgumentException();&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    public Iterator&amp;lt;E&amp;gt; iterator() {&lt;br /&gt;
        return new Iterator() {&lt;br /&gt;
            public boolean hasNext() {&lt;br /&gt;
                return hasNxt;&lt;br /&gt;
            }&lt;br /&gt;
            &lt;br /&gt;
            public E next() {&lt;br /&gt;
                if (hasNxt) {&lt;br /&gt;
                    hasNxt = false;&lt;br /&gt;
                    return item;&lt;br /&gt;
                }&lt;br /&gt;
                throw new NoSuchElementException();&lt;br /&gt;
            }&lt;br /&gt;
            &lt;br /&gt;
            public void remove() {&lt;br /&gt;
                item = null;&lt;br /&gt;
            }&lt;br /&gt;
            boolean hasNxt = true;&lt;br /&gt;
        };&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    public int size() {&lt;br /&gt;
        return (item == null) ? 0 : 1;&lt;br /&gt;
    }&lt;br /&gt;
    public int hashCode() {&lt;br /&gt;
        return item.hashCode();&lt;br /&gt;
    }&lt;br /&gt;
    public boolean equals(Object o) {&lt;br /&gt;
        return (o instanceof OneItemSet) &amp;amp;&amp;amp; item.equals(((OneItemSet) o).item);&lt;br /&gt;
    }&lt;br /&gt;
            &lt;br /&gt;
    E item;&lt;br /&gt;
}&lt;br /&gt;
   &lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Putting your own type in a Set ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
     &lt;br /&gt;
// : c11:Set2.java&lt;br /&gt;
// Putting your own type in a Set.&lt;br /&gt;
// From &amp;quot;Thinking in Java, 3rd ed.&amp;quot; (c) Bruce Eckel 2002&lt;br /&gt;
// www.BruceEckel.ru. See copyright notice in CopyRight.txt.&lt;br /&gt;
import java.util.HashSet;&lt;br /&gt;
import java.util.LinkedHashSet;&lt;br /&gt;
import java.util.Set;&lt;br /&gt;
import java.util.TreeSet;&lt;br /&gt;
public class Set2 {&lt;br /&gt;
  public static Set fill(Set a, int size) {&lt;br /&gt;
    for (int i = 0; i &amp;lt; size; i++)&lt;br /&gt;
      a.add(new Integer(i));&lt;br /&gt;
    return a;&lt;br /&gt;
  }&lt;br /&gt;
  public static void test(Set a) {&lt;br /&gt;
    fill(a, 10);&lt;br /&gt;
    fill(a, 10); // Try to add duplicates&lt;br /&gt;
    fill(a, 10);&lt;br /&gt;
    a.addAll(fill(new TreeSet(), 10));&lt;br /&gt;
    System.out.println(a);&lt;br /&gt;
  }&lt;br /&gt;
  public static void main(String[] args) {&lt;br /&gt;
    test(new HashSet());&lt;br /&gt;
    test(new TreeSet());&lt;br /&gt;
    test(new LinkedHashSet());&lt;br /&gt;
  }&lt;br /&gt;
} ///:~&lt;br /&gt;
&lt;br /&gt;
           &lt;br /&gt;
         &lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Remove all elements from a set ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
     &lt;br /&gt;
import java.util.HashSet;&lt;br /&gt;
import java.util.Set;&lt;br /&gt;
public class Main {&lt;br /&gt;
  public static void main(String[] argv) throws Exception {&lt;br /&gt;
    Set set1 = new HashSet();&lt;br /&gt;
&lt;br /&gt;
    set1.clear();&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
   &lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Remove all the elements in set1 from set2 (set1 -= set2), set1 becomes the asymmetric difference of set1 and set2 ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
     &lt;br /&gt;
import java.util.HashSet;&lt;br /&gt;
import java.util.Set;&lt;br /&gt;
public class Main {&lt;br /&gt;
  public static void main(String[] argv) throws Exception {&lt;br /&gt;
    Set set1 = new HashSet();&lt;br /&gt;
    Set set2 = new HashSet();&lt;br /&gt;
    set1.removeAll(set2);&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
   &lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Set and TreeSet ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
     &lt;br /&gt;
import java.util.*;&lt;br /&gt;
public class Comp {&lt;br /&gt;
  public static void main (String args[]) throws Exception {&lt;br /&gt;
    String elements[] = {&amp;quot;Irish Setter&amp;quot;, &amp;quot;Poodle&amp;quot;, &lt;br /&gt;
      &amp;quot;English Setter&amp;quot;, &amp;quot;Gordon Setter&amp;quot;, &amp;quot;Pug&amp;quot;};&lt;br /&gt;
    Set set = new TreeSet(Collections.reverseOrder());&lt;br /&gt;
    for (int i=0, n=elements.length; i&amp;lt;n; i++) {&lt;br /&gt;
      set.add(elements[i]);&lt;br /&gt;
    }&lt;br /&gt;
    System.out.println(set);&lt;br /&gt;
    System.out.println(((TreeSet)set).ruparator());  &lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
           &lt;br /&gt;
         &lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Set Copy  ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
     &lt;br /&gt;
import java.io.*;&lt;br /&gt;
import java.util.*;&lt;br /&gt;
public class Copy {&lt;br /&gt;
  public static void main (String args[]) throws Exception {&lt;br /&gt;
    String elements[] = {&amp;quot;Irish Setter&amp;quot;, &amp;quot;Poodle&amp;quot;, &lt;br /&gt;
      &amp;quot;English Setter&amp;quot;, &amp;quot;Gordon Setter&amp;quot;, &amp;quot;Pug&amp;quot;};&lt;br /&gt;
    Set set = new HashSet(Arrays.asList(elements));&lt;br /&gt;
    Set set2 = ((Set)((HashSet)set).clone());&lt;br /&gt;
    System.out.println(set2);&lt;br /&gt;
    FileOutputStream fos = new FileOutputStream(&amp;quot;set.ser&amp;quot;);&lt;br /&gt;
    ObjectOutputStream oos = new ObjectOutputStream(fos);&lt;br /&gt;
    oos.writeObject(set);&lt;br /&gt;
    oos.close();&lt;br /&gt;
    FileInputStream fis = new FileInputStream(&amp;quot;set.ser&amp;quot;);&lt;br /&gt;
    ObjectInputStream ois = new ObjectInputStream(fis);&lt;br /&gt;
    Set set3 = (Set)ois.readObject();&lt;br /&gt;
    ois.close();&lt;br /&gt;
    System.out.println(set3);&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
           &lt;br /&gt;
         &lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Set, HashSet and TreeSet ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
import java.util.HashSet;&lt;br /&gt;
import java.util.Set;&lt;br /&gt;
import java.util.TreeSet;&lt;br /&gt;
public class Main {&lt;br /&gt;
  public static void main(String args[]) {&lt;br /&gt;
    Set&amp;lt;String&amp;gt; hs = new HashSet&amp;lt;String&amp;gt;();&lt;br /&gt;
    hs.add(&amp;quot;one&amp;quot;);&lt;br /&gt;
    hs.add(&amp;quot;two&amp;quot;);&lt;br /&gt;
    hs.add(&amp;quot;three&amp;quot;);&lt;br /&gt;
    System.out.println(&amp;quot;Here is the HashSet: &amp;quot; + hs);&lt;br /&gt;
    if (!hs.add(&amp;quot;three&amp;quot;))&lt;br /&gt;
      System.out.println(&amp;quot;Attempt to add duplicate. &amp;quot; + &amp;quot;Set is unchanged: &amp;quot; + hs);&lt;br /&gt;
    TreeSet&amp;lt;Integer&amp;gt; ts = new TreeSet&amp;lt;Integer&amp;gt;();&lt;br /&gt;
    ts.add(8);&lt;br /&gt;
    ts.add(19);&lt;br /&gt;
    ts.add(-2);&lt;br /&gt;
    ts.add(3);&lt;br /&gt;
    System.out.println(ts);&lt;br /&gt;
    System.out.println(&amp;quot;First element in ts: &amp;quot; + ts.first());&lt;br /&gt;
    System.out.println(&amp;quot;Last element in ts: &amp;quot; + ts.last());&lt;br /&gt;
    System.out.println(&amp;quot;First element &amp;gt; 15: &amp;quot; + ts.higher(15));&lt;br /&gt;
    System.out.println(&amp;quot;First element &amp;lt; 15: &amp;quot; + ts.lower(15));&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
   &lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Set implementation that use == instead of equals() ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
/*&lt;br /&gt;
 * Hibernate, Relational Persistence for Idiomatic Java&lt;br /&gt;
 *&lt;br /&gt;
 * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as&lt;br /&gt;
 * indicated by the @author tags or express copyright attribution&lt;br /&gt;
 * statements applied by the authors.  All third-party contributions are&lt;br /&gt;
 * distributed under license by Red Hat Middleware LLC.&lt;br /&gt;
 *&lt;br /&gt;
 * This copyrighted material is made available to anyone wishing to use, modify,&lt;br /&gt;
 * copy, or redistribute it subject to the terms and conditions of the GNU&lt;br /&gt;
 * Lesser General Public License, as published by the Free Software Foundation.&lt;br /&gt;
 *&lt;br /&gt;
 * This program is distributed in the hope that it will be useful,&lt;br /&gt;
 * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY&lt;br /&gt;
 * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License&lt;br /&gt;
 * for more details.&lt;br /&gt;
 *&lt;br /&gt;
 * You should have received a copy of the GNU Lesser General Public License&lt;br /&gt;
 * along with this distribution; if not, write to:&lt;br /&gt;
 * Free Software Foundation, Inc.&lt;br /&gt;
 * 51 Franklin Street, Fifth Floor&lt;br /&gt;
 * Boston, MA  02110-1301  USA&lt;br /&gt;
 *&lt;br /&gt;
 */&lt;br /&gt;
import java.util.Collection;&lt;br /&gt;
import java.util.IdentityHashMap;&lt;br /&gt;
import java.util.Iterator;&lt;br /&gt;
import java.util.Set;&lt;br /&gt;
/**&lt;br /&gt;
 * Set implementation that use == instead of equals() as its comparison&lt;br /&gt;
 * mechanism.  This is achieved by internally using an IdentityHashMap.&lt;br /&gt;
 *&lt;br /&gt;
 * @author Emmanuel Bernard&lt;br /&gt;
 */&lt;br /&gt;
public class IdentitySet implements Set {&lt;br /&gt;
  private static final Object DUMP_VALUE = new Object();&lt;br /&gt;
  private final IdentityHashMap map;&lt;br /&gt;
  /**&lt;br /&gt;
   * Create an IdentitySet with default sizing.&lt;br /&gt;
   */&lt;br /&gt;
  public IdentitySet() {&lt;br /&gt;
    this.map = new IdentityHashMap();&lt;br /&gt;
  }&lt;br /&gt;
  /**&lt;br /&gt;
   * Create an IdentitySet with the given sizing.&lt;br /&gt;
   *&lt;br /&gt;
   * @param sizing The sizing of the set to create.&lt;br /&gt;
   */&lt;br /&gt;
  public IdentitySet(int sizing) {&lt;br /&gt;
    this.map = new IdentityHashMap( sizing );&lt;br /&gt;
  }&lt;br /&gt;
  public int size() {&lt;br /&gt;
    return map.size();&lt;br /&gt;
  }&lt;br /&gt;
  public boolean isEmpty() {&lt;br /&gt;
    return map.isEmpty();&lt;br /&gt;
  }&lt;br /&gt;
  public boolean contains(Object o) {&lt;br /&gt;
    return map.get( o ) == DUMP_VALUE;&lt;br /&gt;
  }&lt;br /&gt;
  public Iterator iterator() {&lt;br /&gt;
    return map.entrySet().iterator();&lt;br /&gt;
  }&lt;br /&gt;
  public Object[] toArray() {&lt;br /&gt;
    return map.entrySet().toArray();&lt;br /&gt;
  }&lt;br /&gt;
  public Object[] toArray(Object[] a) {&lt;br /&gt;
    return map.entrySet().toArray( a );&lt;br /&gt;
  }&lt;br /&gt;
  public boolean add(Object o) {&lt;br /&gt;
    return map.put( o, DUMP_VALUE ) == null;&lt;br /&gt;
  }&lt;br /&gt;
  public boolean remove(Object o) {&lt;br /&gt;
    return map.remove( o ) == DUMP_VALUE;&lt;br /&gt;
  }&lt;br /&gt;
  public boolean containsAll(Collection c) {&lt;br /&gt;
    Iterator it = c.iterator();&lt;br /&gt;
    while ( it.hasNext() ) {&lt;br /&gt;
      if ( !map.containsKey( it.next() ) ) {&lt;br /&gt;
        return false;&lt;br /&gt;
      }&lt;br /&gt;
    }&lt;br /&gt;
    return true;&lt;br /&gt;
  }&lt;br /&gt;
  public boolean addAll(Collection c) {&lt;br /&gt;
    Iterator it = c.iterator();&lt;br /&gt;
    boolean changed = false;&lt;br /&gt;
    while ( it.hasNext() ) {&lt;br /&gt;
      if ( this.add( it.next() ) ) {&lt;br /&gt;
        changed = true;&lt;br /&gt;
      }&lt;br /&gt;
    }&lt;br /&gt;
    return changed;&lt;br /&gt;
  }&lt;br /&gt;
  public boolean retainAll(Collection c) {&lt;br /&gt;
    //doable if needed&lt;br /&gt;
    throw new UnsupportedOperationException();&lt;br /&gt;
  }&lt;br /&gt;
  public boolean removeAll(Collection c) {&lt;br /&gt;
    Iterator it = c.iterator();&lt;br /&gt;
    boolean changed = false;&lt;br /&gt;
    while ( it.hasNext() ) {&lt;br /&gt;
      if ( this.remove( it.next() ) ) {&lt;br /&gt;
        changed = true;&lt;br /&gt;
      }&lt;br /&gt;
    }&lt;br /&gt;
    return changed;&lt;br /&gt;
  }&lt;br /&gt;
  public void clear() {&lt;br /&gt;
    map.clear();&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
   &lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Set operations: union, intersection, difference, symmetric difference, is subset, is superset ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
import java.util.Set;&lt;br /&gt;
import java.util.TreeSet;&lt;br /&gt;
public class Main {&lt;br /&gt;
  public static &amp;lt;T&amp;gt; Set&amp;lt;T&amp;gt; union(Set&amp;lt;T&amp;gt; setA, Set&amp;lt;T&amp;gt; setB) {&lt;br /&gt;
    Set&amp;lt;T&amp;gt; tmp = new TreeSet&amp;lt;T&amp;gt;(setA);&lt;br /&gt;
    tmp.addAll(setB);&lt;br /&gt;
    return tmp;&lt;br /&gt;
  }&lt;br /&gt;
  public static &amp;lt;T&amp;gt; Set&amp;lt;T&amp;gt; intersection(Set&amp;lt;T&amp;gt; setA, Set&amp;lt;T&amp;gt; setB) {&lt;br /&gt;
    Set&amp;lt;T&amp;gt; tmp = new TreeSet&amp;lt;T&amp;gt;();&lt;br /&gt;
    for (T x : setA)&lt;br /&gt;
      if (setB.contains(x))&lt;br /&gt;
        tmp.add(x);&lt;br /&gt;
    return tmp;&lt;br /&gt;
  }&lt;br /&gt;
  public static &amp;lt;T&amp;gt; Set&amp;lt;T&amp;gt; difference(Set&amp;lt;T&amp;gt; setA, Set&amp;lt;T&amp;gt; setB) {&lt;br /&gt;
    Set&amp;lt;T&amp;gt; tmp = new TreeSet&amp;lt;T&amp;gt;(setA);&lt;br /&gt;
    tmp.removeAll(setB);&lt;br /&gt;
    return tmp;&lt;br /&gt;
  }&lt;br /&gt;
  public static &amp;lt;T&amp;gt; Set&amp;lt;T&amp;gt; symDifference(Set&amp;lt;T&amp;gt; setA, Set&amp;lt;T&amp;gt; setB) {&lt;br /&gt;
    Set&amp;lt;T&amp;gt; tmpA;&lt;br /&gt;
    Set&amp;lt;T&amp;gt; tmpB;&lt;br /&gt;
    tmpA = union(setA, setB);&lt;br /&gt;
    tmpB = intersection(setA, setB);&lt;br /&gt;
    return difference(tmpA, tmpB);&lt;br /&gt;
  }&lt;br /&gt;
  public static &amp;lt;T&amp;gt; boolean isSubset(Set&amp;lt;T&amp;gt; setA, Set&amp;lt;T&amp;gt; setB) {&lt;br /&gt;
    return setB.containsAll(setA);&lt;br /&gt;
  }&lt;br /&gt;
  public static &amp;lt;T&amp;gt; boolean isSuperset(Set&amp;lt;T&amp;gt; setA, Set&amp;lt;T&amp;gt; setB) {&lt;br /&gt;
    return setA.containsAll(setB);&lt;br /&gt;
  }&lt;br /&gt;
  public static void main(String args[]) {&lt;br /&gt;
    TreeSet&amp;lt;Character&amp;gt; set1 = new TreeSet&amp;lt;Character&amp;gt;();&lt;br /&gt;
    TreeSet&amp;lt;Character&amp;gt; set2 = new TreeSet&amp;lt;Character&amp;gt;();&lt;br /&gt;
    set1.add(&amp;quot;A&amp;quot;);&lt;br /&gt;
    set1.add(&amp;quot;B&amp;quot;);&lt;br /&gt;
    set1.add(&amp;quot;C&amp;quot;);&lt;br /&gt;
    set1.add(&amp;quot;D&amp;quot;);&lt;br /&gt;
    set2.add(&amp;quot;C&amp;quot;);&lt;br /&gt;
    set2.add(&amp;quot;D&amp;quot;);&lt;br /&gt;
    set2.add(&amp;quot;E&amp;quot;);&lt;br /&gt;
    set2.add(&amp;quot;F&amp;quot;);&lt;br /&gt;
    System.out.println(&amp;quot;set1: &amp;quot; + set1);&lt;br /&gt;
    System.out.println(&amp;quot;set2: &amp;quot; + set2);&lt;br /&gt;
    System.out.println(&amp;quot;Union: &amp;quot; + union(set1, set2));&lt;br /&gt;
    System.out.println(&amp;quot;Intersection: &amp;quot; + intersection(set1, set2));&lt;br /&gt;
    System.out.println(&amp;quot;Difference (set1 - set2): &amp;quot; + difference(set1, set2));&lt;br /&gt;
    System.out.println(&amp;quot;Symmetric Difference: &amp;quot; + symDifference(set1, set2));&lt;br /&gt;
    TreeSet&amp;lt;Character&amp;gt; set3 = new TreeSet&amp;lt;Character&amp;gt;(set1);&lt;br /&gt;
    set3.remove(&amp;quot;D&amp;quot;);&lt;br /&gt;
    System.out.println(&amp;quot;set3: &amp;quot; + set3);&lt;br /&gt;
    System.out.println(&amp;quot;Is set1 a subset of set2? &amp;quot; + isSubset(set1, set3));&lt;br /&gt;
    System.out.println(&amp;quot;Is set1 a superset of set2? &amp;quot; + isSuperset(set1, set3));&lt;br /&gt;
    System.out.println(&amp;quot;Is set3 a subset of set1? &amp;quot; + isSubset(set3, set1));&lt;br /&gt;
    System.out.println(&amp;quot;Is set3 a superset of set1? &amp;quot; + isSuperset(set3, set1));&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
   &lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Set subtraction ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
     &lt;br /&gt;
import java.util.HashSet;&lt;br /&gt;
import java.util.Set;&lt;br /&gt;
public class FindDupsAndUnique {&lt;br /&gt;
  public static void main(String args[]) {&lt;br /&gt;
    Set uniques = new HashSet();&lt;br /&gt;
    Set dups = new HashSet();&lt;br /&gt;
    String[] values = new String[] { &amp;quot;java&amp;quot;, &amp;quot;java2&amp;quot;, &amp;quot;jexp&amp;quot;, &amp;quot;javas&amp;quot;,&lt;br /&gt;
    &amp;quot;java&amp;quot; };&lt;br /&gt;
    for (int i = 0; i &amp;lt; values.length; i++)&lt;br /&gt;
      if (!uniques.add(values[i]))&lt;br /&gt;
        dups.add(values[i]);&lt;br /&gt;
    uniques.removeAll(dups); // Destructive set-difference&lt;br /&gt;
    System.out.println(&amp;quot;Unique words:    &amp;quot; + uniques);&lt;br /&gt;
    System.out.println(&amp;quot;Duplicate words: &amp;quot; + dups);&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
           &lt;br /&gt;
         &lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Set that compares object by identity rather than equality ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
// $Id: IdentitySet.java 16179 2009-03-18 11:08:10Z hardy.ferentschik $&lt;br /&gt;
/*&lt;br /&gt;
* JBoss, Home of Professional Open Source&lt;br /&gt;
* Copyright 2008, Red Hat Middleware LLC, and individual contributors&lt;br /&gt;
* by the @authors tag. See the copyright.txt in the distribution for a&lt;br /&gt;
* full listing of individual contributors.&lt;br /&gt;
*&lt;br /&gt;
* Licensed under the Apache License, Version 2.0 (the &amp;quot;License&amp;quot;);&lt;br /&gt;
* you may not use this file except in compliance with the License.&lt;br /&gt;
* You may obtain a copy of the License at&lt;br /&gt;
* http://www.apache.org/licenses/LICENSE-2.0&lt;br /&gt;
* Unless required by applicable law or agreed to in writing, software&lt;br /&gt;
* distributed under the License is distributed on an &amp;quot;AS IS&amp;quot; BASIS,&lt;br /&gt;
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.&lt;br /&gt;
* See the License for the specific language governing permissions and&lt;br /&gt;
* limitations under the License.&lt;br /&gt;
*/&lt;br /&gt;
import java.util.Collection;&lt;br /&gt;
import java.util.IdentityHashMap;&lt;br /&gt;
import java.util.Iterator;&lt;br /&gt;
import java.util.Map;&lt;br /&gt;
import java.util.Set;&lt;br /&gt;
/**&lt;br /&gt;
 * Set that compares object by identity rather than equality. Wraps around a &amp;lt;code&amp;gt;IdentityHashMap&amp;lt;/code&amp;gt;&lt;br /&gt;
 *&lt;br /&gt;
 * @author Emmanuel Bernard&lt;br /&gt;
 */&lt;br /&gt;
public class IdentitySet implements Set {&lt;br /&gt;
  private Map&amp;lt;Object, Object&amp;gt; map;&lt;br /&gt;
  private Object CONTAINS = new Object();&lt;br /&gt;
  public IdentitySet() {&lt;br /&gt;
    this( 10 );&lt;br /&gt;
  }&lt;br /&gt;
  public IdentitySet(int size) {&lt;br /&gt;
    this.map = new IdentityHashMap&amp;lt;Object, Object&amp;gt;( size );&lt;br /&gt;
  }&lt;br /&gt;
  public int size() {&lt;br /&gt;
    return map.size();&lt;br /&gt;
  }&lt;br /&gt;
  public boolean isEmpty() {&lt;br /&gt;
    return map.isEmpty();&lt;br /&gt;
  }&lt;br /&gt;
  public boolean contains(Object o) {&lt;br /&gt;
    return map.containsKey( o );&lt;br /&gt;
  }&lt;br /&gt;
  public Iterator iterator() {&lt;br /&gt;
    return map.keySet().iterator();&lt;br /&gt;
  }&lt;br /&gt;
  public Object[] toArray() {&lt;br /&gt;
    return map.keySet().toArray();&lt;br /&gt;
  }&lt;br /&gt;
  public boolean add(Object o) {&lt;br /&gt;
    return map.put( o, CONTAINS ) == null;&lt;br /&gt;
  }&lt;br /&gt;
  public boolean remove(Object o) {&lt;br /&gt;
    return map.remove( o ) == CONTAINS;&lt;br /&gt;
  }&lt;br /&gt;
  public boolean addAll(Collection c) {&lt;br /&gt;
    boolean doThing = false;&lt;br /&gt;
    for ( Object o : c ) {&lt;br /&gt;
      doThing = doThing || add( o );&lt;br /&gt;
    }&lt;br /&gt;
    return doThing;&lt;br /&gt;
  }&lt;br /&gt;
  public void clear() {&lt;br /&gt;
    map.clear();&lt;br /&gt;
  }&lt;br /&gt;
  public boolean removeAll(Collection c) {&lt;br /&gt;
    boolean remove = false;&lt;br /&gt;
    for ( Object o : c ) {&lt;br /&gt;
      remove = remove || remove( o );&lt;br /&gt;
    }&lt;br /&gt;
    return remove;&lt;br /&gt;
  }&lt;br /&gt;
  public boolean retainAll(Collection c) {&lt;br /&gt;
    throw new UnsupportedOperationException();&lt;br /&gt;
  }&lt;br /&gt;
  public boolean containsAll(Collection c) {&lt;br /&gt;
    for ( Object o : c ) {&lt;br /&gt;
      if ( !contains( o ) ) {&lt;br /&gt;
        return false;&lt;br /&gt;
      }&lt;br /&gt;
    }&lt;br /&gt;
    return true;&lt;br /&gt;
  }&lt;br /&gt;
  public Object[] toArray(Object[] a) {&lt;br /&gt;
    return map.keySet().toArray( a );&lt;br /&gt;
  }&lt;br /&gt;
  @Override&lt;br /&gt;
  public String toString() {&lt;br /&gt;
    return &amp;quot;IdentitySet{&amp;quot; +&lt;br /&gt;
        &amp;quot;map=&amp;quot; + map +&lt;br /&gt;
        &amp;quot;}&amp;quot;;&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
   &lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Set union and intersection ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
/* *****************************************************************************&lt;br /&gt;
 * SetUils.java&lt;br /&gt;
 * ****************************************************************************/&lt;br /&gt;
/* J_LZ_COPYRIGHT_BEGIN *******************************************************&lt;br /&gt;
* Copyright 2001-2004 Laszlo Systems, Inc.  All Rights Reserved.              *&lt;br /&gt;
* Use is subject to license terms.                                            *&lt;br /&gt;
* J_LZ_COPYRIGHT_END *********************************************************/&lt;br /&gt;
import java.util.*;&lt;br /&gt;
/**&lt;br /&gt;
 * A utility class containing set utility functions.&lt;br /&gt;
 *&lt;br /&gt;
 * @author Oliver Steele&lt;br /&gt;
 */&lt;br /&gt;
public abstract class SetUtils {&lt;br /&gt;
    public static boolean containsAny(Set a, Set b) {&lt;br /&gt;
        for (Iterator iter = b.iterator(); iter.hasNext(); ) {&lt;br /&gt;
            if (a.contains(iter.next())) {&lt;br /&gt;
                return true;&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
        return false;&lt;br /&gt;
    }&lt;br /&gt;
    public static Set intersection(Set a, Set b) {&lt;br /&gt;
        Set c = new HashSet();&lt;br /&gt;
        for (Iterator iter = b.iterator(); iter.hasNext(); ) {&lt;br /&gt;
            Object e = iter.next();&lt;br /&gt;
            if (a.contains(e)) {&lt;br /&gt;
                c.add(e);&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
        return c;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
   &lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Set with values iterated in insertion order. ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
/*&lt;br /&gt;
Copyright (c) 2007, Dennis M. Sosnoski&lt;br /&gt;
All rights reserved.&lt;br /&gt;
Redistribution and use in source and binary forms, with or without modification,&lt;br /&gt;
are permitted provided that the following conditions are met:&lt;br /&gt;
 * Redistributions of source code must retain the above copyright notice, this&lt;br /&gt;
   list of conditions and the following disclaimer.&lt;br /&gt;
 * Redistributions in binary form must reproduce the above copyright notice,&lt;br /&gt;
   this list of conditions and the following disclaimer in the documentation&lt;br /&gt;
   and/or other materials provided with the distribution.&lt;br /&gt;
 * Neither the name of JiBX nor the names of its contributors may be used&lt;br /&gt;
   to endorse or promote products derived from this software without specific&lt;br /&gt;
   prior written permission.&lt;br /&gt;
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS &amp;quot;AS IS&amp;quot; AND&lt;br /&gt;
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED&lt;br /&gt;
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE&lt;br /&gt;
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR&lt;br /&gt;
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES&lt;br /&gt;
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;&lt;br /&gt;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON&lt;br /&gt;
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT&lt;br /&gt;
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS&lt;br /&gt;
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.&lt;br /&gt;
*/&lt;br /&gt;
&lt;br /&gt;
import java.util.ArrayList;&lt;br /&gt;
import java.util.Collection;&lt;br /&gt;
import java.util.HashSet;&lt;br /&gt;
import java.util.Iterator;&lt;br /&gt;
import java.util.Set;&lt;br /&gt;
/**&lt;br /&gt;
 * Set with values iterated in insertion order. This is similar to the Java 1.4&lt;br /&gt;
 * java.util.LinkedHashSet class, but compatible with earlier JVM versions. This&lt;br /&gt;
 * implementation is for insert-only sets.&lt;br /&gt;
 */&lt;br /&gt;
public class InsertionOrderedSet implements Set&lt;br /&gt;
{&lt;br /&gt;
    private final Set m_baseMap;&lt;br /&gt;
    private final ArrayList m_insertList;&lt;br /&gt;
    &lt;br /&gt;
    public InsertionOrderedSet() {&lt;br /&gt;
        m_baseMap = new HashSet();&lt;br /&gt;
        m_insertList = new ArrayList();&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    /* (non-Javadoc)&lt;br /&gt;
     * @see java.util.Map#clear()&lt;br /&gt;
     */&lt;br /&gt;
    public void clear() {&lt;br /&gt;
        m_baseMap.clear();&lt;br /&gt;
        m_insertList.clear();&lt;br /&gt;
    }&lt;br /&gt;
    /* (non-Javadoc)&lt;br /&gt;
     * @see java.util.Set#isEmpty()&lt;br /&gt;
     */&lt;br /&gt;
    public boolean isEmpty() {&lt;br /&gt;
        return m_baseMap.isEmpty();&lt;br /&gt;
    }&lt;br /&gt;
    /* (non-Javadoc)&lt;br /&gt;
     * @see java.util.Set#size()&lt;br /&gt;
     */&lt;br /&gt;
    public int size() {&lt;br /&gt;
        return m_baseMap.size();&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    /* (non-Javadoc)&lt;br /&gt;
     * @see java.util.Set#add(java.lang.Object)&lt;br /&gt;
     */&lt;br /&gt;
    public boolean add(Object o) {&lt;br /&gt;
        if (m_baseMap.contains(o)) {&lt;br /&gt;
            return false;&lt;br /&gt;
        } else {&lt;br /&gt;
            m_baseMap.add(o);&lt;br /&gt;
            m_insertList.add(o);&lt;br /&gt;
            return true;&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
    /* (non-Javadoc)&lt;br /&gt;
     * @see java.util.Set#addAll(java.util.Collection)&lt;br /&gt;
     */&lt;br /&gt;
    public boolean addAll(Collection c) {&lt;br /&gt;
        boolean changed = false;&lt;br /&gt;
        for (Iterator iter = c.iterator(); iter.hasNext();) {&lt;br /&gt;
            Object item = (Object)iter.next();&lt;br /&gt;
            if (add(item)) {&lt;br /&gt;
                changed = true;&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
        return changed;&lt;br /&gt;
    }&lt;br /&gt;
    /* (non-Javadoc)&lt;br /&gt;
     * @see java.util.Set#contains(java.lang.Object)&lt;br /&gt;
     */&lt;br /&gt;
    public boolean contains(Object o) {&lt;br /&gt;
        return m_baseMap.contains(o);&lt;br /&gt;
    }&lt;br /&gt;
    /* (non-Javadoc)&lt;br /&gt;
     * @see java.util.Set#containsAll(java.util.Collection)&lt;br /&gt;
     */&lt;br /&gt;
    public boolean containsAll(Collection c) {&lt;br /&gt;
        return m_baseMap.containsAll(c);&lt;br /&gt;
    }&lt;br /&gt;
    /* (non-Javadoc)&lt;br /&gt;
     * @see java.util.Set#iterator()&lt;br /&gt;
     */&lt;br /&gt;
    public Iterator iterator() {&lt;br /&gt;
        return m_insertList.iterator();&lt;br /&gt;
    }&lt;br /&gt;
    /* (non-Javadoc)&lt;br /&gt;
     * @see java.util.Set#remove(java.lang.Object)&lt;br /&gt;
     */&lt;br /&gt;
    public boolean remove(Object o) {&lt;br /&gt;
        throw new UnsupportedOperationException(&amp;quot;add-only set&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
    /* (non-Javadoc)&lt;br /&gt;
     * @see java.util.Set#removeAll(java.util.Collection)&lt;br /&gt;
     */&lt;br /&gt;
    public boolean removeAll(Collection c) {&lt;br /&gt;
        throw new UnsupportedOperationException(&amp;quot;add-only set&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
    /* (non-Javadoc)&lt;br /&gt;
     * @see java.util.Set#retainAll(java.util.Collection)&lt;br /&gt;
     */&lt;br /&gt;
    public boolean retainAll(Collection c) {&lt;br /&gt;
        throw new UnsupportedOperationException(&amp;quot;add-only set&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
    /* (non-Javadoc)&lt;br /&gt;
     * @see java.util.Set#toArray()&lt;br /&gt;
     */&lt;br /&gt;
    public Object[] toArray() {&lt;br /&gt;
        return m_insertList.toArray();&lt;br /&gt;
    }&lt;br /&gt;
    /* (non-Javadoc)&lt;br /&gt;
     * @see java.util.Set#toArray(T[])&lt;br /&gt;
     */&lt;br /&gt;
    public Object[] toArray(Object[] a) {&lt;br /&gt;
        return m_insertList.toArray(a);&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    /**&lt;br /&gt;
     * Convenience method to add every item in an array.&lt;br /&gt;
     *&lt;br /&gt;
     * @param objs&lt;br /&gt;
     */&lt;br /&gt;
    public void addAll(Object[] objs) {&lt;br /&gt;
        for (int i = 0; i &amp;lt; objs.length; i++) {&lt;br /&gt;
            add(objs[i]);&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
    /**&lt;br /&gt;
     * Get list of values in order added. The returned list is live, and will&lt;br /&gt;
     * grow as new items are added to the set.&lt;br /&gt;
     *&lt;br /&gt;
     * @return list&lt;br /&gt;
     */&lt;br /&gt;
    public ArrayList asList() {&lt;br /&gt;
        return m_insertList;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
   &lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Show the union and intersection of two sets ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
     &lt;br /&gt;
/*&lt;br /&gt;
 * Copyright (c) Ian F. Darwin, http://www.darwinsys.ru/, 1996-2002.&lt;br /&gt;
 * All rights reserved. Software written by Ian F. Darwin and others.&lt;br /&gt;
 * $Id: LICENSE,v 1.8 2004/02/09 03:33:38 ian Exp $&lt;br /&gt;
 *&lt;br /&gt;
 * Redistribution and use in source and binary forms, with or without&lt;br /&gt;
 * modification, are permitted provided that the following conditions&lt;br /&gt;
 * are met:&lt;br /&gt;
 * 1. Redistributions of source code must retain the above copyright&lt;br /&gt;
 *    notice, this list of conditions and the following disclaimer.&lt;br /&gt;
 * 2. Redistributions in binary form must reproduce the above copyright&lt;br /&gt;
 *    notice, this list of conditions and the following disclaimer in the&lt;br /&gt;
 *    documentation and/or other materials provided with the distribution.&lt;br /&gt;
 *&lt;br /&gt;
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS&amp;quot;&amp;quot;&lt;br /&gt;
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED&lt;br /&gt;
 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR&lt;br /&gt;
 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS&lt;br /&gt;
 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR&lt;br /&gt;
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF&lt;br /&gt;
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS&lt;br /&gt;
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN&lt;br /&gt;
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)&lt;br /&gt;
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE&lt;br /&gt;
 * POSSIBILITY OF SUCH DAMAGE.&lt;br /&gt;
 * &lt;br /&gt;
 * Java, the Duke mascot, and all variants of Sun&amp;quot;s Java &amp;quot;steaming coffee&lt;br /&gt;
 * cup&amp;quot; logo are trademarks of Sun Microsystems. Sun&amp;quot;s, and James Gosling&amp;quot;s,&lt;br /&gt;
 * pioneering role in inventing and promulgating (and standardizing) the Java &lt;br /&gt;
 * language and environment is gratefully acknowledged.&lt;br /&gt;
 * &lt;br /&gt;
 * The pioneering role of Dennis Ritchie and Bjarne Stroustrup, of AT&amp;amp;T, for&lt;br /&gt;
 * inventing predecessor languages C and C++ is also gratefully acknowledged.&lt;br /&gt;
 */&lt;br /&gt;
&lt;br /&gt;
import java.util.*;&lt;br /&gt;
/** Show the union and instersection of two sets. */&lt;br /&gt;
public class SetStuff {&lt;br /&gt;
  public static void main(String[] args) {&lt;br /&gt;
    // Create two sets.&lt;br /&gt;
    Set s1 = new HashSet();&lt;br /&gt;
    s1.add(&amp;quot;Ian Darwin&amp;quot;);&lt;br /&gt;
    s1.add(&amp;quot;Bill Dooley&amp;quot;);&lt;br /&gt;
    s1.add(&amp;quot;Jesse James&amp;quot;);&lt;br /&gt;
    Set s2 = new HashSet();&lt;br /&gt;
    s2.add(&amp;quot;Ian Darwin&amp;quot;);&lt;br /&gt;
    s2.add(&amp;quot;Doolin&amp;quot; Dalton&amp;quot;);&lt;br /&gt;
    Set union = new TreeSet(s1);&lt;br /&gt;
    union.addAll(s2);    // now contains the union&lt;br /&gt;
    print(&amp;quot;union&amp;quot;, union);&lt;br /&gt;
    Set intersect = new TreeSet(s1);&lt;br /&gt;
    intersect.retainAll(s2);&lt;br /&gt;
    print(&amp;quot;intersection&amp;quot;, intersect);&lt;br /&gt;
  }&lt;br /&gt;
  protected static void print(String label, Collection c) {&lt;br /&gt;
    System.out.println(&amp;quot;--------------&amp;quot; + label + &amp;quot;--------------&amp;quot;);&lt;br /&gt;
    Iterator it = c.iterator();&lt;br /&gt;
    while (it.hasNext()) {&lt;br /&gt;
      System.out.println(it.next());&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
           &lt;br /&gt;
         &lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Small sets whose elements are known to be unique by construction ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
/* &lt;br /&gt;
 * JGraphT : a free Java graph-theory library&lt;br /&gt;
 * &lt;br /&gt;
 *&lt;br /&gt;
 * Project Info:  http://jgrapht.sourceforge.net/&lt;br /&gt;
 * Project Creator:  Barak Naveh (http://sourceforge.net/users/barak_naveh)&lt;br /&gt;
 *&lt;br /&gt;
 * (C) Copyright 2003-2007, by Barak Naveh and Contributors.&lt;br /&gt;
 *&lt;br /&gt;
 * This library is free software; you can redistribute it and/or modify it&lt;br /&gt;
 * under the terms of the GNU Lesser General Public License as published by&lt;br /&gt;
 * the Free Software Foundation; either version 2.1 of the License, or&lt;br /&gt;
 * (at your option) any later version.&lt;br /&gt;
 *&lt;br /&gt;
 * This library is distributed in the hope that it will be useful, but&lt;br /&gt;
 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY&lt;br /&gt;
 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public&lt;br /&gt;
 * License for more details.&lt;br /&gt;
 *&lt;br /&gt;
 * You should have received a copy of the GNU Lesser General Public License&lt;br /&gt;
 * along with this library; if not, write to the Free Software Foundation,&lt;br /&gt;
 * Inc.,&lt;br /&gt;
 * 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.&lt;br /&gt;
 */&lt;br /&gt;
/* -----------------&lt;br /&gt;
 * ArrayUnenforcedSet.java&lt;br /&gt;
 * -----------------&lt;br /&gt;
 * (C) Copyright 2006-2007, by John V. Sichi and Contributors.&lt;br /&gt;
 *&lt;br /&gt;
 * Original Author:  John V. Sichi&lt;br /&gt;
 * Contributor(s):   -&lt;br /&gt;
 *&lt;br /&gt;
 * $Id: ArrayUnenforcedSet.java 568 2007-09-30 00:12:18Z perfecthash $&lt;br /&gt;
 *&lt;br /&gt;
 * Changes&lt;br /&gt;
 * -------&lt;br /&gt;
 * 07-May-2006 : Initial version (JVS);&lt;br /&gt;
 */&lt;br /&gt;
import java.util.*;&lt;br /&gt;
&lt;br /&gt;
/**&lt;br /&gt;
 * Helper for efficiently representing small sets whose elements are known to be&lt;br /&gt;
 * unique by construction, implying we don&amp;quot;t need to enforce the uniqueness&lt;br /&gt;
 * property in the data structure itself. Use with caution.&lt;br /&gt;
 *&lt;br /&gt;
 * &amp;lt;p&amp;gt;Note that for equals/hashCode, the class implements the Set behavior&lt;br /&gt;
 * (unordered), not the list behavior (ordered); the fact that it subclasses&lt;br /&gt;
 * ArrayList should be considered an implementation detail.&lt;br /&gt;
 *&lt;br /&gt;
 * @author John V. Sichi&lt;br /&gt;
 */&lt;br /&gt;
public class ArrayUnenforcedSet&amp;lt;E&amp;gt;&lt;br /&gt;
    extends ArrayList&amp;lt;E&amp;gt;&lt;br /&gt;
    implements Set&amp;lt;E&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    //~ Static fields/initializers ---------------------------------------------&lt;br /&gt;
    private static final long serialVersionUID = -7413250161201811238L;&lt;br /&gt;
    //~ Constructors -----------------------------------------------------------&lt;br /&gt;
    public ArrayUnenforcedSet()&lt;br /&gt;
    {&lt;br /&gt;
        super();&lt;br /&gt;
    }&lt;br /&gt;
    public ArrayUnenforcedSet(Collection&amp;lt;? extends E&amp;gt; c)&lt;br /&gt;
    {&lt;br /&gt;
        super(c);&lt;br /&gt;
    }&lt;br /&gt;
    public ArrayUnenforcedSet(int n)&lt;br /&gt;
    {&lt;br /&gt;
        super(n);&lt;br /&gt;
    }&lt;br /&gt;
    //~ Methods ----------------------------------------------------------------&lt;br /&gt;
    public boolean equals(Object o)&lt;br /&gt;
    {&lt;br /&gt;
        return new SetForEquality().equals(o);&lt;br /&gt;
    }&lt;br /&gt;
    public int hashCode()&lt;br /&gt;
    {&lt;br /&gt;
        return new SetForEquality().hashCode();&lt;br /&gt;
    }&lt;br /&gt;
    //~ Inner Classes ----------------------------------------------------------&lt;br /&gt;
    /**&lt;br /&gt;
     * Multiple inheritance helper.&lt;br /&gt;
     */&lt;br /&gt;
    private class SetForEquality&lt;br /&gt;
        extends AbstractSet&amp;lt;E&amp;gt;&lt;br /&gt;
    {&lt;br /&gt;
        public Iterator&amp;lt;E&amp;gt; iterator()&lt;br /&gt;
        {&lt;br /&gt;
            return ArrayUnenforcedSet.this.iterator();&lt;br /&gt;
        }&lt;br /&gt;
        public int size()&lt;br /&gt;
        {&lt;br /&gt;
            return ArrayUnenforcedSet.this.size();&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
// End ArrayUnenforcedSet.java&lt;br /&gt;
   &lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Sync Test  ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
     &lt;br /&gt;
&lt;br /&gt;
import java.util.Collections;&lt;br /&gt;
import java.util.HashMap;&lt;br /&gt;
import java.util.HashSet;&lt;br /&gt;
import java.util.Iterator;&lt;br /&gt;
import java.util.Map;&lt;br /&gt;
import java.util.Set;&lt;br /&gt;
public class SyncTest {&lt;br /&gt;
  public static void main(String args[]) {&lt;br /&gt;
    Set simpsons = new HashSet();&lt;br /&gt;
    simpsons.add(&amp;quot;Bart&amp;quot;);&lt;br /&gt;
    simpsons.add(&amp;quot;Hugo&amp;quot;);&lt;br /&gt;
    simpsons.add(&amp;quot;Lisa&amp;quot;);&lt;br /&gt;
    simpsons.add(&amp;quot;Marge&amp;quot;);&lt;br /&gt;
    simpsons.add(&amp;quot;Homer&amp;quot;);&lt;br /&gt;
    simpsons.add(&amp;quot;Maggie&amp;quot;);&lt;br /&gt;
    simpsons.add(&amp;quot;Roy&amp;quot;);&lt;br /&gt;
    simpsons = Collections.synchronizedSet(simpsons);&lt;br /&gt;
    synchronized (simpsons) {&lt;br /&gt;
      Iterator iter = simpsons.iterator();&lt;br /&gt;
      while (iter.hasNext()) {&lt;br /&gt;
        System.out.println(iter.next());&lt;br /&gt;
      }&lt;br /&gt;
    }&lt;br /&gt;
    Map map = Collections.synchronizedMap(new HashMap(89));&lt;br /&gt;
    Set set = map.entrySet();&lt;br /&gt;
    synchronized (map) {&lt;br /&gt;
      Iterator iter = set.iterator();&lt;br /&gt;
      while (iter.hasNext()) {&lt;br /&gt;
        System.out.println(iter.next());&lt;br /&gt;
      }&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
           &lt;br /&gt;
         &lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Tail  ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
     &lt;br /&gt;
import java.util.Arrays;&lt;br /&gt;
import java.util.SortedSet;&lt;br /&gt;
import java.util.TreeSet;&lt;br /&gt;
public class Tail {&lt;br /&gt;
  public static void main(String args[]) throws Exception {&lt;br /&gt;
    String elements[] = { &amp;quot;Irish Setter&amp;quot;, &amp;quot;Poodle&amp;quot;, &amp;quot;English Setter&amp;quot;,&lt;br /&gt;
        &amp;quot;Gordon Setter&amp;quot;, &amp;quot;Pug&amp;quot; };&lt;br /&gt;
    SortedSet set = new TreeSet(Arrays.asList(elements));&lt;br /&gt;
    System.out.println(set.tailSet(&amp;quot;Irish Setter&amp;quot;));&lt;br /&gt;
    System.out.println(set.headSet(&amp;quot;Irish Setter&amp;quot;));&lt;br /&gt;
    System.out.println(set.headSet(&amp;quot;Irish Setter\0&amp;quot;));&lt;br /&gt;
    System.out.println(set.tailSet(&amp;quot;Irish Setter\0&amp;quot;));&lt;br /&gt;
    System.out.println(set.subSet(&amp;quot;Irish Setter&amp;quot;, &amp;quot;Poodle\0&amp;quot;));&lt;br /&gt;
    System.out.println(set.subSet(&amp;quot;Irish Setter&amp;quot;, &amp;quot;Irish Setter\0&amp;quot;));&lt;br /&gt;
    System.out.println(set.subSet(&amp;quot;Irish Setter&amp;quot;, &amp;quot;Irish Setter&amp;quot;));&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
           &lt;br /&gt;
         &lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Things you can do with Sets ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
     &lt;br /&gt;
// : c11:Set1.java&lt;br /&gt;
// Things you can do with Sets.&lt;br /&gt;
// From &amp;quot;Thinking in Java, 3rd ed.&amp;quot; (c) Bruce Eckel 2002&lt;br /&gt;
// www.BruceEckel.ru. See copyright notice in CopyRight.txt.&lt;br /&gt;
import java.util.Arrays;&lt;br /&gt;
import java.util.HashSet;&lt;br /&gt;
import java.util.LinkedHashSet;&lt;br /&gt;
import java.util.Set;&lt;br /&gt;
import java.util.TreeSet;&lt;br /&gt;
public class Set1 {&lt;br /&gt;
  static void fill(Set s) {&lt;br /&gt;
    s.addAll(Arrays.asList(&amp;quot;one two three four five six seven&amp;quot;.split(&amp;quot; &amp;quot;)));&lt;br /&gt;
  }&lt;br /&gt;
  public static void test(Set s) {&lt;br /&gt;
    // Strip qualifiers from class name:&lt;br /&gt;
    System.out.println(s.getClass().getName().replaceAll(&amp;quot;\\w+\\.&amp;quot;, &amp;quot;&amp;quot;));&lt;br /&gt;
    fill(s);&lt;br /&gt;
    fill(s);&lt;br /&gt;
    fill(s);&lt;br /&gt;
    System.out.println(s); // No duplicates!&lt;br /&gt;
    // Add another set to this one:&lt;br /&gt;
    s.addAll(s);&lt;br /&gt;
    s.add(&amp;quot;one&amp;quot;);&lt;br /&gt;
    s.add(&amp;quot;one&amp;quot;);&lt;br /&gt;
    s.add(&amp;quot;one&amp;quot;);&lt;br /&gt;
    System.out.println(s);&lt;br /&gt;
    // Look something up:&lt;br /&gt;
    System.out.println(&amp;quot;s.contains(\&amp;quot;one\&amp;quot;): &amp;quot; + s.contains(&amp;quot;one&amp;quot;));&lt;br /&gt;
  }&lt;br /&gt;
  public static void main(String[] args) {&lt;br /&gt;
    test(new HashSet());&lt;br /&gt;
    test(new TreeSet());&lt;br /&gt;
    test(new LinkedHashSet());&lt;br /&gt;
  }&lt;br /&gt;
} ///:~&lt;br /&gt;
&lt;br /&gt;
           &lt;br /&gt;
         &lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== TreeSet Demo ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
     &lt;br /&gt;
/*&lt;br /&gt;
 * Copyright (c) Ian F. Darwin, http://www.darwinsys.ru/, 1996-2002.&lt;br /&gt;
 * All rights reserved. Software written by Ian F. Darwin and others.&lt;br /&gt;
 * $Id: LICENSE,v 1.8 2004/02/09 03:33:38 ian Exp $&lt;br /&gt;
 *&lt;br /&gt;
 * Redistribution and use in source and binary forms, with or without&lt;br /&gt;
 * modification, are permitted provided that the following conditions&lt;br /&gt;
 * are met:&lt;br /&gt;
 * 1. Redistributions of source code must retain the above copyright&lt;br /&gt;
 *    notice, this list of conditions and the following disclaimer.&lt;br /&gt;
 * 2. Redistributions in binary form must reproduce the above copyright&lt;br /&gt;
 *    notice, this list of conditions and the following disclaimer in the&lt;br /&gt;
 *    documentation and/or other materials provided with the distribution.&lt;br /&gt;
 *&lt;br /&gt;
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS&amp;quot;&amp;quot;&lt;br /&gt;
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED&lt;br /&gt;
 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR&lt;br /&gt;
 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS&lt;br /&gt;
 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR&lt;br /&gt;
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF&lt;br /&gt;
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS&lt;br /&gt;
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN&lt;br /&gt;
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)&lt;br /&gt;
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE&lt;br /&gt;
 * POSSIBILITY OF SUCH DAMAGE.&lt;br /&gt;
 * &lt;br /&gt;
 * Java, the Duke mascot, and all variants of Sun&amp;quot;s Java &amp;quot;steaming coffee&lt;br /&gt;
 * cup&amp;quot; logo are trademarks of Sun Microsystems. Sun&amp;quot;s, and James Gosling&amp;quot;s,&lt;br /&gt;
 * pioneering role in inventing and promulgating (and standardizing) the Java &lt;br /&gt;
 * language and environment is gratefully acknowledged.&lt;br /&gt;
 * &lt;br /&gt;
 * The pioneering role of Dennis Ritchie and Bjarne Stroustrup, of AT&amp;amp;T, for&lt;br /&gt;
 * inventing predecessor languages C and C++ is also gratefully acknowledged.&lt;br /&gt;
 */&lt;br /&gt;
import java.util.TreeSet;&lt;br /&gt;
/**&lt;br /&gt;
 * TreeSet Demo.&lt;br /&gt;
 * &lt;br /&gt;
 * @author Ian F. Darwin, http://www.darwinsys.ru/&lt;br /&gt;
 * @version $Id: TreeSetDemo.java,v 1.3 2004/02/09 03:34:04 ian Exp $&lt;br /&gt;
 */&lt;br /&gt;
public class TreeSetDemo {&lt;br /&gt;
  public static void main(String[] argv) {&lt;br /&gt;
    //+&lt;br /&gt;
    /*&lt;br /&gt;
     * A TreeSet keeps objects in sorted order. We use a Comparator&lt;br /&gt;
     * published by String for case-insensitive sorting order.&lt;br /&gt;
     */&lt;br /&gt;
    TreeSet tm = new TreeSet(String.CASE_INSENSITIVE_ORDER);&lt;br /&gt;
    tm.add(&amp;quot;Gosling&amp;quot;);&lt;br /&gt;
    tm.add(&amp;quot;da Vinci&amp;quot;);&lt;br /&gt;
    tm.add(&amp;quot;van Gogh&amp;quot;);&lt;br /&gt;
    tm.add(&amp;quot;Java To Go&amp;quot;);&lt;br /&gt;
    tm.add(&amp;quot;Vanguard&amp;quot;);&lt;br /&gt;
    tm.add(&amp;quot;Darwin&amp;quot;);&lt;br /&gt;
    tm.add(&amp;quot;Darwin&amp;quot;); // TreeSet is Set, ignores duplicates.&lt;br /&gt;
    // Since it is sorted we can ask for various subsets&lt;br /&gt;
    System.out.println(&amp;quot;Lowest (alphabetically) is &amp;quot; + tm.first());&lt;br /&gt;
    // Print how many elements are greater than &amp;quot;k&amp;quot;&lt;br /&gt;
    System.out.println(tm.tailSet(&amp;quot;k&amp;quot;).toArray().length&lt;br /&gt;
        + &amp;quot; elements higher than \&amp;quot;k\&amp;quot;&amp;quot;);&lt;br /&gt;
    // Print the whole list in sorted order&lt;br /&gt;
    System.out.println(&amp;quot;Sorted list:&amp;quot;);&lt;br /&gt;
    java.util.Iterator t = tm.iterator();&lt;br /&gt;
    while (t.hasNext())&lt;br /&gt;
      System.out.println(t.next());&lt;br /&gt;
    //-&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
           &lt;br /&gt;
         &lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Use set ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
     &lt;br /&gt;
import java.util.HashSet;&lt;br /&gt;
import java.util.Set;&lt;br /&gt;
public class FindDups {&lt;br /&gt;
  public static void main(String args[]) {&lt;br /&gt;
    Set s = new HashSet();&lt;br /&gt;
    String[] values = new String[] { &amp;quot;java&amp;quot;, &amp;quot;java2&amp;quot;, &amp;quot;jexp&amp;quot;, &amp;quot;javas&amp;quot;,&lt;br /&gt;
        &amp;quot;java&amp;quot; };&lt;br /&gt;
    for (int i = 0; i &amp;lt; values.length; i++)&lt;br /&gt;
      if (!s.add(values[i]))&lt;br /&gt;
        System.out.println(&amp;quot;Duplicate detected: &amp;quot; + values[i]);&lt;br /&gt;
    System.out.println(s.size() + &amp;quot; distinct words detected: &amp;quot; + s);&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
           &lt;br /&gt;
         &lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== What you can do with a TreeSet ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
     &lt;br /&gt;
// : c11:SortedSetDemo.java&lt;br /&gt;
// What you can do with a TreeSet.&lt;br /&gt;
// From &amp;quot;Thinking in Java, 3rd ed.&amp;quot; (c) Bruce Eckel 2002&lt;br /&gt;
// www.BruceEckel.ru. See copyright notice in CopyRight.txt.&lt;br /&gt;
import java.util.Arrays;&lt;br /&gt;
import java.util.Iterator;&lt;br /&gt;
import java.util.SortedSet;&lt;br /&gt;
import java.util.TreeSet;&lt;br /&gt;
public class SortedSetDemo {&lt;br /&gt;
  public static void main(String[] args) {&lt;br /&gt;
    SortedSet sortedSet = new TreeSet(Arrays&lt;br /&gt;
        .asList(&amp;quot;one two three four five six seven eight&amp;quot;.split(&amp;quot; &amp;quot;)));&lt;br /&gt;
    System.out.println(sortedSet);&lt;br /&gt;
    Object low = sortedSet.first(), high = sortedSet.last();&lt;br /&gt;
    System.out.println(low);&lt;br /&gt;
    System.out.println(high);&lt;br /&gt;
    Iterator it = sortedSet.iterator();&lt;br /&gt;
    for (int i = 0; i &amp;lt;= 6; i++) {&lt;br /&gt;
      if (i == 3)&lt;br /&gt;
        low = it.next();&lt;br /&gt;
      if (i == 6)&lt;br /&gt;
        high = it.next();&lt;br /&gt;
      else&lt;br /&gt;
        it.next();&lt;br /&gt;
    }&lt;br /&gt;
    System.out.println(low);&lt;br /&gt;
    System.out.println(high);&lt;br /&gt;
    System.out.println(sortedSet.subSet(low, high));&lt;br /&gt;
    System.out.println(sortedSet.headSet(high));&lt;br /&gt;
    System.out.println(sortedSet.tailSet(low));&lt;br /&gt;
  }&lt;br /&gt;
} ///:~&lt;br /&gt;
&lt;br /&gt;
           &lt;br /&gt;
         &lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Working with HashSet and TreeSet ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
     &lt;br /&gt;
import java.util.HashSet;&lt;br /&gt;
import java.util.Iterator;&lt;br /&gt;
import java.util.Set;&lt;br /&gt;
import java.util.TreeSet;&lt;br /&gt;
public class ItemSet {&lt;br /&gt;
  public static void main(String args[]) {&lt;br /&gt;
    String names[] = { &amp;quot;Item 1&amp;quot;, &amp;quot;Item 2&amp;quot;, &amp;quot;Item 3&amp;quot;};&lt;br /&gt;
    Set moons = new HashSet();&lt;br /&gt;
    int namesLen = names.length;&lt;br /&gt;
    int index;&lt;br /&gt;
    for (int i = 0; i &amp;lt; 100; i++) {&lt;br /&gt;
      index = (int) (Math.random() * namesLen);&lt;br /&gt;
      moons.add(names[index]);&lt;br /&gt;
    }&lt;br /&gt;
    Iterator it = moons.iterator();&lt;br /&gt;
    while (it.hasNext()) {&lt;br /&gt;
      System.out.println(it.next());&lt;br /&gt;
    }&lt;br /&gt;
    System.out.println(&amp;quot;---&amp;quot;);&lt;br /&gt;
    Set orderedMoons = new TreeSet(moons);&lt;br /&gt;
    it = orderedMoons.iterator();&lt;br /&gt;
    while (it.hasNext()) {&lt;br /&gt;
      System.out.println(it.next());&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
           &lt;br /&gt;
         &lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;/div&gt;</summary>
		<author><name>Admin</name></author>	</entry>

	<entry>
		<id>http://jexp.ru/index.php?title=Java/Collections_Data_Structure/Array_Convert&amp;diff=9167</id>
		<title>Java/Collections Data Structure/Array Convert</title>
		<link rel="alternate" type="text/html" href="http://jexp.ru/index.php?title=Java/Collections_Data_Structure/Array_Convert&amp;diff=9167"/>
				<updated>2010-06-01T07:27:10Z</updated>
		
		<summary type="html">&lt;p&gt;Admin: 1 версия&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Array Converter ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
/**&lt;br /&gt;
 * &lt;br /&gt;
 * LibFormula : a free Java formula library&lt;br /&gt;
 * &lt;br /&gt;
 *&lt;br /&gt;
 * Project Info:  http://reporting.pentaho.org/libformula/&lt;br /&gt;
 *&lt;br /&gt;
 * (C) Copyright 2006-2007, by Pentaho Corporation and Contributors.&lt;br /&gt;
 *&lt;br /&gt;
 * This library is free software; you can redistribute it and/or modify it under the terms&lt;br /&gt;
 * of the GNU Lesser General Public License as published by the Free Software Foundation;&lt;br /&gt;
 * either version 2.1 of the License, or (at your option) any later version.&lt;br /&gt;
 *&lt;br /&gt;
 * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;&lt;br /&gt;
 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.&lt;br /&gt;
 * See the GNU Lesser General Public License for more details.&lt;br /&gt;
 *&lt;br /&gt;
 * You should have received a copy of the GNU Lesser General Public License along with this&lt;br /&gt;
 * library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330,&lt;br /&gt;
 * Boston, MA 02111-1307, USA.&lt;br /&gt;
 *&lt;br /&gt;
 * [Java is a trademark or registered trademark of Sun Microsystems, Inc.&lt;br /&gt;
 * in the United States and other countries.]&lt;br /&gt;
 *&lt;br /&gt;
 *&lt;br /&gt;
 * ------------&lt;br /&gt;
 * $Id: ArrayConverter.java 3521 2007-10-16 10:55:14Z tmorgner $&lt;br /&gt;
 * ------------&lt;br /&gt;
 * (C) Copyright 2006-2007, by Pentaho Corporation.&lt;br /&gt;
 */&lt;br /&gt;
import java.util.ArrayList;&lt;br /&gt;
import java.util.List;&lt;br /&gt;
import java.lang.reflect.Array;&lt;br /&gt;
/**&lt;br /&gt;
 * Creation-Date: 08.10.2006, 17:37:50&lt;br /&gt;
 *&lt;br /&gt;
 * @author Thomas Morgner&lt;br /&gt;
 */&lt;br /&gt;
public class ArrayConverter&lt;br /&gt;
{&lt;br /&gt;
  private ArrayConverter()&lt;br /&gt;
  {&lt;br /&gt;
  }&lt;br /&gt;
  public static Object[] getAsList(final Object maybeArray,&lt;br /&gt;
                                   final Class arrayType)&lt;br /&gt;
  {&lt;br /&gt;
    if (maybeArray == null)&lt;br /&gt;
    {&lt;br /&gt;
      return null;&lt;br /&gt;
    }&lt;br /&gt;
    if (maybeArray.getClass().isArray() == false)&lt;br /&gt;
    {&lt;br /&gt;
      return new Object[]{maybeArray};&lt;br /&gt;
    }&lt;br /&gt;
    final ArrayList list = new ArrayList();&lt;br /&gt;
    ArrayConverter.addToList(list, maybeArray);&lt;br /&gt;
    final Object o = Array.newInstance(arrayType, list.size());&lt;br /&gt;
    return list.toArray((Object[]) o);&lt;br /&gt;
  }&lt;br /&gt;
  private static void addToList (final List list, final Object array)&lt;br /&gt;
  {&lt;br /&gt;
    final int length = Array.getLength(array);&lt;br /&gt;
    for (int i = 0; i &amp;lt; length; i++)&lt;br /&gt;
    {&lt;br /&gt;
      final Object value = Array.get(array, i);&lt;br /&gt;
      if (value == null)&lt;br /&gt;
      {&lt;br /&gt;
        list.add(null);&lt;br /&gt;
        continue;&lt;br /&gt;
      }&lt;br /&gt;
      if (value.getClass().isArray() == false)&lt;br /&gt;
      {&lt;br /&gt;
        list.add(value);&lt;br /&gt;
        continue;&lt;br /&gt;
      }&lt;br /&gt;
      ArrayConverter.addToList(list, value);&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  /**&lt;br /&gt;
   * @param maybeArray&lt;br /&gt;
   * @param dimensions&lt;br /&gt;
   * @return&lt;br /&gt;
   */&lt;br /&gt;
  public static Object[] getArray(final Object maybeArray,&lt;br /&gt;
                                  final Class arrayType,&lt;br /&gt;
                                  final int dims)&lt;br /&gt;
  {&lt;br /&gt;
    if (maybeArray == null)&lt;br /&gt;
    {&lt;br /&gt;
      return null;&lt;br /&gt;
    }&lt;br /&gt;
    if (dims &amp;lt;= 0)&lt;br /&gt;
    {&lt;br /&gt;
      return null;&lt;br /&gt;
    }&lt;br /&gt;
    if (maybeArray.getClass().isArray() == false)&lt;br /&gt;
    {&lt;br /&gt;
      Object object = maybeArray;&lt;br /&gt;
      for (int i = 0; i &amp;lt; dims; i++)&lt;br /&gt;
      {&lt;br /&gt;
        final Object[] array = (Object[]) Array.newInstance(arrayType, 1);&lt;br /&gt;
        array[0] = object;&lt;br /&gt;
        object = array;&lt;br /&gt;
      }&lt;br /&gt;
      return (Object[]) object;&lt;br /&gt;
    }&lt;br /&gt;
    if (ArrayConverter.getDimensionCount(maybeArray.getClass()) &amp;lt; dims)&lt;br /&gt;
    {&lt;br /&gt;
      return null;&lt;br /&gt;
    }&lt;br /&gt;
    return (Object[]) maybeArray;&lt;br /&gt;
  }&lt;br /&gt;
  public static int getDimensionCount(Class arrayClass)&lt;br /&gt;
  {&lt;br /&gt;
    int count = 0;&lt;br /&gt;
    while (arrayClass != null &amp;amp;&amp;amp; arrayClass.isArray())&lt;br /&gt;
    {&lt;br /&gt;
      count += 1;&lt;br /&gt;
      arrayClass = arrayClass.getComponentType();&lt;br /&gt;
    }&lt;br /&gt;
    return count;&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
   &lt;br /&gt;
    &lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Array helper ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
/*&lt;br /&gt;
 * Hibernate, Relational Persistence for Idiomatic Java&lt;br /&gt;
 *&lt;br /&gt;
 * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as&lt;br /&gt;
 * indicated by the @author tags or express copyright attribution&lt;br /&gt;
 * statements applied by the authors.  All third-party contributions are&lt;br /&gt;
 * distributed under license by Red Hat Middleware LLC.&lt;br /&gt;
 *&lt;br /&gt;
 * This copyrighted material is made available to anyone wishing to use, modify,&lt;br /&gt;
 * copy, or redistribute it subject to the terms and conditions of the GNU&lt;br /&gt;
 * Lesser General Public License, as published by the Free Software Foundation.&lt;br /&gt;
 *&lt;br /&gt;
 * This program is distributed in the hope that it will be useful,&lt;br /&gt;
 * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY&lt;br /&gt;
 * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License&lt;br /&gt;
 * for more details.&lt;br /&gt;
 *&lt;br /&gt;
 * You should have received a copy of the GNU Lesser General Public License&lt;br /&gt;
 * along with this distribution; if not, write to:&lt;br /&gt;
 * Free Software Foundation, Inc.&lt;br /&gt;
 * 51 Franklin Street, Fifth Floor&lt;br /&gt;
 * Boston, MA  02110-1301  USA&lt;br /&gt;
 *&lt;br /&gt;
 */&lt;br /&gt;
import java.lang.reflect.Array;&lt;br /&gt;
import java.lang.reflect.Type;&lt;br /&gt;
import java.util.ArrayList;&lt;br /&gt;
import java.util.Arrays;&lt;br /&gt;
import java.util.Collection;&lt;br /&gt;
import java.util.Iterator;&lt;br /&gt;
import java.util.List;&lt;br /&gt;
public final class ArrayHelper {&lt;br /&gt;
&lt;br /&gt;
  public static int indexOf(Object[] array, Object object) {&lt;br /&gt;
    for (int i = 0; i &amp;lt; array.length; i++) {&lt;br /&gt;
      if (array[i].equals(object))&lt;br /&gt;
        return i;&lt;br /&gt;
    }&lt;br /&gt;
    return -1;&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  public static String[] toStringArray(Object[] objects) {&lt;br /&gt;
    int length = objects.length;&lt;br /&gt;
    String[] result = new String[length];&lt;br /&gt;
    for (int i = 0; i &amp;lt; length; i++) {&lt;br /&gt;
      result[i] = objects[i].toString();&lt;br /&gt;
    }&lt;br /&gt;
    return result;&lt;br /&gt;
  }&lt;br /&gt;
  public static String[] fillArray(String value, int length) {&lt;br /&gt;
    String[] result = new String[length];&lt;br /&gt;
    Arrays.fill(result, value);&lt;br /&gt;
    return result;&lt;br /&gt;
  }&lt;br /&gt;
  public static int[] fillArray(int value, int length) {&lt;br /&gt;
    int[] result = new int[length];&lt;br /&gt;
    Arrays.fill(result, value);&lt;br /&gt;
    return result;&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  public static String[] toStringArray(Collection coll) {&lt;br /&gt;
    return (String[]) coll.toArray(EMPTY_STRING_ARRAY);&lt;br /&gt;
  }&lt;br /&gt;
  public static String[][] to2DStringArray(Collection coll) {&lt;br /&gt;
    return (String[][]) coll.toArray(new String[coll.size()][]);&lt;br /&gt;
  }&lt;br /&gt;
  public static int[][] to2DIntArray(Collection coll) {&lt;br /&gt;
    return (int[][]) coll.toArray(new int[coll.size()][]);&lt;br /&gt;
  }&lt;br /&gt;
  public static Type[] toTypeArray(Collection coll) {&lt;br /&gt;
    return (Type[]) coll.toArray(EMPTY_TYPE_ARRAY);&lt;br /&gt;
  }&lt;br /&gt;
  public static int[] toIntArray(Collection coll) {&lt;br /&gt;
    Iterator iter = coll.iterator();&lt;br /&gt;
    int[] arr = new int[coll.size()];&lt;br /&gt;
    int i = 0;&lt;br /&gt;
    while (iter.hasNext()) {&lt;br /&gt;
      arr[i++] = ((Integer) iter.next()).intValue();&lt;br /&gt;
    }&lt;br /&gt;
    return arr;&lt;br /&gt;
  }&lt;br /&gt;
  public static boolean[] toBooleanArray(Collection coll) {&lt;br /&gt;
    Iterator iter = coll.iterator();&lt;br /&gt;
    boolean[] arr = new boolean[coll.size()];&lt;br /&gt;
    int i = 0;&lt;br /&gt;
    while (iter.hasNext()) {&lt;br /&gt;
      arr[i++] = ((Boolean) iter.next()).booleanValue();&lt;br /&gt;
    }&lt;br /&gt;
    return arr;&lt;br /&gt;
  }&lt;br /&gt;
  public static Object[] typecast(Object[] array, Object[] to) {&lt;br /&gt;
    return java.util.Arrays.asList(array).toArray(to);&lt;br /&gt;
  }&lt;br /&gt;
  // Arrays.asList doesn&amp;quot;t do primitive arrays&lt;br /&gt;
  public static List toList(Object array) {&lt;br /&gt;
    if (array instanceof Object[])&lt;br /&gt;
      return Arrays.asList((Object[]) array); // faster?&lt;br /&gt;
    int size = Array.getLength(array);&lt;br /&gt;
    ArrayList list = new ArrayList(size);&lt;br /&gt;
    for (int i = 0; i &amp;lt; size; i++) {&lt;br /&gt;
      list.add(Array.get(array, i));&lt;br /&gt;
    }&lt;br /&gt;
    return list;&lt;br /&gt;
  }&lt;br /&gt;
  public static String[] slice(String[] strings, int begin, int length) {&lt;br /&gt;
    String[] result = new String[length];&lt;br /&gt;
    for (int i = 0; i &amp;lt; length; i++) {&lt;br /&gt;
      result[i] = strings[begin + i];&lt;br /&gt;
    }&lt;br /&gt;
    return result;&lt;br /&gt;
  }&lt;br /&gt;
  public static Object[] slice(Object[] objects, int begin, int length) {&lt;br /&gt;
    Object[] result = new Object[length];&lt;br /&gt;
    for (int i = 0; i &amp;lt; length; i++) {&lt;br /&gt;
      result[i] = objects[begin + i];&lt;br /&gt;
    }&lt;br /&gt;
    return result;&lt;br /&gt;
  }&lt;br /&gt;
  public static List toList(Iterator iter) {&lt;br /&gt;
    List list = new ArrayList();&lt;br /&gt;
    while (iter.hasNext()) {&lt;br /&gt;
      list.add(iter.next());&lt;br /&gt;
    }&lt;br /&gt;
    return list;&lt;br /&gt;
  }&lt;br /&gt;
  public static String[] join(String[] x, String[] y) {&lt;br /&gt;
    String[] result = new String[x.length + y.length];&lt;br /&gt;
    for (int i = 0; i &amp;lt; x.length; i++)&lt;br /&gt;
      result[i] = x[i];&lt;br /&gt;
    for (int i = 0; i &amp;lt; y.length; i++)&lt;br /&gt;
      result[i + x.length] = y[i];&lt;br /&gt;
    return result;&lt;br /&gt;
  }&lt;br /&gt;
  public static String[] join(String[] x, String[] y, boolean[] use) {&lt;br /&gt;
    String[] result = new String[x.length + countTrue(use)];&lt;br /&gt;
    for (int i = 0; i &amp;lt; x.length; i++)&lt;br /&gt;
      result[i] = x[i];&lt;br /&gt;
    int k = x.length;&lt;br /&gt;
    for (int i = 0; i &amp;lt; y.length; i++) {&lt;br /&gt;
      if (use[i])&lt;br /&gt;
        result[k++] = y[i];&lt;br /&gt;
    }&lt;br /&gt;
    return result;&lt;br /&gt;
  }&lt;br /&gt;
  public static int[] join(int[] x, int[] y) {&lt;br /&gt;
    int[] result = new int[x.length + y.length];&lt;br /&gt;
    for (int i = 0; i &amp;lt; x.length; i++)&lt;br /&gt;
      result[i] = x[i];&lt;br /&gt;
    for (int i = 0; i &amp;lt; y.length; i++)&lt;br /&gt;
      result[i + x.length] = y[i];&lt;br /&gt;
    return result;&lt;br /&gt;
  }&lt;br /&gt;
  public static final boolean[] TRUE = { true };&lt;br /&gt;
  public static final boolean[] FALSE = { false };&lt;br /&gt;
  private ArrayHelper() {&lt;br /&gt;
  }&lt;br /&gt;
  public static String toString(Object[] array) {&lt;br /&gt;
    StringBuffer sb = new StringBuffer();&lt;br /&gt;
    sb.append(&amp;quot;[&amp;quot;);&lt;br /&gt;
    for (int i = 0; i &amp;lt; array.length; i++) {&lt;br /&gt;
      sb.append(array[i]);&lt;br /&gt;
      if (i &amp;lt; array.length - 1)&lt;br /&gt;
        sb.append(&amp;quot;,&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
    sb.append(&amp;quot;]&amp;quot;);&lt;br /&gt;
    return sb.toString();&lt;br /&gt;
  }&lt;br /&gt;
  public static boolean isAllNegative(int[] array) {&lt;br /&gt;
    for (int i = 0; i &amp;lt; array.length; i++) {&lt;br /&gt;
      if (array[i] &amp;gt;= 0)&lt;br /&gt;
        return false;&lt;br /&gt;
    }&lt;br /&gt;
    return true;&lt;br /&gt;
  }&lt;br /&gt;
  public static boolean isAllTrue(boolean[] array) {&lt;br /&gt;
    for (int i = 0; i &amp;lt; array.length; i++) {&lt;br /&gt;
      if (!array[i])&lt;br /&gt;
        return false;&lt;br /&gt;
    }&lt;br /&gt;
    return true;&lt;br /&gt;
  }&lt;br /&gt;
  public static int countTrue(boolean[] array) {&lt;br /&gt;
    int result = 0;&lt;br /&gt;
    for (int i = 0; i &amp;lt; array.length; i++) {&lt;br /&gt;
      if (array[i])&lt;br /&gt;
        result++;&lt;br /&gt;
    }&lt;br /&gt;
    return result;&lt;br /&gt;
  }&lt;br /&gt;
  /*&lt;br /&gt;
   * public static int countFalse(boolean[] array) { int result=0; for ( int&lt;br /&gt;
   * i=0; i&amp;lt;array.length; i++ ) { if ( !array[i] ) result++; } return result; }&lt;br /&gt;
   */&lt;br /&gt;
  public static boolean isAllFalse(boolean[] array) {&lt;br /&gt;
    for (int i = 0; i &amp;lt; array.length; i++) {&lt;br /&gt;
      if (array[i])&lt;br /&gt;
        return false;&lt;br /&gt;
    }&lt;br /&gt;
    return true;&lt;br /&gt;
  }&lt;br /&gt;
  public static void addAll(Collection collection, Object[] array) {&lt;br /&gt;
    for (int i = 0; i &amp;lt; array.length; i++) {&lt;br /&gt;
      collection.add(array[i]);&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
  public static final String[] EMPTY_STRING_ARRAY = {};&lt;br /&gt;
  public static final int[] EMPTY_INT_ARRAY = {};&lt;br /&gt;
  public static final boolean[] EMPTY_BOOLEAN_ARRAY = {};&lt;br /&gt;
  public static final Class[] EMPTY_CLASS_ARRAY = {};&lt;br /&gt;
  public static final Object[] EMPTY_OBJECT_ARRAY = {};&lt;br /&gt;
  public static final Type[] EMPTY_TYPE_ARRAY = {};&lt;br /&gt;
  public static int[] getBatchSizes(int maxBatchSize) {&lt;br /&gt;
    int batchSize = maxBatchSize;&lt;br /&gt;
    int n = 1;&lt;br /&gt;
    while (batchSize &amp;gt; 1) {&lt;br /&gt;
      batchSize = getNextBatchSize(batchSize);&lt;br /&gt;
      n++;&lt;br /&gt;
    }&lt;br /&gt;
    int[] result = new int[n];&lt;br /&gt;
    batchSize = maxBatchSize;&lt;br /&gt;
    for (int i = 0; i &amp;lt; n; i++) {&lt;br /&gt;
      result[i] = batchSize;&lt;br /&gt;
      batchSize = getNextBatchSize(batchSize);&lt;br /&gt;
    }&lt;br /&gt;
    return result;&lt;br /&gt;
  }&lt;br /&gt;
  private static int getNextBatchSize(int batchSize) {&lt;br /&gt;
    if (batchSize &amp;lt;= 10) {&lt;br /&gt;
      return batchSize - 1; // allow 9,8,7,6,5,4,3,2,1&lt;br /&gt;
    } else if (batchSize / 2 &amp;lt; 10) {&lt;br /&gt;
      return 10;&lt;br /&gt;
    } else {&lt;br /&gt;
      return batchSize / 2;&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
  private static int SEED = 23;&lt;br /&gt;
  private static int PRIME_NUMER = 37;&lt;br /&gt;
  /**&lt;br /&gt;
   * calculate the array hash (only the first level)&lt;br /&gt;
   */&lt;br /&gt;
  public static int hash(Object[] array) {&lt;br /&gt;
    int length = array.length;&lt;br /&gt;
    int seed = SEED;&lt;br /&gt;
    for (int index = 0; index &amp;lt; length; index++) {&lt;br /&gt;
      seed = hash(seed, array[index] == null ? 0 : array[index].hashCode());&lt;br /&gt;
    }&lt;br /&gt;
    return seed;&lt;br /&gt;
  }&lt;br /&gt;
  /**&lt;br /&gt;
   * calculate the array hash (only the first level)&lt;br /&gt;
   */&lt;br /&gt;
  public static int hash(char[] array) {&lt;br /&gt;
    int length = array.length;&lt;br /&gt;
    int seed = SEED;&lt;br /&gt;
    for (int index = 0; index &amp;lt; length; index++) {&lt;br /&gt;
      seed = hash(seed, (int) array[index]);&lt;br /&gt;
    }&lt;br /&gt;
    return seed;&lt;br /&gt;
  }&lt;br /&gt;
  /**&lt;br /&gt;
   * calculate the array hash (only the first level)&lt;br /&gt;
   */&lt;br /&gt;
  public static int hash(byte[] bytes) {&lt;br /&gt;
    int length = bytes.length;&lt;br /&gt;
    int seed = SEED;&lt;br /&gt;
    for (int index = 0; index &amp;lt; length; index++) {&lt;br /&gt;
      seed = hash(seed, (int) bytes[index]);&lt;br /&gt;
    }&lt;br /&gt;
    return seed;&lt;br /&gt;
  }&lt;br /&gt;
  private static int hash(int seed, int i) {&lt;br /&gt;
    return PRIME_NUMER * seed + i;&lt;br /&gt;
  }&lt;br /&gt;
  /**&lt;br /&gt;
   * Compare 2 arrays only at the first level&lt;br /&gt;
   */&lt;br /&gt;
  public static boolean isEquals(Object[] o1, Object[] o2) {&lt;br /&gt;
    if (o1 == o2)&lt;br /&gt;
      return true;&lt;br /&gt;
    if (o1 == null || o2 == null)&lt;br /&gt;
      return false;&lt;br /&gt;
    int length = o1.length;&lt;br /&gt;
    if (length != o2.length)&lt;br /&gt;
      return false;&lt;br /&gt;
    for (int index = 0; index &amp;lt; length; index++) {&lt;br /&gt;
      if (!o1[index].equals(o2[index]))&lt;br /&gt;
        return false;&lt;br /&gt;
    }&lt;br /&gt;
    return true;&lt;br /&gt;
  }&lt;br /&gt;
  /**&lt;br /&gt;
   * Compare 2 arrays only at the first level&lt;br /&gt;
   */&lt;br /&gt;
  public static boolean isEquals(char[] o1, char[] o2) {&lt;br /&gt;
    if (o1 == o2)&lt;br /&gt;
      return true;&lt;br /&gt;
    if (o1 == null || o2 == null)&lt;br /&gt;
      return false;&lt;br /&gt;
    int length = o1.length;&lt;br /&gt;
    if (length != o2.length)&lt;br /&gt;
      return false;&lt;br /&gt;
    for (int index = 0; index &amp;lt; length; index++) {&lt;br /&gt;
      if (!(o1[index] == o2[index]))&lt;br /&gt;
        return false;&lt;br /&gt;
    }&lt;br /&gt;
    return true;&lt;br /&gt;
  }&lt;br /&gt;
  /**&lt;br /&gt;
   * Compare 2 arrays only at the first level&lt;br /&gt;
   */&lt;br /&gt;
  public static boolean isEquals(byte[] b1, byte[] b2) {&lt;br /&gt;
    if (b1 == b2)&lt;br /&gt;
      return true;&lt;br /&gt;
    if (b1 == null || b2 == null)&lt;br /&gt;
      return false;&lt;br /&gt;
    int length = b1.length;&lt;br /&gt;
    if (length != b2.length)&lt;br /&gt;
      return false;&lt;br /&gt;
    for (int index = 0; index &amp;lt; length; index++) {&lt;br /&gt;
      if (!(b1[index] == b2[index]))&lt;br /&gt;
        return false;&lt;br /&gt;
    }&lt;br /&gt;
    return true;&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
   &lt;br /&gt;
    &lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== byte array to int array ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
/*&lt;br /&gt;
 * Permission is hereby granted, free of charge, to any person obtaining a copy of &lt;br /&gt;
 * this software and associated documentation files (the &amp;quot;Software&amp;quot;), to deal in &lt;br /&gt;
 * the Software without restriction, including without limitation the rights to &lt;br /&gt;
 * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies &lt;br /&gt;
 * of the Software, and to permit persons to whom the Software is furnished to do&lt;br /&gt;
 * so, subject to the following conditions:&lt;br /&gt;
 * &lt;br /&gt;
 * The above copyright notice and this permission notice shall be included in all&lt;br /&gt;
 * copies or substantial portions of the Software.&lt;br /&gt;
 * &lt;br /&gt;
 * THE SOFTWARE IS PROVIDED &amp;quot;AS IS&amp;quot;, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR&lt;br /&gt;
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, &lt;br /&gt;
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE &lt;br /&gt;
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER &lt;br /&gt;
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, &lt;br /&gt;
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE &lt;br /&gt;
 * SOFTWARE.&lt;br /&gt;
 */&lt;br /&gt;
public class ArrayCopy {&lt;br /&gt;
    &lt;br /&gt;
    public static int[] byte2int(byte[]src) {&lt;br /&gt;
        int dstLength = src.length &amp;gt;&amp;gt;&amp;gt; 2;&lt;br /&gt;
        int[]dst = new int[dstLength];&lt;br /&gt;
        &lt;br /&gt;
        for (int i=0; i&amp;lt;dstLength; i++) {&lt;br /&gt;
            int j = i &amp;lt;&amp;lt; 2;&lt;br /&gt;
            int x = 0;&lt;br /&gt;
            x += (src[j++] &amp;amp; 0xff) &amp;lt;&amp;lt; 0;&lt;br /&gt;
            x += (src[j++] &amp;amp; 0xff) &amp;lt;&amp;lt; 8;&lt;br /&gt;
            x += (src[j++] &amp;amp; 0xff) &amp;lt;&amp;lt; 16;&lt;br /&gt;
            x += (src[j++] &amp;amp; 0xff) &amp;lt;&amp;lt; 24;&lt;br /&gt;
            dst[i] = x;&lt;br /&gt;
        }&lt;br /&gt;
        return dst;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
   &lt;br /&gt;
    &lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Convert array to string ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
/*  ArraysX.java&lt;br /&gt;
{{IS_NOTE&lt;br /&gt;
  Purpose:&lt;br /&gt;
  Description:&lt;br /&gt;
  History:&lt;br /&gt;
    2001/11/13, Henri Chen: Created.&lt;br /&gt;
}}IS_NOTE&lt;br /&gt;
Copyright (C) 2001 Potix Corporation. All Rights Reserved.&lt;br /&gt;
{{IS_RIGHT&lt;br /&gt;
  This program is distributed under GPL Version 3.0 in the hope that&lt;br /&gt;
  it will be useful, but WITHOUT ANY WARRANTY.&lt;br /&gt;
}}IS_RIGHT&lt;br /&gt;
*/&lt;br /&gt;
import java.lang.reflect.Array;&lt;br /&gt;
/**&lt;br /&gt;
 * Utilities for handling arrays.&lt;br /&gt;
 *&lt;br /&gt;
 * @author henrichen&lt;br /&gt;
 */&lt;br /&gt;
public class ArraysX {&lt;br /&gt;
  /** Converts an array to a readable string (for debugging purpose).&lt;br /&gt;
   */&lt;br /&gt;
  public final static String toString(Object[] array) {&lt;br /&gt;
    if (array == null)&lt;br /&gt;
      return &amp;quot;null&amp;quot;;&lt;br /&gt;
    StringBuffer sb = new StringBuffer(128).append(&amp;quot;[&amp;quot;);&lt;br /&gt;
    for (int j = 0; j &amp;lt; array.length; ++j) {&lt;br /&gt;
      if (array[j] == array)&lt;br /&gt;
        sb.append(&amp;quot;(this array)&amp;quot;);&lt;br /&gt;
      else&lt;br /&gt;
        sb.append(array[j]);&lt;br /&gt;
      if (j != array.length - 1)&lt;br /&gt;
        sb.append(&amp;quot;, &amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
    return sb.append(&amp;quot;]&amp;quot;).toString();&lt;br /&gt;
  }&lt;br /&gt;
  /** Converts an array of int to a readable string (for debugging purpose).&lt;br /&gt;
   */&lt;br /&gt;
  public final static String toString(int[] array) {&lt;br /&gt;
    if (array == null)&lt;br /&gt;
      return &amp;quot;null&amp;quot;;&lt;br /&gt;
    StringBuffer sb = new StringBuffer(128).append(&amp;quot;[&amp;quot;);&lt;br /&gt;
    for (int j = 0; j &amp;lt; array.length; ++j) {&lt;br /&gt;
      sb.append(array[j]);&lt;br /&gt;
      if (j != array.length - 1)&lt;br /&gt;
        sb.append(&amp;quot;, &amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
    return sb.append(&amp;quot;]&amp;quot;).toString();&lt;br /&gt;
  }&lt;br /&gt;
  /** Converts an array of long to a readable string (for debugging purpose).&lt;br /&gt;
   */&lt;br /&gt;
  public final static String toString(long[] array) {&lt;br /&gt;
    if (array == null)&lt;br /&gt;
      return &amp;quot;null&amp;quot;;&lt;br /&gt;
    StringBuffer sb = new StringBuffer(128).append(&amp;quot;[&amp;quot;);&lt;br /&gt;
    for (int j = 0; j &amp;lt; array.length; ++j) {&lt;br /&gt;
      sb.append(array[j]);&lt;br /&gt;
      if (j != array.length - 1)&lt;br /&gt;
        sb.append(&amp;quot;, &amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
    return sb.append(&amp;quot;]&amp;quot;).toString();&lt;br /&gt;
  }&lt;br /&gt;
  /** Converts an array of short to a readable string (for debugging purpose).&lt;br /&gt;
   */&lt;br /&gt;
  public final static String toString(short[] array) {&lt;br /&gt;
    if (array == null)&lt;br /&gt;
      return &amp;quot;null&amp;quot;;&lt;br /&gt;
    StringBuffer sb = new StringBuffer(128).append(&amp;quot;[&amp;quot;);&lt;br /&gt;
    for (int j = 0; j &amp;lt; array.length; ++j) {&lt;br /&gt;
      sb.append(array[j]);&lt;br /&gt;
      if (j != array.length - 1)&lt;br /&gt;
        sb.append(&amp;quot;, &amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
    return sb.append(&amp;quot;]&amp;quot;).toString();&lt;br /&gt;
  }&lt;br /&gt;
  /** Converts an array of byte to a readable string (for debugging purpose).&lt;br /&gt;
   */&lt;br /&gt;
  public final static String toString(byte[] array) {&lt;br /&gt;
    if (array == null)&lt;br /&gt;
      return &amp;quot;null&amp;quot;;&lt;br /&gt;
    StringBuffer sb = new StringBuffer(128).append(&amp;quot;[&amp;quot;);&lt;br /&gt;
    for (int j = 0; j &amp;lt; array.length; ++j) {&lt;br /&gt;
      sb.append(array[j]);&lt;br /&gt;
      if (j != array.length - 1)&lt;br /&gt;
        sb.append(&amp;quot;, &amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
    return sb.append(&amp;quot;]&amp;quot;).toString();&lt;br /&gt;
  }&lt;br /&gt;
  /** Converts an array of char to a readable string (for debugging purpose).&lt;br /&gt;
   */&lt;br /&gt;
  public final static String toString(char[] array) {&lt;br /&gt;
    if (array == null)&lt;br /&gt;
      return &amp;quot;null&amp;quot;;&lt;br /&gt;
    StringBuffer sb = new StringBuffer(128).append(&amp;quot;[&amp;quot;);&lt;br /&gt;
    for (int j = 0; j &amp;lt; array.length; ++j) {&lt;br /&gt;
      sb.append(array[j]);&lt;br /&gt;
      if (j != array.length - 1)&lt;br /&gt;
        sb.append(&amp;quot;, &amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
    return sb.append(&amp;quot;]&amp;quot;).toString();&lt;br /&gt;
  }&lt;br /&gt;
  /** Converts an array of boolean to a readable string (for debugging purpose).&lt;br /&gt;
   */&lt;br /&gt;
  public final static String toString(boolean[] array) {&lt;br /&gt;
    if (array == null)&lt;br /&gt;
      return &amp;quot;null&amp;quot;;&lt;br /&gt;
    StringBuffer sb = new StringBuffer(128).append(&amp;quot;[&amp;quot;);&lt;br /&gt;
    for (int j = 0; j &amp;lt; array.length; ++j) {&lt;br /&gt;
      sb.append(array[j]);&lt;br /&gt;
      if (j != array.length - 1)&lt;br /&gt;
        sb.append(&amp;quot;, &amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
    return sb.append(&amp;quot;]&amp;quot;).toString();&lt;br /&gt;
  }&lt;br /&gt;
  /** Converts an array of float to a readable string (for debugging purpose).&lt;br /&gt;
   */&lt;br /&gt;
  public final static String toString(float[] array) {&lt;br /&gt;
    if (array == null)&lt;br /&gt;
      return &amp;quot;null&amp;quot;;&lt;br /&gt;
    StringBuffer sb = new StringBuffer(128).append(&amp;quot;[&amp;quot;);&lt;br /&gt;
    for (int j = 0; j &amp;lt; array.length; ++j) {&lt;br /&gt;
      sb.append(array[j]);&lt;br /&gt;
      if (j != array.length - 1)&lt;br /&gt;
        sb.append(&amp;quot;, &amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
    return sb.append(&amp;quot;]&amp;quot;).toString();&lt;br /&gt;
  }&lt;br /&gt;
  /** Converts an array of char to a readable string (for debugging purpose).&lt;br /&gt;
   */&lt;br /&gt;
  public final static String toString(double[] array) {&lt;br /&gt;
    if (array == null)&lt;br /&gt;
      return &amp;quot;null&amp;quot;;&lt;br /&gt;
    StringBuffer sb = new StringBuffer(128).append(&amp;quot;[&amp;quot;);&lt;br /&gt;
    for (int j = 0; j &amp;lt; array.length; ++j) {&lt;br /&gt;
      sb.append(array[j]);&lt;br /&gt;
      if (j != array.length - 1)&lt;br /&gt;
        sb.append(&amp;quot;, &amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
    return sb.append(&amp;quot;]&amp;quot;).toString();&lt;br /&gt;
  }&lt;br /&gt;
  /**&lt;br /&gt;
   * Returns the hex String representation of a byte array without prefix 0x.&lt;br /&gt;
   * The String is formed by making value[0] the leftmost two digits and&lt;br /&gt;
   * value[value.length-1] the rightmost two digits.&lt;br /&gt;
   *&lt;br /&gt;
   * @param array the byte array&lt;br /&gt;
   */&lt;br /&gt;
  public final static String toHexString(byte[] array) {&lt;br /&gt;
    StringBuffer sb = new StringBuffer(array.length*2 + 8);&lt;br /&gt;
    char ch;&lt;br /&gt;
    for (int i=0; i&amp;lt; array.length; i++) {&lt;br /&gt;
      // byte will be promote to integer first, mask with 0x0f is a must.&lt;br /&gt;
      ch = Character.forDigit(array[i] &amp;gt;&amp;gt;&amp;gt; 4 &amp;amp; 0x0f, 16);&lt;br /&gt;
      sb.append(ch);&lt;br /&gt;
      ch = Character.forDigit(array[i] &amp;amp; 0x0f, 16);&lt;br /&gt;
      sb.append(ch);&lt;br /&gt;
    }&lt;br /&gt;
    return sb.toString();&lt;br /&gt;
  }&lt;br /&gt;
  /**&lt;br /&gt;
   * Returns the octal String representation of a byte array with optional&lt;br /&gt;
   * prefix. The String is formed by making value[0] the leftmost three digits&lt;br /&gt;
   * and value[value.length-1] the rightmost three digits.&lt;br /&gt;
   *&lt;br /&gt;
   * @param array the byte array&lt;br /&gt;
   */&lt;br /&gt;
  public final static String toOctalString(byte[] array, String prefix) {&lt;br /&gt;
    StringBuffer sb = new StringBuffer(array.length*(3+prefix.length()) + 8);&lt;br /&gt;
    if (prefix == null) {&lt;br /&gt;
      for (int i=0; i&amp;lt; array.length; i++) {&lt;br /&gt;
        appendOctalDigits(sb, array[i]);&lt;br /&gt;
      }&lt;br /&gt;
    } else {&lt;br /&gt;
      for (int i=0; i&amp;lt; array.length; i++) {&lt;br /&gt;
        sb.append(prefix);&lt;br /&gt;
        appendOctalDigits(sb, array[i]);&lt;br /&gt;
      }&lt;br /&gt;
    }&lt;br /&gt;
    return sb.toString();&lt;br /&gt;
  }&lt;br /&gt;
  /**&lt;br /&gt;
   * Returns the octal digit String buffer representation of a byte.&lt;br /&gt;
   * @param byte the byte&lt;br /&gt;
   */&lt;br /&gt;
  private final static StringBuffer appendOctalDigits(StringBuffer sb, byte b) {&lt;br /&gt;
    // b will be promote to integer first, mask with 0x07 is a must.&lt;br /&gt;
    return sb.append(Character.forDigit(b &amp;gt;&amp;gt;&amp;gt; 6 &amp;amp; 0x07, 8))&lt;br /&gt;
      .append(Character.forDigit(b &amp;gt;&amp;gt;&amp;gt; 3 &amp;amp; 0x07, 8))&lt;br /&gt;
      .append(Character.forDigit(b &amp;amp; 0x07, 8));&lt;br /&gt;
  }&lt;br /&gt;
  /**&lt;br /&gt;
   * Duplicates the specified array.&lt;br /&gt;
   *&lt;br /&gt;
   * &amp;lt;p&amp;gt;The array could be an array of objects or primiitives.&lt;br /&gt;
   *&lt;br /&gt;
   * @param ary the array&lt;br /&gt;
   * @param jb the beginning index (included)&lt;br /&gt;
   * @param je the ending index (excluded)&lt;br /&gt;
   * @return an array duplicated from ary&lt;br /&gt;
   * @exception IllegalArgumentException if ary is not any array&lt;br /&gt;
   * @exception IndexOutOfBoundsException if out of bounds&lt;br /&gt;
   */&lt;br /&gt;
  public static final Object duplicate(Object ary, int jb, int je) {&lt;br /&gt;
    int len = Array.getLength(ary);&lt;br /&gt;
    if (jb&amp;lt;0 || je&amp;gt;len || jb&amp;gt;je)&lt;br /&gt;
      throw new IndexOutOfBoundsException(jb + &amp;quot; or &amp;quot; + je + &amp;quot; exceeds &amp;quot; + len);&lt;br /&gt;
    len = je - jb;&lt;br /&gt;
    Object dst = Array.newInstance(ary.getClass().getComponentType(), len);&lt;br /&gt;
    System.arraycopy(ary, jb, dst, 0, len);&lt;br /&gt;
    return dst;&lt;br /&gt;
  }&lt;br /&gt;
  /**&lt;br /&gt;
   * Duplicates the specified array.&lt;br /&gt;
   * @param ary the array&lt;br /&gt;
   * @return an array duplicated from ary&lt;br /&gt;
   * @exception IllegalArgumentException if ary is not any array&lt;br /&gt;
   * @exception IndexOutOfBoundsException if out of bounds&lt;br /&gt;
   */&lt;br /&gt;
  public static final Object duplicate(Object ary) {&lt;br /&gt;
    return duplicate(ary, 0, Array.getLength(ary));&lt;br /&gt;
  }&lt;br /&gt;
  /**&lt;br /&gt;
   * Concat the two specified array.&lt;br /&gt;
   *&lt;br /&gt;
   * &amp;lt;p&amp;gt;The array could be an array of objects or primiitives.&lt;br /&gt;
   *&lt;br /&gt;
   * @param ary the array&lt;br /&gt;
   * @param ary1 the array&lt;br /&gt;
   * @return an array concat the ary and ary1&lt;br /&gt;
   * @exception IllegalArgumentException if ary and ary1 component type are different&lt;br /&gt;
   */&lt;br /&gt;
  public static final Object concat(Object ary, Object ary1) {&lt;br /&gt;
    int len = Array.getLength(ary) + Array.getLength(ary1);&lt;br /&gt;
    &lt;br /&gt;
    if (!ary.getClass().getComponentType().equals(ary1.getClass().getComponentType()))&lt;br /&gt;
      throw new IllegalArgumentException(&amp;quot;These concated array component type are different.&amp;quot;);&lt;br /&gt;
    Object dst = Array.newInstance(ary.getClass().getComponentType(), len);&lt;br /&gt;
    &lt;br /&gt;
    System.arraycopy(ary, 0, dst, 0, Array.getLength(ary));&lt;br /&gt;
    System.arraycopy(ary1, 0, dst, Array.getLength(ary), Array.getLength(ary1));&lt;br /&gt;
    &lt;br /&gt;
    return dst;&lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
  /**&lt;br /&gt;
   * Shrink the specified array. It is similar to duplicate, except&lt;br /&gt;
   * it returns the previous instance if je==length &amp;amp;&amp;amp; jb==0.&lt;br /&gt;
   *&lt;br /&gt;
   * @param ary the array&lt;br /&gt;
   * @param jb the beginning index (included)&lt;br /&gt;
   * @param je the ending index (excluded)&lt;br /&gt;
   * @return ary or an array duplicated from ary&lt;br /&gt;
   * @exception IllegalArgumentException if ary is not any array&lt;br /&gt;
   * @exception IndexOutOfBoundsException if out of bounds&lt;br /&gt;
   */&lt;br /&gt;
  public static final Object shrink(Object ary, int jb, int je) {&lt;br /&gt;
    if (jb == 0 &amp;amp;&amp;amp; je == Array.getLength(ary))&lt;br /&gt;
      return ary; //nothing changed&lt;br /&gt;
    return duplicate(ary, jb, je);&lt;br /&gt;
  }&lt;br /&gt;
  /**&lt;br /&gt;
   * Resizes the specified array. Similar to {@link #shrink}, but&lt;br /&gt;
   * it can enlarge and it keeps elements from the first.&lt;br /&gt;
   */&lt;br /&gt;
  public static final Object resize(Object ary, int size) {&lt;br /&gt;
    final int oldsz = Array.getLength(ary);&lt;br /&gt;
    if (oldsz == size)&lt;br /&gt;
      return ary;&lt;br /&gt;
    final Object dst = Array.newInstance(ary.getClass().getComponentType(), size);&lt;br /&gt;
    System.arraycopy(ary, 0, dst, 0, oldsz &amp;gt; size ? size: oldsz);&lt;br /&gt;
    return dst;&lt;br /&gt;
  }&lt;br /&gt;
  /** Clones an array.&lt;br /&gt;
   */&lt;br /&gt;
  public static final Object clone(Object ary) {&lt;br /&gt;
    final int size = Array.getLength(ary);&lt;br /&gt;
    final Object dst = Array.newInstance(ary.getClass().getComponentType(), size);&lt;br /&gt;
    System.arraycopy(ary, 0, dst, 0, size);&lt;br /&gt;
    return dst;&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
   &lt;br /&gt;
    &lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Convert array to string (from c3p0) ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
/**&lt;br /&gt;
 * Distributed as part of c3p0 v.0.9.1.2&lt;br /&gt;
 * &lt;br /&gt;
 * Copyright (C) 2005 Machinery For Change, Inc.&lt;br /&gt;
 * &lt;br /&gt;
 * Author: Steve Waldman &amp;lt;swaldman@mchange.ru&amp;gt;&lt;br /&gt;
 * &lt;br /&gt;
 * This library is free software; you can redistribute it and/or modify it under&lt;br /&gt;
 * the terms of the GNU Lesser General Public License version 2.1, as published&lt;br /&gt;
 * by the Free Software Foundation.&lt;br /&gt;
 * &lt;br /&gt;
 * This software is distributed in the hope that it will be useful, but WITHOUT&lt;br /&gt;
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS&lt;br /&gt;
 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more&lt;br /&gt;
 * details.&lt;br /&gt;
 * &lt;br /&gt;
 * You should have received a copy of the GNU Lesser General Public License&lt;br /&gt;
 * along with this software; see the file LICENSE. If not, write to the Free&lt;br /&gt;
 * Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307,&lt;br /&gt;
 * USA.&lt;br /&gt;
 */&lt;br /&gt;
public final class ArrayUtils {&lt;br /&gt;
  /**&lt;br /&gt;
   * The array may contain nulls, but &amp;lt;TT&amp;gt;o&amp;lt;/TT&amp;gt; must be non-null.&lt;br /&gt;
   */&lt;br /&gt;
  public static int indexOf(Object[] array, Object o) {&lt;br /&gt;
    for (int i = 0, len = array.length; i &amp;lt; len; ++i)&lt;br /&gt;
      if (o.equals(array[i]))&lt;br /&gt;
        return i;&lt;br /&gt;
    return -1;&lt;br /&gt;
  }&lt;br /&gt;
  public static int identityIndexOf(Object[] array, Object o) {&lt;br /&gt;
    for (int i = 0, len = array.length; i &amp;lt; len; ++i)&lt;br /&gt;
      if (o == array[i])&lt;br /&gt;
        return i;&lt;br /&gt;
    return -1;&lt;br /&gt;
  }&lt;br /&gt;
  public static boolean startsWith(byte[] checkMe, byte[] maybePrefix) {&lt;br /&gt;
    int cm_len = checkMe.length;&lt;br /&gt;
    int mp_len = maybePrefix.length;&lt;br /&gt;
    if (cm_len &amp;lt; mp_len)&lt;br /&gt;
      return false;&lt;br /&gt;
    for (int i = 0; i &amp;lt; mp_len; ++i)&lt;br /&gt;
      if (checkMe[i] != maybePrefix[i])&lt;br /&gt;
        return false;&lt;br /&gt;
    return true;&lt;br /&gt;
  }&lt;br /&gt;
  /**&lt;br /&gt;
   * returns a hash-code for an array consistent with Arrays.equals( ... )&lt;br /&gt;
   */&lt;br /&gt;
  public static int hashArray(int[] ii) {&lt;br /&gt;
    int len = ii.length;&lt;br /&gt;
    int out = len;&lt;br /&gt;
    for (int i = 0; i &amp;lt; len; ++i) {&lt;br /&gt;
      // we rotate the bits of the element hashes&lt;br /&gt;
      // around so that the hash has some loaction&lt;br /&gt;
      // dependency&lt;br /&gt;
      int elem_hash = ii[i];&lt;br /&gt;
      int rot = i % 32;&lt;br /&gt;
      int rot_hash = elem_hash &amp;gt;&amp;gt;&amp;gt; rot;&lt;br /&gt;
      rot_hash |= elem_hash &amp;lt;&amp;lt; (32 - rot);&lt;br /&gt;
      out ^= rot_hash;&lt;br /&gt;
    }&lt;br /&gt;
    return out;&lt;br /&gt;
  }&lt;br /&gt;
  public static int hashOrZeroArray(int[] ii) {&lt;br /&gt;
    return (ii == null ? 0 : hashArray(ii));&lt;br /&gt;
  }&lt;br /&gt;
  // these methods are obsoleted by Arrays.toString() in jdk1.5, but&lt;br /&gt;
  // for libs that support older VMs...&lt;br /&gt;
  private static String toString(String[] strings, int guessed_len) {&lt;br /&gt;
    StringBuffer sb = new StringBuffer(guessed_len);&lt;br /&gt;
    boolean first = true;&lt;br /&gt;
    sb.append(&amp;quot;[&amp;quot;);&lt;br /&gt;
    for (int i = 0, len = strings.length; i &amp;lt; len; ++i) {&lt;br /&gt;
      if (first)&lt;br /&gt;
        first = false;&lt;br /&gt;
      else&lt;br /&gt;
        sb.append(&amp;quot;,&amp;quot;);&lt;br /&gt;
      sb.append(strings[i]);&lt;br /&gt;
    }&lt;br /&gt;
    sb.append(&amp;quot;]&amp;quot;);&lt;br /&gt;
    return sb.toString();&lt;br /&gt;
  }&lt;br /&gt;
  public static String toString(boolean[] arr) {&lt;br /&gt;
    String[] strings = new String[arr.length];&lt;br /&gt;
    int chars = 0;&lt;br /&gt;
    for (int i = 0, len = arr.length; i &amp;lt; len; ++i) {&lt;br /&gt;
      String str = String.valueOf(arr[i]);&lt;br /&gt;
      chars += str.length();&lt;br /&gt;
      strings[i] = str;&lt;br /&gt;
    }&lt;br /&gt;
    return toString(strings, chars + arr.length + 1);&lt;br /&gt;
  }&lt;br /&gt;
  public static String toString(byte[] arr) {&lt;br /&gt;
    String[] strings = new String[arr.length];&lt;br /&gt;
    int chars = 0;&lt;br /&gt;
    for (int i = 0, len = arr.length; i &amp;lt; len; ++i) {&lt;br /&gt;
      String str = String.valueOf(arr[i]);&lt;br /&gt;
      chars += str.length();&lt;br /&gt;
      strings[i] = str;&lt;br /&gt;
    }&lt;br /&gt;
    return toString(strings, chars + arr.length + 1);&lt;br /&gt;
  }&lt;br /&gt;
  public static String toString(char[] arr) {&lt;br /&gt;
    String[] strings = new String[arr.length];&lt;br /&gt;
    int chars = 0;&lt;br /&gt;
    for (int i = 0, len = arr.length; i &amp;lt; len; ++i) {&lt;br /&gt;
      String str = String.valueOf(arr[i]);&lt;br /&gt;
      chars += str.length();&lt;br /&gt;
      strings[i] = str;&lt;br /&gt;
    }&lt;br /&gt;
    return toString(strings, chars + arr.length + 1);&lt;br /&gt;
  }&lt;br /&gt;
  public static String toString(short[] arr) {&lt;br /&gt;
    String[] strings = new String[arr.length];&lt;br /&gt;
    int chars = 0;&lt;br /&gt;
    for (int i = 0, len = arr.length; i &amp;lt; len; ++i) {&lt;br /&gt;
      String str = String.valueOf(arr[i]);&lt;br /&gt;
      chars += str.length();&lt;br /&gt;
      strings[i] = str;&lt;br /&gt;
    }&lt;br /&gt;
    return toString(strings, chars + arr.length + 1);&lt;br /&gt;
  }&lt;br /&gt;
  public static String toString(int[] arr) {&lt;br /&gt;
    String[] strings = new String[arr.length];&lt;br /&gt;
    int chars = 0;&lt;br /&gt;
    for (int i = 0, len = arr.length; i &amp;lt; len; ++i) {&lt;br /&gt;
      String str = String.valueOf(arr[i]);&lt;br /&gt;
      chars += str.length();&lt;br /&gt;
      strings[i] = str;&lt;br /&gt;
    }&lt;br /&gt;
    return toString(strings, chars + arr.length + 1);&lt;br /&gt;
  }&lt;br /&gt;
  public static String toString(long[] arr) {&lt;br /&gt;
    String[] strings = new String[arr.length];&lt;br /&gt;
    int chars = 0;&lt;br /&gt;
    for (int i = 0, len = arr.length; i &amp;lt; len; ++i) {&lt;br /&gt;
      String str = String.valueOf(arr[i]);&lt;br /&gt;
      chars += str.length();&lt;br /&gt;
      strings[i] = str;&lt;br /&gt;
    }&lt;br /&gt;
    return toString(strings, chars + arr.length + 1);&lt;br /&gt;
  }&lt;br /&gt;
  public static String toString(float[] arr) {&lt;br /&gt;
    String[] strings = new String[arr.length];&lt;br /&gt;
    int chars = 0;&lt;br /&gt;
    for (int i = 0, len = arr.length; i &amp;lt; len; ++i) {&lt;br /&gt;
      String str = String.valueOf(arr[i]);&lt;br /&gt;
      chars += str.length();&lt;br /&gt;
      strings[i] = str;&lt;br /&gt;
    }&lt;br /&gt;
    return toString(strings, chars + arr.length + 1);&lt;br /&gt;
  }&lt;br /&gt;
  public static String toString(double[] arr) {&lt;br /&gt;
    String[] strings = new String[arr.length];&lt;br /&gt;
    int chars = 0;&lt;br /&gt;
    for (int i = 0, len = arr.length; i &amp;lt; len; ++i) {&lt;br /&gt;
      String str = String.valueOf(arr[i]);&lt;br /&gt;
      chars += str.length();&lt;br /&gt;
      strings[i] = str;&lt;br /&gt;
    }&lt;br /&gt;
    return toString(strings, chars + arr.length + 1);&lt;br /&gt;
  }&lt;br /&gt;
  public static String toString(Object[] arr) {&lt;br /&gt;
    String[] strings = new String[arr.length];&lt;br /&gt;
    int chars = 0;&lt;br /&gt;
    for (int i = 0, len = arr.length; i &amp;lt; len; ++i) {&lt;br /&gt;
      String str;&lt;br /&gt;
      Object o = arr[i];&lt;br /&gt;
      if (o instanceof Object[])&lt;br /&gt;
        str = toString((Object[]) o);&lt;br /&gt;
      else if (o instanceof double[])&lt;br /&gt;
        str = toString((double[]) o);&lt;br /&gt;
      else if (o instanceof float[])&lt;br /&gt;
        str = toString((float[]) o);&lt;br /&gt;
      else if (o instanceof long[])&lt;br /&gt;
        str = toString((long[]) o);&lt;br /&gt;
      else if (o instanceof int[])&lt;br /&gt;
        str = toString((int[]) o);&lt;br /&gt;
      else if (o instanceof short[])&lt;br /&gt;
        str = toString((short[]) o);&lt;br /&gt;
      else if (o instanceof char[])&lt;br /&gt;
        str = toString((char[]) o);&lt;br /&gt;
      else if (o instanceof byte[])&lt;br /&gt;
        str = toString((byte[]) o);&lt;br /&gt;
      else if (o instanceof boolean[])&lt;br /&gt;
        str = toString((boolean[]) o);&lt;br /&gt;
      else&lt;br /&gt;
        str = String.valueOf(arr[i]);&lt;br /&gt;
      chars += str.length();&lt;br /&gt;
      strings[i] = str;&lt;br /&gt;
    }&lt;br /&gt;
    return toString(strings, chars + arr.length + 1);&lt;br /&gt;
  }&lt;br /&gt;
  private ArrayUtils() {&lt;br /&gt;
  }&lt;br /&gt;
  /*&lt;br /&gt;
   * public static void main(String[] argv) { int[] is = {1,2,3,4}; String[] ss =&lt;br /&gt;
   * {&amp;quot;Hello&amp;quot;, &amp;quot;There&amp;quot;}; Object[] os = {&amp;quot;Poop&amp;quot;, is, ss, new Thread()};&lt;br /&gt;
   * &lt;br /&gt;
   * System.out.println( toString(is) ); System.out.println( toString(ss) );&lt;br /&gt;
   * System.out.println( toString(os) ); }&lt;br /&gt;
   */&lt;br /&gt;
}&lt;br /&gt;
   &lt;br /&gt;
    &lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Convert byte array to Integer and Long ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
/*&lt;br /&gt;
 * Copyright Aduna (http://www.aduna-software.ru/) (c) 1997-2006.&lt;br /&gt;
 *&lt;br /&gt;
 * Licensed under the Aduna BSD-style license.&lt;br /&gt;
 */&lt;br /&gt;
&lt;br /&gt;
public class Utils {&lt;br /&gt;
&lt;br /&gt;
  public static void putInt(int value, byte[] array, int offset) {&lt;br /&gt;
    array[offset]   = (byte)(0xff &amp;amp; (value &amp;gt;&amp;gt; 24));&lt;br /&gt;
    array[offset+1] = (byte)(0xff &amp;amp; (value &amp;gt;&amp;gt; 16));&lt;br /&gt;
    array[offset+2] = (byte)(0xff &amp;amp; (value &amp;gt;&amp;gt; 8));&lt;br /&gt;
    array[offset+3] = (byte)(0xff &amp;amp; value);&lt;br /&gt;
  }&lt;br /&gt;
  public static int getInt(byte[] array, int offset) {&lt;br /&gt;
    return&lt;br /&gt;
      ((array[offset]   &amp;amp; 0xff) &amp;lt;&amp;lt; 24) |&lt;br /&gt;
      ((array[offset+1] &amp;amp; 0xff) &amp;lt;&amp;lt; 16) |&lt;br /&gt;
      ((array[offset+2] &amp;amp; 0xff) &amp;lt;&amp;lt; 8) |&lt;br /&gt;
       (array[offset+3] &amp;amp; 0xff);&lt;br /&gt;
  }&lt;br /&gt;
  public static void putLong(long value, byte[] array, int offset) {&lt;br /&gt;
    array[offset]   = (byte)(0xff &amp;amp; (value &amp;gt;&amp;gt; 56));&lt;br /&gt;
    array[offset+1] = (byte)(0xff &amp;amp; (value &amp;gt;&amp;gt; 48));&lt;br /&gt;
    array[offset+2] = (byte)(0xff &amp;amp; (value &amp;gt;&amp;gt; 40));&lt;br /&gt;
    array[offset+3] = (byte)(0xff &amp;amp; (value &amp;gt;&amp;gt; 32));&lt;br /&gt;
    array[offset+4] = (byte)(0xff &amp;amp; (value &amp;gt;&amp;gt; 24));&lt;br /&gt;
    array[offset+5] = (byte)(0xff &amp;amp; (value &amp;gt;&amp;gt; 16));&lt;br /&gt;
    array[offset+6] = (byte)(0xff &amp;amp; (value &amp;gt;&amp;gt; 8));&lt;br /&gt;
    array[offset+7] = (byte)(0xff &amp;amp; value);&lt;br /&gt;
  }&lt;br /&gt;
  public static long getLong(byte[] array, int offset) {&lt;br /&gt;
    return&lt;br /&gt;
      ((long)(array[offset]   &amp;amp; 0xff) &amp;lt;&amp;lt; 56) |&lt;br /&gt;
      ((long)(array[offset+1] &amp;amp; 0xff) &amp;lt;&amp;lt; 48) |&lt;br /&gt;
      ((long)(array[offset+2] &amp;amp; 0xff) &amp;lt;&amp;lt; 40) |&lt;br /&gt;
      ((long)(array[offset+3] &amp;amp; 0xff) &amp;lt;&amp;lt; 32) |&lt;br /&gt;
      ((long)(array[offset+4] &amp;amp; 0xff) &amp;lt;&amp;lt; 24) |&lt;br /&gt;
      ((long)(array[offset+5] &amp;amp; 0xff) &amp;lt;&amp;lt; 16) |&lt;br /&gt;
      ((long)(array[offset+6] &amp;amp; 0xff) &amp;lt;&amp;lt; 8) |&lt;br /&gt;
      ((long)(array[offset+7] &amp;amp; 0xff));&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
   &lt;br /&gt;
    &lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Convert byte array to string ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
/*&lt;br /&gt;
   Copyright (C) 2002 MySQL AB&lt;br /&gt;
     This program is free software; you can redistribute it and/or modify&lt;br /&gt;
     it under the terms of the GNU General Public License as published by&lt;br /&gt;
     the Free Software Foundation; either version 2 of the License, or&lt;br /&gt;
     (at your option) any later version.&lt;br /&gt;
     This program is distributed in the hope that it will be useful,&lt;br /&gt;
     but WITHOUT ANY WARRANTY; without even the implied warranty of&lt;br /&gt;
     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the&lt;br /&gt;
     GNU General Public License for more details.&lt;br /&gt;
     You should have received a copy of the GNU General Public License&lt;br /&gt;
     along with this program; if not, write to the Free Software&lt;br /&gt;
     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA&lt;br /&gt;
     &lt;br /&gt;
 */&lt;br /&gt;
import java.io.UnsupportedEncodingException;&lt;br /&gt;
&lt;br /&gt;
/**&lt;br /&gt;
 * Various utility methods for converting to/from byte&lt;br /&gt;
 * arrays in the platform encoding&lt;br /&gt;
 * &lt;br /&gt;
 * @author Mark Matthews&lt;br /&gt;
 */&lt;br /&gt;
public class StringUtils {&lt;br /&gt;
    //~ Instance/static variables .............................................&lt;br /&gt;
    private static final int BYTE_RANGE = (1 + Byte.MAX_VALUE)&lt;br /&gt;
                                          - Byte.MIN_VALUE;&lt;br /&gt;
    private static byte[] allBytes = new byte[BYTE_RANGE];&lt;br /&gt;
    private static char[] byteToChars = new char[BYTE_RANGE];&lt;br /&gt;
    //~ Initializers ..........................................................&lt;br /&gt;
    static {&lt;br /&gt;
        for (int i = Byte.MIN_VALUE; i &amp;lt;= Byte.MAX_VALUE; i++) {&lt;br /&gt;
            allBytes[i - Byte.MIN_VALUE] = (byte) i;&lt;br /&gt;
        }&lt;br /&gt;
        String allBytesString = new String(allBytes, 0, &lt;br /&gt;
                                           Byte.MAX_VALUE - Byte.MIN_VALUE);&lt;br /&gt;
        for (int i = 0; i &amp;lt; (Byte.MAX_VALUE - Byte.MIN_VALUE); i++) {&lt;br /&gt;
            byteToChars[i] = allBytesString.charAt(i);&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    /**&lt;br /&gt;
     * DOCUMENT ME!&lt;br /&gt;
     * &lt;br /&gt;
     * @param buffer DOCUMENT ME!&lt;br /&gt;
     * @param startPos DOCUMENT ME!&lt;br /&gt;
     * @param length DOCUMENT ME!&lt;br /&gt;
     * @return DOCUMENT ME! &lt;br /&gt;
     */&lt;br /&gt;
    public static final String toAsciiString3(byte[] buffer, int startPos, &lt;br /&gt;
                                              int length) {&lt;br /&gt;
        char[] charArray = new char[length];&lt;br /&gt;
        int readpoint = startPos;&lt;br /&gt;
        for (int i = 0; i &amp;lt; length; i++) {&lt;br /&gt;
            charArray[i] = byteToChars[(int) buffer[readpoint]&lt;br /&gt;
                           - Byte.MIN_VALUE];&lt;br /&gt;
            readpoint++;&lt;br /&gt;
        }&lt;br /&gt;
        return new String(charArray);&lt;br /&gt;
    }&lt;br /&gt;
    /**&lt;br /&gt;
     * DOCUMENT ME!&lt;br /&gt;
     * &lt;br /&gt;
     * @param buffer DOCUMENT ME!&lt;br /&gt;
     * @return DOCUMENT ME! &lt;br /&gt;
     */&lt;br /&gt;
    public static final String toAsciiString(byte[] buffer) {&lt;br /&gt;
        return toAsciiString3(buffer, 0, buffer.length);&lt;br /&gt;
    }&lt;br /&gt;
    /**&lt;br /&gt;
     * DOCUMENT ME!&lt;br /&gt;
     * &lt;br /&gt;
     * @param buffer DOCUMENT ME!&lt;br /&gt;
     * @param startPos DOCUMENT ME!&lt;br /&gt;
     * @param length DOCUMENT ME!&lt;br /&gt;
     * @return DOCUMENT ME! &lt;br /&gt;
     */&lt;br /&gt;
    public static final String toAsciiString2(byte[] buffer, int startPos, &lt;br /&gt;
                                              int length) {&lt;br /&gt;
        return new String(buffer, startPos, length);&lt;br /&gt;
    }&lt;br /&gt;
    /**&lt;br /&gt;
     * DOCUMENT ME!&lt;br /&gt;
     * &lt;br /&gt;
     * @param buffer DOCUMENT ME!&lt;br /&gt;
     * @param startPos DOCUMENT ME!&lt;br /&gt;
     * @param length DOCUMENT ME!&lt;br /&gt;
     * @return DOCUMENT ME! &lt;br /&gt;
     */&lt;br /&gt;
    public static final String toAsciiString(byte[] buffer, int startPos, &lt;br /&gt;
                                             int length) {&lt;br /&gt;
        StringBuffer result = new StringBuffer();&lt;br /&gt;
        int endPoint = startPos + length;&lt;br /&gt;
        for (int i = startPos; i &amp;lt; endPoint; i++) {&lt;br /&gt;
            result.append(byteToChars[(int) buffer[i] - Byte.MIN_VALUE]);&lt;br /&gt;
        }&lt;br /&gt;
        return result.toString();&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
   &lt;br /&gt;
    &lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Converts a Array to an Enumeration and allows it to be serialized ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
/*&lt;br /&gt;
 * Copyright Javelin Software, All rights reserved.&lt;br /&gt;
 */&lt;br /&gt;
&lt;br /&gt;
import java.util.*;&lt;br /&gt;
import java.io.*;&lt;br /&gt;
/**&lt;br /&gt;
 * An ArrayEnumeration converts a Array to an Enumeration and allows it&lt;br /&gt;
 * to be serialized. &lt;br /&gt;
 * &amp;lt;p&amp;gt;&lt;br /&gt;
 * @author Robin Sharp&lt;br /&gt;
 */&lt;br /&gt;
public class ArrayEnumeration implements Enumeration, Serializable&lt;br /&gt;
{&lt;br /&gt;
    /**&lt;br /&gt;
     * Construct a fully qualified ArrayEnumeration.&lt;br /&gt;
     * @param array the array to be Enumerated.&lt;br /&gt;
     */&lt;br /&gt;
     public ArrayEnumeration(Object[] array)&lt;br /&gt;
     {&lt;br /&gt;
         this.array = array;&lt;br /&gt;
     }&lt;br /&gt;
     // ENUMERATION /////////////////////////////////////////////////////////&lt;br /&gt;
    /**&lt;br /&gt;
     * @return true if there are more elements in the enumeration.&lt;br /&gt;
     */&lt;br /&gt;
    public boolean hasMoreElements()&lt;br /&gt;
    {&lt;br /&gt;
        return array != null &amp;amp;&amp;amp; index &amp;lt; array.length;&lt;br /&gt;
    }&lt;br /&gt;
    /**&lt;br /&gt;
     * @return the next element in the enumeration&lt;br /&gt;
     */&lt;br /&gt;
    public Object nextElement()&lt;br /&gt;
    {&lt;br /&gt;
        return array[index++];&lt;br /&gt;
    }&lt;br /&gt;
    // PRIVATE /////////////////////////////////////////////////////////////&lt;br /&gt;
    private Object[] array;&lt;br /&gt;
    private int index;&lt;br /&gt;
}&lt;br /&gt;
   &lt;br /&gt;
    &lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== int array to byte array ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
/*&lt;br /&gt;
 * Permission is hereby granted, free of charge, to any person obtaining a copy of &lt;br /&gt;
 * this software and associated documentation files (the &amp;quot;Software&amp;quot;), to deal in &lt;br /&gt;
 * the Software without restriction, including without limitation the rights to &lt;br /&gt;
 * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies &lt;br /&gt;
 * of the Software, and to permit persons to whom the Software is furnished to do&lt;br /&gt;
 * so, subject to the following conditions:&lt;br /&gt;
 * &lt;br /&gt;
 * The above copyright notice and this permission notice shall be included in all&lt;br /&gt;
 * copies or substantial portions of the Software.&lt;br /&gt;
 * &lt;br /&gt;
 * THE SOFTWARE IS PROVIDED &amp;quot;AS IS&amp;quot;, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR&lt;br /&gt;
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, &lt;br /&gt;
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE &lt;br /&gt;
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER &lt;br /&gt;
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, &lt;br /&gt;
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE &lt;br /&gt;
 * SOFTWARE.&lt;br /&gt;
 */&lt;br /&gt;
public class ArrayCopy {&lt;br /&gt;
    &lt;br /&gt;
  public static byte[] int2byte(int[]src) {&lt;br /&gt;
    int srcLength = src.length;&lt;br /&gt;
    byte[]dst = new byte[srcLength &amp;lt;&amp;lt; 2];&lt;br /&gt;
    &lt;br /&gt;
    for (int i=0; i&amp;lt;srcLength; i++) {&lt;br /&gt;
        int x = src[i];&lt;br /&gt;
        int j = i &amp;lt;&amp;lt; 2;&lt;br /&gt;
        dst[j++] = (byte) ((x &amp;gt;&amp;gt;&amp;gt; 0) &amp;amp; 0xff);           &lt;br /&gt;
        dst[j++] = (byte) ((x &amp;gt;&amp;gt;&amp;gt; 8) &amp;amp; 0xff);&lt;br /&gt;
        dst[j++] = (byte) ((x &amp;gt;&amp;gt;&amp;gt; 16) &amp;amp; 0xff);&lt;br /&gt;
        dst[j++] = (byte) ((x &amp;gt;&amp;gt;&amp;gt; 24) &amp;amp; 0xff);&lt;br /&gt;
    }&lt;br /&gt;
    return dst;&lt;br /&gt;
}&lt;br /&gt;
}&lt;br /&gt;
   &lt;br /&gt;
    &lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Return a new byte array containing a sub-portion of the source array ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
/**********************************************************************************&lt;br /&gt;
 *&lt;br /&gt;
 * Copyright (c) 2003, 2004 The Regents of the University of Michigan, Trustees of Indiana University,&lt;br /&gt;
 *                  Board of Trustees of the Leland Stanford, Jr., University, and The MIT Corporation&lt;br /&gt;
 *&lt;br /&gt;
 * Licensed under the Educational Community License Version 1.0 (the &amp;quot;License&amp;quot;);&lt;br /&gt;
 * By obtaining, using and/or copying this Original Work, you agree that you have read,&lt;br /&gt;
 * understand, and will comply with the terms and conditions of the Educational Community License.&lt;br /&gt;
 * You may obtain a copy of the License at:&lt;br /&gt;
 *&lt;br /&gt;
 *      http://cvs.sakaiproject.org/licenses/license_1_0.html&lt;br /&gt;
 *&lt;br /&gt;
 * THE SOFTWARE IS PROVIDED &amp;quot;AS IS&amp;quot;, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,&lt;br /&gt;
 * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE&lt;br /&gt;
 * AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,&lt;br /&gt;
 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING&lt;br /&gt;
 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.&lt;br /&gt;
 *&lt;br /&gt;
 **********************************************************************************/&lt;br /&gt;
&lt;br /&gt;
/**&lt;br /&gt;
 * Byte utilities&lt;br /&gt;
 */&lt;br /&gt;
public class ByteUtils {&lt;br /&gt;
&lt;br /&gt;
  /**&lt;br /&gt;
   * Return a new byte array containing a sub-portion of the source array&lt;br /&gt;
   * &lt;br /&gt;
   * @param srcBegin&lt;br /&gt;
   *          The beginning index (inclusive)&lt;br /&gt;
   * @return The new, populated byte array&lt;br /&gt;
   */&lt;br /&gt;
  public static byte[] subbytes(byte[] source, int srcBegin) {&lt;br /&gt;
    return subbytes(source, srcBegin, source.length);&lt;br /&gt;
  }&lt;br /&gt;
  /**&lt;br /&gt;
   * Return a new byte array containing a sub-portion of the source array&lt;br /&gt;
   * &lt;br /&gt;
   * @param srcBegin&lt;br /&gt;
   *          The beginning index (inclusive)&lt;br /&gt;
   * @param srcEnd&lt;br /&gt;
   *          The ending index (exclusive)&lt;br /&gt;
   * @return The new, populated byte array&lt;br /&gt;
   */&lt;br /&gt;
  public static byte[] subbytes(byte[] source, int srcBegin, int srcEnd) {&lt;br /&gt;
    byte destination[];&lt;br /&gt;
    destination = new byte[srcEnd - srcBegin];&lt;br /&gt;
    getBytes(source, srcBegin, srcEnd, destination, 0);&lt;br /&gt;
    return destination;&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  /**&lt;br /&gt;
   * Copies bytes from the source byte array to the destination array&lt;br /&gt;
   * &lt;br /&gt;
   * @param source&lt;br /&gt;
   *          The source array&lt;br /&gt;
   * @param srcBegin&lt;br /&gt;
   *          Index of the first source byte to copy&lt;br /&gt;
   * @param srcEnd&lt;br /&gt;
   *          Index after the last source byte to copy&lt;br /&gt;
   * @param destination&lt;br /&gt;
   *          The destination array&lt;br /&gt;
   * @param dstBegin&lt;br /&gt;
   *          The starting offset in the destination array&lt;br /&gt;
   */&lt;br /&gt;
  public static void getBytes(byte[] source, int srcBegin, int srcEnd, byte[] destination,&lt;br /&gt;
      int dstBegin) {&lt;br /&gt;
    System.arraycopy(source, srcBegin, destination, dstBegin, srcEnd - srcBegin);&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
   &lt;br /&gt;
    &lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Turn an array of ints into a printable string. ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
import java.io.IOException;&lt;br /&gt;
import java.io.InputStream;&lt;br /&gt;
import java.util.Enumeration;&lt;br /&gt;
import java.util.Properties;&lt;br /&gt;
/*&lt;br /&gt;
   Derby - Class org.apache.derby.iapi.util.PropertyUtil&lt;br /&gt;
   Licensed to the Apache Software Foundation (ASF) under one or more&lt;br /&gt;
   contributor license agreements.  See the NOTICE file distributed with&lt;br /&gt;
   this work for additional information regarding copyright ownership.&lt;br /&gt;
   The ASF licenses this file to you under the Apache License, Version 2.0&lt;br /&gt;
   (the &amp;quot;License&amp;quot;); you may not use this file except in compliance with&lt;br /&gt;
   the License.  You may obtain a copy of the License at&lt;br /&gt;
      http://www.apache.org/licenses/LICENSE-2.0&lt;br /&gt;
   Unless required by applicable law or agreed to in writing, software&lt;br /&gt;
   distributed under the License is distributed on an &amp;quot;AS IS&amp;quot; BASIS,&lt;br /&gt;
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.&lt;br /&gt;
   See the License for the specific language governing permissions and&lt;br /&gt;
   limitations under the License.&lt;br /&gt;
 */&lt;br /&gt;
&lt;br /&gt;
public class Main {&lt;br /&gt;
&lt;br /&gt;
  /**&lt;br /&gt;
   * Turn an array of ints into a printable string. Returns what&amp;quot;s returned&lt;br /&gt;
   * in Java 5 by java.util.Arrays.toString(int[]).&lt;br /&gt;
   */&lt;br /&gt;
  public  static  String  stringify( int[] raw )&lt;br /&gt;
  {&lt;br /&gt;
      if ( raw == null ) { return &amp;quot;null&amp;quot;; }&lt;br /&gt;
      &lt;br /&gt;
      StringBuffer    buffer = new StringBuffer();&lt;br /&gt;
      int                 count = raw.length;&lt;br /&gt;
      buffer.append( &amp;quot;[ &amp;quot; );&lt;br /&gt;
      for ( int i = 0; i &amp;lt; count; i++ )&lt;br /&gt;
      {&lt;br /&gt;
          if ( i &amp;gt; 0 ) { buffer.append( &amp;quot;, &amp;quot; ); }&lt;br /&gt;
          buffer.append( raw[ i ] );&lt;br /&gt;
      }&lt;br /&gt;
      buffer.append( &amp;quot; ]&amp;quot; );&lt;br /&gt;
      return buffer.toString();&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
   &lt;br /&gt;
    &lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;/div&gt;</summary>
		<author><name>Admin</name></author>	</entry>

	<entry>
		<id>http://jexp.ru/index.php?title=Java/Collections_Data_Structure/EnumMap&amp;diff=9169</id>
		<title>Java/Collections Data Structure/EnumMap</title>
		<link rel="alternate" type="text/html" href="http://jexp.ru/index.php?title=Java/Collections_Data_Structure/EnumMap&amp;diff=9169"/>
				<updated>2010-06-01T07:27:10Z</updated>
		
		<summary type="html">&lt;p&gt;Admin: 1 версия&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Use EnumMap to store enum type data ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
import java.util.EnumMap;&lt;br /&gt;
public class SizeMap {&lt;br /&gt;
  public static void main(String[] args) {&lt;br /&gt;
    EnumMap&amp;lt;Size, String&amp;gt; sizeMap = new EnumMap&amp;lt;Size, String&amp;gt;(Size.class);&lt;br /&gt;
    sizeMap.put(Size.S, &amp;quot;S&amp;quot;);&lt;br /&gt;
    sizeMap.put(Size.M, &amp;quot;M&amp;quot;);&lt;br /&gt;
    sizeMap.put(Size.L, &amp;quot;L&amp;quot;);&lt;br /&gt;
    sizeMap.put(Size.XL, &amp;quot;XL&amp;quot;);&lt;br /&gt;
    sizeMap.put(Size.XXL, &amp;quot;XXL&amp;quot;);&lt;br /&gt;
    sizeMap.put(Size.XXXL, &amp;quot;XXXL&amp;quot;);&lt;br /&gt;
    for (Size size : Size.values()) {&lt;br /&gt;
      System.out.println(size + &amp;quot;:&amp;quot; + sizeMap.get(size));&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
enum Size {&lt;br /&gt;
  S, M, L, XL, XXL, XXXL;&lt;br /&gt;
}&lt;br /&gt;
 &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;/div&gt;</summary>
		<author><name>Admin</name></author>	</entry>

	</feed>