X-Git-Url: http://jaekl.net/gitweb/?a=blobdiff_plain;f=prod%2Fnet%2Fjaekl%2Fcfb%2Fxml%2FSourceLine.java;h=e5e82f6aa3e8e88f47042bdf9795dfee1049e668;hb=7ac6be132ecd6872971a1de56f033b4434d3173a;hp=c78ae3af8717835bf21d207b3c9660a19d55edcf;hpb=08a530ef53cc4756f5e632b69c78830872ebd9f4;p=cfb.git diff --git a/prod/net/jaekl/cfb/xml/SourceLine.java b/prod/net/jaekl/cfb/xml/SourceLine.java index c78ae3a..e5e82f6 100644 --- a/prod/net/jaekl/cfb/xml/SourceLine.java +++ b/prod/net/jaekl/cfb/xml/SourceLine.java @@ -1,14 +1,16 @@ package net.jaekl.cfb.xml; -import org.xml.sax.Attributes; +import java.io.PrintWriter; import net.jaekl.qd.xml.MissingAttributeException; import net.jaekl.qd.xml.ParseResult; import net.jaekl.qd.xml.XmlParseException; +import org.xml.sax.Attributes; + public class SourceLine extends ParseResult { - static final String ROOT_TAG = "SourceLine"; + static final String TAG = "SourceLine"; static final String[] INTERNAL = { }; static final Object[][] EXTERNAL = { }; @@ -21,41 +23,48 @@ public class SourceLine extends ParseResult { int m_end; public SourceLine() { - super(ROOT_TAG, INTERNAL, EXTERNAL); + super(TAG, INTERNAL, EXTERNAL); m_className = null; m_start = m_end = (-1); } + public String getClassName() { return m_className; } + public int getStart() { return m_start; } + public int getEnd() { return m_end; } + @Override - public void endContents(String uri, String localName, String qName, String chars, Attributes attr) - throws XmlParseException - { + public void handleMainAttributes(Attributes attr) throws MissingAttributeException { String scratch; - m_className = getRequiredAttr(localName, attr, ATTR_CLASS_NAME); + m_className = getRequiredAttr(TAG, attr, ATTR_CLASS_NAME); - scratch = getRequiredAttr(localName, attr, ATTR_START); + scratch = getOptionalAttr(attr, ATTR_START, "-1"); m_start = Integer.parseInt(scratch); - scratch = getRequiredAttr(localName, attr, ATTR_END); + scratch = getOptionalAttr(attr, ATTR_END, "-1"); m_end = Integer.parseInt(scratch); } - String getRequiredAttr(String tagName, Attributes attr, String attrName) - throws MissingAttributeException + @Override + public void endContents(String uri, String localName, String qName, String chars) + throws XmlParseException { - String result = attr.getValue(attrName); - if (null == result) { - throw new MissingAttributeException(tagName, attrName); - } - return result; + // no-op } - + @Override public void endExternal(String uri, String localName, String qName) throws XmlParseException { // no-op } - + + @Override + public void dump(PrintWriter pw, int indent) + { + super.dump(pw, indent); + String tab = String.format("%" + (indent + 2) + "s", ""); + + pw.println(tab + m_className + " (" + m_start + " .. " + m_end + ")"); + } }