Add knowledge about the specific FB tags
[cfb.git] / prod / net / jaekl / qd / xml / ParseResult.java
index 6c2c25f6e9c2e7b22567cbaf388038a9cc2cb685..e8210159951327dfbb7646f28c8d05bfe55e7f80 100644 (file)
@@ -19,6 +19,8 @@ import org.xml.sax.helpers.AttributesImpl;
 
 public abstract class ParseResult
 {
+       public static final String TAG_FIELD_NAME = "TAG";
+       
        Stack<CurrentInfo> m_current;                                                           // Name of the element that we're currently inside
        StringBuilder m_chars;                                                                          // character content of m_current.peek()
        ArrayList<ParseResult> m_childParsers;                                          // Set of all child parsers
@@ -90,7 +92,7 @@ public abstract class ParseResult
                ParseResult[] result = new ParseResult[collection.size()];
                return collection.toArray(result);
        }
-
+       
        // returns true if this ParseResult's context has ended with this endElement() call
        public boolean endElement(String uri, String localName, String qName) throws XmlParseException
        {
@@ -179,5 +181,24 @@ public abstract class ParseResult
                // Default implementation is a no-op.
                // Override if you want to validate on endElement()
        }
+       
+       protected String getRequiredAttr(String tagName, Attributes attr, String attrName)
+               throws MissingAttributeException
+       {
+               String result = attr.getValue(attrName);
+               if (null == result) {
+                       throw new MissingAttributeException(tagName, attrName);
+               }
+               return result;
+       }
+       
+       protected String getOptionalAttr(Attributes attr, String attrName, String defaultValue)
+       {
+               String value = attr.getValue(attrName);
+               if (null == value) {
+                       return defaultValue;
+               }
+               return value;
+       }
 }