<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="ru">
		<id>http://www.jexp.ru/index.php?action=history&amp;feed=atom&amp;title=Java%2FDevelopment_Class%2FChar_Text</id>
		<title>Java/Development Class/Char Text - История изменений</title>
		<link rel="self" type="application/atom+xml" href="http://www.jexp.ru/index.php?action=history&amp;feed=atom&amp;title=Java%2FDevelopment_Class%2FChar_Text"/>
		<link rel="alternate" type="text/html" href="http://www.jexp.ru/index.php?title=Java/Development_Class/Char_Text&amp;action=history"/>
		<updated>2026-04-22T13:57:33Z</updated>
		<subtitle>История изменений этой страницы в вики</subtitle>
		<generator>MediaWiki 1.30.0</generator>

	<entry>
		<id>http://www.jexp.ru/index.php?title=Java/Development_Class/Char_Text&amp;diff=8373&amp;oldid=prev</id>
		<title>Admin: 1 версия</title>
		<link rel="alternate" type="text/html" href="http://www.jexp.ru/index.php?title=Java/Development_Class/Char_Text&amp;diff=8373&amp;oldid=prev"/>
				<updated>2010-06-01T07:00:30Z</updated>
		
		<summary type="html">&lt;p&gt;1 версия&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left&quot; data-mw=&quot;interface&quot;&gt;
				&lt;tr style=&quot;vertical-align: top;&quot; lang=&quot;ru&quot;&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;← Предыдущая&lt;/td&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;Версия 07:00, 1 июня 2010&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; style=&quot;text-align: center;&quot; lang=&quot;ru&quot;&gt;&lt;div class=&quot;mw-diff-empty&quot;&gt;(нет различий)&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;</summary>
		<author><name>Admin</name></author>	</entry>

	<entry>
		<id>http://www.jexp.ru/index.php?title=Java/Development_Class/Char_Text&amp;diff=8372&amp;oldid=prev</id>
		<title> в 18:01, 31 мая 2010</title>
		<link rel="alternate" type="text/html" href="http://www.jexp.ru/index.php?title=Java/Development_Class/Char_Text&amp;diff=8372&amp;oldid=prev"/>
				<updated>2010-05-31T18:01:46Z</updated>
		
		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Новая страница&lt;/b&gt;&lt;/p&gt;&lt;div&gt;== Break Iterator 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;
/* From http://java.sun.ru/docs/books/tutorial/index.html */&lt;br /&gt;
/*&lt;br /&gt;
 * Copyright (c) 1995-1998 Sun Microsystems, Inc. All Rights Reserved.&lt;br /&gt;
 * &lt;br /&gt;
 * Permission to use, copy, modify, and distribute this software and its&lt;br /&gt;
 * documentation for NON-COMMERCIAL purposes and without fee is hereby granted&lt;br /&gt;
 * provided that this copyright notice appears in all copies. Please refer to&lt;br /&gt;
 * the file &amp;quot;copyright.html&amp;quot; for further important copyright and licensing&lt;br /&gt;
 * information.&lt;br /&gt;
 * &lt;br /&gt;
 * SUN MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE&lt;br /&gt;
 * SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED&lt;br /&gt;
 * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR&lt;br /&gt;
 * NON-INFRINGEMENT. SUN SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY&lt;br /&gt;
 * LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS&lt;br /&gt;
 * DERIVATIVES.&lt;br /&gt;
 */&lt;br /&gt;
import java.text.BreakIterator;&lt;br /&gt;
import java.util.Locale;&lt;br /&gt;
public class BreakIteratorDemo {&lt;br /&gt;
  static void extractWords(String target, BreakIterator wordIterator) {&lt;br /&gt;
    wordIterator.setText(target);&lt;br /&gt;
    int start = wordIterator.first();&lt;br /&gt;
    int end = wordIterator.next();&lt;br /&gt;
    while (end != BreakIterator.DONE) {&lt;br /&gt;
      String word = target.substring(start, end);&lt;br /&gt;
      if (Character.isLetterOrDigit(word.charAt(0))) {&lt;br /&gt;
        System.out.println(word);&lt;br /&gt;
      }&lt;br /&gt;
      start = end;&lt;br /&gt;
      end = wordIterator.next();&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
  static void reverseWords(String target, BreakIterator wordIterator) {&lt;br /&gt;
    wordIterator.setText(target);&lt;br /&gt;
    int end = wordIterator.last();&lt;br /&gt;
    int start = wordIterator.previous();&lt;br /&gt;
    while (start != BreakIterator.DONE) {&lt;br /&gt;
      String word = target.substring(start, end);&lt;br /&gt;
      if (Character.isLetterOrDigit(word.charAt(0)))&lt;br /&gt;
        System.out.println(word);&lt;br /&gt;
      end = start;&lt;br /&gt;
      start = wordIterator.previous();&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
  static void markBoundaries(String target, BreakIterator iterator) {&lt;br /&gt;
    StringBuffer markers = new StringBuffer();&lt;br /&gt;
    markers.setLength(target.length() + 1);&lt;br /&gt;
    for (int k = 0; k &amp;lt; markers.length(); k++) {&lt;br /&gt;
      markers.setCharAt(k, &amp;quot; &amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
    iterator.setText(target);&lt;br /&gt;
    int boundary = iterator.first();&lt;br /&gt;
    while (boundary != BreakIterator.DONE) {&lt;br /&gt;
      markers.setCharAt(boundary, &amp;quot;^&amp;quot;);&lt;br /&gt;
      boundary = iterator.next();&lt;br /&gt;
    }&lt;br /&gt;
    System.out.println(target);&lt;br /&gt;
    System.out.println(markers);&lt;br /&gt;
  }&lt;br /&gt;
  static void formatLines(String target, int maxLength, Locale currentLocale) {&lt;br /&gt;
    BreakIterator boundary = BreakIterator.getLineInstance(currentLocale);&lt;br /&gt;
    boundary.setText(target);&lt;br /&gt;
    int start = boundary.first();&lt;br /&gt;
    int end = boundary.next();&lt;br /&gt;
    int lineLength = 0;&lt;br /&gt;
    while (end != BreakIterator.DONE) {&lt;br /&gt;
      String word = target.substring(start, end);&lt;br /&gt;
      lineLength = lineLength + word.length();&lt;br /&gt;
      if (lineLength &amp;gt;= maxLength) {&lt;br /&gt;
        System.out.println();&lt;br /&gt;
        lineLength = word.length();&lt;br /&gt;
      }&lt;br /&gt;
      System.out.print(word);&lt;br /&gt;
      start = end;&lt;br /&gt;
      end = boundary.next();&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
  static void listPositions(String target, BreakIterator iterator) {&lt;br /&gt;
    iterator.setText(target);&lt;br /&gt;
    int boundary = iterator.first();&lt;br /&gt;
    while (boundary != BreakIterator.DONE) {&lt;br /&gt;
      System.out.println(boundary);&lt;br /&gt;
      boundary = iterator.next();&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
  static void characterExamples() {&lt;br /&gt;
    BreakIterator arCharIterator = BreakIterator&lt;br /&gt;
        .getCharacterInstance(new Locale(&amp;quot;ar&amp;quot;, &amp;quot;SA&amp;quot;));&lt;br /&gt;
    // Arabic word for &amp;quot;house&amp;quot;&lt;br /&gt;
    String house = &amp;quot;\u0628&amp;quot; + &amp;quot;\u064e&amp;quot; + &amp;quot;\u064a&amp;quot; + &amp;quot;\u0652&amp;quot; + &amp;quot;\u067a&amp;quot;&lt;br /&gt;
        + &amp;quot;\u064f&amp;quot;;&lt;br /&gt;
    listPositions(house, arCharIterator);&lt;br /&gt;
  }&lt;br /&gt;
  static void wordExamples() {&lt;br /&gt;
    Locale currentLocale = new Locale(&amp;quot;en&amp;quot;, &amp;quot;US&amp;quot;);&lt;br /&gt;
    BreakIterator wordIterator = BreakIterator&lt;br /&gt;
        .getWordInstance(currentLocale);&lt;br /&gt;
    String someText = &amp;quot;She stopped.  &amp;quot;&lt;br /&gt;
        + &amp;quot;She said, \&amp;quot;Hello there,\&amp;quot; and then went on.&amp;quot;;&lt;br /&gt;
    markBoundaries(someText, wordIterator);&lt;br /&gt;
    System.out.println();&lt;br /&gt;
    extractWords(someText, wordIterator);&lt;br /&gt;
  }&lt;br /&gt;
  static void sentenceExamples() {&lt;br /&gt;
    Locale currentLocale = new Locale(&amp;quot;en&amp;quot;, &amp;quot;US&amp;quot;);&lt;br /&gt;
    BreakIterator sentenceIterator = BreakIterator&lt;br /&gt;
        .getSentenceInstance(currentLocale);&lt;br /&gt;
    String someText = &amp;quot;She stopped.  &amp;quot;&lt;br /&gt;
        + &amp;quot;She said, \&amp;quot;Hello there,\&amp;quot; and then went on.&amp;quot;;&lt;br /&gt;
    markBoundaries(someText, sentenceIterator);&lt;br /&gt;
    String variousText = &amp;quot;He&amp;quot;s vanished!  &amp;quot;&lt;br /&gt;
        + &amp;quot;What will we do?  It&amp;quot;s up to us.&amp;quot;;&lt;br /&gt;
    markBoundaries(variousText, sentenceIterator);&lt;br /&gt;
    String decimalText = &amp;quot;Please add 1.5 liters to the tank.&amp;quot;;&lt;br /&gt;
    markBoundaries(decimalText, sentenceIterator);&lt;br /&gt;
    String donneText = &amp;quot;\&amp;quot;No man is an island . . . &amp;quot;&lt;br /&gt;
        + &amp;quot;every man . . . \&amp;quot;&amp;quot;;&lt;br /&gt;
    markBoundaries(donneText, sentenceIterator);&lt;br /&gt;
    String dogText = &amp;quot;My friend, Mr. Jones, has a new dog.  &amp;quot;&lt;br /&gt;
        + &amp;quot;The dog&amp;quot;s name is Spot.&amp;quot;;&lt;br /&gt;
    markBoundaries(dogText, sentenceIterator);&lt;br /&gt;
  }&lt;br /&gt;
  static void lineExamples() {&lt;br /&gt;
    Locale currentLocale = new Locale(&amp;quot;en&amp;quot;, &amp;quot;US&amp;quot;);&lt;br /&gt;
    BreakIterator lineIterator = BreakIterator&lt;br /&gt;
        .getLineInstance(currentLocale);&lt;br /&gt;
    String someText = &amp;quot;She stopped.  &amp;quot;&lt;br /&gt;
        + &amp;quot;She said, \&amp;quot;Hello there,\&amp;quot; and then went on.&amp;quot;;&lt;br /&gt;
    markBoundaries(someText, lineIterator);&lt;br /&gt;
    String hardHyphen = &amp;quot;There are twenty-four hours in a day.&amp;quot;;&lt;br /&gt;
    markBoundaries(hardHyphen, lineIterator);&lt;br /&gt;
    System.out.println();&lt;br /&gt;
    String moreText = &amp;quot;She said, \&amp;quot;Hello there,\&amp;quot; and then &amp;quot;&lt;br /&gt;
        + &amp;quot;went on down the street.  When she stopped &amp;quot;&lt;br /&gt;
        + &amp;quot;to look at the fur coats in a shop window, &amp;quot;&lt;br /&gt;
        + &amp;quot;her dog growled.  \&amp;quot;Sorry Jake,\&amp;quot; she said. &amp;quot;&lt;br /&gt;
        + &amp;quot; \&amp;quot;I didn&amp;quot;t know you would take it personally.\&amp;quot;&amp;quot;;&lt;br /&gt;
    formatLines(moreText, 30, currentLocale);&lt;br /&gt;
    System.out.println();&lt;br /&gt;
  }&lt;br /&gt;
  static public void main(String[] args) {&lt;br /&gt;
    characterExamples();&lt;br /&gt;
    System.out.println();&lt;br /&gt;
    wordExamples();&lt;br /&gt;
    System.out.println();&lt;br /&gt;
    sentenceExamples();&lt;br /&gt;
    System.out.println();&lt;br /&gt;
    lineExamples();&lt;br /&gt;
  }&lt;br /&gt;
} // class&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;
== Capitalizing each word in a sentence with loop ==&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;
public class Main {&lt;br /&gt;
  public static void main(String[] a) {&lt;br /&gt;
    String sentence = &amp;quot;this is a test&amp;quot;;&lt;br /&gt;
    String tmp = &amp;quot;&amp;quot;;&lt;br /&gt;
    String[] words = sentence.split(&amp;quot; &amp;quot;);&lt;br /&gt;
    for (int i = 0; i &amp;lt; words.length; i++) {&lt;br /&gt;
      tmp += words[i].substring(0, 1).toUpperCase();&lt;br /&gt;
      tmp += words[i].substring(1).toLowerCase();&lt;br /&gt;
      tmp += &amp;quot; &amp;quot;;&lt;br /&gt;
    }&lt;br /&gt;
    System.out.println(tmp.trim()); &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;
== Capitalizing each word in a sentence with recursive function ==&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;
public class Main {&lt;br /&gt;
  public static void main(String[] args) {&lt;br /&gt;
    String sentence = &amp;quot;this is a test&amp;quot;;&lt;br /&gt;
    System.out.println(capSentence(sentence, true));&lt;br /&gt;
  }&lt;br /&gt;
  public static String capSentence(String string, boolean capitalize) {&lt;br /&gt;
    if (string.length() == 0) {&lt;br /&gt;
      return &amp;quot;&amp;quot;;&lt;br /&gt;
    }&lt;br /&gt;
    String c = string.substring(0, 1);&lt;br /&gt;
    if (capitalize) {&lt;br /&gt;
      return c.toUpperCase() + capSentence(string.substring(1), c.equals(&amp;quot; &amp;quot;));&lt;br /&gt;
    } else {&lt;br /&gt;
      return c.toLowerCase() + capSentence(string.substring(1), c.equals(&amp;quot; &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;
== Character 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;
 * 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;
public class CharacterDemo {&lt;br /&gt;
  public static void main(String args[]) {&lt;br /&gt;
    Character a = new Character(&amp;quot;a&amp;quot;);&lt;br /&gt;
    Character a2 = new Character(&amp;quot;a&amp;quot;);&lt;br /&gt;
    Character b = new Character(&amp;quot;b&amp;quot;);&lt;br /&gt;
    int difference = a.rupareTo(b);&lt;br /&gt;
    if (difference == 0) {&lt;br /&gt;
      System.out.println(&amp;quot;a is equal to b.&amp;quot;);&lt;br /&gt;
    } else if (difference &amp;lt; 0) {&lt;br /&gt;
      System.out.println(&amp;quot;a is less than b.&amp;quot;);&lt;br /&gt;
    } else if (difference &amp;gt; 0) {&lt;br /&gt;
      System.out.println(&amp;quot;a is greater than b.&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
    System.out.println(&amp;quot;a is &amp;quot; + ((a.equals(a2)) ? &amp;quot;equal&amp;quot; : &amp;quot;not equal&amp;quot;)&lt;br /&gt;
        + &amp;quot; to a2.&amp;quot;);&lt;br /&gt;
    System.out.println(&amp;quot;The character &amp;quot; + a.toString() + &amp;quot; is &amp;quot;&lt;br /&gt;
        + (Character.isUpperCase(a.charValue()) ? &amp;quot;upper&amp;quot; : &amp;quot;lower&amp;quot;)&lt;br /&gt;
        + &amp;quot;case.&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;
== Keys 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;
/* From http://java.sun.ru/docs/books/tutorial/index.html */&lt;br /&gt;
/*&lt;br /&gt;
 * Copyright (c) 1995-1998 Sun Microsystems, Inc. All Rights Reserved.&lt;br /&gt;
 * &lt;br /&gt;
 * Permission to use, copy, modify, and distribute this software and its&lt;br /&gt;
 * documentation for NON-COMMERCIAL purposes and without fee is hereby granted&lt;br /&gt;
 * provided that this copyright notice appears in all copies. Please refer to&lt;br /&gt;
 * the file &amp;quot;copyright.html&amp;quot; for further important copyright and licensing&lt;br /&gt;
 * information.&lt;br /&gt;
 * &lt;br /&gt;
 * SUN MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE&lt;br /&gt;
 * SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED&lt;br /&gt;
 * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR&lt;br /&gt;
 * NON-INFRINGEMENT. SUN SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY&lt;br /&gt;
 * LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS&lt;br /&gt;
 * DERIVATIVES.&lt;br /&gt;
 */&lt;br /&gt;
import java.text.CollationKey;&lt;br /&gt;
import java.text.Collator;&lt;br /&gt;
import java.util.Locale;&lt;br /&gt;
public class KeysDemo {&lt;br /&gt;
  public static void sortArray(CollationKey[] keys) {&lt;br /&gt;
    CollationKey tmp;&lt;br /&gt;
    for (int i = 0; i &amp;lt; keys.length; i++) {&lt;br /&gt;
      for (int j = i + 1; j &amp;lt; keys.length; j++) {&lt;br /&gt;
        // Compare the keys&lt;br /&gt;
        if (keys[i].rupareTo(keys[j]) &amp;gt; 0) {&lt;br /&gt;
          // Swap keys[i] and keys[j]&lt;br /&gt;
          tmp = keys[i];&lt;br /&gt;
          keys[i] = keys[j];&lt;br /&gt;
          keys[j] = tmp;&lt;br /&gt;
        }&lt;br /&gt;
      }&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
  static void displayWords(CollationKey[] keys) {&lt;br /&gt;
    for (int i = 0; i &amp;lt; keys.length; i++) {&lt;br /&gt;
      System.out.println(keys[i].getSourceString());&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
  static public void main(String[] args) {&lt;br /&gt;
    Collator enUSCollator = Collator.getInstance(new Locale(&amp;quot;en&amp;quot;, &amp;quot;US&amp;quot;));&lt;br /&gt;
    String[] words = { &amp;quot;peach&amp;quot;, &amp;quot;apricot&amp;quot;, &amp;quot;grape&amp;quot;, &amp;quot;lemon&amp;quot; };&lt;br /&gt;
    CollationKey[] keys = new CollationKey[words.length];&lt;br /&gt;
    for (int k = 0; k &amp;lt; keys.length; k++) {&lt;br /&gt;
      keys[k] = enUSCollator.getCollationKey(words[k]);&lt;br /&gt;
    }&lt;br /&gt;
    sortArray(keys);&lt;br /&gt;
    displayWords(keys);&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;
== Rules 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;
/* From http://java.sun.ru/docs/books/tutorial/index.html */&lt;br /&gt;
/*&lt;br /&gt;
 * Copyright (c) 1995-1998 Sun Microsystems, Inc. All Rights Reserved.&lt;br /&gt;
 * &lt;br /&gt;
 * Permission to use, copy, modify, and distribute this software and its&lt;br /&gt;
 * documentation for NON-COMMERCIAL purposes and without fee is hereby granted&lt;br /&gt;
 * provided that this copyright notice appears in all copies. Please refer to&lt;br /&gt;
 * the file &amp;quot;copyright.html&amp;quot; for further important copyright and licensing&lt;br /&gt;
 * information.&lt;br /&gt;
 * &lt;br /&gt;
 * SUN MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE&lt;br /&gt;
 * SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED&lt;br /&gt;
 * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR&lt;br /&gt;
 * NON-INFRINGEMENT. SUN SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY&lt;br /&gt;
 * LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS&lt;br /&gt;
 * DERIVATIVES.&lt;br /&gt;
 */&lt;br /&gt;
import java.text.Collator;&lt;br /&gt;
import java.text.ParseException;&lt;br /&gt;
import java.text.RuleBasedCollator;&lt;br /&gt;
public class RulesDemo {&lt;br /&gt;
  public static void sortStrings(Collator collator, String[] words) {&lt;br /&gt;
    String tmp;&lt;br /&gt;
    for (int i = 0; i &amp;lt; words.length; i++) {&lt;br /&gt;
      for (int j = i + 1; j &amp;lt; words.length; j++) {&lt;br /&gt;
        // Compare elements of the words array&lt;br /&gt;
        if (collator.rupare(words[i], words[j]) &amp;gt; 0) {&lt;br /&gt;
          // Swap words[i] and words[j]&lt;br /&gt;
          tmp = words[i];&lt;br /&gt;
          words[i] = words[j];&lt;br /&gt;
          words[j] = tmp;&lt;br /&gt;
        }&lt;br /&gt;
      }&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
  public static void printStrings(String[] words) {&lt;br /&gt;
    for (int i = 0; i &amp;lt; words.length; i++) {&lt;br /&gt;
      System.out.println(words[i]);&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
  static public void main(String[] args) {&lt;br /&gt;
    String englishRules = (&amp;quot;&amp;lt; a,A &amp;lt; b,B &amp;lt; c,C &amp;lt; d,D &amp;lt; e,E &amp;lt; f,F &amp;quot;&lt;br /&gt;
        + &amp;quot;&amp;lt; g,G &amp;lt; h,H &amp;lt; i,I &amp;lt; j,J &amp;lt; k,K &amp;lt; l,L &amp;quot;&lt;br /&gt;
        + &amp;quot;&amp;lt; m,M &amp;lt; n,N &amp;lt; o,O &amp;lt; p,P &amp;lt; q,Q &amp;lt; r,R &amp;quot;&lt;br /&gt;
        + &amp;quot;&amp;lt; s,S &amp;lt; t,T &amp;lt; u,U &amp;lt; v,V &amp;lt; w,W &amp;lt; x,X &amp;quot; + &amp;quot;&amp;lt; y,Y &amp;lt; z,Z&amp;quot;);&lt;br /&gt;
    String smallnTilde = new String(&amp;quot;\u00F1&amp;quot;);&lt;br /&gt;
    String capitalNTilde = new String(&amp;quot;\u00D1&amp;quot;);&lt;br /&gt;
    String traditionalSpanishRules = (&amp;quot;&amp;lt; a,A &amp;lt; b,B &amp;lt; c,C &amp;quot;&lt;br /&gt;
        + &amp;quot;&amp;lt; ch, cH, Ch, CH &amp;quot; + &amp;quot;&amp;lt; d,D &amp;lt; e,E &amp;lt; f,F &amp;quot;&lt;br /&gt;
        + &amp;quot;&amp;lt; g,G &amp;lt; h,H &amp;lt; i,I &amp;lt; j,J &amp;lt; k,K &amp;lt; l,L &amp;quot; + &amp;quot;&amp;lt; ll, lL, Ll, LL &amp;quot;&lt;br /&gt;
        + &amp;quot;&amp;lt; m,M &amp;lt; n,N &amp;quot; + &amp;quot;&amp;lt; &amp;quot; + smallnTilde + &amp;quot;,&amp;quot; + capitalNTilde&lt;br /&gt;
        + &amp;quot; &amp;quot; + &amp;quot;&amp;lt; o,O &amp;lt; p,P &amp;lt; q,Q &amp;lt; r,R &amp;quot;&lt;br /&gt;
        + &amp;quot;&amp;lt; s,S &amp;lt; t,T &amp;lt; u,U &amp;lt; v,V &amp;lt; w,W &amp;lt; x,X &amp;quot; + &amp;quot;&amp;lt; y,Y &amp;lt; z,Z&amp;quot;);&lt;br /&gt;
    String[] words = { &amp;quot;luz&amp;quot;, &amp;quot;curioso&amp;quot;, &amp;quot;llama&amp;quot;, &amp;quot;chalina&amp;quot; };&lt;br /&gt;
    try {&lt;br /&gt;
      RuleBasedCollator enCollator = new RuleBasedCollator(englishRules);&lt;br /&gt;
      RuleBasedCollator spCollator = new RuleBasedCollator(&lt;br /&gt;
          traditionalSpanishRules);&lt;br /&gt;
      sortStrings(enCollator, words);&lt;br /&gt;
      printStrings(words);&lt;br /&gt;
      System.out.println();&lt;br /&gt;
      sortStrings(spCollator, words);&lt;br /&gt;
      printStrings(words);&lt;br /&gt;
    } catch (ParseException pe) {&lt;br /&gt;
      System.out.println(&amp;quot;Parse exception for rules&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;/div&gt;</summary>
			</entry>

	</feed>