added some convenience methods
authorerickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Thu, 30 Aug 2007 19:10:20 +0000 (19:10 +0000)
committererickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Thu, 30 Aug 2007 19:10:20 +0000 (19:10 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@7751 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/src/java/org/open_ils/idl/IDLParser.java

index 942bf5a..a82b25d 100644 (file)
@@ -33,9 +33,12 @@ public class IDLParser {
     /** If true, we retain the full set of IDL objects in memory.  This is true by default. */
     private boolean keepIDLObjects;
 
+    private int parsedObjectCount;
+
     public IDLParser() {
         IDLObjects = new HashMap<String, IDLObject>();
         keepIDLObjects = true;
+        parsedObjectCount = 0;
     }
 
     public IDLParser(String fileName) throws IOException {
@@ -47,6 +50,7 @@ public class IDLParser {
         this.inStream = inStream;
     }
 
+
     /**
     * Parses the IDL XML
     */
@@ -89,12 +93,28 @@ public class IDLParser {
         }
    }
 
-   /**
+    /**
     * Returns the IDLObject with the given IDLClass 
     */
-   public IDLObject getObject(String IDLClass) {
+    public IDLObject getObject(String IDLClass) {
       return (IDLObject) IDLObjects.get(IDLClass);
-   }
+    }
+
+    /**
+     * Returns the full set of IDL objects as a hash from classname to object.
+     * If keepIDLObjects is false, the map will be empty.
+     */
+    public HashMap<String, IDLObject> getIDLObjects() {
+        return IDLObjects;
+    }
+
+    /**
+     * Returns the number of parsed objects, regardless of the keepIDLObjects setting.
+     */
+    public int getObjectCount() {
+        return parsedObjectCount;
+    }
+
 
     public void handleStartElement(XMLStreamReader reader) {
 
@@ -157,6 +177,8 @@ public class IDLParser {
             OSRFRegistry.registerObject(
                 current.getIDLClass(), OSRFRegistry.WireProtocol.ARRAY, fieldNames);
 
+            parsedObjectCount++;
+
             current = null;
         }
     }