+
+ /** Used to hide implementation from public interface. */
+ private final class SXML extends XML {
+ private StringBuffer chars = new StringBuffer();
+ private Tree.Element element = null;
+ private Queue queue = new Queue(10);
+ int depth0 = 0;
+
+ private SXML(int b) { super(b, false); }
+ public void startElement(Tree.Element e) {
+ if (chars.length() > 0) {
+ queue.append(chars.toString());
+ queue.append(new Integer(depth0));
+ chars.setLength(0);
+ }
+ queue.append(e);
+ queue.append(new Integer(depth0));
+ depth0++;
+ }
+ public void endElement(Tree.Element e) {
+ if (chars.length() > 0) {
+ queue.append(chars.toString());
+ queue.append(new Integer(depth0));
+ chars.setLength(0);
+ }
+ depth0--;
+ }
+ public void whitespace(char[] ch, int s, int l) { characters(ch, s, l); }
+ public void characters(char[] ch, int s, int l) { chars.append(ch, s, l); }
+ private Tree.Leaf next() throws IOException, Exn {
+ while (queue.size() == 0)
+ if (!parseNext()) return null;
+ Object o = queue.remove();
+ depth = ((Integer)queue.remove()).intValue();
+ if (o instanceof String) return new Text(current(), (String)o);
+ else return (Tree.Leaf)o;
+ }
+ }
+ }
+
+ // Public Interfaces //////////////////////////////////////////////////////
+
+
+ // Support Classes ////////////////////////////////////////////////////////
+
+ /** Represents a block of text in an XML.Document model. */
+ public static final class Text implements Tree.Leaf, Serializable {
+ private Tree.Node p;
+ public String t;
+
+ Text() {}
+ Text(Tree.Node p, String t) { this.t = t; this.p = p; }
+
+ public Tree.Node getParent() { return p; }
+ public void setParent(Tree.Node parent) { p = parent; }
+ public void out(Writer out) throws IOException { out.write(t); }
+ public void out(OutputStream out) { throw new UnsupportedOperationException(); }
+ }
+
+ public static final class Elem
+ implements Tree.Element, Tree.Attributes, Tree.Prefixes, Serializable {
+ private String uri = null;
+ private String localName = null;
+ private String qName = null;
+ private String prefix = null;
+
+ private Tree.Node parent = null;
+ private Basket.List children = null;
+
+ private Tree.Attributes a = this;
+ private Tree.Prefixes p = this;
+
+ Elem() { }