Commit 428a0c03 authored by petter's avatar petter

added accessors for XMLElement children

git-svn-id: https://www2.in.tum.de/repos/cup/develop@67 f8377d4f-c7f8-0310-b030-a31f13008fac
parent ce7d198c
......@@ -75,9 +75,12 @@ public abstract class XMLElement {
public abstract Location right();
public abstract Location left();
protected abstract void dump(XMLStreamWriter writer) throws XMLStreamException;
public abstract List<XMLElement> getChildren();
public abstract boolean hasChildren();
public static class NonTerminal extends XMLElement {
@Override
public boolean hasChildren() { return !list.isEmpty(); }
public List<XMLElement> getChildren() { return list; }
@Override
public List<XMLElement> selectById(String s) {
LinkedList<XMLElement> response= new LinkedList<XMLElement>();
if (tagname.equals(s))
......@@ -139,7 +142,9 @@ public abstract class XMLElement {
}
public static class Error extends XMLElement {
@Override
public boolean hasChildren() { return false; }
public List<XMLElement> getChildren() { return null; }
@Override
public List<XMLElement> selectById(String s) {
return new LinkedList<XMLElement>();
}
......@@ -164,7 +169,9 @@ public abstract class XMLElement {
}
public static class Terminal extends XMLElement {
public List<XMLElement> selectById(String s) {
public boolean hasChildren() { return false; }
public List<XMLElement> getChildren() { return null; }
public List<XMLElement> selectById(String s) {
List<XMLElement> ret = new LinkedList<XMLElement>();
if (tagname.equals(s)) { ret.add(this); }
return ret;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment