commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bay...@apache.org
Subject svn commit: r829282 - in /commons/proper/lang/trunk/src: java/org/apache/commons/lang/CharRange.java java/org/apache/commons/lang/CharSet.java test/org/apache/commons/lang/CharRangeTest.java test/org/apache/commons/lang/CharSetTest.java
Date Fri, 23 Oct 2009 23:59:02 GMT
Author: bayard
Date: Fri Oct 23 23:59:02 2009
New Revision: 829282

URL: http://svn.apache.org/viewvc?rev=829282&view=rev
Log:
Applying patch from LANG-514. CharRange constructors removed and replaced with readable static
builder methods

Modified:
    commons/proper/lang/trunk/src/java/org/apache/commons/lang/CharRange.java
    commons/proper/lang/trunk/src/java/org/apache/commons/lang/CharSet.java
    commons/proper/lang/trunk/src/test/org/apache/commons/lang/CharRangeTest.java
    commons/proper/lang/trunk/src/test/org/apache/commons/lang/CharSetTest.java

Modified: commons/proper/lang/trunk/src/java/org/apache/commons/lang/CharRange.java
URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/java/org/apache/commons/lang/CharRange.java?rev=829282&r1=829281&r2=829282&view=diff
==============================================================================
--- commons/proper/lang/trunk/src/java/org/apache/commons/lang/CharRange.java (original)
+++ commons/proper/lang/trunk/src/java/org/apache/commons/lang/CharRange.java Fri Oct 23 23:59:02
2009
@@ -48,27 +48,51 @@
     /** Cached toString. */
     private transient String iToString;
 
-    //-----------------------------------------------------------------------
+    /**
+     * <p>Constructs a <code>CharRange</code> over a set of characters,
+     * optionally negating the range.</p>
+     *
+     * <p>A negated range includes everything except that defined by the
+     * start and end characters.</p>
+     * 
+     * <p>If start and end are in the wrong order, they are reversed.
+     * Thus <code>a-e</code> is the same as <code>e-a</code>.</p>
+     *
+     * @param start  first character, inclusive, in this range
+     * @param end  last character, inclusive, in this range
+     * @param negated  true to express everything except the range
+     */
+    private CharRange(char start, char end, boolean negated) {
+        super();
+        if (start > end) {
+            char temp = start;
+            start = end;
+            end = temp;
+        }
+        
+        this.start = start;
+        this.end = end;
+        this.negated = negated;
+    }
+
     /**
      * <p>Constructs a <code>CharRange</code> over a single character.</p>
      *
      * @param ch  only character in this range
+     * @see CharRange#CharRange(char, boolean)
      */
-    public CharRange(char ch) {
-        this(ch, ch, false);
+    public static CharRange is(char ch) {
+        return new CharRange(ch, ch, false);
     }
 
     /**
-     * <p>Constructs a <code>CharRange</code> over a single character,
-     * optionally negating the range.</p>
-     *
-     * <p>A negated range includes everything except the specified char.</p>
+     * <p>Constructs a negated <code>CharRange</code> over a single character.</p>
      *
      * @param ch  only character in this range
-     * @param negated  true to express everything except the range
+     * @see CharRange#CharRange(char, boolean)
      */
-    public CharRange(char ch, boolean negated) {
-        this(ch, ch, negated);
+    public static CharRange isNot(char ch) {
+        return new CharRange(ch, ch, true);
     }
 
     /**
@@ -76,36 +100,21 @@
      *
      * @param start  first character, inclusive, in this range
      * @param end  last character, inclusive, in this range
+     * @see CharRange#CharRange(char, char, boolean)
      */
-    public CharRange(char start, char end) {
-        this(start, end, false);
+    public static CharRange isIn(char start, char end) {
+        return new CharRange(start, end, false);
     }
 
     /**
-     * <p>Constructs a <code>CharRange</code> over a set of characters,
-     * optionally negating the range.</p>
-     *
-     * <p>A negated range includes everything except that defined by the
-     * start and end characters.</p>
-     * 
-     * <p>If start and end are in the wrong order, they are reversed.
-     * Thus <code>a-e</code> is the same as <code>e-a</code>.</p>
+     * <p>Constructs a negated <code>CharRange</code> over a set of characters.</p>
      *
      * @param start  first character, inclusive, in this range
      * @param end  last character, inclusive, in this range
-     * @param negated  true to express everything except the range
+     * @see CharRange#CharRange(char, char, boolean)
      */
-    public CharRange(char start, char end, boolean negated) {
-        super();
-        if (start > end) {
-            char temp = start;
-            start = end;
-            end = temp;
-        }
-        
-        this.start = start;
-        this.end = end;
-        this.negated = negated;
+    public static CharRange isNotIn(char start, char end) {
+        return new CharRange(start, end, true);
     }
 
     // Accessors

Modified: commons/proper/lang/trunk/src/java/org/apache/commons/lang/CharSet.java
URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/java/org/apache/commons/lang/CharSet.java?rev=829282&r1=829281&r2=829282&view=diff
==============================================================================
--- commons/proper/lang/trunk/src/java/org/apache/commons/lang/CharSet.java (original)
+++ commons/proper/lang/trunk/src/java/org/apache/commons/lang/CharSet.java Fri Oct 23 23:59:02
2009
@@ -204,19 +204,19 @@
             int remainder = (len - pos);
             if (remainder >= 4 && str.charAt(pos) == '^' && str.charAt(pos
+ 2) == '-') {
                 // negated range
-                set.add(new CharRange(str.charAt(pos + 1), str.charAt(pos + 3), true));
+                set.add(CharRange.isNotIn(str.charAt(pos + 1), str.charAt(pos + 3)));
                 pos += 4;
             } else if (remainder >= 3 && str.charAt(pos + 1) == '-') {
                 // range
-                set.add(new CharRange(str.charAt(pos), str.charAt(pos + 2)));
+                set.add(CharRange.isIn(str.charAt(pos), str.charAt(pos + 2)));
                 pos += 3;
             } else if (remainder >= 2 && str.charAt(pos) == '^') {
                 // negated char
-                set.add(new CharRange(str.charAt(pos + 1), true));
+                set.add(CharRange.isNot(str.charAt(pos + 1)));
                 pos += 2;
             } else {
                 // char
-                set.add(new CharRange(str.charAt(pos)));
+                set.add(CharRange.is(str.charAt(pos)));
                 pos += 1;
             }
         }

Modified: commons/proper/lang/trunk/src/test/org/apache/commons/lang/CharRangeTest.java
URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/test/org/apache/commons/lang/CharRangeTest.java?rev=829282&r1=829281&r2=829282&view=diff
==============================================================================
--- commons/proper/lang/trunk/src/test/org/apache/commons/lang/CharRangeTest.java (original)
+++ commons/proper/lang/trunk/src/test/org/apache/commons/lang/CharRangeTest.java Fri Oct
23 23:59:02 2009
@@ -62,98 +62,66 @@
         assertEquals(true, Modifier.isPublic(CharRange.class.getModifiers()));
         assertEquals(true, Modifier.isFinal(CharRange.class.getModifiers()));
     }
-    
+
     //-----------------------------------------------------------------------
-    public void testConstructorAccessors_Char() {
-        CharRange rangea = new CharRange('a');
-        assertEquals('a', rangea.getStart());
-        assertEquals('a', rangea.getEnd());
-        assertEquals(false, rangea.isNegated());
-        assertEquals("a", rangea.toString());
-    }
-    
-    public void testConstructorAccessors_CharBoolean_Normal() {
-        CharRange rangea = new CharRange('a');
+    public void testConstructorAccessors_is() {
+        CharRange rangea = CharRange.is('a');
         assertEquals('a', rangea.getStart());
         assertEquals('a', rangea.getEnd());
         assertEquals(false, rangea.isNegated());
         assertEquals("a", rangea.toString());
     }
     
-    public void testConstructorAccessors_CharBoolean_Negated() {
-        CharRange rangea = new CharRange('a', true);
+    public void testConstructorAccessors_isNot() {
+        CharRange rangea = CharRange.isNot('a');
         assertEquals('a', rangea.getStart());
         assertEquals('a', rangea.getEnd());
         assertEquals(true, rangea.isNegated());
         assertEquals("^a", rangea.toString());
     }
     
-    public void testConstructorAccessors_CharChar_Same() {
-        CharRange rangea = new CharRange('a', 'a');
+    public void testConstructorAccessors_isIn_Same() {
+        CharRange rangea = CharRange.isIn('a', 'a');
         assertEquals('a', rangea.getStart());
         assertEquals('a', rangea.getEnd());
         assertEquals(false, rangea.isNegated());
         assertEquals("a", rangea.toString());
     }
     
-    public void testConstructorAccessors_CharChar_Normal() {
-        CharRange rangea = new CharRange('a', 'e');
+    public void testConstructorAccessors_isIn_Normal() {
+        CharRange rangea = CharRange.isIn('a', 'e');
         assertEquals('a', rangea.getStart());
         assertEquals('e', rangea.getEnd());
         assertEquals(false, rangea.isNegated());
         assertEquals("a-e", rangea.toString());
     }
     
-    public void testConstructorAccessors_CharChar_Reversed() {
-        CharRange rangea = new CharRange('e', 'a');
+    public void testConstructorAccessors_isIn_Reversed() {
+        CharRange rangea = CharRange.isIn('e', 'a');
         assertEquals('a', rangea.getStart());
         assertEquals('e', rangea.getEnd());
         assertEquals(false, rangea.isNegated());
         assertEquals("a-e", rangea.toString());
     }
     
-    public void testConstructorAccessors_CharCharBoolean_Same() {
-        CharRange rangea = new CharRange('a', 'a', false);
-        assertEquals('a', rangea.getStart());
-        assertEquals('a', rangea.getEnd());
-        assertEquals(false, rangea.isNegated());
-        assertEquals("a", rangea.toString());
-    }
-    
-    public void testConstructorAccessors_CharCharBoolean_Normal() {
-        CharRange rangea = new CharRange('a', 'e', false);
-        assertEquals('a', rangea.getStart());
-        assertEquals('e', rangea.getEnd());
-        assertEquals(false, rangea.isNegated());
-        assertEquals("a-e", rangea.toString());
-    }
-    
-    public void testConstructorAccessors_CharCharBoolean_Reversed() {
-        CharRange rangea = new CharRange('e', 'a', false);
-        assertEquals('a', rangea.getStart());
-        assertEquals('e', rangea.getEnd());
-        assertEquals(false, rangea.isNegated());
-        assertEquals("a-e", rangea.toString());
-    }
-    
-    public void testConstructorAccessors_CharCharBoolean_SameNegated() {
-        CharRange rangea = new CharRange('a', 'a', true);
+    public void testConstructorAccessors_isNotIn_Same() {
+        CharRange rangea = CharRange.isNotIn('a', 'a');
         assertEquals('a', rangea.getStart());
         assertEquals('a', rangea.getEnd());
         assertEquals(true, rangea.isNegated());
         assertEquals("^a", rangea.toString());
     }
     
-    public void testConstructorAccessors_CharCharBoolean_NormalNegated() {
-        CharRange rangea = new CharRange('a', 'e', true);
+    public void testConstructorAccessors_isNotIn_Normal() {
+        CharRange rangea = CharRange.isNotIn('a', 'e');
         assertEquals('a', rangea.getStart());
         assertEquals('e', rangea.getEnd());
         assertEquals(true, rangea.isNegated());
         assertEquals("^a-e", rangea.toString());
     }
     
-    public void testConstructorAccessors_CharCharBoolean_ReversedNegated() {
-        CharRange rangea = new CharRange('e', 'a', true);
+    public void testConstructorAccessors_isNotIn_Reversed() {
+        CharRange rangea = CharRange.isNotIn('e', 'a');
         assertEquals('a', rangea.getStart());
         assertEquals('e', rangea.getEnd());
         assertEquals(true, rangea.isNegated());
@@ -162,18 +130,18 @@
 
     //-----------------------------------------------------------------------    
     public void testEquals_Object() {
-        CharRange rangea = new CharRange('a');
-        CharRange rangeae = new CharRange('a', 'e');
-        CharRange rangenotbf = new CharRange('b', 'f', false);
+        CharRange rangea = CharRange.is('a');
+        CharRange rangeae = CharRange.isIn('a', 'e');
+        CharRange rangenotbf = CharRange.isIn('b', 'f');
         
         assertEquals(false, rangea.equals(null));
         
         assertEquals(true, rangea.equals(rangea));
-        assertEquals(true, rangea.equals(new CharRange('a')));
+        assertEquals(true, rangea.equals(CharRange.is('a')));
         assertEquals(true, rangeae.equals(rangeae));
-        assertEquals(true, rangeae.equals(new CharRange('a', 'e')));
+        assertEquals(true, rangeae.equals(CharRange.isIn('a', 'e')));
         assertEquals(true, rangenotbf.equals(rangenotbf));
-        assertEquals(true, rangenotbf.equals(new CharRange('b', 'f', false)));
+        assertEquals(true, rangenotbf.equals(CharRange.isIn('b', 'f')));
         
         assertEquals(false, rangea.equals(rangeae));
         assertEquals(false, rangea.equals(rangenotbf));
@@ -184,16 +152,16 @@
     }
             
     public void testHashCode() {
-        CharRange rangea = new CharRange('a');
-        CharRange rangeae = new CharRange('a', 'e');
-        CharRange rangenotbf = new CharRange('b', 'f', false);
+        CharRange rangea = CharRange.is('a');
+        CharRange rangeae = CharRange.isIn('a', 'e');
+        CharRange rangenotbf = CharRange.isIn('b', 'f');
         
         assertEquals(true, rangea.hashCode() == rangea.hashCode());
-        assertEquals(true, rangea.hashCode() == new CharRange('a').hashCode());
+        assertEquals(true, rangea.hashCode() == CharRange.is('a').hashCode());
         assertEquals(true, rangeae.hashCode() == rangeae.hashCode());
-        assertEquals(true, rangeae.hashCode() == new CharRange('a', 'e').hashCode());
+        assertEquals(true, rangeae.hashCode() == CharRange.isIn('a', 'e').hashCode());
         assertEquals(true, rangenotbf.hashCode() == rangenotbf.hashCode());
-        assertEquals(true, rangenotbf.hashCode() == new CharRange('b', 'f', false).hashCode());
+        assertEquals(true, rangenotbf.hashCode() == CharRange.isIn('b', 'f').hashCode());
         
         assertEquals(false, rangea.hashCode() == rangeae.hashCode());
         assertEquals(false, rangea.hashCode() == rangenotbf.hashCode());
@@ -205,31 +173,25 @@
     
     //-----------------------------------------------------------------------    
     public void testContains_Char() {
-        CharRange range = new CharRange('c');
+        CharRange range = CharRange.is('c');
         assertEquals(false, range.contains('b'));
         assertEquals(true, range.contains('c'));
         assertEquals(false, range.contains('d'));
         assertEquals(false, range.contains('e'));
         
-        range = new CharRange('c', 'd');
-        assertEquals(false, range.contains('b'));
-        assertEquals(true, range.contains('c'));
-        assertEquals(true, range.contains('d'));
-        assertEquals(false, range.contains('e'));
-        
-        range = new CharRange('d', 'c');
+        range = CharRange.isIn('c', 'd');
         assertEquals(false, range.contains('b'));
         assertEquals(true, range.contains('c'));
         assertEquals(true, range.contains('d'));
         assertEquals(false, range.contains('e'));
         
-        range = new CharRange('c', 'd', false);
+        range = CharRange.isIn('d', 'c');
         assertEquals(false, range.contains('b'));
         assertEquals(true, range.contains('c'));
         assertEquals(true, range.contains('d'));
         assertEquals(false, range.contains('e'));
         
-        range = new CharRange('c', 'd', true);
+        range = CharRange.isNotIn('c', 'd');
         assertEquals(true, range.contains('b'));
         assertEquals(false, range.contains('c'));
         assertEquals(false, range.contains('d'));
@@ -240,19 +202,19 @@
     
     //-----------------------------------------------------------------------    
     public void testContains_Charrange() {
-        CharRange a = new CharRange('a');
-        CharRange b = new CharRange('b');
-        CharRange c = new CharRange('c');
-        CharRange c2 = new CharRange('c');
-        CharRange d = new CharRange('d');
-        CharRange e = new CharRange('e');
-        CharRange cd = new CharRange('c', 'd');
-        CharRange bd = new CharRange('b', 'd');
-        CharRange bc = new CharRange('b', 'c');
-        CharRange ab = new CharRange('a', 'b');
-        CharRange de = new CharRange('d', 'e');
-        CharRange ef = new CharRange('e', 'f');
-        CharRange ae = new CharRange('a', 'e');
+        CharRange a = CharRange.is('a');
+        CharRange b = CharRange.is('b');
+        CharRange c = CharRange.is('c');
+        CharRange c2 = CharRange.is('c');
+        CharRange d = CharRange.is('d');
+        CharRange e = CharRange.is('e');
+        CharRange cd = CharRange.isIn('c', 'd');
+        CharRange bd = CharRange.isIn('b', 'd');
+        CharRange bc = CharRange.isIn('b', 'c');
+        CharRange ab = CharRange.isIn('a', 'b');
+        CharRange de = CharRange.isIn('d', 'e');
+        CharRange ef = CharRange.isIn('e', 'f');
+        CharRange ae = CharRange.isIn('a', 'e');
         
         // normal/normal
         assertEquals(false, c.contains(b));
@@ -278,17 +240,17 @@
         assertEquals(true, ae.contains(cd));
         assertEquals(true, ae.contains(de));
         
-        CharRange notb = new CharRange('b', 'b', true);
-        CharRange notc = new CharRange('c', 'c', true);
-        CharRange notd = new CharRange('d', 'd', true);
-        CharRange notab = new CharRange('a', 'b', true);
-        CharRange notbc = new CharRange('b', 'c', true);
-        CharRange notbd = new CharRange('b', 'd', true);
-        CharRange notcd = new CharRange('c', 'd', true);
-        CharRange notde = new CharRange('d', 'e', true);
-        CharRange notae = new CharRange('a', 'e', true);
-        CharRange all = new CharRange((char) 0, Character.MAX_VALUE);
-        CharRange allbutfirst = new CharRange((char) 1, Character.MAX_VALUE);
+        CharRange notb = CharRange.isNot('b');
+        CharRange notc = CharRange.isNot('c');
+        CharRange notd = CharRange.isNot('d');
+        CharRange notab = CharRange.isNotIn('a', 'b');
+        CharRange notbc = CharRange.isNotIn('b', 'c');
+        CharRange notbd = CharRange.isNotIn('b', 'd');
+        CharRange notcd = CharRange.isNotIn('c', 'd');
+        CharRange notde = CharRange.isNotIn('d', 'e');
+        CharRange notae = CharRange.isNotIn('a', 'e');
+        CharRange all = CharRange.isIn((char) 0, Character.MAX_VALUE);
+        CharRange allbutfirst = CharRange.isIn((char) 1, Character.MAX_VALUE);
         
         // normal/negated
         assertEquals(false, c.contains(notc));
@@ -354,7 +316,7 @@
     }
     
     public void testContainsNullArg() {
-        CharRange range = new CharRange('a');
+        CharRange range = CharRange.is('a');
         try {
             @SuppressWarnings("unused")
             boolean contains = range.contains(null);
@@ -365,11 +327,11 @@
     
     //-----------------------------------------------------------------------    
     public void testSerialization() {
-        CharRange range = new CharRange('a');
+        CharRange range = CharRange.is('a');
         assertEquals(range, SerializationUtils.clone(range)); 
-        range = new CharRange('a', 'e');
+        range = CharRange.isIn('a', 'e');
         assertEquals(range, SerializationUtils.clone(range)); 
-        range = new CharRange('a', 'e', true);
+        range = CharRange.isNotIn('a', 'e');
         assertEquals(range, SerializationUtils.clone(range)); 
     }
     

Modified: commons/proper/lang/trunk/src/test/org/apache/commons/lang/CharSetTest.java
URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/test/org/apache/commons/lang/CharSetTest.java?rev=829282&r1=829281&r2=829282&view=diff
==============================================================================
--- commons/proper/lang/trunk/src/test/org/apache/commons/lang/CharSetTest.java (original)
+++ commons/proper/lang/trunk/src/test/org/apache/commons/lang/CharSetTest.java Fri Oct 23
23:59:02 2009
@@ -130,35 +130,35 @@
         set = CharSet.getInstance("abc");
         array = set.getCharRanges();
         assertEquals(3, array.length);
-        assertEquals(true, ArrayUtils.contains(array, new CharRange('a')));
-        assertEquals(true, ArrayUtils.contains(array, new CharRange('b')));
-        assertEquals(true, ArrayUtils.contains(array, new CharRange('c')));
+        assertEquals(true, ArrayUtils.contains(array, CharRange.is('a')));
+        assertEquals(true, ArrayUtils.contains(array, CharRange.is('b')));
+        assertEquals(true, ArrayUtils.contains(array, CharRange.is('c')));
         
         set = CharSet.getInstance("a-ce-f");
         array = set.getCharRanges();
         assertEquals(2, array.length);
-        assertEquals(true, ArrayUtils.contains(array, new CharRange('a', 'c')));
-        assertEquals(true, ArrayUtils.contains(array, new CharRange('e', 'f')));
+        assertEquals(true, ArrayUtils.contains(array, CharRange.isIn('a', 'c')));
+        assertEquals(true, ArrayUtils.contains(array, CharRange.isIn('e', 'f')));
         
         set = CharSet.getInstance("ae-f");
         array = set.getCharRanges();
         assertEquals(2, array.length);
-        assertEquals(true, ArrayUtils.contains(array, new CharRange('a')));
-        assertEquals(true, ArrayUtils.contains(array, new CharRange('e', 'f')));
+        assertEquals(true, ArrayUtils.contains(array, CharRange.is('a')));
+        assertEquals(true, ArrayUtils.contains(array, CharRange.isIn('e', 'f')));
         
         set = CharSet.getInstance("e-fa");
         array = set.getCharRanges();
         assertEquals(2, array.length);
-        assertEquals(true, ArrayUtils.contains(array, new CharRange('a')));
-        assertEquals(true, ArrayUtils.contains(array, new CharRange('e', 'f')));
+        assertEquals(true, ArrayUtils.contains(array, CharRange.is('a')));
+        assertEquals(true, ArrayUtils.contains(array, CharRange.isIn('e', 'f')));
         
         set = CharSet.getInstance("ae-fm-pz");
         array = set.getCharRanges();
         assertEquals(4, array.length);
-        assertEquals(true, ArrayUtils.contains(array, new CharRange('a')));
-        assertEquals(true, ArrayUtils.contains(array, new CharRange('e', 'f')));
-        assertEquals(true, ArrayUtils.contains(array, new CharRange('m', 'p')));
-        assertEquals(true, ArrayUtils.contains(array, new CharRange('z')));
+        assertEquals(true, ArrayUtils.contains(array, CharRange.is('a')));
+        assertEquals(true, ArrayUtils.contains(array, CharRange.isIn('e', 'f')));
+        assertEquals(true, ArrayUtils.contains(array, CharRange.isIn('m', 'p')));
+        assertEquals(true, ArrayUtils.contains(array, CharRange.is('z')));
     }
     
     public void testConstructor_String_comboNegated() {
@@ -168,39 +168,39 @@
         set = CharSet.getInstance("^abc");
         array = set.getCharRanges();
         assertEquals(3, array.length);
-        assertEquals(true, ArrayUtils.contains(array, new CharRange('a', 'a', true)));
-        assertEquals(true, ArrayUtils.contains(array, new CharRange('b')));
-        assertEquals(true, ArrayUtils.contains(array, new CharRange('c')));
+        assertEquals(true, ArrayUtils.contains(array, CharRange.isNot('a')));
+        assertEquals(true, ArrayUtils.contains(array, CharRange.is('b')));
+        assertEquals(true, ArrayUtils.contains(array, CharRange.is('c')));
         
         set = CharSet.getInstance("b^ac");
         array = set.getCharRanges();
         assertEquals(3, array.length);
-        assertEquals(true, ArrayUtils.contains(array, new CharRange('b')));
-        assertEquals(true, ArrayUtils.contains(array, new CharRange('a', 'a', true)));
-        assertEquals(true, ArrayUtils.contains(array, new CharRange('c')));
+        assertEquals(true, ArrayUtils.contains(array, CharRange.is('b')));
+        assertEquals(true, ArrayUtils.contains(array, CharRange.isNot('a')));
+        assertEquals(true, ArrayUtils.contains(array, CharRange.is('c')));
         
         set = CharSet.getInstance("db^ac");
         array = set.getCharRanges();
         assertEquals(4, array.length);
-        assertEquals(true, ArrayUtils.contains(array, new CharRange('d')));
-        assertEquals(true, ArrayUtils.contains(array, new CharRange('b')));
-        assertEquals(true, ArrayUtils.contains(array, new CharRange('a', 'a', true)));
-        assertEquals(true, ArrayUtils.contains(array, new CharRange('c')));
+        assertEquals(true, ArrayUtils.contains(array, CharRange.is('d')));
+        assertEquals(true, ArrayUtils.contains(array, CharRange.is('b')));
+        assertEquals(true, ArrayUtils.contains(array, CharRange.isNot('a')));
+        assertEquals(true, ArrayUtils.contains(array, CharRange.is('c')));
         
         set = CharSet.getInstance("^b^a");
         array = set.getCharRanges();
         assertEquals(2, array.length);
-        assertEquals(true, ArrayUtils.contains(array, new CharRange('b', 'b', true)));
-        assertEquals(true, ArrayUtils.contains(array, new CharRange('a', 'a', true)));
+        assertEquals(true, ArrayUtils.contains(array, CharRange.isNot('b')));
+        assertEquals(true, ArrayUtils.contains(array, CharRange.isNot('a')));
         
         set = CharSet.getInstance("b^a-c^z");
         array = set.getCharRanges();
         assertEquals(3, array.length);
-        assertEquals(true, ArrayUtils.contains(array, new CharRange('a', 'c', true)));
-        assertEquals(true, ArrayUtils.contains(array, new CharRange('z', 'z', true)));
-        assertEquals(true, ArrayUtils.contains(array, new CharRange('b')));
+        assertEquals(true, ArrayUtils.contains(array, CharRange.isNotIn('a', 'c')));
+        assertEquals(true, ArrayUtils.contains(array, CharRange.isNot('z')));
+        assertEquals(true, ArrayUtils.contains(array, CharRange.is('b')));
     }
-        
+
     public void testConstructor_String_oddDash() {
         CharSet set;
         CharRange[] array;
@@ -208,44 +208,44 @@
         set = CharSet.getInstance("-");
         array = set.getCharRanges();
         assertEquals(1, array.length);
-        assertEquals(true, ArrayUtils.contains(array, new CharRange('-')));
+        assertEquals(true, ArrayUtils.contains(array, CharRange.is('-')));
         
         set = CharSet.getInstance("--");
         array = set.getCharRanges();
         assertEquals(1, array.length);
-        assertEquals(true, ArrayUtils.contains(array, new CharRange('-')));
+        assertEquals(true, ArrayUtils.contains(array, CharRange.is('-')));
         
         set = CharSet.getInstance("---");
         array = set.getCharRanges();
         assertEquals(1, array.length);
-        assertEquals(true, ArrayUtils.contains(array, new CharRange('-')));
+        assertEquals(true, ArrayUtils.contains(array, CharRange.is('-')));
         
         set = CharSet.getInstance("----");
         array = set.getCharRanges();
         assertEquals(1, array.length);
-        assertEquals(true, ArrayUtils.contains(array, new CharRange('-')));
+        assertEquals(true, ArrayUtils.contains(array, CharRange.is('-')));
         
         set = CharSet.getInstance("-a");
         array = set.getCharRanges();
         assertEquals(2, array.length);
-        assertEquals(true, ArrayUtils.contains(array, new CharRange('-')));
-        assertEquals(true, ArrayUtils.contains(array, new CharRange('a')));
+        assertEquals(true, ArrayUtils.contains(array, CharRange.is('-')));
+        assertEquals(true, ArrayUtils.contains(array, CharRange.is('a')));
         
         set = CharSet.getInstance("a-");
         array = set.getCharRanges();
         assertEquals(2, array.length);
-        assertEquals(true, ArrayUtils.contains(array, new CharRange('a')));
-        assertEquals(true, ArrayUtils.contains(array, new CharRange('-')));
+        assertEquals(true, ArrayUtils.contains(array, CharRange.is('a')));
+        assertEquals(true, ArrayUtils.contains(array, CharRange.is('-')));
         
         set = CharSet.getInstance("a--");
         array = set.getCharRanges();
         assertEquals(1, array.length);
-        assertEquals(true, ArrayUtils.contains(array, new CharRange('a', '-')));
+        assertEquals(true, ArrayUtils.contains(array, CharRange.isIn('a', '-')));
         
         set = CharSet.getInstance("--a");
         array = set.getCharRanges();
         assertEquals(1, array.length);
-        assertEquals(true, ArrayUtils.contains(array, new CharRange('-', 'a')));
+        assertEquals(true, ArrayUtils.contains(array, CharRange.isIn('-', 'a')));
     }
     
     public void testConstructor_String_oddNegate() {
@@ -254,57 +254,57 @@
         set = CharSet.getInstance("^");
         array = set.getCharRanges();
         assertEquals(1, array.length);
-        assertEquals(true, ArrayUtils.contains(array, new CharRange('^'))); // "^"
+        assertEquals(true, ArrayUtils.contains(array, CharRange.is('^'))); // "^"
         
         set = CharSet.getInstance("^^");
         array = set.getCharRanges();
         assertEquals(1, array.length);
-        assertEquals(true, ArrayUtils.contains(array, new CharRange('^', '^', true))); //
"^^"
+        assertEquals(true, ArrayUtils.contains(array, CharRange.isNot('^'))); // "^^"
         
         set = CharSet.getInstance("^^^");
         array = set.getCharRanges();
         assertEquals(2, array.length);
-        assertEquals(true, ArrayUtils.contains(array, new CharRange('^', '^', true))); //
"^^"
-        assertEquals(true, ArrayUtils.contains(array, new CharRange('^', '^'))); // "^"
+        assertEquals(true, ArrayUtils.contains(array, CharRange.isNot('^'))); // "^^"
+        assertEquals(true, ArrayUtils.contains(array, CharRange.is('^'))); // "^"
         
         set = CharSet.getInstance("^^^^");
         array = set.getCharRanges();
         assertEquals(1, array.length);
-        assertEquals(true, ArrayUtils.contains(array, new CharRange('^', '^', true))); //
"^^" x2
+        assertEquals(true, ArrayUtils.contains(array, CharRange.isNot('^'))); // "^^" x2
         
         set = CharSet.getInstance("a^");
         array = set.getCharRanges();
         assertEquals(2, array.length);
-        assertEquals(true, ArrayUtils.contains(array, new CharRange('a'))); // "a"
-        assertEquals(true, ArrayUtils.contains(array, new CharRange('^'))); // "^"
+        assertEquals(true, ArrayUtils.contains(array, CharRange.is('a'))); // "a"
+        assertEquals(true, ArrayUtils.contains(array, CharRange.is('^'))); // "^"
         
         set = CharSet.getInstance("^a-");
         array = set.getCharRanges();
         assertEquals(2, array.length);
-        assertEquals(true, ArrayUtils.contains(array, new CharRange('a', 'a', true))); //
"^a"
-        assertEquals(true, ArrayUtils.contains(array, new CharRange('-'))); // "-"
+        assertEquals(true, ArrayUtils.contains(array, CharRange.isNot('a'))); // "^a"
+        assertEquals(true, ArrayUtils.contains(array, CharRange.is('-'))); // "-"
         
         set = CharSet.getInstance("^^-c");
         array = set.getCharRanges();
         assertEquals(1, array.length);
-        assertEquals(true, ArrayUtils.contains(array, new CharRange('^', 'c', true))); //
"^^-c"
+        assertEquals(true, ArrayUtils.contains(array, CharRange.isNotIn('^', 'c'))); // "^^-c"
         
         set = CharSet.getInstance("^c-^");
         array = set.getCharRanges();
         assertEquals(1, array.length);
-        assertEquals(true, ArrayUtils.contains(array, new CharRange('c', '^', true))); //
"^c-^"
+        assertEquals(true, ArrayUtils.contains(array, CharRange.isNotIn('c', '^'))); // "^c-^"
         
         set = CharSet.getInstance("^c-^d");
         array = set.getCharRanges();
         assertEquals(2, array.length);
-        assertEquals(true, ArrayUtils.contains(array, new CharRange('c', '^', true))); //
"^c-^"
-        assertEquals(true, ArrayUtils.contains(array, new CharRange('d'))); // "d"
+        assertEquals(true, ArrayUtils.contains(array, CharRange.isNotIn('c', '^'))); // "^c-^"
+        assertEquals(true, ArrayUtils.contains(array, CharRange.is('d'))); // "d"
         
         set = CharSet.getInstance("^^-");
         array = set.getCharRanges();
         assertEquals(2, array.length);
-        assertEquals(true, ArrayUtils.contains(array, new CharRange('^', '^', true))); //
"^^"
-        assertEquals(true, ArrayUtils.contains(array, new CharRange('-'))); // "-"
+        assertEquals(true, ArrayUtils.contains(array, CharRange.isNot('^'))); // "^^"
+        assertEquals(true, ArrayUtils.contains(array, CharRange.is('-'))); // "-"
     }
     
     public void testConstructor_String_oddCombinations() {
@@ -313,8 +313,8 @@
         
         set = CharSet.getInstance("a-^c");
         array = set.getCharRanges();
-        assertEquals(true, ArrayUtils.contains(array, new CharRange('a', '^'))); // "a-^"
-        assertEquals(true, ArrayUtils.contains(array, new CharRange('c'))); // "c"
+        assertEquals(true, ArrayUtils.contains(array, CharRange.isIn('a', '^'))); // "a-^"
+        assertEquals(true, ArrayUtils.contains(array, CharRange.is('c'))); // "c"
         assertEquals(false, set.contains('b'));
         assertEquals(true, set.contains('^'));  
         assertEquals(true, set.contains('_')); // between ^ and a
@@ -322,16 +322,16 @@
         
         set = CharSet.getInstance("^a-^c");
         array = set.getCharRanges();
-        assertEquals(true, ArrayUtils.contains(array, new CharRange('a', '^', true))); //
"^a-^"
-        assertEquals(true, ArrayUtils.contains(array, new CharRange('c'))); // "c"
+        assertEquals(true, ArrayUtils.contains(array, CharRange.isNotIn('a', '^'))); // "^a-^"
+        assertEquals(true, ArrayUtils.contains(array, CharRange.is('c'))); // "c"
         assertEquals(true, set.contains('b'));
         assertEquals(false, set.contains('^'));  
         assertEquals(false, set.contains('_')); // between ^ and a
         
         set = CharSet.getInstance("a- ^-- "); //contains everything
         array = set.getCharRanges();
-        assertEquals(true, ArrayUtils.contains(array, new CharRange('a', ' '))); // "a- "
-        assertEquals(true, ArrayUtils.contains(array, new CharRange('-', ' ', true))); //
"^-- "
+        assertEquals(true, ArrayUtils.contains(array, CharRange.isIn('a', ' '))); // "a-
"
+        assertEquals(true, ArrayUtils.contains(array, CharRange.isNotIn('-', ' '))); // "^--
"
         assertEquals(true, set.contains('#'));
         assertEquals(true, set.contains('^'));
         assertEquals(true, set.contains('a'));
@@ -340,7 +340,7 @@
         
         set = CharSet.getInstance("^-b");
         array = set.getCharRanges();
-        assertEquals(true, ArrayUtils.contains(array, new CharRange('^','b'))); // "^-b"
+        assertEquals(true, ArrayUtils.contains(array, CharRange.isIn('^','b'))); // "^-b"
         assertEquals(true, set.contains('b'));
         assertEquals(true, set.contains('_')); // between ^ and a
         assertEquals(false, set.contains('A'));
@@ -348,7 +348,7 @@
         
         set = CharSet.getInstance("b-^");
         array = set.getCharRanges();
-        assertEquals(true, ArrayUtils.contains(array, new CharRange('^','b'))); // "b-^"
+        assertEquals(true, ArrayUtils.contains(array, CharRange.isIn('^','b'))); // "b-^"
         assertEquals(true, set.contains('b'));
         assertEquals(true, set.contains('^'));
         assertEquals(true, set.contains('a')); // between ^ and b
@@ -460,20 +460,20 @@
         
         array = CharSet.ASCII_ALPHA.getCharRanges();
         assertEquals(2, array.length);
-        assertEquals(true, ArrayUtils.contains(array, new CharRange('a', 'z')));
-        assertEquals(true, ArrayUtils.contains(array, new CharRange('A', 'Z')));
+        assertEquals(true, ArrayUtils.contains(array, CharRange.isIn('a', 'z')));
+        assertEquals(true, ArrayUtils.contains(array, CharRange.isIn('A', 'Z')));
         
         array = CharSet.ASCII_ALPHA_LOWER.getCharRanges();
         assertEquals(1, array.length);
-        assertEquals(true, ArrayUtils.contains(array, new CharRange('a', 'z')));
+        assertEquals(true, ArrayUtils.contains(array, CharRange.isIn('a', 'z')));
         
         array = CharSet.ASCII_ALPHA_UPPER.getCharRanges();
         assertEquals(1, array.length);
-        assertEquals(true, ArrayUtils.contains(array, new CharRange('A', 'Z')));
+        assertEquals(true, ArrayUtils.contains(array, CharRange.isIn('A', 'Z')));
         
         array = CharSet.ASCII_NUMERIC.getCharRanges();
         assertEquals(1, array.length);
-        assertEquals(true, ArrayUtils.contains(array, new CharRange('0', '9')));
+        assertEquals(true, ArrayUtils.contains(array, CharRange.isIn('0', '9')));
     }
     
 }



Mime
View raw message