]> git.aero2k.de Git - tmp/jakarta-migration.git/commitdiff
CSPACE-235,CSPACE-237: Created initial object model for ID generators, parts, and...
authorAron Roberts <aron@socrates.berkeley.edu>
Wed, 24 Jun 2009 18:48:28 +0000 (18:48 +0000)
committerAron Roberts <aron@socrates.berkeley.edu>
Wed, 24 Jun 2009 18:48:28 +0000 (18:48 +0000)
12 files changed:
sandbox/aron/id/src/main/java/org/collectionspace/services/id/AlphabeticIDGenerator.java
sandbox/aron/id/src/main/java/org/collectionspace/services/id/IDGenerator.java
sandbox/aron/id/src/main/java/org/collectionspace/services/id/IDPart.java
sandbox/aron/id/src/main/java/org/collectionspace/services/id/IDPattern.java
sandbox/aron/id/src/main/java/org/collectionspace/services/id/NumericIDGenerator.java
sandbox/aron/id/src/main/java/org/collectionspace/services/id/StringIDGenerator.java
sandbox/aron/id/src/main/java/org/collectionspace/services/id/YearIDGenerator.java
sandbox/aron/id/src/test/java/org/collectionspace/services/id/AlphabeticIDPartTest.java
sandbox/aron/id/src/test/java/org/collectionspace/services/id/IDPatternTest.java
sandbox/aron/id/src/test/java/org/collectionspace/services/id/NumericIDPartTest.java
sandbox/aron/id/src/test/java/org/collectionspace/services/id/StringIDPartTest.java
sandbox/aron/id/src/test/java/org/collectionspace/services/id/YearIDPartTest.java

index b34ea4f43231cb85ce85d16c43ee27e8335a1dff..21f268cc784189db042a121b5f9652dbe1d1e4b5 100644 (file)
@@ -170,11 +170,6 @@ public class AlphabeticIDGenerator implements IDGenerator {
 
        }
 
-  // Reset the current value to the initial value.
-       public synchronized void reset() {
-         Collections.copy(this.currentValue, this.initialValue);
-       }
-
   // Returns the initial value.
        public synchronized String getInitialID() {
                return getIDString(this.initialValue);
@@ -222,7 +217,14 @@ public class AlphabeticIDGenerator implements IDGenerator {
 
                // Set the current value.
                this.currentValue = new Vector<Character>(v);
+               
        }
+
+  // Reset the current value to the initial value.
+       public synchronized void resetID() {
+         Collections.copy(this.currentValue, this.initialValue);
+       }
+
        
        // Returns the next alphabetic ID in the sequence.
        //
@@ -233,7 +235,7 @@ public class AlphabeticIDGenerator implements IDGenerator {
   //
   // See the TODOs at the top of this class for additional
   // functionality that needs to be implemented.
-  public synchronized String getNextID() {
+  public synchronized String nextID() {
 
                // Get next values for each character, from right to left
                // (least significant to most significant).
@@ -279,7 +281,7 @@ public class AlphabeticIDGenerator implements IDGenerator {
   }
 
   // Returns a String representation of the ID, by appending
-  // the String values of each character in the Vector.
+  // the String values of each character.
   public synchronized String getIDString(Vector<Character> v) {
                StringBuffer sb = new StringBuffer();
          for ( Character ch : v ) {
index 5b43709d2c5db7e350034f167f44d3fbe76feada..0963894ee38eb54ef7b73a0764ff2dc0cf8ecb69 100644 (file)
@@ -24,18 +24,27 @@ package org.collectionspace.services.id;
 
 public interface IDGenerator {
     
-       public void reset();
-
+       // Returns the initial value of the ID.
        public String getInitialID();
 
+       // Gets the current value of an ID.
        public String getCurrentID();
        
+       // Sets the current value of an ID.
        public void setCurrentID(String value);
 
-       public String getNextID();
+       // Resets an ID to its initial value.
+       public void resetID();
+
+       // Returns the next ID in the sequence, and sets
+       // the current value to that ID.
+       public String nextID();
 
+       // Validates an ID against a pattern of generated IDs.
        public boolean isValidID(String value);
 
+       // Returns a String representation of the regular expression ("regex")
+       // pattern used to validate instance values of generated IDs.  
        public String getRegex();
                
 }
index ffabe304c72e54c51949052bad662d2565f7ad41..a108c33d82cf754a692f5e299762af6af1ceeef1 100644 (file)
@@ -40,33 +40,33 @@ public abstract class IDPart {
                this.generator = idGenerator;
        }
 
-       // Resets the ID to its initial value.
-       public synchronized void reset() {
-               generator.reset();
-       }
-
-       // Returns the initial value of this ID.
+       // Returns the initial value of the ID associated with this IDPart.
        public synchronized String getInitialID() {
                return generator.getInitialID();
        }
 
-       // Returns the current value of this ID.
+       // Returns the current value of the ID associated with this IDPart.
        public synchronized String getCurrentID() {
                return generator.getCurrentID();
        }
 
-       // Sets the current value of this ID.
+       // Sets the current value of the ID associated with this IDPart.
        public synchronized void setCurrentID(String value) {
                generator.setCurrentID(value);
        }
 
-       // Returns the next value of this ID.
-       public synchronized String getNextID() throws IllegalStateException {
-               return generator.getNextID();
+       // Resets the ID associated with this IDPart to its initial value.
+       public synchronized void resetID() {
+               generator.resetID();
+       }
+
+       // Returns the next ID in the sequence, and sets the current value
+       // of the ID associated with this IDPart to that next ID.
+       public synchronized String nextID() throws IllegalStateException {
+               return generator.nextID();
        }
 
-       // Validates an instance of the ID, to
-       // identify if it matches this IDPart's pattern.
+       // Validates a supplied ID against the pattern of this IDPart.
        //
        // Some IDParts may offer generic validation,
        // while others may offer per-instance valiadation
@@ -76,7 +76,8 @@ public abstract class IDPart {
                return generator.isValidID(value);
        }
 
-  // Returns a regular expression pattern used for ID validation.
+       // Returns a String representation of the regular expression ("regex")
+       // pattern used to validate instance values of this IDPart.  
        public synchronized String getRegex() {
                return generator.getRegex();
        }
index 3df25ca9408d3b41de55a7802b70712473171f2c..7b848c1e7edd286d5279046d55f6f7f437ce11f3 100644 (file)
@@ -63,14 +63,22 @@ public class IDPattern {
        // Returns the current value of this ID, given a
        // supplied ID that partly matches the pattern.
        //
-       // This will result in an ID that matches
-       // the supplied ID, with an optional next ID component
-       // that reflects the initial ID of that component.
-       // (E.g. "2009.5." becomes "2009.5.1", if the next
-       // ID component is an incrementing numeric IDPart.)
+       // If the supplied ID fully matches the pattern,
+       // will return the supplied ID.
        //
-  // @TODO: Throws IllegalArgumentException
-       public synchronized String getCurrentID(String value) {
+       // However, if the supplied ID is a partial ID, which
+       // partly "stem-matches" the pattern but does not
+       // ully match the pattern, will return the partial ID with
+       // its next ID component appended.  The next ID component
+       // will be set to its initial value.
+       //
+       // Examples:
+       // * 2009.5." becomes "2009.5.1", in a case where the
+       //   next ID component is an incrementing numeric IDPart.
+       // * "E55-" becomes "E55-a", where the next ID component
+       //   is an incrementing alphabetic IDPart.
+       public synchronized String getCurrentID(String value)
+               throws IllegalArgumentException {
 
          if (value == null) return value;
          
@@ -101,59 +109,51 @@ public class IDPattern {
                        }
                }
 
-               // If the supplied ID doesn't entirely match the pattern,
-               // return the supplied ID as the next ID.
-               //
-               // @TODO: We may wish to handle this differently,
-               // such as by throwing an Exception.
+               // If the supplied ID doesn't partly match the pattern,
+               // throw an Exception.
                if (matchedParts == 0) {
-                       // return value;
-                       return "foo1";
+                       throw new IllegalArgumentException("Supplied ID does not match this ID pattern.");
                }
 
                pattern = Pattern.compile(regex.toString());
                matcher = pattern.matcher(value);
                
-               // If the supplied ID doesn't entirely match the pattern,
-               // return the supplied ID as the next ID.
-               //
-               // @TODO: We may wish to handle this differently,
-               // such as by throwing an Exception.
+               // If the supplied ID doesn't match the pattern built above,
+               // throw an Exception.  (This error condition should likely
+               // never be reached, but it's here as a guard.)
                if (! matcher.matches()) {
-                       // return value;
-                       return "foo2";
+                       throw new IllegalArgumentException("Supplied ID does not match this ID pattern.");
                }
                
-               // Temporary for debugging
-               // return regex.toString();
-
-               // Otherwise, if the supplied ID partly matches the pattern,
-               // split the ID into its components and store those values in
-               // each of the pattern's IDParts.
+               // Otherwise, if the supplied ID matches the pattern,
+               // split the ID into its components and store those
+               // values in each of the pattern's IDParts.
                IDPart currentPart;
                for (int i = 1; i <= matchedParts; i++) {
                  currentPart = this.parts.get(i - 1);
       currentPart.setCurrentID(matcher.group(i));
                }
 
-               // Obtain the initial value of the next IDPart,
-               // and set the current value of that part to its initial value.
+               // Obtain the initial value of the next IDPart, and
+               // set the current value of that part to its initial value.
                //
                // If the supplied ID fully matches the pattern, there will
-               // be no 'next' IDPart, and an Exception will be thrown
+               // be no 'next' IDPart, and we must catch that Exception below
                int nextPartNum = matchedParts;
                try {
                        String initial = this.parts.get(nextPartNum).getInitialID();
                        this.parts.get(nextPartNum).setCurrentID(initial);
+                       // Increment the number of matched parts to reflect the
+                       // addition of this next IDPart.
                        matchedParts++;
                } catch (ArrayIndexOutOfBoundsException e ) {
                        // Do nothing here; we simply won't increment
-                       // the number of matched parts for the loop below.
+                       // the number of matched parts, used in the loop below.
                }
                
                // Call the getCurrentID() method on each of the
                // supplied IDParts, as well as on the added IDPart
-               // whose current value was just obtained, if any.
+               // whose initial value was just obtained, if any.
                StringBuffer sb = new StringBuffer();
                for (int i = 1; i <= matchedParts; i++) {
                        sb.append(this.parts.get(i - 1).getCurrentID());
@@ -163,17 +163,15 @@ public class IDPattern {
 
        }
 
-       // Returns the next value of this ID.
-       //
-       // @TODO: Throws IllegalArgumentException
-       public synchronized String getNextID() {
+       // Returns the next value of this ID, and sets the current value to that ID.
+       public synchronized String nextID() throws IllegalStateException {
        
                // Obtain the last (least significant) IDPart,
-               // and call its getNextID() method, which will
+               // and call its nextID() method, which will
                // concurrently set the current value of that ID
                // to the next ID.
                int lastPartNum = this.parts.size() - 1;
-               this.parts.get(lastPartNum).getNextID();
+               this.parts.get(lastPartNum).nextID();
                
                // Then call the getCurrentID() method on all of the IDParts
                StringBuffer sb = new StringBuffer(MAX_ID_LENGTH);
@@ -186,23 +184,22 @@ public class IDPattern {
        }
 
        // Returns the next value of this ID, given a
-       // supplied ID that entirely matches the pattern.
-       //
-  // @TODO: Throws IllegalArgumentException
-       public synchronized String getNextID(String value) {
+       // supplied ID that entirely matches the pattern,
+       // and sets the current value to that ID.
+       public synchronized String nextID(String value)
+               throws IllegalStateException, IllegalArgumentException {
 
-         if (value == null) return value;
+         if (value == null) { 
+               throw new IllegalArgumentException("Supplied ID cannot be null.");
+         }
        
                Pattern pattern = Pattern.compile(getRegex());
                Matcher matcher = pattern.matcher(value);
                
                // If the supplied ID doesn't entirely match the pattern,
-               // return the supplied ID as the next ID.
-               //
-               // @TODO: We may wish to handle this differently,
-               // such as by throwing an Exception.
+               // throw an Exception.
                if (! matcher.matches()) {
-                       return value;
+                       throw new IllegalArgumentException("Supplied ID does not match this ID pattern.");
                }
                
                // Otherwise, if the supplied ID entirely matches the pattern,
@@ -215,14 +212,14 @@ public class IDPattern {
                }
 
                // Obtain the last (least significant) IDPart,
-               // and call its getNextID() method, which will
+               // and call its nextID() method, which will
                // concurrently set the current value of that ID
                // to the next ID.
                //
-               // @TODO: This code is duplicated in getNextID(), above,
+               // @TODO: This code is duplicated in nextID(), above,
                // and thus we may want to refactor this.
                int lastPartNum = this.parts.size() - 1;
-               this.parts.get(lastPartNum).getNextID();
+               this.parts.get(lastPartNum).nextID();
                
                // Then call the getCurrentID() method on all of the IDParts
                StringBuffer sb = new StringBuffer();
@@ -236,7 +233,8 @@ public class IDPattern {
 
        // Validates a provided ID against the pattern.
        //
-       // @TODO May potentially throw at least one pattern-related exception.
+       // @TODO May potentially throw at least one pattern-related exception;
+       // we'll need to catch and handle this.
        public synchronized boolean isValidID(String value) {
        
          if (value == null) return false;
index 69b12e2cfbf7e33c34a26bb24e93efeb11967d76..4d4f7206b6a47fde94dcc43c497e0f1c726520cc 100644 (file)
@@ -70,10 +70,6 @@ public class NumericIDGenerator implements IDGenerator {
                
        }
 
-       public synchronized void reset() {
-               this.currentValue = this.initialValue;
-       }
-
        public synchronized String getInitialID() {
                return Long.toString(this.initialValue);
        }
@@ -82,7 +78,7 @@ public class NumericIDGenerator implements IDGenerator {
                return Long.toString(this.currentValue);
        }
 
-  // Sets the current value.
+  // Sets the current value of the ID.
        public synchronized void setCurrentID(String value) throws IllegalArgumentException {
 
          // @TODO Much of this code is copied from the main constructor,
@@ -105,7 +101,12 @@ public class NumericIDGenerator implements IDGenerator {
                this.maxLength = DEFAULT_MAX_LENGTH;
        }
        
-       public synchronized String getNextID() throws IllegalStateException {
+       public synchronized void resetID() {
+               this.currentValue = this.initialValue;
+       }
+
+       // Returns the next ID in the sequence, and sets the current value to that ID.
+       public synchronized String nextID() throws IllegalStateException {
                this.currentValue++;
                String nextID = Long.toString(this.currentValue);
                if (nextID.length() > this.maxLength) {
index 04e8e64c699f8e6e77929894780e45a2d069b927..e2c2a391e720d64ed0f414bf010c88f4735b0f49 100644 (file)
@@ -42,10 +42,6 @@ public class StringIDGenerator implements IDGenerator {
 
        }
 
-       public synchronized void reset() {
-               // Do nothing
-       }
-
        public synchronized String getInitialID() {
                return this.initialValue;
        }
@@ -61,7 +57,11 @@ public class StringIDGenerator implements IDGenerator {
                this.currentValue = value;
        }
        
-       public synchronized String getNextID() {
+       public synchronized void resetID() {
+               // Do nothing
+       }
+
+       public synchronized String nextID() {
                return this.currentValue;
   }
 
index 41f07f2f5abb76475c968a4cade469dd81c8ab35..91578351169a5e1c436bcf1da33f2a4a37d717eb 100644 (file)
@@ -71,10 +71,6 @@ public class YearIDGenerator implements IDGenerator {
 
        }
 
-       public synchronized void reset() {
-               this.currentValue = this.initialValue;
-       }
-
        public synchronized String getInitialID() {
                return this.initialValue;
        }
@@ -100,12 +96,16 @@ public class YearIDGenerator implements IDGenerator {
 
        }
        
+       public synchronized void resetID() {
+               this.currentValue = this.initialValue;
+       }
+
        // @TODO: We'll need to decide what a "next" ID means in the context of:
        // - An initially supplied value.
        // - A year value that has not changed from its previous value.
        // - A year value that has changed, as a result of a rollover
        //   to a new instant in time.
-       public synchronized String getNextID() {
+       public synchronized String nextID() {
                return this.currentValue;
   }
 
index bbd0aa63b825491168aafd5941162af2f6a33be5..5b85ad55a51056e7665fa117391c8833d1ef82df 100644 (file)
@@ -25,89 +25,89 @@ public class AlphabeticIDPartTest extends TestCase {
 
        IDPart part;
        
-       public void testGetNextIDLowercase() {
+       public void testnextIDLowercase() {
 
                part = new AlphabeticIDPart("a");
-               assertEquals("b", part.getNextID());
-               assertEquals("c", part.getNextID());
+               assertEquals("b", part.nextID());
+               assertEquals("c", part.nextID());
 
                part = new AlphabeticIDPart("x");
-               assertEquals("y", part.getNextID());
-               assertEquals("z", part.getNextID());
+               assertEquals("y", part.nextID());
+               assertEquals("z", part.nextID());
 
 }
 
-       public void testGetNextIDLowercase2Chars() {
+       public void testnextIDLowercase2Chars() {
 
                part = new AlphabeticIDPart("aa");
-               assertEquals("ab", part.getNextID());
-               assertEquals("ac", part.getNextID());
+               assertEquals("ab", part.nextID());
+               assertEquals("ac", part.nextID());
 
                part = new AlphabeticIDPart("zx");
-               assertEquals("zy", part.getNextID());
-               assertEquals("zz", part.getNextID());
+               assertEquals("zy", part.nextID());
+               assertEquals("zz", part.nextID());
 
        }
 
-       public void testGetNextIDLowercase2CharsRolloverFirst() {
+       public void testnextIDLowercase2CharsRolloverFirst() {
 
                part = new AlphabeticIDPart("ay");
-               assertEquals("az", part.getNextID());
-               assertEquals("ba", part.getNextID());
-               assertEquals("bb", part.getNextID());
+               assertEquals("az", part.nextID());
+               assertEquals("ba", part.nextID());
+               assertEquals("bb", part.nextID());
 
   }
        
-       public void testGetNextIDUppercase() {
+       public void testnextIDUppercase() {
                
                part = new AlphabeticIDPart("A", "Z", "A");
-               assertEquals("B", part.getNextID());
-               assertEquals("C", part.getNextID());
+               assertEquals("B", part.nextID());
+               assertEquals("C", part.nextID());
 
                part = new AlphabeticIDPart("A", "Z", "X");
-               assertEquals("Y", part.getNextID());
-               assertEquals("Z", part.getNextID());
+               assertEquals("Y", part.nextID());
+               assertEquals("Z", part.nextID());
 
 }
 
-       public void testGetNextIDUppercase2Chars() {
+       public void testnextIDUppercase2Chars() {
 
                part = new AlphabeticIDPart("A", "Z", "AA");
-               assertEquals("AB", part.getNextID());
-               assertEquals("AC", part.getNextID());
+               assertEquals("AB", part.nextID());
+               assertEquals("AC", part.nextID());
 
                part = new AlphabeticIDPart("A", "Z", "ZX");
-               assertEquals("ZY", part.getNextID());
-               assertEquals("ZZ", part.getNextID());
+               assertEquals("ZY", part.nextID());
+               assertEquals("ZZ", part.nextID());
                        
        }
 
-       public void testGetNextIDUppercase2CharsRolloverFirst() {
+       public void testnextIDUppercase2CharsRolloverFirst() {
 
                part = new AlphabeticIDPart("A", "Z", "AY");
-               assertEquals("AZ", part.getNextID());
-               assertEquals("BA", part.getNextID());
-               assertEquals("BB", part.getNextID());
+               assertEquals("AZ", part.nextID());
+               assertEquals("BA", part.nextID());
+               assertEquals("BB", part.nextID());
 
   }
   
-       public void testResetLowercase() {
+       public void testresetIDLowercase() {
                
                part = new AlphabeticIDPart("zx");
-               assertEquals("zy", part.getNextID());
-               assertEquals("zz", part.getNextID());
-               part.reset();
+               assertEquals("zy", part.nextID());
+               assertEquals("zz", part.nextID());
+               part.resetID();
                assertEquals("zx", part.getCurrentID());
        
        }
 
-       public void testResetUppercase() {
+       public void testresetIDUppercase() {
                
                part = new AlphabeticIDPart("A", "Z", "RA");
-               assertEquals("RB", part.getNextID());
-               assertEquals("RC", part.getNextID());
-               part.reset();
-               assertEquals("RB", part.getNextID());
+               assertEquals("RB", part.nextID());
+               assertEquals("RC", part.nextID());
+               part.resetID();
+               assertEquals("RB", part.nextID());
        
        }
        
@@ -129,10 +129,10 @@ public class AlphabeticIDPartTest extends TestCase {
                
                part = new AlphabeticIDPart("aaa");
                assertEquals("aaa", part.getCurrentID());
-               assertEquals("aab", part.getNextID());
-               assertEquals("aac", part.getNextID());
+               assertEquals("aab", part.nextID());
+               assertEquals("aac", part.nextID());
                assertEquals("aac", part.getCurrentID());
-               assertEquals("aad", part.getNextID());
+               assertEquals("aad", part.nextID());
                
        }
 
@@ -140,28 +140,28 @@ public class AlphabeticIDPartTest extends TestCase {
                
                part = new AlphabeticIDPart("A", "Z", "A");
                assertEquals("A", part.getCurrentID());
-               assertEquals("B", part.getNextID());
-               assertEquals("C", part.getNextID());
+               assertEquals("B", part.nextID());
+               assertEquals("C", part.nextID());
                assertEquals("C", part.getCurrentID());
-               assertEquals("D", part.getNextID());
+               assertEquals("D", part.nextID());
                
        }       
        
        public void testOverflowLowercase() {
        
     part = new AlphabeticIDPart("zx");
-    assertEquals("zy", part.getNextID());
-    assertEquals("zz", part.getNextID());
-    assertEquals("aaa", part.getNextID());
+    assertEquals("zy", part.nextID());
+    assertEquals("zz", part.nextID());
+    assertEquals("aaa", part.nextID());
                
        }
 
        public void testOverflowUppercase() {
        
     part = new AlphabeticIDPart("A", "Z", "X");
-    assertEquals("Y", part.getNextID());
-    assertEquals("Z", part.getNextID());
-    assertEquals("AA", part.getNextID());
+    assertEquals("Y", part.nextID());
+    assertEquals("Z", part.nextID());
+    assertEquals("AA", part.nextID());
                
        }
 
index bb89f25e06550315d4ef8a71bf170cbe71101ebd..e89653522d80fa8c2623203c23c41201bd45bf84 100644 (file)
@@ -64,39 +64,39 @@ public class IDPatternTest extends TestCase {
                pattern.add(new StringIDPart("E"));
                pattern.add(new NumericIDPart("1"));
                assertEquals("E1", pattern.getCurrentID("E"));
-               assertEquals("E2", pattern.getNextID());
+               assertEquals("E2", pattern.nextID());
 
                pattern = new IDPattern();
                pattern.add(new YearIDPart());
                pattern.add(new StringIDPart("."));
                assertEquals("2009.", pattern.getCurrentID("2009"));
-               assertEquals("2009.", pattern.getNextID());
+               assertEquals("2009.", pattern.nextID());
                assertEquals("2010.", pattern.getCurrentID("2010"));
-               assertEquals("2010.", pattern.getNextID());
+               assertEquals("2010.", pattern.nextID());
 
                pattern = new IDPattern();
                pattern.add(new YearIDPart());
                pattern.add(new StringIDPart("."));
                pattern.add(new NumericIDPart("1"));
                assertEquals("2009.1", pattern.getCurrentID("2009."));
-               assertEquals("2009.2", pattern.getNextID());
+               assertEquals("2009.2", pattern.nextID());
 
                pattern = new IDPattern();
                pattern.add(new YearIDPart());
                pattern.add(new StringIDPart("."));
                pattern.add(new NumericIDPart("55"));
                assertEquals("2010.55", pattern.getCurrentID("2010."));
-               assertEquals("2010.56", pattern.getNextID());
+               assertEquals("2010.56", pattern.nextID());
 
                pattern = new IDPattern();
                pattern.add(new YearIDPart("2009"));
                pattern.add(new StringIDPart("."));
                pattern.add(new NumericIDPart());
                assertEquals("2009.1", pattern.getCurrentID("2009."));
-               assertEquals("2009.2", pattern.getNextID());
+               assertEquals("2009.2", pattern.nextID());
                // Test a repeat of the last two operations.
                assertEquals("2009.1", pattern.getCurrentID("2009."));
-               assertEquals("2009.2", pattern.getNextID());
+               assertEquals("2009.2", pattern.nextID());
 
                pattern = new IDPattern();
                pattern.add(new YearIDPart("2009"));
@@ -105,7 +105,7 @@ public class IDPatternTest extends TestCase {
                pattern.add(new StringIDPart("-"));
                pattern.add(new AlphabeticIDPart("a"));
                assertEquals("2009.1-a", pattern.getCurrentID("2009.1-"));
-               assertEquals("2009.1-b", pattern.getNextID());
+               assertEquals("2009.1-b", pattern.nextID());
                assertEquals("2009.3-a", pattern.getCurrentID("2009.3-"));
 
        }
@@ -117,7 +117,7 @@ public class IDPatternTest extends TestCase {
                pattern.add(new StringIDPart("."));
                pattern.add(new NumericIDPart("55"));
                assertEquals("2009.55", pattern.getCurrentID("2009.55"));
-               assertEquals("2009.56", pattern.getNextID());
+               assertEquals("2009.56", pattern.nextID());
 
                pattern = new IDPattern();
                pattern.add(new YearIDPart("2009"));
@@ -126,7 +126,7 @@ public class IDPatternTest extends TestCase {
                pattern.add(new StringIDPart("-"));
                pattern.add(new AlphabeticIDPart("a"));
                assertEquals("2009.1-a", pattern.getCurrentID("2009.1-a"));
-               assertEquals("2009.1-b", pattern.getNextID());
+               assertEquals("2009.1-b", pattern.nextID());
 
        }
 
@@ -136,8 +136,8 @@ public class IDPatternTest extends TestCase {
                pattern.add(new YearIDPart("2009"));
                pattern.add(new StringIDPart("."));
                pattern.add(new NumericIDPart("1"));
-               assertEquals("2009.2", pattern.getNextID());
-               assertEquals("2009.3", pattern.getNextID());
+               assertEquals("2009.2", pattern.nextID());
+               assertEquals("2009.3", pattern.nextID());
 
                pattern = new IDPattern();
                pattern.add(new YearIDPart("2009"));
@@ -145,14 +145,14 @@ public class IDPatternTest extends TestCase {
                pattern.add(new NumericIDPart("1"));
                pattern.add(new StringIDPart("-"));
                pattern.add(new AlphabeticIDPart("a"));
-               assertEquals("2009.1-b", pattern.getNextID());
-               assertEquals("2009.1-c", pattern.getNextID());
+               assertEquals("2009.1-b", pattern.nextID());
+               assertEquals("2009.1-c", pattern.nextID());
 
                pattern = new IDPattern();
                pattern.add(new StringIDPart("T"));
                pattern.add(new NumericIDPart("1005"));
-               assertEquals("T1006", pattern.getNextID());
-               assertEquals("T1007", pattern.getNextID());
+               assertEquals("T1006", pattern.nextID());
+               assertEquals("T1007", pattern.nextID());
                        
        }
 
@@ -163,8 +163,8 @@ public class IDPatternTest extends TestCase {
                pattern.add(new StringIDPart("."));
                pattern.add(new NumericIDPart("1"));
                pattern.add(new StringIDPart("-"));
-               assertEquals("2009.1-", pattern.getNextID());
-               assertEquals("2009.1-", pattern.getNextID());
+               assertEquals("2009.1-", pattern.nextID());
+               assertEquals("2009.1-", pattern.nextID());
 
        }
 
@@ -174,8 +174,8 @@ public class IDPatternTest extends TestCase {
                pattern.add(new YearIDPart("2009"));
                pattern.add(new StringIDPart("."));
                pattern.add(new NumericIDPart("1"));
-               assertEquals("2009.2", pattern.getNextID("2009.1"));
-               assertEquals("2009.3", pattern.getNextID("2009.2"));
+               assertEquals("2009.2", pattern.nextID("2009.1"));
+               assertEquals("2009.3", pattern.nextID("2009.2"));
 
                pattern = new IDPattern();
                pattern.add(new YearIDPart("2009"));
@@ -183,8 +183,8 @@ public class IDPatternTest extends TestCase {
                pattern.add(new NumericIDPart("1"));
                pattern.add(new StringIDPart("-"));
                pattern.add(new AlphabeticIDPart("a"));
-               assertEquals("2009.1-b", pattern.getNextID("2009.1-a"));
-               assertEquals("2009.3-c", pattern.getNextID("2009.3-b"));
+               assertEquals("2009.1-b", pattern.nextID("2009.1-a"));
+               assertEquals("2009.3-c", pattern.nextID("2009.3-b"));
 
        }
        
index 1f3d0cc1238c75fd231f164f7bdb9369797ced0b..0708300bbc9d31fa576454df93f086d02d4b4a0e 100644 (file)
@@ -28,14 +28,14 @@ public class NumericIDPartTest extends TestCase {
        public void testNextID() {
 
                part = new NumericIDPart("0");          
-               assertEquals("1", part.getNextID());
-               assertEquals("2", part.getNextID());
-               assertEquals("3", part.getNextID());
+               assertEquals("1", part.nextID());
+               assertEquals("2", part.nextID());
+               assertEquals("3", part.nextID());
 
                part = new NumericIDPart("25");
-               assertEquals("26", part.getNextID());
-               assertEquals("27", part.getNextID());
-               assertEquals("28", part.getNextID());
+               assertEquals("26", part.nextID());
+               assertEquals("27", part.nextID());
+               assertEquals("28", part.nextID());
                        
        }
 
@@ -43,9 +43,9 @@ public class NumericIDPartTest extends TestCase {
 
                try {
                        part = new NumericIDPart("997", "3");           
-                       assertEquals("998", part.getNextID());
-                       assertEquals("999", part.getNextID());
-                       assertEquals("1000", part.getNextID());
+                       assertEquals("998", part.nextID());
+                       assertEquals("999", part.nextID());
+                       assertEquals("1000", part.nextID());
                        fail("Should have thrown IllegalStateException here");
                } catch (IllegalStateException expected) {
                        // This Exception should be thrown, and thus the test should pass.
@@ -54,9 +54,9 @@ public class NumericIDPartTest extends TestCase {
                // Tests default MAX_LENGTH value of 6 decimal places
                try {
                        part = new NumericIDPart("999997");             
-                       assertEquals("999998", part.getNextID());
-                       assertEquals("999999", part.getNextID());
-                       assertEquals("1000000", part.getNextID());
+                       assertEquals("999998", part.nextID());
+                       assertEquals("999999", part.nextID());
+                       assertEquals("1000000", part.nextID());
                        fail("Should have thrown IllegalStateException here");
                } catch (IllegalStateException expected) {
                        // This Exception should be thrown, and thus the test should pass.
@@ -64,14 +64,14 @@ public class NumericIDPartTest extends TestCase {
                        
        }
 
-       public void testReset() {
+       public void testresetID() {
        
                part = new NumericIDPart("25");
-               assertEquals("26", part.getNextID());
-               assertEquals("27", part.getNextID());
-               assertEquals("28", part.getNextID());
-               part.reset();
-               assertEquals("26", part.getNextID());
+               assertEquals("26", part.nextID());
+               assertEquals("27", part.nextID());
+               assertEquals("28", part.nextID());
+               part.resetID();
+               assertEquals("26", part.nextID());
                        
        }
 
@@ -89,10 +89,10 @@ public class NumericIDPartTest extends TestCase {
 
                part = new NumericIDPart("0");
                assertEquals("0", part.getCurrentID());
-               assertEquals("1", part.getNextID());
-               assertEquals("2", part.getNextID());
+               assertEquals("1", part.nextID());
+               assertEquals("2", part.nextID());
                assertEquals("2", part.getCurrentID());
-               assertEquals("3", part.getNextID());
+               assertEquals("3", part.nextID());
 
                part = new NumericIDPart("25");
                assertEquals("25", part.getCurrentID());
index d0e40f697112d6744fe7121bda232a04bc5f6c31..dd3a7a928a0eef4a373247bb4e695d344eea8737 100644 (file)
@@ -27,15 +27,15 @@ public class StringIDPartTest extends TestCase {
 
        public void testNextID() {
                part = new StringIDPart("XYZ");         
-               assertEquals("XYZ", part.getNextID());                  
+               assertEquals("XYZ", part.nextID());                     
        }
 
-       public void testReset() {
+       public void testresetID() {
        
                part = new StringIDPart(".");
-               assertEquals(".", part.getNextID());
-               part.reset();
-               assertEquals(".", part.getNextID());
+               assertEquals(".", part.nextID());
+               part.resetID();
+               assertEquals(".", part.nextID());
                        
        }
 
index 2dee61c798eb593f42446f5901b392278b4c753b..12b5d85f3eb1fb3e28eb43babc32ab816b7ce2d0 100644 (file)
@@ -48,15 +48,15 @@ public class YearIDPartTest extends TestCase {
 /*
        public void testNextID() {
                part = new YearIDPart("XYZ");           
-               assertEquals("XYZ", part.getNextID());                  
+               assertEquals("XYZ", part.nextID());                     
        }
 
-       public void testReset() {
+       public void testresetID() {
        
                part = new YearIDPart(".");
-               assertEquals(".", part.getNextID());
-               part.reset();
-               assertEquals(".", part.getNextID());
+               assertEquals(".", part.nextID());
+               part.resetID();
+               assertEquals(".", part.nextID());
                        
        }