Author: nandana
Date: Wed Sep 29 17:21:50 2010
New Revision: 1002759
URL: http://svn.apache.org/viewvc?rev=1002759&view=rev
Log:
Applying the patch for WSCOMMONS-556, DOOM Performance improvements. Thanks
Kasun
Modified:
webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/AttrImpl.java
webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/CDATASectionImpl.java
webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/CharacterImpl.java
webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/CommentImpl.java
webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/DOMImplementationImpl.java
webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/DOMUtil.java
webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/DocumentImpl.java
webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/ElementImpl.java
webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/NamedNodeMapImpl.java
webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/NodeImpl.java
webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/TextImpl.java
webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/TextNodeImpl.java
Modified:
webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/AttrImpl.java
URL:
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/AttrImpl.java?rev=1002759&r1=1002758&r2=1002759&view=diff
==============================================================================
---
webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/AttrImpl.java
(original)
+++
webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/AttrImpl.java
Wed Sep 29 17:21:50 2010
@@ -61,6 +61,8 @@ public class AttrImpl extends NodeImpl i
/** Flag used to mark an attribute as per the DOM Level 3 specification */
protected boolean isId;
+ private String prefixSeparater = ":";
+
protected AttrImpl(DocumentImpl ownerDocument, OMFactory factory) {
super(ownerDocument, factory);
}
@@ -107,11 +109,28 @@ public class AttrImpl extends NodeImpl i
/** Returns the name of this attribute. */
public String getNodeName() {
- return (this.namespace != null
+ //String prefix = this.namespace.getPrefix();
+ if (this.namespace != null
+ && !"".equals(this.namespace.getPrefix()) &&
+ !(OMConstants.XMLNS_NS_PREFIX.equals(this.attrName)))
+ {
+ //String nodeName = this.namespace.getPrefix() + ":" +
this.attrName;
+ //return
this.namespace.getPrefix().concat(prefixSeparater).concat(this.attrName);
+ // return nodeName;
+
+ return new StringBuilder(20).append(this.namespace.getPrefix())
+ .append(prefixSeparater)
+ .append(this.attrName).toString();
+
+ } else {
+ return this.attrName;
+ }
+
+ /* return (this.namespace != null
&& !"".equals(this.namespace.getPrefix()) &&
!(OMConstants.XMLNS_NS_PREFIX.equals(this.attrName)))
? this.namespace.getPrefix() + ":" + this.attrName
- : this.attrName;
+ : this.attrName;*/
}
/**
@@ -149,11 +168,24 @@ public class AttrImpl extends NodeImpl i
if ((OMConstants.XMLNS_NS_PREFIX.equals(this.attrName))) {
return this.attrName;
} else if
(OMConstants.XMLNS_NS_URI.equals(this.namespace.getNamespaceURI())) {
- return OMConstants.XMLNS_NS_PREFIX + ":" + this.attrName;
+ //return OMConstants.XMLNS_NS_PREFIX + ":" + this.attrName;
+
+ return new StringBuilder(20)
+ .append(OMConstants.XMLNS_NS_PREFIX)
+ .append(prefixSeparater)
+ .append(this.attrName).toString();
+ // return
OMConstants.XMLNS_NS_PREFIX.concat(prefixSeparater).concat(this.attrName);
} else if (this.namespace.getPrefix().equals("")) {
return this.attrName;
} else {
- return this.namespace.getPrefix() + ":" + this.attrName;
+ //return this.namespace.getPrefix() + ":" + this.attrName;
+
+ return new StringBuilder(20)
+ .append(this.namespace.getPrefix())
+ .append(prefixSeparater)
+ .append(this.attrName).toString();
+
+ //return
this.namespace.getPrefix().concat(prefixSeparater).concat(this.attrName);
}
} else {
return this.attrName;
@@ -355,7 +387,8 @@ public class AttrImpl extends NodeImpl i
*/
public String getLocalName() {
return (this.namespace == null) ? this.attrName : DOMUtil
- .getLocalName(this.attrName);
+ .getNameAndPrefix(this.attrName)[1];
+ // .getLocalName(this.attrName);
}
/**
@@ -364,10 +397,7 @@ public class AttrImpl extends NodeImpl i
* @see org.w3c.dom.Node#getNamespaceURI()
*/
public String getNamespaceURI() {
- if (this.namespace != null) {
- return namespace.getNamespaceURI();
- }
- return null;
+ return (this.namespace != null) ? namespace.getNamespaceURI() : null;
}
/**
Modified:
webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/CDATASectionImpl.java
URL:
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/CDATASectionImpl.java?rev=1002759&r1=1002758&r2=1002759&view=diff
==============================================================================
---
webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/CDATASectionImpl.java
(original)
+++
webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/CDATASectionImpl.java
Wed Sep 29 17:21:50 2010
@@ -46,7 +46,7 @@ public class CDATASectionImpl extends Te
}
public Node cloneNode(boolean deep) {
- CDATASectionImpl textImpl = new
CDATASectionImpl(this.textValue.toString(), this.factory);
+ CDATASectionImpl textImpl = new CDATASectionImpl(this.textValue,
this.factory);
textImpl.setOwnerDocument(this.ownerNode);
return textImpl;
}
Modified:
webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/CharacterImpl.java
URL:
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/CharacterImpl.java?rev=1002759&r1=1002758&r2=1002759&view=diff
==============================================================================
---
webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/CharacterImpl.java
(original)
+++
webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/CharacterImpl.java
Wed Sep 29 17:21:50 2010
@@ -29,7 +29,8 @@ import org.w3c.dom.DOMException;
*/
public abstract class CharacterImpl extends ChildNode implements CharacterData
{
- protected StringBuffer textValue;
+ // protected StringBuffer textValue;
+ protected String textValue;
protected CharacterImpl(OMFactory factory) {
super(factory);
@@ -42,8 +43,7 @@ public abstract class CharacterImpl exte
public CharacterImpl(DocumentImpl ownerNode, String value, OMFactory
factory) {
super(ownerNode, factory);
- this.textValue = (value != null) ? new StringBuffer(value)
- : new StringBuffer("");
+ this.textValue = (value != null) ? value : "";
}
///
@@ -51,7 +51,7 @@ public abstract class CharacterImpl exte
///
public void appendData(String value) throws DOMException {
-
+
if (this.isReadonly()) {
throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR,
DOMMessageFormatter.formatMessage(
@@ -59,7 +59,7 @@ public abstract class CharacterImpl exte
"NO_MODIFICATION_ALLOWED_ERR",
null));
}
- this.textValue.append(value);
+ this.textValue += value;
}
/**
@@ -91,9 +91,11 @@ public abstract class CharacterImpl exte
int end = Math.min(count + offset, length);
if (data == null) {
- this.textValue.delete(offset, end);
+ //this.textValue.delete(offset, end);
+ this.textValue = (new StringBuilder(textValue)).delete(offset,
end).toString();
} else {
- this.textValue.replace(offset, end, data);
+ // this.textValue.replace(offset, end, data);
+ this.textValue = (new
StringBuilder(textValue)).replace(offset, end, data).toString();
}
}
@@ -102,7 +104,7 @@ public abstract class CharacterImpl exte
/** Returns the value of the data. */
public String getData() throws DOMException {
- return (this.textValue != null) ? this.textValue.toString() : "";
+ return (this.textValue != null) ? this.textValue : "";
}
/** Inserts a string at the specified offset. */
@@ -123,14 +125,16 @@ public abstract class CharacterImpl exte
"INDEX_SIZE_ERR", null));
}
- this.textValue.insert(offset, data);
-
+ //this.textValue.insert(offset, data);
+ this.textValue = (new StringBuilder(textValue)).insert(offset,
data).toString();
}
/** Sets the text value of data. */
public void setData(String data) throws DOMException {
if (!this.isReadonly()) {
- this.textValue.replace(0, this.getLength(), data);
+ //this.textValue.replace(0, this.getLength(), data);
+ //this.textValue = (new StringBuilder(textValue)).replace(0,
this.getLength(), data).toString();
+ this.textValue = data;
} else {
throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR,
DOMMessageFormatter.formatMessage(
Modified:
webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/CommentImpl.java
URL:
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/CommentImpl.java?rev=1002759&r1=1002758&r2=1002759&view=diff
==============================================================================
---
webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/CommentImpl.java
(original)
+++
webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/CommentImpl.java
Wed Sep 29 17:21:50 2010
@@ -54,8 +54,8 @@ public class CommentImpl extends Charact
}
public void setValue(String text) {
- this.textValue.delete(0, this.textValue.length());
- this.textValue.append(text);
+ //this.textValue.delete(0, this.textValue.length());
+ this.textValue = text;
}
public int getType() {
@@ -68,6 +68,6 @@ public class CommentImpl extends Charact
}
public void internalSerialize(XMLStreamWriter writer, boolean cache)
throws XMLStreamException {
- writer.writeComment(this.textValue.toString());
+ writer.writeComment(this.textValue);
}
}
Modified:
webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/DOMImplementationImpl.java
URL:
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/DOMImplementationImpl.java?rev=1002759&r1=1002758&r2=1002759&view=diff
==============================================================================
---
webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/DOMImplementationImpl.java
(original)
+++
webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/DOMImplementationImpl.java
Wed Sep 29 17:21:50 2010
@@ -41,9 +41,10 @@ public class DOMImplementationImpl imple
DocumentImpl doc = new DocumentImpl(fac);
fac.setDocument(doc);
- new ElementImpl(doc, DOMUtil.getLocalName(qualifiedName),
- new NamespaceImpl(namespaceURI, DOMUtil
- .getPrefix(qualifiedName)), fac);
+ String[] nameAndPrefix = DOMUtil.getNameAndPrefix(qualifiedName);
+
+ new ElementImpl(doc, nameAndPrefix[1],
+ new NamespaceImpl(namespaceURI, nameAndPrefix[0]),
fac);
return doc;
}
Modified:
webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/DOMUtil.java
URL:
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/DOMUtil.java?rev=1002759&r1=1002758&r2=1002759&view=diff
==============================================================================
---
webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/DOMUtil.java
(original)
+++
webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/DOMUtil.java
Wed Sep 29 17:21:50 2010
@@ -19,9 +19,14 @@
package org.apache.axiom.om.impl.dom;
-/** Utility class for the OM-DOM implementation */
+/**
+ * Utility class for the OM-DOM implementation
+ */
class DOMUtil {
+ private static String separator = ":";
+
+
public static boolean isQualifiedName(String value) {
// TODO check for valid characters
// throw new UnsupportedOperationException("TODO");
@@ -29,9 +34,9 @@ class DOMUtil {
}
/**
- * @deprecated please use isQualifiedName
* @param value
* @return
+ * @deprecated please use isQualifiedName
*/
public static boolean isValidChras(String value) {
// TODO check for valid characters
@@ -55,29 +60,56 @@ class DOMUtil {
}
/**
+ * Substitute method for getLocalName and getPrefix
+ *
+ * @param qualifiedName
+ * @return qualified name split in to Prefix and localName
+ * stringArray[0] is the prefix
+ * stringArray[1] is the localName
+ */
+ public static String[] getNameAndPrefix(String qualifiedName) {
+ if (qualifiedName.indexOf(DOMUtil.separator) > -1) {
+ if (!qualifiedName.trim().endsWith(DOMUtil.separator))
+ return qualifiedName.split(DOMUtil.separator);
+ else {
+ String[] container = new String[2];
+ container[0] = null;
+ container[1] = qualifiedName;
+ return container;
+
+ }
+ } else {
+ String[] container = new String[2];
+ container[0] = null;
+ container[1] = qualifiedName;
+ return container;
+ }
+ }
+
+ /**
* Get the local name from a qualified name
*
* @param qualifiedName
*/
- public static String getLocalName(String qualifiedName) {
- if (qualifiedName.indexOf(":") > -1
- && !qualifiedName.trim().endsWith(":")) {
- return qualifiedName.split(":")[1];
+ /*public static String getLocalName(String qualifiedName) {
+ if (qualifiedName.indexOf(DOMUtil.separator) > -1
+ && !qualifiedName.trim().endsWith(DOMUtil.separator)) {
+ return qualifiedName.split(DOMUtil.separator)[1];
} else {
return qualifiedName;
}
}
- /**
+ *//**
* Get the prefix from a qualified name
*
* @param qualifiedName
- */
+ *//*
public static String getPrefix(String qualifiedName) {
- if (qualifiedName.indexOf(":") > -1) {
- return qualifiedName.split(":")[0];
+ if (qualifiedName.indexOf(DOMUtil.separator) > -1) {
+ return qualifiedName.split(DOMUtil.separator)[0];
} else {
return null;
}
- }
+ }*/
}
Modified:
webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/DocumentImpl.java
URL:
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/DocumentImpl.java?rev=1002759&r1=1002758&r2=1002759&view=diff
==============================================================================
---
webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/DocumentImpl.java
(original)
+++
webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/DocumentImpl.java
Wed Sep 29 17:21:50 2010
@@ -167,8 +167,9 @@ public class DocumentImpl extends Parent
public Attr createAttributeNS(String namespaceURI, String qualifiedName)
throws DOMException {
- String localName = DOMUtil.getLocalName(qualifiedName);
- String prefix = DOMUtil.getPrefix(qualifiedName);
+ String[] nameAndPrefix = DOMUtil.getNameAndPrefix(qualifiedName);
+ String localName = nameAndPrefix[1];
+ String prefix = nameAndPrefix[0];
if (!OMConstants.XMLNS_NS_PREFIX.equals(localName)) {
this.checkQName(prefix, localName);
@@ -202,8 +203,10 @@ public class DocumentImpl extends Parent
if (ns == null) ns = "";
- String localName = DOMUtil.getLocalName(qualifiedName);
- String prefix = DOMUtil.getPrefix(qualifiedName);
+ String[] nameAndPrefix = DOMUtil.getNameAndPrefix(qualifiedName);
+ String localName = nameAndPrefix[1];
+ String prefix = nameAndPrefix[0];
+
if(prefix == null) {
prefix = "";
}
Modified:
webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/ElementImpl.java
URL:
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/ElementImpl.java?rev=1002759&r1=1002758&r2=1002759&view=diff
==============================================================================
---
webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/ElementImpl.java
(original)
+++
webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/ElementImpl.java
Wed Sep 29 17:21:50 2010
@@ -55,6 +55,7 @@ import java.io.ByteArrayOutputStream;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
+import java.util.Vector;
/** Implementation of the org.w3c.dom.Element and org.apache.axiom.om.Element
interfaces. */
public class ElementImpl extends ParentNode implements Element, OMElement,
@@ -72,7 +73,20 @@ public class ElementImpl extends ParentN
private static final EmptyIterator EMPTY_ITERATOR = new EmptyIterator();
- /** @param ownerDocument */
+ private String prefixSeparater = ":";
+
+ private static final String INVALID_CHARACTER_ERR =
"INVALID_CHARACTER_ERR";
+ private static final String NO_MODIFICATION_ALLOWED_ERR =
"NO_MODIFICATION_ALLOWED_ERR";
+ private static final String NAMESPACE_ERR = "NAMESPACE_ERR";
+ private static final String NOT_FOUND_ERR = "NOT_FOUND_ERR";
+ private static final String WRONG_DOCUMENT_ERR = "WRONG_DOCUMENT_ERR";
+ private static final String INUSE_ATTRIBUTE_ERR = "INUSE_ATTRIBUTE_ERR";
+
+ /** @param ownerDocument ownerDocument
+ * @param tagName tagName
+ * @param factory OMFactory
+ *
+ * */
public ElementImpl(DocumentImpl ownerDocument, String tagName,
OMFactory factory) {
super(ownerDocument, factory);
@@ -87,6 +101,7 @@ public class ElementImpl extends ParentN
* @param ownerDocument
* @param tagName
* @param ns
+ * @param factory
*/
public ElementImpl(DocumentImpl ownerDocument, String tagName,
NamespaceImpl ns, OMFactory factory) {
@@ -160,14 +175,16 @@ public class ElementImpl extends ParentN
* (non-Javadoc)
*
* @see org.w3c.dom.Node#getNodeName()
- */
+ */
public String getNodeName() {
if (this.namespace != null) {
if (this.namespace.getPrefix() == null
|| "".equals(this.namespace.getPrefix())) {
return this.localName;
- } else {
- return this.namespace.getPrefix() + ":" + this.localName;
+ } else {
+ return new StringBuilder(20).append(this.namespace.getPrefix())
+ .append(prefixSeparater)
+ .append(this.localName).toString();
}
} else {
return this.localName;
@@ -232,13 +249,13 @@ public class ElementImpl extends ParentN
if (this.isReadonly()) {
String msg = DOMMessageFormatter.formatMessage(
DOMMessageFormatter.DOM_DOMAIN,
- "NO_MODIFICATION_ALLOWED_ERR", null);
+ ElementImpl.NO_MODIFICATION_ALLOWED_ERR, null);
throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR,
msg);
}
if (name.startsWith(OMConstants.XMLNS_NS_PREFIX)) {
- String namespacePrefix = DOMUtil.getLocalName(name);
+ String namespacePrefix = DOMUtil.getNameAndPrefix(name)[1];
if (this.findNamespaceURI(namespacePrefix) != null) {
this.removeNamespace(namespacePrefix);
}
@@ -260,7 +277,7 @@ public class ElementImpl extends ParentN
if (this.isReadonly()) {
String msg = DOMMessageFormatter.formatMessage(
DOMMessageFormatter.DOM_DOMAIN,
- "NO_MODIFICATION_ALLOWED_ERR", null);
+ ElementImpl.NO_MODIFICATION_ALLOWED_ERR, null);
throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR,
msg);
}
@@ -268,7 +285,7 @@ public class ElementImpl extends ParentN
if (OMConstants.XMLNS_NS_URI.equals(namespaceURI)) {
//look in the ns list
if (this.namespaces != null) {
- this.namespaces.remove(DOMUtil.getLocalName(localName));
+ this.namespaces.remove(DOMUtil.getNameAndPrefix(localName)[1]);
}
} else if (this.attributes != null) {
@@ -285,14 +302,14 @@ public class ElementImpl extends ParentN
if (isReadonly()) {
String msg = DOMMessageFormatter.formatMessage(
DOMMessageFormatter.DOM_DOMAIN,
- "NO_MODIFICATION_ALLOWED_ERR", null);
+ ElementImpl.NO_MODIFICATION_ALLOWED_ERR, null);
throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR,
msg);
}
if (this.attributes == null
|| this.attributes.getNamedItem(oldAttr.getName()) == null) {
String msg = DOMMessageFormatter.formatMessage(
- DOMMessageFormatter.DOM_DOMAIN, "NOT_FOUND_ERR", null);
+ DOMMessageFormatter.DOM_DOMAIN, ElementImpl.NOT_FOUND_ERR,
null);
throw new DOMException(DOMException.NOT_FOUND_ERR, msg);
}
return (AttrImpl) this.attributes.removeNamedItem(oldAttr
@@ -389,7 +406,7 @@ public class ElementImpl extends ParentN
if (attrImpl.isOwned()) {// check for ownership
if (!this.getOwnerDocument().equals(attr.getOwnerDocument())) {
String msg = DOMMessageFormatter.formatMessage(
- DOMMessageFormatter.DOM_DOMAIN, "WRONG_DOCUMENT_ERR",
+ DOMMessageFormatter.DOM_DOMAIN,
ElementImpl.WRONG_DOCUMENT_ERR,
null);
throw new DOMException(DOMException.WRONG_DOCUMENT_ERR, msg);
}
@@ -398,7 +415,7 @@ public class ElementImpl extends ParentN
if (this.isReadonly()) {
String msg = DOMMessageFormatter.formatMessage(
DOMMessageFormatter.DOM_DOMAIN,
- "NO_MODIFICATION_ALLOWED_ERR", null);
+ ElementImpl.NO_MODIFICATION_ALLOWED_ERR, null);
throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR,
msg);
}
@@ -407,14 +424,14 @@ public class ElementImpl extends ParentN
if (attrImpl.isUsed()) {
String msg = DOMMessageFormatter
.formatMessage(DOMMessageFormatter.DOM_DOMAIN,
- "INUSE_ATTRIBUTE_ERR", null);
+ ElementImpl.INUSE_ATTRIBUTE_ERR, null);
throw new DOMException(DOMException.INUSE_ATTRIBUTE_ERR, msg);
}
if (attr.getNodeName().startsWith(OMConstants.XMLNS_NS_PREFIX + ":")) {
// This is a ns declaration
this.declareNamespace(attr.getNodeValue(), DOMUtil
- .getLocalName(attr.getName()));
+ .getNameAndPrefix(attr.getName())[1]);
//Don't add this to attr list, since its a namespace
return attr;
@@ -447,7 +464,7 @@ public class ElementImpl extends ParentN
}
if (name.startsWith(OMConstants.XMLNS_NS_PREFIX + ":")) {
// This is a ns declaration
- this.declareNamespace(value, DOMUtil.getLocalName(name));
+ this.declareNamespace(value, DOMUtil.getNameAndPrefix(name)[1]);
} else if (name.equals(OMConstants.XMLNS_NS_PREFIX)) {
this.declareDefaultNamespace(value);
} else {
@@ -477,7 +494,7 @@ public class ElementImpl extends ParentN
if (!this.getOwnerDocument().equals(attr.getOwnerDocument())) {
String msg = DOMMessageFormatter.formatMessage(
DOMMessageFormatter.DOM_DOMAIN,
- "WRONG_DOCUMENT_ERR", null);
+ ElementImpl.WRONG_DOCUMENT_ERR, null);
throw new DOMException(DOMException.WRONG_DOCUMENT_ERR,
msg);
}
}
@@ -485,7 +502,7 @@ public class ElementImpl extends ParentN
if (this.isReadonly()) {
String msg = DOMMessageFormatter.formatMessage(
DOMMessageFormatter.DOM_DOMAIN,
- "NO_MODIFICATION_ALLOWED_ERR", null);
+ ElementImpl.NO_MODIFICATION_ALLOWED_ERR, null);
throw new DOMException(
DOMException.NO_MODIFICATION_ALLOWED_ERR, msg);
}
@@ -523,16 +540,14 @@ public class ElementImpl extends ParentN
*/
public void setAttributeNS(String namespaceURI, String qualifiedName,
String value) throws DOMException {
+ String[] nameAndPrefix = DOMUtil.getNameAndPrefix(qualifiedName);
if (namespaceURI != null && !"".equals(namespaceURI)) {
if (namespaceURI.equals(OMConstants.XMLNS_NS_URI)) {
- this.declareNamespace(value, DOMUtil
- .getLocalName(qualifiedName));
+ this.declareNamespace(value, nameAndPrefix[1]);
} else {
- AttrImpl attr = new AttrImpl(this.ownerNode, DOMUtil
- .getLocalName(qualifiedName), value, this.factory);
- attr.setOMNamespace(new NamespaceImpl(namespaceURI, DOMUtil
- .getPrefix(qualifiedName)));
+ AttrImpl attr = new AttrImpl(this.ownerNode, nameAndPrefix[1],
value, this.factory);
+ attr.setOMNamespace(new NamespaceImpl(namespaceURI,
nameAndPrefix[0]));
this.setAttributeNodeNS(attr);
}
@@ -540,7 +555,7 @@ public class ElementImpl extends ParentN
// When the namespace is null, the attr name given better not be
// a qualified name
// But anyway check and set it
- this.setAttribute(DOMUtil.getLocalName(qualifiedName), value);
+ this.setAttribute(nameAndPrefix[1], value);
}
}
@@ -549,7 +564,7 @@ public class ElementImpl extends ParentN
String value) throws DOMException {
if (!DOMUtil.isQualifiedName(qualifiedName)) {
String msg = DOMMessageFormatter.formatMessage(
- DOMMessageFormatter.DOM_DOMAIN, "INVALID_CHARACTER_ERR",
+ DOMMessageFormatter.DOM_DOMAIN,
ElementImpl.INVALID_CHARACTER_ERR ,
null);
throw new DOMException(DOMException.INVALID_CHARACTER_ERR, msg);
}
@@ -557,7 +572,7 @@ public class ElementImpl extends ParentN
if (this.isReadonly()) {
String msg = DOMMessageFormatter.formatMessage(
DOMMessageFormatter.DOM_DOMAIN,
- "NO_MODIFICATION_ALLOWED_ERR", null);
+ ElementImpl.NO_MODIFICATION_ALLOWED_ERR, null);
throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR,
msg);
}
@@ -568,26 +583,25 @@ public class ElementImpl extends ParentN
if (namespaceURI != null) {
if (!DOMUtil.isValidNamespace(namespaceURI, qualifiedName)) {
String msg = DOMMessageFormatter.formatMessage(
- DOMMessageFormatter.DOM_DOMAIN, "NAMESPACE_ERR", null);
+ DOMMessageFormatter.DOM_DOMAIN,
ElementImpl.NAMESPACE_ERR, null);
throw new DOMException(DOMException.NAMESPACE_ERR, msg);
}
// Check whether there's an existing Attr with same local name and
// namespace URI
- Attr attributeNode = this.getAttributeNodeNS(namespaceURI, DOMUtil
- .getLocalName(qualifiedName));
+ String[] nameAndPrefix = DOMUtil.getNameAndPrefix(qualifiedName);
+ Attr attributeNode = this.getAttributeNodeNS(namespaceURI,
nameAndPrefix[1]);
+// Attr attributeNode = this.getAttributeNodeNS(namespaceURI,
DOMUtil
+// .getLocalName(qualifiedName));
if (attributeNode != null) {
AttrImpl tempAttr = ((AttrImpl) attributeNode);
- tempAttr.setOMNamespace(new NamespaceImpl(namespaceURI, DOMUtil
- .getPrefix(qualifiedName)));
+ tempAttr.setOMNamespace(new NamespaceImpl(namespaceURI,
nameAndPrefix[0]));
tempAttr.setAttributeValue(value);
this.attributes.setNamedItem(tempAttr);
return tempAttr;
} else {
- NamespaceImpl ns = new NamespaceImpl(namespaceURI, DOMUtil
- .getPrefix(qualifiedName));
+ NamespaceImpl ns = new NamespaceImpl(namespaceURI,
nameAndPrefix[0]);
AttrImpl attr = new AttrImpl((DocumentImpl) this
- .getOwnerDocument(), DOMUtil
- .getLocalName(qualifiedName), ns, value, this.factory);
+ .getOwnerDocument(), nameAndPrefix[1], ns, value,
this.factory);
this.attributes.setNamedItem(attr);
return attr;
}
@@ -1055,7 +1069,7 @@ public class ElementImpl extends ParentN
if (this.isReadonly()) {
String msg = DOMMessageFormatter.formatMessage(
DOMMessageFormatter.DOM_DOMAIN,
- "NO_MODIFICATION_ALLOWED_ERR", null);
+ ElementImpl.NO_MODIFICATION_ALLOWED_ERR, null);
throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR,
msg);
}
@@ -1369,7 +1383,7 @@ public class ElementImpl extends ParentN
if (this.isReadonly()) {
String msg = DOMMessageFormatter.formatMessage(
DOMMessageFormatter.DOM_DOMAIN,
- "NO_MODIFICATION_ALLOWED_ERR", null);
+ ElementImpl.NO_MODIFICATION_ALLOWED_ERR, null);
throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR,
msg);
}
@@ -1378,7 +1392,7 @@ public class ElementImpl extends ParentN
if (tempAttr == null) {
String msg = DOMMessageFormatter.formatMessage(
DOMMessageFormatter.DOM_DOMAIN,
- "NOT_FOUND_ERR", null);
+ ElementImpl.NOT_FOUND_ERR, null);
throw new DOMException(DOMException.NOT_FOUND_ERR,
msg);
}
@@ -1391,7 +1405,7 @@ public class ElementImpl extends ParentN
if (this.isReadonly()) {
String msg = DOMMessageFormatter.formatMessage(
DOMMessageFormatter.DOM_DOMAIN,
- "NO_MODIFICATION_ALLOWED_ERR", null);
+ ElementImpl.NO_MODIFICATION_ALLOWED_ERR, null);
throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR,
msg);
}
@@ -1400,7 +1414,7 @@ public class ElementImpl extends ParentN
if (tempAttr == null) {
String msg = DOMMessageFormatter.formatMessage(
DOMMessageFormatter.DOM_DOMAIN,
- "NOT_FOUND_ERR", null);
+ ElementImpl.NOT_FOUND_ERR, null);
throw new DOMException(DOMException.NOT_FOUND_ERR,
msg);
}
@@ -1412,7 +1426,7 @@ public class ElementImpl extends ParentN
if (this.isReadonly()) {
String msg = DOMMessageFormatter.formatMessage(
DOMMessageFormatter.DOM_DOMAIN,
- "NO_MODIFICATION_ALLOWED_ERR", null);
+ ElementImpl.NO_MODIFICATION_ALLOWED_ERR, null);
throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR,
msg);
}
@@ -1430,7 +1444,7 @@ public class ElementImpl extends ParentN
if (tempAttr == null) {
String msg = DOMMessageFormatter.formatMessage(
DOMMessageFormatter.DOM_DOMAIN,
- "NOT_FOUND_ERR", null);
+ ElementImpl.NOT_FOUND_ERR, null);
throw new DOMException(DOMException.NOT_FOUND_ERR,
msg);
}
Modified:
webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/NamedNodeMapImpl.java
URL:
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/NamedNodeMapImpl.java?rev=1002759&r1=1002758&r2=1002759&view=diff
==============================================================================
---
webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/NamedNodeMapImpl.java
(original)
+++
webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/NamedNodeMapImpl.java
Wed Sep 29 17:21:50 2010
@@ -43,7 +43,7 @@ public class NamedNodeMapImpl implements
protected final static short CHANGED = 0x1 << 1;
protected final static short HASDEFAULTS = 0x1 << 2;
-
+
protected NamedNodeMapImpl(ParentNode ownerNode) {
this.ownerNode = ownerNode;
}
@@ -177,7 +177,7 @@ public class NamedNodeMapImpl implements
* @param name The local name of the node to remove.
* @return Returns the node removed from the map if a node with such a
local name and namespace
* URI exists.
- * @throws NOT_FOUND_ERR: Raised if there is no node named name in the map.
+ * @throws DOMException: Raised if there is no node named name in the map.
*/
public Node removeNamedItemNS(String namespaceURI, String name)
throws DOMException {
@@ -331,7 +331,7 @@ public class NamedNodeMapImpl implements
// so we must linear search thru it.
// In addition, to get this to work with nodes without any namespace
// (namespaceURI and localNames are both null) we then use the nodeName
- // as a seconday key.
+ // as a secondary key.
for (int i = 0; i < nodes.size(); i++) {
NodeImpl a = (NodeImpl) nodes.elementAt(i);
String aNamespaceURI = a.getNamespaceURI();
Modified:
webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/NodeImpl.java
URL:
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/NodeImpl.java?rev=1002759&r1=1002758&r2=1002759&view=diff
==============================================================================
---
webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/NodeImpl.java
(original)
+++
webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/NodeImpl.java
Wed Sep 29 17:21:50 2010
@@ -41,12 +41,11 @@ import javax.xml.stream.XMLStreamWriter;
import java.io.OutputStream;
import java.io.Writer;
import java.util.Hashtable;
-import java.util.Map;
public abstract class NodeImpl implements Node, NodeList, OMNodeEx, Cloneable {
/** Holds the user data objects */
- private Map userData = new Hashtable();
+ private Hashtable userData; // Will be initialized in setUserData()
/** Field builder */
public OMXMLParserWrapper builder;
@@ -78,7 +77,8 @@ public abstract class NodeImpl implement
//
protected NodeImpl(DocumentImpl ownerDocument, OMFactory factory) {
- this(factory);
+ //this(factory);
+ this.factory = factory;
this.ownerNode = ownerDocument;
// this.isOwned(true);
@@ -541,11 +541,7 @@ public abstract class NodeImpl implement
public boolean isSameNode(Node node) {
// TODO : check
- if (this == node) {
- return true;
- } else {
- return false;
- }
+ return this == node;
}
public String lookupPrefix(String arg0) {
@@ -729,8 +725,7 @@ public abstract class NodeImpl implement
//i.e. no corresponding node
return notEqual;
} else {
- NodeImpl node1 = thisNode;
- if (!(node1.isEqualNode(tmpNode))) {
+ if (!(thisNode.isEqualNode(tmpNode))) {
return notEqual;
}
}
@@ -746,12 +741,52 @@ public abstract class NodeImpl implement
throw new UnsupportedOperationException("TODO");
}
+ /* public Object setUserData(String key, Object value, UserDataHandler
userDataHandler) {
+ return userData.put(key, value);
+ }
+
+ public Object getUserData(String key) {
+ return userData.get(key);
+ } */
+
+ /* *
+ * userData storage/hashtable will be called only when the user needs to
set user data. Previously, it was done as,
+ * for every node a new Hashtable created making the excution very
inefficient. According to profiles, no. of method
+ * invocations to setUserData() method is very low, so this implementation
is better.
+ * Another option:
+ * TODO do a profile and check the times for hashtable initialization. If
it's still higher, we have to go to second option
+ * Create a separate class(UserData) to store key and value pairs. Then
put those objects to a array with a reasonable size.
+ * then grow it accordingly. @ Kasun Gajasinghe
+ * @param key userData key
+ * @param value userData value
+ * @param userDataHandler it seems all invocations sends null for this
parameter.
+ * Kept it for the moment just for being on the safe side.
+ * @return previous Object if one is set before.
+ */
+
public Object setUserData(String key, Object value, UserDataHandler
userDataHandler) {
+ if (userData == null) {
+ userData = new Hashtable();
+ }
return userData.put(key, value);
}
public Object getUserData(String key) {
- return userData.get(key);
+ if (userData != null) {
+ return userData.get(key);
+ }
+ return null;
+ }
+
+ public Document getParentOwnerDocument() {
+ // if we have an owner simply forward the request
+ // otherwise ownerNode is our ownerDocument
+ if (isOwned()) {
+ return ownerNode.getParentOwnerDocument();
+ } else {
+ return ownerNode;
+ }
+
}
public void serialize(OutputStream output) throws XMLStreamException {
Modified:
webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/TextImpl.java
URL:
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/TextImpl.java?rev=1002759&r1=1002758&r2=1002759&view=diff
==============================================================================
---
webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/TextImpl.java
(original)
+++
webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/TextImpl.java
Wed Sep 29 17:21:50 2010
@@ -111,7 +111,7 @@ public class TextImpl extends TextNodeIm
}
public Node cloneNode(boolean deep) {
- TextImpl textImpl = new TextImpl(this.textValue.toString(),
this.factory);
+ TextImpl textImpl = new TextImpl(this.textValue, this.factory);
textImpl.setOwnerDocument(this.ownerNode);
return textImpl;
}
Modified:
webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/TextNodeImpl.java
URL:
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/TextNodeImpl.java?rev=1002759&r1=1002758&r2=1002759&view=diff
==============================================================================
---
webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/TextNodeImpl.java
(original)
+++
webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/TextNodeImpl.java
Wed Sep 29 17:21:50 2010
@@ -63,10 +63,14 @@ public abstract class TextNodeImpl exten
*/
private Object dataHandlerObject = null;
- /** Field nameSpace is used when serializing Binary stuff as MTOM
optimized. */
+ /**
+ * Field nameSpace is used when serializing Binary stuff as MTOM optimized.
+ */
protected OMNamespace ns = null;
- /** Field nameSpace used when serializing Binary stuff as MTOM optimized.
*/
+ /**
+ * Field nameSpace used when serializing Binary stuff as MTOM optimized.
+ */
public static final OMNamespace XOP_NS = new OMNamespaceImpl(
"http://www.w3.org/2004/08/xop/include", "xop");
@@ -78,8 +82,9 @@ public abstract class TextNodeImpl exten
*/
public TextNodeImpl(String text, OMFactory factory) {
super(factory);
- this.textValue = (text != null) ? new StringBuffer(text)
- : new StringBuffer("");
+ //this.textValue = (text != null) ? new StringBuffer(text)
+ // : new StringBuffer("");
+ this.textValue = (text != null) ? text : "";
this.done = true;
this.ns = XOP_NS;
}
@@ -92,7 +97,7 @@ public abstract class TextNodeImpl exten
* MIME messages
*/
public TextNodeImpl(String contentID, OMContainer parent,
- OMXMLParserWrapper builder, OMFactory factory) {
+ OMXMLParserWrapper builder, OMFactory factory) {
super((DocumentImpl) ((ParentNode) parent).getOwnerDocument(),
factory);
this.contentID = contentID;
this.optimize = true;
@@ -101,59 +106,59 @@ public abstract class TextNodeImpl exten
this.builder = builder;
this.ns = XOP_NS;
}
-
+
/**
* Construct TextImpl that is a copy of the source OMTextImpl
+ *
* @param parent
- * @param source TextImpl
+ * @param source TextImpl
* @param factory
*/
public TextNodeImpl(OMContainer parent, TextNodeImpl source, OMFactory
factory) {
super((DocumentImpl) ((ParentNode) parent).getOwnerDocument(),
factory);
this.done = true;
-
+
// Copy the value of the text
if (source.textValue != null) {
- this.textValue = new StringBuffer();
- this.textValue.append(source.textValue.toString());
+ this.textValue = source.textValue;
}
-
+
// Clone the charArray (if it exists)
if (source.charArray != null) {
this.charArray = new char[source.charArray.length];
- for (int i=0; i<source.charArray.length; i++) {
+ for (int i = 0; i < source.charArray.length; i++) {
this.charArray[i] = source.charArray[i];
}
}
-
-
+
+
// Turn off textNS...the namespace will need to be recalculated
// in the new tree's context.
this.textNS = null;
-
+
// Copy the optimized related settings.
this.optimize = source.optimize;
this.mimeType = source.mimeType;
this.isBinary = source.isBinary;
-
+
// TODO
// Do we need a deep copy of the data-handler
this.contentID = source.contentID;
this.dataHandlerObject = source.dataHandlerObject;
-
+
if (source.ns != null) {
- this.ns = new OMNamespaceImpl(source.ns.getNamespaceURI(),
- source.ns.getPrefix());
+ this.ns = new OMNamespaceImpl(source.ns.getNamespaceURI(),
+ source.ns.getPrefix());
}
}
public TextNodeImpl(String text, String mimeType, boolean optimize,
- OMFactory factory) {
+ OMFactory factory) {
this(text, mimeType, optimize, true, factory);
}
public TextNodeImpl(String text, String mimeType, boolean optimize,
- boolean isBinary, OMFactory factory) {
+ boolean isBinary, OMFactory factory) {
this(text, factory);
this.mimeType = mimeType;
this.optimize = optimize;
@@ -165,7 +170,7 @@ public abstract class TextNodeImpl exten
* @param optimize To send binary content. Created progrmatically.
*/
public TextNodeImpl(DocumentImpl ownerNode, Object dataHandler, boolean
optimize,
- OMFactory factory) {
+ OMFactory factory) {
super(ownerNode, factory);
this.dataHandlerObject = dataHandler;
this.isBinary = true;
@@ -176,7 +181,7 @@ public abstract class TextNodeImpl exten
/**
* Constructor.
- *
+ *
* @param contentID
* @param dataHandlerProvider
* @param optimize
@@ -192,7 +197,9 @@ public abstract class TextNodeImpl exten
done = true;
}
- /** @param ownerNode */
+ /**
+ * @param ownerNode
+ */
public TextNodeImpl(DocumentImpl ownerNode, OMFactory factory) {
super(ownerNode, factory);
this.done = true;
@@ -222,7 +229,7 @@ public abstract class TextNodeImpl exten
* @param value
*/
public TextNodeImpl(DocumentImpl ownerNode, String value, String mimeType,
- boolean optimize, OMFactory factory) {
+ boolean optimize, OMFactory factory) {
this(ownerNode, value, factory);
this.mimeType = mimeType;
this.optimize = optimize;
@@ -236,7 +243,7 @@ public abstract class TextNodeImpl exten
}
public TextNodeImpl(OMContainer parent, QName text, int nodeType,
- OMFactory factory) {
+ OMFactory factory) {
this(((ElementImpl) parent).ownerNode, factory);
if (text != null) {
this.textNS =
@@ -244,7 +251,7 @@ public abstract class TextNodeImpl exten
} else {
}
- this.textValue = new StringBuffer((text == null) ? "" :
text.getLocalPart());
+ this.textValue = (text == null) ? "" : text.getLocalPart();
this.done = true;
}
@@ -259,15 +266,15 @@ public abstract class TextNodeImpl exten
public Text splitText(int offset) throws DOMException {
if (this.isReadonly()) {
throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR,
- DOMMessageFormatter.formatMessage(
- DOMMessageFormatter.DOM_DOMAIN,
- "NO_MODIFICATION_ALLOWED_ERR",
null));
+ DOMMessageFormatter.formatMessage(
+ DOMMessageFormatter.DOM_DOMAIN,
+ "NO_MODIFICATION_ALLOWED_ERR", null));
}
if (offset < 0 || offset > this.textValue.length()) {
throw new DOMException(DOMException.INDEX_SIZE_ERR,
- DOMMessageFormatter.formatMessage(
- DOMMessageFormatter.DOM_DOMAIN,
"INDEX_SIZE_ERR",
- null));
+ DOMMessageFormatter.formatMessage(
+ DOMMessageFormatter.DOM_DOMAIN, "INDEX_SIZE_ERR",
+ null));
}
String newValue = this.textValue.substring(offset);
this.deleteData(offset, this.textValue.length());
@@ -287,6 +294,7 @@ public abstract class TextNodeImpl exten
// /
// /org.w3c.dom.Node methods
// /
+
public String getNodeName() {
return "#text";
}
@@ -340,7 +348,7 @@ public abstract class TextNodeImpl exten
return getTextFromProperPlace();
} else {
try {
- return Base64Utils.encode((DataHandler)getDataHandler());
+ return Base64Utils.encode((DataHandler) getDataHandler());
} catch (Exception e) {
throw new OMException(e);
}
@@ -350,10 +358,9 @@ public abstract class TextNodeImpl exten
public String getData() throws DOMException {
return this.getText();
}
-
+
public char[] getTextCharacters() {
- return charArray != null ? charArray : this.textValue.toString()
- .toCharArray();
+ return charArray != null ? charArray : this.textValue.toCharArray();
}
public boolean isCharacters() {
@@ -361,7 +368,7 @@ public abstract class TextNodeImpl exten
}
private String getTextFromProperPlace() {
- return charArray != null ? new String(charArray) :
textValue.toString();
+ return charArray != null ? new String(charArray) : textValue;
}
private String getTextString() {
@@ -391,7 +398,7 @@ public abstract class TextNodeImpl exten
} else {
try {
// TODO: do we really want to build a QName from base64
encoded data?!?
- return new
QName(Base64Utils.encode((DataHandler)getDataHandler()));
+ return new QName(Base64Utils.encode((DataHandler)
getDataHandler()));
} catch (Exception e) {
throw new OMException(e);
}
@@ -428,7 +435,7 @@ public abstract class TextNodeImpl exten
.getDataHandler(contentID);
} else if (dataHandlerObject instanceof DataHandlerProvider) {
try {
- dataHandlerObject =
((DataHandlerProvider)dataHandlerObject).getDataHandler();
+ dataHandlerObject = ((DataHandlerProvider)
dataHandlerObject).getDataHandler();
} catch (IOException ex) {
throw new OMException(ex);
}
@@ -463,7 +470,7 @@ public abstract class TextNodeImpl exten
writeOutput(writer);
} else {
try {
- XMLStreamWriterUtils.writeDataHandler(writer,
(DataHandler)getDataHandler(),
+ XMLStreamWriterUtils.writeDataHandler(writer, (DataHandler)
getDataHandler(),
contentID, optimize);
} catch (IOException ex) {
throw new OMException("Error reading data handler", ex);
@@ -492,12 +499,13 @@ public abstract class TextNodeImpl exten
}
public String toString() {
- return (this.textValue != null) ? textValue.toString() : "";
+ return (this.textValue != null) ? textValue : "";
}
/* (non-Javadoc)
* @see org.apache.axiom.om.OMNode#buildAll()
*/
+
public void buildWithAttachments() {
this.build();
if (isOptimized()) {
@@ -522,7 +530,7 @@ public abstract class TextNodeImpl exten
public OMNamespace getNamespace() {
return textNS;
}
-
+
public void setContentID(String cid) {
this.contentID = cid;
}