commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From roxspr...@apache.org
Subject cvs commit: jakarta-commons/cli/src/java/org/apache/commons/cli2 GroupImpl.java StringComparator.java
Date Sun, 01 Feb 2004 23:41:57 GMT
roxspring    2004/02/01 15:41:57

  Modified:    cli/src/java/org/apache/commons/cli2 Tag:
                        RESEARCH_CLI_2_ROXSPRING GroupImpl.java
  Removed:     cli/src/java/org/apache/commons/cli2 Tag:
                        RESEARCH_CLI_2_ROXSPRING StringComparator.java
  Log:
  StringComparator was only being used by GroupImpl and only in reverse.
  An optimised comparator has been placed in GroupImpl.java instead
  
  Revision  Changes    Path
  No                   revision
  No                   revision
  1.1.2.5   +24 -2     jakarta-commons/cli/src/java/org/apache/commons/cli2/Attic/GroupImpl.java
  
  Index: GroupImpl.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/cli/src/java/org/apache/commons/cli2/Attic/GroupImpl.java,v
  retrieving revision 1.1.2.4
  retrieving revision 1.1.2.5
  diff -u -r1.1.2.4 -r1.1.2.5
  --- GroupImpl.java	31 Jan 2004 16:17:09 -0000	1.1.2.4
  +++ GroupImpl.java	1 Feb 2004 23:41:57 -0000	1.1.2.5
  @@ -96,7 +96,7 @@
   		this.options = Collections.unmodifiableList(optionsCopy);
   		
   		final List anonymous = new ArrayList();
  -		final SortedMap optionMap = new TreeMap(StringComparator.getReverseInstance());
  +		final SortedMap optionMap = new TreeMap(ReverseStringComparator.getInstance());
   		for (final Iterator i = optionsCopy.iterator(); i.hasNext();) {
   			final Option option = (Option) i.next();
   
  @@ -413,4 +413,26 @@
   		return helpLines;
   	}
   
  -}
  \ No newline at end of file
  +}
  +
  +class ReverseStringComparator implements Comparator {
  +    private static final Comparator instance = new ReverseStringComparator();
  +
  +    public static final Comparator getInstance() {
  +        return instance;
  +    }
  +    
  +    private ReverseStringComparator(){
  +        // just making sure nobody else creates one
  +    }
  +
  +    /* (non-Javadoc)
  +     * @see java.util.Comparator#compare(java.lang.Object, java.lang.Object)
  +     */
  +    public int compare(final Object o1, final Object o2) {
  +        final String s1 = (String) o1;
  +        final String s2 = (String) o2;
  +
  +        return -s1.compareTo(s2);
  +    }
  +}
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message