You are viewing a plain text version of this content. The canonical link for it is here.
Posted to axis-cvs@ws.apache.org by ch...@apache.org on 2005/03/15 11:56:40 UTC
svn commit: r157534 [1/4] - in
webservices/axis/trunk/archive/java/scratch/Thilina/MTOM: lib/
src/java/org/apache/axis/impl/ src/java/org/apache/axis/om/impl/
src/java/org/apache/axis/om/impl/llom/
src/java/org/apache/axis/om/impl/llom/builder/
src/java/org/apache/axis/om/impl/llom/exception/
src/java/org/apache/axis/om/impl/llom/mtom/
src/java/org/apache/axis/om/impl/llom/serialize/
src/java/org/apache/axis/om/impl/llom/traverse/ src/test-resources/
src/test/org/apache/axis/om/ src/test/org/apache/axis/om/impl/
src/test/org/apache/axis/om/impl/llom/
src/test/org/apache/axis/om/impl/llom/mtom/
Author: chinthaka
Date: Tue Mar 15 02:56:31 2005
New Revision: 157534
URL: http://svn.apache.org/viewcvs?view=rev&rev=157534
Log:
Applying patch for Thilina
Added:
webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/lib/commons-logging-1.0.3.jar (with props)
webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/om/impl/
webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/om/impl/llom/
webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/om/impl/llom/OMAttributeImpl.java
webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/om/impl/llom/OMDocument.java
webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/om/impl/llom/OMElementImpl.java
webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/om/impl/llom/OMNamedNodeImpl.java
webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/om/impl/llom/OMNamespaceImpl.java
webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/om/impl/llom/OMNavigator.java
webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/om/impl/llom/OMNodeImpl.java
webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/om/impl/llom/OMStAXWrapper.java
webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/om/impl/llom/OMTextImpl.java
webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/om/impl/llom/SOAPBodyImpl.java
webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/om/impl/llom/SOAPEnvelopeImpl.java
webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/om/impl/llom/SOAPFaultImpl.java
webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/om/impl/llom/SOAPHeaderBlockImpl.java
webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/om/impl/llom/SOAPHeaderImpl.java
webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/om/impl/llom/builder/
webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/om/impl/llom/builder/MTOMStAXSOAPModelBuilder.java
webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/om/impl/llom/builder/StAXBuilder.java
webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/om/impl/llom/builder/StAXOMBuilder.java
webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/om/impl/llom/builder/StAXSOAPModelBuilder.java
webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/om/impl/llom/exception/
webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/om/impl/llom/exception/OMBuilderException.java
webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/om/impl/llom/exception/OMStreamingException.java
webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/om/impl/llom/mtom/
webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/om/impl/llom/mtom/ByteArrayDataSource.java
webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/om/impl/llom/mtom/MIMEParser.java
webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/om/impl/llom/mtom/MTOMBuilder.java
webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/om/impl/llom/mtom/MTOMXMLStreamWriter.java
webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/om/impl/llom/mtom/OMBlob.java
webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/om/impl/llom/serialize/
webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/om/impl/llom/serialize/SimpleOMSerializer.java
webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/om/impl/llom/traverse/
webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/om/impl/llom/traverse/OMChildrenIterator.java
webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/om/impl/llom/traverse/OMChildrenQNameIterator.java
webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/om/impl/llom/traverse/OMChildrenWithSpecificAttributeIterator.java
webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/test/org/apache/axis/om/
webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/test/org/apache/axis/om/impl/
webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/test/org/apache/axis/om/impl/llom/
webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/test/org/apache/axis/om/impl/llom/OMTextImplTest.java
webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/test/org/apache/axis/om/impl/llom/mtom/
webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/test/org/apache/axis/om/impl/llom/mtom/MTOMTest.java
Removed:
webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/impl/
Modified:
webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/test-resources/OMSerializeMTOMOut.txt
Added: webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/lib/commons-logging-1.0.3.jar
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/lib/commons-logging-1.0.3.jar?view=auto&rev=157534
==============================================================================
Binary file - no diff available.
Propchange: webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/lib/commons-logging-1.0.3.jar
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Added: webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/om/impl/llom/OMAttributeImpl.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/om/impl/llom/OMAttributeImpl.java?view=auto&rev=157534
==============================================================================
--- webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/om/impl/llom/OMAttributeImpl.java (added)
+++ webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/om/impl/llom/OMAttributeImpl.java Tue Mar 15 02:56:31 2005
@@ -0,0 +1,134 @@
+/*
+ * Copyright 2004,2005 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.axis.om.impl.llom;
+
+import org.apache.axis.om.OMAttribute;
+import org.apache.axis.om.OMNamespace;
+
+import javax.xml.namespace.QName;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+/**
+ * Class OMAttributeImpl
+ */
+public class OMAttributeImpl implements OMAttribute {
+ /**
+ * Field localName
+ */
+ private String localName;
+
+ /**
+ * Field value
+ */
+ private String value;
+
+ /**
+ * Field namespace
+ */
+ private OMNamespace namespace;
+
+ /**
+ * Field QUOTE_ENTITY
+ */
+ private static String QUOTE_ENTITY = """;
+
+ /**
+ * Field matcher
+ */
+ private static Matcher matcher = Pattern.compile("\"").matcher(null);
+
+ /**
+ * Constructor OMAttributeImpl
+ *
+ * @param localName
+ * @param ns
+ * @param value
+ */
+ public OMAttributeImpl(String localName, OMNamespace ns, String value) {
+ setLocalName(localName);
+ setValue(value);
+ setOMNamespace(ns);
+ }
+
+ /**
+ * Method getQName
+ *
+ * @return
+ */
+ public QName getQName() {
+ String namespaceName = (namespace != null)
+ ? namespace.getName()
+ : null;
+ return new QName(namespaceName, localName);
+ }
+
+ // -------- Getters and Setters
+
+ /**
+ * Method getLocalName
+ *
+ * @return
+ */
+ public String getLocalName() {
+ return localName;
+ }
+
+ /**
+ * Method setLocalName
+ *
+ * @param localName
+ */
+ public void setLocalName(String localName) {
+ this.localName = localName;
+ }
+
+ /**
+ * Method getValue
+ *
+ * @return
+ */
+ public String getValue() {
+ return value;
+ }
+
+ /**
+ * Method setValue
+ *
+ * @param value
+ */
+ public void setValue(String value) {
+ this.value = value;
+ }
+
+ /**
+ * Method setOMNamespace
+ *
+ * @param omNamespace
+ */
+ public void setOMNamespace(OMNamespace omNamespace) {
+ this.namespace = omNamespace;
+ }
+
+ /**
+ * Method getNamespace
+ *
+ * @return
+ */
+ public OMNamespace getNamespace() {
+ return namespace;
+ }
+}
Added: webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/om/impl/llom/OMDocument.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/om/impl/llom/OMDocument.java?view=auto&rev=157534
==============================================================================
--- webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/om/impl/llom/OMDocument.java (added)
+++ webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/om/impl/llom/OMDocument.java Tue Mar 15 02:56:31 2005
@@ -0,0 +1,71 @@
+/*
+ * Copyright 2004,2005 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.axis.om.impl.llom;
+
+import org.apache.axis.om.OMElement;
+import org.apache.axis.om.OMXMLParserWrapper;
+
+/**
+ * Class OMDocument
+ */
+public class OMDocument {
+ /**
+ * Field rootElement
+ */
+ private OMElement rootElement;
+
+ /**
+ * Field parserWrapper
+ */
+ private OMXMLParserWrapper parserWrapper;
+
+ /**
+ * @param rootElement
+ * @param parserWrapper
+ */
+ public OMDocument(OMElement rootElement, OMXMLParserWrapper parserWrapper) {
+ this.rootElement = rootElement;
+ this.parserWrapper = parserWrapper;
+ }
+
+ /**
+ * @param parserWrapper
+ */
+ public OMDocument(OMXMLParserWrapper parserWrapper) {
+ this.parserWrapper = parserWrapper;
+ }
+
+ /**
+ * Method getRootElement
+ *
+ * @return
+ */
+ public OMElement getRootElement() {
+ if (rootElement == null) {
+ parserWrapper.next();
+ }
+ return rootElement;
+ }
+
+ /**
+ * Method setRootElement
+ *
+ * @param rootElement
+ */
+ public void setRootElement(OMElement rootElement) {
+ this.rootElement = rootElement;
+ }
+}
Added: webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/om/impl/llom/OMElementImpl.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/om/impl/llom/OMElementImpl.java?view=auto&rev=157534
==============================================================================
--- webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/om/impl/llom/OMElementImpl.java (added)
+++ webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/om/impl/llom/OMElementImpl.java Tue Mar 15 02:56:31 2005
@@ -0,0 +1,836 @@
+/*
+ * Copyright 2004,2005 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.axis.om.impl.llom;
+
+import org.apache.axis.om.OMAttribute;
+import org.apache.axis.om.OMConstants;
+import org.apache.axis.om.OMElement;
+import org.apache.axis.om.OMException;
+import org.apache.axis.om.OMFactory;
+import org.apache.axis.om.OMNamespace;
+import org.apache.axis.om.OMNode;
+import org.apache.axis.om.OMText;
+import org.apache.axis.om.OMXMLParserWrapper;
+import org.apache.axis.om.impl.llom.serialize.StreamWriterToContentHandlerConverter;
+import org.apache.axis.om.impl.llom.serialize.StreamingOMSerializer;
+import org.apache.axis.om.impl.llom.traverse.OMChildrenIterator;
+import org.apache.axis.om.impl.llom.traverse.OMChildrenQNameIterator;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.stream.XMLStreamWriter;
+import java.util.HashMap;
+import java.util.Iterator;
+
+/**
+ * Class OMElementImpl
+ */
+public class OMElementImpl extends OMNamedNodeImpl
+ implements OMElement, OMConstants {
+ /**
+ * Field firstChild
+ */
+ protected OMNode firstChild;
+
+ /**
+ * Field builder
+ */
+ protected OMXMLParserWrapper builder;
+
+ /**
+ * Field namespaces
+ */
+ private HashMap namespaces = null;
+
+ /**
+ * Field attributes
+ */
+ private HashMap attributes = null;
+
+ /**
+ * Field log
+ */
+ private Log log = LogFactory.getLog(getClass());
+
+ /**
+ * Field noPrefixNamespaceCounter
+ */
+ private int noPrefixNamespaceCounter = 0;
+
+ /**
+ * Constructor OMElementImpl
+ *
+ * @param localName
+ * @param ns
+ * @param parent
+ * @param builder
+ */
+ public OMElementImpl(String localName, OMNamespace ns, OMElement parent,
+ OMXMLParserWrapper builder) {
+ super(localName, null, parent);
+ if (ns != null) {
+ setNamespace(handleNamespace(ns));
+ }
+ this.builder = builder;
+ firstChild = null;
+ }
+
+ /**
+ * @param parent
+ * @param parent
+ */
+ protected OMElementImpl(OMElement parent) {
+ super(parent);
+ this.done = true;
+ }
+
+ /**
+ * Constructor OMElementImpl
+ *
+ * @param localName
+ * @param ns
+ */
+ public OMElementImpl(String localName, OMNamespace ns) {
+ super(localName, null, null);
+ this.done = true;
+ if (ns != null) {
+ setNamespace(handleNamespace(ns));
+ }
+ }
+
+ /**
+ * Here it is assumed that this QName passed, at least contains the localName for this element
+ *
+ * @param qname
+ * @param parent
+ * @throws OMException
+ */
+ public OMElementImpl(QName qname, OMElement parent) throws OMException {
+ super(qname.getLocalPart(), null, parent);
+ this.done = true;
+ handleNamespace(qname, parent);
+ }
+
+ /**
+ * Method handleNamespace
+ *
+ * @param qname
+ * @param parent
+ */
+ private void handleNamespace(QName qname, OMElement parent) {
+ OMNamespace ns;
+
+ // first try to find a namespace from the scope
+ String namespaceURI = qname.getNamespaceURI();
+ if (!"".equals(namespaceURI)) {
+ ns = findInScopeNamespace(qname.getNamespaceURI(),
+ qname.getPrefix());
+ } else {
+ if (parent != null) {
+ ns = parent.getNamespace();
+ } else {
+ throw new OMException(
+ "Element can not be declared without a namespaceURI. Every Element should be namespace qualified");
+ }
+ }
+
+ /**
+ * What is left now is
+ * 1. nsURI = null & parent != null, but ns = null
+ * 2. nsURI != null, (parent doesn't have an ns with given URI), but ns = null
+ */
+ if ((ns == null) && !"".equals(namespaceURI)) {
+ String prefix = qname.getPrefix();
+ if (!"".equals(prefix)) {
+ ns = declareNamespace(namespaceURI, prefix);
+ } else {
+ ns = declareNamespace(namespaceURI, getNextNamespacePrefix());
+ }
+ }
+ if (ns == null) {
+ throw new OMException(
+ "Element can not be declared without a namespaceURI. Every Element should be namespace qualified");
+ }
+ this.setNamespace(ns);
+ }
+
+ /**
+ * Method handleNamespace
+ *
+ * @param ns
+ * @return
+ */
+ private OMNamespace handleNamespace(OMNamespace ns) {
+ OMNamespace namespace = findInScopeNamespace(ns.getName(),
+ ns.getPrefix());
+ if (namespace == null) {
+ namespace = declareNamespace(ns);
+ }
+ return namespace;
+ }
+
+ /**
+ * This will add child to the element. One can decide whether he append the child or he adds to the
+ * front of the children list
+ *
+ * @param child
+ */
+ public void addChild(OMNode child) {
+ addChild((OMNodeImpl) child);
+ }
+
+ /**
+ * This will search for children with a given QName and will return an iterator to traverse through
+ * the OMNodes.
+ * This QName can contain any combination of prefix, localname and URI
+ *
+ * @param elementQName
+ * @return
+ * @throws org.apache.axis.om.OMException
+ * @throws OMException
+ */
+ public Iterator getChildrenWithName(QName elementQName) throws OMException {
+ return new OMChildrenQNameIterator((OMNodeImpl) getFirstChild(),
+ elementQName);
+ }
+
+ /**
+ * Method getChildWithName
+ *
+ * @param elementQName
+ * @return
+ * @throws OMException
+ */
+ public OMNode getChildWithName(QName elementQName) throws OMException {
+ OMChildrenQNameIterator omChildrenQNameIterator =
+ new OMChildrenQNameIterator((OMNodeImpl) getFirstChild(),
+ elementQName);
+ OMNode omNode = null;
+ if (omChildrenQNameIterator.hasNext()) {
+ omNode = (OMNode) omChildrenQNameIterator.next();
+ }
+ return omNode;
+ }
+
+ /**
+ * Method addChild
+ *
+ * @param child
+ */
+ private void addChild(OMNodeImpl child) {
+ if ((firstChild == null) && !done) {
+ builder.next();
+ }
+ child.setPreviousSibling(null);
+ child.setNextSibling(firstChild);
+ if (firstChild != null) {
+ OMNodeImpl firstChildImpl = (OMNodeImpl) firstChild;
+ firstChildImpl.setPreviousSibling(child);
+ }
+ child.setParent(this);
+ firstChild = child;
+ }
+
+ /**
+ * This will give the next sibling. This can be an OMAttribute for OMAttribute or OMText or OMELement for others.
+ *
+ * @return
+ * @throws org.apache.axis.om.OMException
+ * @throws OMException
+ */
+ public OMNode getNextSibling() throws OMException {
+ while (!done) {
+ builder.next();
+ }
+ return super.getNextSibling();
+ }
+
+ /**
+ * This returns a collection of this element.
+ * Children can be of types OMElement, OMText.
+ *
+ * @return
+ */
+ public Iterator getChildren() {
+ return new OMChildrenIterator(getFirstChild());
+ }
+
+ /**
+ * THis will create a namespace in the current element scope
+ *
+ * @param uri
+ * @param prefix
+ * @return
+ */
+ public OMNamespace declareNamespace(String uri, String prefix) {
+ OMNamespaceImpl ns = new OMNamespaceImpl(uri, prefix);
+ return declareNamespace(ns);
+ }
+
+ /**
+ * Method setValue
+ *
+ * @param value
+ */
+ public void setValue(String value) {
+ OMText txt = OMFactory.newInstance().createText(value);
+ this.addChild(txt);
+ }
+
+ /**
+ * @param namespace
+ * @return
+ */
+ public OMNamespace declareNamespace(OMNamespace namespace) {
+ if (namespaces == null) {
+ this.namespaces = new HashMap(5);
+ }
+ namespaces.put(namespace.getPrefix(), namespace);
+ return namespace;
+ }
+
+ /**
+ * This will find a namespace with the given uri and prefix, in the scope of the docuemnt.
+ * This will start to find from the current element and goes up in the hiararchy until this finds one.
+ * If none is found, return null
+ *
+ * @param uri
+ * @param prefix
+ * @return
+ * @throws org.apache.axis.om.OMException
+ * @throws OMException
+ */
+ public OMNamespace findInScopeNamespace(String uri, String prefix)
+ throws OMException {
+
+ // check in the current element
+ OMNamespace namespace = findDeclaredNamespace(uri, prefix);
+ if (namespace != null) {
+ return namespace;
+ }
+
+ // go up to check with ancestors
+ if (parent != null) {
+ return parent.findInScopeNamespace(uri, prefix);
+ }
+ return null;
+ }
+
+ /**
+ * This will ckeck for the namespace <B>only</B> in the current Element
+ * This can also be used to retrieve the prefix of a known namespace URI
+ *
+ * @param uri
+ * @param prefix
+ * @return
+ * @throws OMException
+ */
+ public OMNamespace findDeclaredNamespace(String uri, String prefix)
+ throws OMException {
+ if (namespaces == null) {
+ return null;
+ }
+ if (prefix == null || "".equals("")) {
+ Iterator namespaceListIterator = namespaces.values().iterator();
+ while (namespaceListIterator.hasNext()) {
+ OMNamespace omNamespace =
+ (OMNamespace) namespaceListIterator.next();
+ if (omNamespace.getName().equals(uri)) {
+ return omNamespace;
+ }
+ }
+ return null;
+ } else {
+ return (OMNamespace) namespaces.get(prefix);
+ }
+ }
+
+ /**
+ * Method getAllDeclaredNamespaces
+ *
+ * @return
+ */
+ public Iterator getAllDeclaredNamespaces() {
+ if (namespaces == null) {
+ return null;
+ }
+ return namespaces.values().iterator();
+ }
+
+ /**
+ * This will help to search for an attribute with a given QName within this Element
+ *
+ * @param qname
+ * @return
+ * @throws org.apache.axis.om.OMException
+ * @throws OMException
+ */
+ public OMAttribute getAttributeWithQName(QName qname) throws OMException {
+ if (attributes == null) {
+ return null;
+ }
+ return (OMAttribute) attributes.get(qname);
+ }
+
+ /**
+ * This will return a List of OMAttributes
+ *
+ * @return
+ */
+ public Iterator getAttributes() {
+ if (attributes == null) {
+ return null;
+ }
+ return attributes.values().iterator();
+ }
+
+ /**
+ * This will insert attribute to this element. Implementor can decide as to insert this
+ * in the front or at the end of set of attributes
+ *
+ * @param attr
+ * @return
+ */
+ public OMAttribute insertAttribute(OMAttribute attr) {
+ if (attributes == null) {
+ this.attributes = new HashMap(5);
+ }
+ attributes.put(attr.getQName(), attr);
+ return attr;
+ }
+
+ /**
+ * Method removeAttribute
+ *
+ * @param attr
+ */
+ public void removeAttribute(OMAttribute attr) {
+ if (attributes != null) {
+ attributes.remove(attr.getQName());
+ }
+ }
+
+ /**
+ * Method insertAttribute
+ *
+ * @param attributeName
+ * @param value
+ * @param ns
+ * @return
+ */
+ public OMAttribute insertAttribute(String attributeName, String value,
+ OMNamespace ns) {
+ OMNamespace namespace = null;
+ if (ns != null) {
+ namespace = findInScopeNamespace(ns.getName(), ns.getPrefix());
+ if (namespace == null) {
+ throw new OMException(
+ "Given OMNamespace(" + ns.getName() + ns.getPrefix()
+ + ") for "
+ + "this attribute is not declared in the scope of this element. First declare the namespace"
+ + " and then use it with the attribute");
+ }
+ }
+ return insertAttribute(new OMAttributeImpl(attributeName, ns, value));
+ }
+
+ /**
+ * Method setBuilder
+ *
+ * @param wrapper
+ */
+ public void setBuilder(OMXMLParserWrapper wrapper) {
+ this.builder = wrapper;
+ }
+
+ /**
+ * Method getBuilder
+ *
+ * @return
+ */
+ public OMXMLParserWrapper getBuilder() {
+ return builder;
+ }
+
+ /**
+ * This will force the parser to proceed, if parser has not yet finished with the XML input
+ */
+ public void buildNext() {
+ builder.next();
+ }
+
+ /**
+ * Method getFirstChild
+ *
+ * @return
+ */
+ public OMNode getFirstChild() {
+ while ((firstChild == null) && !done) {
+ buildNext();
+ }
+ return firstChild;
+ }
+
+ /**
+ * Method setFirstChild
+ *
+ * @param firstChild
+ */
+ public void setFirstChild(OMNode firstChild) {
+ this.firstChild = firstChild;
+ }
+
+ /**
+ * This will remove this information item and its children, from the model completely
+ *
+ * @throws org.apache.axis.om.OMException
+ * @throws OMException
+ */
+ public void detach() throws OMException {
+ if (done) {
+ super.detach();
+ } else {
+ builder.discard(this);
+ }
+ }
+
+ /**
+ * Method isComplete
+ *
+ * @return
+ */
+ public boolean isComplete() {
+ return done;
+ }
+
+ /**
+ * This will return the literal value of the node.
+ * OMText --> the text
+ * OMElement --> local name of the element in String format
+ * OMAttribute --> the value of the attribue
+ *
+ * @return
+ * @throws org.apache.axis.om.OMException
+ * @throws OMException
+ */
+ public String getValue() throws OMException {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * This is to get the type of node, as this is the super class of all the nodes
+ *
+ * @return
+ * @throws org.apache.axis.om.OMException
+ * @throws OMException
+ */
+ public short getType() throws OMException {
+ return OMNode.ELEMENT_NODE;
+ }
+
+ /**
+ * @param cacheOff
+ * @return
+ */
+ public XMLStreamReader getPullParser(boolean cacheOff) {
+ if ((builder == null) && cacheOff) {
+ throw new UnsupportedOperationException(
+ "This element was not created in a manner to be switched");
+ }
+ return new OMStAXWrapper(builder, this, cacheOff);
+ }
+
+ public String getText() {
+ String childText = "";
+ OMNode child = this.getFirstChild();
+ while(child != null){
+ String value = child.getValue();
+ System.out.println("value.length() = " + value.length());
+ if(child.getType() == OMNode.TEXT_NODE && value != null && !"".equals(value.trim())){
+ childText += value.trim();
+ }
+ child = child.getNextSibling();
+ }
+
+ return childText;
+ }
+
+ /**
+ * Method serialize
+ *
+ * @param writer
+ * @param cache
+ * @throws XMLStreamException
+ */
+ public void serialize(XMLStreamWriter writer, boolean cache)
+ throws XMLStreamException {
+ boolean firstElement = false;
+ short builderType = PULL_TYPE_BUILDER; // default is pull type
+ if (builder != null) {
+ builderType = this.builder.getBuilderType();
+ }
+ if ((builderType == PUSH_TYPE_BUILDER)
+ && (builder.getRegisteredContentHandler() == null)) {
+ builder.registerExternalContentHandler(
+ new StreamWriterToContentHandlerConverter(writer));
+
+ // for now only SAX
+ }
+
+ // Special case for the pull type building with cache off
+ // The getPullParser method returns the current elements itself.
+ if (!cache) {
+ if ((firstChild == null) && (nextSibling == null) && !isComplete()
+ && (builderType == PULL_TYPE_BUILDER)) {
+ StreamingOMSerializer streamingOMSerializer =
+ new StreamingOMSerializer();
+ streamingOMSerializer.serialize(this.getPullParser(!cache),
+ writer);
+ return;
+ }
+ }
+ if (!cache) {
+ if (isComplete()) {
+
+ // serialize own normally
+ serializeNormal(writer, cache);
+ if (nextSibling != null) {
+
+ // serilize next sibling
+ nextSibling.serialize(writer, cache);
+ } else {
+ if (parent == null) {
+ return;
+ } else if (parent.isComplete()) {
+ return;
+ } else {
+
+ // do the special serialization
+ // Only the push serializer is left now
+ builder.setCache(cache);
+ builder.next();
+ }
+ }
+ } else if (firstChild != null) {
+ serializeStartpart(writer);
+ log.info("Serializing the Element from " + localName
+ + " the generated OM tree");
+ firstChild.serialize(writer, cache);
+ serializeEndpart(writer);
+ } else {
+
+ // do the special serilization
+ // Only the push serializer is left now
+ builder.setCache(cache);
+ serializeStartpart(writer);
+ builder.next();
+ serializeEndpart(writer);
+ }
+ } else {
+
+ // serialize own normally
+ serializeNormal(writer, cache);
+
+ // serialize the siblings if this is not the first element
+ if (!firstElement) {
+ OMNode nextSibling = this.getNextSibling();
+ if (nextSibling != null) {
+ nextSibling.serialize(writer, cache);
+ }
+ }
+ }
+ }
+
+ /**
+ * Method serializeStartpart
+ *
+ * @param writer
+ * @throws XMLStreamException
+ */
+ private void serializeStartpart(XMLStreamWriter writer)
+ throws XMLStreamException {
+ String nameSpaceName = null;
+ String writer_prefix = null;
+ String prefix = null;
+ if (ns != null) {
+ nameSpaceName = ns.getName();
+ writer_prefix = writer.getPrefix(nameSpaceName);
+ prefix = ns.getPrefix();
+ if (nameSpaceName != null) {
+ if (writer_prefix != null) {
+ writer.writeStartElement(nameSpaceName,
+ this.getLocalName());
+ } else {
+ if (prefix != null) {
+ writer.writeStartElement(prefix, this.getLocalName(),
+ nameSpaceName);
+ writer.writeNamespace(prefix, nameSpaceName);
+ writer.setPrefix(prefix, nameSpaceName);
+ } else {
+ writer.writeStartElement(nameSpaceName,
+ this.getLocalName());
+ writer.writeDefaultNamespace(nameSpaceName);
+ writer.setDefaultNamespace(nameSpaceName);
+ }
+ }
+ } else {
+ writer.writeStartElement(this.getLocalName());
+// throw new OMException(
+// "Non namespace qualified elements are not allowed");
+ }
+ } else {
+ writer.writeStartElement(this.getLocalName());
+// throw new OMException(
+// "Non namespace qualified elements are not allowed");
+ }
+
+ // add the elements attributes
+ if (attributes != null) {
+ Iterator attributesList = attributes.values().iterator();
+ while (attributesList.hasNext()) {
+ serializeAttribute((OMAttribute) attributesList.next(), writer);
+ }
+ }
+
+ // add the namespaces
+ Iterator namespaces = this.getAllDeclaredNamespaces();
+ if (namespaces != null) {
+ while (namespaces.hasNext()) {
+ serializeNamespace((OMNamespace) namespaces.next(), writer);
+ }
+ }
+ }
+
+ /**
+ * Method serializeEndpart
+ *
+ * @param writer
+ * @throws XMLStreamException
+ */
+ private void serializeEndpart(XMLStreamWriter writer)
+ throws XMLStreamException {
+ writer.writeEndElement();
+ }
+
+ /**
+ * Method serializeNormal
+ *
+ * @param writer
+ * @param cache
+ * @throws XMLStreamException
+ */
+ private void serializeNormal(XMLStreamWriter writer, boolean cache)
+ throws XMLStreamException {
+ serializeStartpart(writer);
+ OMNode firstChild = getFirstChild();
+ if (firstChild != null) {
+ firstChild.serialize(writer, cache);
+ }
+ serializeEndpart(writer);
+ }
+
+ /**
+ * Method serializeAttribute
+ *
+ * @param attr
+ * @param writer
+ * @throws XMLStreamException
+ */
+ protected void serializeAttribute(OMAttribute attr, XMLStreamWriter writer)
+ throws XMLStreamException {
+
+ // first check whether the attribute is associated with a namespace
+ OMNamespace ns = attr.getNamespace();
+ String prefix = null;
+ String namespaceName = null;
+ if (ns != null) {
+
+ // add the prefix if it's availble
+ prefix = ns.getPrefix();
+ namespaceName = ns.getName();
+ if (prefix != null) {
+ writer.writeAttribute(prefix, namespaceName,
+ attr.getLocalName(), attr.getValue());
+ } else {
+ writer.writeAttribute(namespaceName, attr.getLocalName(),
+ attr.getValue());
+ }
+ } else {
+ writer.writeAttribute(attr.getLocalName(), attr.getValue());
+ }
+ }
+
+ /**
+ * Method serializeNamespace
+ *
+ * @param namespace
+ * @param writer
+ * @throws XMLStreamException
+ */
+ protected void serializeNamespace(
+ OMNamespace namespace, XMLStreamWriter writer)
+ throws XMLStreamException {
+ if (namespace != null) {
+ String uri = namespace.getName();
+ String prefix = writer.getPrefix(uri);
+ String ns_prefix = namespace.getPrefix();
+ if (prefix == null) {
+ writer.writeNamespace(ns_prefix, namespace.getName());
+ writer.setPrefix(ns_prefix, uri);
+ }
+ }
+ }
+
+ /**
+ * Method getNextNamespacePrefix
+ *
+ * @return
+ */
+ private String getNextNamespacePrefix() {
+ return "ns" + ++noPrefixNamespaceCounter;
+ }
+
+ public OMElement getFirstElement() {
+ OMNode node = getFirstChild();
+ while(node != null){
+ if(node.getType() == OMNode.ELEMENT_NODE){
+ return (OMElement)node;
+ }else{
+ node = node.getNextSibling();
+ }
+ }
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.axis.om.OMElement#getNextSiblingElement()
+ */
+ public OMElement getNextSiblingElement() throws OMException {
+ OMNode node = getNextSibling();
+ while(node != null){
+ if(node.getType() == OMNode.ELEMENT_NODE){
+ return (OMElement)node;
+ }else{
+ node = node.getNextSibling();
+ }
+ }
+ return null;
+ }
+
+}
Added: webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/om/impl/llom/OMNamedNodeImpl.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/om/impl/llom/OMNamedNodeImpl.java?view=auto&rev=157534
==============================================================================
--- webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/om/impl/llom/OMNamedNodeImpl.java (added)
+++ webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/om/impl/llom/OMNamedNodeImpl.java Tue Mar 15 02:56:31 2005
@@ -0,0 +1,139 @@
+/*
+ * Copyright 2004,2005 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.axis.om.impl.llom;
+
+import org.apache.axis.om.OMElement;
+import org.apache.axis.om.OMException;
+import org.apache.axis.om.OMNamedNode;
+import org.apache.axis.om.OMNamespace;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamWriter;
+import javax.xml.stream.XMLStreamException;
+
+/**
+ * Class OMNamedNodeImpl
+ */
+public class OMNamedNodeImpl extends OMNodeImpl implements OMNamedNode {
+ /**
+ * Field ns
+ */
+ protected OMNamespace ns;
+
+ /**
+ * Field localName
+ */
+ protected String localName;
+
+ /**
+ * Constructor OMNamedNodeImpl
+ *
+ * @param parent
+ */
+ public OMNamedNodeImpl(OMElement parent) {
+ super(parent);
+ }
+
+ /**
+ * Method serialize
+ *
+ * @param writer
+ * @param cache
+ * @throws javax.xml.stream.XMLStreamException
+ *
+ */
+ public void serialize(XMLStreamWriter writer, boolean cache)
+ throws XMLStreamException {
+ //TODO: do we need to do something here?
+ }
+
+ /**
+ * Constructor OMNamedNodeImpl
+ *
+ * @param localName
+ * @param ns
+ * @param parent
+ */
+ public OMNamedNodeImpl(String localName, OMNamespace ns, OMElement parent) {
+ super(parent);
+ this.localName = localName;
+ this.ns = ns;
+ }
+
+ /**
+ * Method getLocalName
+ *
+ * @return
+ */
+ public String getLocalName() {
+ return localName;
+ }
+
+ /**
+ * Method setLocalName
+ *
+ * @param localName
+ */
+ public void setLocalName(String localName) {
+ this.localName = localName;
+ }
+
+ /**
+ * Method getNamespace
+ *
+ * @return
+ * @throws OMException
+ */
+ public OMNamespace getNamespace() throws OMException {
+ if ((ns == null) && (parent != null)) {
+ ns = parent.getNamespace();
+ }
+ if (ns == null) {
+ throw new OMException(
+ "all elements in a soap message must be namespace qualified");
+ }
+ return ns;
+ }
+
+ /**
+ * Method getNamespaceName
+ *
+ * @return
+ */
+ public String getNamespaceName() {
+ if (ns != null) {
+ return ns.getName();
+ }
+ return null;
+ }
+
+ /**
+ * @param namespace
+ */
+ public void setNamespace(OMNamespace namespace) {
+ this.ns = namespace;
+ }
+
+ /**
+ * Method getQName
+ *
+ * @return
+ */
+ public QName getQName() {
+ QName qName = new QName(ns.getName(), localName, ns.getPrefix());
+ return qName;
+ }
+}
Added: webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/om/impl/llom/OMNamespaceImpl.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/om/impl/llom/OMNamespaceImpl.java?view=auto&rev=157534
==============================================================================
--- webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/om/impl/llom/OMNamespaceImpl.java (added)
+++ webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/om/impl/llom/OMNamespaceImpl.java Tue Mar 15 02:56:31 2005
@@ -0,0 +1,74 @@
+/*
+ * Copyright 2004,2005 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.axis.om.impl.llom;
+
+import org.apache.axis.om.OMNamespace;
+
+/**
+ * Class OMNamespaceImpl
+ */
+public class OMNamespaceImpl implements OMNamespace {
+ /**
+ * Field prefix
+ */
+ private String prefix;
+
+ /**
+ * Field uri
+ */
+ private String uri;
+
+ // private String value;
+
+ /**
+ * @param uri
+ * @param prefix
+ */
+ public OMNamespaceImpl(String uri, String prefix) {
+ this.uri = uri;
+ this.prefix = prefix;
+ }
+
+ /**
+ * Method equals
+ *
+ * @param uri
+ * @param prefix
+ * @return
+ */
+ public boolean equals(String uri, String prefix) {
+ return (((prefix == null) && (this.prefix == null)) || ((prefix != null) && prefix.equals(
+ this.prefix))) && uri.equals(uri);
+ }
+
+ /**
+ * Method getPrefix
+ *
+ * @return
+ */
+ public String getPrefix() {
+ return prefix;
+ }
+
+ /**
+ * Method getName
+ *
+ * @return
+ */
+ public String getName() {
+ return uri;
+ }
+}
Added: webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/om/impl/llom/OMNavigator.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/om/impl/llom/OMNavigator.java?view=auto&rev=157534
==============================================================================
--- webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/om/impl/llom/OMNavigator.java (added)
+++ webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/om/impl/llom/OMNavigator.java Tue Mar 15 02:56:31 2005
@@ -0,0 +1,191 @@
+/*
+ *
+ * Copyright 2004,2005 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.axis.om.impl.llom;
+
+ import org.apache.axis.om.OMElement;
+ import org.apache.axis.om.OMNode;
+
+ /**
+ * Refer to the testClass to find out how to use
+ * features like isNavigable, isComplete and step
+ */
+ public class OMNavigator {
+ /**
+ * Field node
+ */
+ protected OMNode node;
+
+ /**
+ * Field visited
+ */
+ private boolean visited;
+
+ /**
+ * Field next
+ */
+ private OMNode next;
+
+ // root is the starting element. Once the navigator comes back to the
+ // root, the traversal is terminated
+
+ /**
+ * Field root
+ */
+ private OMNode root;
+
+ /**
+ * Field backtracked
+ */
+ private boolean backtracked;
+
+ // flags that tell the status of the navigator
+
+ /**
+ * Field end
+ */
+ private boolean end = false;
+
+ /**
+ * Field start
+ */
+ private boolean start = true;
+
+ /**
+ * Constructor OMNavigator
+ */
+ public OMNavigator() {
+ }
+
+ /**
+ * Constructor OMNavigator
+ *
+ * @param node
+ */
+ public OMNavigator(OMNode node) {
+ init(node);
+ }
+
+ /**
+ * Method init
+ *
+ * @param node
+ */
+ public void init(OMNode node) {
+ next = node;
+ root = node;
+ backtracked = false;
+ }
+
+ /**
+ * get the next node
+ *
+ * @return OMnode in the sequence of preorder traversal. Note however that an element node is
+ * treated slightly diffrently. Once the element is passed it returns the same element in the
+ * next encounter as well
+ */
+ public OMNode next() {
+ if (next == null) {
+ return null;
+ }
+ node = next;
+ visited = backtracked;
+ backtracked = false;
+ updateNextNode();
+
+ // set the starting and ending flags
+ if (root.equals(node)) {
+ if (!start) {
+ end = true;
+ } else {
+ start = false;
+ }
+ }
+ return node;
+ }
+
+ /**
+ * Private method to encapsulate the searching logic
+ */
+ private void updateNextNode() {
+ if ((next instanceof OMElement) && !visited) {
+ OMElementImpl e = (OMElementImpl) next;
+ if (e.firstChild != null) {
+ next = e.firstChild;
+ } else if (e.isComplete()) {
+ backtracked = true;
+ } else {
+ next = null;
+ }
+ } else {
+ OMNode nextSibling = ((OMNodeImpl) next).nextSibling;
+ OMNode parent = next.getParent();
+ if (nextSibling != null) {
+ next = nextSibling;
+ } else if ((parent != null) && parent.isComplete()) {
+ next = parent;
+ backtracked = true;
+ } else {
+ next = null;
+ }
+ }
+ }
+
+ /**
+ * Method visited
+ *
+ * @return
+ */
+ public boolean visited() {
+ return visited;
+ }
+
+ /**
+ * This is a very special method. This allows the navigator to step
+ * once it has reached the existing om. At this point the isNavigable
+ * method will return false but the isComplete method may return false
+ * which means that the navigating the given element is not complete but
+ * the navigator cannot proceed
+ */
+ public void step() {
+ if (!end) {
+ next = node;
+ updateNextNode();
+ }
+ }
+
+ /**
+ * the navigable status
+ *
+ * @return
+ */
+ public boolean isNavigable() {
+ if (end) {
+ return false;
+ } else {
+ return !(next == null);
+ }
+ }
+
+ /**
+ * The completed status
+ *
+ * @return
+ */
+ public boolean isCompleted() {
+ return end;
+ }
+ }
Added: webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/om/impl/llom/OMNodeImpl.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/om/impl/llom/OMNodeImpl.java?view=auto&rev=157534
==============================================================================
--- webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/om/impl/llom/OMNodeImpl.java (added)
+++ webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/om/impl/llom/OMNodeImpl.java Tue Mar 15 02:56:31 2005
@@ -0,0 +1,286 @@
+/*
+ * Copyright 2004,2005 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.axis.om.impl.llom;
+
+import org.apache.axis.om.OMElement;
+import org.apache.axis.om.OMException;
+import org.apache.axis.om.OMNode;
+
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamWriter;
+
+/**
+ * Class OMNodeImpl
+ */
+public abstract class OMNodeImpl implements OMNode {
+ /**
+ * Field parent
+ */
+ protected OMElementImpl parent;
+
+ /**
+ * Field nextSibling
+ */
+ protected OMNodeImpl nextSibling;
+
+ /**
+ * Field previousSibling
+ */
+ protected OMNodeImpl previousSibling;
+
+ /**
+ * Field value
+ */
+ protected String value;
+
+ /**
+ * Field done
+ */
+ protected boolean done = false;
+
+ /**
+ * Field nodeType
+ */
+ protected short nodeType;
+
+ /**
+ * Constructor OMNodeImpl
+ */
+ public OMNodeImpl() {
+ }
+
+ /**
+ * For a node to exist there must be a parent
+ *
+ * @param parent
+ */
+ public OMNodeImpl(OMElement parent) {
+ if ((parent != null) && (parent.getType() == OMNode.ELEMENT_NODE)) {
+ this.parent = (OMElementImpl) parent;
+ }
+ }
+
+ /**
+ * This method should return the immediate parent of the node.
+ * Parent is always an Element
+ *
+ * @return
+ * @throws org.apache.axis.om.OMException
+ * @throws OMException
+ */
+ public OMElement getParent() throws OMException {
+ return parent;
+ }
+
+ /**
+ * Method setParent
+ *
+ * @param element
+ */
+ public void setParent(OMElement element) {
+ if (element instanceof OMNodeImpl) {
+ this.parent = (OMElementImpl) element;
+ }
+ }
+
+ /**
+ * This will give the next sibling. This can be an OMAttribute for OMAttribute or OMText or OMELement for others.
+ *
+ * @return
+ * @throws org.apache.axis.om.OMException
+ * @throws OMException
+ */
+ public OMNode getNextSibling() throws OMException {
+ if ((nextSibling == null) && (parent != null) && !parent.isComplete()) {
+ parent.buildNext();
+ }
+ return nextSibling;
+ }
+
+ /**
+ * Method setNextSibling
+ *
+ * @param node
+ */
+ public void setNextSibling(OMNode node) {
+ this.nextSibling = (OMNodeImpl) node;
+ }
+
+ /**
+ * This will return the literal value of the node.
+ * OMText --> the text
+ * OMElement --> local name of the element in String format
+ * OMAttribute --> the value of the attribue
+ *
+ * @return
+ * @throws org.apache.axis.om.OMException
+ * @throws OMException
+ */
+ public String getValue() throws OMException {
+ return value;
+ }
+
+ /**
+ * Method setValue
+ *
+ * @param value
+ */
+ public void setValue(String value) {
+ this.value = value;
+ }
+
+ /**
+ * this will indicate whether parser has parsed this information item completely or not.
+ * If somethings info are not available in the item, one has to check this attribute to make sure that, this
+ * item has been parsed completely or not.
+ *
+ * @return
+ */
+ public boolean isComplete() {
+ return true;
+ }
+
+ /**
+ * Method setComplete
+ *
+ * @param state
+ */
+ public void setComplete(boolean state) {
+ this.done = state;
+ }
+
+ /**
+ * This will remove this information item and its children, from the model completely
+ *
+ * @throws org.apache.axis.om.OMException
+ * @throws OMException
+ */
+ public void detach() throws OMException {
+ if (parent == null) {
+ throw new OMException(
+ "Elements that doesn't have a parent can not be detached");
+ }
+ OMNodeImpl nextSibling = (OMNodeImpl) getNextSibling();
+ if (previousSibling == null) {
+ parent.setFirstChild(nextSibling);
+ } else {
+ previousSibling.setNextSibling(nextSibling);
+ }
+ if (nextSibling != null) {
+ nextSibling.setPreviousSibling(previousSibling);
+ }
+ }
+
+ /**
+ * This will insert a sibling just after the current information item.
+ *
+ * @param sibling
+ * @throws org.apache.axis.om.OMException
+ * @throws OMException
+ */
+ public void insertSiblingAfter(OMNode sibling) throws OMException {
+ if (parent == null) {
+ throw new OMException();
+ }
+ sibling.setParent(parent);
+ if (sibling instanceof OMNodeImpl) {
+ OMNodeImpl siblingImpl = (OMNodeImpl) sibling;
+ if (nextSibling == null) {
+ getNextSibling();
+ }
+ siblingImpl.setPreviousSibling(this);
+ if (nextSibling != null) {
+ nextSibling.setPreviousSibling(sibling);
+ }
+ sibling.setNextSibling(nextSibling);
+ nextSibling = siblingImpl;
+ }
+ }
+
+ /**
+ * This will insert a sibling just before the current information item
+ *
+ * @param sibling
+ * @throws org.apache.axis.om.OMException
+ * @throws OMException
+ */
+ public void insertSiblingBefore(OMNode sibling) throws OMException {
+ if (parent == null) {
+ throw new OMException();
+ }
+ sibling.setParent(parent);
+ if (sibling instanceof OMNodeImpl) {
+ OMNodeImpl siblingImpl = (OMNodeImpl) sibling;
+ siblingImpl.setPreviousSibling(previousSibling);
+ siblingImpl.setNextSibling(this);
+ if (previousSibling == null) {
+ parent.setFirstChild(siblingImpl);
+ } else {
+ previousSibling.setNextSibling(siblingImpl);
+ }
+ previousSibling = siblingImpl;
+ }
+ }
+
+ /**
+ * This is to get the type of node, as this is the super class of all the nodes
+ *
+ * @return
+ * @throws org.apache.axis.om.OMException
+ * @throws OMException
+ */
+ public short getType() throws OMException {
+ return nodeType;
+ }
+
+ /**
+ * Method setType
+ *
+ * @param nodeType
+ * @throws OMException
+ */
+ public void setType(short nodeType) throws OMException {
+ this.nodeType = nodeType;
+ }
+
+ /**
+ * Method getPreviousSibling
+ *
+ * @return
+ */
+ public OMNode getPreviousSibling() {
+ return previousSibling;
+ }
+
+ /**
+ * Method setPreviousSibling
+ *
+ * @param previousSibling
+ */
+ public void setPreviousSibling(OMNode previousSibling) {
+ this.previousSibling = (OMNodeImpl) previousSibling;
+ }
+
+ /**
+ * Method serialize
+ *
+ * @param writer
+ * @param cache
+ * @throws XMLStreamException
+ */
+ public abstract void serialize(XMLStreamWriter writer, boolean cache)
+ throws XMLStreamException ;
+}