Commit in GeomConverter/src/org/lcsim/detector/identifier on MAIN
ExpandedIdentifier.java+34-61.1 -> 1.2
IExpandedIdentifier.java+50-61.2 -> 1.3
+84-12
2 modified files


GeomConverter/src/org/lcsim/detector/identifier
ExpandedIdentifier.java 1.1 -> 1.2
diff -u -r1.1 -r1.2
--- ExpandedIdentifier.java	2 May 2007 01:58:19 -0000	1.1
+++ ExpandedIdentifier.java	4 May 2007 01:18:21 -0000	1.2
@@ -4,10 +4,10 @@
 import java.util.List;
 
 /**
- * COMMENT
+ * Implementation of {@see IExpandedIdentifier}.
  *
  * @author Jeremy McCormick
- * @version $Id: ExpandedIdentifier.java,v 1.1 2007/05/02 01:58:19 jeremy Exp $
+ * @version $Id: ExpandedIdentifier.java,v 1.2 2007/05/04 01:18:21 jeremy Exp $
  */
 
 public class ExpandedIdentifier
@@ -50,7 +50,7 @@
         values.clear();
     }
 
-    public int getNumberOfFields()
+    public int size()
     {
         return values.size();
     }
@@ -82,12 +82,12 @@
     
     public boolean equals(IExpandedIdentifier id)
     {
-        if ( id.getNumberOfFields() != this.getNumberOfFields() )
+        if ( id.size() != this.size() )
         {
             return false;
         }
         
-        for ( int i=0; i<this.getNumberOfFields(); i++)
+        for ( int i=0; i<this.size(); i++)
         {
             if ( id.getValue(i) != this.getValue(i))
             {
@@ -96,4 +96,32 @@
         }
         return true;
     }
-}
\ No newline at end of file
+
+    public int match( IExpandedIdentifier id )
+    {
+        int maxSize = ( size() > id.size() ? id.size() : size() );
+        for ( int i=0; i<maxSize; i++ )
+        {
+            int compare = Integer.valueOf( getValue( i ) ).compareTo( id.getValue( i ) );
+            if ( compare != 0 )
+            {
+                return compare;         
+            }
+        }
+        return 0;
+    }
+
+    public int getMaxIndex()
+    {
+        return size() - 1;
+    }
+
+    public int compareField( IExpandedIdentifier id, int idx )
+    {
+        if ( idx > getMaxIndex() || idx > id.getMaxIndex() )
+        {
+            throw new IllegalArgumentException( "Index is invalid <" + idx + ">.");
+        }
+        return Integer.valueOf( getValue( idx ) ).compareTo( id.getValue( idx ) );
+    }
+}

GeomConverter/src/org/lcsim/detector/identifier
IExpandedIdentifier.java 1.2 -> 1.3
diff -u -r1.2 -r1.3
--- IExpandedIdentifier.java	3 May 2007 21:48:25 -0000	1.2
+++ IExpandedIdentifier.java	4 May 2007 01:18:21 -0000	1.3
@@ -3,22 +3,66 @@
 import java.util.List;
 
 /**
- * COMMENT
+ * An ID that has been unpacked from an {@see org.lcsim.detector.IIdentifier}
+ * so that individual field values are available by index.
  *
- * @author Jeremy McCormick
- * @version $Id: IExpandedIdentifier.java,v 1.2 2007/05/03 21:48:25 jeremy Exp $
+ * Use the appropriate {@see org.lcsim.detector.IIdentifierDictionary} to
+ * see which indices correspond to which field labels.
+ * 
+ * @author  jeremym
+ * @version $Id: IExpandedIdentifier.java,v 1.3 2007/05/04 01:18:21 jeremy Exp $
  */
 
 public interface IExpandedIdentifier
 {
+    /**
+     * Push a value onto the end of this identifier.
+     */
     public void addValue(int value);
+
+    /**
+     * Get the field value at index of {@param index}.
+     */
     public int getValue(int index);
+
+    /**
+     * Return the field values as a list. 
+     */
     public List<Integer> getValues();
-    public int getNumberOfFields();
+
+    /**
+     * Get the number of fields in this identifier.
+     */
+    public int size();
+
+    /**
+     * Get the maximum index which is {@see #size} - 1 .
+     */
+    public int getMaxIndex();
+
+    /**
+     * Clear the identifier of all field values.
+     * The {@see #size} method returns 0 after
+     * this method is called.
+     */
     public void clear();
+
+    /**
+     * True if the {@see IExpandedIdentifier} is in
+     * a valid state with 1 or more field values;
+     * False if there are no values when size is 0. 
+     */
     public boolean isValid();
+
+    /**
+     * True if identifiers are logically equivalent.
+     */
     public boolean equals(IExpandedIdentifier id);
         
-    // compare only matching prefix fields
-    //public int match(IExpandedIdentifier id); 
+    /**
+     * Compares identifiers on prefix fields.
+     * The smaller of the two maximum indices is
+     * used for the field range.
+     */
+    public int match(IExpandedIdentifier id);
 }
CVSspam 0.2.8