X-Git-Url: http://jaekl.net/gitweb/?p=cfb.git;a=blobdiff_plain;f=prod%2Fnet%2Fjaekl%2Fqd%2Fxml%2FParseResult.java;h=e8210159951327dfbb7646f28c8d05bfe55e7f80;hp=6c2c25f6e9c2e7b22567cbaf388038a9cc2cb685;hb=a938b67bf3d3bd86f8dd7b1f958e81007bf6f2fe;hpb=08a530ef53cc4756f5e632b69c78830872ebd9f4 diff --git a/prod/net/jaekl/qd/xml/ParseResult.java b/prod/net/jaekl/qd/xml/ParseResult.java index 6c2c25f..e821015 100644 --- a/prod/net/jaekl/qd/xml/ParseResult.java +++ b/prod/net/jaekl/qd/xml/ParseResult.java @@ -19,6 +19,8 @@ import org.xml.sax.helpers.AttributesImpl; public abstract class ParseResult { + public static final String TAG_FIELD_NAME = "TAG"; + Stack m_current; // Name of the element that we're currently inside StringBuilder m_chars; // character content of m_current.peek() ArrayList 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; + } }