- * Returns the QName of this attribute which represents the
- * local name, the qualified name and the Namespace.
- *
- *
- * @return the QName associated with this attribute
- */
- QName getQName();
+ /**
+ * Returns the QName of this attribute which represents the
+ * local name, the qualified name and the Namespace.
+ *
+ * @return the QName associated with this attribute
+ */
+ QName getQName();
- /**
- *
- * Returns the Namespace of this element if one exists
- * otherwise null is returned returned.
- *
- *
- * @return the Namespace associated with this node
- */
- Namespace getNamespace();
+ /**
+ * Returns the Namespace of this element if one exists
+ * otherwise null is returned returned.
+ *
+ * @return the Namespace associated with this node
+ */
+ Namespace getNamespace();
- /**
- *
- * Sets the Namespace of this element or if this element is
- * read only then an UnsupportedOperationException is thrown.
- *
- *
- * @param namespace
- * is the Namespace to associate with this element
- */
- void setNamespace(Namespace namespace);
+ /**
+ * Sets the Namespace of this element or if this element is
+ * read only then an UnsupportedOperationException is thrown.
+ *
+ * @param namespace is the Namespace to associate with this element
+ */
+ void setNamespace(Namespace namespace);
- /**
- *
- * Returns the namespace prefix of this element if one exists otherwise an
- * empty String is returned.
- *
- *
- * @return the prefix of the Namespace of this element or an
- * empty String
- */
- String getNamespacePrefix();
+ /**
+ * Returns the namespace prefix of this element if one exists otherwise an
+ * empty String is returned.
+ *
+ * @return the prefix of the Namespace of this element or an
+ * empty String
+ */
+ String getNamespacePrefix();
- /**
- *
- * Returns the URI mapped to the namespace of this element if one exists
- * otherwise an empty String is returned.
- *
- *
- * @return the URI for the Namespace of this element or an
- * empty String
- */
- String getNamespaceURI();
+ /**
+ * Returns the URI mapped to the namespace of this element if one exists
+ * otherwise an empty String is returned.
+ *
+ * @return the URI for the Namespace of this element or an
+ * empty String
+ */
+ String getNamespaceURI();
- /**
- *
- * Returns the fully qualified name of this element.
- *
- *
- *
- * This will be the same as the value returned from {@link Node#getName()}
- * if this element has no namespace attached to this element or an
- * expression of the form
- *
- *
- * getNamespacePrefix() + ":" + getName()
- *
- *
- * will be returned.
- *
- *
- * @return the fully qualified name of the element
- */
- String getQualifiedName();
+ /**
+ * Returns the fully qualified name of this element.
+ *
+ * This will be the same as the value returned from {@link Node#getName()}
+ * if this element has no namespace attached to this element or an
+ * expression of the form
+ *
+ * getNamespacePrefix() + ":" + getName()
+ *
+ * will be returned.
+ *
+ * @return the fully qualified name of the element
+ */
+ String getQualifiedName();
- /**
- *
- * Returns the value of the attribute. This method returns the same value as
- * the {@link Node#getText()}method.
- *
- *
- * @return the value of the attribute
- */
- String getValue();
+ /**
+ * Returns the value of the attribute. This method returns the same value as
+ * the {@link Node#getText()}method.
+ *
+ * @return the value of the attribute
+ */
+ String getValue();
- /**
- *
- * Sets the value of this attribute or this method will throw an
- * UnsupportedOperationException if it is read-only.
- *
- *
- * @param value
- * is the new value of this attribute
- */
- void setValue(String value);
+ /**
+ * Sets the value of this attribute or this method will throw an
+ * UnsupportedOperationException if it is read-only.
+ *
+ * @param value is the new value of this attribute
+ */
+ void setValue(String value);
- /**
- *
- * Accesses the data of this attribute which may implement data typing
- * bindings such as XML Schema or Java Bean
- * bindings or will return the same value as {@link Node#getText()}.
- *
- *
- * @return the attribute data
- */
- Object getData();
+ /**
+ * Accesses the data of this attribute which may implement data typing
+ * bindings such as XML Schema or Java Bean
+ * bindings or will return the same value as {@link Node#getText()}.
+ *
+ * @return the attribute data
+ */
+ Object getData();
- /**
- *
- * Sets the data value of this attribute if this element supports data
- * binding or calls {@link Node#setText(String)}if it doesn't.
- *
- *
- * @param data
- * the attribute data
- */
- void setData(Object data);
+ /**
+ * Sets the data value of this attribute if this element supports data
+ * binding or calls {@link Node#setText(String)}if it doesn't.
+ *
+ * @param data the attribute data
+ */
+ void setData(Object data);
}
/*
diff --git a/fine-org-dom4j/src/main/java/org/dom4j/Branch.java b/fine-org-dom4j/src/main/java/org/dom4j/Branch.java
index 4074a588d..c7d36c2f6 100644
--- a/fine-org-dom4j/src/main/java/org/dom4j/Branch.java
+++ b/fine-org-dom4j/src/main/java/org/dom4j/Branch.java
@@ -11,306 +11,263 @@ import java.util.Iterator;
import java.util.List;
/**
- *
* Branch interface defines the common behaviour for Nodes which
* can contain child nodes (content) such as XML elements and documents. This
* interface allows both elements and documents to be treated in a polymorphic
* manner when changing or navigating child nodes (content).
- *
- *
+ *
* @author James Strachan
- * @version $Revision$
+ * @version $Revision: 1.32 $
*/
+@SuppressWarnings("unused")
public interface Branch extends Node {
- /**
- * Returns the Node at the specified index position.
- *
- * @param index
- * the index of the node to return.
- *
- * @return the Node at the specified position.
- *
- * @throws IndexOutOfBoundsException
- * if the index is out of range (index < 0 || index >=
- * {@link Branch#nodeCount()}).
- */
- Node node(int index) throws IndexOutOfBoundsException;
+ /**
+ * Returns the Node at the specified index position.
+ *
+ * @param index the index of the node to return.
+ * @return the Node at the specified position.
+ * @throws IndexOutOfBoundsException if the index is out of range (index < 0 || index >=
+ * {@link Branch#nodeCount()}).
+ */
+ Node node(int index) throws IndexOutOfBoundsException;
- /**
- * Returns the index of the given node if it is a child node of this branch
- * or -1 if the given node is not a child node.
- *
- * @param node
- * the content child node to find.
- *
- * @return the index of the given node starting at 0 or -1 if the node is
- * not a child node of this branch
- */
- int indexOf(Node node);
+ /**
+ * Returns the index of the given node if it is a child node of this branch
+ * or -1 if the given node is not a child node.
+ *
+ * @param node the content child node to find.
+ * @return the index of the given node starting at 0 or -1 if the node is
+ * not a child node of this branch
+ */
+ int indexOf(Node node);
- /**
- * Returns the number of Node instances that this branch
- * contains.
- *
- * @return the number of nodes this branch contains
- */
- int nodeCount();
+ /**
+ * Returns the number of Node instances that this branch
+ * contains.
+ *
+ * @return the number of nodes this branch contains
+ */
+ int nodeCount();
- /**
- * Returns the element of the given ID attribute value. If this tree is
- * capable of understanding which attribute value should be used for the ID
- * then it should be used, otherwise this method should return null.
- *
- * @param elementID
- * DOCUMENT ME!
- *
- * @return DOCUMENT ME!
- */
- Element elementByID(String elementID);
+ /**
+ * Returns the element of the given ID attribute value. If this tree is
+ * capable of understanding which attribute value should be used for the ID
+ * then it should be used, otherwise this method should return null.
+ *
+ * @param elementID DOCUMENT ME!
+ * @return DOCUMENT ME!
+ */
+ Element elementByID(String elementID);
- /**
- *
- * Returns the content nodes of this branch as a backed {@link List}so that
- * the content of this branch may be modified directly using the
- * {@link List}interface. The List is backed by the
- * Branch so that changes to the list are reflected in the
- * branch and vice versa.
- *
- *
- * @return the nodes that this branch contains as a List
- */
- List content();
+ /**
+ * Returns the content nodes of this branch as a backed {@link List}so that
+ * the content of this branch may be modified directly using the
+ * {@link List}interface. The List is backed by the
+ * Branch so that changes to the list are reflected in the
+ * branch and vice versa.
+ *
+ * @return the nodes that this branch contains as a List
+ */
+ List content();
- /**
- * Returns an iterator through the content nodes of this branch
- *
- * @return an iterator through the content nodes of this branch
- */
- Iterator nodeIterator();
+ /**
+ * Returns an iterator through the content nodes of this branch
+ *
+ * @return an iterator through the content nodes of this branch
+ */
+ Iterator nodeIterator();
- /**
- * Sets the contents of this branch as a List of
- * Node instances.
- *
- * @param content
- * is the list of nodes to use as the content for this branch.
- */
- void setContent(List content);
+ /**
+ * Sets the contents of this branch as a List of
+ * Node instances.
+ *
+ * @param content is the list of nodes to use as the content for this branch.
+ */
+ void setContent(List content);
- /**
- * Appends the content of the given branch to this branch instance. This
- * method behaves like the {@link
- * java.util.Collection#addAll(java.util.Collection)} method.
- *
- * @param branch
- * is the branch whose content will be added to me.
- */
- void appendContent(Branch branch);
+ /**
+ * Appends the content of the given branch to this branch instance. This
+ * method behaves like the {@link
+ * java.util.Collection#addAll(java.util.Collection)} method.
+ *
+ * @param branch is the branch whose content will be added to me.
+ */
+ void appendContent(Branch branch);
- /**
- * Clears the content for this branch, removing any Node
- * instances this branch may contain.
- */
- void clearContent();
+ /**
+ * Clears the content for this branch, removing any Node
+ * instances this branch may contain.
+ */
+ void clearContent();
- /**
- *
- * Returns a list of all the processing instructions in this branch. The
- * list is backed by this branch so that changes to the list will be
- * reflected in the branch but the reverse is not the case.
- *
- *
- * @return a backed list of the processing instructions
- */
- List processingInstructions();
+ /**
+ * Returns a list of all the processing instructions in this branch. The
+ * list is backed by this branch so that changes to the list will be
+ * reflected in the branch but the reverse is not the case.
+ *
+ * @return a backed list of the processing instructions
+ */
+ List processingInstructions();
- /**
- *
- * Returns a list of the processing instructions for the given target. The
- * list is backed by this branch so that changes to the list will be
- * reflected in the branch but the reverse is not the case.
- *
- *
- * @param target
- * DOCUMENT ME!
- *
- * @return a backed list of the processing instructions
- */
- List processingInstructions(String target);
+ /**
+ * Returns a list of the processing instructions for the given target. The
+ * list is backed by this branch so that changes to the list will be
+ * reflected in the branch but the reverse is not the case.
+ *
+ * @param target DOCUMENT ME!
+ * @return a backed list of the processing instructions
+ */
+ List processingInstructions(String target);
- /**
- * DOCUMENT ME!
- *
- * @param target
- * DOCUMENT ME!
- *
- * @return the processing instruction for the given target
- */
- ProcessingInstruction processingInstruction(String target);
+ /**
+ * DOCUMENT ME!
+ *
+ * @param target DOCUMENT ME!
+ * @return the processing instruction for the given target
+ */
+ ProcessingInstruction processingInstruction(String target);
- /**
- * Sets all the processing instructions for this branch
- *
- * @param listOfPIs
- * DOCUMENT ME!
- */
- void setProcessingInstructions(List listOfPIs);
+ /**
+ * Sets all the processing instructions for this branch
+ *
+ * @param listOfPIs DOCUMENT ME!
+ */
+ void setProcessingInstructions(List listOfPIs);
- /**
- * Adds a new Element node with the given name to this branch
- * and returns a reference to the new node.
- *
- * @param name
- * is the name for the Element node.
- *
- * @return the newly added Element node.
- */
- Element addElement(String name);
+ /**
+ * Adds a new Element node with the given name to this branch
+ * and returns a reference to the new node.
+ *
+ * @param name is the name for the Element node.
+ * @return the newly added Element node.
+ */
+ Element addElement(String name);
- /**
- * Adds a new Element node with the given {@link QName}to
- * this branch and returns a reference to the new node.
- *
- * @param qname
- * is the qualified name for the Element node.
- *
- * @return the newly added Element node.
- */
- Element addElement(QName qname);
+ /**
+ * Adds a new Element node with the given {@link QName}to
+ * this branch and returns a reference to the new node.
+ *
+ * @param qname is the qualified name for the Element node.
+ * @return the newly added Element node.
+ */
+ Element addElement(QName qname);
- /**
- * Adds a new Element node with the given qualified name and
- * namespace URI to this branch and returns a reference to the new node.
- *
- * @param qualifiedName
- * is the fully qualified name of the Element
- * @param namespaceURI
- * is the URI of the namespace to use
- *
- * @return the newly added Element node.
- */
- Element addElement(String qualifiedName, String namespaceURI);
+ /**
+ * Adds a new Element node with the given qualified name and
+ * namespace URI to this branch and returns a reference to the new node.
+ *
+ * @param qualifiedName is the fully qualified name of the Element
+ * @param namespaceURI is the URI of the namespace to use
+ * @return the newly added Element node.
+ */
+ Element addElement(String qualifiedName, String namespaceURI);
- /**
- * Removes the processing instruction for the given target if it exists
- *
- * @param target
- * DOCUMENT ME!
- *
- * @return true if a processing instruction was removed else false
- */
- boolean removeProcessingInstruction(String target);
+ /**
+ * Removes the processing instruction for the given target if it exists
+ *
+ * @param target DOCUMENT ME!
+ * @return true if a processing instruction was removed else false
+ */
+ boolean removeProcessingInstruction(String target);
- /**
- * Adds the given Node or throws {@link IllegalAddException}
- * if the given node is not of a valid type. This is a polymorphic method
- * which will call the typesafe method for the node type such as
- * add(Element) or add(Comment).
- *
- * @param node
- * is the given node to add
- */
- void add(Node node);
+ /**
+ * Adds the given Node or throws {@link IllegalAddException}
+ * if the given node is not of a valid type. This is a polymorphic method
+ * which will call the typesafe method for the node type such as
+ * add(Element) or add(Comment).
+ *
+ * @param node is the given node to add
+ */
+ void add(Node node);
- /**
- * Adds the given Comment to this branch. If the given node
- * already has a parent defined then an IllegalAddException
- * will be thrown.
- *
- * @param comment
- * is the comment to be added
- */
- void add(Comment comment);
+ /**
+ * Adds the given Comment to this branch. If the given node
+ * already has a parent defined then an IllegalAddException
+ * will be thrown.
+ *
+ * @param comment is the comment to be added
+ */
+ void add(Comment comment);
- /**
- * Adds the given Element to this branch. If the given node
- * already has a parent defined then an IllegalAddException
- * will be thrown.
- *
- * @param element
- * is the element to be added
- */
- void add(Element element);
+ /**
+ * Adds the given Element to this branch. If the given node
+ * already has a parent defined then an IllegalAddException
+ * will be thrown.
+ *
+ * @param element is the element to be added
+ */
+ void add(Element element);
- /**
- * Adds the given ProcessingInstruction to this branch. If
- * the given node already has a parent defined then an
- * IllegalAddException will be thrown.
- *
- * @param pi
- * is the processing instruction to be added
- */
- void add(ProcessingInstruction pi);
+ /**
+ * Adds the given ProcessingInstruction to this branch. If
+ * the given node already has a parent defined then an
+ * IllegalAddException will be thrown.
+ *
+ * @param pi is the processing instruction to be added
+ */
+ void add(ProcessingInstruction pi);
- /**
- * Removes the given Node if the node is an immediate child
- * of this branch. If the given node is not an immediate child of this
- * branch then the {@link Node#detach()}method should be used instead. This
- * is a polymorphic method which will call the typesafe method for the node
- * type such as remove(Element) or remove(Comment).
- *
- * @param node
- * is the given node to be removed
- *
- * @return true if the node was removed
- */
- boolean remove(Node node);
+ /**
+ * Removes the given Node if the node is an immediate child
+ * of this branch. If the given node is not an immediate child of this
+ * branch then the {@link Node#detach()}method should be used instead. This
+ * is a polymorphic method which will call the typesafe method for the node
+ * type such as remove(Element) or remove(Comment).
+ *
+ * @param node is the given node to be removed
+ * @return true if the node was removed
+ */
+ boolean remove(Node node);
- /**
- * Removes the given Comment if the node is an immediate
- * child of this branch. If the given node is not an immediate child of this
- * branch then the {@link Node#detach()}method should be used instead.
- *
- * @param comment
- * is the comment to be removed
- *
- * @return true if the comment was removed
- */
- boolean remove(Comment comment);
+ /**
+ * Removes the given Comment if the node is an immediate
+ * child of this branch. If the given node is not an immediate child of this
+ * branch then the {@link Node#detach()}method should be used instead.
+ *
+ * @param comment is the comment to be removed
+ * @return true if the comment was removed
+ */
+ boolean remove(Comment comment);
- /**
- * Removes the given Element if the node is an immediate
- * child of this branch. If the given node is not an immediate child of this
- * branch then the {@link Node#detach()}method should be used instead.
- *
- * @param element
- * is the element to be removed
- *
- * @return true if the element was removed
- */
- boolean remove(Element element);
+ /**
+ * Removes the given Element if the node is an immediate
+ * child of this branch. If the given node is not an immediate child of this
+ * branch then the {@link Node#detach()}method should be used instead.
+ *
+ * @param element is the element to be removed
+ * @return true if the element was removed
+ */
+ boolean remove(Element element);
- /**
- * Removes the given ProcessingInstruction if the node is an
- * immediate child of this branch. If the given node is not an immediate
- * child of this branch then the {@link Node#detach()}method should be used
- * instead.
- *
- * @param pi
- * is the processing instruction to be removed
- *
- * @return true if the processing instruction was removed
- */
- boolean remove(ProcessingInstruction pi);
+ /**
+ * Removes the given ProcessingInstruction if the node is an
+ * immediate child of this branch. If the given node is not an immediate
+ * child of this branch then the {@link Node#detach()}method should be used
+ * instead.
+ *
+ * @param pi is the processing instruction to be removed
+ * @return true if the processing instruction was removed
+ */
+ boolean remove(ProcessingInstruction pi);
- /**
- * Puts all Text nodes in the full depth of the sub-tree
- * underneath this Node, including attribute nodes, into a
- * "normal" form where only structure (e.g., elements, comments, processing
- * instructions, CDATA sections, and entity references) separates
- * Text nodes, i.e., there are neither adjacent
- * Text nodes nor empty Text nodes. This can
- * be used to ensure that the DOM view of a document is the same as if it
- * were saved and re-loaded, and is useful when operations (such as XPointer
- * lookups) that depend on a particular document tree structure are to be
- * used.In cases where the document contains CDATASections,
- * the normalize operation alone may not be sufficient, since XPointers do
- * not differentiate between Text nodes and
- * CDATASection nodes.
- *
- * @since DOM Level 2
- */
- void normalize();
+ /**
+ * Puts all Text nodes in the full depth of the sub-tree
+ * underneath this Node, including attribute nodes, into a
+ * "normal" form where only structure (e.g., elements, comments, processing
+ * instructions, CDATA sections, and entity references) separates
+ * Text nodes, i.e., there are neither adjacent
+ * Text nodes nor empty Text nodes. This can
+ * be used to ensure that the DOM view of a document is the same as if it
+ * were saved and re-loaded, and is useful when operations (such as XPointer
+ * lookups) that depend on a particular document tree structure are to be
+ * used.In cases where the document contains CDATASections,
+ * the normalize operation alone may not be sufficient, since XPointers do
+ * not differentiate between Text nodes and
+ * CDATASection nodes.
+ *
+ * @since DOM Level 2
+ */
+ void normalize();
}
/*
diff --git a/fine-org-dom4j/src/main/java/org/dom4j/CDATA.java b/fine-org-dom4j/src/main/java/org/dom4j/CDATA.java
index d6816106a..8db6aeedf 100644
--- a/fine-org-dom4j/src/main/java/org/dom4j/CDATA.java
+++ b/fine-org-dom4j/src/main/java/org/dom4j/CDATA.java
@@ -8,13 +8,12 @@
package org.dom4j;
/**
- *
- *
+ *
* @author James Strachan
- * @version $Revision$
+ * @version $Revision: 1.14 $
*/
+@SuppressWarnings("unused")
public interface Document extends Branch {
/**
* Returns the root {@link Element}for this document.
@@ -70,7 +69,7 @@ public interface Document extends Branch {
*
* @return this Document instance.
*/
- Document addProcessingInstruction(String target, Map data);
+ Document addProcessingInstruction(String target, Map data);
/**
* Adds a DOCTYPE declaration to this document
@@ -124,15 +123,13 @@ public interface Document extends Branch {
* when the Document was created in memory) or when the implementation does
* not support this operation.
*
- *
* The way this encoding is retrieved also depends on the way the XML source
* is parsed. For instance, if the SAXReader is used and if the underlying
* XMLReader implementation support the
* org.xml.sax.ext.Locator2 interface, the result returned by
* this method is specified by the getEncoding() method of
* that interface.
- *
- *
+ *
* @return The encoding of this document, as stated in the XML declaration,
* or null if unknown.
*
diff --git a/fine-org-dom4j/src/main/java/org/dom4j/DocumentException.java b/fine-org-dom4j/src/main/java/org/dom4j/DocumentException.java
index 2feb890be..2c7b5f027 100644
--- a/fine-org-dom4j/src/main/java/org/dom4j/DocumentException.java
+++ b/fine-org-dom4j/src/main/java/org/dom4j/DocumentException.java
@@ -7,78 +7,32 @@
package org.dom4j;
-import java.io.PrintStream;
-import java.io.PrintWriter;
-
/**
- *
- * DocumentException is a nested Exception which may be thrown
- * during the processing of a DOM4J document.
- *
- *
+ * DocumentException is a nested Exception which may be thrown during the processing of a DOM4J document.
+ *
* @author James Strachan
- * @version $Revision$
+ * @author Filip Jirsák
*/
public class DocumentException extends Exception {
- /** A wrapped Throwable */
- private Throwable nestedException;
public DocumentException() {
- super("Error occurred in DOM4J application.");
}
public DocumentException(String message) {
super(message);
}
- public DocumentException(Throwable nestedException) {
- super(nestedException.getMessage());
- this.nestedException = nestedException;
+ public DocumentException(String message, Throwable cause) {
+ super(message, cause);
}
- public DocumentException(String message, Throwable nestedException) {
- super(message);
- this.nestedException = nestedException;
+ public DocumentException(Throwable cause) {
+ super(cause);
}
+ @Deprecated
public Throwable getNestedException() {
- return nestedException;
- }
-
- public String getMessage() {
- if (nestedException != null) {
- return super.getMessage() + " Nested exception: "
- + nestedException.getMessage();
- } else {
- return super.getMessage();
- }
- }
-
- public void printStackTrace() {
- super.printStackTrace();
-
- if (nestedException != null) {
- System.err.print("Nested exception: ");
- nestedException.printStackTrace();
- }
- }
-
- public void printStackTrace(PrintStream out) {
- super.printStackTrace(out);
-
- if (nestedException != null) {
- out.println("Nested exception: ");
- nestedException.printStackTrace(out);
- }
- }
-
- public void printStackTrace(PrintWriter writer) {
- super.printStackTrace(writer);
-
- if (nestedException != null) {
- writer.println("Nested exception: ");
- nestedException.printStackTrace(writer);
- }
+ return null;
}
}
diff --git a/fine-org-dom4j/src/main/java/org/dom4j/DocumentFactory.java b/fine-org-dom4j/src/main/java/org/dom4j/DocumentFactory.java
index 2571a3b40..9aaaa11cb 100644
--- a/fine-org-dom4j/src/main/java/org/dom4j/DocumentFactory.java
+++ b/fine-org-dom4j/src/main/java/org/dom4j/DocumentFactory.java
@@ -32,28 +32,25 @@ import org.dom4j.xpath.XPathPattern;
import org.jaxen.VariableContext;
/**
- *
* DocumentFactory is a collection of factory methods to allow
* easy custom building of DOM4J trees. The default tree that is built uses a
* doubly linked tree.
- *
- *
- *
+ *
* The tree built allows full XPath expressions from anywhere on the tree.
- *
- *
+ *
* @author James Strachan
*/
+@SuppressWarnings("unused")
public class DocumentFactory implements Serializable {
- private static SingletonStrategy singleton = null;
+ private static SingletonStrategy singleton = null;
protected transient QNameCache cache;
- /** Default namespace prefix -> URI mappings for XPath expressions to use */
- private Map xpathNamespaceURIs;
+ /** Default namespace prefix → URI mappings for XPath expressions to use */
+ private Map xpathNamespaceURIs;
- private static SingletonStrategy createSingleton() {
- SingletonStrategy result = null;
+ private static SingletonStrategy createSingleton() {
+ SingletonStrategy result;
String documentFactoryClassName;
try {
@@ -67,10 +64,10 @@ public class DocumentFactory implements Serializable {
String singletonClass = System.getProperty(
"org.dom4j.DocumentFactory.singleton.strategy",
"org.dom4j.util.SimpleSingleton");
- Class clazz = Class.forName(singletonClass);
- result = (SingletonStrategy) clazz.newInstance();
+ Class clazz = (Class) Class.forName(singletonClass);
+ result = clazz.newInstance();
} catch (Exception e) {
- result = new SimpleSingleton();
+ result = new SimpleSingleton();
}
result.setSingletonClassName(documentFactoryClassName);
@@ -83,18 +80,16 @@ public class DocumentFactory implements Serializable {
}
/**
- *
* Access to singleton implementation of DocumentFactory which is used if no
* DocumentFactory is specified when building using the standard builders.
- *
- *
+ *
* @return the default singleon instance
*/
public static synchronized DocumentFactory getInstance() {
if (singleton == null) {
singleton = createSingleton();
}
- return (DocumentFactory) singleton.instance();
+ return singleton.instance();
}
// Factory methods
@@ -121,10 +116,7 @@ public class DocumentFactory implements Serializable {
// createDocument() method.
Document answer = createDocument();
- if (answer instanceof AbstractDocument) {
- ((AbstractDocument) answer).setXMLEncoding(encoding);
- }
-
+ answer.setXMLEncoding(encoding);
return answer;
}
@@ -191,7 +183,7 @@ public class DocumentFactory implements Serializable {
}
public ProcessingInstruction createProcessingInstruction(String target,
- Map data) {
+ Map data) {
return new DefaultProcessingInstruction(target, data);
}
@@ -324,7 +316,7 @@ public class DocumentFactory implements Serializable {
*
* @return DOCUMENT ME!
*/
- public List getQNames() {
+ public List getQNames() {
return cache.getQNames();
}
@@ -337,7 +329,7 @@ public class DocumentFactory implements Serializable {
* namespace URI. This value could well be null to indicate no
* namespace URIs are being mapped.
*/
- public Map getXPathNamespaceURIs() {
+ public Map getXPathNamespaceURIs() {
return xpathNamespaceURIs;
}
@@ -349,7 +341,7 @@ public class DocumentFactory implements Serializable {
* @param namespaceURIs
* DOCUMENT ME!
*/
- public void setXPathNamespaceURIs(Map namespaceURIs) {
+ public void setXPathNamespaceURIs(Map namespaceURIs) {
this.xpathNamespaceURIs = namespaceURIs;
}
@@ -372,10 +364,10 @@ public class DocumentFactory implements Serializable {
try {
// I'll use the current class loader
// that loaded me to avoid problems in J2EE and web apps
- Class theClass = Class.forName(className, true,
+ Class theClass = (Class) Class.forName(className, true,
DocumentFactory.class.getClassLoader());
- return (DocumentFactory) theClass.newInstance();
+ return theClass.newInstance();
} catch (Throwable e) {
System.out.println("WARNING: Cannot load DocumentFactory: "
+ className);
diff --git a/fine-org-dom4j/src/main/java/org/dom4j/DocumentHelper.java b/fine-org-dom4j/src/main/java/org/dom4j/DocumentHelper.java
index 35f31bc1e..865a51a17 100644
--- a/fine-org-dom4j/src/main/java/org/dom4j/DocumentHelper.java
+++ b/fine-org-dom4j/src/main/java/org/dom4j/DocumentHelper.java
@@ -18,16 +18,16 @@ import org.dom4j.rule.Pattern;
import org.jaxen.VariableContext;
import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
/**
- *
* DocumentHelper is a collection of helper methods for using
* DOM4J.
- *
- *
+ *
* @author James Strachan
- * @version $Revision$
+ * @version $Revision: 1.26 $
*/
+@SuppressWarnings("unused")
public final class DocumentHelper {
private DocumentHelper() {
}
@@ -89,7 +89,7 @@ public final class DocumentHelper {
}
public static ProcessingInstruction createProcessingInstruction(String pi,
- Map data) {
+ Map data) {
return getDocumentFactory().createProcessingInstruction(pi, data);
}
@@ -107,12 +107,12 @@ public final class DocumentHelper {
* XPath XPath instance using the singleton {@link
* DocumentFactory}.
*
- *
+ *
* @param xpathExpression
* is the XPath expression to create
- *
+ *
* @return a new XPath instance
- *
+ *
* @throws InvalidXPathException
* if the XPath expression is invalid
*/
@@ -127,14 +127,14 @@ public final class DocumentHelper {
* XPath XPath instance using the singleton {@link
* DocumentFactory}.
*
- *
+ *
* @param xpathExpression
* is the XPath expression to create
* @param context
* is the variable context to use when evaluating the XPath
- *
+ *
* @return a new XPath instance
- *
+ *
* @throws InvalidXPathException
* if the XPath expression is invalid
*/
@@ -150,10 +150,10 @@ public final class DocumentHelper {
* filter expressions occur within XPath expressions such as
* self::node()[ filterExpression ]
*
- *
+ *
* @param xpathFilterExpression
* is the XPath filter expression to create
- *
+ *
* @return a new NodeFilter instance
*/
public static NodeFilter createXPathFilter(String xpathFilterExpression) {
@@ -166,10 +166,10 @@ public final class DocumentHelper {
* an XSLT style {@link Pattern}instance which can then be used in an XSLT
* processing model.
*
- *
+ *
* @param xpathPattern
* is the XPath pattern expression to create
- *
+ *
* @return a new Pattern instance
*/
public static Pattern createPattern(String xpathPattern) {
@@ -182,15 +182,15 @@ public final class DocumentHelper {
* {@link List}of {@link Node}instances appending all the results together
* into a single list.
*
- *
+ *
* @param xpathFilterExpression
* is the XPath filter expression to evaluate
* @param nodes
* is the list of nodes on which to evalute the XPath
- *
+ *
* @return the results of all the XPath evaluations as a single list
*/
- public static List selectNodes(String xpathFilterExpression, List nodes) {
+ public static List selectNodes(String xpathFilterExpression, List nodes) {
XPath xpath = createXPath(xpathFilterExpression);
return xpath.selectNodes(nodes);
@@ -202,15 +202,15 @@ public final class DocumentHelper {
* {@link List}of {@link Node}instances appending all the results together
* into a single list.
*
- *
+ *
* @param xpathFilterExpression
* is the XPath filter expression to evaluate
* @param node
* is the Node on which to evalute the XPath
- *
+ *
* @return the results of all the XPath evaluations as a single list
*/
- public static List selectNodes(String xpathFilterExpression, Node node) {
+ public static List selectNodes(String xpathFilterExpression, Node node) {
XPath xpath = createXPath(xpathFilterExpression);
return xpath.selectNodes(node);
@@ -221,13 +221,13 @@ public final class DocumentHelper {
* sort sorts the given List of Nodes using an XPath
* expression as a {@link java.util.Comparator}.
*
- *
+ *
* @param list
* is the list of Nodes to sort
* @param xpathExpression
* is the XPath expression used for comparison
*/
- public static void sort(List list, String xpathExpression) {
+ public static void sort(List list, String xpathExpression) {
XPath xpath = createXPath(xpathExpression);
xpath.sort(list);
}
@@ -238,7 +238,7 @@ public final class DocumentHelper {
* expression as a {@link java.util.Comparator}and optionally removing
* duplicates.
*
- *
+ *
* @param list
* is the list of Nodes to sort
* @param expression
@@ -247,7 +247,7 @@ public final class DocumentHelper {
* if true then duplicate values (using the sortXPath for
* comparisions) will be removed from the List
*/
- public static void sort(List list, String expression, boolean distinct) {
+ public static void sort(List list, String expression, boolean distinct) {
XPath xpath = createXPath(expression);
xpath.sort(list, distinct);
}
@@ -257,25 +257,26 @@ public final class DocumentHelper {
* parseText parses the given text as an XML document and
* returns the newly created Document.
*
- *
+ *
+ * Loading external DTD and entities is disabled (if it is possible) for security reasons.
+ *
* @param text
* the XML text to be parsed
- *
+ *
* @return a newly parsed Document
- *
+ *
* @throws DocumentException
* if the document could not be parsed
*/
public static Document parseText(String text) throws DocumentException {
- Document result = null;
+ SAXReader reader = SAXReader.createDefault();
- SAXReader reader = new SAXReader();
String encoding = getEncoding(text);
InputSource source = new InputSource(new StringReader(text));
source.setEncoding(encoding);
- result = reader.read(source);
+ Document result = reader.read(source);
// if the XML parser doesn't provide a way to retrieve the encoding,
// specify it manually
@@ -322,14 +323,14 @@ public final class DocumentHelper {
* get the first child <a> element, which would be created if it did
* not exist, then the next child <b> and so on until finally a
* <c> element is returned.
- *
+ *
* @param source
* is the Element or Document to start navigating from
* @param path
* is a simple path expression, seperated by '/' which denotes
* the path from the source to the resulting element such as
* a/b/c
- *
+ *
* @return the first Element on the given path which either already existed
* on the path or were created by this method.
*/
@@ -378,24 +379,24 @@ public final class DocumentHelper {
* Redistribution and use of this software and associated documentation
* ("Software"), with or without modification, are permitted provided that the
* following conditions are met:
- *
+ *
* 1. Redistributions of source code must retain copyright statements and
* notices. Redistributions must also contain a copy of this document.
- *
+ *
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
- *
+ *
* 3. The name "DOM4J" must not be used to endorse or promote products derived
* from this Software without prior written permission of MetaStuff, Ltd. For
* written permission, please contact dom4j-info@metastuff.com.
- *
+ *
* 4. Products derived from this Software may not be called "DOM4J" nor may
* "DOM4J" appear in their names without prior written permission of MetaStuff,
* Ltd. DOM4J is a registered trademark of MetaStuff, Ltd.
- *
+ *
* 5. Due credit should be given to the DOM4J Project - http://www.dom4j.org
- *
+ *
* THIS SOFTWARE IS PROVIDED BY METASTUFF, LTD. AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
@@ -407,6 +408,6 @@ public final class DocumentHelper {
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
- *
+ *
* Copyright 2001-2005 (C) MetaStuff, Ltd. All Rights Reserved.
*/
diff --git a/fine-org-dom4j/src/main/java/org/dom4j/DocumentType.java b/fine-org-dom4j/src/main/java/org/dom4j/DocumentType.java
index d2c9f3cb2..aaea5eae0 100644
--- a/fine-org-dom4j/src/main/java/org/dom4j/DocumentType.java
+++ b/fine-org-dom4j/src/main/java/org/dom4j/DocumentType.java
@@ -7,16 +7,17 @@
package org.dom4j;
+import org.dom4j.dtd.Decl;
+
import java.util.List;
/**
- *
* DocumentType defines an XML DOCTYPE declaration.
- *
- *
+ *
* @author James Strachan
- * @version $Revision$
+ * @version $Revision: 1.10 $
*/
+@SuppressWarnings("unused")
public interface DocumentType extends Node {
/**
* This method is the equivalent to the {@link #getName}method. It is added
@@ -49,7 +50,7 @@ public interface DocumentType extends Node {
*
* @return DOCUMENT ME!
*/
- List getInternalDeclarations();
+ List getInternalDeclarations();
/**
* Sets the list of internal DTD declaration objects, defined in the
@@ -58,7 +59,7 @@ public interface DocumentType extends Node {
* @param declarations
* DOCUMENT ME!
*/
- void setInternalDeclarations(List declarations);
+ void setInternalDeclarations(List declarations);
/**
* Returns a list of internal DTD declaration objects, defined in the
@@ -66,7 +67,7 @@ public interface DocumentType extends Node {
*
* @return DOCUMENT ME!
*/
- List getExternalDeclarations();
+ List getExternalDeclarations();
/**
* Sets the list of internal DTD declaration objects, defined in the
@@ -75,7 +76,7 @@ public interface DocumentType extends Node {
* @param declarations
* DOCUMENT ME!
*/
- void setExternalDeclarations(List declarations);
+ void setExternalDeclarations(List declarations);
}
/*
diff --git a/fine-org-dom4j/src/main/java/org/dom4j/Element.java b/fine-org-dom4j/src/main/java/org/dom4j/Element.java
index 56b446b13..9cf2738c3 100644
--- a/fine-org-dom4j/src/main/java/org/dom4j/Element.java
+++ b/fine-org-dom4j/src/main/java/org/dom4j/Element.java
@@ -12,839 +12,682 @@ import java.util.List;
import java.util.Map;
/**
- *
* Element interface defines an XML element. An element can have
* declared namespaces, attributes, child nodes and textual content.
- *
- *
*
* Some of this interface is optional. Some implementations may be read-only and
* not support being modified. Some implementations may not support the parent
- * relationship and methods such as {@link #getParent}or {@link#getDocument}.
- *
- *
+ * relationship and methods such as {@link #getParent}or {@link #getDocument}.
+ *
* @author James Strachan
- * @version $Revision$
+ * @version $Revision: 1.47 $
*/
+@SuppressWarnings("unused")
public interface Element extends Branch {
- // Name and namespace related methods
- // -------------------------------------------------------------------------
-
- /**
- *
- * Returns the QName of this element which represents the
- * local name, the qualified name and the Namespace.
- *
- *
- * @return the QName associated with this element
- */
- QName getQName();
-
- /**
- *
- * Sets the QName of this element which represents the local
- * name, the qualified name and the Namespace.
- *
- *
- * @param qname
- * is the QName to be associated with this element
- */
- void setQName(QName qname);
-
- /**
- *
- * Returns the Namespace of this element if one exists
- * otherwise Namespace.NO_NAMESPACE is returned.
- *
- *
- * @return the Namespace associated with this element
- */
- Namespace getNamespace();
-
- /**
- *
- * Returns the QName for the given qualified name, using the
- * namespace URI in scope for the given prefix of the qualified name or the
- * default namespace if the qualified name has no prefix.
- *
- *
- * @param qualifiedName
- * DOCUMENT ME!
- *
- * @return the QName for the given qualified name
- */
- QName getQName(String qualifiedName);
-
- /**
- *
- * Returns the Namespace which is mapped to the given prefix
- * or null if it could not be found.
- *
- *
- * @param prefix
- * DOCUMENT ME!
- *
- * @return the Namespace associated with the given prefix
- */
- Namespace getNamespaceForPrefix(String prefix);
-
- /**
- *
- * Returns the Namespace which is mapped to the given URI or
- * null if it could not be found. If there is more than one
- * Namespace mapped to the URI, which of them will be
- * returned is undetermined.
- *
- *
- * @param uri
- * DOCUMENT ME!
- *
- * @return the Namespace associated with the given URI
- */
- Namespace getNamespaceForURI(String uri);
-
- /**
- *
- * Returns the all namespaces which are mapped to the given URI or an empty
- * list if no such namespaces could be found.
- *
- *
- * @param uri
- * DOCUMENT ME!
- *
- * @return the namespaces associated with the given URI
- *
- * @since 1.5
- */
- List getNamespacesForURI(String uri);
-
- /**
- *
- * Returns the namespace prefix of this element if one exists otherwise an
- * empty String is returned.
- *
- *
- * @return the prefix of the Namespace of this element or an
- * empty String
- */
- String getNamespacePrefix();
-
- /**
- *
- * Returns the URI mapped to the namespace of this element if one exists
- * otherwise an empty String is returned.
- *
- *
- * @return the URI for the Namespace of this element or an
- * empty String
- */
- String getNamespaceURI();
-
- /**
- *
- * Returns the fully qualified name of this element. This will be the same
- * as the value returned from {@link #getName}if this element has no
- * namespace attached to this element or an expression of the form
- *
- *
- * getNamespacePrefix() + ":" + getName()
- *
- *
- * will be returned.
- *
- *
- * @return the fully qualified name of the element.
- */
- String getQualifiedName();
-
- /**
- *
- * Returns any additional namespaces declarations for this element other
- * than namespace returned via the {@link #getNamespace()}method. If no
- * additional namespace declarations are present for this element then an
- * empty list will be returned. The list is backed by the element such that
- * changes to the list will be reflected in the element though the reverse
- * is not the case.
- *
- *
- * @return a list of any additional namespace declarations.
- */
- List additionalNamespaces();
-
- /**
- *
- * Returns all the namespaces declared by this element. If no namespaces are
- * declared for this element then an empty list will be returned. The list
- * is backed by the element such that changes to the list will be reflected
- * in the element though the reverse is not the case.
- *
- *
- * @return a list of namespaces declared for this element.
- */
- List declaredNamespaces();
-
- // Builder methods
- // -------------------------------------------------------------------------
-
- /**
- *
- * Adds the attribute value of the given local name. If an attribute already
- * exists for the given name it will be replaced. Attributes with null
- * values are silently ignored. If the value of the attribute is null then
- * this method call will remove any attributes with the given name.
- *
- *
- * @param name
- * is the name of the attribute whose value is to be added or
- * updated
- * @param value
- * is the attribute's value
- *
- * @return this Element instance.
- */
- Element addAttribute(String name, String value);
-
- /**
- *
- * Adds the attribute value of the given fully qualified name. If an
- * attribute already exists for the given name it will be replaced.
- * Attributes with null values are silently ignored. If the value of the
- * attribute is null then this method call will remove any attributes with
- * the given name.
- *
- *
- * @param qName
- * is the fully qualified name of the attribute whose value is to
- * be added or updated
- * @param value
- * is the attribute's value
- *
- * @return this Element instance.
- */
- Element addAttribute(QName qName, String value);
-
- /**
- * Adds a new Comment node with the given text to this
- * element.
- *
- * @param comment
- * is the text for the Comment node.
- *
- * @return this Element instance.
- */
- Element addComment(String comment);
-
- /**
- * Adds a new CDATA node with the given text to this element.
- *
- * @param cdata
- * is the text for the CDATA node.
- *
- * @return this Element instance.
- */
- Element addCDATA(String cdata);
-
- /**
- * Adds a new Entity node with the given name and text to
- * this element and returns a reference to the new node.
- *
- * @param name
- * is the name for the Entity node.
- * @param text
- * is the text for the Entity node.
- *
- * @return this Element instance.
- */
- Element addEntity(String name, String text);
-
- /**
- * Adds a namespace to this element for use by its child content
- *
- * @param prefix
- * is the prefix to use, which should not be null or blank
- * @param uri
- * is the namespace URI
- *
- * @return this Element instance.
- */
- Element addNamespace(String prefix, String uri);
-
- /**
- * Adds a processing instruction for the given target
- *
- * @param target
- * is the target of the processing instruction
- * @param text
- * is the textual data (key/value pairs) of the processing
- * instruction
- *
- * @return this Element instance.
- */
- Element addProcessingInstruction(String target, String text);
-
- /**
- * Adds a processing instruction for the given target
- *
- * @param target
- * is the target of the processing instruction
- * @param data
- * is a Map of the key / value pairs of the processing
- * instruction
- *
- * @return this Element instance.
- */
- Element addProcessingInstruction(String target, Map data);
-
- /**
- * Adds a new Text node with the given text to this element.
- *
- * @param text
- * is the text for the Text node.
- *
- * @return this Element instance.
- */
- Element addText(String text);
-
- // Typesafe modifying methods
- // -------------------------------------------------------------------------
-
- /**
- * Adds the given Attribute to this element. If the given
- * node already has a parent defined then an
- * IllegalAddException will be thrown. Attributes with null
- * values are silently ignored.
- *
- *
- * If the value of the attribute is null then this method call will remove
- * any attributes with the QName of this attribute.
- *
- *
- * @param attribute
- * is the attribute to be added
- */
- void add(Attribute attribute);
-
- /**
- * Adds the given CDATA to this element. If the given node
- * already has a parent defined then an IllegalAddException
- * will be thrown.
- *
- * @param cdata
- * is the CDATA to be added
- */
- void add(CDATA cdata);
-
- /**
- * Adds the given Entity to this element. If the given node
- * already has a parent defined then an IllegalAddException
- * will be thrown.
- *
- * @param entity
- * is the entity to be added
- */
- void add(Entity entity);
-
- /**
- * Adds the given Text to this element. If the given node
- * already has a parent defined then an IllegalAddException
- * will be thrown.
- *
- * @param text
- * is the text to be added
- */
- void add(Text text);
-
- /**
- * Adds the given Namespace to this element. If the given
- * node already has a parent defined then an
- * IllegalAddException will be thrown.
- *
- * @param namespace
- * is the namespace to be added
- */
- void add(Namespace namespace);
-
- /**
- * Removes the given Attribute from this element.
- *
- * @param attribute
- * is the attribute to be removed
- *
- * @return true if the attribute was removed
- */
- boolean remove(Attribute attribute);
-
- /**
- * Removes the given CDATA if the node is an immediate child
- * of this element. If the given node is not an immediate child of this
- * element then the {@link Node#detach()}method should be used instead.
- *
- * @param cdata
- * is the CDATA to be removed
- *
- * @return true if the cdata was removed
- */
- boolean remove(CDATA cdata);
-
- /**
- * Removes the given Entity if the node is an immediate child
- * of this element. If the given node is not an immediate child of this
- * element then the {@link Node#detach()}method should be used instead.
- *
- * @param entity
- * is the entity to be removed
- *
- * @return true if the entity was removed
- */
- boolean remove(Entity entity);
-
- /**
- * Removes the given Namespace if the node is an immediate
- * child of this element. If the given node is not an immediate child of
- * this element then the {@link Node#detach()}method should be used
- * instead.
- *
- * @param namespace
- * is the namespace to be removed
- *
- * @return true if the namespace was removed
- */
- boolean remove(Namespace namespace);
-
- /**
- * Removes the given Text if the node is an immediate child
- * of this element. If the given node is not an immediate child of this
- * element then the {@link Node#detach()}method should be used instead.
- *
- * @param text
- * is the text to be removed
- *
- * @return true if the text was removed
- */
- boolean remove(Text text);
-
- // Text methods
- // -------------------------------------------------------------------------
-
- /**
- * Returns the text value of this element without recursing through child
- * elements. This method iterates through all {@link Text},{@link CDATA}
- * and {@link Entity}nodes that this element contains and appends the text
- * values together.
- *
- * @return the textual content of this Element. Child elements are not
- * navigated. This method does not return null;
- */
- String getText();
-
- /**
- * DOCUMENT ME!
- *
- * @return the trimmed text value where whitespace is trimmed and normalised
- * into single spaces. This method does not return null.
- */
- String getTextTrim();
-
- /**
- * Returns the XPath string-value of this node. The behaviour of this method
- * is defined in the XPath
- * specification . This method returns the string-value of all the
- * contained {@link Text},{@link CDATA},{@link Entity}and {@link
- * Element} nodes all appended together.
- *
- * @return the text from all the child Text and Element nodes appended
- * together.
- */
- String getStringValue();
-
- /**
- * Accesses the data of this element which may implement data typing
- * bindings such as XML Schema or Java Bean bindings or will return the same
- * value as {@link #getText}
- *
- * @return DOCUMENT ME!
- */
- Object getData();
-
- /**
- * Sets the data value of this element if this element supports data binding
- * or calls {@link #setText}if it doesn't
- *
- * @param data
- * DOCUMENT ME!
- */
- void setData(Object data);
-
- // Attribute methods
- // -------------------------------------------------------------------------
-
- /**
- *
- * Returns the {@link Attribute}instances this element contains as a backed
- * {@link List}so that the attributes may be modified directly using the
- * {@link List}interface. The List is backed by the
- * Element so that changes to the list are reflected in the
- * element and vice versa.
- *
- *
- * @return the attributes that this element contains as a List
- */
- List attributes();
-
- /**
- * Sets the attributes that this element contains
- *
- * @param attributes
- * DOCUMENT ME!
- */
- void setAttributes(List attributes);
-
- /**
- * DOCUMENT ME!
- *
- * @return the number of attributes this element contains
- */
- int attributeCount();
-
- /**
- * DOCUMENT ME!
- *
- * @return an iterator over the attributes of this element
- */
- Iterator attributeIterator();
-
- /**
- * Returns the attribute at the specified indexGets the
- *
- * @param index
- * DOCUMENT ME!
- *
- * @return the attribute at the specified index where index >= 0 and
- * index < number of attributes or throws an
- * IndexOutOfBoundsException if the index is not within the
- * allowable range
- */
- Attribute attribute(int index);
-
- /**
- * Returns the attribute with the given name
- *
- * @param name
- * DOCUMENT ME!
- *
- * @return the attribute for the given local name in any namespace. If there
- * are more than one attributes with the given local name in
- * different namespaces then the first one is returned.
- */
- Attribute attribute(String name);
-
- /**
- * DOCUMENT ME!
- *
- * @param qName
- * is the fully qualified name
- *
- * @return the attribute for the given fully qualified name or null if it
- * could not be found.
- */
- Attribute attribute(QName qName);
-
- /**
- *
- * This returns the attribute value for the attribute with the given name
- * and any namespace or null if there is no such attribute or the empty
- * string if the attribute value is empty.
- *
- *
- * @param name
- * is the name of the attribute value to be returnd
- *
- * @return the value of the attribute, null if the attribute does not exist
- * or the empty string
- */
- String attributeValue(String name);
-
- /**
- *
- * This returns the attribute value for the attribute with the given name
- * and any namespace or the default value if there is no such attribute
- * value.
- *
- *
- * @param name
- * is the name of the attribute value to be returnd
- * @param defaultValue
- * is the default value to be returned if the attribute has no
- * value defined.
- *
- * @return the value of the attribute or the defaultValue if the attribute
- * has no value defined.
- */
- String attributeValue(String name, String defaultValue);
-
- /**
- *
- * This returns the attribute value for the attribute with the given fully
- * qualified name or null if there is no such attribute or the empty string
- * if the attribute value is empty.
- *
- *
- * @param qName
- * is the fully qualified name
- *
- * @return the value of the attribute, null if the attribute does not exist
- * or the empty string
- */
- String attributeValue(QName qName);
-
- /**
- *
- * This returns the attribute value for the attribute with the given fully
- * qualified name or the default value if there is no such attribute value.
- *
- *
- * @param qName
- * is the fully qualified name
- * @param defaultValue
- * is the default value to be returned if the attribute has no
- * value defined.
- *
- * @return the value of the attribute or the defaultValue if the attribute
- * has no value defined.
- */
- String attributeValue(QName qName, String defaultValue);
-
- /**
- *
- * Sets the attribute value of the given local name.
- *
- *
- * @param name
- * is the name of the attribute whose value is to be added or
- * updated
- * @param value
- * is the attribute's value
- *
- * @deprecated As of version 0.5. Please use {@link
- * #addAttribute(String,String)} instead. WILL BE REMOVED IN
- * dom4j-1.6 !!
- */
- void setAttributeValue(String name, String value);
-
- /**
- *
- * Sets the attribute value of the given fully qualified name.
- *
- *
- * @param qName
- * is the fully qualified name of the attribute whose value is to
- * be added or updated
- * @param value
- * is the attribute's value
- *
- * @deprecated As of version 0.5. Please use {@link
- * #addAttribute(QName,String)} instead. WILL BE REMOVED IN
- * dom4j-1.6 !!
- */
- void setAttributeValue(QName qName, String value);
-
- // Content methods
- // -------------------------------------------------------------------------
-
- /**
- * Returns the first element for the given local name and any namespace.
- *
- * @param name
- * DOCUMENT ME!
- *
- * @return the first element with the given local name
- */
- Element element(String name);
-
- /**
- * Returns the first element for the given fully qualified name.
- *
- * @param qName
- * is the fully qualified name to search for
- *
- * @return the first element with the given fully qualified name
- */
- Element element(QName qName);
-
- /**
- *
- * Returns the elements contained in this element. If this element does not
- * contain any elements then this method returns an empty list. The list is
- * backed by the element such that changes to the list will be reflected in
- * the element though the reverse is not the case.
- *
- *
- * @return a list of all the elements in this element.
- */
- List elements();
-
- /**
- *
- * Returns the elements contained in this element with the given local name
- * and any namespace. If no elements are found then this method returns an
- * empty list. The list is backed by the element such that changes to the
- * list will be reflected in the element though the reverse is not the case.
- *
- *
- * @param name
- * DOCUMENT ME!
- *
- * @return a list of all the elements in this element for the given local
- * name
- */
- List elements(String name);
-
- /**
- *
- * Returns the elements contained in this element with the given fully
- * qualified name. If no elements are found then this method returns an
- * empty list. The list is backed by the element such that changes to the
- * list will be reflected in the element though the reverse is not the case.
- *
- *
- * @param qName
- * is the fully qualified name to search for
- *
- * @return a list of all the elements in this element for the given fully
- * qualified name.
- */
- List elements(QName qName);
-
- /**
- * Returns an iterator over all this elements child elements.
- *
- * @return an iterator over the contained elements
- */
- Iterator elementIterator();
-
- /**
- * Returns an iterator over the elements contained in this element which
- * match the given local name and any namespace.
- *
- * @param name
- * DOCUMENT ME!
- *
- * @return an iterator over the contained elements matching the given local
- * name
- */
- Iterator elementIterator(String name);
-
- /**
- * Returns an iterator over the elements contained in this element which
- * match the given fully qualified name.
- *
- * @param qName
- * is the fully qualified name to search for
- *
- * @return an iterator over the contained elements matching the given fully
- * qualified name
- */
- Iterator elementIterator(QName qName);
-
- // Helper methods
- // -------------------------------------------------------------------------
-
- /**
- * DOCUMENT ME!
- *
- * @return true if this element is the root element of a document and this
- * element supports the parent relationship else false.
- */
- boolean isRootElement();
-
- /**
- *
- * Returns true if this Element has mixed content. Mixed
- * content means that an element contains both textual data and child
- * elements.
- *
- *
- * @return true if this element contains mixed content.
- */
- boolean hasMixedContent();
-
- /**
- *
- * Returns true if this Element has text only content.
- *
- *
- * @return true if this element is empty or only contains text content.
- */
- boolean isTextOnly();
-
- /**
- * Appends the attributes of the given element to me. This method behaves
- * like the {@link java.util.Collection#addAll(java.util.Collection)}
- * method.
- *
- * @param element
- * is the element whose attributes will be added to me.
- */
- void appendAttributes(Element element);
-
- /**
- *
- * Creates a deep copy of this element The new element is detached from its
- * parent, and getParent() on the clone will return null.
- *
- *
- * @return a new deep copy Element
- */
- Element createCopy();
-
- /**
- *
- * Creates a deep copy of this element with the given local name The new
- * element is detached from its parent, and getParent() on the clone will
- * return null.
- *
- *
- * @param name
- * DOCUMENT ME!
- *
- * @return a new deep copy Element
- */
- Element createCopy(String name);
-
- /**
- *
- * Creates a deep copy of this element with the given fully qualified name.
- * The new element is detached from its parent, and getParent() on the clone
- * will return null.
- *
- *
- * @param qName
- * DOCUMENT ME!
- *
- * @return a new deep copy Element
- */
- Element createCopy(QName qName);
-
- String elementText(String name);
-
- String elementText(QName qname);
-
- String elementTextTrim(String name);
-
- String elementTextTrim(QName qname);
-
- /**
- * Returns a node at the given index suitable for an XPath result set. This
- * means the resulting Node will either be null or it will support the
- * parent relationship.
- *
- * @param index
- * DOCUMENT ME!
- *
- * @return the Node for the given index which will support the parent
- * relationship or null if there is not a node at the given index.
- */
- Node getXPathResult(int index);
+ // Name and namespace related methods
+ // -------------------------------------------------------------------------
+
+ /**
+ * Returns the QName of this element which represents the
+ * local name, the qualified name and the Namespace.
+ *
+ * @return the QName associated with this element
+ */
+ QName getQName();
+
+ /**
+ * Sets the QName of this element which represents the local
+ * name, the qualified name and the Namespace.
+ *
+ * @param qname is the QName to be associated with this element
+ */
+ void setQName(QName qname);
+
+ /**
+ * Returns the Namespace of this element if one exists
+ * otherwise Namespace.NO_NAMESPACE is returned.
+ *
+ * @return the Namespace associated with this element
+ */
+ Namespace getNamespace();
+
+ /**
+ * Returns the QName for the given qualified name, using the
+ * namespace URI in scope for the given prefix of the qualified name or the
+ * default namespace if the qualified name has no prefix.
+ *
+ * @param qualifiedName DOCUMENT ME!
+ * @return the QName for the given qualified name
+ */
+ QName getQName(String qualifiedName);
+
+ /**
+ * Returns the Namespace which is mapped to the given prefix
+ * or null if it could not be found.
+ *
+ * @param prefix DOCUMENT ME!
+ * @return the Namespace associated with the given prefix
+ */
+ Namespace getNamespaceForPrefix(String prefix);
+
+ /**
+ * Returns the Namespace which is mapped to the given URI or
+ * null if it could not be found. If there is more than one
+ * Namespace mapped to the URI, which of them will be
+ * returned is undetermined.
+ *
+ * @param uri DOCUMENT ME!
+ * @return the Namespace associated with the given URI
+ */
+ Namespace getNamespaceForURI(String uri);
+
+ /**
+ * Returns the all namespaces which are mapped to the given URI or an empty
+ * list if no such namespaces could be found.
+ *
+ * @param uri DOCUMENT ME!
+ * @return the namespaces associated with the given URI
+ * @since 1.5
+ */
+ List getNamespacesForURI(String uri);
+
+ /**
+ * Returns the namespace prefix of this element if one exists otherwise an
+ * empty String is returned.
+ *
+ * @return the prefix of the Namespace of this element or an
+ * empty String
+ */
+ String getNamespacePrefix();
+
+ /**
+ * Returns the URI mapped to the namespace of this element if one exists
+ * otherwise an empty String is returned.
+ *
+ * @return the URI for the Namespace of this element or an
+ * empty String
+ */
+ String getNamespaceURI();
+
+ /**
+ * Returns the fully qualified name of this element. This will be the same
+ * as the value returned from {@link #getName}if this element has no
+ * namespace attached to this element or an expression of the form
+ *
+ * getNamespacePrefix() + ":" + getName()
+ *
+ * will be returned.
+ *
+ * @return the fully qualified name of the element.
+ */
+ String getQualifiedName();
+
+ /**
+ * Returns any additional namespaces declarations for this element other
+ * than namespace returned via the {@link #getNamespace()}method. If no
+ * additional namespace declarations are present for this element then an
+ * empty list will be returned. The list is backed by the element such that
+ * changes to the list will be reflected in the element though the reverse
+ * is not the case.
+ *
+ * @return a list of any additional namespace declarations.
+ */
+ List additionalNamespaces();
+
+ /**
+ * Returns all the namespaces declared by this element. If no namespaces are
+ * declared for this element then an empty list will be returned. The list
+ * is backed by the element such that changes to the list will be reflected
+ * in the element though the reverse is not the case.
+ *
+ * @return a list of namespaces declared for this element.
+ */
+ List declaredNamespaces();
+
+ // Builder methods
+ // -------------------------------------------------------------------------
+
+ /**
+ * Adds the attribute value of the given local name. If an attribute already
+ * exists for the given name it will be replaced. Attributes with null
+ * values are silently ignored. If the value of the attribute is null then
+ * this method call will remove any attributes with the given name.
+ *
+ * @param name is the name of the attribute whose value is to be added or
+ * updated
+ * @param value is the attribute's value
+ * @return this Element instance.
+ */
+ Element addAttribute(String name, String value);
+
+ /**
+ * Adds the attribute value of the given fully qualified name. If an
+ * attribute already exists for the given name it will be replaced.
+ * Attributes with null values are silently ignored. If the value of the
+ * attribute is null then this method call will remove any attributes with
+ * the given name.
+ *
+ * @param qName is the fully qualified name of the attribute whose value is to
+ * be added or updated
+ * @param value is the attribute's value
+ * @return this Element instance.
+ */
+ Element addAttribute(QName qName, String value);
+
+ /**
+ * Adds a new Comment node with the given text to this
+ * element.
+ *
+ * @param comment is the text for the Comment node.
+ * @return this Element instance.
+ */
+ Element addComment(String comment);
+
+ /**
+ * Adds a new CDATA node with the given text to this element.
+ *
+ * @param cdata is the text for the CDATA node.
+ * @return this Element instance.
+ */
+ Element addCDATA(String cdata);
+
+ /**
+ * Adds a new Entity node with the given name and text to
+ * this element and returns a reference to the new node.
+ *
+ * @param name is the name for the Entity node.
+ * @param text is the text for the Entity node.
+ * @return this Element instance.
+ */
+ Element addEntity(String name, String text);
+
+ /**
+ * Adds a namespace to this element for use by its child content
+ *
+ * @param prefix is the prefix to use, which should not be null or blank
+ * @param uri is the namespace URI
+ * @return this Element instance.
+ */
+ Element addNamespace(String prefix, String uri);
+
+ /**
+ * Adds a processing instruction for the given target
+ *
+ * @param target is the target of the processing instruction
+ * @param text is the textual data (key/value pairs) of the processing
+ * instruction
+ * @return this Element instance.
+ */
+ Element addProcessingInstruction(String target, String text);
+
+ /**
+ * Adds a processing instruction for the given target
+ *
+ * @param target is the target of the processing instruction
+ * @param data is a Map of the key / value pairs of the processing
+ * instruction
+ * @return this Element instance.
+ */
+ Element addProcessingInstruction(String target, Map data);
+
+ /**
+ * Adds a new Text node with the given text to this element.
+ *
+ * @param text is the text for the Text node.
+ * @return this Element instance.
+ */
+ Element addText(String text);
+
+ // Typesafe modifying methods
+ // -------------------------------------------------------------------------
+
+ /**
+ * Adds the given Attribute to this element. If the given
+ * node already has a parent defined then an
+ * IllegalAddException will be thrown. Attributes with null
+ * values are silently ignored.
+ *
+ * If the value of the attribute is null then this method call will remove
+ * any attributes with the QName of this attribute.
+ *
+ * @param attribute is the attribute to be added
+ */
+ void add(Attribute attribute);
+
+ /**
+ * Adds the given CDATA to this element. If the given node
+ * already has a parent defined then an IllegalAddException
+ * will be thrown.
+ *
+ * @param cdata is the CDATA to be added
+ */
+ void add(CDATA cdata);
+
+ /**
+ * Adds the given Entity to this element. If the given node
+ * already has a parent defined then an IllegalAddException
+ * will be thrown.
+ *
+ * @param entity is the entity to be added
+ */
+ void add(Entity entity);
+
+ /**
+ * Adds the given Text to this element. If the given node
+ * already has a parent defined then an IllegalAddException
+ * will be thrown.
+ *
+ * @param text is the text to be added
+ */
+ void add(Text text);
+
+ /**
+ * Adds the given Namespace to this element. If the given
+ * node already has a parent defined then an
+ * IllegalAddException will be thrown.
+ *
+ * @param namespace is the namespace to be added
+ */
+ void add(Namespace namespace);
+
+ /**
+ * Removes the given Attribute from this element.
+ *
+ * @param attribute is the attribute to be removed
+ * @return true if the attribute was removed
+ */
+ boolean remove(Attribute attribute);
+
+ /**
+ * Removes the given CDATA if the node is an immediate child
+ * of this element. If the given node is not an immediate child of this
+ * element then the {@link Node#detach()}method should be used instead.
+ *
+ * @param cdata is the CDATA to be removed
+ * @return true if the cdata was removed
+ */
+ boolean remove(CDATA cdata);
+
+ /**
+ * Removes the given Entity if the node is an immediate child
+ * of this element. If the given node is not an immediate child of this
+ * element then the {@link Node#detach()}method should be used instead.
+ *
+ * @param entity is the entity to be removed
+ * @return true if the entity was removed
+ */
+ boolean remove(Entity entity);
+
+ /**
+ * Removes the given Namespace if the node is an immediate
+ * child of this element. If the given node is not an immediate child of
+ * this element then the {@link Node#detach()}method should be used
+ * instead.
+ *
+ * @param namespace is the namespace to be removed
+ * @return true if the namespace was removed
+ */
+ boolean remove(Namespace namespace);
+
+ /**
+ * Removes the given Text if the node is an immediate child
+ * of this element. If the given node is not an immediate child of this
+ * element then the {@link Node#detach()}method should be used instead.
+ *
+ * @param text is the text to be removed
+ * @return true if the text was removed
+ */
+ boolean remove(Text text);
+
+ // Text methods
+ // -------------------------------------------------------------------------
+
+ /**
+ * Returns the text value of this element without recursing through child
+ * elements. This method iterates through all {@link Text},{@link CDATA}
+ * and {@link Entity}nodes that this element contains and appends the text
+ * values together.
+ *
+ * @return the textual content of this Element. Child elements are not
+ * navigated. This method does not return null;
+ */
+ String getText();
+
+ /**
+ * DOCUMENT ME!
+ *
+ * @return the trimmed text value where whitespace is trimmed and normalised
+ * into single spaces. This method does not return null.
+ */
+ String getTextTrim();
+
+ /**
+ * Returns the XPath string-value of this node. The behaviour of this method
+ * is defined in the XPath
+ * specification . This method returns the string-value of all the
+ * contained {@link Text},{@link CDATA},{@link Entity}and {@link
+ * Element} nodes all appended together.
+ *
+ * @return the text from all the child Text and Element nodes appended
+ * together.
+ */
+ String getStringValue();
+
+ /**
+ * Accesses the data of this element which may implement data typing
+ * bindings such as XML Schema or Java Bean bindings or will return the same
+ * value as {@link #getText}
+ *
+ * @return DOCUMENT ME!
+ */
+ Object getData();
+
+ /**
+ * Sets the data value of this element if this element supports data binding
+ * or calls {@link #setText}if it doesn't
+ *
+ * @param data DOCUMENT ME!
+ */
+ void setData(Object data);
+
+ // Attribute methods
+ // -------------------------------------------------------------------------
+
+ /**
+ * Returns the {@link Attribute}instances this element contains as a backed
+ * {@link List}so that the attributes may be modified directly using the
+ * {@link List}interface. The List is backed by the
+ * Element so that changes to the list are reflected in the
+ * element and vice versa.
+ *
+ * @return the attributes that this element contains as a List
+ */
+ List attributes();
+
+ /**
+ * Sets the attributes that this element contains
+ *
+ * @param attributes DOCUMENT ME!
+ */
+ void setAttributes(List attributes);
+
+ /**
+ * DOCUMENT ME!
+ *
+ * @return the number of attributes this element contains
+ */
+ int attributeCount();
+
+ /**
+ * DOCUMENT ME!
+ *
+ * @return an iterator over the attributes of this element
+ */
+ Iterator attributeIterator();
+
+ /**
+ * Returns the attribute at the specified indexGets the
+ *
+ * @param index DOCUMENT ME!
+ * @return the attribute at the specified index where index >= 0 and
+ * index < number of attributes or throws an
+ * IndexOutOfBoundsException if the index is not within the
+ * allowable range
+ */
+ Attribute attribute(int index);
+
+ /**
+ * Returns the attribute with the given name
+ *
+ * @param name DOCUMENT ME!
+ * @return the attribute for the given local name in any namespace. If there
+ * are more than one attributes with the given local name in
+ * different namespaces then the first one is returned.
+ */
+ Attribute attribute(String name);
+
+ /**
+ * DOCUMENT ME!
+ *
+ * @param qName is the fully qualified name
+ * @return the attribute for the given fully qualified name or null if it
+ * could not be found.
+ */
+ Attribute attribute(QName qName);
+
+ /**
+ * This returns the attribute value for the attribute with the given name
+ * and any namespace or null if there is no such attribute or the empty
+ * string if the attribute value is empty.
+ *
+ * @param name is the name of the attribute value to be returned
+ * @return the value of the attribute, null if the attribute does not exist
+ * or the empty string
+ */
+ String attributeValue(String name);
+
+ /**
+ * This returns the attribute value for the attribute with the given name
+ * and any namespace or the default value if there is no such attribute
+ * value.
+ *
+ * @param name is the name of the attribute value to be returned
+ * @param defaultValue is the default value to be returned if the attribute has no
+ * value defined.
+ * @return the value of the attribute or the defaultValue if the attribute
+ * has no value defined.
+ */
+ String attributeValue(String name, String defaultValue);
+
+ /**
+ * This returns the attribute value for the attribute with the given fully
+ * qualified name or null if there is no such attribute or the empty string
+ * if the attribute value is empty.
+ *
+ * @param qName is the fully qualified name
+ * @return the value of the attribute, null if the attribute does not exist
+ * or the empty string
+ */
+ String attributeValue(QName qName);
+
+ /**
+ * This returns the attribute value for the attribute with the given fully
+ * qualified name or the default value if there is no such attribute value.
+ *
+ * @param qName is the fully qualified name
+ * @param defaultValue is the default value to be returned if the attribute has no
+ * value defined.
+ * @return the value of the attribute or the defaultValue if the attribute
+ * has no value defined.
+ */
+ String attributeValue(QName qName, String defaultValue);
+
+ /**
+ * Sets the attribute value of the given local name.
+ *
+ * @param name is the name of the attribute whose value is to be added or
+ * updated
+ * @param value is the attribute's value
+ * @deprecated As of version 0.5. Please use {@link
+ * #addAttribute(String, String)} instead. WILL BE REMOVED IN
+ * dom4j-1.6 !!
+ */
+ void setAttributeValue(String name, String value);
+
+ /**
+ * Sets the attribute value of the given fully qualified name.
+ *
+ * @param qName is the fully qualified name of the attribute whose value is to
+ * be added or updated
+ * @param value is the attribute's value
+ * @deprecated As of version 0.5. Please use {@link
+ * #addAttribute(QName, String)} instead. WILL BE REMOVED IN
+ * dom4j-1.6 !!
+ */
+ void setAttributeValue(QName qName, String value);
+
+ // Content methods
+ // -------------------------------------------------------------------------
+
+ /**
+ * Returns the first element for the given local name and any namespace.
+ *
+ * @param name DOCUMENT ME!
+ * @return the first element with the given local name
+ */
+ Element element(String name);
+
+ /**
+ * Returns the first element for the given fully qualified name.
+ *
+ * @param qName is the fully qualified name to search for
+ * @return the first element with the given fully qualified name
+ */
+ Element element(QName qName);
+
+ /**
+ * Returns the elements contained in this element. If this element does not
+ * contain any elements then this method returns an empty list. The list is
+ * backed by the element such that changes to the list will be reflected in
+ * the element though the reverse is not the case.
+ *
+ * @return a list of all the elements in this element.
+ */
+ List elements();
+
+ /**
+ * Returns the elements contained in this element with the given local name
+ * and any namespace. If no elements are found then this method returns an
+ * empty list. The list is backed by the element such that changes to the
+ * list will be reflected in the element though the reverse is not the case.
+ *
+ * @param name DOCUMENT ME!
+ * @return a list of all the elements in this element for the given local
+ * name
+ */
+ List elements(String name);
+
+ /**
+ * Returns the elements contained in this element with the given fully
+ * qualified name. If no elements are found then this method returns an
+ * empty list. The list is backed by the element such that changes to the
+ * list will be reflected in the element though the reverse is not the case.
+ *
+ * @param qName is the fully qualified name to search for
+ * @return a list of all the elements in this element for the given fully
+ * qualified name.
+ */
+ List elements(QName qName);
+
+ /**
+ * Returns an iterator over all this elements child elements.
+ *
+ * @return an iterator over the contained elements
+ */
+ Iterator elementIterator();
+
+ /**
+ * Returns an iterator over the elements contained in this element which
+ * match the given local name and any namespace.
+ *
+ * @param name DOCUMENT ME!
+ * @return an iterator over the contained elements matching the given local
+ * name
+ */
+ Iterator elementIterator(String name);
+
+ /**
+ * Returns an iterator over the elements contained in this element which
+ * match the given fully qualified name.
+ *
+ * @param qName is the fully qualified name to search for
+ * @return an iterator over the contained elements matching the given fully
+ * qualified name
+ */
+ Iterator elementIterator(QName qName);
+
+ // Helper methods
+ // -------------------------------------------------------------------------
+
+ /**
+ * DOCUMENT ME!
+ *
+ * @return true if this element is the root element of a document and this
+ * element supports the parent relationship else false.
+ */
+ boolean isRootElement();
+
+ /**
+ * Returns true if this Element has mixed content. Mixed
+ * content means that an element contains both textual data and child
+ * elements.
+ *
+ * @return true if this element contains mixed content.
+ */
+ boolean hasMixedContent();
+
+ /**
+ * Returns true if this Element has text only content.
+ *
+ * @return true if this element is empty or only contains text content.
+ */
+ boolean isTextOnly();
+
+ /**
+ * Appends the attributes of the given element to me. This method behaves
+ * like the {@link java.util.Collection#addAll(java.util.Collection)}
+ * method.
+ *
+ * @param element is the element whose attributes will be added to me.
+ */
+ void appendAttributes(Element element);
+
+ /**
+ * Creates a deep copy of this element The new element is detached from its
+ * parent, and getParent() on the clone will return null.
+ *
+ * @return a new deep copy Element
+ */
+ Element createCopy();
+
+ /**
+ * Creates a deep copy of this element with the given local name The new
+ * element is detached from its parent, and getParent() on the clone will
+ * return null.
+ *
+ * @param name DOCUMENT ME!
+ * @return a new deep copy Element
+ */
+ Element createCopy(String name);
+
+ /**
+ * Creates a deep copy of this element with the given fully qualified name.
+ * The new element is detached from its parent, and getParent() on the clone
+ * will return null.
+ *
+ * @param qName DOCUMENT ME!
+ * @return a new deep copy Element
+ */
+ Element createCopy(QName qName);
+
+ String elementText(String name);
+
+ String elementText(QName qname);
+
+ String elementTextTrim(String name);
+
+ String elementTextTrim(QName qname);
+
+ /**
+ * Returns a node at the given index suitable for an XPath result set. This
+ * means the resulting Node will either be null or it will support the
+ * parent relationship.
+ *
+ * @param index DOCUMENT ME!
+ * @return the Node for the given index which will support the parent
+ * relationship or null if there is not a node at the given index.
+ */
+ Node getXPathResult(int index);
}
/*
diff --git a/fine-org-dom4j/src/main/java/org/dom4j/ElementHandler.java b/fine-org-dom4j/src/main/java/org/dom4j/ElementHandler.java
index a03bf85c0..f195891fc 100644
--- a/fine-org-dom4j/src/main/java/org/dom4j/ElementHandler.java
+++ b/fine-org-dom4j/src/main/java/org/dom4j/ElementHandler.java
@@ -8,16 +8,15 @@
package org.dom4j;
/**
- *
* ElementHandler interface defines a handler of
* Element objects. It is used primarily in event based
* processing models such as for processing large XML documents as they are
* being parsed rather than waiting until the whole document is parsed.
- *
- *
+ *
* @author James Strachan
- * @version $Revision$
+ * @version $Revision: 1.8 $
*/
+@SuppressWarnings("unused")
public interface ElementHandler {
/**
* Called by an event based processor when an elements openning tag is
diff --git a/fine-org-dom4j/src/main/java/org/dom4j/ElementPath.java b/fine-org-dom4j/src/main/java/org/dom4j/ElementPath.java
index 2d8784c7f..8ddfdf6cc 100644
--- a/fine-org-dom4j/src/main/java/org/dom4j/ElementPath.java
+++ b/fine-org-dom4j/src/main/java/org/dom4j/ElementPath.java
@@ -13,8 +13,9 @@ package org.dom4j;
* primary use is to retrieve the current {@link Element}being processed.
*
* @author Dave White
- * @version $Revision$
+ * @version $Revision: 1.6 $
*/
+@SuppressWarnings("unused")
public interface ElementPath {
/**
* DOCUMENT ME!
diff --git a/fine-org-dom4j/src/main/java/org/dom4j/Entity.java b/fine-org-dom4j/src/main/java/org/dom4j/Entity.java
index 7c851691e..e79a8e70e 100644
--- a/fine-org-dom4j/src/main/java/org/dom4j/Entity.java
+++ b/fine-org-dom4j/src/main/java/org/dom4j/Entity.java
@@ -8,13 +8,12 @@
package org.dom4j;
/**
- *
* Namespace is a Flyweight Namespace that can be shared amongst
* nodes.
- *
- *
+ *
* @author James Strachan
- * @version $Revision$
+ * @version $Revision: 1.22 $
*/
public class Namespace extends AbstractNode {
/** Cache of Namespace instances */
@@ -51,6 +49,10 @@ public class Namespace extends AbstractNode {
public Namespace(String prefix, String uri) {
this.prefix = (prefix != null) ? prefix : "";
this.uri = (uri != null) ? uri : "";
+
+ if (!this.prefix.isEmpty()) {
+ QName.validateNCName(this.prefix);
+ }
}
/**
diff --git a/fine-org-dom4j/src/main/java/org/dom4j/Node.java b/fine-org-dom4j/src/main/java/org/dom4j/Node.java
index fd11396cf..1cec5a3da 100644
--- a/fine-org-dom4j/src/main/java/org/dom4j/Node.java
+++ b/fine-org-dom4j/src/main/java/org/dom4j/Node.java
@@ -12,26 +12,21 @@ import java.io.Writer;
import java.util.List;
/**
- *
* Node defines the polymorphic behavior for all XML nodes in a
* dom4j tree.
- *
- *
- *
+ *
* A node can be output as its XML format, can be detached from its position in
* a document and can have XPath expressions evaluated on itself.
- *
- *
- *
+ *
* A node may optionally support the parent relationship and may be read only.
- *
- *
+ *
* @author James Strachan
- * @version $Revision$
+ * @version $Revision: 1.31 $
*
* @see #supportsParent
* @see #isReadOnly
*/
+@SuppressWarnings("unused")
public interface Node extends Cloneable {
// W3C DOM complient node type codes
@@ -381,7 +376,7 @@ public interface Node extends Cloneable {
* @return the list of Node or String
* instances depending on the XPath expression
*/
- List selectNodes(String xpathExpression);
+ List selectNodes(String xpathExpression);
/**
*
@@ -417,7 +412,7 @@ public interface Node extends Cloneable {
* @return the list of Node instances sorted by the
* comparisonXPathExpression
*/
- List selectNodes(String xpathExpression, String comparisonXPathExpression);
+ List selectNodes(String xpathExpression, String comparisonXPathExpression);
/**
*
@@ -438,7 +433,7 @@ public interface Node extends Cloneable {
* @return the list of Node instances sorted by the
* comparisonXPathExpression
*/
- List selectNodes(String xpathExpression, String comparisonXPathExpression,
+ List selectNodes(String xpathExpression, String comparisonXPathExpression,
boolean removeDuplicates);
/**
diff --git a/fine-org-dom4j/src/main/java/org/dom4j/NodeFilter.java b/fine-org-dom4j/src/main/java/org/dom4j/NodeFilter.java
index 936143323..a5091b9f7 100644
--- a/fine-org-dom4j/src/main/java/org/dom4j/NodeFilter.java
+++ b/fine-org-dom4j/src/main/java/org/dom4j/NodeFilter.java
@@ -8,15 +8,14 @@
package org.dom4j;
/**
- *
* NodeFilter defines the behavior for a filter or predicate
* which acts on a DOM4J Node. Instances can be generated from an {@link
* DocumentFactory}.
- *
* ProcessingInstruction defines an XML processing instruction.
* The {@link Node#getName}method will return the target of the PI and the
* {@link Node#getText}method will return the data from all of the
* instructions.
- *
- *
+ *
* @author James Strachan
- * @version $Revision$
+ * @version $Revision: 1.10 $
*/
+@SuppressWarnings("unused")
public interface ProcessingInstruction extends Node {
/**
* This method is the equivalent to the {@link #getName}method. It is added
@@ -63,11 +62,11 @@ public interface ProcessingInstruction extends Node {
*
* @return the values for this processing instruction as a Map
*/
- Map getValues();
+ Map getValues();
void setValue(String name, String value);
- void setValues(Map data);
+ void setValues(Map data);
boolean removeValue(String name);
}
diff --git a/fine-org-dom4j/src/main/java/org/dom4j/QName.java b/fine-org-dom4j/src/main/java/org/dom4j/QName.java
index 955c0d386..e9b2170e9 100644
--- a/fine-org-dom4j/src/main/java/org/dom4j/QName.java
+++ b/fine-org-dom4j/src/main/java/org/dom4j/QName.java
@@ -11,40 +11,114 @@ import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.Serializable;
+import java.util.regex.Pattern;
import org.dom4j.tree.QNameCache;
import org.dom4j.util.SingletonStrategy;
/**
- *
* QName represents a qualified name value of an XML element or
* attribute. It consists of a local name and a {@link Namespace}instance. This
* object is immutable.
- *
- *
+ *
* @author James Strachan
+ * @author Filip Jirsák
*/
public class QName implements Serializable {
/** The Singleton instance */
- private static SingletonStrategy singleton = null;
+ private static SingletonStrategy singleton = null;
+
+ /**
+ * {@code NameStartChar} without colon.
+ *
+ *
* Visitor is used to implement the Visitor
* pattern in DOM4J. An object of this interface can be passed to a
* Node which will then call its typesafe methods. Please refer
* to the Gang of Four book of Design Patterns for more details on the
* Visitor pattern.
- *
- *
- *
+ *
* This site
* has further discussion on design patterns and links to the GOF book. This link describes the
* Visitor pattern in detail.
- *
* VisitorSupport is an abstract base class which is useful for
* implementation inheritence or when using anonymous inner classes to create
* simple Visitor implementations.
- *
- * getText will return the textual version of the XPath
- * expression.
- *
- *
- * @return the textual format of the XPath expression.
- */
- String getText();
+ /**
+ * getText will return the textual version of the XPath
+ * expression.
+ *
+ * @return the textual format of the XPath expression.
+ */
+ String getText();
- /**
- *
- * matches returns true if the given node matches the XPath
- * expression. To be more precise when evaluating this XPath expression on
- * the given node the result set must include the node.
- *
- *
- * @param node
- * DOCUMENT ME!
- *
- * @return true if the given node matches this XPath expression
- */
- boolean matches(Node node);
+ /**
+ * matches returns true if the given node matches the XPath
+ * expression. To be more precise when evaluating this XPath expression on
+ * the given node the result set must include the node.
+ *
+ * @param node DOCUMENT ME!
+ * @return true if the given node matches this XPath expression
+ */
+ boolean matches(Node node);
- /**
- *
- * evaluate evaluates an XPath expression and returns the
- * result as an {@link Object}. The object returned can either be a {@link
- * List} of {@link Node}instances, a {@link Node}instance, a {@link
- * String} or a {@link Number}instance depending on the XPath expression.
- *
- *
- * @param context
- * is either a node or a list of nodes on which to evalute the
- * XPath
- *
- * @return the value of the XPath expression as a {@link List}of {@link
- * Node} instances, a {@link Node}instance, a {@link String}or a
- * {@link Number}instance depending on the XPath expression.
- */
- Object evaluate(Object context);
+ /**
+ * evaluate evaluates an XPath expression and returns the
+ * result as an {@link Object}. The object returned can either be a {@link
+ * List} of {@link Node}instances, a {@link Node}instance, a {@link
+ * String} or a {@link Number}instance depending on the XPath expression.
+ *
+ * @param context is either a node or a list of nodes on which to evalute the
+ * XPath
+ * @return the value of the XPath expression as a {@link List}of {@link
+ * Node} instances, a {@link Node}instance, a {@link String}or a
+ * {@link Number}instance depending on the XPath expression.
+ */
+ Object evaluate(Object context);
- /**
- *
- * selectObject evaluates an XPath expression and returns the
- * result as an {@link Object}. The object returned can either be a {@link
- * List} of {@link Node}instances, a {@link Node}instance, a {@link
- * String} or a {@link Number}instance depending on the XPath expression.
- *
- *
- * @param context
- * is either a node or a list of nodes on which to evalute the
- * XPath
- *
- * @return the value of the XPath expression as a {@link List}of {@link
- * Node} instances, a {@link Node}instance, a {@link String}or a
- * {@link Number}instance depending on the XPath expression.
- *
- * @deprecated please use evaluate(Object) instead. WILL BE REMOVED IN
- * dom4j-1.6 !!
- */
- Object selectObject(Object context);
+ /**
+ * selectObject evaluates an XPath expression and returns the
+ * result as an {@link Object}. The object returned can either be a {@link
+ * List} of {@link Node}instances, a {@link Node}instance, a {@link
+ * String} or a {@link Number}instance depending on the XPath expression.
+ *
+ * @param context is either a node or a list of nodes on which to evalute the
+ * XPath
+ * @return the value of the XPath expression as a {@link List}of {@link
+ * Node} instances, a {@link Node}instance, a {@link String}or a
+ * {@link Number}instance depending on the XPath expression.
+ * @deprecated please use evaluate(Object) instead. WILL BE REMOVED IN
+ * dom4j-1.6 !!
+ */
+ Object selectObject(Object context);
- /**
- *
- * selectNodes performs this XPath expression on the given
- * {@link Node}or {@link List}of {@link Node}s instances appending all
- * the results together into a single list.
- *
- *
- * @param context
- * is either a node or a list of nodes on which to evalute the
- * XPath
- *
- * @return the results of all the XPath evaluations as a single list
- */
- List selectNodes(Object context);
+ /**
+ * selectNodes performs this XPath expression on the given
+ * {@link Node}or {@link List}of {@link Node}s instances appending all
+ * the results together into a single list.
+ *
+ * @param context is either a node or a list of nodes on which to evalute the
+ * XPath
+ * @return the results of all the XPath evaluations as a single list
+ */
+ List selectNodes(Object context);
- /**
- *
- * selectNodes evaluates the XPath expression on the given
- * {@link Node}or {@link List}of {@link Node}s and returns the result as
- * a List of Node s sorted by the sort XPath
- * expression.
- *
- *
- * @param context
- * is either a node or a list of nodes on which to evalute the
- * XPath
- * @param sortXPath
- * is the XPath expression to sort by
- *
- * @return a list of Node instances
- */
- List selectNodes(Object context, XPath sortXPath);
+ /**
+ * selectNodes evaluates the XPath expression on the given
+ * {@link Node}or {@link List}of {@link Node}s and returns the result as
+ * a List of Node s sorted by the sort XPath
+ * expression.
+ *
+ * @param context is either a node or a list of nodes on which to evalute the
+ * XPath
+ * @param sortXPath is the XPath expression to sort by
+ * @return a list of Node instances
+ */
+ List selectNodes(Object context, XPath sortXPath);
- /**
- *
- * selectNodes evaluates the XPath expression on the given
- * {@link Node}or {@link List}of {@link Node}s and returns the result as
- * a List of Node s sorted by the sort XPath
- * expression.
- *
- *
- * @param context
- * is either a node or a list of nodes on which to evalute the
- * XPath
- * @param sortXPath
- * is the XPath expression to sort by
- * @param distinct
- * specifies whether or not duplicate values of the sort
- * expression are allowed. If this parameter is true then only
- * distinct sort expressions values are included in the result
- *
- * @return a list of Node instances
- */
- List selectNodes(Object context, XPath sortXPath, boolean distinct);
+ /**
+ * selectNodes evaluates the XPath expression on the given
+ * {@link Node}or {@link List}of {@link Node}s and returns the result as
+ * a List of Node s sorted by the sort XPath
+ * expression.
+ *
+ * @param context is either a node or a list of nodes on which to evalute the
+ * XPath
+ * @param sortXPath is the XPath expression to sort by
+ * @param distinct specifies whether or not duplicate values of the sort
+ * expression are allowed. If this parameter is true then only
+ * distinct sort expressions values are included in the result
+ * @return a list of Node instances
+ */
+ List selectNodes(Object context, XPath sortXPath, boolean distinct);
- /**
- *
- * selectSingleNode evaluates this XPath expression on the
- * given {@link Node}or {@link List}of {@link Node}s and returns the
- * result as a single Node instance.
- *
- *
- * @param context
- * is either a node or a list of nodes on which to evalute the
- * XPath
- *
- * @return a single matching Node instance
- */
- Node selectSingleNode(Object context);
+ /**
+ * selectSingleNode evaluates this XPath expression on the
+ * given {@link Node}or {@link List}of {@link Node}s and returns the
+ * result as a single Node instance.
+ *
+ * @param context is either a node or a list of nodes on which to evalute the
+ * XPath
+ * @return a single matching Node instance
+ */
+ Node selectSingleNode(Object context);
- /**
- *
- * valueOf evaluates this XPath expression and returns the
- * textual representation of the results using the XPath string() function.
- *
- *
- * @param context
- * is either a node or a list of nodes on which to evalute the
- * XPath
- *
- * @return the string representation of the results of the XPath expression
- */
- String valueOf(Object context);
+ /**
+ * valueOf evaluates this XPath expression and returns the
+ * textual representation of the results using the XPath string() function.
+ *
+ * @param context is either a node or a list of nodes on which to evalute the
+ * XPath
+ * @return the string representation of the results of the XPath expression
+ */
+ String valueOf(Object context);
- /**
- *
- * numberValueOf evaluates an XPath expression and returns
- * the numeric value of the XPath expression if the XPath expression results
- * is a number, or null if the result is not a number.
- *
- *
- * @param context
- * is either a node or a list of nodes on which to evalute the
- * XPath
- *
- * @return the numeric result of the XPath expression or null if the result
- * is not a number.
- */
- Number numberValueOf(Object context);
+ /**
+ * numberValueOf evaluates an XPath expression and returns
+ * the numeric value of the XPath expression if the XPath expression results
+ * is a number, or null if the result is not a number.
+ *
+ * @param context is either a node or a list of nodes on which to evalute the
+ * XPath
+ * @return the numeric result of the XPath expression or null if the result
+ * is not a number.
+ */
+ Number numberValueOf(Object context);
- /**
- * Retrieve a boolean-value interpretation of this XPath expression when
- * evaluated against a given context.
- *
- *
- * The boolean-value of the expression is determined per the
- * boolean(..) core function as defined in the XPath
- * specification. This means that an expression that selects zero nodes will
- * return false, while an expression that selects
- * one-or-more nodes will return true.
- *
- *
- * @param context
- * The node, nodeset or Context object for evaluation. This value
- * can be null
- *
- * @return The boolean-value interpretation of this expression.
- *
- * @since 1.5
- */
- boolean booleanValueOf(Object context);
+ /**
+ * Retrieve a boolean-value interpretation of this XPath expression when
+ * evaluated against a given context.
+ *
+ * The boolean-value of the expression is determined per the
+ * boolean(..) core function as defined in the XPath
+ * specification. This means that an expression that selects zero nodes will
+ * return false, while an expression that selects
+ * one-or-more nodes will return true.
+ *
+ * @param context The node, nodeset or Context object for evaluation. This value
+ * can be null
+ * @return The boolean-value interpretation of this expression.
+ * @since 1.5
+ */
+ boolean booleanValueOf(Object context);
- /**
- *
- * sort sorts the given List of Nodes using this XPath
- * expression as a {@link java.util.Comparator}.
- *
- *
- * @param list
- * is the list of Nodes to sort
- */
- void sort(List list);
+ /**
+ * sort sorts the given List of Nodes using this XPath
+ * expression as a {@link java.util.Comparator}.
+ *
+ * @param list is the list of Nodes to sort
+ */
+ void sort(List list);
- /**
- *
- * sort sorts the given List of Nodes using this XPath
- * expression as a {@link java.util.Comparator}and optionally removing
- * duplicates.
- *
- *
- * @param list
- * is the list of Nodes to sort
- * @param distinct
- * if true then duplicate values (using the sortXPath for
- * comparisions) will be removed from the List
- */
- void sort(List list, boolean distinct);
+ /**
+ * sort sorts the given List of Nodes using this XPath
+ * expression as a {@link java.util.Comparator}and optionally removing
+ * duplicates.
+ *
+ * @param list is the list of Nodes to sort
+ * @param distinct if true then duplicate values (using the sortXPath for
+ * comparisions) will be removed from the List
+ */
+ void sort(List list, boolean distinct);
- /**
- * DOCUMENT ME!
- *
- * @return the current function context
- */
- FunctionContext getFunctionContext();
+ /**
+ * DOCUMENT ME!
+ *
+ * @return the current function context
+ */
+ FunctionContext getFunctionContext();
- /**
- * Sets the function context to be used when evaluating XPath expressions
- *
- * @param functionContext
- * DOCUMENT ME!
- */
- void setFunctionContext(FunctionContext functionContext);
+ /**
+ * Sets the function context to be used when evaluating XPath expressions
+ *
+ * @param functionContext DOCUMENT ME!
+ */
+ void setFunctionContext(FunctionContext functionContext);
- /**
- * DOCUMENT ME!
- *
- * @return the current namespace context
- */
- NamespaceContext getNamespaceContext();
+ /**
+ * DOCUMENT ME!
+ *
+ * @return the current namespace context
+ */
+ NamespaceContext getNamespaceContext();
- /**
- * Sets the namespace context to be used when evaluating XPath expressions
- *
- * @param namespaceContext
- * DOCUMENT ME!
- */
- void setNamespaceContext(NamespaceContext namespaceContext);
+ /**
+ * Sets the namespace context to be used when evaluating XPath expressions
+ *
+ * @param namespaceContext DOCUMENT ME!
+ */
+ void setNamespaceContext(NamespaceContext namespaceContext);
- /**
- *
- * Sets the current NamespaceContext from a Map where the keys are the
- * String namespace prefixes and the values are the namespace URIs.
- *
- *
- * @param map
- * the map containing the namespace mappings
- */
- void setNamespaceURIs(Map map);
+ /**
+ * Sets the current NamespaceContext from a Map where the keys are the
+ * String namespace prefixes and the values are the namespace URIs.
+ *
+ * For example:
+ *