/* * [Comparators.java] * * Summary: Test harness for comparators. Not needed in actual applications. * * Copyright: (c) 2002-2017 Roedy Green, Canadian Mind Products, http://mindprod.com * * Licence: This software may be copied and used freely for any purpose but military. * http://mindprod.com/contact/nonmil.html * * Requires: JDK 1.8+ * * Created with: JetBrains IntelliJ IDEA IDE http://www.jetbrains.com/idea/ * * Version History: * 1.1 2005-07-04 Updated to add java 1.5 type checking. * 1.2 2007-03-26 * 1.3 2007-04-06 tidy code. * 1.4 2007-05-22 add icon and PAD. */ package com.mindprod.comparators; import java.util.Arrays; import static java.lang.System.*; /** * Test harness for comparators. Not needed in actual applications. *

* * @author Roedy Green, Canadian Mind Products * @version 1.4 2007-05-22 add icon and PAD. * @noinspection WeakerAccess * @since 2002 */ public final class Comparators { private static final int FIRST_COPYRIGHT_YEAR = 2002; /** * undisplayed copyright notice */ @SuppressWarnings( { "UnusedDeclaration" } ) private static final String EMBEDDED_COPYRIGHT = "Copyright: (c) 2002-2017 Roedy Green, Canadian Mind Products, http://mindprod.com"; /** * when package was released. * * @noinspection UnusedDeclaration */ private static final String RELEASE_DATE = "2007-05-22"; /** * name of package. * * @noinspection UnusedDeclaration */ private static final String TITLE_STRING = "Comparators"; /** * version of package. * * @noinspection UnusedDeclaration */ private static final String VERSION_STRING = "1.4"; /** * TEST harness to TEST Comparators 2005-07-02 converted to Java 1.5 * * @param args not used */ public static void main( String[] args ) { // TEST case-sensitive compare String[] sen = new String[] { "rabbit", "Rabbit", "cow", "squirrel" }; Arrays.sort( sen, new StringComparator() ); for ( String aSen : sen ) { out.println( aSen ); } // TEST case-insensitive compare String[] ig = new String[] { "whale", "Whale", "bird", "manatee" }; Arrays.sort( ig, new StringComparatorIgnoreCase() ); for ( String anIg : ig ) { out.println( anIg ); } // TEST HTML ignoring compare String[] ht = new String[] { " BIRD", "bird", "bird", "birch" }; Arrays.sort( ht, new HTMLComparator() ); for ( String aHt : ht ) { out.println( aHt + ":" + HTMLComparator.flatten( aHt ) ); } } }