You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by ru...@apache.org on 2005/10/06 13:04:13 UTC
svn commit: r306585 [1/2] - in
/webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2:
om/impl/dom/ om/impl/dom/factory/ om/impl/dom/msg/ soap/impl/dom/
soap/impl/dom/factory/
Author: ruchithf
Date: Thu Oct 6 04:03:44 2005
New Revision: 306585
URL: http://svn.apache.org/viewcvs?rev=306585&view=rev
Log:
Initial set of classes for the DOM implementation
Added:
webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/om/impl/dom/
webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/om/impl/dom/AttrImpl.java
webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/om/impl/dom/AttributeMap.java
webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/om/impl/dom/CharacterImpl.java
webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/om/impl/dom/ChildNode.java
webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/om/impl/dom/DOMMessageFormatter.java
webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/om/impl/dom/DOMSerializerUtil.java
webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/om/impl/dom/DocumentFragmentimpl.java
webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/om/impl/dom/DocumentImpl.java
webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/om/impl/dom/ElementImpl.java
webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/om/impl/dom/NamedNodeMapImpl.java
webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/om/impl/dom/NamespaceImpl.java
webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/om/impl/dom/NodeImpl.java
webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/om/impl/dom/NodeListImpl.java
webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/om/impl/dom/ParentNode.java
webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/om/impl/dom/TextImpl.java
webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/om/impl/dom/factory/
webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/om/impl/dom/factory/OMDOMFactory.java
webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/om/impl/dom/msg/
webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/om/impl/dom/msg/DOMMessages.properties
webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/om/impl/dom/msg/XMLMessages.properties
webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/om/impl/dom/msg/XMLSerializerMessages.properties
webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/soap/impl/dom/
webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/soap/impl/dom/factory/
webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/soap/impl/dom/factory/DOMSOAPFactory.java
Added: webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/om/impl/dom/AttrImpl.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/om/impl/dom/AttrImpl.java?rev=306585&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/om/impl/dom/AttrImpl.java (added)
+++ webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/om/impl/dom/AttrImpl.java Thu Oct 6 04:03:44 2005
@@ -0,0 +1,140 @@
+package org.apache.axis2.om.impl.dom;
+
+import org.apache.axis2.om.OMAttribute;
+import org.apache.axis2.om.OMContainer;
+import org.apache.axis2.om.OMException;
+import org.apache.axis2.om.OMNamespace;
+import org.apache.axis2.om.OMNode;
+import org.apache.axis2.om.impl.OMOutputImpl;
+import org.w3c.dom.Attr;
+import org.w3c.dom.DOMException;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamWriter;
+
+/**
+ * @author Ruchith Fernando (ruchith.fernando@gmail.com)
+ */
+public class AttrImpl extends NodeImpl implements OMAttribute, Attr {
+
+ private String attrName;
+ private TextImpl attrValue;
+
+ private boolean specified;
+
+ protected AttrImpl(DocumentImpl ownerDocument) {
+ super(ownerDocument);
+ }
+
+ ///
+ ///org.w3c.dom.Node methods
+ ///
+ public String getNodeName() {
+ return this.attrName.toString();
+ }
+ public short getNodeType() {
+ return Node.ATTRIBUTE_NODE;
+ }
+
+ public String getNodeValue() throws DOMException {
+ return (this.attrName==null)?"":this.attrValue.getData();
+ }
+
+ ///
+ ///org.w3c.dom.Attr methods
+ ///
+ public String getName() {
+ return this.attrName;
+ }
+ public Element getOwnerElement() {
+ //Owned is set to an element instance when the attribute is added to an element
+ return (Element) (isOwned() ? ownerNode : null);
+ }
+
+ public boolean getSpecified() {
+ //TODO
+ throw new UnsupportedOperationException("TODO");
+ }
+
+ public OMNode detach() throws OMException {
+ //TODO
+ throw new UnsupportedOperationException("TODO");
+ }
+
+ public void discard() throws OMException {
+ //TODO
+ throw new UnsupportedOperationException("TODO");
+ }
+
+ public int getType() {
+ //TODO
+ throw new UnsupportedOperationException("TODO");
+ }
+
+ public void serialize(OMOutputImpl omOutput) throws XMLStreamException {
+ //TODO
+ throw new UnsupportedOperationException("TODO");
+ }
+
+ public void serialize(XMLStreamWriter xmlWriter) throws XMLStreamException {
+ //TODO
+ throw new UnsupportedOperationException("TODO");
+ }
+
+ public void serializeAndConsume(OMOutputImpl omOutput) throws XMLStreamException {
+ //TODO
+ throw new UnsupportedOperationException("TODO");
+ }
+
+ public void serializeAndConsume(XMLStreamWriter xmlWriter) throws XMLStreamException {
+ //TODO
+ throw new UnsupportedOperationException("TODO");
+ }
+
+ public OMNamespace getNamespace() {
+ //TODO
+ throw new UnsupportedOperationException("TODO");
+ }
+
+ public QName getQName() {
+ //TODO
+ throw new UnsupportedOperationException("TODO");
+ }
+
+ public String getValue() {
+ //TODO
+ throw new UnsupportedOperationException("TODO");
+ }
+
+ public void setLocalName(String localName) {
+ //TODO
+ throw new UnsupportedOperationException("TODO");
+ }
+
+ public void setOMNamespace(OMNamespace omNamespace) {
+ //TODO
+ throw new UnsupportedOperationException("TODO");
+ }
+
+ public void setValue(String value) {
+ //TODO
+ throw new UnsupportedOperationException("TODO");
+ }
+
+ public void setParent(OMContainer element) {
+ //TODO
+ throw new UnsupportedOperationException("TODO");
+ }
+
+ public void setType(int nodeType) throws OMException {
+ //TODO
+ throw new UnsupportedOperationException("TODO");
+ }
+
+
+
+
+}
Added: webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/om/impl/dom/AttributeMap.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/om/impl/dom/AttributeMap.java?rev=306585&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/om/impl/dom/AttributeMap.java (added)
+++ webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/om/impl/dom/AttributeMap.java Thu Oct 6 04:03:44 2005
@@ -0,0 +1,163 @@
+
+package org.apache.axis2.om.impl.dom;
+
+import java.util.Vector;
+
+
+import org.w3c.dom.DOMException;
+import org.w3c.dom.Node;
+
+/**
+ *
+ *
+ * @author Ruchith Fernando (ruchith.fernando@gmail.com)
+ */
+public class AttributeMap extends NamedNodeMapImpl {
+
+ /**
+ * @param ownerNode
+ */
+ protected AttributeMap(ParentNode ownerNode) {
+ super(ownerNode);
+ }
+
+
+ public Node removeNamedItem(String name) throws DOMException {
+ // TODO
+ return super.removeNamedItem(name);
+ }
+
+ public Node removeNamedItemNS(String namespaceURI, String name)
+ throws DOMException {
+ // TODO
+ return super.removeNamedItemNS(namespaceURI, name);
+ }
+
+ /**
+ * This is mostly a copy of the Xerces impl
+ */
+ public Node setNamedItem(Node attribute) throws DOMException {
+
+ if (isReadOnly()) {
+ String msg = DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "NO_MODIFICATION_ALLOWED_ERR", null);
+ throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR, msg);
+ }
+ if (attribute.getOwnerDocument() != ownerNode.getOwnerDocument()) {
+ String msg = DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "WRONG_DOCUMENT_ERR", null);
+ throw new DOMException(DOMException.WRONG_DOCUMENT_ERR, msg);
+ }
+ if (attribute.getNodeType() != Node.ATTRIBUTE_NODE) {
+ String msg = DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "HIERARCHY_REQUEST_ERR", null);
+ throw new DOMException(DOMException.HIERARCHY_REQUEST_ERR, msg);
+ }
+
+ AttrImpl attr = (AttrImpl)attribute;
+ if(attr.isOwned()) { //If the attribute is owned then:
+ if(attr.getOwnerElement() != this.ownerNode) // the owner must be the owner of this list
+ throw new DOMException(DOMException.INUSE_ATTRIBUTE_ERR,
+ DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN,
+ "INUSE_ATTRIBUTE_ERR", null));
+ else
+ return attr; //No point adding the 'same' attr again to the same element
+ }
+
+
+ attr.ownerNode = this.ownerNode; //Set the owner node
+ attr.isOwned(true); //To indicate that this attr belong to an element
+
+ int i = findNamePoint(attr.getNodeName(),0);
+
+ AttrImpl previous = null;
+ if (i >= 0) { //There's an attribute already with this attr's name
+ previous = (AttrImpl) nodes.elementAt(i);
+ nodes.setElementAt(attr,i);
+ previous.ownerNode = this.ownerNode;
+ previous.isOwned(false);
+
+ // make sure it won't be mistaken with defaults in case it's reused
+ previous.isSpecified(true);
+ } else {
+ i = -1 - i; // Insert point (may be end of list)
+ if (null == nodes) {
+ nodes = new Vector(5, 10);
+ }
+ nodes.insertElementAt(attr, i);
+ }
+
+// - Not sure whether we really need this
+// // notify document
+// ownerNode.getOwnerDocument().setAttrNode(attr, previous);
+
+ // If the new attribute is not normalized,
+ // the owning element is inherently not normalized.
+ if (!attr.isNormalized()) {
+ ownerNode.isNormalized(false);
+ }
+ return previous;
+
+ }
+
+ /**
+ * This is mostly a copy of the Xerces impl
+ */
+ public Node setNamedItemNS(Node attribute) throws DOMException {
+ if (isReadOnly()) {
+ String msg = DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "NO_MODIFICATION_ALLOWED_ERR", null);
+ throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR, msg);
+ }
+ if (attribute.getOwnerDocument() != ownerNode.getOwnerDocument()) {
+ String msg = DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "WRONG_DOCUMENT_ERR", null);
+ throw new DOMException(DOMException.WRONG_DOCUMENT_ERR, msg);
+ }
+ if (attribute.getNodeType() != Node.ATTRIBUTE_NODE) {
+ String msg = DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "HIERARCHY_REQUEST_ERR", null);
+ throw new DOMException(DOMException.HIERARCHY_REQUEST_ERR, msg);
+ }
+
+ AttrImpl attr = (AttrImpl)attribute;
+ if(attr.isOwned()) { //If the attribute is owned then:
+ if(attr.getOwnerElement() != this.ownerNode) // the owner must be the owner of this list
+ throw new DOMException(DOMException.INUSE_ATTRIBUTE_ERR,
+ DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN,
+ "INUSE_ATTRIBUTE_ERR", null));
+ else
+ return attr; //No point adding the 'same' attr again to the same element
+ }
+
+ attr.ownerNode = this.ownerNode; //Set the owner node
+ attr.isOwned(true); //To indicate that this attr belong to an element
+
+ int i = findNamePoint(attr.getNamespaceURI(), attr.getLocalName());
+ AttrImpl previous = null;
+
+ if (i >= 0) {
+ previous = (AttrImpl) nodes.elementAt(i);
+ nodes.setElementAt(attr,i);
+ previous.ownerNode = this.ownerNode;
+ previous.isOwned(false);
+ // make sure it won't be mistaken with defaults in case it's reused
+ previous.isSpecified(true);
+ } else {
+ // If we can't find by namespaceURI, localName, then we find by
+ // nodeName so we know where to insert.
+ i = findNamePoint(attr.getNodeName(),0);
+ if (i >=0) {
+ previous = (AttrImpl) nodes.elementAt(i);
+ nodes.insertElementAt(attr,i);
+ } else {
+ i = -1 - i; // Insert point (may be end of list)
+ if (null == nodes) {
+ nodes = new Vector(5, 10);
+ }
+ nodes.insertElementAt(attr, i);
+ }
+ }
+
+ // If the new attribute is not normalized,
+ // the owning element is inherently not normalized.
+ if (!attr.isNormalized()) {
+ ownerNode.isNormalized(false);
+ }
+ return previous;
+ }
+}
Added: webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/om/impl/dom/CharacterImpl.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/om/impl/dom/CharacterImpl.java?rev=306585&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/om/impl/dom/CharacterImpl.java (added)
+++ webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/om/impl/dom/CharacterImpl.java Thu Oct 6 04:03:44 2005
@@ -0,0 +1,178 @@
+package org.apache.axis2.om.impl.dom;
+
+import org.apache.axis2.om.OMText;
+import org.w3c.dom.CharacterData;
+import org.w3c.dom.DOMException;
+
+/**
+ * This implements the OMCharater operations which are to be
+ * inherited by TextImpl, CommentImpl, CDATASectionImpl
+ *
+ * @author Ruchith Fernando (ruchith.fernando@gmail.com)
+ */
+public abstract class CharacterImpl extends ChildNode implements
+ OMText, CharacterData {
+
+ protected StringBuffer textValue;
+
+ /**
+ * @param ownerNode
+ */
+ public CharacterImpl(DocumentImpl ownerNode) {
+ super(ownerNode);
+ }
+
+ public CharacterImpl(DocumentImpl ownerNode, String value){
+ super(ownerNode);
+ this.textValue = new StringBuffer(value);
+ }
+
+ ///
+ ///org.w3c.dom.CharacterData mrthods
+ ///
+
+ public void appendData(String value) throws DOMException {
+
+ if (this.isReadonly()) {
+ throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR,
+ DOMMessageFormatter.formatMessage(
+ DOMMessageFormatter.DOM_DOMAIN,
+ "NO_MODIFICATION_ALLOWED_ERR", null));
+ }
+
+ this.textValue.append(value);
+ }
+
+ /**
+ *
+ */
+ public void deleteData(int offset, int count) throws DOMException {
+ this.replaceData(offset,count,null);
+ }
+
+ /**
+ * If the given data is null the content will be deleted
+ */
+ public void replaceData(int offset, int count, String data) throws DOMException {
+
+ if (this.isReadonly()) {
+ throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR,
+ DOMMessageFormatter.formatMessage(
+ DOMMessageFormatter.DOM_DOMAIN,
+ "NO_MODIFICATION_ALLOWED_ERR", null));
+ }
+
+ int length = this.textValue.length();
+ if (offset < 0 || offset > length - 1 || count < 0) {
+ throw new DOMException(DOMException.INDEX_SIZE_ERR,
+ DOMMessageFormatter.formatMessage(
+ DOMMessageFormatter.DOM_DOMAIN, "INDEX_SIZE_ERR",
+ null));
+ } else {
+
+ int end = Math.min(count + offset, length);
+
+ if (data == null) {
+ this.textValue.delete(offset, end);
+ } else {
+ this.textValue.replace(offset, end, data);
+ }
+ }
+
+ }
+
+
+
+ /**
+ * Returns the value of the data
+ */
+ public String getData() throws DOMException {
+ return this.textValue.toString();
+ }
+
+ /**
+ * Inserts a sting at the specified offset
+ */
+ public void insertData(int offset, String data) throws DOMException {
+ int length = this.textValue.length();
+
+ if (this.isReadonly()) {
+ throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR,
+ DOMMessageFormatter.formatMessage(
+ DOMMessageFormatter.DOM_DOMAIN,
+ "NO_MODIFICATION_ALLOWED_ERR", null));
+ }
+
+ if(offset < 0 || offset > length-1) {
+ throw new DOMException(DOMException.INDEX_SIZE_ERR,
+ DOMMessageFormatter.formatMessage(
+ DOMMessageFormatter.DOM_DOMAIN,
+ "INDEX_SIZE_ERR", null));
+ }
+
+ this.textValue.insert(offset,data);
+
+ }
+
+ /**
+ * Sets the text value of data
+ */
+ public void setData(String data) throws DOMException {
+ if (!this.isReadonly()) {
+ this.textValue.replace(0,textValue.length(), data);
+ } else {
+ throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR,
+ DOMMessageFormatter.formatMessage(
+ DOMMessageFormatter.DOM_DOMAIN,
+ "NO_MODIFICATION_ALLOWED_ERR", null));
+ }
+ }
+
+ /**
+ * Extracts a range of data from the node.
+ * @return The specified substring. If the sum of offset and count exceeds
+ * the length, then all 16-bit units to the end of the data are returned.
+ */
+ public String substringData(int offset, int count) throws DOMException {
+ if(offset < 0 || offset > this.textValue.length() || count < 0) {
+ throw new DOMException(DOMException.INDEX_SIZE_ERR,
+ DOMMessageFormatter.formatMessage(
+ DOMMessageFormatter.DOM_DOMAIN,
+ "INDEX_SIZE_ERR", null));
+ }
+
+ int end = Math.min( count + offset, textValue.length());
+ return this.textValue.substring(offset, end);
+ }
+
+ /**
+ * returns the length of the sting value
+ */
+ public int getLength() {
+ return this.textValue.length();
+ }
+
+
+ ///OMCharacter methods
+
+ public String getText() {
+ return this.textValue.toString();
+ }
+
+
+ ///
+ /// Unsupported binary manipulation related method
+ ///
+
+
+
+ public String getContentID() {
+ throw new UnsupportedOperationException("This is required to hanlde binary content in OM");
+ }
+ public Object getDataHandler() {
+ throw new UnsupportedOperationException("This is required to hanlde binary content in OM");
+ }
+
+
+
+}
Added: webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/om/impl/dom/ChildNode.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/om/impl/dom/ChildNode.java?rev=306585&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/om/impl/dom/ChildNode.java (added)
+++ webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/om/impl/dom/ChildNode.java Thu Oct 6 04:03:44 2005
@@ -0,0 +1,134 @@
+package org.apache.axis2.om.impl.dom;
+
+import org.apache.axis2.om.OMContainer;
+import org.apache.axis2.om.OMException;
+import org.apache.axis2.om.OMNode;
+import org.apache.axis2.om.impl.OMNodeEx;
+import org.w3c.dom.Node;
+
+/**
+ * @author Ruchith Fernando (ruchith.fernando@gmail.com)
+ */
+public abstract class ChildNode extends NodeImpl {
+
+ protected ChildNode previousSubling;
+
+ protected ChildNode nextSibling;
+
+ protected ParentNode parentNode;
+
+
+ /**
+ * @param ownerNode
+ */
+ protected ChildNode(DocumentImpl ownerDocument) {
+ super(ownerDocument);
+ }
+
+ protected ChildNode() {
+
+ }
+
+ public OMNode getNextOMSibling() throws OMException {
+ return this.nextSibling;
+ }
+ public Node getNextSibling() {
+ return this.nextSibling;
+ }
+ public OMNode getPreviousOMSibling() {
+ return this.previousSubling;
+ }
+ public Node getPreviousSibling() {
+ return this.previousSubling;
+ }
+
+ ///
+ ///OMNode methods
+ ///
+ public void setNextOMSibling(OMNode node) {
+ if(node instanceof ChildNode)
+ this.nextSibling = (ChildNode)node;
+ else
+ throw new OMException("The node is not a " + ChildNode.class);
+ }
+
+ public void setPreviousOMSibling(OMNode node) {
+ if(node instanceof ChildNode)
+ this.previousSubling = (ChildNode)node;
+ else
+ throw new OMException("The node is not a " + ChildNode.class);
+ }
+
+ public OMContainer getParent() throws OMException {
+ return (OMContainer)this.parentNode;
+ }
+
+ public void setParent(OMContainer element) {
+ if(element instanceof ParentNode)
+ this.parentNode = (ParentNode)element;
+ else
+ throw new OMException("The given parent is not of the type " + ParentNode.class);
+
+ }
+
+ public OMNode detach() throws OMException{
+ if(this.parentNode == null) {
+ throw new OMException("Parent level elements cannot be ditached");
+ } else {
+ if(previousSubling == null) { // This is the first child
+ this.parentNode.setFirstChild(nextSibling);
+ } else {
+ ((OMNodeEx)this.getPreviousOMSibling()).setNextOMSibling(nextSibling);
+ } if (this.nextSibling != null) {
+ this.nextSibling.setPreviousOMSibling(this.previousSubling);
+ }
+ this.parentNode = null;
+ }
+ return this;
+ }
+
+ public void discard() throws OMException {
+ //TODO
+ throw new UnsupportedOperationException("TODO");
+ }
+
+ /**
+ * Insert the given sibling next to this item
+ */
+ public void insertSiblingAfter(OMNode sibling) throws OMException {
+ ((OMNodeEx)sibling).setParent(this.parentNode);
+
+ if(sibling instanceof ChildNode) {
+ ChildNode domSibling = (ChildNode)sibling;
+ domSibling.previousSubling = this;
+ if(this.nextSibling != null) {
+ this.nextSibling.previousSubling = domSibling;
+ }
+ domSibling.nextSibling = this.nextSibling;
+ this.nextSibling = domSibling;
+
+ } else {
+ throw new OMException("The given child is not of type " + ChildNode.class);
+ }
+ }
+
+ /**
+ * Insert the given sibling before this item
+ */
+ public void insertSiblingBefore(OMNode sibling) throws OMException {
+ ((OMNodeEx)sibling).setParent(this.parentNode);
+ if(sibling instanceof ChildNode) {
+ ChildNode domSibling = (ChildNode)sibling;
+ domSibling.nextSibling = this;
+ if(this.previousSubling != null) {
+ this.previousSubling.nextSibling = domSibling;
+ }
+ domSibling.previousSubling = this.previousSubling;
+ this.previousSubling = domSibling;
+
+ } else {
+ throw new OMException("The given child is not of type " + ChildNode.class);
+ }
+
+ }
+}
Added: webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/om/impl/dom/DOMMessageFormatter.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/om/impl/dom/DOMMessageFormatter.java?rev=306585&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/om/impl/dom/DOMMessageFormatter.java (added)
+++ webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/om/impl/dom/DOMMessageFormatter.java Thu Oct 6 04:03:44 2005
@@ -0,0 +1,143 @@
+
+/*
+ * Copyright 2002,2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.axis2.om.impl.dom;
+
+import java.util.Locale;
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
+import java.util.PropertyResourceBundle;
+
+/**
+ * Used to format DOM error messages, using the system locale.
+ *
+ * @xerces.internal
+ *
+ * @author Sandy Gao, IBM
+ * @version $Id: DOMMessageFormatter.java,v 1.7 2004/10/05 17:12:51 mrglavas Exp $
+ */
+public class DOMMessageFormatter {
+ public static final String DOM_DOMAIN = "http://www.w3.org/dom/DOMTR";
+ public static final String XML_DOMAIN = "http://www.w3.org/TR/1998/REC-xml-19980210";
+ public static final String SERIALIZER_DOMAIN = "http://apache.org/xml/serializer";
+
+ private static ResourceBundle domResourceBundle = null;
+ private static ResourceBundle xmlResourceBundle = null;
+ private static ResourceBundle serResourceBundle = null;
+ private static Locale locale = null;
+
+
+ public static final String LEVEL3_NOT_SUPPORTED= "DOM Level 3 operations are not supported";
+ public static final String NOT_REQUIRED_FOR_XMLSEC_OR_WSS4J= "This method is not required by Apache XML-Security Impl or WSS4J";
+
+ DOMMessageFormatter(){
+ locale = Locale.getDefault();
+ }
+ /**
+ * Formats a message with the specified arguments using the given
+ * locale information.
+ *
+ * @param domain domain from which error string is to come.
+ * @param key The message key.
+ * @param arguments The message replacement text arguments. The order
+ * of the arguments must match that of the placeholders
+ * in the actual message.
+ *
+ * @return the formatted message.
+ *
+ * @throws MissingResourceException Thrown if the message with the
+ * specified key cannot be found.
+ */
+ public static String formatMessage(String domain,
+ String key, Object[] arguments)
+ throws MissingResourceException {
+ ResourceBundle resourceBundle = getResourceBundle(domain);
+ if(resourceBundle == null){
+ init();
+ resourceBundle = getResourceBundle(domain);
+ if(resourceBundle == null)
+ throw new MissingResourceException("Unknown domain" + domain, null, key);
+ }
+ // format message
+ String msg;
+ try {
+ msg = key + ": " + resourceBundle.getString(key);
+ if (arguments != null) {
+ try {
+ msg = java.text.MessageFormat.format(msg, arguments);
+ }
+ catch (Exception e) {
+ msg = resourceBundle.getString("FormatFailed");
+ msg += " " + resourceBundle.getString(key);
+ }
+ }
+ } // error
+ catch (MissingResourceException e) {
+ msg = resourceBundle.getString("BadMessageKey");
+ throw new MissingResourceException(key, msg, key);
+ }
+
+ // no message
+ if (msg == null) {
+ msg = key;
+ if (arguments.length > 0) {
+ StringBuffer str = new StringBuffer(msg);
+ str.append('?');
+ for (int i = 0; i < arguments.length; i++) {
+ if (i > 0) {
+ str.append('&');
+ }
+ str.append(String.valueOf(arguments[i]));
+ }
+ }
+ }
+
+ return msg;
+ }
+
+ static ResourceBundle getResourceBundle(String domain){
+ if(domain == DOM_DOMAIN || domain.equals(DOM_DOMAIN))
+ return domResourceBundle;
+ else if( domain == XML_DOMAIN || domain.equals(XML_DOMAIN))
+ return xmlResourceBundle;
+ else if(domain == SERIALIZER_DOMAIN || domain.equals(SERIALIZER_DOMAIN))
+ return serResourceBundle;
+ return null;
+ }
+ /**
+ * Initialize Message Formatter.
+ */
+ public static void init(){
+ if (locale != null) {
+ domResourceBundle = PropertyResourceBundle.getBundle("org.apache.axis2.dom.msg.DOMMessages", locale);
+ serResourceBundle = PropertyResourceBundle.getBundle("org.apache.axis2.dom.msg.XMLSerializerMessages", locale);
+ xmlResourceBundle = PropertyResourceBundle.getBundle("org.apache.axis2.dom.msg.XMLMessages", locale);
+ }else{
+ domResourceBundle = PropertyResourceBundle.getBundle("org.apache.axis2.dom.msg.DOMMessages");
+ serResourceBundle = PropertyResourceBundle.getBundle("org.apache.axis2.dom.msg.XMLSerializerMessages");
+ xmlResourceBundle = PropertyResourceBundle.getBundle("org.apache.axis2.dom.msg.XMLMessages");
+ }
+ }
+
+ /**
+ * setLocale to be used by the formatter.
+ * @param locale
+ */
+ public static void setLocale(Locale dlocale){
+ locale = dlocale;
+ }
+}
Added: webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/om/impl/dom/DOMSerializerUtil.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/om/impl/dom/DOMSerializerUtil.java?rev=306585&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/om/impl/dom/DOMSerializerUtil.java (added)
+++ webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/om/impl/dom/DOMSerializerUtil.java Thu Oct 6 04:03:44 2005
@@ -0,0 +1,25 @@
+package org.apache.axis2.om.impl.dom;
+
+import org.apache.axis2.om.impl.OMOutputImpl;
+
+import javax.xml.stream.XMLStreamException;
+
+/**
+ * @author Ruchith Fernando (ruchith.fernando@gmail.com)
+ */
+public class DOMSerializerUtil {
+
+
+ public void serializeStartpart(ChildNode child, OMOutputImpl output) {
+
+ }
+
+ public void serializeEndPart(OMOutputImpl output) throws XMLStreamException {
+ output.getXmlStreamWriter().writeEndElement();
+ }
+
+
+ //static void serializeAttribute(AttributeI attr, OMOutput omOutput) throws XMLStreamException {
+
+
+}
Added: webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/om/impl/dom/DocumentFragmentimpl.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/om/impl/dom/DocumentFragmentimpl.java?rev=306585&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/om/impl/dom/DocumentFragmentimpl.java (added)
+++ webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/om/impl/dom/DocumentFragmentimpl.java Thu Oct 6 04:03:44 2005
@@ -0,0 +1,83 @@
+package org.apache.axis2.om.impl.dom;
+
+import org.apache.axis2.om.OMException;
+import org.apache.axis2.om.impl.OMOutputImpl;
+import org.w3c.dom.DocumentFragment;
+import org.w3c.dom.Node;
+
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamWriter;
+
+/**
+ * @author Ruchith Fernando (ruchith.fernando@gmail.com)
+ */
+public class DocumentFragmentimpl extends ParentNode implements
+ DocumentFragment {
+
+ /**
+ * @param ownerDocument
+ */
+ public DocumentFragmentimpl(DocumentImpl ownerDocument) {
+ super(ownerDocument);
+ }
+
+ /* (non-Javadoc)
+ * @see org.w3c.dom.Node#getNodeType()
+ */
+ public short getNodeType() {
+ return Node.DOCUMENT_FRAGMENT_NODE;
+ }
+
+ /* (non-Javadoc)
+ * @see org.w3c.dom.Node#getNodeName()
+ */
+ public String getNodeName() {
+ return "#document-fragment";
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.axis2.om.OMNode#getType()
+ */
+ public int getType() throws OMException {
+ return Node.DOCUMENT_FRAGMENT_NODE;
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.axis2.om.OMNode#setType(int)
+ */
+ public void setType(int nodeType) throws OMException {
+ //DO Nothing :-?
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.axis2.om.OMNode#serializeWithCache(org.apache.axis2.om.OMOutput)
+ */
+ public void serializeWithCache(OMOutputImpl omOutput) throws XMLStreamException {
+ //TODO
+ throw new UnsupportedOperationException("TODO");
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.axis2.om.OMNode#serialize(org.apache.axis2.om.OMOutput)
+ */
+ public void serialize(OMOutputImpl omOutput) throws XMLStreamException {
+ //TODO
+ throw new UnsupportedOperationException("TODO");
+ }
+
+ public void serialize(XMLStreamWriter xmlWriter) throws XMLStreamException {
+ //TODO
+ throw new UnsupportedOperationException("TODO");
+ }
+
+ public void serializeAndConsume(OMOutputImpl omOutput) throws XMLStreamException {
+ //TODO
+ throw new UnsupportedOperationException("TODO");
+ }
+
+ public void serializeAndConsume(XMLStreamWriter xmlWriter) throws XMLStreamException {
+ //TODO
+ throw new UnsupportedOperationException("TODO");
+ }
+
+}
Added: webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/om/impl/dom/DocumentImpl.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/om/impl/dom/DocumentImpl.java?rev=306585&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/om/impl/dom/DocumentImpl.java (added)
+++ webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/om/impl/dom/DocumentImpl.java Thu Oct 6 04:03:44 2005
@@ -0,0 +1,194 @@
+package org.apache.axis2.om.impl.dom;
+
+import org.apache.axis2.om.OMContainer;
+import org.apache.axis2.om.OMException;
+import org.apache.axis2.om.OMNode;
+import org.apache.axis2.om.impl.OMOutputImpl;
+import org.w3c.dom.Attr;
+import org.w3c.dom.CDATASection;
+import org.w3c.dom.Comment;
+import org.w3c.dom.DOMException;
+import org.w3c.dom.DOMImplementation;
+import org.w3c.dom.Document;
+import org.w3c.dom.DocumentFragment;
+import org.w3c.dom.DocumentType;
+import org.w3c.dom.Element;
+import org.w3c.dom.EntityReference;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+import org.w3c.dom.ProcessingInstruction;
+import org.w3c.dom.Text;
+
+import java.util.Hashtable;
+
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamWriter;
+
+/**
+ * @author Ruchith Fernando (ruchith.fernando@gmail.com)
+ */
+public class DocumentImpl extends ParentNode implements Document {
+
+
+ protected Hashtable identifiers;
+
+ /**
+ * @param ownerDocument
+ */
+ public DocumentImpl(DocumentImpl ownerDocument) {
+ super(ownerDocument);
+ }
+
+ protected DocumentImpl() {
+
+ }
+
+ ///
+ ///OMNode methods
+ ////
+ public void setType(int nodeType) throws OMException {
+ throw new UnsupportedOperationException("In OM Document object doesn't have a type");
+ }
+ public int getType() throws OMException {
+ throw new UnsupportedOperationException("In OM Document object doesn't have a type");
+ }
+
+ public void serialize(OMOutputImpl omOutput) throws XMLStreamException {
+ // TODO Auto-generated method stub
+ }
+
+ ///
+ ///Override ChildNode specific methods
+ ///
+ public OMNode getNextOMSibling() throws OMException {
+ throw new UnsupportedOperationException("This is the document node");
+ }
+ public Node getNextSibling() {
+ throw new UnsupportedOperationException("This is the document node");
+ }
+ public OMContainer getParent() throws OMException {
+ throw new UnsupportedOperationException("This is the document node");
+ }
+ public OMNode getPreviousOMSibling() {
+ throw new UnsupportedOperationException("This is the document node");
+ }
+ public Node getPreviousSibling() {
+ throw new UnsupportedOperationException("This is the document node");
+ }
+ public void setNextOMSibling(OMNode node) {
+ throw new UnsupportedOperationException("This is the document node");
+ }
+ public void setParent(OMContainer element) {
+ throw new UnsupportedOperationException("This is the document node");
+ }
+ public void setPreviousOMSibling(OMNode node) {
+ throw new UnsupportedOperationException("This is the document node");
+ }
+
+
+
+ ///
+ ///org.w3c.dom.Node methods
+ ///
+ public String getNodeName() {
+ return "#document";
+ }
+ public short getNodeType() {
+ return Node.DOCUMENT_NODE;
+ }
+
+ ///org.w3c.dom.Document methods
+ ///
+
+ public Attr createAttribute(String arg0) throws DOMException {
+ //TODO
+ throw new UnsupportedOperationException("TODO");
+ }
+
+ public Attr createAttributeNS(String arg0, String arg1) throws DOMException {
+ //TODO
+ throw new UnsupportedOperationException("TODO");
+ }
+
+ public CDATASection createCDATASection(String arg0) throws DOMException {
+ //TODO
+ throw new UnsupportedOperationException("TODO");
+ }
+
+ public Comment createComment(String arg0) {
+ //TODO
+ throw new UnsupportedOperationException("TODO");
+ }
+
+ public DocumentFragment createDocumentFragment() {
+ //TODO
+ throw new UnsupportedOperationException("TODO");
+ }
+
+ public Element createElement(String tagName) throws DOMException {
+ return new ElementImpl(this, tagName);
+ }
+
+ public Element createElementNS(String tagName, String ns)
+ throws DOMException {
+ NamespaceImpl namespace = new NamespaceImpl(ns);
+ return new ElementImpl(this, tagName, namespace);
+ }
+
+ public EntityReference createEntityReference(String arg0)
+ throws DOMException {
+ //TODO
+ throw new UnsupportedOperationException("TODO");
+ }
+ public ProcessingInstruction createProcessingInstruction(String arg0,
+ String arg1) throws DOMException {
+ throw new UnsupportedOperationException("PIs are not supported by OM yet :-?");
+ }
+ public Text createTextNode(String value) {
+ return new TextImpl(this, value);
+ }
+ public DocumentType getDoctype() {
+ //TODO
+ throw new UnsupportedOperationException("TODO");
+ }
+ public Element getDocumentElement() {
+ //TODO
+ throw new UnsupportedOperationException("TODO");
+ }
+ public Element getElementById(String arg0) {
+ //TODO
+ throw new UnsupportedOperationException("TODO");
+ }
+ public NodeList getElementsByTagName(String arg0) {
+ //TODO
+ throw new UnsupportedOperationException("TODO");
+ }
+ public NodeList getElementsByTagNameNS(String arg0, String arg1) {
+ //TODO
+ throw new UnsupportedOperationException("TODO");
+ }
+ public DOMImplementation getImplementation() {
+ //TODO
+ throw new UnsupportedOperationException("TODO");
+ }
+ public Node importNode(Node arg0, boolean arg1) throws DOMException {
+ //TODO
+ throw new UnsupportedOperationException("TODO");
+ }
+
+ public void serialize(XMLStreamWriter xmlWriter) throws XMLStreamException {
+ //TODO
+ throw new UnsupportedOperationException("TODO");
+ }
+
+ public void serializeAndConsume(OMOutputImpl omOutput) throws XMLStreamException {
+ //TODO
+ throw new UnsupportedOperationException("TODO");
+ }
+
+ public void serializeAndConsume(XMLStreamWriter xmlWriter) throws XMLStreamException {
+ //TODO
+ throw new UnsupportedOperationException("TODO");
+ }
+
+}
Added: webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/om/impl/dom/ElementImpl.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/om/impl/dom/ElementImpl.java?rev=306585&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/om/impl/dom/ElementImpl.java (added)
+++ webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/om/impl/dom/ElementImpl.java Thu Oct 6 04:03:44 2005
@@ -0,0 +1,243 @@
+package org.apache.axis2.om.impl.dom;
+
+import org.apache.axis2.om.OMException;
+import org.apache.axis2.om.impl.OMOutputImpl;
+import org.w3c.dom.Attr;
+import org.w3c.dom.DOMException;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamWriter;
+
+/**
+ * @author Ruchith Fernando (ruchith.fernando@gmail.com)
+ */
+public class ElementImpl extends ParentNode implements Element {
+
+ private NamespaceImpl namespace;
+ private String tagName;
+
+ /**
+ * @param ownerDocument
+ */
+ public ElementImpl(DocumentImpl ownerDocument, String tagName) {
+ super(ownerDocument);
+ this.tagName = tagName;
+ }
+
+ /**
+ * Create a new element with the
+ * @param ownerDocument
+ * @param tagName
+ * @param ns
+ */
+ public ElementImpl(DocumentImpl ownerDocument, String tagName, NamespaceImpl ns) {
+ super(ownerDocument);
+ this.tagName = tagName;
+ this.namespace = ns;
+ }
+
+
+ ///
+ ///org.w3c.dom.Node methods
+ ///
+
+ /* (non-Javadoc)
+ * @see org.w3c.dom.Node#getNodeType()
+ */
+ public short getNodeType() {
+ return Node.ELEMENT_NODE;
+ }
+
+ /* (non-Javadoc)
+ * @see org.w3c.dom.Node#getNodeName()
+ */
+ public String getNodeName() {
+ return this.tagName;
+ }
+
+ /**
+ * Returns the value of the namespace URI
+ */
+ public String getNamespaceURI() {
+ return this.namespace.getName();
+ }
+
+ ///
+ ///org.apache.axis2.om.OMNode methods
+ ///
+
+ /* (non-Javadoc)
+ * @see org.apache.axis2.om.OMNode#getType()
+ */
+ public int getType() throws OMException {
+ return Node.ELEMENT_NODE;
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.axis2.om.OMNode#setType(int)
+ */
+ public void setType(int nodeType) throws OMException {
+ //Do nothing ...
+ //This is an Eement Node...
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.axis2.om.OMNode#serialize(org.apache.axis2.om.OMOutput)
+ */
+ public void serialize(OMOutputImpl omOutput) throws XMLStreamException {
+ //TODO
+ throw new UnsupportedOperationException("TODO");
+ }
+
+
+ ///
+ /// org.w3c.dom.Element methods
+ ///
+
+ /* (non-Javadoc)
+ * @see org.w3c.dom.Element#getTagName()
+ */
+ public String getTagName() {
+ return this.tagName;
+ }
+
+ /* (non-Javadoc)
+ * @see org.w3c.dom.Element#removeAttribute(java.lang.String)
+ */
+ public void removeAttribute(String arg0) throws DOMException {
+ //TODO
+ throw new UnsupportedOperationException("TODO");
+ }
+
+ /* (non-Javadoc)
+ * @see org.w3c.dom.Element#hasAttribute(java.lang.String)
+ */
+ public boolean hasAttribute(String arg0) {
+ //TODO
+ throw new UnsupportedOperationException("TODO");
+ }
+
+ /* (non-Javadoc)
+ * @see org.w3c.dom.Element#getAttribute(java.lang.String)
+ */
+ public String getAttribute(String arg0) {
+ //TODO
+ throw new UnsupportedOperationException("TODO");
+ }
+
+ /* (non-Javadoc)
+ * @see org.w3c.dom.Element#removeAttributeNS(java.lang.String, java.lang.String)
+ */
+ public void removeAttributeNS(String arg0, String arg1) throws DOMException {
+ //TODO
+ throw new UnsupportedOperationException("TODO");
+ }
+
+ /* (non-Javadoc)
+ * @see org.w3c.dom.Element#setAttribute(java.lang.String, java.lang.String)
+ */
+ public void setAttribute(String arg0, String arg1) throws DOMException {
+ //TODO
+ throw new UnsupportedOperationException("TODO");
+ }
+
+ /* (non-Javadoc)
+ * @see org.w3c.dom.Element#hasAttributeNS(java.lang.String, java.lang.String)
+ */
+ public boolean hasAttributeNS(String arg0, String arg1) {
+ //TODO
+ throw new UnsupportedOperationException("TODO");
+ }
+
+ /* (non-Javadoc)
+ * @see org.w3c.dom.Element#getAttributeNode(java.lang.String)
+ */
+ public Attr getAttributeNode(String arg0) {
+ //TODO
+ throw new UnsupportedOperationException("TODO");
+ }
+
+ /* (non-Javadoc)
+ * @see org.w3c.dom.Element#removeAttributeNode(org.w3c.dom.Attr)
+ */
+ public Attr removeAttributeNode(Attr arg0) throws DOMException {
+ //TODO
+ throw new UnsupportedOperationException("TODO");
+ }
+
+ /* (non-Javadoc)
+ * @see org.w3c.dom.Element#setAttributeNode(org.w3c.dom.Attr)
+ */
+ public Attr setAttributeNode(Attr arg0) throws DOMException {
+ //TODO
+ throw new UnsupportedOperationException("TODO");
+ }
+
+ /* (non-Javadoc)
+ * @see org.w3c.dom.Element#setAttributeNodeNS(org.w3c.dom.Attr)
+ */
+ public Attr setAttributeNodeNS(Attr arg0) throws DOMException {
+ //TODO
+ throw new UnsupportedOperationException("TODO");
+ }
+
+ /* (non-Javadoc)
+ * @see org.w3c.dom.Element#getElementsByTagName(java.lang.String)
+ */
+ public NodeList getElementsByTagName(String arg0) {
+ //TODO
+ throw new UnsupportedOperationException("TODO");
+ }
+
+ /* (non-Javadoc)
+ * @see org.w3c.dom.Element#getAttributeNS(java.lang.String, java.lang.String)
+ */
+ public String getAttributeNS(String arg0, String arg1) {
+ //TODO
+ throw new UnsupportedOperationException("TODO");
+ }
+
+ /* (non-Javadoc)
+ * @see org.w3c.dom.Element#setAttributeNS(java.lang.String, java.lang.String, java.lang.String)
+ */
+ public void setAttributeNS(String arg0, String arg1, String arg2) throws DOMException {
+ //TODO
+ throw new UnsupportedOperationException("TODO");
+ }
+
+ /* (non-Javadoc)
+ * @see org.w3c.dom.Element#getAttributeNodeNS(java.lang.String, java.lang.String)
+ */
+ public Attr getAttributeNodeNS(String arg0, String arg1) {
+ //TODO
+ throw new UnsupportedOperationException("TODO");
+ }
+
+ /* (non-Javadoc)
+ * @see org.w3c.dom.Element#getElementsByTagNameNS(java.lang.String, java.lang.String)
+ */
+ public NodeList getElementsByTagNameNS(String arg0, String arg1) {
+ //TODO
+ throw new UnsupportedOperationException("TODO");
+ }
+
+
+ public void serialize(XMLStreamWriter xmlWriter) throws XMLStreamException {
+ //TODO
+ throw new UnsupportedOperationException("TODO");
+ }
+
+ public void serializeAndConsume(OMOutputImpl omOutput) throws XMLStreamException {
+ //TODO
+ throw new UnsupportedOperationException("TODO");// TODO Auto-generated method stub
+
+ }
+
+ public void serializeAndConsume(XMLStreamWriter xmlWriter) throws XMLStreamException {
+ //TODO
+ throw new UnsupportedOperationException("TODO");
+ }
+}
Added: webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/om/impl/dom/NamedNodeMapImpl.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/om/impl/dom/NamedNodeMapImpl.java?rev=306585&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/om/impl/dom/NamedNodeMapImpl.java (added)
+++ webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/om/impl/dom/NamedNodeMapImpl.java Thu Oct 6 04:03:44 2005
@@ -0,0 +1,441 @@
+package org.apache.axis2.om.impl.dom;
+
+import java.util.Vector;
+
+import org.w3c.dom.DOMException;
+import org.w3c.dom.NamedNodeMap;
+import org.w3c.dom.Node;
+
+/**
+ *
+ * Most of the implementation is taken from
+ * From org.apache.xerces.dom.NamedNodeMapImpl
+ *
+ * @author Ruchith Fernando (ruchith.fernando@gmail.com)
+ */
+public class NamedNodeMapImpl implements NamedNodeMap {
+
+ Vector nodes;
+ ParentNode ownerNode;
+ //
+ // Data
+ //
+
+ protected short flags;
+
+ protected final static short READONLY = 0x1<<0;
+ protected final static short CHANGED = 0x1<<1;
+ protected final static short HASDEFAULTS = 0x1<<2;
+
+
+ protected NamedNodeMapImpl(ParentNode ownerNode) {
+ this.ownerNode = ownerNode;
+ }
+
+ /**
+ *
+ */
+ public Node getNamedItem(String name) {
+ int i = findNamePoint(name,0);
+ return (i < 0) ? null : (Node)(nodes.elementAt(i));
+
+ }
+
+ /**
+ *From org.apache.xerces.dom.NamedNodeMapImpl
+ */
+ public Node item(int index) {
+ return (nodes != null && index < nodes.size()) ?
+ (Node)(nodes.elementAt(index)) : null;
+ }
+
+ /**
+ * From org.apache.xerces.dom.NamedNodeMapImpl
+ */
+ public int getLength() {
+ return (nodes != null) ? nodes.size() : 0;
+ }
+
+ /**
+ * Removes a node specified by name.
+ * @param name The name of a node to remove.
+ * @return The node removed from the map if a node with such a name exists.
+ */
+ /***/
+ public Node removeNamedItem(String name)
+ throws DOMException {
+
+ if (isReadOnly()) {
+ String msg = DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "NO_MODIFICATION_ALLOWED_ERR", null);
+ throw
+ new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR,
+ msg);
+ }
+ int i = findNamePoint(name,0);
+ if (i < 0) {
+ String msg = DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "NOT_FOUND_ERR", null);
+ throw new DOMException(DOMException.NOT_FOUND_ERR, msg);
+ }
+
+ NodeImpl n = (NodeImpl)nodes.elementAt(i);
+ nodes.removeElementAt(i);
+
+ return n;
+
+ } // removeNamedItem(String):Node
+
+
+ /**
+ * Introduced in DOM Level 2. <p>
+ * Retrieves a node specified by local name and namespace URI.
+ *
+ * @param namespaceURI The namespace URI of the node to retrieve.
+ * When it is null or an empty string, this
+ * method behaves like getNamedItem.
+ * @param localName The local name of the node to retrieve.
+ * @return Node A Node (of any type) with the specified name, or null if the specified
+ * name did not identify any node in the map.
+ */
+ public Node getNamedItemNS(String namespaceURI, String localName) {
+
+ int i = findNamePoint(namespaceURI, localName);
+ return (i < 0) ? null : (Node)(nodes.elementAt(i));
+
+ } // getNamedItemNS(String,String):Node
+
+ /**
+ * Adds a node using its namespaceURI and localName.
+ * @see org.w3c.dom.NamedNodeMap#setNamedItem
+ * @return If the new Node replaces an existing node the replaced Node is returned,
+ * otherwise null is returned.
+ * @param arg A node to store in a named node map. The node will later be
+ * accessible using the value of the namespaceURI and localName
+ * attribute of the node. If a node with those namespace URI and
+ * local name is already present in the map, it is replaced by the new
+ * one.
+ */
+ public Node setNamedItemNS(Node arg) throws DOMException {
+
+ DocumentImpl ownerDocument = (DocumentImpl)ownerNode.getOwnerDocument();
+ if (isReadOnly()) {
+ String msg = DOMMessageFormatter.formatMessage(
+ DOMMessageFormatter.DOM_DOMAIN,
+ "NO_MODIFICATION_ALLOWED_ERR", null);
+ throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR,
+ msg);
+ }
+
+ if (arg.getOwnerDocument() != ownerDocument) {
+ String msg = DOMMessageFormatter.formatMessage(
+ DOMMessageFormatter.DOM_DOMAIN, "WRONG_DOCUMENT_ERR", null);
+ throw new DOMException(DOMException.WRONG_DOCUMENT_ERR, msg);
+ }
+
+ int i = findNamePoint(arg.getNamespaceURI(), arg.getLocalName());
+ NodeImpl previous = null;
+ if (i >= 0) {
+ previous = (NodeImpl) nodes.elementAt(i);
+ nodes.setElementAt(arg,i);
+ } else {
+ // If we can't find by namespaceURI, localName, then we find by
+ // nodeName so we know where to insert.
+ i = findNamePoint(arg.getNodeName(),0);
+ if (i >= 0) {
+ previous = (NodeImpl) nodes.elementAt(i);
+ nodes.insertElementAt(arg,i);
+ } else {
+ i = -1 - i; // Insert point (may be end of list)
+ if (null == nodes) {
+ nodes = new Vector(5, 10);
+ }
+ nodes.insertElementAt(arg, i);
+ }
+ }
+ return previous;
+
+ } // setNamedItemNS(Node):Node
+
+ /**
+ * Introduced in DOM Level 2. <p>
+ * Removes a node specified by local name and namespace URI.
+ * @param namespaceURI
+ * The namespace URI of the node to remove.
+ * When it is null or an empty string, this
+ * method behaves like removeNamedItem.
+ * @param The local name of the node to remove.
+ * @return Node 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.
+
+ */
+ public Node removeNamedItemNS(String namespaceURI, String name)
+ throws DOMException {
+
+ if (isReadOnly()) {
+ String msg = DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "NO_MODIFICATION_ALLOWED_ERR", null);
+ throw
+ new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR,
+ msg);
+ }
+ int i = findNamePoint(namespaceURI, name);
+ if (i < 0) {
+ String msg = DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "NOT_FOUND_ERR", null);
+ throw new DOMException(DOMException.NOT_FOUND_ERR, msg);
+ }
+
+ NodeImpl n = (NodeImpl)nodes.elementAt(i);
+ nodes.removeElementAt(i);
+
+ return n;
+
+ } // removeNamedItem(String):Node
+
+
+ /**
+ * Adds a node using its nodeName attribute.
+ * As the nodeName attribute is used to derive the name which the node must be
+ * stored under, multiple nodes of certain types (those that have a "special" string
+ * value) cannot be stored as the names would clash. This is seen as preferable to
+ * allowing nodes to be aliased.
+ * @see org.w3c.dom.NamedNodeMap#setNamedItem
+ * @return If the new Node replaces an existing node the replaced Node is returned,
+ * otherwise null is returned.
+ * @param arg
+ * A node to store in a named node map. The node will later be
+ * accessible using the value of the namespaceURI and localName
+ * attribute of the node. If a node with those namespace URI and
+ * local name is already present in the map, it is replaced by the new
+ * one.
+ * @exception org.w3c.dom.DOMException The exception description.
+ */
+ public Node setNamedItem(Node arg)
+ throws DOMException {
+
+ DocumentImpl ownerDocument = (DocumentImpl)ownerNode.getOwnerDocument();
+
+ if (isReadOnly()) {
+ String msg = DOMMessageFormatter.formatMessage(
+ DOMMessageFormatter.DOM_DOMAIN,
+ "NO_MODIFICATION_ALLOWED_ERR", null);
+ throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR,
+ msg);
+ }
+ if (arg.getOwnerDocument() != ownerDocument) {
+ String msg = DOMMessageFormatter.formatMessage(
+ DOMMessageFormatter.DOM_DOMAIN, "WRONG_DOCUMENT_ERR", null);
+ throw new DOMException(DOMException.WRONG_DOCUMENT_ERR, msg);
+ }
+
+ int i = findNamePoint(arg.getNodeName(),0);
+ NodeImpl previous = null;
+ if (i >= 0) {
+ previous = (NodeImpl) nodes.elementAt(i);
+ nodes.setElementAt(arg,i);
+ } else {
+ i = -1 - i; // Insert point (may be end of list)
+ if (null == nodes) {
+ nodes = new Vector(5, 10);
+ }
+ nodes.insertElementAt(arg, i);
+ }
+ return previous;
+
+ } // setNamedItem(Node):Node
+
+
+ final boolean isReadOnly() {
+ return (flags & READONLY) != 0;
+ }
+
+ final void isReadOnly(boolean value) {
+ flags = (short) (value ? flags | READONLY : flags & ~READONLY);
+ }
+
+ final boolean changed() {
+ return (flags & CHANGED) != 0;
+ }
+
+ final void changed(boolean value) {
+ flags = (short) (value ? flags | CHANGED : flags & ~CHANGED);
+ }
+
+ final boolean hasDefaults() {
+ return (flags & HASDEFAULTS) != 0;
+ }
+
+ final void hasDefaults(boolean value) {
+ flags = (short) (value ? flags | HASDEFAULTS : flags & ~HASDEFAULTS);
+ }
+
+ /**
+ *
+ * From org.apache.xerces.dom.NamedNodeMapImpl
+ *
+ * Subroutine: Locate the named item, or the point at which said item
+ * should be added.
+ *
+ * @param name Name of a node to look up.
+ *
+ * @return If positive or zero, the index of the found item.
+ * If negative, index of the appropriate point at which to insert
+ * the item, encoded as -1-index and hence reconvertable by subtracting
+ * it from -1. (Encoding because I don't want to recompare the strings
+ * but don't want to burn bytes on a datatype to hold a flagged value.)
+ */
+ protected int findNamePoint(String name, int start) {
+
+ // Binary search
+ int i = 0;
+ if (nodes != null) {
+ int first = start;
+ int last = nodes.size() - 1;
+
+ while (first <= last) {
+ i = (first + last) / 2;
+ int test = name.compareTo(((Node)(nodes.elementAt(i))).getNodeName());
+ if (test == 0) {
+ return i; // Name found
+ }
+ else if (test < 0) {
+ last = i - 1;
+ }
+ else {
+ first = i + 1;
+ }
+ }
+
+ if (first > i) {
+ i = first;
+ }
+ }
+
+ return -1 - i; // not-found has to be encoded.
+
+ } // findNamePoint(String):int
+
+ /** This findNamePoint is for DOM Level 2 Namespaces.
+ */
+ protected int findNamePoint(String namespaceURI, String name) {
+
+ if (nodes == null) return -1;
+ if (name == null) return -1;
+
+ // This is a linear search through the same nodes Vector.
+ // The Vector is sorted on the DOM Level 1 nodename.
+ // The DOM Level 2 NS keys are namespaceURI and Localname,
+ // 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.
+ for (int i = 0; i < nodes.size(); i++) {
+ NodeImpl a = (NodeImpl)nodes.elementAt(i);
+ String aNamespaceURI = a.getNamespaceURI();
+ String aLocalName = a.getLocalName();
+ if (namespaceURI == null) {
+ if (aNamespaceURI == null
+ &&
+ (name.equals(aLocalName)
+ ||
+ (aLocalName == null && name.equals(a.getNodeName()))))
+ return i;
+ } else {
+ if (namespaceURI.equals(aNamespaceURI)
+ &&
+ name.equals(aLocalName))
+ return i;
+ }
+ }
+ return -1;
+ }
+
+ // compare 2 nodes in the map. If a precedes b, return true, otherwise
+ // return false
+ protected boolean precedes(Node a, Node b) {
+
+ if (nodes != null) {
+ for (int i = 0; i < nodes.size(); i++) {
+ Node n = (Node)nodes.elementAt(i);
+ if (n==a) return true;
+ if (n==b) return false;
+ }
+ }
+
+ return false;
+ }
+
+
+ /**
+ * NON-DOM: Remove attribute at specified index
+ */
+ protected void removeItem(int index) {
+ if (nodes != null && index < nodes.size()){
+ nodes.removeElementAt(index);
+ }
+ }
+
+
+ protected Object getItem (int index){
+ if (nodes !=null) {
+ return nodes.elementAt(index);
+ }
+ return null;
+ }
+
+ protected int addItem (Node arg) {
+ int i = findNamePoint(arg.getNamespaceURI(), arg.getLocalName());
+ if (i >= 0) {
+ nodes.setElementAt(arg,i);
+ }
+ else {
+ // If we can't find by namespaceURI, localName, then we find by
+ // nodeName so we know where to insert.
+ i = findNamePoint(arg.getNodeName(),0);
+ if (i >= 0) {
+ nodes.insertElementAt(arg,i);
+ }
+ else {
+ i = -1 - i; // Insert point (may be end of list)
+ if (null == nodes) {
+ nodes = new Vector(5, 10);
+ }
+ nodes.insertElementAt(arg, i);
+ }
+ }
+ return i;
+ }
+
+ /**
+ * NON-DOM: copy content of this map into the specified vector
+ *
+ * @param list Vector to copy information into.
+ * @return A copy of this node named map
+ */
+ protected Vector cloneMap(Vector list){
+ if (list == null) {
+ list = new Vector(5, 10);
+ }
+ list.setSize(0);
+ if (nodes != null) {
+ for (int i=0; i<nodes.size(); i++) {
+ list.insertElementAt(nodes.elementAt(i), i);
+ }
+ }
+
+ return list;
+ }
+
+ protected int getNamedItemIndex(String namespaceURI, String localName) {
+ return findNamePoint(namespaceURI, localName);
+ }
+
+ /**
+ * NON-DOM remove all elements from this map
+ */
+ public void removeAll (){
+ if (nodes != null) {
+ nodes.removeAllElements();
+ }
+ }
+
+}
Added: webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/om/impl/dom/NamespaceImpl.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/om/impl/dom/NamespaceImpl.java?rev=306585&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/om/impl/dom/NamespaceImpl.java (added)
+++ webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/om/impl/dom/NamespaceImpl.java Thu Oct 6 04:03:44 2005
@@ -0,0 +1,38 @@
+package org.apache.axis2.om.impl.dom;
+
+import org.apache.axis2.om.OMNamespace;
+
+/**
+ * @author Ruchith Fernando (ruchith.fernando@gmail.com)
+ */
+public class NamespaceImpl implements OMNamespace {
+
+ private String nsUri;
+ private String nsPrefix;
+
+ public NamespaceImpl(String uri) {
+ this.nsUri = uri;
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.axis2.om.OMNamespace#equals(java.lang.String, java.lang.String)
+ */
+ public boolean equals(String uri, String prefix) {
+ return (this.nsUri == uri && this.nsPrefix == prefix);
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.axis2.om.OMNamespace#getPrefix()
+ */
+ public String getPrefix() {
+ return this.nsPrefix;
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.axis2.om.OMNamespace#getName()
+ */
+ public String getName() {
+ return this.nsUri;
+ }
+
+}
Added: webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/om/impl/dom/NodeImpl.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/om/impl/dom/NodeImpl.java?rev=306585&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/om/impl/dom/NodeImpl.java (added)
+++ webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/om/impl/dom/NodeImpl.java Thu Oct 6 04:03:44 2005
@@ -0,0 +1,432 @@
+package org.apache.axis2.om.impl.dom;
+
+import org.apache.axis2.om.OMContainer;
+import org.apache.axis2.om.OMException;
+import org.apache.axis2.om.OMNode;
+import org.apache.axis2.om.OMXMLParserWrapper;
+import org.apache.axis2.om.impl.OMNodeEx;
+import org.apache.axis2.om.impl.OMOutputImpl;
+import org.w3c.dom.DOMException;
+import org.w3c.dom.Document;
+import org.w3c.dom.NamedNodeMap;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+import javax.xml.stream.XMLStreamException;
+
+/**
+ * @author Ruchith Fernando (ruchith.fernando@gmail.com)
+ */
+public abstract class NodeImpl implements Node, NodeList,OMNodeEx {
+
+
+ /**
+ * Field builder
+ */
+ protected OMXMLParserWrapper builder;
+
+ /**
+ * Field done
+ */
+ protected boolean done = false;
+
+ /**
+ * Field nodeType
+ */
+ protected int nodeType;
+
+
+
+
+ protected NodeImpl ownerNode;
+
+ // data
+
+ protected short flags;
+ protected final static short OWNED = 0x1<<1;
+ protected final static short FIRSTCHILD = 0x1<<2;
+ protected final static short READONLY = 0x1<<3;
+ protected final static short SPECIFIED = 0x1<<4;
+ protected final static short NORMALIZED = 0x1<<5;
+
+ //
+ // Constructors
+ //
+
+ protected NodeImpl(DocumentImpl ownerDocument) {
+
+ this.ownerNode = ownerDocument;
+ }
+
+ protected NodeImpl() {
+ }
+
+
+
+ public void normalize() {
+ /* by default we do not have any children,
+ ParentNode overrides this behavior */
+ }
+
+
+ public boolean hasAttributes() {
+ return false; // overridden in ElementImpl
+ }
+
+
+ public boolean hasChildNodes() {
+ return false; //Override in ParentNode
+ }
+
+
+ public String getLocalName()
+ {
+ return null; //Override in AttrImpl and ElementImpl
+ }
+
+ public String getNamespaceURI() {
+ return null; //Override in AttrImpl and ElementImpl
+ }
+
+
+
+
+ public String getNodeValue() throws DOMException {
+ return null;
+ }
+
+
+ public String getPrefix()
+ {
+ return null;
+ }
+
+ public void setNodeValue(String arg0) throws DOMException {
+ //Don't do anything, to be overridden in SOME Child classes
+ }
+
+
+
+ public void setPrefix(String prefix) throws DOMException {
+ throw new DOMException(DOMException.NAMESPACE_ERR,
+ DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN,
+ "NAMESPACE_ERR", null));
+ }
+
+ /**
+ * Find the Document that this Node belongs to (the document in
+ * whose context the Node was created). The Node may or may not
+ */
+ public Document getOwnerDocument() {
+ // if we have an owner simply forward the request
+ // otherwise ownerNode is our ownerDocument
+ if (isOwned()) {
+ return ownerNode.getOwnerDocument();
+ } else {
+ return (Document) this.ownerNode;
+ }
+ }
+
+ /**
+ * Return the collection of attributes associated with this node,
+ * or null if none. At this writing, Element is the only type of node
+ * which will ever have attributes.
+ *
+ * @see ElementImpl
+ */
+ public NamedNodeMap getAttributes() {
+ return null; // overridden in ElementImpl
+ }
+
+ /** The first child of this Node, or null if none.
+ * <P>
+ * By default we do not have any children, ParentNode overrides this.
+ * @see ParentNode
+ */
+ public Node getFirstChild() {
+ return null;
+ }
+
+
+ /** The first child of this Node, or null if none.
+ * <P>
+ * By default we do not have any children, ParentNode overrides this.
+ * @see ParentNode
+ */
+ public Node getLastChild() {
+ return null;
+ }
+
+ /** The next child of this node's parent, or null if none */
+ public Node getNextSibling() {
+ return null; // default behavior, overriden in ChildNode
+ }
+
+
+ public Node getParentNode() {
+ return null; // overriden by ChildNode
+ //Document, DocumentFragment, and Attribute will never have parents.
+ }
+
+ /*
+ * same as above but returns internal type
+ */
+ NodeImpl parentNode() {
+ return null;
+ }
+
+ /** The previous child of this node's parent, or null if none */
+ public Node getPreviousSibling() {
+ return null; // default behavior, overriden in ChildNode
+ }
+
+ public Node cloneNode(boolean deep) {
+ throw new UnsupportedOperationException("TODO");
+ //TODO
+ } // cloneNode(boolean):Node
+
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.w3c.dom.Node#getChildNodes()
+ */
+ public NodeList getChildNodes() {
+ return this;
+ }
+
+ public boolean isSupported(String feature, String version)
+ {
+ throw new UnsupportedOperationException();
+ //TODO
+ }
+
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.w3c.dom.Node#appendChild(org.w3c.dom.Node)
+ */
+ public Node appendChild(Node newChild) throws DOMException {
+ return insertBefore(newChild, null);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.w3c.dom.Node#removeChild(org.w3c.dom.Node)
+ */
+ public Node removeChild(Node oldChild) throws DOMException {
+ throw new DOMException(DOMException.NOT_FOUND_ERR, DOMMessageFormatter
+ .formatMessage(DOMMessageFormatter.DOM_DOMAIN, "NOT_FOUND_ERR",
+ null));
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.w3c.dom.Node#insertBefore(org.w3c.dom.Node, org.w3c.dom.Node)
+ */
+ public Node insertBefore(Node newChild, Node refChild) throws DOMException {
+ //Overridden in ParentNode
+ throw new DOMException(DOMException.HIERARCHY_REQUEST_ERR,
+ DOMMessageFormatter.formatMessage(
+ DOMMessageFormatter.DOM_DOMAIN,
+ "HIERARCHY_REQUEST_ERR", null));
+
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.w3c.dom.Node#replaceChild(org.w3c.dom.Node, org.w3c.dom.Node)
+ */
+ public Node replaceChild(Node newChild, Node oldChild) throws DOMException {
+ throw new DOMException(DOMException.HIERARCHY_REQUEST_ERR,
+ DOMMessageFormatter.formatMessage(
+ DOMMessageFormatter.DOM_DOMAIN,
+ "HIERARCHY_REQUEST_ERR", null));
+ }
+
+
+
+ //
+ // NodeList methods
+ //
+
+ /**
+ * NodeList method: Count the immediate children of this node
+ * <P>
+ * By default we do not have any children, ParentNode overrides this.
+ * @see ParentNode
+ *
+ * @return int
+ */
+ public int getLength() {
+ return 0;
+ }
+
+ /**
+ * NodeList method: Return the Nth immediate child of this node, or
+ * null if the index is out of bounds.
+ * <P>
+ * By default we do not have any children, ParentNode overrides this.
+ * @see ParentNode
+ *
+ * @return org.w3c.dom.Node
+ * @param Index int
+ */
+ public Node item(int index) {
+ return null;
+ }
+
+
+
+
+ /*
+ * Flags setters and getters
+ */
+
+
+ final boolean isOwned() {
+ return (flags & OWNED) != 0;
+ }
+
+ final void isOwned(boolean value) {
+ flags = (short) (value ? flags | OWNED : flags & ~OWNED);
+ }
+
+ final boolean isFirstChild() {
+ return (flags & FIRSTCHILD) != 0;
+ }
+
+ final void isFirstChild(boolean value) {
+ flags = (short) (value ? flags | FIRSTCHILD : flags & ~FIRSTCHILD);
+ }
+
+ final boolean isReadonly() {
+ return (flags & READONLY) != 0;
+ }
+
+ final void isReadonly(boolean value) {
+ flags = (short) (value ? flags | READONLY : flags & ~READONLY);
+ }
+
+ final boolean isSpecified() {
+ return (flags & SPECIFIED) != 0;
+ }
+
+ final void isSpecified(boolean value) {
+ flags = (short) (value ? flags | SPECIFIED : flags & ~SPECIFIED);
+ }
+
+ final boolean isNormalized() {
+ return (flags & NORMALIZED) != 0;
+ }
+
+ final void isNormalized(boolean value) {
+ // See if flag should propagate to parent.
+ if (!value && isNormalized() && ownerNode != null) {
+ ownerNode.isNormalized(false);
+ }
+ flags = (short) (value ? flags | NORMALIZED : flags & ~NORMALIZED);
+ }
+
+ ///
+ ///OM Methods
+ ///
+
+ /* (non-Javadoc)
+ * @see org.apache.axis.om.OMNode#getParent()
+ */
+ public OMContainer getParent() throws OMException {
+ return null; // overriden by ChildNode
+ //Document, DocumentFragment, and Attribute will never have parents.
+ }
+
+
+
+ /* (non-Javadoc)
+ * @see org.apache.axis.om.OMNode#isComplete()
+ */
+ public boolean isComplete() {
+ return this.done;
+ }
+
+ /**
+ */
+ public void setComplete(boolean state) {
+ this.done = state;
+
+ }
+
+ /**
+ * There no concept of caching in this OM-DOM implementation
+ */
+ public void serializeWithCache(OMOutputImpl omOutput) throws XMLStreamException {
+ this.serialize(omOutput);
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.axis.om.OMNode#insertSiblingAfter(org.apache.axis.om.OMNode)
+ */
+ public void insertSiblingAfter(OMNode sibling) throws OMException {
+ //Overridden in ChildNode
+ throw new DOMException(DOMException.HIERARCHY_REQUEST_ERR,
+ DOMMessageFormatter.formatMessage(
+ DOMMessageFormatter.DOM_DOMAIN,
+ "HIERARCHY_REQUEST_ERR", null));
+
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.axis.om.OMNode#insertSiblingBefore(org.apache.axis.om.OMNode)
+ */
+ public void insertSiblingBefore(OMNode sibling) throws OMException {
+ //Overridden in ChildNode
+ throw new DOMException(DOMException.HIERARCHY_REQUEST_ERR,
+ DOMMessageFormatter.formatMessage(
+ DOMMessageFormatter.DOM_DOMAIN,
+ "HIERARCHY_REQUEST_ERR", null));
+
+ }
+
+
+
+ /**
+ * default behavior, overriden in ChildNode
+ */
+ public OMNode getPreviousOMSibling() {
+ return null;
+ }
+
+ /**
+ * default behavior, overriden in ChildNode
+ */
+ public OMNode getNextOMSibling() {
+ return null;
+ }
+
+ public void setPreviousOMSibling(OMNode previousSibling) {
+ throw new DOMException(DOMException.HIERARCHY_REQUEST_ERR,
+ DOMMessageFormatter.formatMessage(
+ DOMMessageFormatter.DOM_DOMAIN,
+ "HIERARCHY_REQUEST_ERR", null));
+ }
+
+ public void setNextOMSibling(OMNode previousSibling) {
+ throw new DOMException(DOMException.HIERARCHY_REQUEST_ERR,
+ DOMMessageFormatter.formatMessage(
+ DOMMessageFormatter.DOM_DOMAIN,
+ "HIERARCHY_REQUEST_ERR", null));
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.axis.om.OMNode#build()
+ */
+ public void build() {
+ if(!done)
+ this.builder.next();
+ }
+
+}
Added: webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/om/impl/dom/NodeListImpl.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/om/impl/dom/NodeListImpl.java?rev=306585&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/om/impl/dom/NodeListImpl.java (added)
+++ webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/om/impl/dom/NodeListImpl.java Thu Oct 6 04:03:44 2005
@@ -0,0 +1,49 @@
+package org.apache.axis2.om.impl.dom;
+
+import java.util.Vector;
+
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+
+public class NodeListImpl implements NodeList {
+
+ protected NodeImpl rootNode;
+ protected String tagName;
+ protected Vector nodes;
+
+ protected String nsName;
+ protected boolean enableNS = false;
+
+
+ /** Constructor. */
+ public NodeListImpl(NodeImpl rootNode, String tagName) {
+ this.rootNode = rootNode;
+ this.tagName = tagName;
+ nodes = new Vector();
+ }
+
+ /** Constructor for Namespace support. */
+ public NodeListImpl(NodeImpl rootNode,
+ String nsName, String tagName) {
+ this(rootNode, tagName);
+ this.nsName = (nsName != null && !nsName.equals("")) ? nsName : null;
+ enableNS = true;
+ }
+
+ /* (non-Javadoc)
+ * @see org.w3c.dom.NodeList#getLength()
+ */
+ public int getLength() {
+ //TODO
+ throw new UnsupportedOperationException("TODO");
+ }
+
+ /* (non-Javadoc)
+ * @see org.w3c.dom.NodeList#item(int)
+ */
+ public Node item(int arg0) {
+ //TODO
+ throw new UnsupportedOperationException("TODO");
+ }
+}
Added: webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/om/impl/dom/ParentNode.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/om/impl/dom/ParentNode.java?rev=306585&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/om/impl/dom/ParentNode.java (added)
+++ webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/om/impl/dom/ParentNode.java Thu Oct 6 04:03:44 2005
@@ -0,0 +1,310 @@
+package org.apache.axis2.om.impl.dom;
+
+import org.apache.axis2.om.OMElement;
+import org.apache.axis2.om.OMException;
+import org.apache.axis2.om.OMNode;
+import org.apache.axis2.om.impl.OMContainerEx;
+import org.apache.axis2.om.impl.llom.traverse.OMChildrenIterator;
+import org.w3c.dom.DOMException;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+import java.util.Iterator;
+
+import javax.xml.namespace.QName;
+
+/**
+ * @author Ruchith Fernando (ruchith.fernando@gmail.com)
+ */
+public abstract class ParentNode extends ChildNode implements OMContainerEx{
+
+
+ protected ChildNode firstChild;
+
+ protected ChildNode lastChild;
+
+
+
+ /**
+ * @param ownerDocument
+ */
+ protected ParentNode(DocumentImpl ownerDocument) {
+ super(ownerDocument);
+ }
+
+ protected ParentNode() {
+ }
+
+ ///
+ ///OMContainer methods
+ ///
+
+ public void addChild(OMNode omNode) {
+ this.appendChild((Node)omNode);
+ }
+
+
+ public void buildNext() {
+ if(!this.done)
+ builder.next();
+ }
+
+ public Iterator getChildren() {
+ return new OMChildrenIterator(this.firstChild);
+ }
+
+ public Iterator getChildrenWithName(QName elementQName) throws OMException {
+ // TODO Cannot use OMChildrenQNameIterator since it uses llom.ElementImpl
+ // TODO
+ throw new UnsupportedOperationException("TODO");
+ }
+
+ public OMElement getFirstChildWithName(QName elementQName)
+ throws OMException {
+ //TODO
+ throw new UnsupportedOperationException("TODO");
+ }
+
+ public OMNode getFirstOMChild() {
+ return this.firstChild;
+ }
+
+ public void setFirstChild(OMNode omNode) {
+ this.firstChild = (ChildNode) omNode;
+ }
+
+
+ ///
+ ///DOM Node methods
+ ///
+
+ public NodeList getChildNodes() {
+ return new NodeListImpl(this, this.getNamespaceURI(),this.getLocalName());
+ }
+
+ public Node getFirstChild() {
+ return this.firstChild;
+ }
+
+ public Node getLastChild() {
+ return this.lastChild;
+ }
+
+ public boolean hasChildNodes() {
+ return this.firstChild != null;
+ }
+
+ /**
+ * Inserts newChild before the refChild
+ * If the refChild is null then the newChild is nade the last child
+ */
+ public Node insertBefore(Node newChild, Node refChild) throws DOMException {
+
+ ChildNode newDomChild = (ChildNode)newChild;
+ ChildNode refDomChild = (ChildNode)refChild;
+
+ if(this == newChild || !isAncestor(newChild)) {
+ throw new DOMException(DOMException.HIERARCHY_REQUEST_ERR,
+ DOMMessageFormatter.formatMessage(
+ DOMMessageFormatter.DOM_DOMAIN,
+ "HIERARCHY_REQUEST_ERR", null));
+ }
+
+ if(!this.ownerNode.equals(newDomChild.ownerNode)) {
+ throw new DOMException(DOMException.WRONG_DOCUMENT_ERR,
+ DOMMessageFormatter.formatMessage(
+ DOMMessageFormatter.DOM_DOMAIN,
+ "WRONG_DOCUMENT_ERR", null));
+ }
+
+ if(this.isReadonly()) {
+ throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR,
+ DOMMessageFormatter.formatMessage(
+ DOMMessageFormatter.DOM_DOMAIN,
+ "NO_MODIFICATION_ALLOWED_ERR", null));
+ }
+
+ if(refChild == null) { //Append the child to the end of the list
+ this.lastChild.nextSibling = newDomChild;
+ newDomChild.previousSubling = this.lastChild;
+
+ this.lastChild = newDomChild;
+ return newChild;
+ } else {
+ Iterator children = this.getChildren();
+ boolean found = false;
+ while(children.hasNext()) {
+ ChildNode tempNode = (ChildNode)children.next();
+
+ if(tempNode.equals(refChild)) {
+ //RefChild found
+ if(tempNode.isFirstChild()) { //If the refChild is the first child
+
+ if(newChild instanceof DocumentFragmentimpl) {
+ //The new child is a DocumentFragment
+ DocumentFragmentimpl docFrag = (DocumentFragmentimpl)newChild;
+ this.firstChild = docFrag.firstChild;
+ docFrag.lastChild.nextSibling = refDomChild;
+ refDomChild.previousSubling = docFrag.lastChild.nextSibling;
+
+ } else {
+
+ //Make the newNode the first Child
+ this.firstChild = newDomChild;
+
+ newDomChild.nextSibling = refDomChild;
+ refDomChild.previousSubling = newDomChild;
+
+ newDomChild.previousSubling = null; //Just to be sure :-)
+ }
+ } else { //If the refChild is not the fist child
+ ChildNode previousNode = refDomChild.previousSubling;
+
+ if(newChild instanceof DocumentFragmentimpl) {
+ //the newChild is a document fragment
+ DocumentFragmentimpl docFrag = (DocumentFragmentimpl)newChild;
+
+ previousNode.nextSibling = docFrag.firstChild;
+ docFrag.firstChild.previousSubling = previousNode;
+
+ docFrag.lastChild.nextSibling = refDomChild;
+ refDomChild.previousSubling = docFrag.lastChild;
+ } else {
+
+ previousNode.nextSibling = newDomChild;
+ newDomChild.previousSubling = previousNode;
+
+ newDomChild.nextSibling = refDomChild;
+ refDomChild.previousSubling = newDomChild;
+ }
+
+ }
+ found = true;
+ break;
+ }
+ }
+
+ if(!found) {
+ throw new DOMException(DOMException.NOT_FOUND_ERR,
+ DOMMessageFormatter.formatMessage(
+ DOMMessageFormatter.DOM_DOMAIN,
+ "NOT_FOUND_ERR", null));
+ }
+ return newChild;
+ }
+ }
+
+ /**
+ * Replaces the oldChild with the newChild
+ */
+ public Node replaceChild(Node newChild, Node oldChild) throws DOMException {
+ ChildNode newDomChild = (ChildNode)newChild;
+ ChildNode oldDomChild = (ChildNode)oldChild;
+
+ if(this == newChild || !isAncestor(newChild)) {
+ throw new DOMException(DOMException.HIERARCHY_REQUEST_ERR,
+ DOMMessageFormatter.formatMessage(
+ DOMMessageFormatter.DOM_DOMAIN,
+ "HIERARCHY_REQUEST_ERR", null));
+ }
+
+ if(!this.ownerNode.equals(newDomChild.ownerNode)) {
+ throw new DOMException(DOMException.WRONG_DOCUMENT_ERR,
+ DOMMessageFormatter.formatMessage(
+ DOMMessageFormatter.DOM_DOMAIN,
+ "WRONG_DOCUMENT_ERR", null));
+ }
+
+ if (this.isReadonly()) {
+ throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR,
+ DOMMessageFormatter.formatMessage(
+ DOMMessageFormatter.DOM_DOMAIN,
+ "NO_MODIFICATION_ALLOWED_ERR", null));
+ }
+
+ Iterator children = this.getChildren();
+ boolean found = false;
+ while(children.hasNext()) {
+ ChildNode tempNode = (ChildNode)children.next();
+ if(tempNode.equals(oldChild)) {
+ if(newChild instanceof DocumentFragmentimpl) {
+ DocumentFragmentimpl docFrag = (DocumentFragmentimpl)newDomChild;
+ docFrag.firstChild.previousSubling = oldDomChild.previousSubling;
+
+ } else {
+ newDomChild.nextSibling = oldDomChild.nextSibling;
+ newDomChild.previousSubling = oldDomChild.previousSubling;
+
+ oldDomChild.previousSubling.nextSibling = newDomChild;
+ oldDomChild.nextSibling.previousSubling = newDomChild;
+ }
+ found = true;
+
+ //remove the old child's references to this tree
+ oldDomChild.nextSibling = null;
+ oldDomChild.previousSubling = null;
+ }
+ }
+
+
+ if(!found)
+ throw new DOMException(DOMException.NOT_FOUND_ERR,
+ DOMMessageFormatter.formatMessage(
+ DOMMessageFormatter.DOM_DOMAIN,
+ "NOT_FOUND_ERR", null));
+
+ return oldChild;
+ }
+
+
+ /**
+ * Removes the given child from the DOM Tree
+ */
+ public Node removeChild(Node oldChild) throws DOMException {
+ //Check if this node is readonly
+ if(this.isReadonly()) {
+ throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR,
+ DOMMessageFormatter.formatMessage(
+ DOMMessageFormatter.DOM_DOMAIN,
+ "NO_MODIFICATION_ALLOWED_ERR", null));
+ }
+
+ //Check if the Child is there
+ Iterator children = this.getChildren();
+ boolean childFound = false;
+ while(children.hasNext()) {
+ ChildNode tempNode = (ChildNode)children.next();
+ if(tempNode.equals(oldChild)) {
+ //Child found
+ ChildNode oldDomChild = (ChildNode)oldChild;
+ ChildNode privChild = oldDomChild.previousSubling;
+
+ privChild.nextSibling = oldDomChild.nextSibling;
+ oldDomChild.nextSibling.previousSubling = privChild;
+
+ //Remove old child's references to this tree
+ oldDomChild.nextSibling = null;
+ oldDomChild.previousSubling = null;
+
+ childFound = true;
+ }
+ }
+
+ if(!childFound)
+ throw new DOMException(DOMException.NOT_FOUND_ERR,
+ DOMMessageFormatter.formatMessage(
+ DOMMessageFormatter.DOM_DOMAIN,
+ "NOT_FOUND_ERR", null));
+
+ return oldChild;
+ }
+
+
+
+ private boolean isAncestor(Node newNode) {
+
+ //TODO isAncestor
+ return true;
+ }
+
+}
Added: webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/om/impl/dom/TextImpl.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/om/impl/dom/TextImpl.java?rev=306585&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/om/impl/dom/TextImpl.java (added)
+++ webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/om/impl/dom/TextImpl.java Thu Oct 6 04:03:44 2005
@@ -0,0 +1,133 @@
+package org.apache.axis2.om.impl.dom;
+
+import org.apache.axis2.om.OMException;
+import org.apache.axis2.om.OMNode;
+import org.apache.axis2.om.impl.OMOutputImpl;
+import org.w3c.dom.DOMException;
+import org.w3c.dom.Node;
+import org.w3c.dom.Text;
+
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamWriter;
+
+/**
+ * @author Ruchith Fernando (ruchith.fernando@gmail.com)
+ */
+public class TextImpl extends CharacterImpl implements Text {
+
+ /**
+ * @param ownerNode
+ */
+ public TextImpl(DocumentImpl ownerNode) {
+ super(ownerNode);
+ }
+
+ /**
+ * @param ownerNode
+ * @param value
+ */
+ public TextImpl(DocumentImpl ownerNode, String value) {
+ super(ownerNode, value);
+ }
+
+ /**
+ * Breaks this node into two nodes at the specified offset, keeping both
+ * in the tree as siblings. After being split, this node will contain all
+ * the content up to the offset point. A new node of the same type, which
+ * contains all the content at and after the offset point, is returned. If
+ * the original node had a parent node, the new node is inserted as the
+ * next sibling of the original node. When the offset is equal to the
+ * length of this node, the new node has no data.
+ */
+ 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));
+ }
+ if(offset < 0 || offset > this.textValue.length()) {
+ throw new DOMException(DOMException.INDEX_SIZE_ERR,
+ DOMMessageFormatter.formatMessage(
+ DOMMessageFormatter.DOM_DOMAIN, "INDEX_SIZE_ERR",
+ null));
+ }
+ String newValue = this.textValue.substring(offset);
+ this.deleteData(offset, this.textValue.length());
+
+ TextImpl newText = (TextImpl)this.getOwnerDocument().createTextNode(newValue);
+ newText.setParent(this.parentNode);
+
+ this.insertSiblingAfter(newText);
+
+
+ return null;
+ }
+
+ ///
+ ///org.w3c.dom.Node methods
+ ///
+ public String getNodeName() {
+ return "#text";
+ }
+ public short getNodeType() {
+ return OMNode.TEXT_NODE;
+ }
+
+ ///
+ ///OMNode methods
+ ///
+
+ /* (non-Javadoc)
+ * @see org.apache.axis2.om.OMNode#getType()
+ */
+ public int getType() throws OMException {
+ return Node.TEXT_NODE;
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.axis2.om.OMNode#setType(int)
+ */
+ public void setType(int nodeType) throws OMException {
+ //do not do anything here
+ //Its not clear why we should let someone change the type of a node
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.apache.axis2.om.OMNode#serialize(org.apache.axis2.om.OMOutput)
+ */
+ public void serialize(OMOutputImpl omOutput) throws XMLStreamException {
+ // TODO
+ throw new UnsupportedOperationException("TODO");
+ }
+
+
+ public void serialize(XMLStreamWriter xmlWriter) throws XMLStreamException {
+ // TODO
+ throw new UnsupportedOperationException("TODO");
+ }
+
+ public void serializeAndConsume(OMOutputImpl omOutput) throws XMLStreamException {
+ // TODO
+ throw new UnsupportedOperationException("TODO");
+ }
+
+ public void serializeAndConsume(XMLStreamWriter xmlWriter) throws XMLStreamException {
+ // TODO
+ throw new UnsupportedOperationException("TODO");
+ }
+
+ public void doOptimize(boolean value) {
+ throw new UnsupportedOperationException("TODO");
+ }
+ public boolean isOptimized() {
+ throw new UnsupportedOperationException("TODO");
+ }
+
+ public void setOptimize(boolean value) {
+ // TODO
+ throw new UnsupportedOperationException("TODO");
+ }
+
+}