diff --git a/core/src/processing/xml/StdXMLBuilder.java b/core/src/processing/xml/StdXMLBuilder.java index faa4f0902..2f94203f5 100644 --- a/core/src/processing/xml/StdXMLBuilder.java +++ b/core/src/processing/xml/StdXMLBuilder.java @@ -232,7 +232,7 @@ public class StdXMLBuilder XMLElement elt = (XMLElement) this.stack.pop(); if (elt.getChildCount() == 1) { - XMLElement child = elt.getChildAtIndex(0); + XMLElement child = elt.getChild(0); if (child.getLocalName() == null) { elt.setContent(child.getContent()); diff --git a/core/src/processing/xml/XMLElement.java b/core/src/processing/xml/XMLElement.java index 182c83882..ed2675269 100644 --- a/core/src/processing/xml/XMLElement.java +++ b/core/src/processing/xml/XMLElement.java @@ -48,104 +48,66 @@ import processing.core.PApplet; * @instanceName xml any variable of type XMLElement */ public class XMLElement implements Serializable { + /** No line number defined. */ + public static final int NO_LINE = -1; - /** No line number defined. */ - public static final int NO_LINE = -1; + /** The sketch creating this element. */ + private PApplet sketch; + + /** The parent element. */ + private XMLElement parent; + + /** The attributes of the element. */ + private Vector attributes; + + /** The child elements. */ + private Vector children; + + /** The name of the element. */ + private String name; + + /** The full name of the element (includes the namespace). */ + private String fullName; + + /** The namespace URI. */ + private String namespace; + + /** The content of the element. */ + private String content; + + /** The system ID of the source data where this element is located. */ + private String systemID; + + /** The line in the source data where this element starts. */ + private int line; - /** The parent element. */ - private XMLElement parent; + /** + * Creates an empty element to be used for #PCDATA content. + * @nowebref + */ + public XMLElement() { + this(null, null, null, NO_LINE); + } - /** The attributes of the element. */ - private Vector attributes; + /** + * Creates an empty element. + * + * @param fullName the name of the element. + */ + public XMLElement(String fullName) { + this(fullName, null, null, NO_LINE); + } - /** The child elements. */ - private Vector children; - - - /** The name of the element. */ - private String name; - - - /** - * The full name of the element. - */ - private String fullName; - - - /** - * The namespace URI. - */ - private String namespace; - - - /** - * The content of the element. - */ - private String content; - - - /** - * The system ID of the source data where this element is located. - */ - private String systemID; - - - /** - * The line in the source data where this element starts. - */ - private int line; - - - /** - * Creates an empty element to be used for #PCDATA content. - * @nowebref - */ - public XMLElement() { - this(null, null, null, NO_LINE); - } - - - protected void init(String fullName, - String namespace, - String systemID, - int lineNr) { - this.fullName = fullName; - if (namespace == null) { - this.name = fullName; - } else { - int index = fullName.indexOf(':'); - if (index >= 0) { - this.name = fullName.substring(index + 1); - } else { - this.name = fullName; - } - } - this.namespace = namespace; - this.line = lineNr; - this.systemID = systemID; - } - - - /** - * Creates an empty element. - * - * @param fullName the name of the element. - */ -// public XMLElement(String fullName) { -// this(fullName, null, null, NO_LINE); -// } - - - /** - * Creates an empty element. - * - * @param fullName the name of the element. - * @param systemID the system ID of the XML data where the element starts. - * @param lineNr the line in the XML data where the element starts. - */ +// /** +// * Creates an empty element. +// * +// * @param fullName the name of the element. +// * @param systemID the system ID of the XML data where the element starts. +// * @param lineNr the line in the XML data where the element starts. +// */ // public XMLElement(String fullName, // String systemID, // int lineNr) { @@ -153,138 +115,151 @@ public class XMLElement implements Serializable { // } - /** - * Creates an empty element. - * - * @param fullName the full name of the element - * @param namespace the namespace URI. - */ +// /** +// * Creates an empty element. +// * +// * @param fullName the full name of the element +// * @param namespace the namespace URI. +// */ // public XMLElement(String fullName, // String namespace) { // this(fullName, namespace, null, NO_LINE); // } - /** - * Creates an empty element. - * - * @param fullName the full name of the element - * @param namespace the namespace URI. - * @param systemID the system ID of the XML data where the element starts. - * @param lineNr the line in the XML data where the element starts. - * @nowebref - */ - public XMLElement(String fullName, + /** + * Creates an empty element. (Used internally for parsing/building.) + * + * @param fullName the full name of the element + * @param namespace the namespace URI. + * @param systemID the system ID of the XML data where the element starts. + * @param lineNr the line in the XML data where the element starts. + * @nowebref + */ + public XMLElement(String fullName, + String namespace, + String systemID, + int lineNr) { + this.attributes = new Vector(); + this.children = new Vector(8); + this.fullName = fullName; + if (namespace == null) { + this.name = fullName; + } else { + int index = fullName.indexOf(':'); + if (index >= 0) { + this.name = fullName.substring(index + 1); + } else { + this.name = fullName; + } + } + this.namespace = namespace; + this.content = null; + this.line = lineNr; + this.systemID = systemID; + this.parent = null; + } + + + /** + * Begin parsing XML data passed in from a PApplet. This code + * wraps exception handling, for more advanced exception handling, + * use the constructor that takes a Reader or InputStream. + * @author processing.org + * @param filename name of the XML file to load + * @param parent typically use "this" + */ + public XMLElement(PApplet sketch, String filename) { + this(); + this.sketch = sketch; + init(sketch.createReader(filename)); + } + + + public XMLElement(Reader reader) { + this(); + init(reader); + } + + + static public XMLElement parse(String xml) { + return parse(new StringReader(xml)); + } + + + static public XMLElement parse(Reader r) { + try { + StdXMLParser parser = new StdXMLParser(); + parser.setBuilder(new StdXMLBuilder()); + parser.setValidator(new XMLValidator()); + parser.setReader(new StdXMLReader(r)); + return (XMLElement) parser.parse(); + } catch (XMLException e) { + e.printStackTrace(); + return null; + } + } + + + protected void init(String fullName, String namespace, String systemID, - int lineNr) { - this.attributes = new Vector(); - this.children = new Vector(8); - this.fullName = fullName; - if (namespace == null) { - this.name = fullName; - } else { - int index = fullName.indexOf(':'); - if (index >= 0) { - this.name = fullName.substring(index + 1); - } else { - this.name = fullName; - } - } - this.namespace = namespace; - this.content = null; - this.line = lineNr; - this.systemID = systemID; - this.parent = null; + int lineNr) { + this.fullName = fullName; + if (namespace == null) { + this.name = fullName; + } else { + int index = fullName.indexOf(':'); + if (index >= 0) { + this.name = fullName.substring(index + 1); + } else { + this.name = fullName; + } } + this.namespace = namespace; + this.line = lineNr; + this.systemID = systemID; + } - /** - * Begin parsing XML data passed in from a PApplet. This code - * wraps exception handling, for more advanced exception handling, - * use the constructor that takes a Reader or InputStream. - * @author processing.org - * @param filename name of the XML file to load - * @param parent typically use "this" - */ - public XMLElement(PApplet parent, String filename) { - this(); - parseFromReader(parent.createReader(filename)); - } - - /** - * @nowebref - */ - public XMLElement(Reader r) { - this(); - parseFromReader(r); - } - - /** - * @nowebref - */ - public XMLElement(String xml) { - this(); - parseFromReader(new StringReader(xml)); + protected void init(Reader r) { + try { + StdXMLParser parser = new StdXMLParser(); + parser.setBuilder(new StdXMLBuilder(this)); + parser.setValidator(new XMLValidator()); + parser.setReader(new StdXMLReader(r)); + parser.parse(); + } catch (XMLException e) { + e.printStackTrace(); } + } - protected void parseFromReader(Reader r) { - try { - StdXMLParser parser = new StdXMLParser(); - parser.setBuilder(new StdXMLBuilder(this)); - parser.setValidator(new XMLValidator()); - parser.setReader(new StdXMLReader(r)); - //System.out.println(parser.parse().getName()); - /*XMLElement xm = (XMLElement)*/ parser.parse(); - //System.out.println("xm name is " + xm.getName()); - //System.out.println(xm + " " + this); - //parser.parse(); - } catch (XMLException e) { - e.printStackTrace(); - } - } - - -// static public XMLElement parse(Reader r) { -// try { -// StdXMLParser parser = new StdXMLParser(); -// parser.setBuilder(new StdXMLBuilder()); -// parser.setValidator(new XMLValidator()); -// parser.setReader(new StdXMLReader(r)); -// return (XMLElement) parser.parse(); -// } catch (XMLException e) { -// e.printStackTrace(); -// return null; -// } +// /** +// * Creates an element to be used for #PCDATA content. +// */ +// public XMLElement createPCDataElement() { +// return new XMLElement(); // } - /** - * Creates an element to be used for #PCDATA content. - */ - public XMLElement createPCDataElement() { - return new XMLElement(); - } - - - /** - * Creates an empty element. - * - * @param fullName the name of the element. - */ +// /** +// * Creates an empty element. +// * +// * @param fullName the name of the element. +// */ // public XMLElement createElement(String fullName) { -// return new XMLElement(fullName); +// return new XMLElement(fullName); // } - /** - * Creates an empty element. - * - * @param fullName the name of the element. - * @param systemID the system ID of the XML data where the element starts. - * @param lineNr the line in the XML data where the element starts. - */ +// /** +// * Creates an empty element. +// * +// * @param fullName the name of the element. +// * @param systemID the system ID of the XML data where the element starts. +// * @param lineNr the line in the XML data where the element starts. +// */ // public XMLElement createElement(String fullName, // String systemID, // int lineNr) { @@ -293,194 +268,193 @@ public class XMLElement implements Serializable { // } - /** - * Creates an empty element. - * - * @param fullName the full name of the element - * @param namespace the namespace URI. - */ - public XMLElement createElement(String fullName, - String namespace) { - //return new XMLElement(fullName, namespace); - return new XMLElement(fullName, namespace, null, NO_LINE); +// /** +// * Creates an empty element. +// * +// * @param fullName the full name of the element +// * @param namespace the namespace URI. +// */ +// public XMLElement createElement(String fullName, +// String namespace) { +// //return new XMLElement(fullName, namespace); +// return new XMLElement(fullName, namespace, null, NO_LINE); +// } + + +// /** +// * Creates an empty element. +// * +// * @param fullName the full name of the element +// * @param namespace the namespace URI. +// * @param systemID the system ID of the XML data where the element starts. +// * @param lineNr the line in the XML data where the element starts. +// */ +// public XMLElement createElement(String fullName, +// String namespace, +// String systemID, +// int lineNr) { +// return new XMLElement(fullName, namespace, systemID, lineNr); +// } + + + /** + * Cleans up the object when it's destroyed. + */ + protected void finalize() throws Throwable { + this.attributes.clear(); + this.attributes = null; + this.children = null; + this.fullName = null; + this.name = null; + this.namespace = null; + this.content = null; + this.systemID = null; + this.parent = null; + super.finalize(); + } + + + /** + * Returns the parent element. This method returns null for the root + * element. + */ + public XMLElement getParent() { + return this.parent; + } + + + /** + * Returns the full name (i.e. the name including an eventual namespace + * prefix) of the element. + * + * @webref + * @brief Returns the name of the element. + * @return the name, or null if the element only contains #PCDATA. + */ + public String getName() { + return this.fullName; + } + + + /** + * Returns the name of the element without its namespace. + * + * @return the name, or null if the element only contains #PCDATA. + */ + public String getLocalName() { + return this.name; + } + + + /** + * Returns the namespace of the element. + * + * @return the namespace, or null if no namespace is associated with the + * element. + */ + public String getNamespace() { + return this.namespace; + } + + + /** + * Sets the full name. This method also sets the short name and clears the + * namespace URI. + * + * @param name the non-null name. + */ + public void setName(String name) { + this.name = name; + this.fullName = name; + this.namespace = null; + } + + + /** + * Sets the name. + * + * @param fullName the non-null full name. + * @param namespace the namespace URI, which may be null. + */ + public void setName(String fullName, String namespace) { + int index = fullName.indexOf(':'); + if ((namespace == null) || (index < 0)) { + this.name = fullName; + } else { + this.name = fullName.substring(index + 1); } + this.fullName = fullName; + this.namespace = namespace; + } - /** - * Creates an empty element. - * - * @param fullName the full name of the element - * @param namespace the namespace URI. - * @param systemID the system ID of the XML data where the element starts. - * @param lineNr the line in the XML data where the element starts. - */ - public XMLElement createElement(String fullName, - String namespace, - String systemID, - int lineNr) { - return new XMLElement(fullName, namespace, systemID, lineNr); + /** + * Adds a child element. + * + * @param child the non-null child to add. + */ + public void addChild(XMLElement child) { + if (child == null) { + throw new IllegalArgumentException("child must not be null"); } + if ((child.getLocalName() == null) && (! this.children.isEmpty())) { + XMLElement lastChild = (XMLElement) this.children.lastElement(); - - /** - * Cleans up the object when it's destroyed. - */ - protected void finalize() throws Throwable { - this.attributes.clear(); - this.attributes = null; - this.children = null; - this.fullName = null; - this.name = null; - this.namespace = null; - this.content = null; - this.systemID = null; - this.parent = null; - super.finalize(); + if (lastChild.getLocalName() == null) { + lastChild.setContent(lastChild.getContent() + + child.getContent()); + return; + } } + ((XMLElement)child).parent = this; + this.children.addElement(child); + } - /** - * Returns the parent element. This method returns null for the root - * element. - */ - public XMLElement getParent() { - return this.parent; + /** + * Inserts a child element. + * + * @param child the non-null child to add. + * @param index where to put the child. + */ + public void insertChild(XMLElement child, int index) { + if (child == null) { + throw new IllegalArgumentException("child must not be null"); } - - - /** - * Returns the full name (i.e. the name including an eventual namespace - * prefix) of the element. - * - * @webref - * @brief Returns the name of the element. - * @return the name, or null if the element only contains #PCDATA. - */ - public String getName() { - return this.fullName; + if ((child.getLocalName() == null) && (! this.children.isEmpty())) { + XMLElement lastChild = (XMLElement) this.children.lastElement(); + if (lastChild.getLocalName() == null) { + lastChild.setContent(lastChild.getContent() + + child.getContent()); + return; + } } + ((XMLElement) child).parent = this; + this.children.insertElementAt(child, index); + } - /** - * Returns the name of the element. - * - * @return the name, or null if the element only contains #PCDATA. - */ - public String getLocalName() { - return this.name; + /** + * Removes a child element. + * + * @param child the non-null child to remove. + */ + public void removeChild(XMLElement child) { + if (child == null) { + throw new IllegalArgumentException("child must not be null"); } + this.children.removeElement(child); + } - /** - * Returns the namespace of the element. - * - * @return the namespace, or null if no namespace is associated with the - * element. - */ - public String getNamespace() { - return this.namespace; - } - - - /** - * Sets the full name. This method also sets the short name and clears the - * namespace URI. - * - * @param name the non-null name. - */ - public void setName(String name) { - this.name = name; - this.fullName = name; - this.namespace = null; - } - - - /** - * Sets the name. - * - * @param fullName the non-null full name. - * @param namespace the namespace URI, which may be null. - */ - public void setName(String fullName, String namespace) { - int index = fullName.indexOf(':'); - if ((namespace == null) || (index < 0)) { - this.name = fullName; - } else { - this.name = fullName.substring(index + 1); - } - this.fullName = fullName; - this.namespace = namespace; - } - - - /** - * Adds a child element. - * - * @param child the non-null child to add. - */ - public void addChild(XMLElement child) { - if (child == null) { - throw new IllegalArgumentException("child must not be null"); - } - if ((child.getLocalName() == null) && (! this.children.isEmpty())) { - XMLElement lastChild = (XMLElement) this.children.lastElement(); - - if (lastChild.getLocalName() == null) { - lastChild.setContent(lastChild.getContent() - + child.getContent()); - return; - } - } - ((XMLElement)child).parent = this; - this.children.addElement(child); - } - - - /** - * Inserts a child element. - * - * @param child the non-null child to add. - * @param index where to put the child. - */ - public void insertChild(XMLElement child, int index) { - if (child == null) { - throw new IllegalArgumentException("child must not be null"); - } - if ((child.getLocalName() == null) && (! this.children.isEmpty())) { - XMLElement lastChild = (XMLElement) this.children.lastElement(); - if (lastChild.getLocalName() == null) { - lastChild.setContent(lastChild.getContent() - + child.getContent()); - return; - } - } - ((XMLElement) child).parent = this; - this.children.insertElementAt(child, index); - } - - - /** - * Removes a child element. - * - * @param child the non-null child to remove. - */ - public void removeChild(XMLElement child) { - if (child == null) { - throw new IllegalArgumentException("child must not be null"); - } - this.children.removeElement(child); - } - - - /** - * Removes the child located at a certain index. - * - * @param index the index of the child, where the first child has index 0. - */ -// public void removeChildAtIndex(int index) { - public void removeChild(int index) { - this.children.removeElementAt(index); - } + /** + * Removes the child located at a certain index. + * + * @param index the index of the child, where the first child has index 0. + */ + public void removeChild(int index) { + children.removeElementAt(index); + } // /** @@ -493,37 +467,37 @@ public class XMLElement implements Serializable { // } - /** - * Returns whether the element is a leaf element. - * - * @return true if the element has no children. - */ - public boolean isLeaf() { - return this.children.isEmpty(); - } + /** + * Returns whether the element is a leaf element. + * + * @return true if the element has no children. + */ + public boolean isLeaf() { + return children.isEmpty(); + } - /** - * Returns whether the element has children. - * - * @return true if the element has children. - */ - public boolean hasChildren() { - return (! this.children.isEmpty()); - } + /** + * Returns whether the element has children. + * + * @return true if the element has children. + */ + public boolean hasChildren() { + return (!children.isEmpty()); + } - /** - * Returns the number of children for the element. - * - * @return the count. - * @webref - * @see processing.xml.XMLElement#getChild(int) - * @see processing.xml.XMLElement#getChildren(String) - */ - public int getChildCount() { - return this.children.size(); - } + /** + * Returns the number of children for the element. + * + * @return the count. + * @webref + * @see processing.xml.XMLElement#getChild(int) + * @see processing.xml.XMLElement#getChildren(String) + */ + public int getChildCount() { + return this.children.size(); + } /** @@ -536,288 +510,186 @@ public class XMLElement implements Serializable { // } - /** - * Put the names of all children into an array. Same as looping through - * each child and calling getName() on each XMLElement. - */ - public String[] listChildren() { - int childCount = getChildCount(); - String[] outgoing = new String[childCount]; - for (int i = 0; i < childCount; i++) { - outgoing[i] = getChild(i).getName(); + /** + * Put the names of all children into an array. Same as looping through + * each child and calling getName() on each XMLElement. + */ + public String[] listChildren() { + int childCount = getChildCount(); + String[] outgoing = new String[childCount]; + for (int i = 0; i < childCount; i++) { + outgoing[i] = getChild(i).getName(); + } + return outgoing; + } + + + /** + * Returns an array containing all the child elements. + */ + public XMLElement[] getChildren() { + int childCount = getChildCount(); + XMLElement[] kids = new XMLElement[childCount]; + children.copyInto(kids); + return kids; + } + + + /** + * Quick accessor for an element at a particular index. + * @author processing.org + * @param index the element + */ + public XMLElement getChild(int index) { + return (XMLElement) children.elementAt(index); + } + + + /** + * Returns the child XMLElement as specified by the index parameter. The value of the index parameter must be less than the total number of children to avoid going out of the array storing the child elements. + * When the path parameter is specified, then it will return all children that match that path. The path is a series of elements and sub-elements, separated by slashes. + * + * @return the element + * @author processing.org + * + * @webref + * @see processing.xml.XMLElement#getChildCount() + * @see processing.xml.XMLElement#getChildren(String) + * @brief Get a child by its name or path. + * @param path path to a particular element + */ + public XMLElement getChild(String path) { + if (path.indexOf('/') != -1) { + return getChildRecursive(PApplet.split(path, '/'), 0); + } + int childCount = getChildCount(); + for (int i = 0; i < childCount; i++) { + XMLElement kid = getChild(i); + String kidName = kid.getName(); + if (kidName != null && kidName.equals(path)) { + return kid; } - return outgoing; } - - - /** - * Returns an array containing all the child elements. - */ - public XMLElement[] getChildren() { - int childCount = getChildCount(); - XMLElement[] kids = new XMLElement[childCount]; - children.copyInto(kids); - return kids; + return null; + } + + + /** + * Internal helper function for getChild(String). + * @param items result of splitting the query on slashes + * @param offset where in the items[] array we're currently looking + * @return matching element or null if no match + * @author processing.org + */ + protected XMLElement getChildRecursive(String[] items, int offset) { + // if it's a number, do an index instead + if (Character.isDigit(items[offset].charAt(0))) { + XMLElement kid = getChild(Integer.parseInt(items[offset])); + if (offset == items.length-1) { + return kid; + } else { + return kid.getChildRecursive(items, offset+1); + } } - - - /** - * Quick accessor for an element at a particular index. - * @author processing.org - * @param index the element - */ - public XMLElement getChild(int index) { - return (XMLElement) children.elementAt(index); - } - - - /** - * Returns the child XMLElement as specified by the index parameter. The value of the index parameter must be less than the total number of children to avoid going out of the array storing the child elements. - * When the path parameter is specified, then it will return all children that match that path. The path is a series of elements and sub-elements, separated by slashes. - * - * @return the element - * @author processing.org - * - * @webref - * @see processing.xml.XMLElement#getChildCount() - * @see processing.xml.XMLElement#getChildren(String) - * @brief Get a child by its name or path. - * @param path path to a particular element - */ - public XMLElement getChild(String path) { - if (path.indexOf('/') != -1) { - return getChildRecursive(PApplet.split(path, '/'), 0); + int childCount = getChildCount(); + for (int i = 0; i < childCount; i++) { + XMLElement kid = getChild(i); + String kidName = kid.getName(); + if (kidName != null && kidName.equals(items[offset])) { + if (offset == items.length-1) { + return kid; + } else { + return kid.getChildRecursive(items, offset+1); } - int childCount = getChildCount(); - for (int i = 0; i < childCount; i++) { - XMLElement kid = getChild(i); - String kidName = kid.getName(); - if (kidName != null && kidName.equals(path)) { - return kid; - } - } - return null; + } } + return null; + } - /** - * Internal helper function for getChild(String). - * @param items result of splitting the query on slashes - * @param offset where in the items[] array we're currently looking - * @return matching element or null if no match - * @author processing.org - */ - protected XMLElement getChildRecursive(String[] items, int offset) { - // if it's a number, do an index instead - if (Character.isDigit(items[offset].charAt(0))) { - XMLElement kid = getChild(Integer.parseInt(items[offset])); - if (offset == items.length-1) { - return kid; - } else { - return kid.getChildRecursive(items, offset+1); - } - } - int childCount = getChildCount(); - for (int i = 0; i < childCount; i++) { - XMLElement kid = getChild(i); - String kidName = kid.getName(); - if (kidName != null && kidName.equals(items[offset])) { - if (offset == items.length-1) { - return kid; - } else { - return kid.getChildRecursive(items, offset+1); - } - } - } - return null; +// /** +// * Returns the child at a specific index. +// * +// * @param index the index of the child +// * +// * @return the non-null child +// * +// * @throws java.lang.ArrayIndexOutOfBoundsException +// * if the index is out of bounds. +// */ +// public XMLElement getChildAtIndex(int index) throws ArrayIndexOutOfBoundsException { +// return (XMLElement) this.children.elementAt(index); +// } + + + /** + * Returns all of the children as an XMLElement array. + * When the path parameter is specified, then it will return all children that match that path. + * The path is a series of elements and sub-elements, separated by slashes. + * + * @param path element name or path/to/element + * @return array of child elements that match + * @author processing.org + * + * @webref + * @brief Returns all of the children as an XMLElement array. + * @see processing.xml.XMLElement#getChildCount() + * @see processing.xml.XMLElement#getChild(int) + */ + public XMLElement[] getChildren(String path) { + if (path.indexOf('/') != -1) { + return getChildrenRecursive(PApplet.split(path, '/'), 0); } - - - /** - * Returns the child at a specific index. - * - * @param index the index of the child - * - * @return the non-null child - * - * @throws java.lang.ArrayIndexOutOfBoundsException - * if the index is out of bounds. - */ - public XMLElement getChildAtIndex(int index) - throws ArrayIndexOutOfBoundsException { - return (XMLElement) this.children.elementAt(index); + // if it's a number, do an index instead + // (returns a single element array, since this will be a single match + if (Character.isDigit(path.charAt(0))) { + return new XMLElement[] { getChild(Integer.parseInt(path)) }; } - - - /** - * Searches a child element. - * - * @param name the full name of the child to search for. - * - * @return the child element, or null if no such child was found. - */ -// public XMLElement getFirstChildNamed(String name) { -// Enumeration enum = this.children.elements(); -// while (enum.hasMoreElements()) { -// XMLElement child = (XMLElement) enum.nextElement(); -// String childName = child.getFullName(); -// if ((childName != null) && childName.equals(name)) { -// return child; -// } -// } -// return null; -// } - - - /** - * Searches a child element. - * - * @param name the name of the child to search for. - * @param namespace the namespace, which may be null. - * - * @return the child element, or null if no such child was found. - */ -// public XMLElement getFirstChildNamed(String name, -// String namespace) { -// Enumeration enum = this.children.elements(); -// while (enum.hasMoreElements()) { -// XMLElement child = (XMLElement) enum.nextElement(); -// String str = child.getName(); -// boolean found = (str != null) && (str.equals(name)); -// str = child.getNamespace(); -// if (str == null) { -// found &= (name == null); -// } else { -// found &= str.equals(namespace); -// } -// if (found) { -// return child; -// } -// } -// return null; -// } - - - /** - * Returns all of the children as an XMLElement array. - * When the path parameter is specified, then it will return all children that match that path. - * The path is a series of elements and sub-elements, separated by slashes. - * - * @param path element name or path/to/element - * @return array of child elements that match - * @author processing.org - * - * @webref - * @brief Returns all of the children as an XMLElement array. - * @see processing.xml.XMLElement#getChildCount() - * @see processing.xml.XMLElement#getChild(int) - */ - public XMLElement[] getChildren(String path) { - if (path.indexOf('/') != -1) { - return getChildrenRecursive(PApplet.split(path, '/'), 0); - } - // if it's a number, do an index instead - // (returns a single element array, since this will be a single match - if (Character.isDigit(path.charAt(0))) { - return new XMLElement[] { getChild(Integer.parseInt(path)) }; - } - int childCount = getChildCount(); - XMLElement[] matches = new XMLElement[childCount]; - int matchCount = 0; - for (int i = 0; i < childCount; i++) { - XMLElement kid = getChild(i); - String kidName = kid.getName(); - if (kidName != null && kidName.equals(path)) { - matches[matchCount++] = kid; - } - } - return (XMLElement[]) PApplet.subset(matches, 0, matchCount); + int childCount = getChildCount(); + XMLElement[] matches = new XMLElement[childCount]; + int matchCount = 0; + for (int i = 0; i < childCount; i++) { + XMLElement kid = getChild(i); + String kidName = kid.getName(); + if (kidName != null && kidName.equals(path)) { + matches[matchCount++] = kid; + } } + return (XMLElement[]) PApplet.subset(matches, 0, matchCount); + } - protected XMLElement[] getChildrenRecursive(String[] items, int offset) { - if (offset == items.length-1) { - return getChildren(items[offset]); - } - XMLElement[] matches = getChildren(items[offset]); - XMLElement[] outgoing = new XMLElement[0]; - for (int i = 0; i < matches.length; i++) { - XMLElement[] kidMatches = matches[i].getChildrenRecursive(items, offset+1); - outgoing = (XMLElement[]) PApplet.concat(outgoing, kidMatches); - } - return outgoing; + protected XMLElement[] getChildrenRecursive(String[] items, int offset) { + if (offset == items.length-1) { + return getChildren(items[offset]); } - - - /** - * Returns a vector of all child elements named name. - * - * @param name the full name of the children to search for. - * - * @return the non-null vector of child elements. - */ -// public Vector getChildrenNamed(String name) { -// Vector result = new Vector(this.children.size()); -// Enumeration enum = this.children.elements(); -// while (enum.hasMoreElements()) { -// XMLElement child = (XMLElement) enum.nextElement(); -// String childName = child.getFullName(); -// if ((childName != null) && childName.equals(name)) { -// result.addElement(child); -// } -// } -// return result; -// } - - - /** - * Returns a vector of all child elements named name. - * - * @param name the name of the children to search for. - * @param namespace the namespace, which may be null. - * - * @return the non-null vector of child elements. - */ -// public Vector getChildrenNamed(String name, -// String namespace) { -// Vector result = new Vector(this.children.size()); -// Enumeration enum = this.children.elements(); -// while (enum.hasMoreElements()) { -// XMLElement child = (XMLElement) enum.nextElement(); -// String str = child.getName(); -// boolean found = (str != null) && (str.equals(name)); -// str = child.getNamespace(); -// if (str == null) { -// found &= (name == null); -// } else { -// found &= str.equals(namespace); -// } -// -// if (found) { -// result.addElement(child); -// } -// } -// return result; -// } - - - /** - * Searches an attribute. - * - * @param fullName the non-null full name of the attribute. - * - * @return the attribute, or null if the attribute does not exist. - */ - private XMLAttribute findAttribute(String fullName) { - Enumeration en = this.attributes.elements(); - while (en.hasMoreElements()) { - XMLAttribute attr = (XMLAttribute) en.nextElement(); - if (attr.getFullName().equals(fullName)) { - return attr; - } - } - return null; + XMLElement[] matches = getChildren(items[offset]); + XMLElement[] outgoing = new XMLElement[0]; + for (int i = 0; i < matches.length; i++) { + XMLElement[] kidMatches = matches[i].getChildrenRecursive(items, offset+1); + outgoing = (XMLElement[]) PApplet.concat(outgoing, kidMatches); } + return outgoing; + } + + + /** + * Searches an attribute. + * + * @param fullName the non-null full name of the attribute. + * + * @return the attribute, or null if the attribute does not exist. + */ + private XMLAttribute findAttribute(String fullName) { + Enumeration en = this.attributes.elements(); + while (en.hasMoreElements()) { + XMLAttribute attr = (XMLAttribute) en.nextElement(); + if (attr.getFullName().equals(fullName)) { + return attr; + } + } + return null; + } // /** @@ -848,61 +720,59 @@ public class XMLElement implements Serializable { // } - /** - * Returns the number of attributes. - */ - public int getAttributeCount() { - return this.attributes.size(); - } - - - public String[] listAttributes() { - String[] outgoing = new String[attributes.size()]; - attributes.copyInto(outgoing); - return outgoing; + /** + * Returns the number of attributes. + */ + public int getAttributeCount() { + return this.attributes.size(); + } + + + public String[] listAttributes() { + String[] outgoing = new String[attributes.size()]; + attributes.copyInto(outgoing); + return outgoing; + } + + + /** + * Returns the value of an attribute. + * @param name the non-null name of the attribute. + * @return the value, or null if the attribute does not exist. + */ + public String getAttribute(String name) { + return this.getAttribute(name, null); + } + + + /** + * Returns the value of an attribute. + * + * @param name the non-null full name of the attribute. + * @param defaultValue the default value of the attribute. + * + * @return the value, or defaultValue if the attribute does not exist. + */ + public String getAttribute(String name, String defaultValue) { + XMLAttribute attr = this.findAttribute(name); + if (attr == null) { + return defaultValue; + } else { + return attr.getValue(); } + } - /** - * Returns the value of an attribute. - * - * @param name the non-null name of the attribute. - * - * @return the value, or null if the attribute does not exist. - */ - public String getAttribute(String name) { - return this.getAttribute(name, null); - } - - - /** - * Returns the value of an attribute. - * - * @param name the non-null full name of the attribute. - * @param defaultValue the default value of the attribute. - * - * @return the value, or defaultValue if the attribute does not exist. - */ - public String getAttribute(String name, String defaultValue) { - XMLAttribute attr = this.findAttribute(name); - if (attr == null) { - return defaultValue; - } else { - return attr.getValue(); - } - } - - - /** - * Returns the value of an attribute. - * - * @param name the non-null name of the attribute. - * @param namespace the namespace URI, which may be null. - * @param defaultValue the default value of the attribute. - * - * @return the value, or defaultValue if the attribute does not exist. - * @deprecated namespace code is more trouble than it's worth - */ +// /** +// * Returns the value of an attribute. +// * +// * @param name the non-null name of the attribute. +// * @param namespace the namespace URI, which may be null. +// * @param defaultValue the default value of the attribute. +// * +// * @return the value, or defaultValue if the attribute does not exist. +// * @deprecated namespace code is more trouble than it's worth +// */ // public String getAttribute(String name, // String namespace, // String defaultValue) { @@ -915,29 +785,29 @@ public class XMLElement implements Serializable { // } - /** - * @deprecated use getString() or getAttribute() - */ - public String getStringAttribute(String name) { - return getAttribute(name); - } + /** + * @deprecated use getString() or getAttribute() + */ + public String getStringAttribute(String name) { + return getAttribute(name); + } - /** - * Returns a String attribute of the element. - * If the default parameter is used and the attribute doesn't exist, the default value is returned. - * When using the version of the method without the default parameter, if the attribute doesn't exist, the value 0 is returned. - * - * @webref - * @param name the name of the attribute - * @param default Value value returned if the attribute is not found - * - * @brief Returns a String attribute of the element. - * @deprecated use getString() or getAttribute() - */ - public String getStringAttribute(String name, String defaultValue) { - return getAttribute(name, defaultValue); - } + /** + * Returns a String attribute of the element. + * If the default parameter is used and the attribute doesn't exist, the default value is returned. + * When using the version of the method without the default parameter, if the attribute doesn't exist, the value 0 is returned. + * + * @webref + * @param name the name of the attribute + * @param default Value value returned if the attribute is not found + * + * @brief Returns a String attribute of the element. + * @deprecated use getString() or getAttribute() + */ + public String getStringAttribute(String name, String defaultValue) { + return getAttribute(name, defaultValue); + } // /** @@ -950,51 +820,51 @@ public class XMLElement implements Serializable { // } - public String getString(String name) { - return getAttribute(name); - } - - - public String getString(String name, String defaultValue) { - return getAttribute(name, defaultValue); - } - - - /** - * Returns a boolean attribute of the element. - */ - public boolean getBoolean(String name) { - return getBoolean(name, false); - } + public String getString(String name) { + return getAttribute(name); + } - /** - * Returns a boolean attribute of the element. - * If the defaultValue parameter is used and the attribute doesn't exist, the defaultValue is returned. - * When using the version of the method without the defaultValue parameter, if the attribute doesn't exist, the value false is returned. - * - * @param name the name of the attribute - * @param defaultValue value returned if the attribute is not found - * - * @webref - * @brief Returns a boolean attribute of the element. - * @return the value, or defaultValue if the attribute does not exist. - */ - public boolean getBoolean(String name, boolean defaultValue) { - String value = this.getAttribute(name, Boolean.toString(defaultValue)); - return value.equals("1") || value.toLowerCase().equals("true"); - } + public String getString(String name, String defaultValue) { + return getAttribute(name, defaultValue); + } - /** - * Returns the value of an attribute. - * - * @param name the non-null name of the attribute. - * @param namespace the namespace URI, which may be null. - * @param defaultValue the default value of the attribute. - * - * @return the value, or defaultValue if the attribute does not exist. - */ + /** + * Returns a boolean attribute of the element. + */ + public boolean getBoolean(String name) { + return getBoolean(name, false); + } + + + /** + * Returns a boolean attribute of the element. + * If the defaultValue parameter is used and the attribute doesn't exist, the defaultValue is returned. + * When using the version of the method without the defaultValue parameter, if the attribute doesn't exist, the value false is returned. + * + * @param name the name of the attribute + * @param defaultValue value returned if the attribute is not found + * + * @webref + * @brief Returns a boolean attribute of the element. + * @return the value, or defaultValue if the attribute does not exist. + */ + public boolean getBoolean(String name, boolean defaultValue) { + String value = this.getAttribute(name, Boolean.toString(defaultValue)); + return value.equals("1") || value.toLowerCase().equals("true"); + } + + +// /** +// * Returns the value of an attribute. +// * +// * @param name the non-null name of the attribute. +// * @param namespace the namespace URI, which may be null. +// * @param defaultValue the default value of the attribute. +// * +// * @return the value, or defaultValue if the attribute does not exist. +// */ // public boolean getBooleanAttribute(String name, // String namespace, // boolean defaultValue) { @@ -1004,46 +874,46 @@ public class XMLElement implements Serializable { // } - /** - * @deprecated use getInt() instead - */ - public int getIntAttribute(String name) { - return getInt(name, 0); - } - - - /** - * @deprecated use getInt() instead - */ - public int getIntAttribute(String name, int defaultValue) { - return getInt(name, defaultValue); - } - - - /** - * Returns an integer attribute of the element. - */ - public int getInt(String name) { - return getInt(name, 0); - } + /** + * @deprecated use getInt() instead + */ + public int getIntAttribute(String name) { + return getInt(name, 0); + } - /** - * Returns an integer attribute of the element. - * If the default parameter is used and the attribute doesn't exist, the default value is returned. - * When using the version of the method without the default parameter, if the attribute doesn't exist, the value 0 is returned. - * - * @param name the name of the attribute - * @param defaultValue value returned if the attribute is not found - * - * @webref - * @brief Returns an integer attribute of the element. - * @return the value, or defaultValue if the attribute does not exist. - */ - public int getInt(String name, int defaultValue) { - String value = this.getAttribute(name, Integer.toString(defaultValue)); - return Integer.parseInt(value); - } + /** + * @deprecated use getInt() instead + */ + public int getIntAttribute(String name, int defaultValue) { + return getInt(name, defaultValue); + } + + + /** + * Returns an integer attribute of the element. + */ + public int getInt(String name) { + return getInt(name, 0); + } + + + /** + * Returns an integer attribute of the element. + * If the default parameter is used and the attribute doesn't exist, the default value is returned. + * When using the version of the method without the default parameter, if the attribute doesn't exist, the value 0 is returned. + * + * @param name the name of the attribute + * @param defaultValue value returned if the attribute is not found + * + * @webref + * @brief Returns an integer attribute of the element. + * @return the value, or defaultValue if the attribute does not exist. + */ + public int getInt(String name, int defaultValue) { + String value = this.getAttribute(name, Integer.toString(defaultValue)); + return Integer.parseInt(value); + } // /** @@ -1065,39 +935,39 @@ public class XMLElement implements Serializable { // } - /** - * @deprecated use getFloat() instead - */ - public float getFloatAttribute(String name) { - return getFloat(name, 0); - } - - - /** - * @deprecated use getFloat() instead - */ - public float getFloatAttribute(String name, float defaultValue) { - return getFloat(name, 0); - } + /** + * @deprecated use getFloat() instead + */ + public float getFloatAttribute(String name) { + return getFloat(name, 0); + } - /** - * Returns a float attribute of the element. - * If the default parameter is used and the attribute doesn't exist, the default value is returned. - * When using the version of the method without the default parameter, if the attribute doesn't exist, the value 0 is returned. - * - * @param name the name of the attribute - * @param defaultValue value returned if the attribute is not found - * - * @return the value, or defaultValue if the attribute does not exist. - * - * @webref - * @brief Returns a float attribute of the element. - */ - public float getFloat(String name, float defaultValue) { - String value = this.getAttribute(name, Float.toString(defaultValue)); - return Float.parseFloat(value); - } + /** + * @deprecated use getFloat() instead + */ + public float getFloatAttribute(String name, float defaultValue) { + return getFloat(name, 0); + } + + + /** + * Returns a float attribute of the element. + * If the default parameter is used and the attribute doesn't exist, the default value is returned. + * When using the version of the method without the default parameter, if the attribute doesn't exist, the value 0 is returned. + * + * @param name the name of the attribute + * @param defaultValue value returned if the attribute is not found + * + * @return the value, or defaultValue if the attribute does not exist. + * + * @webref + * @brief Returns a float attribute of the element. + */ + public float getFloat(String name, float defaultValue) { + String value = this.getAttribute(name, Float.toString(defaultValue)); + return Float.parseFloat(value); + } // /** @@ -1120,23 +990,23 @@ public class XMLElement implements Serializable { // } - public double getDouble(String name) { - return getDouble(name, 0); - } + public double getDouble(String name) { + return getDouble(name, 0); + } - /** - * Returns the value of an attribute. - * - * @param name the non-null full name of the attribute. - * @param defaultValue the default value of the attribute. - * - * @return the value, or defaultValue if the attribute does not exist. - */ - public double getDouble(String name, double defaultValue) { - String value = this.getAttribute(name, Double.toString(defaultValue)); - return Double.parseDouble(value); - } + /** + * Returns the value of an attribute. + * + * @param name the non-null full name of the attribute. + * @param defaultValue the default value of the attribute. + * + * @return the value, or defaultValue if the attribute does not exist. + */ + public double getDouble(String name, double defaultValue) { + String value = this.getAttribute(name, Double.toString(defaultValue)); + return Double.parseDouble(value); + } // /** @@ -1218,21 +1088,21 @@ public class XMLElement implements Serializable { // } - /** - * Sets an attribute. - * - * @param name the non-null full name of the attribute. - * @param value the non-null value of the attribute. - */ - public void set(String name, String value) { - XMLAttribute attr = this.findAttribute(name); - if (attr == null) { - attr = new XMLAttribute(name, name, null, value, "CDATA"); - this.attributes.addElement(attr); - } else { - attr.setValue(value); - } + /** + * Sets an attribute. + * + * @param name the non-null full name of the attribute. + * @param value the non-null value of the attribute. + */ + public void set(String name, String value) { + XMLAttribute attr = this.findAttribute(name); + if (attr == null) { + attr = new XMLAttribute(name, name, null, value, "CDATA"); + this.attributes.addElement(attr); + } else { + attr.setValue(value); } + } // /** @@ -1257,20 +1127,20 @@ public class XMLElement implements Serializable { // } - /** - * Removes an attribute. Formerly removeAttribute(). - * - * @param name the non-null name of the attribute. - */ - public void remove(String name) { - for (int i = 0; i < this.attributes.size(); i++) { - XMLAttribute attr = (XMLAttribute) this.attributes.elementAt(i); - if (attr.getFullName().equals(name)) { - this.attributes.removeElementAt(i); - return; - } - } + /** + * Removes an attribute. Formerly removeAttribute(). + * + * @param name the non-null name of the attribute. + */ + public void remove(String name) { + for (int i = 0; i < this.attributes.size(); i++) { + XMLAttribute attr = (XMLAttribute) this.attributes.elementAt(i); + if (attr.getFullName().equals(name)) { + this.attributes.removeElementAt(i); + return; + } } + } // /** @@ -1314,14 +1184,14 @@ public class XMLElement implements Serializable { // } - /** - * Returns whether an attribute exists. - * - * @return true if the attribute exists. - */ - public boolean hasAttribute(String name) { - return this.findAttribute(name) != null; - } + /** + * Returns whether an attribute exists. + * + * @return true if the attribute exists. + */ + public boolean hasAttribute(String name) { + return this.findAttribute(name) != null; + } // /** @@ -1377,108 +1247,108 @@ public class XMLElement implements Serializable { // } - /** - * Returns the system ID of the data where the element started. - * - * @return the system ID, or null if unknown. - * - * @see #getLineNr - */ - public String getSystemID() { - return this.systemID; + /** + * Returns the system ID of the data where the element started. + * + * @return the system ID, or null if unknown. + * + * @see #getLineNr + */ + public String getSystemID() { + return this.systemID; + } + + + /** + * Returns the line number in the data where the element started. + * + * @return the line number, or NO_LINE if unknown. + * + * @see #NO_LINE + * @see #getSystemID + */ + public int getLine() { + return this.line; + } + + + /** + * Returns the content of an element. If there is no such content, null is returned. + * =advanced + * Return the #PCDATA content of the element. If the element has a + * combination of #PCDATA content and child elements, the #PCDATA + * sections can be retrieved as unnamed child objects. In this case, + * this method returns null. + * + * @webref + * @brief Returns the content of an element + * @return the content. + */ + public String getContent() { + return this.content; + } + + + /** + * Sets the #PCDATA content. It is an error to call this method with a + * non-null value if there are child objects. + * + * @param content the (possibly null) content. + */ + public void setContent(String content) { + this.content = content; + } + + + /** + * Returns true if the element equals another element. + * + * @param rawElement the element to compare to + */ + public boolean equals(Object object) { + if (!(object instanceof XMLElement)) { + return false; } + XMLElement rawElement = (XMLElement) object; - - /** - * Returns the line number in the data where the element started. - * - * @return the line number, or NO_LINE if unknown. - * - * @see #NO_LINE - * @see #getSystemID - */ - public int getLine() { - return this.line; + if (! this.name.equals(rawElement.getLocalName())) { + return false; } - - - /** - * Returns the content of an element. If there is no such content, null is returned. - * =advanced - * Return the #PCDATA content of the element. If the element has a - * combination of #PCDATA content and child elements, the #PCDATA - * sections can be retrieved as unnamed child objects. In this case, - * this method returns null. - * - * @webref - * @brief Returns the content of an element - * @return the content. - */ - public String getContent() { - return this.content; + if (this.attributes.size() != rawElement.getAttributeCount()) { + return false; } - - - /** - * Sets the #PCDATA content. It is an error to call this method with a - * non-null value if there are child objects. - * - * @param content the (possibly null) content. - */ - public void setContent(String content) { - this.content = content; - } - - - /** - * Returns true if the element equals another element. - * - * @param rawElement the element to compare to - */ - public boolean equals(Object object) { - if (!(object instanceof XMLElement)) { + Enumeration en = this.attributes.elements(); + while (en.hasMoreElements()) { + XMLAttribute attr = (XMLAttribute) en.nextElement(); + // if (! rawElement.hasAttribute(attr.getName(), attr.getNamespace())) { + if (!rawElement.hasAttribute(attr.getFullName())) { return false; } - XMLElement rawElement = (XMLElement) object; - - if (! this.name.equals(rawElement.getLocalName())) { - return false; + // String value = rawElement.getAttribute(attr.getName(), + // attr.getNamespace(), + // null); + String value = rawElement.getAttribute(attr.getFullName(), null); + if (! attr.getValue().equals(value)) { + return false; } - if (this.attributes.size() != rawElement.getAttributeCount()) { - return false; - } - Enumeration en = this.attributes.elements(); - while (en.hasMoreElements()) { - XMLAttribute attr = (XMLAttribute) en.nextElement(); -// if (! rawElement.hasAttribute(attr.getName(), attr.getNamespace())) { - if (!rawElement.hasAttribute(attr.getFullName())) { - return false; - } -// String value = rawElement.getAttribute(attr.getName(), -// attr.getNamespace(), -// null); - String value = rawElement.getAttribute(attr.getFullName(), null); - if (! attr.getValue().equals(value)) { - return false; - } -// String type = -// rawElement.getAttributeType(attr.getName(), attr.getNamespace()); -// if (!attr.getType().equals(type)) { -// return false; -// } - } - if (this.children.size() != rawElement.getChildCount()) { - return false; - } - for (int i = 0; i < this.children.size(); i++) { - XMLElement child1 = this.getChildAtIndex(i); - XMLElement child2 = rawElement.getChildAtIndex(i); + // String type = + // rawElement.getAttributeType(attr.getName(), attr.getNamespace()); + // if (!attr.getType().equals(type)) { + // return false; + // } + } + if (this.children.size() != rawElement.getChildCount()) { + return false; + } + for (int i = 0; i < this.children.size(); i++) { + XMLElement child1 = this.getChild(i); + XMLElement child2 = rawElement.getChild(i); - if (!child1.equals(child2)) { - return false; - } + if (!child1.equals(child2)) { + return false; } - return true; + } + return true; } // /** @@ -1545,20 +1415,57 @@ public class XMLElement implements Serializable { // } - public String toString() { - return toString(true); + public String toString() { + return toString(true); + } + + + public String toString(boolean pretty) { + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + OutputStreamWriter osw = new OutputStreamWriter(baos); + XMLWriter writer = new XMLWriter(osw); + try { + writer.write(this, pretty); + } catch (IOException e) { + e.printStackTrace(); } - - - public String toString(boolean pretty) { - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - OutputStreamWriter osw = new OutputStreamWriter(baos); - XMLWriter writer = new XMLWriter(osw); - try { - writer.write(this, pretty); - } catch (IOException e) { - e.printStackTrace(); - } - return baos.toString(); + return baos.toString(); + } + + + private PApplet findSketch() { + if (sketch != null) { + return sketch; } + if (parent != null) { + return parent.findSketch(); + } + return null; + } + + + public boolean save(String filename) { + if (sketch == null) { + sketch = findSketch(); + } + if (sketch == null) { + System.err.println("save() can only be used on elements loaded by a sketch"); + throw new RuntimeException("no sketch found, use write(PrintWriter) instead."); + } + return write(sketch.createWriter(filename)); + } + + + public boolean write(PrintWriter writer) { + writer.println(XMLWriter.HEADER); + XMLWriter xmlw = new XMLWriter(writer); + try { + xmlw.write(this, true); + return true; + + } catch (IOException e) { + e.printStackTrace(); + return false; + } + } } diff --git a/core/todo.txt b/core/todo.txt index 2a7f50afe..1c30ae447 100644 --- a/core/todo.txt +++ b/core/todo.txt @@ -1,33 +1,26 @@ 0190 core - -LIBRARIES / XML - +xml fixes X add getBoolean() methods? -_ http://code.google.com/p/processing/issues/detail?id=304 +X http://code.google.com/p/processing/issues/detail?id=304 X removing namespace versions of the getXxxx() methods X these were never documented, and cause more trouble than they're worth X changing getIntAttribute() et al to getInt() _ need to make the reference change for the next release X add listChildren() method _ add to reference -_ adding write() method? -_ handle charset decoding in xml element parser? -_ same with the other methods like loadStrings() -_ could also be a way to handle gzip too? -_ tho charset + gzip would be a problem -_ need to handle how save() works inside xml lib -_ need to handle