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 as...@apache.org on 2004/10/29 06:15:39 UTC
svn commit: rev 55939 - in webservices/axis/trunk/java/dev/scratch/chinthaka: OM API OM API/src OM API/src/java OM API/src/java/org OM API/src/java/org/apache OM API/src/java/org/apache/axis OM API/src/java/org/apache/axis/om OMAPI_with_Impl/dist OMAPI_with_Impl/lib OMAPI_with_Impl/src/java/org/apache/axis/om/impl OMAPI_with_Impl/src/java/org/apache/axis/om/impl/util OMAPI_with_Impl/src/test/org/apache/axis/om OMAPI_with_Impl/src/test/org/apache/axis/om/util
Author: aslom
Date: Thu Oct 28 21:15:38 2004
New Revision: 55939
Added:
webservices/axis/trunk/java/dev/scratch/chinthaka/OM API/
webservices/axis/trunk/java/dev/scratch/chinthaka/OM API/src/
webservices/axis/trunk/java/dev/scratch/chinthaka/OM API/src/java/
webservices/axis/trunk/java/dev/scratch/chinthaka/OM API/src/java/org/
webservices/axis/trunk/java/dev/scratch/chinthaka/OM API/src/java/org/apache/
webservices/axis/trunk/java/dev/scratch/chinthaka/OM API/src/java/org/apache/axis/
webservices/axis/trunk/java/dev/scratch/chinthaka/OM API/src/java/org/apache/axis/om/
webservices/axis/trunk/java/dev/scratch/chinthaka/OM API/src/java/org/apache/axis/om/MimeHeader.java
webservices/axis/trunk/java/dev/scratch/chinthaka/OM API/src/java/org/apache/axis/om/MimeHeaders.java
webservices/axis/trunk/java/dev/scratch/chinthaka/OM API/src/java/org/apache/axis/om/OMAttribute.java
webservices/axis/trunk/java/dev/scratch/chinthaka/OM API/src/java/org/apache/axis/om/OMElement.java
webservices/axis/trunk/java/dev/scratch/chinthaka/OM API/src/java/org/apache/axis/om/OMException.java
webservices/axis/trunk/java/dev/scratch/chinthaka/OM API/src/java/org/apache/axis/om/OMNamedNode.java
webservices/axis/trunk/java/dev/scratch/chinthaka/OM API/src/java/org/apache/axis/om/OMNamespace.java
webservices/axis/trunk/java/dev/scratch/chinthaka/OM API/src/java/org/apache/axis/om/OMNode.java
webservices/axis/trunk/java/dev/scratch/chinthaka/OM API/src/java/org/apache/axis/om/OMText.java
webservices/axis/trunk/java/dev/scratch/chinthaka/OM API/src/java/org/apache/axis/om/Printable.java
webservices/axis/trunk/java/dev/scratch/chinthaka/OM API/src/java/org/apache/axis/om/SOAPBody.java
webservices/axis/trunk/java/dev/scratch/chinthaka/OM API/src/java/org/apache/axis/om/SOAPBodyElement.java
webservices/axis/trunk/java/dev/scratch/chinthaka/OM API/src/java/org/apache/axis/om/SOAPEnvelope.java
webservices/axis/trunk/java/dev/scratch/chinthaka/OM API/src/java/org/apache/axis/om/SOAPFault.java
webservices/axis/trunk/java/dev/scratch/chinthaka/OM API/src/java/org/apache/axis/om/SOAPHeader.java
webservices/axis/trunk/java/dev/scratch/chinthaka/OM API/src/java/org/apache/axis/om/SOAPHeaderElement.java
webservices/axis/trunk/java/dev/scratch/chinthaka/OM API/src/java/org/apache/axis/om/SOAPMessage.java
webservices/axis/trunk/java/dev/scratch/chinthaka/OMAPI_with_Impl/dist/
webservices/axis/trunk/java/dev/scratch/chinthaka/OMAPI_with_Impl/lib/
webservices/axis/trunk/java/dev/scratch/chinthaka/OMAPI_with_Impl/lib/xpp3-1.1.3.4.M.jar (contents, props changed)
Modified:
webservices/axis/trunk/java/dev/scratch/chinthaka/OMAPI_with_Impl/src/java/org/apache/axis/om/impl/OMAttributeImpl.java
webservices/axis/trunk/java/dev/scratch/chinthaka/OMAPI_with_Impl/src/java/org/apache/axis/om/impl/OMTextImpl.java
webservices/axis/trunk/java/dev/scratch/chinthaka/OMAPI_with_Impl/src/java/org/apache/axis/om/impl/util/OMChildrenQNameIterator.java
webservices/axis/trunk/java/dev/scratch/chinthaka/OMAPI_with_Impl/src/test/org/apache/axis/om/OMElementTest.java
webservices/axis/trunk/java/dev/scratch/chinthaka/OMAPI_with_Impl/src/test/org/apache/axis/om/util/OMNodeBuilder.java
Log:
Eran Chinthaka: a proposed SAAJ like api for OM for Engine/ Handlers developer convenience.
Added: webservices/axis/trunk/java/dev/scratch/chinthaka/OM API/src/java/org/apache/axis/om/MimeHeader.java
==============================================================================
--- (empty file)
+++ webservices/axis/trunk/java/dev/scratch/chinthaka/OM API/src/java/org/apache/axis/om/MimeHeader.java Thu Oct 28 21:15:38 2004
@@ -0,0 +1,60 @@
+/* Copyright 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 java.org.apache.axis.om;
+
+/**
+ * An object that stores a MIME header name and its value. One
+ * or more <CODE>MimeHeader</CODE> objects may be contained in a
+ * <CODE>MimeHeaders</CODE> object.
+ * @see javax.xml.soap.MimeHeaders MimeHeaders
+ */
+public class MimeHeader {
+
+ /**
+ * Constructs a <CODE>MimeHeader</CODE> object initialized
+ * with the given name and value.
+ * @param name a <CODE>String</CODE> giving the
+ * name of the header
+ * @param value a <CODE>String</CODE> giving the
+ * value of the header
+ */
+ public MimeHeader(String name, String value) {
+ this.name = name;
+ this.value = value;
+ }
+
+ /**
+ * Returns the name of this <CODE>MimeHeader</CODE>
+ * object.
+ * @return the name of the header as a <CODE>String</CODE>
+ */
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * Returns the value of this <CODE>MimeHeader</CODE>
+ * object.
+ * @return the value of the header as a <CODE>String</CODE>
+ */
+ public String getValue() {
+ return value;
+ }
+
+ private String name;
+
+ private String value;
+}
Added: webservices/axis/trunk/java/dev/scratch/chinthaka/OM API/src/java/org/apache/axis/om/MimeHeaders.java
==============================================================================
--- (empty file)
+++ webservices/axis/trunk/java/dev/scratch/chinthaka/OM API/src/java/org/apache/axis/om/MimeHeaders.java Thu Oct 28 21:15:38 2004
@@ -0,0 +1,311 @@
+/* Copyright 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 java.org.apache.axis.om;
+
+import javax.xml.soap.MimeHeader;
+import java.util.Iterator;
+import java.util.Vector;
+
+/**
+ * A container for <CODE>MimeHeader</CODE> objects, which
+ * represent the MIME headers present in a MIME part of a
+ * message.</P>
+ *
+ * <P>This class is used primarily when an application wants to
+ * retrieve specific attachments based on certain MIME headers and
+ * values. This class will most likely be used by implementations
+ * of <CODE>AttachmentPart</CODE> and other MIME dependent parts
+ * of the JAXM API.
+ * @see javax.xml.soap.SOAPMessage#getAttachments() SOAPMessage.getAttachments()
+ * @see javax.xml.soap.AttachmentPart AttachmentPart
+ */
+public class MimeHeaders {
+
+ class MatchingIterator implements Iterator {
+
+ private Object nextMatch() {
+
+ label0:
+ while (iterator.hasNext()) {
+ javax.xml.soap.MimeHeader mimeheader = (MimeHeader) iterator.next();
+
+ if (names == null) {
+ return match
+ ? null
+ : mimeheader;
+ }
+
+ for (int i = 0; i < names.length; i++) {
+ if (!mimeheader.getName().equalsIgnoreCase(names[i])) {
+ continue;
+ }
+
+ if (match) {
+ return mimeheader;
+ }
+
+ continue label0;
+ }
+
+ if (!match) {
+ return mimeheader;
+ }
+ }
+
+ return null;
+ }
+
+ public boolean hasNext() {
+
+ if (nextHeader == null) {
+ nextHeader = nextMatch();
+ }
+
+ return nextHeader != null;
+ }
+
+ public Object next() {
+
+ if (nextHeader != null) {
+ Object obj = nextHeader;
+
+ nextHeader = null;
+
+ return obj;
+ }
+
+ if (hasNext()) {
+ return nextHeader;
+ } else {
+ return null;
+ }
+ }
+
+ public void remove() {
+ iterator.remove();
+ }
+
+ private boolean match;
+
+ private Iterator iterator;
+
+ private String names[];
+
+ private Object nextHeader;
+
+ MatchingIterator(String as[], boolean flag) {
+
+ match = flag;
+ names = as;
+ iterator = headers.iterator();
+ }
+ }
+
+ /**
+ * Constructs
+ * a default <CODE>MimeHeaders</CODE> object initialized with
+ * an empty <CODE>Vector</CODE> object.
+ */
+ public MimeHeaders() {
+ headers = new Vector();
+ }
+
+ /**
+ * Returns all of the values for the specified header as an
+ * array of <CODE>String</CODE> objects.
+ * @param name the name of the header for which
+ * values will be returned
+ * @return a <CODE>String</CODE> array with all of the values
+ * for the specified header
+ * @see #setHeader(String, String) setHeader(java.lang.String, java.lang.String)
+ */
+ public String[] getHeader(String name) {
+
+ Vector vector = new Vector();
+
+ for (int i = 0; i < headers.size(); i++) {
+ MimeHeader mimeheader = (MimeHeader) headers.elementAt(i);
+
+ if (mimeheader.getName().equalsIgnoreCase(name)
+ && (mimeheader.getValue() != null)) {
+ vector.addElement(mimeheader.getValue());
+ }
+ }
+
+ if (vector.size() == 0) {
+ return null;
+ } else {
+ String as[] = new String[vector.size()];
+
+ vector.copyInto(as);
+
+ return as;
+ }
+ }
+
+ /**
+ * Replaces the current value of the first header entry whose
+ * name matches the given name with the given value, adding a
+ * new header if no existing header name matches. This method
+ * also removes all matching headers after the first one.
+ *
+ * <P>Note that RFC822 headers can contain only US-ASCII
+ * characters.</P>
+ * @param name a <CODE>String</CODE> with the
+ * name of the header for which to search
+ * @param value a <CODE>String</CODE> with the
+ * value that will replace the current value of the
+ * specified header
+ * @throws IllegalArgumentException if there was a
+ * problem in the mime header name or the value being set
+ * @see #getHeader(String) getHeader(java.lang.String)
+ */
+ public void setHeader(String name, String value) {
+
+ boolean flag = false;
+
+ if ((name == null) || name.equals("")) {
+ throw new IllegalArgumentException(
+ "Illegal MimeHeader name");
+ }
+
+ for (int i = 0; i < headers.size(); i++) {
+ MimeHeader mimeheader = (MimeHeader) headers.elementAt(i);
+
+ if (mimeheader.getName().equalsIgnoreCase(name)) {
+ if (!flag) {
+ headers.setElementAt(new MimeHeader(mimeheader
+ .getName(), value), i);
+
+ flag = true;
+ } else {
+ headers.removeElementAt(i--);
+ }
+ }
+ }
+
+ if (!flag) {
+ addHeader(name, value);
+ }
+ }
+
+ /**
+ * Adds a <CODE>MimeHeader</CODE> object with the specified
+ * name and value to this <CODE>MimeHeaders</CODE> object's
+ * list of headers.
+ *
+ * <P>Note that RFC822 headers can contain only US-ASCII
+ * characters.</P>
+ * @param name a <CODE>String</CODE> with the
+ * name of the header to be added
+ * @param value a <CODE>String</CODE> with the
+ * value of the header to be added
+ * @throws IllegalArgumentException if
+ * there was a problem in the mime header name or value
+ * being added
+ */
+ public void addHeader(String name, String value) {
+
+ if ((name == null) || name.equals("")) {
+ throw new IllegalArgumentException(
+ "Illegal MimeHeader name");
+ }
+
+ int i = headers.size();
+
+ for (int j = i - 1; j >= 0; j--) {
+ MimeHeader mimeheader = (MimeHeader) headers.elementAt(j);
+
+ if (mimeheader.getName().equalsIgnoreCase(name)) {
+ headers.insertElementAt(new MimeHeader(name, value), j + 1);
+
+ return;
+ }
+ }
+
+ headers.addElement(new MimeHeader(name, value));
+ }
+
+ /**
+ * Remove all <CODE>MimeHeader</CODE> objects whose name
+ * matches the the given name.
+ * @param name a <CODE>String</CODE> with the
+ * name of the header for which to search
+ */
+ public void removeHeader(String name) {
+
+ for (int i = 0; i < headers.size(); i++) {
+ MimeHeader mimeheader = (MimeHeader) headers.elementAt(i);
+
+ if (mimeheader.getName().equalsIgnoreCase(name)) {
+ headers.removeElementAt(i--);
+ }
+ }
+ }
+
+ /**
+ * Removes all the header entries from this <CODE>
+ * MimeHeaders</CODE> object.
+ */
+ public void removeAllHeaders() {
+ headers.removeAllElements();
+ }
+
+ /**
+ * Returns all the headers in this <CODE>MimeHeaders</CODE>
+ * object.
+ * @return an <CODE>Iterator</CODE> object over this <CODE>
+ * MimeHeaders</CODE> object's list of <CODE>
+ * MimeHeader</CODE> objects
+ */
+ public Iterator getAllHeaders() {
+ return headers.iterator();
+ }
+
+ /**
+ * Returns all the <CODE>MimeHeader</CODE> objects whose
+ * name matches a name in the given array of names.
+ * @param names an array of <CODE>String</CODE>
+ * objects with the names for which to search
+ * @return an <CODE>Iterator</CODE> object over the <CODE>
+ * MimeHeader</CODE> objects whose name matches one of the
+ * names in the given list
+ */
+ public Iterator getMatchingHeaders(String names[]) {
+ return new MatchingIterator(names, true);
+ }
+
+ /**
+ * Returns all of the <CODE>MimeHeader</CODE> objects whose
+ * name does not match a name in the given array of names.
+ * @param names an array of <CODE>String</CODE>
+ * objects with the names for which to search
+ * @return an <CODE>Iterator</CODE> object over the <CODE>
+ * MimeHeader</CODE> objects whose name does not match one
+ * of the names in the given list
+ */
+ public Iterator getNonMatchingHeaders(String names[]) {
+ return new MatchingIterator(names, false);
+ }
+
+ // fixme: does this need to be a Vector? Will a non-synchronized impl of
+ // List do?
+ /**
+ * A <code>Vector</code> containing the headers as <code>MimeHeader</code>
+ * instances.
+ */
+ protected Vector headers;
+}
Added: webservices/axis/trunk/java/dev/scratch/chinthaka/OM API/src/java/org/apache/axis/om/OMAttribute.java
==============================================================================
--- (empty file)
+++ webservices/axis/trunk/java/dev/scratch/chinthaka/OM API/src/java/org/apache/axis/om/OMAttribute.java Thu Oct 28 21:15:38 2004
@@ -0,0 +1,28 @@
+package org.apache.axis.om;
+
+/**
+ * Copyright 2001-2004 The Apache Software Foundation.
+ * <p/>
+ * 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
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * 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.
+ * <p/>
+ * User: Eran Chinthaka - Lanka Software Foundation
+ * Date: Oct 4, 2004
+ * Time: 11:49:01 AM
+ * <p/>
+ * One must implement relevant constructors for the class implementing this interface
+ * all the things like namespace, parent, value, etc., that should come in this are defined in base classes
+ */
+public interface OMAttribute extends OMNamedNode {
+
+
+}
Added: webservices/axis/trunk/java/dev/scratch/chinthaka/OM API/src/java/org/apache/axis/om/OMElement.java
==============================================================================
--- (empty file)
+++ webservices/axis/trunk/java/dev/scratch/chinthaka/OM API/src/java/org/apache/axis/om/OMElement.java Thu Oct 28 21:15:38 2004
@@ -0,0 +1,98 @@
+package org.apache.axis.om;
+
+import org.apache.xml.utils.QName;
+
+import java.util.Iterator;
+
+/**
+ * Copyright 2001-2004 The Apache Software Foundation.
+ * <p/>
+ * 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
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * 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.
+ * <p/>
+ * User: Eran Chinthaka - Lanka Software Foundation
+ * Date: Oct 4, 2004
+ * Time: 11:52:18 AM
+ * <p/>
+ * One must make sure to insert relevant constructors for the classes that are implementing this interface
+ */
+public interface OMElement extends OMNamedNode {
+
+ /**
+ * This will add child to the element. One must preserve the order of children, in this operation
+ * Tip : appending the new child is prefered
+ * @param omNode
+ */
+ public void addChild(OMNode omNode);
+
+ /**
+ * 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 OMException
+ */
+ public Iterator getChildrenWithName(QName elementQName) throws OMException;
+
+ /**
+ * This returns a collection of this element.
+ * Children can be of types OMElement, OMText.
+ */
+ public Iterator getChildren();
+
+ /**
+ * THis will create a namespace in the current element scope
+ *
+ * @param uri
+ * @param prefix
+ * @return
+ */
+ public OMNamespace createNamespace(String uri, String prefix);
+
+ /**
+ * 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 OMException
+ */
+ public OMNamespace resolveNamespace(String uri, String prefix) throws OMException;
+
+ /**
+ * This will help to search for an attribute with a given QName within this Element
+ * @param qname
+ * @return
+ * @throws OMException
+ */
+ public Iterator getAttributeWithQName(QName qname) throws OMException;
+
+ /**
+ * This will return a List of OMAttributes
+ *
+ * @return
+ */
+ public Iterator getAttributes();
+
+ /**
+ * 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
+ */
+ public void insertAttribute(OMAttribute attr);
+ public void removeAttribute(OMAttribute attr);
+
+}
Added: webservices/axis/trunk/java/dev/scratch/chinthaka/OM API/src/java/org/apache/axis/om/OMException.java
==============================================================================
--- (empty file)
+++ webservices/axis/trunk/java/dev/scratch/chinthaka/OM API/src/java/org/apache/axis/om/OMException.java Thu Oct 28 21:15:38 2004
@@ -0,0 +1,37 @@
+package org.apache.axis.om;
+
+/**
+ * Copyright 2001-2004 The Apache Software Foundation.
+ * <p/>
+ * 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
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * 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.
+ * <p/>
+ * User: Eran Chinthaka - Lanka Software Foundation
+ * Date: Oct 4, 2004
+ * Time: 11:47:19 AM
+ */
+public class OMException extends RuntimeException {
+ public OMException() {
+ }
+
+ public OMException(String message) {
+ super(message);
+ }
+
+ public OMException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public OMException(Throwable cause) {
+ super(cause);
+ }
+}
Added: webservices/axis/trunk/java/dev/scratch/chinthaka/OM API/src/java/org/apache/axis/om/OMNamedNode.java
==============================================================================
--- (empty file)
+++ webservices/axis/trunk/java/dev/scratch/chinthaka/OM API/src/java/org/apache/axis/om/OMNamedNode.java Thu Oct 28 21:15:38 2004
@@ -0,0 +1,33 @@
+package org.apache.axis.om;
+
+
+/**
+ * Copyright 2001-2004 The Apache Software Foundation.
+ * <p/>
+ * 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
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * 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.
+ * <p/>
+ * User: Eran Chinthaka - Lanka Software Foundation
+ * Date: Oct 4, 2004
+ * Time: 11:39:01 AM
+ * <p/>
+ * OMElement and OMAttribute must have namespace support and those two behave in same manner as far as the namespaces are concerned.
+ * So one can implement this interface specific methods in an abstract class.
+ */
+public interface OMNamedNode extends OMNode {
+
+ public String getLocalName();
+ public void setLocalName(String localName);
+
+ public OMNamespace getNamespace() throws OMException;
+ public void setNamespace(OMNamespace namespace);
+}
Added: webservices/axis/trunk/java/dev/scratch/chinthaka/OM API/src/java/org/apache/axis/om/OMNamespace.java
==============================================================================
--- (empty file)
+++ webservices/axis/trunk/java/dev/scratch/chinthaka/OM API/src/java/org/apache/axis/om/OMNamespace.java Thu Oct 28 21:15:38 2004
@@ -0,0 +1,30 @@
+package org.apache.axis.om;
+
+/**
+ * Copyright 2001-2004 The Apache Software Foundation.
+ * <p/>
+ * 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
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * 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.
+ * <p/>
+ * User: Eran Chinthaka - Lanka Software Foundation
+ * Date: Oct 4, 2004
+ * Time: 1:24:00 PM
+ */
+public interface OMNamespace extends OMNode {
+
+ public boolean equals(OMNamespace ns);
+ public boolean equals(String uri, String prefix);
+
+ public boolean isDefaultNs();
+
+ public String getPrefix();
+}
Added: webservices/axis/trunk/java/dev/scratch/chinthaka/OM API/src/java/org/apache/axis/om/OMNode.java
==============================================================================
--- (empty file)
+++ webservices/axis/trunk/java/dev/scratch/chinthaka/OM API/src/java/org/apache/axis/om/OMNode.java Thu Oct 28 21:15:38 2004
@@ -0,0 +1,132 @@
+package org.apache.axis.om;
+
+
+
+
+/**
+ * Copyright 2001-2004 The Apache Software Foundation.
+ * <p/>
+ * 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
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * 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.
+ * <p/>
+ * User: Eran Chinthaka - Lanka Software Foundation
+ * Date: Oct 1, 2004
+ * Time: 3:36:14 PM
+ */
+public interface OMNode {
+ //==================================================================================
+
+ // Followings are the codes for node types. Extracted these from DOM API
+ /**
+ * The node is an <code>Element</code>.
+ */
+ public static final short ELEMENT_NODE = 1;
+ /**
+ * The node is an <code>Attr</code>.
+ */
+ public static final short ATTRIBUTE_NODE = 2;
+ /**
+ * The node is a <code>Text</code> node.
+ */
+ public static final short TEXT_NODE = 3;
+ /**
+ * The node is a <code>CDATASection</code>.
+ */
+ public static final short CDATA_SECTION_NODE = 4;
+
+ /**
+ * The node is a <code>Comment</code>.
+ */
+ public static final short COMMENT_NODE = 8;
+ /**
+ * The node is a <code>Document</code>.
+ */
+ public static final short DOCUMENT_NODE = 9;
+
+ //==================================================================================
+
+ /**
+ * This method should return the immediate parent of the node.
+ * Parent is always an Element
+ *
+ * @return
+ * @throws OMException
+ */
+ public OMElement getParent() throws OMException;
+
+ public void setParent(OMElement element);
+
+ /**
+ * This will give the next sibling. This can be an OMAttribute for OMAttribute or OMText or OMELement for others.
+ *
+ * @return
+ * @throws OMException
+ */
+ public OMNode getNextSibling() throws OMException;
+
+ public void setNextSibling(OMNode 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 OMException
+ */
+ public String getValue() throws OMException;
+
+ public void setValue(String 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();
+
+ public void setComplete(boolean state);
+
+ /**
+ * This will remove this information item and its children, from the model completely
+ *
+ * @throws OMException
+ */
+ public void detach() throws OMException;
+
+ /**
+ * This will insert a sibling just after the current information item.
+ *
+ * @param sibling
+ * @throws OMException
+ */
+ public void insertSiblingAfter(OMNode sibling) throws OMException;
+
+ /**
+ * This will insert a sibling just before the current information item
+ *
+ * @param sibling
+ * @throws OMException
+ */
+ public void insertSiblingBefore(OMNode sibling) throws OMException;
+
+ /** This is to get the type of node, as this is the super class of all the nodes
+ *
+ * @return
+ * @throws OMException
+ */
+ public short getType() throws OMException;
+ public void setType(short nodeType) throws OMException;
+}
Added: webservices/axis/trunk/java/dev/scratch/chinthaka/OM API/src/java/org/apache/axis/om/OMText.java
==============================================================================
--- (empty file)
+++ webservices/axis/trunk/java/dev/scratch/chinthaka/OM API/src/java/org/apache/axis/om/OMText.java Thu Oct 28 21:15:38 2004
@@ -0,0 +1,31 @@
+package org.apache.axis.om;
+
+/**
+ * Copyright 2001-2004 The Apache Software Foundation.
+ * <p/>
+ * 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
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * 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.
+ * <p/>
+ * User: Eran Chinthaka - Lanka Software Foundation
+ * Date: Oct 4, 2004
+ * Time: 2:04:43 PM
+ */
+public interface OMText extends OMNode {
+ /**
+ * We use the OMText class to hold comments, text, characterData, CData, etc.,
+ * The codes are found in OMNode class
+ *
+ * @param type
+ */
+ public void setTextType(short type);
+ public short getTextType();
+}
Added: webservices/axis/trunk/java/dev/scratch/chinthaka/OM API/src/java/org/apache/axis/om/Printable.java
==============================================================================
--- (empty file)
+++ webservices/axis/trunk/java/dev/scratch/chinthaka/OM API/src/java/org/apache/axis/om/Printable.java Thu Oct 28 21:15:38 2004
@@ -0,0 +1,29 @@
+package org.apache.axis.om;
+
+import java.io.PrintStream;
+
+/**
+ * Copyright 2001-2004 The Apache Software Foundation.
+ * <p/>
+ * 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
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * 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.
+ * <p/>
+ * User: Eran Chinthaka - Lanka Software Foundation
+ * Date: Oct 6, 2004
+ * Time: 11:36:01 AM
+ * <p/>
+ * A component that implements this interface is printable to an outputstream
+ */
+public interface Printable {
+
+ public void print(PrintStream ps) throws OMException;
+}
Added: webservices/axis/trunk/java/dev/scratch/chinthaka/OM API/src/java/org/apache/axis/om/SOAPBody.java
==============================================================================
--- (empty file)
+++ webservices/axis/trunk/java/dev/scratch/chinthaka/OM API/src/java/org/apache/axis/om/SOAPBody.java Thu Oct 28 21:15:38 2004
@@ -0,0 +1,98 @@
+/* Copyright 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 java.org.apache.axis.om;
+
+import org.apache.axis.om.OMElement;
+import org.apache.axis.om.OMException;
+
+import javax.xml.soap.SOAPFault;
+
+
+/**
+ * An object that represents the contents of the SOAP body
+ * element in a SOAP message. A SOAP body element consists of XML data
+ * that affects the way the application-specific content is processed.
+ * <P>
+ * A <code>SOAPBody</code> object contains <code>SOAPBodyElement</code>
+ * objects, which have the content for the SOAP body.
+ * A <code>SOAPFault</code> object, which carries status and/or
+ * error information, is an example of a <code>SOAPBodyElement</code> object.
+ *
+ */
+public interface SOAPBody extends OMElement {
+
+ /**
+ * Creates a new <code>SOAPFault</code> object and adds it to
+ * this <code>SOAPBody</code> object.
+ * @return the new <code>SOAPFault</code> object
+ * @throws org.apache.axis.om.OMException if there is a SOAP error
+ */
+ public abstract SOAPFault addFault() throws OMException;
+
+ /**
+ * Indicates whether a <code>SOAPFault</code> object exists in
+ * this <code>SOAPBody</code> object.
+ * @return <code>true</code> if a <code>SOAPFault</code> object exists in
+ * this <code>SOAPBody</code> object; <code>false</code>
+ * otherwise
+ */
+ public abstract boolean hasFault();
+
+ /**
+ * Returns the <code>SOAPFault</code> object in this <code>SOAPBody</code>
+ * object.
+ * @return the <code>SOAPFault</code> object in this <code>SOAPBody</code>
+ * object
+ */
+ public abstract SOAPFault getFault();
+
+ /**
+ * Creates a new <code>SOAPBodyElement</code> object with the
+ * specified name and adds it to this <code>SOAPBody</code> object.
+ * @param element a <code>OMNamedNode</code> object with the name for the new
+ * <code>SOAPBodyElement</code> object
+ * @return the new <code>SOAPBodyElement</code> object
+ * @throws OMException if a SOAP error occurs
+ */
+ public abstract SOAPBodyElement addBodyElement(SOAPBodyElement element)
+ throws OMException;
+
+
+ /**
+ *
+ * @param soapFault
+ * @throws OMException
+ */
+ public abstract void addFault(SOAPFault soapFault) throws OMException;
+
+ /**
+ * Adds the root node of the DOM <code>Document</code> to this
+ * <code>SOAPBody</code> object.
+ * <p>
+ * Calling this method invalidates the <code>document</code> parameter. The
+ * client application should discard all references to this
+ * <code>Document</code> and its contents upon calling
+ * <code>addDocument</code>. The behavior of an application that continues
+ * to use such references is undefined.
+ *
+ * @param element the <code>Document</code> object whose root node will be
+ * added to this <code>SOAPBody</code>
+ * @return the <code>SOAPBodyElement</code> that represents the root node
+ * that was added
+ * @throws OMException if the <code>Document</code> cannot be added
+ */
+ public abstract SOAPBodyElement addDocument(OMElement element) throws OMException;
+ }
Added: webservices/axis/trunk/java/dev/scratch/chinthaka/OM API/src/java/org/apache/axis/om/SOAPBodyElement.java
==============================================================================
--- (empty file)
+++ webservices/axis/trunk/java/dev/scratch/chinthaka/OM API/src/java/org/apache/axis/om/SOAPBodyElement.java Thu Oct 28 21:15:38 2004
@@ -0,0 +1,35 @@
+/* Copyright 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 java.org.apache.axis.om;
+
+import org.apache.axis.om.OMElement;
+
+
+/**
+ * A <code>SOAPBodyElement</code> object represents the contents in
+ * a <code>SOAPBody</code> object. The <code>SOAPFault</code> interface
+ * is a <code>SOAPBodyElement</code> object that has been defined.
+ * <P>
+ * A new <code>SOAPBodyElement</code> object can be created and added
+ * to a <code>SOAPBody</code> object with the <code>SOAPBody</code>
+ * method <code>addBodyElement</code>. In the following line of code,
+ * <code>sb</code> is a <code>SOAPBody</code> object, and
+ * <code>myName</code> is a <code>Name</code> object.
+ * <PRE>
+ * SOAPBodyElement sbe = sb.addBodyElement(myName);
+ * </PRE>
+ */
+public interface SOAPBodyElement extends OMElement {}
Added: webservices/axis/trunk/java/dev/scratch/chinthaka/OM API/src/java/org/apache/axis/om/SOAPEnvelope.java
==============================================================================
--- (empty file)
+++ webservices/axis/trunk/java/dev/scratch/chinthaka/OM API/src/java/org/apache/axis/om/SOAPEnvelope.java Thu Oct 28 21:15:38 2004
@@ -0,0 +1,86 @@
+/* Copyright 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.
+ * <p/>
+ * User: Eran Chinthaka - Lanka Software Foundation
+ * Date: Oct 28, 2004
+ * Time: 11:52:18 AM
+ * <p/>
+ *
+ */
+
+
+package java.org.apache.axis.om;
+
+import org.apache.axis.om.OMElement;
+import org.apache.axis.om.OMException;
+import org.apache.axis.om.OMNamespace;
+
+
+public interface SOAPEnvelope extends OMElement {
+
+ /**
+ * Creates a new <CODE>Name</CODE> object initialized with the
+ * given local name, namespace prefix, and namespace URI.
+ * <p/>
+ * <P>This factory method creates <CODE>Name</CODE> objects
+ * for use in the SOAP/XML document.
+ *
+ * @param localName a <CODE>String</CODE> giving
+ * the local name
+ * @param prefix a <CODE>String</CODE> giving
+ * the prefix of the namespace
+ * @param uri a <CODE>String</CODE> giving the
+ * URI of the namespace
+ * @return a <CODE>OMNamespace</CODE> object initialized with the given
+ * local name, namespace prefix, and namespace URI
+ * @throws OMException if there is a SOAP error
+ */
+ public abstract OMNamespace createNamespace(String localName, String prefix, String uri)
+ throws OMException;
+
+
+ /**
+ * Returns the <CODE>SOAPHeader</CODE> object for this <CODE>
+ * SOAPEnvelope</CODE> object.
+ * <p/>
+ * <P> This SOAPHeader will just be a container for all the headers in the
+ * <CODE>SOAPMessage</CODE>
+ * </P>
+ *
+ *
+ * @return the <CODE>SOAPHeader</CODE> object or <CODE>
+ * null</CODE> if there is none
+ * @throws OMException if there is a problem
+ * obtaining the <CODE>SOAPHeader</CODE> object
+ */
+ public abstract SOAPHeader getHeader() throws OMException;
+
+ /**
+ * Returns the <CODE>SOAPBody</CODE> object associated with
+ * this <CODE>SOAPEnvelope</CODE> object.
+ * <p/>
+ * <P> This SOAPBody will just be a container for all the BodyElements in the
+ * <CODE>SOAPMessage</CODE>
+ * </P>
+ *
+ * @return the <CODE>SOAPBody</CODE> object for this <CODE>
+ * SOAPEnvelope</CODE> object or <CODE>null</CODE> if there
+ * is none
+ * @throws OMException if there is a problem
+ * obtaining the <CODE>SOAPBody</CODE> object
+ */
+ public abstract SOAPBody getBody() throws OMException;
+
+
+}
Added: webservices/axis/trunk/java/dev/scratch/chinthaka/OM API/src/java/org/apache/axis/om/SOAPFault.java
==============================================================================
--- (empty file)
+++ webservices/axis/trunk/java/dev/scratch/chinthaka/OM API/src/java/org/apache/axis/om/SOAPFault.java Thu Oct 28 21:15:38 2004
@@ -0,0 +1,142 @@
+/* Copyright 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 java.org.apache.axis.om;
+
+import org.apache.axis.om.OMException;
+import java.util.Locale;
+
+
+/**
+ * An element in the <CODE>SOAPBody</CODE> object that contains
+ * error and/or status information. This information may relate to
+ * errors in the <CODE>SOAPMessage</CODE> object or to problems
+ * that are not related to the content in the message itself.
+ * Problems not related to the message itself are generally errors
+ * in processing, such as the inability to communicate with an
+ * upstream server.
+ * <P>
+ * The <CODE>SOAPFault</CODE> interface provides methods for
+ * retrieving the information contained in a <CODE>
+ * SOAPFault</CODE> object and for setting the fault code, the
+ * fault actor, and a string describing the fault. A fault code is
+ * one of the codes defined in the SOAP 1.1 specification that
+ * describe the fault. An actor is an intermediate recipient to
+ * whom a message was routed. The message path may include one or
+ * more actors, or, if no actors are specified, the message goes
+ * only to the default actor, which is the final intended
+ * recipient.
+ */
+public interface SOAPFault extends SOAPBodyElement {
+
+ /**
+ * Sets this <CODE>SOAPFault</CODE> object with the given
+ * fault code.
+ * <p/>
+ * <P>Fault codes, which given information about the fault,
+ * are defined in the SOAP 1.1 specification.</P>
+ *
+ * @param faultCode a <CODE>String</CODE> giving
+ * the fault code to be set; must be one of the fault codes
+ * defined in the SOAP 1.1 specification
+ * @throws OMException if there was an error in
+ * adding the <CODE>faultCode</CODE> to the underlying XML
+ * tree.
+ * @see #getFaultCode() getFaultCode()
+ */
+ public abstract void setFaultCode(String faultCode) throws OMException;
+
+ /**
+ * Gets the fault code for this <CODE>SOAPFault</CODE>
+ * object.
+ *
+ * @return a <CODE>String</CODE> with the fault code
+ * @see #setFaultCode(String) setFaultCode(java.lang.String)
+ */
+ public abstract String getFaultCode();
+
+ /**
+ * Sets this <CODE>SOAPFault</CODE> object with the given
+ * fault actor.
+ * <p/>
+ * <P>The fault actor is the recipient in the message path who
+ * caused the fault to happen.</P>
+ *
+ * @param faultActor a <CODE>String</CODE>
+ * identifying the actor that caused this <CODE>
+ * SOAPFault</CODE> object
+ * @throws OMException if there was an error in
+ * adding the <CODE>faultActor</CODE> to the underlying XML
+ * tree.
+ * @see #getFaultActor() getFaultActor()
+ */
+ public abstract void setFaultActor(String faultActor) throws OMException;
+
+ /**
+ * Gets the fault actor for this <CODE>SOAPFault</CODE>
+ * object.
+ *
+ * @return a <CODE>String</CODE> giving the actor in the message
+ * path that caused this <CODE>SOAPFault</CODE> object
+ * @see #setFaultActor(String) setFaultActor(java.lang.String)
+ */
+ public abstract String getFaultActor();
+
+ /**
+ * Sets the fault string for this <CODE>SOAPFault</CODE>
+ * object to the given string.
+ *
+ * @param faultString a <CODE>String</CODE>
+ * giving an explanation of the fault
+ * @throws OMException if there was an error in
+ * adding the <CODE>faultString</CODE> to the underlying XML
+ * tree.
+ * @see #getFaultString() getFaultString()
+ */
+ public abstract void setFaultString(String faultString)
+ throws OMException;
+
+ /**
+ * Gets the fault string for this <CODE>SOAPFault</CODE>
+ * object.
+ *
+ * @return a <CODE>String</CODE> giving an explanation of the
+ * fault
+ */
+ public abstract String getFaultString();
+
+ /**
+ * Sets the fault string for this <code>SOAPFault</code> object to the given
+ * string and localized to the given locale.
+ *
+ * @param faultString a <code>String</code> giving an explanation of
+ * the fault
+ * @param locale a <code>Locale</code> object indicating the
+ * native language of the <code>faultString</code>
+ * @throws OMException if there was an error in adding the
+ * <code>faultString</code> to the underlying XML tree
+ */
+ public abstract void setFaultString(String faultString, Locale locale) throws OMException;
+
+ /**
+ * Returns the optional detail element for this <code>SOAPFault</code>
+ * object.
+ *
+ * @return a <code>Locale</code> object indicating the native language of
+ * the fault string or <code>null</code> if no locale was
+ * specified
+ */
+ public abstract Locale getFaultStringLocale();
+}
Added: webservices/axis/trunk/java/dev/scratch/chinthaka/OM API/src/java/org/apache/axis/om/SOAPHeader.java
==============================================================================
--- (empty file)
+++ webservices/axis/trunk/java/dev/scratch/chinthaka/OM API/src/java/org/apache/axis/om/SOAPHeader.java Thu Oct 28 21:15:38 2004
@@ -0,0 +1,115 @@
+/* Copyright 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 java.org.apache.axis.om;
+
+import org.apache.axis.om.OMElement;
+import org.apache.axis.om.OMException;
+import org.apache.axis.om.OMNamespace;
+
+import java.util.Iterator;
+
+
+public interface SOAPHeader extends OMElement {
+
+ /**
+ * Creates a new <CODE>SOAPHeaderElement</CODE> object
+ * initialized with the specified name and adds it to this
+ * <CODE>SOAPHeader</CODE> object.
+ * @param namespace a <CODE>OMNamespace</CODE> object with
+ * the name of the new <CODE>SOAPHeaderElement</CODE>
+ * object
+ * @return the new <CODE>SOAPHeaderElement</CODE> object that
+ * was inserted into this <CODE>SOAPHeader</CODE>
+ * object
+ * @throws OMException if a SOAP error occurs
+ */
+ public abstract SOAPHeaderElement addHeaderElement(OMNamespace namespace)
+ throws OMException ;
+
+ /**
+ * Returns a list of all the <CODE>SOAPHeaderElement</CODE>
+ * objects in this <CODE>SOAPHeader</CODE> object that have the
+ * the specified actor. An actor is a global attribute that
+ * indicates the intermediate parties to whom the message should
+ * be sent. An actor receives the message and then sends it to
+ * the next actor. The default actor is the ultimate intended
+ * recipient for the message, so if no actor attribute is
+ * included in a <CODE>SOAPHeader</CODE> object, the message is
+ * sent to its ultimate destination.
+ * @param actor a <CODE>String</CODE> giving the
+ * URI of the actor for which to search
+ * @return an <CODE>Iterator</CODE> object over all the <CODE>
+ * SOAPHeaderElement</CODE> objects that contain the
+ * specified actor
+ * @see #extractHeaderElements(java.lang.String) extractHeaderElements(java.lang.String)
+ */
+ public abstract Iterator examineHeaderElements(String actor);
+
+ /**
+ * Returns a list of all the <CODE>SOAPHeaderElement</CODE>
+ * objects in this <CODE>SOAPHeader</CODE> object that have
+ * the the specified actor and detaches them from this <CODE>
+ * SOAPHeader</CODE> object.
+ *
+ * <P>This method allows an actor to process only the parts of
+ * the <CODE>SOAPHeader</CODE> object that apply to it and to
+ * remove them before passing the message on to the next
+ * actor.
+ * @param actor a <CODE>String</CODE> giving the
+ * URI of the actor for which to search
+ * @return an <CODE>Iterator</CODE> object over all the <CODE>
+ * SOAPHeaderElement</CODE> objects that contain the
+ * specified actor
+ * @see #examineHeaderElements(java.lang.String) examineHeaderElements(java.lang.String)
+ */
+ public abstract Iterator extractHeaderElements(String actor);
+
+ /**
+ * Returns an <code>Iterator</code> over all the
+ * <code>SOAPHeaderElement</code> objects in this <code>SOAPHeader</code>
+ * object that have the specified actor and that have a MustUnderstand
+ * attribute whose value is equivalent to <code>true</code>.
+ *
+ * @param actor a <code>String</code> giving the URI of the actor for which
+ * to search
+ * @return an <code>Iterator</code> object over all the
+ * <code>SOAPHeaderElement</code> objects that contain the
+ * specified actor and are marked as MustUnderstand
+ */
+ public abstract Iterator examineMustUnderstandHeaderElements(String actor);
+
+ /**
+ * Returns an <code>Iterator</code> over all the
+ * <code>SOAPHeaderElement</code> objects in this <code>SOAPHeader</code>
+ * object.
+ *
+ * @return an <code>Iterator</code> object over all the
+ * <code>SOAPHeaderElement</code> objects contained by this
+ * <code>SOAPHeader</code>
+ */
+ public abstract Iterator examineAllHeaderElements();
+
+ /**
+ * Returns an <code>Iterator</code> over all the
+ * <code>SOAPHeaderElement</code> objects in this <code>SOAPHeader </code>
+ * object and detaches them from this <code>SOAPHeader</code> object.
+ *
+ * @return an <code>Iterator</code> object over all the
+ * <code>SOAPHeaderElement</code> objects contained by this
+ * <code>SOAPHeader</code>
+ */
+ public abstract Iterator extractAllHeaderElements();
+}
Added: webservices/axis/trunk/java/dev/scratch/chinthaka/OM API/src/java/org/apache/axis/om/SOAPHeaderElement.java
==============================================================================
--- (empty file)
+++ webservices/axis/trunk/java/dev/scratch/chinthaka/OM API/src/java/org/apache/axis/om/SOAPHeaderElement.java Thu Oct 28 21:15:38 2004
@@ -0,0 +1,79 @@
+/* Copyright 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 java.org.apache.axis.om;
+
+import javax.xml.soap.SOAPElement;
+
+/**
+ * <P>An object representing the contents in the SOAP header part
+ * of the SOAP envelope. The immediate children of a <CODE>
+ * SOAPHeader</CODE> object can be represented only as <CODE>
+ * SOAPHeaderElement</CODE> objects.</P>
+ *
+ * <P>A <CODE>SOAPHeaderElement</CODE> object can have other
+ * <CODE>OMElement</CODE> objects as its children.</P>
+ */
+public interface SOAPHeaderElement extends SOAPElement {
+
+ /**
+ * Sets the actor associated with this <CODE>
+ * SOAPHeaderElement</CODE> object to the specified actor. The
+ * default value of an actor is: <CODE>
+ * SOAPConstants.URI_SOAP_ACTOR_NEXT</CODE>
+ * @param actorURI a <CODE>String</CODE> giving
+ * the URI of the actor to set
+ * @see #getActor() getActor()
+ * @throws java.lang.IllegalArgumentException if
+ * there is a problem in setting the actor.
+ */
+ public abstract void setActor(String actorURI);
+
+ /**
+ * Returns the uri of the actor associated with this <CODE>
+ * SOAPHeaderElement</CODE> object.
+ * @return a <CODE>String</CODE> giving the URI of the
+ * actor
+ * @see #setActor(java.lang.String) setActor(java.lang.String)
+ */
+ public abstract String getActor();
+
+ /**
+ * Sets the mustUnderstand attribute for this <CODE>
+ * SOAPHeaderElement</CODE> object to be on or off.
+ *
+ * <P>If the mustUnderstand attribute is on, the actor who
+ * receives the <CODE>SOAPHeaderElement</CODE> must process it
+ * correctly. This ensures, for example, that if the <CODE>
+ * SOAPHeaderElement</CODE> object modifies the message, that
+ * the message is being modified correctly.</P>
+ * @param mustUnderstand <CODE>true</CODE> to
+ * set the mustUnderstand attribute on; <CODE>false</CODE>
+ * to turn if off
+ * @throws java.lang.IllegalArgumentException if
+ * there is a problem in setting the actor.
+ * @see #getMustUnderstand() getMustUnderstand()
+ */
+ public abstract void setMustUnderstand(boolean mustUnderstand);
+
+ /**
+ * Returns whether the mustUnderstand attribute for this
+ * <CODE>SOAPHeaderElement</CODE> object is turned on.
+ * @return <CODE>true</CODE> if the mustUnderstand attribute of
+ * this <CODE>SOAPHeaderElement</CODE> object is turned on;
+ * <CODE>false</CODE> otherwise
+ */
+ public abstract boolean getMustUnderstand();
+}
Added: webservices/axis/trunk/java/dev/scratch/chinthaka/OM API/src/java/org/apache/axis/om/SOAPMessage.java
==============================================================================
--- (empty file)
+++ webservices/axis/trunk/java/dev/scratch/chinthaka/OM API/src/java/org/apache/axis/om/SOAPMessage.java Thu Oct 28 21:15:38 2004
@@ -0,0 +1,44 @@
+package org.apache.axis.om;
+
+import java.org.apache.axis.om.SOAPEnvelope;
+import java.org.apache.axis.om.MimeHeaders;
+
+
+/**
+ * Copyright 2001-2004 The Apache Software Foundation.
+ * <p/>
+ * 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
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * 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.
+ *
+ * @author Axis team
+ * Date: Oct 4, 2004
+ * Time: 4:48:10 PM
+ */
+public interface SOAPMessage extends OMNode {
+
+ /**
+ * Get the root element of this document as a SOAPEnvelope
+ *
+ * @return the root element
+ */
+ public SOAPEnvelope getEnvelope();
+
+ /**
+ * Returns all the transport-specific MIME headers for this
+ * <CODE>SOAPMessage</CODE> object in a transport-independent
+ * fashion.
+ * @return a <CODE>MimeHeaders</CODE> object containing the
+ * <CODE>MimeHeader</CODE> objects
+ */
+ public abstract MimeHeaders getMimeHeaders();
+
+}
Added: webservices/axis/trunk/java/dev/scratch/chinthaka/OMAPI_with_Impl/lib/xpp3-1.1.3.4.M.jar
==============================================================================
Binary file. No diff available.
Modified: webservices/axis/trunk/java/dev/scratch/chinthaka/OMAPI_with_Impl/src/java/org/apache/axis/om/impl/OMAttributeImpl.java
==============================================================================
--- webservices/axis/trunk/java/dev/scratch/chinthaka/OMAPI_with_Impl/src/java/org/apache/axis/om/impl/OMAttributeImpl.java (original)
+++ webservices/axis/trunk/java/dev/scratch/chinthaka/OMAPI_with_Impl/src/java/org/apache/axis/om/impl/OMAttributeImpl.java Thu Oct 28 21:15:38 2004
@@ -1,3 +1,4 @@
+<<<<<<< .mine
package org.apache.axis.om.impl;
import org.apache.axis.om.OMAttribute;
@@ -76,3 +77,83 @@
}
+=======
+package org.apache.axis.om.impl;
+
+import org.apache.axis.om.OMAttribute;
+import org.apache.axis.om.OMElement;
+import org.apache.axis.om.OMException;
+import org.apache.axis.om.OMNamespace;
+
+import java.io.PrintStream;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+/**
+ * Copyright 2001-2004 The Apache Software Foundation.
+ * <p/>
+ * 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
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * 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.
+ * <p/>
+ * User: Eran Chinthaka - Lanka Software Foundation
+ * Date: Oct 6, 2004
+ * Time: 11:43:23 AM
+ */
+public class OMAttributeImpl extends OMNamedNodeImpl implements OMAttribute {
+ private static String QUOTE_ENTITY = """;
+ private static Matcher matcher = Pattern.compile("\"").matcher(null);
+
+ public OMAttributeImpl(String localName, OMNamespace ns, String value, OMElement parent) {
+ super(localName, ns, parent);
+ setValue(value);
+ }
+
+ public OMAttributeImpl(String localName, OMNamespace ns, String value) {
+ super(localName, ns, null);
+ setValue(value);
+ }
+
+ synchronized static String replaceQuoteWithEntity(String value) {
+ matcher.reset(value);
+ return matcher.replaceAll(QUOTE_ENTITY);
+ }
+
+ public void print(PrintStream s) throws OMException {
+ super.print(s);
+ s.print('=');
+ String v = value;
+ char quote = '"';
+ if (value.indexOf('"') != -1)
+ if (value.indexOf('\'') == -1)
+ quote = '\'';
+ else
+ v = replaceQuoteWithEntity(value);
+ s.print(quote);
+ s.print(v);
+ s.print(quote);
+ }
+
+ public void detach() throws OMException {
+
+ if (parent == null)
+ throw new OMException();
+ if (getPreviousSibling() == null)
+ parent.setFirstAttribute((OMAttributeImpl) nextSibling);
+ else
+ previousSibling.setNextSibling(nextSibling);
+ if (nextSibling != null)
+ nextSibling.setPreviousSibling(previousSibling);
+ }
+
+
+}
+>>>>>>> .r55205
Modified: webservices/axis/trunk/java/dev/scratch/chinthaka/OMAPI_with_Impl/src/java/org/apache/axis/om/impl/OMTextImpl.java
==============================================================================
--- webservices/axis/trunk/java/dev/scratch/chinthaka/OMAPI_with_Impl/src/java/org/apache/axis/om/impl/OMTextImpl.java (original)
+++ webservices/axis/trunk/java/dev/scratch/chinthaka/OMAPI_with_Impl/src/java/org/apache/axis/om/impl/OMTextImpl.java Thu Oct 28 21:15:38 2004
@@ -1,3 +1,4 @@
+<<<<<<< .mine
package org.apache.axis.om.impl;
import org.apache.axis.om.OMElement;
@@ -81,3 +82,88 @@
}
+=======
+package org.apache.axis.om.impl;
+
+import org.apache.axis.om.OMElement;
+import org.apache.axis.om.OMException;
+import org.apache.axis.om.OMNode;
+import org.apache.axis.om.OMText;
+
+import java.io.PrintStream;
+
+/**
+ * Copyright 2001-2004 The Apache Software Foundation.
+ * <p/>
+ * 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
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * 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.
+ * <p/>
+ * User: Eran Chinthaka - Lanka Software Foundation
+ * Date: Oct 6, 2004
+ * Time: 1:36:55 PM
+ */
+public class OMTextImpl extends OMNodeImpl implements OMText {
+
+ protected short textType;
+
+ public OMTextImpl(OMElement parent, String text) {
+ super(parent);
+ setValue(text);
+ done = true;
+ }
+
+ public OMTextImpl(String s) {
+ super();
+ setValue(s);
+ }
+
+ /**
+ * We use the OMText class to hold comments, text, characterData, CData, etc.,
+ * The codes are found in OMNode class
+ *
+ * @param type
+ */
+ public void setTextType(short type) {
+ this.textType = type;
+ }
+
+ public short getTextType() {
+ return textType;
+ }
+
+ public OMNode getFirstChild() throws OMException {
+ throw new OMException();
+ }
+
+ public void setFirstChild(OMNode node) throws OMException {
+ throw new OMException();
+ }
+
+ public void print(PrintStream s) throws OMException {
+ s.print(value);
+ }
+
+ /**
+ * 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
+ */
+ public short getType() throws OMException {
+ return OMNode.TEXT_NODE; //TODO implement this
+ }
+
+
+
+
+}
+>>>>>>> .r55205
Modified: webservices/axis/trunk/java/dev/scratch/chinthaka/OMAPI_with_Impl/src/java/org/apache/axis/om/impl/util/OMChildrenQNameIterator.java
==============================================================================
--- webservices/axis/trunk/java/dev/scratch/chinthaka/OMAPI_with_Impl/src/java/org/apache/axis/om/impl/util/OMChildrenQNameIterator.java (original)
+++ webservices/axis/trunk/java/dev/scratch/chinthaka/OMAPI_with_Impl/src/java/org/apache/axis/om/impl/util/OMChildrenQNameIterator.java Thu Oct 28 21:15:38 2004
@@ -1,3 +1,4 @@
+<<<<<<< .mine
package org.apache.axis.om.impl.util;
import org.apache.axis.om.OMNode;
@@ -102,3 +103,109 @@
}
+=======
+package org.apache.axis.om.impl.util;
+
+import org.apache.axis.om.OMNode;
+import org.apache.axis.om.impl.OMNamedNodeImpl;
+import org.apache.axis.om.impl.OMNodeImpl;
+import org.apache.xml.utils.QName;
+
+import java.util.Iterator;
+
+/**
+ * Copyright 2001-2004 The Apache Software Foundation.
+ * <p/>
+ * 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
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * 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.
+ * <p/>
+ * User: Eran Chinthaka - Lanka Software Foundation
+ * Date: Oct 13, 2004
+ * Time: 11:25:29 AM
+ */
+public class OMChildrenQNameIterator implements Iterator {
+
+ private OMNode omNode;
+ private QName qName;
+
+ private boolean picked = false;
+
+ public OMChildrenQNameIterator(OMNodeImpl firstChild, QName qName) {
+ this.omNode = firstChild;
+ this.qName = qName;
+ }
+
+ /**
+ * Removes from the underlying collection the last element returned by the
+ * iterator (optional operation). This method can be called only once per
+ * call to <tt>next</tt>. The behavior of an iterator is unspecified if
+ * the underlying collection is modified while the iteration is in
+ * progress in any way other than by calling this method.
+ *
+ * @throws UnsupportedOperationException if the <tt>remove</tt>
+ * operation is not supported by this Iterator.
+ * @throws IllegalStateException if the <tt>next</tt> method has not
+ * yet been called, or the <tt>remove</tt> method has already
+ * been called after the last call to the <tt>next</tt>
+ * method.
+ */
+ public void remove() {
+ throw new UnsupportedOperationException(); //TODO implement this
+ }
+
+ /**
+ * Returns <tt>true</tt> if the iteration has more elements. (In other
+ * words, returns <tt>true</tt> if <tt>next</tt> would return an element
+ * rather than throwing an exception.)
+ *
+ * @return <tt>true</tt> if the iterator has more elements.
+ */
+ public boolean hasNext() {
+
+ boolean needToMoveForward = true;
+ boolean isMatchingNodeFound = false;
+
+ while (needToMoveForward) {
+ if (omNode != null) {
+
+ // check the current node for the criteria
+ if ((omNode instanceof OMNamedNodeImpl) && ((OMNamedNodeImpl) omNode).getQName().equals(qName)) {
+ isMatchingNodeFound = true;
+ needToMoveForward = false;
+ } else {
+ // get the next named node
+ omNode = omNode.getNextSibling();
+ isMatchingNodeFound = needToMoveForward = !(omNode == null);
+ }
+ } else {
+ needToMoveForward = false;
+ }
+ }
+ return isMatchingNodeFound;
+ }
+
+ /**
+ * Returns the next element in the iteration.
+ *
+ * @return the next element in the iteration.
+ * @throws java.util.NoSuchElementException
+ * iteration has no more elements.
+ */
+ public Object next() {
+ OMNode tempNode = omNode;
+ omNode = omNode.getNextSibling();
+ return tempNode;
+ }
+
+
+}
+>>>>>>> .r55205
Modified: webservices/axis/trunk/java/dev/scratch/chinthaka/OMAPI_with_Impl/src/test/org/apache/axis/om/OMElementTest.java
==============================================================================
--- webservices/axis/trunk/java/dev/scratch/chinthaka/OMAPI_with_Impl/src/test/org/apache/axis/om/OMElementTest.java (original)
+++ webservices/axis/trunk/java/dev/scratch/chinthaka/OMAPI_with_Impl/src/test/org/apache/axis/om/OMElementTest.java Thu Oct 28 21:15:38 2004
@@ -1,3 +1,4 @@
+<<<<<<< .mine
/**
* Copyright 2001-2004 The Apache Software Foundation.
* <p/>
@@ -439,3 +440,446 @@
}
+=======
+/**
+ * Copyright 2001-2004 The Apache Software Foundation.
+ * <p/>
+ * 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
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * 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.
+ * <p/>
+ * Author: Eran Chinthaka - Lanka Software Foundation
+ * Date: Oct 14, 2004
+ * Time: 12:42:46 PM
+ */
+package org.apache.axis.om;
+
+import junit.framework.TestCase;
+import org.apache.axis.om.impl.OMXmlPullParserWrapper;
+import org.apache.axis.om.util.OMNodeBuilder;
+import org.apache.xml.utils.QName;
+import org.xmlpull.v1.XmlPullParser;
+import org.xmlpull.v1.XmlPullParserFactory;
+
+import java.io.FileReader;
+import java.util.Iterator;
+
+
+public class OMElementTest extends TestCase {
+ private static final String IN_FILE_NAME = "resources/soapmessage.xml";
+ private OMElement root;
+ private OMXmlPullParserWrapper omXmlPullParserWrapper;
+
+
+ public static void main(String[] args) {
+ }
+
+ /*
+ * @see TestCase#setUp()
+ */
+ protected void setUp() throws Exception {
+ super.setUp();
+ root = getOMBuilder().getDocument().getRootElement();
+
+ }
+
+ private OMXmlPullParserWrapper getOMBuilder() throws Exception {
+ XmlPullParser parser = XmlPullParserFactory.newInstance().newPullParser();
+ parser.setFeature(XmlPullParser.FEATURE_PROCESS_NAMESPACES, true);
+ parser.setInput(new FileReader(IN_FILE_NAME));
+ omXmlPullParserWrapper = new OMXmlPullParserWrapper(parser);
+ return omXmlPullParserWrapper;
+ }
+
+ public final void testAddChild() {
+
+ System.out.print("Testing addChild(OMNode) .....");
+
+ // add new child with the name TestElement
+ OMNamespace omNamespace = OMNodeBuilder.createOMNamespace("http://opensource.lk/chinthaka", "prefix");
+ root.addChild(OMNodeBuilder.createOMElement("TestElement", omNamespace, root, omXmlPullParserWrapper));
+
+ // search for the child
+ boolean newChildFound = false;
+ Iterator iterator = root.getChildren();
+ while (iterator.hasNext()) {
+ OMNode omNode = (OMNode) iterator.next();
+ if (omNode.getValue().equalsIgnoreCase("TestElement")) {
+ newChildFound = true;
+ }
+ }
+ assertTrue(newChildFound);
+
+ System.out.println(" \t\t OK");
+ }
+
+
+ public final void testGetChildrenWithName() {
+ System.out.print("Testing getChildrenWithQName(QName) ......");
+
+ // add new child with the name TestElement
+ OMNamespace omNamespace = OMNodeBuilder.createOMNamespace("http://opensource.lk/chinthaka", "prefix");
+ root.addChild(OMNodeBuilder.createOMElement("TestElement", omNamespace, root, omXmlPullParserWrapper));
+
+ Iterator iter = root.getChildrenWithName(new QName("http://opensource.lk/chinthaka", "TestElement"));
+ int childrenCount = 0;
+ while (iter.hasNext()) {
+ iter.next();
+ childrenCount++;
+ }
+
+ assertTrue("getChildrenWithName is not working properly", childrenCount == 1);
+
+ System.out.println(" \t\t OK");
+
+
+ }
+
+ public final void testGetChildren() {
+ System.out.print("Testing getChildren ..............");
+ Iterator childrenIterator = root.getChildren();
+
+ int totalNumberOfChildren = 0;
+ int elementNodes = 0;
+ int textNodes = 0;
+ OMNode omNode;
+ short nodeType;
+ String elementLocalName;
+
+ while (childrenIterator.hasNext()) {
+ omNode = (OMNode) childrenIterator.next();
+ nodeType = omNode.getType();
+ if (nodeType == OMNode.TEXT_NODE) {
+ textNodes++;
+ } else if (nodeType == OMNode.ELEMENT_NODE) {
+ elementLocalName = omNode.getValue();
+ assertTrue("No Header or Body element exists .......", (elementLocalName.equalsIgnoreCase("Header") || elementLocalName.equalsIgnoreCase("Body")));
+ elementNodes++;
+ }
+ totalNumberOfChildren++;
+ }
+
+ assertEquals("Two Elements should exist", 2, elementNodes);
+ assertEquals("Three Text nodes should exist", 3, textNodes);
+ assertEquals("Five children should exist", 5, totalNumberOfChildren);
+
+ System.out.println(" \t\t OK");
+
+ }
+
+ public final void testNamespaceOperations() {
+ String uri = "http://opensource.lk/chinthaka";
+ String prefix = "prefix";
+
+ System.out.print("Testing create namespace .......");
+ root.createNamespace(uri, prefix);
+ OMNamespace namespace = root.resolveNamespace(uri, prefix);
+ assertTrue("namespace has not been set properly ", namespace.equals(uri, prefix));
+ System.out.println(" \t\t OK");
+
+ System.out.print("Testing resolve namespace .......");
+ OMNamespace dummyNamespace = root.resolveNamespace("dummy uri", " dummy prefix");
+ assertTrue(dummyNamespace == null);
+ System.out.println(" \t\t OK");
+
+ System.out.print("Testing get Namespace ...");
+ namespace = root.getNamespace();
+ assertTrue(namespace.equals("http://schemas.xmlsoap.org/soap/envelope/", "soapenv"));
+ System.out.println(" \t\t\t\t OK");
+
+ System.out.print("Testing set namespace .......");
+ namespace = OMNodeBuilder.createOMNamespace(uri, prefix);
+ root.setNamespace(namespace);
+ assertTrue(root.getNamespace().equals(namespace));
+ System.out.println(" \t\t\t OK");
+
+ }
+
+
+ public final void testGetAttributeWithQName() {
+ System.out.print("Testing getAttributeWithQName ...");
+
+
+ Iterator toElementIter = getToElementIterator();
+ if (toElementIter == null) {
+ assertFalse("No To element found in the header element", true);
+ } else {
+ if (toElementIter.hasNext()) {
+ OMElement toElement = (OMElement) toElementIter.next();
+ Iterator attrubuteIter = toElement.getAttributeWithQName(new QName("http://schemas.xmlsoap.org/soap/envelope/", "mustUnderstand"));
+ if (attrubuteIter.hasNext()) {
+ OMAttribute omAttribute = (OMAttribute) attrubuteIter.next();
+ assertTrue(omAttribute.getLocalName().equalsIgnoreCase("mustUnderstand") && omAttribute.getValue().equals("0"));
+ }
+
+ }
+ }
+
+ System.out.println(" \t\t OK");
+
+ }
+
+ private Iterator getToElementIterator() {
+ Iterator headerElementIter = root.getChildrenWithName(new QName("http://schemas.xmlsoap.org/soap/envelope/", "Header"));
+ if (headerElementIter.hasNext()) {
+ OMElement omElement = (OMElement) headerElementIter.next();
+ return omElement.getChildrenWithName(new QName("http://schemas.xmlsoap.org/ws/2004/03/addressing", "To"));
+ }
+
+ return null;
+ }
+
+ public final void testGetAttributes() {
+ System.out.print("Testing getAttributes ...");
+
+ Iterator toElementIter = getToElementIterator();
+ if (toElementIter == null) {
+ assertFalse("No To element found in the header element", true);
+ } else {
+ if (toElementIter.hasNext()) {
+ OMElement toElement = (OMElement) toElementIter.next();
+ Iterator toElementAttributeIter = toElement.getAttributes();
+
+ int attribCount = 0;
+ while (toElementAttributeIter.hasNext()) {
+ OMAttribute omAttribute = (OMAttribute) toElementAttributeIter.next();
+ assertTrue("To element having attributes, other than mustUnderstand", omAttribute.getLocalName().equalsIgnoreCase("mustUnderstand"));
+ attribCount++;
+ }
+
+ assertTrue("To element having more than one attribute", attribCount == 1);
+ }
+ }
+
+ System.out.println(" \t\t OK");
+
+ }
+
+ public final void testInsertAttribute() {
+ System.out.print("Testing insertAttribute ....");
+
+ Iterator toElementIter = getToElementIterator();
+ if (toElementIter == null) {
+ assertFalse("No To element found in the header element", true);
+ } else {
+ if (toElementIter.hasNext()) {
+ OMElement toElement = (OMElement) toElementIter.next();
+ toElement.insertAttribute(OMNodeBuilder.createOMAttribute("AttributeOne", null, "AttributeValueOne", toElement));
+ toElement.insertAttribute(OMNodeBuilder.createOMAttribute("AttributeTwo", null, "AttributeValueTwo", toElement));
+
+ Iterator toElementAttributeIter = toElement.getAttributes();
+ boolean attribOneFound = false;
+ boolean attribTwoFound = false;
+
+ int attribCount = 0;
+ while (toElementAttributeIter.hasNext()) {
+ OMAttribute omAttribute = (OMAttribute) toElementAttributeIter.next();
+ if (omAttribute.getLocalName().equalsIgnoreCase("AttributeOne")) {
+ attribOneFound = true;
+ } else if (omAttribute.getLocalName().equalsIgnoreCase("AttributeTwo")) {
+ attribTwoFound = true;
+ }
+ attribCount++;
+
+ }
+
+ assertTrue("insertAttribute is not working properly", attribCount == 3);
+ assertTrue("Attribute insertion has not worked properly", attribOneFound && attribTwoFound);
+
+ }
+ }
+
+ System.out.println(" \t\t OK");
+ }
+
+ public final void testRemoveAttribute() {
+ System.out.print("Testing insertAttribute ....");
+
+ Iterator toElementIter = getToElementIterator();
+ if (toElementIter == null) {
+ assertFalse("No To element found in the header element", true);
+ } else {
+ if (toElementIter.hasNext()) {
+ OMElement toElement = (OMElement) toElementIter.next();
+ OMAttribute omAttribute = OMNodeBuilder.createOMAttribute("AttributeOne", null, "AttributeValueOne", toElement);
+ toElement.insertAttribute(omAttribute);
+
+ Iterator toElementAttributeIter = toElement.getAttributes();
+
+ int attribCount = 0;
+ while (toElementAttributeIter.hasNext()) {
+ toElementAttributeIter.next();
+ attribCount++;
+ }
+ assertTrue("Attribute addition has not been done properly", attribCount == 2);
+
+ toElement.removeAttribute(omAttribute);
+
+ toElementAttributeIter = toElement.getAttributes();
+ attribCount = 0;
+ while (toElementAttributeIter.hasNext()) {
+ toElementAttributeIter.next();
+ attribCount++;
+ }
+ assertTrue("Attribute removal has not been done properly", attribCount == 1);
+
+ }
+ }
+ System.out.println(" \t\t OK");
+
+ }
+
+ public final void testGetLocalName() {
+ System.out.print("Testing getLocalName ...");
+ assertEquals("getLocalName not working properly ..", "Envelope", root.getLocalName());
+ System.out.println(" \t\t OK");
+ }
+
+ public final void testSetLocalName() {
+ System.out.print("Testing setLocalName ...");
+ root.setLocalName("NewLocalName");
+ assertEquals("setLocalName not working properly ..", "NewLocalName", root.getLocalName());
+ System.out.println(" \t\t OK");
+ }
+
+
+ public final void testGetParent() {
+ System.out.print("Testing getParent ...");
+
+ Iterator rootChildrenIter = root.getChildren();
+ while (rootChildrenIter.hasNext()) {
+ OMNode omNode = (OMNode) rootChildrenIter.next();
+ assertTrue("getParent has some problems", omNode.getParent() == root);
+ }
+ System.out.println(" \t\t OK");
+
+ }
+
+
+ public final void testGetNextSibling() {
+ System.out.print("Testing getNextSibling ...");
+
+ Iterator rootChildrenIter = root.getChildren();
+ OMNode previousSibling = null;
+ while (rootChildrenIter.hasNext()) {
+ OMNode omNode = (OMNode) rootChildrenIter.next();
+ if (previousSibling != null) {
+ assertTrue("getNextSibling is not working properly ... ", previousSibling.getNextSibling() == omNode);
+ }
+ }
+
+ System.out.println(" \t\t OK");
+
+ }
+
+ public final void testSetNextSibling() {
+ System.out.print("Testing getNextSibling ...");
+
+ Iterator rootChildrenIter = root.getChildren();
+
+ OMNode firstChild = getNextChild(rootChildrenIter);
+ OMNode secondChild = getNextChild(rootChildrenIter);
+ OMNode thirdChild = getNextChild(rootChildrenIter);
+
+ firstChild.setNextSibling(thirdChild);
+
+ assertTrue(firstChild.getNextSibling() == thirdChild);
+ System.out.println(" \t\t OK");
+
+ }
+
+ private OMNode getNextChild(Iterator rootChildrenIter) {
+ if (rootChildrenIter.hasNext()) {
+ return (OMNode) rootChildrenIter.next();
+ }
+
+ return null;
+ }
+
+ public final void testGetValue() {
+ System.out.print("Testing getValue ...");
+ assertEquals("Local Name is not equal to value of Element", root.getValue(), root.getLocalName());
+ System.out.println(" \t\t OK");
+ }
+
+ public final void testIsComplete() {
+ System.out.print("Testing isComplete ...");
+
+ Iterator rootChildrenIter = root.getChildren();
+
+ OMNode firstChild = getNextChild(rootChildrenIter);
+ getNextChild(rootChildrenIter);
+
+ assertTrue("Complete has not been set properly", firstChild.isComplete());
+ System.out.println(" \t\t OK");
+
+ }
+
+ public final void testDetach() {
+ System.out.println("Testing detach ....");
+ Iterator childrenIterator = root.getChildren();
+ while (childrenIterator.hasNext()) {
+ OMNode omNode = (OMNode) childrenIterator.next();
+ if (omNode.getType() == OMNode.TEXT_NODE) {
+ omNode.detach();
+ }
+ }
+
+ childrenIterator = root.getChildren();
+ while (childrenIterator.hasNext()) {
+ OMNode omNode = (OMNode) childrenIterator.next();
+ if (omNode.getType() == OMNode.TEXT_NODE) {
+ assertTrue("Detaching is not working", false);
+ }
+ }
+
+ System.out.println(" \t\t OK");
+
+ }
+
+ public final void testInsertSiblingAfter() {
+ System.out.print("Testing insertSiblingAfter ...");
+
+ Iterator rootChildrenIter = root.getChildren();
+
+ OMNode firstChild = getNextChild(rootChildrenIter);
+ OMNode secondChild = getNextChild(rootChildrenIter);
+ OMNode thirdChild = getNextChild(rootChildrenIter);
+
+ firstChild.insertSiblingAfter(thirdChild);
+
+ assertTrue("insertSiblingAfter is not woking properly", firstChild.getNextSibling() == thirdChild);
+ System.out.println(" \t\t OK");
+
+ }
+
+ public final void testInsertSiblingBefore() {
+ System.out.print("Testing insertSiblingBefore ...");
+
+ Iterator rootChildrenIter = root.getChildren();
+
+ OMNode firstChild = getNextChild(rootChildrenIter);
+ OMNode secondChild = getNextChild(rootChildrenIter);
+ OMNode thirdChild = getNextChild(rootChildrenIter);
+
+ firstChild.insertSiblingBefore(thirdChild);
+
+ assertTrue("insertSiblingBefore is not woking properly", thirdChild.getNextSibling() == firstChild);
+ System.out.println(" \t\t OK");
+ }
+
+ public final void testGetType() {
+ assertTrue("Element type is not set properly ", root.getType() == OMNode.ELEMENT_NODE);
+ }
+
+
+}
+>>>>>>> .r55205
Modified: webservices/axis/trunk/java/dev/scratch/chinthaka/OMAPI_with_Impl/src/test/org/apache/axis/om/util/OMNodeBuilder.java
==============================================================================
--- webservices/axis/trunk/java/dev/scratch/chinthaka/OMAPI_with_Impl/src/test/org/apache/axis/om/util/OMNodeBuilder.java (original)
+++ webservices/axis/trunk/java/dev/scratch/chinthaka/OMAPI_with_Impl/src/test/org/apache/axis/om/util/OMNodeBuilder.java Thu Oct 28 21:15:38 2004
@@ -1,3 +1,4 @@
+<<<<<<< .mine
package org.apache.axis.om.util;
import org.apache.axis.om.OMElement;
@@ -85,3 +86,92 @@
}
}
+=======
+package org.apache.axis.om.util;
+
+import org.apache.axis.om.OMElement;
+import org.apache.axis.om.OMNamespace;
+import org.apache.axis.om.OMAttribute;
+import org.apache.axis.om.impl.OMElementImpl;
+import org.apache.axis.om.impl.OMXmlPullParserWrapper;
+import org.apache.axis.om.impl.OMNamespaceImpl;
+import org.apache.axis.om.impl.OMAttributeImpl;
+
+/**
+ * Copyright 2001-2004 The Apache Software Foundation.
+ * <p/>
+ * 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
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * 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.
+ * <p/>
+ * User: Eran Chinthaka - Lanka Software Foundation
+ * Date: Oct 14, 2004
+ * Time: 1:19:29 PM
+ *
+ * I created this class to be dependant on the implementation, so that one has to change only this class
+ * to test a different implementation which implements the proposed OM API
+ */
+public class OMNodeBuilder {
+ /**
+ *
+ * @param parent
+ * @return
+ */
+ public static OMElement createOMElement(OMElement parent){
+ return new OMElementImpl(parent);
+ }
+
+ /**
+ *
+ * @param localName
+ * @param namespace
+ * @return
+ */
+ public static OMElement createOMElement(String localName, OMNamespace namespace){
+ return new OMElementImpl(localName, namespace);
+ }
+
+ /**
+ *
+ * @param localName
+ * @param namespace
+ * @param parent
+ * @param pullParserWrapper
+ * @return
+ */
+ public static OMElement createOMElement(String localName, OMNamespace namespace, OMElement parent, OMXmlPullParserWrapper pullParserWrapper){
+ return new OMElementImpl(localName, namespace, parent, pullParserWrapper);
+ }
+
+ /**
+ *
+ * @param uri
+ * @param prefix
+ * @return
+ */
+ public static OMNamespace createOMNamespace(String uri, String prefix){
+ return new OMNamespaceImpl(uri, prefix);
+ }
+
+ /**
+ *
+ * @param localName
+ * @param ns
+ * @param value
+ * @param parent
+ * @return
+ */
+ public static OMAttribute createOMAttribute(String localName, OMNamespace ns, String value, OMElement parent){
+ return new OMAttributeImpl(localName, ns, value, parent);
+ }
+
+}
+>>>>>>> .r55205