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 [2/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/
Added: webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/om/impl/llom/OMStAXWrapper.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/om/impl/llom/OMStAXWrapper.java?view=auto&rev=157534
==============================================================================
--- webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/om/impl/llom/OMStAXWrapper.java (added)
+++ webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/om/impl/llom/OMStAXWrapper.java Tue Mar 15 02:56:31 2005
@@ -0,0 +1,1170 @@
+/*
+ * 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.OMElement;
+import org.apache.axis.om.OMNamedNode;
+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.exception.OMStreamingException;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import javax.xml.namespace.NamespaceContext;
+import javax.xml.namespace.QName;
+import javax.xml.stream.Location;
+import javax.xml.stream.XMLStreamConstants;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+import java.util.Iterator;
+import java.util.Stack;
+
+/**
+ * Note - This class also implements the streaming constants interface
+ * to get access to the StAX constants
+ */
+public class OMStAXWrapper implements XMLStreamReader, XMLStreamConstants {
+ /**
+ * Field log
+ */
+ private Log log = LogFactory.getLog(getClass());
+
+ /**
+ * Field navigator
+ */
+ private OMNavigator navigator;
+
+ /**
+ * Field builder
+ */
+ private OMXMLParserWrapper builder;
+
+ /**
+ * Field parser
+ */
+ private XMLStreamReader parser;
+
+ /**
+ * Field rootNode
+ */
+ private OMNode rootNode;
+
+ /**
+ * Field isFirst
+ */
+ private boolean isFirst = true;
+
+ // navigable means the output should be taken from the navigator
+ // as soon as the navigator returns a null navigable will be reset
+ // to false and the subsequent events will be taken from the builder
+ // or the parser directly
+
+ /**
+ * Field NAVIGABLE
+ */
+ private static final short NAVIGABLE = 0;
+
+ /**
+ * Field SWITCH_AT_NEXT
+ */
+ private static final short SWITCH_AT_NEXT = 1;
+
+ /**
+ * Field COMPLETED
+ */
+ private static final short COMPLETED = 2;
+
+ /**
+ * Field SWITCHED
+ */
+ private static final short SWITCHED = 3;
+
+ /**
+ * Field state
+ */
+ private short state;
+
+ /**
+ * Field currentEvent
+ */
+ private int currentEvent = 0;
+
+ // SwitchingAllowed is set to false by default
+ // this means that unless the user explicitly states
+ // that he wants things not to be cached, everything will
+ // be cached
+
+ /**
+ * Field switchingAllowed
+ */
+ boolean switchingAllowed = false;
+
+ /**
+ * Field elementStack
+ */
+ private Stack elementStack = new Stack();
+
+ // keeps the next event. The parser actually keeps one step ahead to
+ // detect the end of navigation. (at the end of the stream the navigator
+ // returns a null
+
+ /**
+ * Field nextNode
+ */
+ private OMNode nextNode = null;
+
+ // holder for the current node. Needs this to generate events from the current node
+
+ /**
+ * Field currentNode
+ */
+ private OMNode currentNode = null;
+
+ // needs this to refer to the last known node
+
+ /**
+ * Field lastNode
+ */
+ private OMNode lastNode = null;
+
+ /**
+ * Method setAllowSwitching
+ *
+ * @param b
+ */
+ public void setAllowSwitching(boolean b) {
+ this.switchingAllowed = b;
+ }
+
+ /**
+ * Method isAllowSwitching
+ *
+ * @return
+ */
+ public boolean isAllowSwitching() {
+ return switchingAllowed;
+ }
+
+ /**
+ * When constructing the OMStaxWrapper, the creator must produce the
+ * builder (an instance of the OMXMLparserWrapper of the input) and the
+ * Element Node to start parsing. The wrapper wil parse(proceed) until
+ * the end of the given element. hence care should be taken to pass the
+ * root element if the entire document is needed
+ *
+ * @param builder
+ * @param startNode
+ */
+ OMStAXWrapper(OMXMLParserWrapper builder, OMElement startNode) {
+ this(builder, startNode, false);
+ }
+
+ /**
+ * Constructor OMStAXWrapper
+ *
+ * @param builder
+ * @param startNode
+ * @param cacheOff
+ */
+ OMStAXWrapper(OMXMLParserWrapper builder, OMElement startNode,
+ boolean cacheOff) {
+
+ // create a navigator
+ this.navigator = new OMNavigator(startNode);
+ this.builder = builder;
+ this.rootNode = startNode;
+
+ // initaite the next and current nodes
+ // Note - navigator is written in such a way that it first
+ // returns the starting node at the first call to it
+ currentNode = navigator.next();
+ updateNextNode();
+ switchingAllowed = cacheOff;
+ }
+
+ /**
+ * @return
+ * @see javax.xml.stream.XMLStreamReader#getPrefix()
+ */
+ public String getPrefix() {
+ String returnStr = null;
+ if (parser != null) {
+ returnStr = parser.getPrefix();
+ } else {
+ if ((currentEvent == START_ELEMENT)
+ || (currentEvent == END_ELEMENT)) {
+ OMNamespace ns = ((OMElement) lastNode).getNamespace();
+ returnStr = (ns == null)
+ ? null
+ : ns.getPrefix();
+ }
+ }
+ return returnStr;
+ }
+
+ /**
+ * @return
+ * @see javax.xml.stream.XMLStreamReader#getNamespaceURI()
+ */
+ public String getNamespaceURI() {
+ String returnStr = null;
+ if (parser != null) {
+ returnStr = parser.getNamespaceURI();
+ } else {
+ if ((currentEvent == START_ELEMENT)
+ || (currentEvent == END_ELEMENT)
+ || (currentEvent == NAMESPACE)) {
+ OMNamespace ns = ((OMElement) lastNode).getNamespace();
+ returnStr = (ns == null)
+ ? null
+ : ns.getName();
+ }
+ }
+ return returnStr;
+ }
+
+ /**
+ * @return
+ * @see javax.xml.stream.XMLStreamReader#hasName()
+ */
+ public boolean hasName() {
+ if (parser != null) {
+ return parser.hasName();
+ } else {
+ return ((currentEvent == START_ELEMENT)
+ || (currentEvent == END_ELEMENT));
+ }
+ }
+
+ /**
+ * @return
+ * @see javax.xml.stream.XMLStreamReader#getLocalName()
+ */
+ public String getLocalName() {
+ String returnStr = null;
+ if (parser != null) {
+ returnStr = parser.getLocalName();
+ } else {
+ if ((currentEvent == START_ELEMENT)
+ || (currentEvent == END_ELEMENT)
+ || (currentEvent == ENTITY_REFERENCE)) {
+ returnStr = ((OMElement) lastNode).getLocalName();
+ }
+ }
+ return returnStr;
+ }
+
+ /**
+ * @return
+ * @see javax.xml.stream.XMLStreamReader#getName()
+ */
+ public QName getName() {
+ QName returnName = null;
+ if (parser != null) {
+ returnName = parser.getName();
+ } else {
+ if ((currentEvent == START_ELEMENT)
+ || (currentEvent == END_ELEMENT)) {
+ returnName = getQName((OMNamedNode) lastNode);
+ }
+ }
+ return returnName;
+ }
+
+ /**
+ * @return
+ * @see javax.xml.stream.XMLStreamReader#hasText()
+ */
+ public boolean hasText() {
+ return ((currentEvent == CHARACTERS) || (currentEvent == DTD)
+ || (currentEvent == ENTITY_REFERENCE)
+ || (currentEvent == COMMENT) || (currentEvent == SPACE));
+ }
+
+ /**
+ * @return
+ * @see javax.xml.stream.XMLStreamReader#getTextLength()
+ */
+ public int getTextLength() {
+ int returnLength = 0;
+ if (parser != null) {
+ returnLength = parser.getTextLength();
+ } else {
+ OMText textNode = (OMText) lastNode;
+ returnLength = textNode.getValue().length();
+ }
+ return returnLength;
+ }
+
+ /**
+ * @return
+ * @see javax.xml.stream.XMLStreamReader#getTextStart()
+ */
+ public int getTextStart() {
+ int returnLength = 0;
+ if (parser != null) {
+ returnLength = parser.getTextStart();
+ }
+
+ // Note - this has no relevant method in the OM
+ return returnLength;
+ }
+
+ /**
+ * @param i
+ * @param chars
+ * @param i1
+ * @param i2
+ * @return
+ * @throws XMLStreamException
+ * @see javax.xml.stream.XMLStreamReader#getTextCharacters(int, char[], int, int)
+ */
+ public int getTextCharacters(int i, char[] chars, int i1, int i2)
+ throws XMLStreamException {
+ int returnLength = 0;
+ if (hasText()) {
+ if (parser != null) {
+ try {
+ returnLength = parser.getTextCharacters(i, chars, i1, i2);
+ } catch (XMLStreamException e) {
+ throw new OMStreamingException(e);
+ }
+ }
+
+ // Note - this has no relevant method in the OM
+ }
+ return returnLength;
+ }
+
+ /**
+ * @return
+ * @see javax.xml.stream.XMLStreamReader#getTextCharacters()
+ */
+ public char[] getTextCharacters() {
+ char[] returnArray = null;
+ if (parser != null) {
+ returnArray = parser.getTextCharacters();
+ } else {
+ if (hasText()) {
+ OMText textNode = (OMText) lastNode;
+ String str = textNode.getValue();
+ returnArray = str.toCharArray();
+ }
+ }
+ return returnArray;
+ }
+
+ /**
+ * @return
+ * @see javax.xml.stream.XMLStreamReader#getText()
+ */
+ public String getText() {
+ String returnString = null;
+ if (parser != null) {
+ returnString = parser.getText();
+ } else {
+ if (hasText()) {
+ OMText textNode = (OMText) lastNode;
+ returnString = textNode.getValue();
+ }
+ }
+ return returnString;
+ }
+
+ /**
+ * @return
+ * @see javax.xml.stream.XMLStreamReader#getEventType()
+ */
+
+ // todo this should be improved
+ public int getEventType() {
+ return currentEvent;
+ }
+
+ /**
+ * @param i
+ * @return
+ * @see javax.xml.stream.XMLStreamReader#getNamespaceURI
+ */
+ public String getNamespaceURI(int i) {
+ String returnString = null;
+ if (parser != null) {
+ returnString = parser.getNamespaceURI(i);
+ } else {
+ if (isStartElement() || isEndElement()
+ || (currentEvent == NAMESPACE)) {
+ OMNamespace ns = (OMNamespace) getItemFromIterator(
+ ((OMElement) lastNode).getAllDeclaredNamespaces(), i);
+ returnString = (ns == null)
+ ? null
+ : ns.getName();
+ }
+ }
+ return returnString;
+ }
+
+ /**
+ * @param i
+ * @return
+ * @see javax.xml.stream.XMLStreamReader#getNamespacePrefix
+ */
+ public String getNamespacePrefix(int i) {
+ String returnString = null;
+ if (parser != null) {
+ returnString = parser.getNamespacePrefix(i);
+ } else {
+ if (isStartElement() || isEndElement()
+ || (currentEvent == NAMESPACE)) {
+ OMNamespace ns = (OMNamespace) getItemFromIterator(
+ ((OMElement) lastNode).getAllDeclaredNamespaces(), i);
+ returnString = (ns == null)
+ ? null
+ : ns.getPrefix();
+ }
+ }
+ return returnString;
+ }
+
+ /**
+ * @return
+ * @see javax.xml.stream.XMLStreamReader#getNamespaceCount()
+ */
+ public int getNamespaceCount() {
+ int returnCount = 0;
+ if (parser != null) {
+ returnCount = parser.getNamespaceCount();
+ } else {
+ if (isStartElement() || isEndElement()
+ || (currentEvent == NAMESPACE)) {
+ returnCount =
+ getCount(((OMElement) lastNode).getAllDeclaredNamespaces());
+ }
+ }
+ return returnCount;
+ }
+
+ /**
+ * @param i
+ * @return
+ * @see javax.xml.stream.XMLStreamReader#isAttributeSpecified
+ */
+ public boolean isAttributeSpecified(int i) {
+ boolean returnValue = false;
+ if (parser != null) {
+ returnValue = parser.isAttributeSpecified(i);
+ } else {
+ if (isStartElement() || (currentEvent == ATTRIBUTE)) {
+
+ // theres nothing to be returned here
+ } else {
+ throw new IllegalStateException(
+ "attribute type accessed in illegal event!");
+ }
+ }
+ return returnValue;
+ }
+
+ /**
+ * @param i
+ * @return
+ * @see javax.xml.stream.XMLStreamReader#getAttributeValue
+ */
+ public String getAttributeValue(int i) {
+ String returnString = null;
+ if (parser != null) {
+ returnString = parser.getAttributeValue(i);
+ } else {
+ if (isStartElement() || (currentEvent == ATTRIBUTE)) {
+ OMAttribute attrib = getAttribute((OMElement) lastNode, i);
+ if (attrib != null) {
+ returnString = attrib.getValue();
+ }
+ } else {
+ throw new IllegalStateException(
+ "attribute type accessed in illegal event!");
+ }
+ }
+ return returnString;
+ }
+
+ /**
+ * @param i
+ * @return
+ * @see javax.xml.stream.XMLStreamReader#getAttributeType
+ */
+ public String getAttributeType(int i) {
+ String returnString = null;
+ if (parser != null) {
+ returnString = parser.getAttributeType(i);
+ } else {
+ if (isStartElement() || (currentEvent == ATTRIBUTE)) {
+
+ // todo implement this
+ } else {
+ throw new IllegalStateException(
+ "attribute type accessed in illegal event!");
+ }
+ }
+ return returnString;
+ }
+
+ /**
+ * @param i
+ * @return
+ * @see javax.xml.stream.XMLStreamReader#getAttributePrefix
+ */
+ public String getAttributePrefix(int i) {
+ String returnString = null;
+ if (parser != null) {
+ returnString = parser.getAttributePrefix(i);
+ } else {
+ if (isStartElement() || (currentEvent == ATTRIBUTE)) {
+ OMAttribute attrib = getAttribute((OMElement) lastNode, i);
+ if (attrib != null) {
+ OMNamespace nameSpace = attrib.getNamespace();
+ if (nameSpace != null) {
+ returnString = nameSpace.getPrefix();
+ }
+ }
+ } else {
+ throw new IllegalStateException(
+ "attribute prefix accessed in illegal event!");
+ }
+ }
+ return returnString;
+ }
+
+ /**
+ * @param i
+ * @return
+ * @see javax.xml.stream.XMLStreamReader#getAttributeLocalName
+ */
+ public String getAttributeLocalName(int i) {
+ String returnString = null;
+ if (parser != null) {
+ returnString = parser.getAttributeLocalName(i);
+ } else {
+ if (isStartElement() || (currentEvent == ATTRIBUTE)) {
+ OMAttribute attrib = getAttribute((OMElement) lastNode, i);
+ if (attrib != null) {
+ returnString = attrib.getLocalName();
+ }
+ } else {
+ throw new IllegalStateException(
+ "attribute localName accessed in illegal event!");
+ }
+ }
+ return returnString;
+ }
+
+ /**
+ * @param i
+ * @return
+ * @see javax.xml.stream.XMLStreamReader#getAttributeNamespace
+ */
+ public String getAttributeNamespace(int i) {
+ String returnString = null;
+ if (parser != null) {
+ returnString = parser.getAttributeNamespace(i);
+ } else {
+ if (isStartElement() || (currentEvent == ATTRIBUTE)) {
+ OMAttribute attrib = getAttribute((OMElement) lastNode, i);
+ if (attrib != null) {
+ OMNamespace nameSpace = attrib.getNamespace();
+ if (nameSpace != null) {
+ returnString = nameSpace.getName();
+ }
+ }
+ } else {
+ throw new IllegalStateException(
+ "attribute nameSpace accessed in illegal event!");
+ }
+ }
+ return returnString;
+ }
+
+ /**
+ * @param i
+ * @return
+ * @see javax.xml.stream.XMLStreamReader#getAttributeName
+ */
+ public QName getAttributeName(int i) {
+ QName returnQName = null;
+ if (parser != null) {
+ returnQName = parser.getAttributeName(i);
+ } else {
+ if (isStartElement() || (currentEvent == ATTRIBUTE)) {
+ returnQName = getAttribute((OMElement) lastNode, i).getQName();
+ } else {
+ throw new IllegalStateException(
+ "attribute count accessed in illegal event!");
+ }
+ }
+ return returnQName;
+ }
+
+ /**
+ * @return
+ * @see javax.xml.stream.XMLStreamReader#getAttributeCount
+ */
+ public int getAttributeCount() {
+ int returnCount = 0;
+ if (parser != null) {
+ returnCount = parser.getAttributeCount();
+ } else {
+ if (isStartElement() || (currentEvent == ATTRIBUTE)) {
+ OMElement elt = (OMElement) lastNode;
+ returnCount = getCount(elt.getAttributes());
+ } else {
+ throw new IllegalStateException(
+ "attribute count accessed in illegal event!");
+ }
+ }
+ return returnCount;
+ }
+
+ // todo
+
+ /**
+ * Method getAttributeValue
+ *
+ * @param s
+ * @param s1
+ * @return
+ */
+ public String getAttributeValue(String s, String s1) {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * Method isWhiteSpace
+ *
+ * @return
+ */
+ public boolean isWhiteSpace() {
+ boolean b;
+ if (parser != null) {
+ b = parser.isWhiteSpace();
+ } else {
+ b = (currentEvent == SPACE);
+ }
+ return b;
+ }
+
+ /**
+ * Method isCharacters
+ *
+ * @return
+ */
+ public boolean isCharacters() {
+ boolean b;
+ if (parser != null) {
+ b = parser.isCharacters();
+ } else {
+ b = (currentEvent == CHARACTERS);
+ }
+ return b;
+ }
+
+ /**
+ * Method isEndElement
+ *
+ * @return
+ */
+ public boolean isEndElement() {
+ boolean b;
+ if (parser != null) {
+ b = parser.isEndElement();
+ } else {
+ b = (currentEvent == END_ELEMENT);
+ }
+ return b;
+ }
+
+ /**
+ * @param i
+ * @param s
+ * @param s1
+ * @throws XMLStreamException
+ * @see javax.xml.stream.XMLStreamReader#require(int, String, String)
+ */
+ public void require(int i, String s, String s1) throws XMLStreamException {
+ throw new XMLStreamException();
+ }
+
+ /**
+ * Method isStartElement
+ *
+ * @return
+ */
+ public boolean isStartElement() {
+ boolean b;
+ if (parser != null) {
+ b = parser.isStartElement();
+ } else {
+ b = (currentEvent == START_ELEMENT);
+ }
+ return b;
+ }
+
+ /**
+ * Method getNamespaceURI
+ *
+ * @param s
+ * @return
+ */
+ public String getNamespaceURI(String s) {
+ String returnString = null;
+ if (parser != null) {
+ returnString = parser.getNamespaceURI(s);
+ } else {
+ if (isStartElement() || isEndElement()
+ || (currentEvent == NAMESPACE)) {
+
+ // Nothing to do here! How to get the namespacace references
+ }
+ }
+ return returnString;
+ }
+
+ /**
+ * Method close
+ *
+ * @throws XMLStreamException
+ */
+ public void close() throws XMLStreamException {
+
+ // this doesnot mean anything with respect to the OM
+ if (parser != null) {
+ parser.close();
+ }
+ }
+
+ /**
+ * Method hasNext
+ *
+ * @return
+ * @throws XMLStreamException
+ */
+ public boolean hasNext() throws XMLStreamException {
+ return !(state == COMPLETED);
+ }
+
+ /**
+ * Not implemented yet
+ *
+ * @return
+ * @throws org.apache.axis.om.impl.llom.exception.OMStreamingException
+ *
+ * @throws XMLStreamException
+ */
+ public int nextTag() throws XMLStreamException {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * @return
+ * @throws XMLStreamException
+ * @see javax.xml.stream.XMLStreamReader#getElementText()
+ */
+ public String getElementText() throws XMLStreamException {
+ String returnText = "";
+ if (parser != null) {
+ try {
+ returnText = parser.getElementText();
+ } catch (XMLStreamException e) {
+ throw new OMStreamingException(e);
+ }
+ } else {
+ if (currentNode.getType() == OMNode.ELEMENT_NODE) {
+
+ // todo complete this
+ return null;
+ }
+ }
+ return returnText;
+ }
+
+ /**
+ * Method next
+ *
+ * @return
+ * @throws XMLStreamException
+ */
+ public int next() throws XMLStreamException {
+ switch (state) {
+ case COMPLETED:
+ throw new OMStreamingException("Parser completed!");
+ case SWITCH_AT_NEXT:
+ state = SWITCHED;
+
+ // load the parser
+ try {
+ parser = (XMLStreamReader) builder.getParser();
+ } catch (ClassCastException e) {
+ throw new UnsupportedOperationException(
+ "incompatible parser found!");
+ }
+ log.info(
+ "Switching to the Real Stax parser to generated the future events");
+ currentEvent = parser.getEventType();
+ updateCompleteStatus();
+ break;
+ case NAVIGABLE:
+ currentEvent = generateEvents(currentNode);
+ updateCompleteStatus();
+ updateLastNode();
+ break;
+ case SWITCHED:
+ currentEvent = parser.next();
+ updateCompleteStatus();
+ break;
+ default :
+ throw new OMStreamingException("unsuppported state!");
+ }
+ return currentEvent;
+ }
+
+ /**
+ * Method getProperty
+ *
+ * @param s
+ * @return
+ * @throws IllegalArgumentException
+ */
+ public Object getProperty(String s) throws IllegalArgumentException {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * This is a very important method. this keeps the
+ * navigator one step ahead and pushes the navigator
+ * one event ahead. If the nextNode is null then navigable is set to false;
+ * At the same time the parser and builder are set up for the upcoming event
+ * generation
+ *
+ * @throws XMLStreamException
+ */
+ private void updateLastNode() throws XMLStreamException {
+ lastNode = currentNode;
+ currentNode = nextNode;
+ try {
+ updateNextNode();
+ } catch (Exception e) {
+ throw new XMLStreamException(e);
+ }
+ }
+
+ /**
+ * Method updateNextNode
+ */
+ private void updateNextNode() {
+ if (navigator.isNavigable()) {
+ nextNode = navigator.next();
+ } else {
+ if (!switchingAllowed) {
+ if (navigator.isCompleted()) {
+ nextNode = null;
+ } else {
+ builder.next();
+ navigator.step();
+ nextNode = navigator.next();
+ }
+ } else {
+
+ // reset caching (the default is ON so it was not needed in the
+ // earlier case!
+ builder.setCache(false);
+ state = SWITCH_AT_NEXT;
+ }
+ }
+ }
+
+ /**
+ * Method updateCompleteStatus
+ */
+ private void updateCompleteStatus() {
+ if (state == NAVIGABLE) {
+ if (rootNode == currentNode) {
+ if (isFirst) {
+ isFirst = false;
+ } else {
+ state = COMPLETED;
+ }
+ }
+ } else {
+ state = (currentEvent == END_DOCUMENT)
+ ? COMPLETED
+ : state;
+ }
+ }
+
+ /**
+ * Method getNamespaceContext
+ *
+ * @return
+ */
+ public NamespaceContext getNamespaceContext() {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * Method getEncoding
+ *
+ * @return
+ */
+ public String getEncoding() {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * Method getLocation
+ *
+ * @return
+ */
+ public Location getLocation() {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * Method getVersion
+ *
+ * @return
+ */
+ public String getVersion() {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * Method isStandalone
+ *
+ * @return
+ */
+ public boolean isStandalone() {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * Method standaloneSet
+ *
+ * @return
+ */
+ public boolean standaloneSet() {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * Method getCharacterEncodingScheme
+ *
+ * @return
+ */
+ public String getCharacterEncodingScheme() {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * Method getPITarget
+ *
+ * @return
+ */
+ public String getPITarget() {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * Method getPIData
+ *
+ * @return
+ */
+ public String getPIData() {
+ throw new UnsupportedOperationException();
+ }
+
+ /*
+ *
+ * ################################################################
+ * Generator methods for the OMNodes returned by the navigator
+ * ################################################################
+ *
+ */
+
+ /**
+ * Method generateEvents
+ *
+ * @param node
+ * @return
+ */
+ private int generateEvents(OMNode node) {
+ int returnEvent = 0;
+ int nodeType = node.getType();
+ switch (nodeType) {
+ case OMNode.ELEMENT_NODE:
+ OMElement element = (OMElement) node;
+ log.info("Generating events from element {"
+ + element.getNamespaceName() + '}'
+ + element.getLocalName() + " Generated OM tree");
+ returnEvent = generateElementEvents(element);
+ break;
+ case OMNode.TEXT_NODE:
+ returnEvent = generateTextEvents();
+ break;
+ case OMNode.COMMENT_NODE:
+ returnEvent = generateCommentEvents();
+ break;
+ case OMNode.CDATA_SECTION_NODE:
+ returnEvent = generateCdataEvents();
+ break;
+ default :
+ break; // just ignore any other nodes
+ }
+ return returnEvent;
+ }
+
+ /**
+ * Method generateElementEvents
+ *
+ * @param elt
+ * @return
+ */
+ private int generateElementEvents(OMElement elt) {
+ int returnValue = START_ELEMENT;
+ if (!elementStack.isEmpty() && elementStack.peek().equals(elt)) {
+ returnValue = END_ELEMENT;
+ elementStack.pop();
+ } else {
+ elementStack.push(elt);
+ }
+ return returnValue;
+ }
+
+ /**
+ * Method generateTextEvents
+ *
+ * @return
+ */
+ private int generateTextEvents() {
+ return CHARACTERS;
+ }
+
+ /**
+ * Method generateCommentEvents
+ *
+ * @return
+ */
+ private int generateCommentEvents() {
+ return COMMENT;
+ }
+
+ /**
+ * Method generateCdataEvents
+ *
+ * @return
+ */
+ private int generateCdataEvents() {
+ return CDATA;
+ }
+
+ /*
+ * ####################################################################
+ * Other helper methods
+ * ####################################################################
+ */
+
+ /**
+ * helper method
+ *
+ * @param it
+ * @return
+ */
+ private int getCount(Iterator it) {
+ int count = 0;
+ if (it != null) {
+ while (it.hasNext()) {
+ it.next();
+ count++;
+ }
+ }
+ return count;
+ }
+
+ /**
+ * Helper method
+ *
+ * @param it
+ * @param index
+ * @return
+ */
+ private Object getItemFromIterator(Iterator it, int index) {
+ int count = 0;
+ Object returnObject = null;
+ boolean found = false;
+ if (it != null) {
+ while (it.hasNext()) {
+ returnObject = it.next();
+ if (index == count++) {
+ found = true;
+ break;
+ }
+ }
+ }
+ if (found) {
+ return returnObject;
+ } else {
+ return null;
+ }
+ }
+
+ /**
+ * Helper method
+ *
+ * @param namedNode
+ * @return
+ */
+ private QName getQName(OMNamedNode namedNode) {
+ QName returnName;
+ OMNamespace ns = namedNode.getNamespace();
+ String localPart = namedNode.getLocalName();
+ if (ns != null) {
+ String prefix = ns.getPrefix();
+ String uri = ns.getName();
+ if ((prefix == null) || prefix.equals("")) {
+ returnName = new QName(uri, localPart);
+ } else {
+ returnName = new QName(uri, localPart, prefix);
+ }
+ } else {
+ returnName = new QName(localPart);
+ }
+ return returnName;
+ }
+
+ /**
+ * @param elt
+ * @param index
+ * @return
+ */
+ private OMAttribute getAttribute(OMElement elt, int index) {
+ OMAttribute returnAttrib = null;
+ if (elt != null) {
+ returnAttrib =
+ (OMAttribute) getItemFromIterator(elt.getAttributes(), index);
+ }
+ return returnAttrib;
+ }
+}
Added: webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/om/impl/llom/OMTextImpl.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/om/impl/llom/OMTextImpl.java?view=auto&rev=157534
==============================================================================
--- webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/om/impl/llom/OMTextImpl.java (added)
+++ webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/om/impl/llom/OMTextImpl.java Tue Mar 15 02:56:31 2005
@@ -0,0 +1,175 @@
+/*
+ * 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.OMConstants;
+import org.apache.axis.encoding.*;
+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 javax.activation.DataHandler;
+import org.apache.axis.om.impl.llom.mtom.*;
+
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamWriter;
+
+/**
+ * Class OMTextImpl
+ */
+public class OMTextImpl extends OMNodeImpl implements OMText, OMConstants {
+ /**
+ * Field textType
+ */
+ protected short textType = TEXT_NODE;
+
+ protected String mimeType;
+
+ /**
+ * Constructor OMTextImpl
+ *
+ * @param parent
+ * @param text
+ */
+ public OMTextImpl(OMElement parent, String text) {
+ super(parent);
+ setValue(text);
+ done = true;
+ }
+
+ /**
+ * Constructor OMTextImpl
+ *
+ * @param s
+ */
+ public OMTextImpl(String s) {
+ setValue(s);
+ }
+ /**
+ * Constructor OMTextImpl
+ * Used when the contant is Base64 encoded binary
+ * @param s
+ * @param type - Mime type
+ */
+ public OMTextImpl(String s,String mimeType) {
+ setValue(s);
+ this.mimeType= mimeType;
+ }
+
+ /**
+ * 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) {
+ if ((type == TEXT_NODE) || (type == COMMENT_NODE)
+ || (type == CDATA_SECTION_NODE)) {
+ this.textType = type;
+ } else {
+ throw new UnsupportedOperationException(
+ "Attempt to set wrong type");
+ }
+ }
+
+ /**
+ * Method getTextType
+ *
+ * @return
+ */
+ public short getTextType() {
+ return textType;
+ }
+
+ /**
+ * Method getFirstChild
+ *
+ * @return
+ * @throws OMException
+ */
+ public OMNode getFirstChild() throws OMException {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * Method setFirstChild
+ *
+ * @param node
+ * @throws OMException
+ */
+ public void setFirstChild(OMNode node) throws OMException {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * @return
+ * @throws org.apache.axis.om.OMException
+ * @throws OMException
+ */
+ public short getType() throws OMException {
+ return textType;
+ }
+
+ /**
+ * @return
+ * @throws org.apache.axis.om.OMException
+ * @throws OMException
+ */
+ public DataHandler getDataHandler() throws OMException {
+ /*
+ * this should return a DataHandler containing the binary data
+ * reperesented by the Base64 strings stored in OMText
+ */
+ String value;
+ if ((value = getValue())!=null)
+ {
+ ByteArrayDataSource dataSource;
+ byte[] data = Base64.decode(value);
+ if (mimeType!=null)
+ {
+ dataSource = new ByteArrayDataSource(data,mimeType);
+ }
+ else
+ {
+ // Assumes type as application/octet-stream
+ dataSource = new ByteArrayDataSource(data);
+ }
+ DataHandler DH = new DataHandler(dataSource);
+ return DH;
+ }
+ return null;
+ }
+
+ /**
+ * @param writer
+ * @param cache
+ * @throws XMLStreamException
+ */
+ public void serialize(XMLStreamWriter writer, boolean cache)
+ throws XMLStreamException {
+ if (textType == TEXT_NODE) {
+ writer.writeCharacters(this.value);
+ } else if (textType == COMMENT_NODE) {
+ writer.writeComment(this.value);
+ } else if (textType == CDATA_SECTION_NODE) {
+ writer.writeCData(this.value);
+ }
+ OMNode nextSibling = this.getNextSibling();
+ if (nextSibling != null) {
+ nextSibling.serialize(writer, cache);
+ }
+ }
+}
Added: webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/om/impl/llom/SOAPBodyImpl.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/om/impl/llom/SOAPBodyImpl.java?view=auto&rev=157534
==============================================================================
--- webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/om/impl/llom/SOAPBodyImpl.java (added)
+++ webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/om/impl/llom/SOAPBodyImpl.java Tue Mar 15 02:56:31 2005
@@ -0,0 +1,130 @@
+/*
+ * 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.OMConstants;
+import org.apache.axis.om.OMElement;
+import org.apache.axis.om.OMException;
+import org.apache.axis.om.OMXMLParserWrapper;
+import org.apache.axis.om.SOAPBody;
+import org.apache.axis.om.SOAPEnvelope;
+import org.apache.axis.om.SOAPFault;
+
+/**
+ * Class SOAPBodyImpl
+ */
+public class SOAPBodyImpl extends OMElementImpl
+ implements SOAPBody, OMConstants {
+ /**
+ * Field hasSOAPFault
+ */
+ private boolean hasSOAPFault = false;
+
+ /**
+ * @param envelope
+ */
+ public SOAPBodyImpl(SOAPEnvelope envelope) {
+ super(envelope);
+ this.ns = envelope.getNamespace();
+ this.localName = OMConstants.BODY_LOCAL_NAME;
+ }
+
+ /**
+ * Constructor SOAPBodyImpl
+ *
+ * @param envelope
+ * @param builder
+ */
+ public SOAPBodyImpl(SOAPEnvelope envelope, OMXMLParserWrapper builder) {
+ super(OMConstants.BODY_LOCAL_NAME, envelope.getNamespace(), envelope,
+ builder);
+ }
+
+ /**
+ * Creates a new <code>SOAPFault</code> object and adds it to
+ * this <code>SOAPBody</code> object.
+ *
+ * @param e
+ * @return the new <code>SOAPFault</code> object
+ * @throws org.apache.axis.om.OMException if there is a SOAP error
+ * @throws OMException
+ */
+ public SOAPFault addFault(Exception e) throws OMException {
+ SOAPFault soapFault = new SOAPFaultImpl(this, e);
+ addFault(soapFault);
+ return soapFault;
+ }
+
+ /**
+ * 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 boolean hasFault() {
+ if (hasSOAPFault) {
+ return true;
+ } else {
+ OMElement element = getFirstElement();
+ if(element != null
+ && SOAPFAULT_LOCAL_NAME.equals(element.getLocalName())
+ && SOAPFAULT_NAMESPACE_URI.equals(element.getNamespaceName())){
+ hasSOAPFault = true;
+ return true;
+ }else{
+ return false;
+ }
+ }
+ }
+
+ /**
+ * 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 SOAPFault getFault() {
+ if(hasSOAPFault){
+ OMElement element = getFirstElement();
+ if(element != null
+ && SOAPFAULT_LOCAL_NAME.equals(element.getLocalName())
+ && SOAPFAULT_NAMESPACE_URI.equals(element.getNamespaceName())){
+ hasSOAPFault = true;
+ return (SOAPFault)element;
+ }else{
+ return null;
+ }
+ }
+ return null;
+ }
+
+ /**
+ * @param soapFault
+ * @throws org.apache.axis.om.OMException
+ * @throws OMException
+ */
+ public void addFault(SOAPFault soapFault) throws OMException {
+ if (hasSOAPFault) {
+ throw new OMException(
+ "SOAP Body already has a SOAP Fault and there can not be more than one SOAP fault");
+ }
+ addChild(soapFault);
+ hasSOAPFault = true;
+ }
+}
Added: webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/om/impl/llom/SOAPEnvelopeImpl.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/om/impl/llom/SOAPEnvelopeImpl.java?view=auto&rev=157534
==============================================================================
--- webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/om/impl/llom/SOAPEnvelopeImpl.java (added)
+++ webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/om/impl/llom/SOAPEnvelopeImpl.java Tue Mar 15 02:56:31 2005
@@ -0,0 +1,112 @@
+/*
+ * 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.OMConstants;
+import org.apache.axis.om.OMElement;
+import org.apache.axis.om.OMException;
+import org.apache.axis.om.OMNamespace;
+import org.apache.axis.om.OMXMLParserWrapper;
+import org.apache.axis.om.SOAPBody;
+import org.apache.axis.om.SOAPEnvelope;
+import org.apache.axis.om.SOAPHeader;
+
+/**
+ * Class SOAPEnvelopeImpl
+ */
+public class SOAPEnvelopeImpl extends OMElementImpl
+ implements SOAPEnvelope, OMConstants {
+ /**
+ * @param builder
+ */
+ public SOAPEnvelopeImpl(OMXMLParserWrapper builder) {
+ super(SOAPENVELOPE_LOCAL_NAME, null, null, builder);
+ }
+
+ /**
+ * Constructor SOAPEnvelopeImpl
+ *
+ * @param ns
+ * @param builder
+ */
+ public SOAPEnvelopeImpl(OMNamespace ns, OMXMLParserWrapper builder) {
+ super(SOAPENVELOPE_LOCAL_NAME, ns, null, builder);
+ }
+
+ /**
+ * @param ns
+ */
+ public SOAPEnvelopeImpl(OMNamespace ns) {
+ super(SOAPENVELOPE_LOCAL_NAME, ns);
+ }
+
+ /**
+ * Returns the <CODE>SOAPHeader</CODE> object for this <CODE>
+ * SOAPEnvelope</CODE> object.
+ * <P> This SOAPHeader will just be a container for all the headers in the
+ * <CODE>OMMessage</CODE>
+ * </P>
+ *
+ * @return the <CODE>SOAPHeader</CODE> object or <CODE>
+ * null</CODE> if there is none
+ * @throws org.apache.axis.om.OMException if there is a problem
+ * obtaining the <CODE>SOAPHeader</CODE> object
+ * @throws OMException
+ */
+ public SOAPHeader getHeader() throws OMException {
+ OMElement element = getFirstElement();
+ if (OMConstants.HEADER_LOCAL_NAME.equals(element.getLocalName())) {
+ return (SOAPHeader) element;
+ }
+ return null;
+ }
+
+ /**
+ * Returns the <CODE>SOAPBody</CODE> object associated with
+ * this <CODE>SOAPEnvelope</CODE> object.
+ * <P> This SOAPBody will just be a container for all the BodyElements in the
+ * <CODE>OMMessage</CODE>
+ * </P>
+ *
+ * @return the <CODE>SOAPBody</CODE> object for this <CODE>
+ * SOAPEnvelope</CODE> object or <CODE>null</CODE> if there
+ * is none
+ * @throws org.apache.axis.om.OMException if there is a problem
+ * obtaining the <CODE>SOAPBody</CODE> object
+ * @throws OMException
+ */
+ public SOAPBody getBody() throws OMException {
+ OMElement element = getFirstElement();
+ if (OMConstants.BODY_LOCAL_NAME.equals(element.getLocalName())) {
+ return (SOAPBody) element;
+ }else{
+ element = element.getNextSiblingElement();
+ if (OMConstants.BODY_LOCAL_NAME.equals(element.getLocalName())) {
+ return (SOAPBody) element;
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Method detach
+ *
+ * @throws OMException
+ */
+ public void detach() throws OMException {
+ throw new OMException("Root Element can not be detached");
+ }
+}
Added: webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/om/impl/llom/SOAPFaultImpl.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/om/impl/llom/SOAPFaultImpl.java?view=auto&rev=157534
==============================================================================
--- webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/om/impl/llom/SOAPFaultImpl.java (added)
+++ webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/om/impl/llom/SOAPFaultImpl.java Tue Mar 15 02:56:31 2005
@@ -0,0 +1,303 @@
+/*
+ * 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.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.SOAPFault;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLOutputFactory;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamWriter;
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.util.Iterator;
+
+/**
+ * Class SOAPFaultImpl
+ */
+public class SOAPFaultImpl extends OMElementImpl
+ implements SOAPFault, OMConstants {
+ /**
+ * Field e
+ */
+ private Exception e;
+
+ /**
+ * Field faultCodeElement
+ */
+ private OMElementImpl faultCodeElement;
+
+ /**
+ * Field faultActorElement
+ */
+ private OMElementImpl faultActorElement;
+
+ /**
+ * Field faultStringElement
+ */
+ private OMElementImpl faultStringElement;
+
+ /**
+ * Field detailElement
+ */
+ private OMElementImpl detailElement;
+
+ /**
+ * Constructor SOAPFaultImpl
+ *
+ * @param parent
+ * @param e
+ */
+ public SOAPFaultImpl(OMElement parent, Exception e) {
+ super(SOAPFAULT_LOCAL_NAME,
+ new OMNamespaceImpl(SOAPFAULT_NAMESPACE_URI,
+ SOAPFAULT_NAMESPACE_PREFIX));
+ this.parent = (OMElementImpl) parent;
+ this.e = e;
+ StringWriter sw = new StringWriter();
+ e.printStackTrace(new PrintWriter(sw));
+ this.setDetailInformation(OMFactory.newInstance().createText(this,
+ sw.getBuffer().toString()));
+ }
+
+ /**
+ * Constructor SOAPFaultImpl
+ *
+ * @param ns
+ * @param parent
+ * @param builder
+ */
+ public SOAPFaultImpl(OMNamespace ns, OMElement parent,
+ OMXMLParserWrapper builder) {
+ super(SOAPFAULT_LOCAL_NAME, ns, parent, builder);
+ }
+
+ /**
+ * Method setFaultCode
+ *
+ * @param faultCode
+ * @throws OMException
+ */
+ public void setFaultCode(QName faultCode) throws OMException {
+ if (faultCodeElement != null) {
+ faultCodeElement.detach();
+ }
+ faultCodeElement =
+ new OMElementImpl(OMConstants.SOAPFAULT_CODE_LOCAL_NAME, this.ns);
+ this.addChild(faultCodeElement);
+ faultCodeElement.addChild(new OMTextImpl(faultCodeElement,
+ faultCode.getPrefix() + ':'
+ + faultCode.getLocalPart()));
+ }
+
+ /**
+ * Method getFaultCode
+ *
+ * @return
+ */
+ public QName getFaultCode() {
+ if (faultCodeElement != null) {
+ Iterator childrenIter = faultCodeElement.getChildren();
+ while (childrenIter.hasNext()) {
+ Object o = childrenIter.next();
+ if ((o instanceof OMText)
+ && !((OMText) o).getValue().trim().equals("")) {
+ String[] strings = ((OMText) o).getValue().split(":");
+ return new QName("", strings[1], strings[0]);
+ }
+ }
+ } else {
+ faultCodeElement = (OMElementImpl) this.getChildWithName(
+ new QName(
+ this.ns.getName(), OMConstants.SOAPFAULT_CODE_LOCAL_NAME,
+ this.ns.getPrefix()));
+ if (faultCodeElement != null) {
+ return this.getFaultCode();
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Method setFaultActor
+ *
+ * @param faultActor
+ * @throws OMException
+ */
+ public void setFaultActor(String faultActor) throws OMException {
+ if (faultActorElement != null) {
+ faultActorElement.detach();
+ }
+ faultActorElement =
+ new OMElementImpl(OMConstants.SOAPFAULT_ACTOR_LOCAL_NAME, this.ns);
+ this.addChild(faultActorElement);
+ faultActorElement.addChild(new OMTextImpl(faultActorElement,
+ faultActor));
+ }
+
+ /**
+ * Method getFaultActor
+ *
+ * @return
+ */
+ public String getFaultActor() {
+ if (faultActorElement != null) {
+ Iterator childrenIter = faultActorElement.getChildren();
+ while (childrenIter.hasNext()) {
+ Object o = childrenIter.next();
+ if ((o instanceof OMText)
+ && !"".equals(((OMText) o).getValue())) {
+ return ((OMText) o).getValue();
+ }
+ }
+ } else {
+ faultActorElement = (OMElementImpl) this.getChildWithName(
+ new QName(
+ this.ns.getName(), OMConstants.SOAPFAULT_ACTOR_LOCAL_NAME,
+ this.ns.getPrefix()));
+ if (faultActorElement != null) {
+ return this.getFaultString();
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Method setFaultString
+ *
+ * @param faultString
+ * @throws OMException
+ */
+ public void setFaultString(String faultString) throws OMException {
+ if (faultStringElement != null) {
+ faultStringElement.detach();
+ }
+ faultStringElement =
+ new OMElementImpl(OMConstants.SOAPFAULT_STRING_LOCAL_NAME, this.ns);
+ this.addChild(faultStringElement);
+ faultStringElement.addChild(new OMTextImpl(faultStringElement,
+ faultString));
+ }
+
+ /**
+ * Method getFaultString
+ *
+ * @return
+ */
+ public String getFaultString() {
+ if (faultStringElement != null) {
+ Iterator childrenIter = faultStringElement.getChildren();
+ while (childrenIter.hasNext()) {
+ Object o = childrenIter.next();
+ if ((o instanceof OMText)
+ && !"".equals(((OMText) o).getValue())) {
+ return ((OMText) o).getValue();
+ }
+ }
+ } else {
+ faultStringElement = (OMElementImpl) this.getChildWithName(
+ new QName(
+ this.ns.getName(), OMConstants.SOAPFAULT_STRING_LOCAL_NAME,
+ this.ns.getPrefix()));
+ if (faultStringElement != null) {
+ return this.getFaultString();
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Method setDetailInformation
+ *
+ * @param detail
+ */
+ public void setDetailInformation(OMNode detail) {
+ if (detailElement != null) {
+ detailElement.detach();
+ }
+ detailElement =
+ new OMElementImpl(OMConstants.SOAPFAULT_DETAIL_LOCAL_NAME, this.ns);
+ this.addChild(detailElement);
+ detailElement.addChild(detail);
+ }
+
+ /**
+ * Method getDetailInformation
+ *
+ * @return
+ */
+ public OMNode getDetailInformation() {
+ if (detailElement != null) {
+ Iterator childrenIter = detailElement.getChildren();
+ while (childrenIter.hasNext()) {
+ Object o = childrenIter.next();
+ if (!((o instanceof OMText)
+ && "".equals(((OMText) o).getValue()))) {
+ return (OMNode) o;
+ }
+ }
+ } else {
+ detailElement = (OMElementImpl) this.getChildWithName(
+ new QName(
+ this.ns.getName(), OMConstants.SOAPFAULT_DETAIL_LOCAL_NAME,
+ this.ns.getPrefix()));
+ if (detailElement != null) {
+ return this.getDetailInformation();
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Method getException
+ *
+ * @return
+ * @throws OMException
+ */
+ public Exception getException() throws OMException {
+ if (e == null) {
+ OMNode detailsInformationNode = this.getDetailInformation();
+ if (detailsInformationNode instanceof OMElement) {
+ try {
+ StringWriter sw = new StringWriter();
+ XMLStreamWriter writer =
+ XMLOutputFactory.newInstance().createXMLStreamWriter(
+ sw);
+ ((OMElement) detailsInformationNode).serialize(writer,
+ true);
+ writer.flush();
+ return new Exception(sw.toString());
+ } catch (XMLStreamException e1) {
+ throw new OMException("Exception in StAX Writer", e1);
+ }
+ } else if (detailsInformationNode instanceof OMText) {
+ return new Exception(
+ ((OMText) detailsInformationNode).getValue());
+ }
+ } else {
+ return e;
+ }
+ return null;
+ }
+}
Added: webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/om/impl/llom/SOAPHeaderBlockImpl.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/om/impl/llom/SOAPHeaderBlockImpl.java?view=auto&rev=157534
==============================================================================
--- webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/om/impl/llom/SOAPHeaderBlockImpl.java (added)
+++ webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/om/impl/llom/SOAPHeaderBlockImpl.java Tue Mar 15 02:56:31 2005
@@ -0,0 +1,152 @@
+/*
+ * 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.OMNamespace;
+import org.apache.axis.om.OMXMLParserWrapper;
+import org.apache.axis.om.SOAPHeaderBlock;
+
+import javax.xml.namespace.QName;
+
+/**
+ * Class SOAPHeaderBlockImpl
+ */
+public class SOAPHeaderBlockImpl extends OMElementImpl
+ implements SOAPHeaderBlock {
+ /**
+ * @param localName
+ * @param ns
+ */
+ public SOAPHeaderBlockImpl(String localName, OMNamespace ns) {
+ super(localName, ns);
+ }
+
+ /**
+ * Constructor SOAPHeaderBlockImpl
+ *
+ * @param localName
+ * @param ns
+ * @param parent
+ * @param builder
+ */
+ public SOAPHeaderBlockImpl(String localName, OMNamespace ns,
+ OMElement parent, OMXMLParserWrapper builder) {
+ super(localName, ns, parent, builder);
+ }
+
+ /**
+ * Sets the actor associated with this <CODE>
+ * SOAPHeaderBlock</CODE> object to the specified actor. The
+ * default value of an actor is: <CODE>
+ * OMConstants.URI_SOAP_ACTOR_NEXT</CODE>
+ *
+ * @param actorURI a <CODE>String</CODE> giving
+ * the URI of the actor to set
+ * @throws IllegalArgumentException if
+ * there is a problem in setting the actor.
+ * @see #getActor() getActor()
+ */
+ public void setActor(String actorURI) {
+ setAttribute(OMConstants.ATTR_ACTOR, actorURI);
+ }
+
+ /**
+ * @param attributeName
+ * @param attrValue
+ */
+ private void setAttribute(String attributeName, String attrValue) {
+ OMAttribute omAttribute = this.getAttributeWithQName(
+ new QName(OMConstants.SOAP_ENVELOPE_NAMESPACE_URI, attributeName));
+ if (omAttribute != null) {
+ omAttribute.setValue(attrValue);
+ } else {
+ OMAttribute attribute = new OMAttributeImpl(
+ attributeName,
+ new OMNamespaceImpl(
+ OMConstants.SOAP_ENVELOPE_NAMESPACE_URI,
+ OMConstants.SOAPENVELOPE_NAMESPACE_PREFIX), attrValue);
+ this.insertAttribute(attribute);
+ }
+ }
+
+ /**
+ * Returns the uri of the actor associated with this <CODE>
+ * SOAPHeaderBlock</CODE> object.
+ *
+ * @return a <CODE>String</CODE> giving the URI of the
+ * actor
+ * @see #setActor(String) setActor(java.lang.String)
+ */
+ public String getActor() {
+ return getAttribute(OMConstants.ATTR_ACTOR);
+ }
+
+ /**
+ * Method getAttribute
+ *
+ * @param attrName
+ * @return
+ */
+ private String getAttribute(String attrName) {
+ OMAttribute omAttribute = this.getAttributeWithQName(
+ new QName(OMConstants.SOAP_ENVELOPE_NAMESPACE_URI, attrName));
+ return (omAttribute != null)
+ ? omAttribute.getValue()
+ : null;
+ }
+
+ /**
+ * Sets the mustUnderstand attribute for this <CODE>
+ * SOAPHeaderBlock</CODE> object to be on or off.
+ * <P>If the mustUnderstand attribute is on, the actor who
+ * receives the <CODE>SOAPHeaderBlock</CODE> must process it
+ * correctly. This ensures, for example, that if the <CODE>
+ * SOAPHeaderBlock</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 IllegalArgumentException if
+ * there is a problem in setting the actor.
+ * @see #getMustUnderstand() getMustUnderstand()
+ */
+ public void setMustUnderstand(boolean mustUnderstand) {
+ setAttribute(OMConstants.ATTR_MUSTUNDERSTAND, mustUnderstand
+ ? "true"
+ : "false");
+ }
+
+ /**
+ * Returns whether the mustUnderstand attribute for this
+ * <CODE>SOAPHeaderBlock</CODE> object is turned on.
+ *
+ * @return <CODE>true</CODE> if the mustUnderstand attribute of
+ * this <CODE>SOAPHeaderBlock</CODE> object is turned on;
+ * <CODE>false</CODE> otherwise
+ */
+ public boolean getMustUnderstand() {
+ String mustUnderstand = "";
+ if ((mustUnderstand = getAttribute(OMConstants.ATTR_MUSTUNDERSTAND))
+ != null) {
+ return mustUnderstand.equalsIgnoreCase("true");
+ }
+ return false;
+ }
+}
Added: webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/om/impl/llom/SOAPHeaderImpl.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/om/impl/llom/SOAPHeaderImpl.java?view=auto&rev=157534
==============================================================================
--- webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/om/impl/llom/SOAPHeaderImpl.java (added)
+++ webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/om/impl/llom/SOAPHeaderImpl.java Tue Mar 15 02:56:31 2005
@@ -0,0 +1,185 @@
+/*
+ * 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.OMConstants;
+import org.apache.axis.om.OMException;
+import org.apache.axis.om.OMNamespace;
+import org.apache.axis.om.OMXMLParserWrapper;
+import org.apache.axis.om.SOAPEnvelope;
+import org.apache.axis.om.SOAPHeader;
+import org.apache.axis.om.SOAPHeaderBlock;
+import org.apache.axis.om.impl.llom.traverse.OMChildrenWithSpecificAttributeIterator;
+
+import javax.xml.namespace.QName;
+import java.util.Iterator;
+
+/**
+ * Class SOAPHeaderImpl
+ */
+public class SOAPHeaderImpl extends OMElementImpl implements SOAPHeader {
+ /**
+ * @param envelope
+ */
+ public SOAPHeaderImpl(SOAPEnvelope envelope) {
+ super(envelope);
+
+ // set the namespaces
+ this.ns = envelope.getNamespace();
+ this.localName = OMConstants.HEADER_LOCAL_NAME;
+ }
+
+ /**
+ * Constructor SOAPHeaderImpl
+ *
+ * @param envelope
+ * @param builder
+ */
+ public SOAPHeaderImpl(SOAPEnvelope envelope, OMXMLParserWrapper builder) {
+ super(OMConstants.HEADER_LOCAL_NAME, (envelope == null)
+ ? null
+ : envelope.getNamespace(), envelope,
+ builder);
+ }
+
+ /**
+ * Creates a new <CODE>SOAPHeaderBlock</CODE> object
+ * initialized with the specified name and adds it to this
+ * <CODE>SOAPHeader</CODE> object.
+ *
+ * @param localName
+ * @param ns
+ * @return the new <CODE>SOAPHeaderBlock</CODE> object that
+ * was inserted into this <CODE>SOAPHeader</CODE>
+ * object
+ * @throws org.apache.axis.om.OMException if a SOAP error occurs
+ * @throws OMException
+ */
+ public SOAPHeaderBlock addHeaderBlock(String localName, OMNamespace ns)
+ throws OMException {
+ SOAPHeaderBlock soapHeaderBlock = new SOAPHeaderBlockImpl(localName,
+ ns);
+ this.addChild(soapHeaderBlock);
+ soapHeaderBlock.setComplete(true);
+ return soapHeaderBlock;
+ }
+
+ /**
+ * Returns a list of all the <CODE>SOAPHeaderBlock</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 paramActor a <CODE>String</CODE> giving the
+ * URI of the actor for which to search
+ * @return an <CODE>Iterator</CODE> object over all the <CODE>
+ * SOAPHeaderBlock</CODE> objects that contain the
+ * specified actor
+ * @see #extractHeaderBlocks(String) extractHeaderBlocks(java.lang.String)
+ */
+ public Iterator examineHeaderBlocks(String paramActor) {
+ Iterator headerBlocksIter = this.getChildren();
+ while (headerBlocksIter.hasNext()) {
+ Object o = headerBlocksIter.next();
+ if (o instanceof SOAPHeaderBlock) {
+ SOAPHeaderBlock soapHeaderBlock = (SOAPHeaderBlock) o;
+ String actor = soapHeaderBlock.getActor();
+ if ((actor != null) && actor.equalsIgnoreCase(paramActor)) {
+
+ // headerBlocksIter.
+ }
+ }
+ }
+ return headerBlocksIter;
+ }
+
+ /**
+ * Returns a list of all the <CODE>SOAPHeaderBlock</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>
+ * SOAPHeaderBlock</CODE> objects that contain the
+ * specified actor
+ * @see #examineHeaderBlocks(String) examineHeaderBlocks(java.lang.String)
+ */
+ public Iterator extractHeaderBlocks(String actor) {
+ return new OMChildrenWithSpecificAttributeIterator(
+ getFirstChild(),
+ new QName(
+ OMConstants.SOAP_ENVELOPE_NAMESPACE_URI, OMConstants.ATTR_ACTOR),
+ actor, true);
+ }
+
+ /**
+ * Returns an <code>Iterator</code> over all the
+ * <code>SOAPHeaderBlock</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>SOAPHeaderBlock</code> objects that contain the
+ * specified actor and are marked as MustUnderstand
+ */
+ public Iterator examineMustUnderstandHeaderBlocks(String actor) {
+ return new OMChildrenWithSpecificAttributeIterator(
+ getFirstChild(),
+ new QName(
+ OMConstants.SOAP_ENVELOPE_NAMESPACE_URI, OMConstants.ATTR_ACTOR),
+ actor, false);
+ }
+
+ /**
+ * Returns an <code>Iterator</code> over all the
+ * <code>SOAPHeaderBlock</code> objects in this <code>SOAPHeader</code>
+ * object.
+ * Not that this will return elements containing the QName (http://schemas.xmlsoap.org/soap/envelope/, Header)
+ *
+ * @return an <code>Iterator</code> object over all the
+ * <code>SOAPHeaderBlock</code> objects contained by this
+ * <code>SOAPHeader</code>
+ */
+ public Iterator examineAllHeaderBlocks() {
+ return this.getChildrenWithName(null);
+ }
+
+ /**
+ * Returns an <code>Iterator</code> over all the
+ * <code>SOAPHeaderBlock</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>SOAPHeaderBlock</code> objects contained by this
+ * <code>SOAPHeader</code>
+ */
+ public Iterator extractAllHeaderBlocks() {
+ throw new UnsupportedOperationException(); // TODO implement this
+ }
+}
Added: webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/om/impl/llom/builder/MTOMStAXSOAPModelBuilder.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/om/impl/llom/builder/MTOMStAXSOAPModelBuilder.java?view=auto&rev=157534
==============================================================================
--- webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/om/impl/llom/builder/MTOMStAXSOAPModelBuilder.java (added)
+++ webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/om/impl/llom/builder/MTOMStAXSOAPModelBuilder.java Tue Mar 15 02:56:31 2005
@@ -0,0 +1,114 @@
+/*
+ * Created on Mar 11, 2005
+ *
+ * TODO To change the template for this generated file go to
+ * Window - Preferences - Java - Code Style - Code Templates
+ */
+package org.apache.axis.om.impl.llom.builder;
+
+import org.apache.axis.om.*;
+import org.apache.axis.om.impl.llom.mtom.*;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import java.io.IOException;
+import java.io.InputStream;
+
+import javax.mail.MessagingException;
+import javax.xml.stream.FactoryConfigurationError;
+import javax.xml.stream.XMLStreamException;
+
+/**
+ * @author Thilina Gunarathne
+ * thilina@opensource.lk
+ */
+public class MTOMStAXSOAPModelBuilder extends StAXSOAPModelBuilder {
+ private Log log = LogFactory.getLog(getClass());
+
+ MTOMBuilder MtomBuilder;
+
+ public MTOMStAXSOAPModelBuilder(OMFactory ombuilderFactory,
+ InputStream inStream) throws Exception, XMLStreamException,
+ FactoryConfigurationError, IOException, MessagingException {
+ super(ombuilderFactory);
+ MtomBuilder = new MTOMBuilder(inStream);
+ this.parser = MtomBuilder.getParser();
+ }
+
+ public MTOMStAXSOAPModelBuilder(InputStream inStream)
+ throws XMLStreamException, FactoryConfigurationError, IOException,
+ MessagingException {
+ super();
+ MtomBuilder = new MTOMBuilder(inStream);
+ this.parser = MtomBuilder.getParser();
+ }
+
+ protected OMNode createOMElement() throws OMException {
+
+ String elementName = parser.getLocalName();
+
+ String namespaceURI = parser.getNamespaceURI();
+
+ // create an OMBlob if the element is an <xop:Include>
+ if (elementName.equalsIgnoreCase("Include")
+ & namespaceURI
+ .equalsIgnoreCase("http://www.w3.org/2004/08/xop/include")) {
+
+ OMBlob node;
+ String contentID = null;
+ String contentIDName = null;
+ OMAttribute Attr;
+ if (lastNode == null) {
+ // Decide whether to ckeck the level >3 or not
+ throw new OMException(
+ "XOP:Include element is not supported here");
+ }
+ if (parser.getAttributeCount() > 0) {
+ contentID = parser.getAttributeValue(0);
+ contentID = contentID.trim();
+ contentIDName = parser.getAttributeLocalName(0);
+ if (contentIDName.equalsIgnoreCase("href")
+ & contentID.substring(0, 3).equalsIgnoreCase("cid")) {
+ contentID = contentID.substring(4);
+ } else {
+ throw new OMException(
+ "contentID not Found in XOP:Include element");
+ }
+ } else {
+ throw new OMException(
+ "Href attribute not found in XOP:Include element");
+ }
+
+ if (lastNode.isComplete()) {
+ node = new OMBlob(contentID, lastNode.getParent(), MtomBuilder, this);
+ lastNode.setNextSibling(node);
+ node.setPreviousSibling(lastNode);
+ } else {
+ OMElement e = (OMElement) lastNode;
+ node = new OMBlob(contentID, (OMElement) lastNode, MtomBuilder,this);
+ e.setFirstChild(node);
+ }
+ return node;
+
+ } else {
+ OMElement node;
+ if (lastNode == null) {
+ node = constructNode(null, elementName, true);
+ } else if (lastNode.isComplete()) {
+ node = constructNode(lastNode.getParent(), elementName, false);
+ lastNode.setNextSibling(node);
+ node.setPreviousSibling(lastNode);
+ } else {
+ OMElement e = (OMElement) lastNode;
+ node = constructNode((OMElement) lastNode, elementName, false);
+ e.setFirstChild(node);
+ }
+
+ // fill in the attributes
+ processAttributes(node);
+ log.info("Build the OMElelment {" + node.getNamespaceName() + '}'
+ + node.getLocalName() + "By the StaxSOAPModelBuilder");
+ return node;
+ }
+ }
+ }
\ No newline at end of file