From: erickson Date: Thu, 30 Aug 2007 19:10:20 +0000 (+0000) Subject: added some convenience methods X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=24ce15eb91744afc5fb03b84ff47344e861bec6b;p=Evergreen.git added some convenience methods git-svn-id: svn://svn.open-ils.org/ILS/trunk@7751 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- diff --git a/Open-ILS/src/java/org/open_ils/idl/IDLParser.java b/Open-ILS/src/java/org/open_ils/idl/IDLParser.java index 942bf5aa6c..a82b25d732 100644 --- a/Open-ILS/src/java/org/open_ils/idl/IDLParser.java +++ b/Open-ILS/src/java/org/open_ils/idl/IDLParser.java @@ -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(); 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 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; } }