home *** CD-ROM | disk | FTP | other *** search
Java Source | 1997-07-30 | 1.4 KB | 49 lines |
- // Copyright(c) 1997 ObjectSpace, Inc.
-
- import COM.objectspace.jgl.*;
- import java.text.Collator;
- import java.text.CollationKey;
- import java.util.Enumeration;
-
- /**
- * Comparison of CollationKeys.
- *
- * @see COM.objectspace.jgl.LessCollationKey
- * @see COM.objectspace.jgl.LessEqualCollationKey
- * @see COM.objectspace.jgl.GreaterCollationKey
- * @see COM.objectspace.jgl.GreaterEqualCollationKey
- * @see java.text.Collator
- * @see java.text.CollationKey
- * @version 2.0.2
- * @author ObjectSpace, Inc.
- */
-
- public class Collate2
- {
- public static void show( String tag, Collator collator )
- {
- // allow duplicates in set
- OrderedSet set = new OrderedSet( new LessCollationKey(), true );
-
- // add a few entries
- set.add( collator.getCollationKey( "Texas" ) );
- set.add( collator.getCollationKey( "texas" ) );
- set.add( collator.getCollationKey( "Texas Fight" ) );
-
- // print the resulting container
- System.out.println( tag );
- Enumeration iterator = set.begin();
- while ( iterator.hasMoreElements() )
- System.out.println( "\t" + ( (CollationKey)iterator.nextElement() ).getSourceString() );
- }
-
- public static void main( String args[] )
- {
- Collator collator = Collator.getInstance();
- show( "default collating", collator );
-
- collator.setStrength( Collator.PRIMARY );
- show( "case insensitive", collator );
- }
- }
-