X-Git-Url: http://jaekl.net/gitweb/?a=blobdiff_plain;f=prod%2Fnet%2Fjaekl%2Fcfb%2Fxml%2FBugCollection.java;h=168c8f1c5787935a5c6badab052d291c2d1e74b0;hb=a4a577abc3f9b2b1147caafd1cb39fa8c2622cd4;hp=9078e2fe95ef73f1a946ee397331264e33de470b;hpb=08a530ef53cc4756f5e632b69c78830872ebd9f4;p=cfb.git diff --git a/prod/net/jaekl/cfb/xml/BugCollection.java b/prod/net/jaekl/cfb/xml/BugCollection.java index 9078e2f..168c8f1 100644 --- a/prod/net/jaekl/cfb/xml/BugCollection.java +++ b/prod/net/jaekl/cfb/xml/BugCollection.java @@ -1,32 +1,73 @@ package net.jaekl.cfb.xml; -import org.xml.sax.Attributes; +import java.io.PrintWriter; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import net.jaekl.cfb.util.Util; import net.jaekl.qd.xml.ParseResult; import net.jaekl.qd.xml.XmlParseException; public class BugCollection extends ParseResult { - static final String ROOT_TAG = "BugCollection"; + static final String TAG = "BugCollection"; static final String[] INTERNAL = { }; - static final Object[][] EXTERNAL = { { BugInstance.ROOT_TAG, BugInstance.class} }; + static final Object[][] EXTERNAL = { { BugInstance.TAG, BugInstance.class} }; + ArrayList m_bugs; + public BugCollection() { - super(ROOT_TAG, INTERNAL, EXTERNAL); + super(TAG, INTERNAL, EXTERNAL); + m_bugs = new ArrayList(); } + public List getBugs() { return Collections.unmodifiableList(m_bugs); } + public void add(BugInstance bug) { m_bugs.add(bug); } + @Override - public void endContents(String uri, String localName, String qName, - String chars, Attributes attr) throws XmlParseException { - // TODO Auto-generated method stub - + public void endContents(String uri, String localName, String qName, String chars) + throws XmlParseException + { + // no-op } @Override public void endExternal(String uri, String localName, String qName) - throws XmlParseException { - // TODO Auto-generated method stub - + throws XmlParseException + { + if (BugInstance.TAG.equals(localName)) { + ParseResult[] collected = collectParsedChildren(BugInstance.class); + for (ParseResult pr : collected) { + assert(pr instanceof BugInstance); + m_bugs.add((BugInstance) pr); + } + } + } + + @Override + public void dump(PrintWriter pw, int indent) { + super.dump(pw, indent); + for (BugInstance bug : m_bugs) { + bug.dump(pw, indent + 2); + } } + @Override + public boolean equals(Object obj) { + if (null == obj) { + return false; + } + if (! (obj instanceof BugCollection)) { + return false; + } + BugCollection other = (BugCollection)obj; + + return Util.listsAreEqual(this.m_bugs, other.m_bugs); + } + + @Override + public int hashCode() { + return Util.objHashCode(m_bugs); + } }