You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commons-dev@ws.apache.org by ve...@apache.org on 2009/06/20 00:59:58 UTC
svn commit: r786706 - in /webservices/commons/trunk/modules/axiom/modules:
axiom-api/ axiom-api/src/main/java/org/apache/axiom/om/
axiom-api/src/test/java/org/apache/axiom/om/ axiom-dom/
axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/ axiom-impl/...
Author: veithen
Date: Fri Jun 19 22:59:57 2009
New Revision: 786706
URL: http://svn.apache.org/viewvc?rev=786706&view=rev
Log:
WSCOMMONS-479:
* Introduced a common super-interface for OMDocument and OMNode and moved the declarations of methods applicable to both types of information items to that interface.
* Changed the LLOM implementation so that OMDocumentImpl implements all required methods.
* DOOM's DocumentImpl already had all methods (because it inherits from NodeImpl), but the "build" methods was overridden in an incorrect way. Fixed that.
* Added a test case for the "build" method on OMDocument.
Added:
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/OMSerializable.java (with props)
webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMSerializableImpl.java (with props)
Modified:
webservices/commons/trunk/modules/axiom/modules/axiom-api/pom.xml
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/OMContainer.java
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/OMDocument.java
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/OMNode.java
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/java/org/apache/axiom/om/OMDocumentTestBase.java
webservices/commons/trunk/modules/axiom/modules/axiom-dom/pom.xml
webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/DocumentImpl.java
webservices/commons/trunk/modules/axiom/modules/axiom-impl/pom.xml
webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMDocumentImpl.java
webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMElementImpl.java
webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMNodeImpl.java
Modified: webservices/commons/trunk/modules/axiom/modules/axiom-api/pom.xml
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-api/pom.xml?rev=786706&r1=786705&r2=786706&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-api/pom.xml (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-api/pom.xml Fri Jun 19 22:59:57 2009
@@ -68,6 +68,12 @@
<artifactId>${stax.impl.artifact}</artifactId>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>commons-io</groupId>
+ <artifactId>commons-io</artifactId>
+ <version>1.4</version>
+ <scope>test</scope>
+ </dependency>
</dependencies>
<build>
<resources>
Modified: webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/OMContainer.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/OMContainer.java?rev=786706&r1=786705&r2=786706&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/OMContainer.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/OMContainer.java Fri Jun 19 22:59:57 2009
@@ -27,7 +27,7 @@
* <p/>
* <p>Exposes the ability to add, find, and iterate over the children of a document or element.</p>
*/
-public interface OMContainer {
+public interface OMContainer extends OMSerializable {
/**
* Adds the given node as the last child. One must preserve the order of children, in this
@@ -96,7 +96,5 @@
*/
OMNode getFirstOMChild();
- boolean isComplete();
-
void buildNext();
}
Modified: webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/OMDocument.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/OMDocument.java?rev=786706&r1=786705&r2=786706&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/OMDocument.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/OMDocument.java Fri Jun 19 22:59:57 2009
@@ -118,8 +118,4 @@
* @throws XMLStreamException
*/
void serialize(OutputStream output) throws XMLStreamException;
-
- /** Returns the OMFactory that created this object */
- OMFactory getOMFactory();
-
}
Modified: webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/OMNode.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/OMNode.java?rev=786706&r1=786705&r2=786706&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/OMNode.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/OMNode.java Fri Jun 19 22:59:57 2009
@@ -21,7 +21,6 @@
import javax.xml.stream.XMLStreamConstants;
import javax.xml.stream.XMLStreamException;
-import javax.xml.stream.XMLStreamWriter;
import java.io.OutputStream;
import java.io.Writer;
@@ -39,7 +38,7 @@
* addition, while {@link OMDocument} and {@link OMAttribute} exist, neither is an extension of
* <code>OMNode</code>. </p>
*/
-public interface OMNode {
+public interface OMNode extends OMSerializable {
/**
* The node is an <code>Element</code>.
*
@@ -114,15 +113,6 @@
OMNode getNextOMSibling() throws OMException;
/**
- * Indicates whether parser has parsed this information item completely or not. If some 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 Returns boolean.
- */
- boolean isComplete();
-
- /**
* Removes a node (and all of its children) from its containing parent.
* <p/>
* <p/>
@@ -184,14 +174,6 @@
/**
* Serializes the node with caching.
*
- * @param xmlWriter
- * @throws XMLStreamException
- */
- void serialize(XMLStreamWriter xmlWriter) throws XMLStreamException;
-
- /**
- * Serializes the node with caching.
- *
* @param output
* @throws XMLStreamException
*/
@@ -228,15 +210,6 @@
/**
* Serializes the node without caching.
*
- * @param xmlWriter
- * @throws XMLStreamException
- */
- void serializeAndConsume(XMLStreamWriter xmlWriter)
- throws XMLStreamException;
-
- /**
- * Serializes the node without caching.
- *
* @param output
* @throws XMLStreamException
*/
@@ -271,9 +244,6 @@
void serializeAndConsume(Writer writer, OMOutputFormat format)
throws XMLStreamException;
- /** Builds itself. */
- void build();
-
/**
* Builds itself with the OMText binary content. AXIOM supports two levels of deffered building.
* First is deffered building of AXIOM using StAX. Second level is the deffered building of
@@ -288,10 +258,4 @@
* @param build if true, the object is built first before closing the builder/parser
*/
void close(boolean build);
-
- /**
- * Returns the OMFactory that created this object
- */
- OMFactory getOMFactory();
-
}
Added: webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/OMSerializable.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/OMSerializable.java?rev=786706&view=auto
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/OMSerializable.java (added)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/OMSerializable.java Fri Jun 19 22:59:57 2009
@@ -0,0 +1,75 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.axiom.om;
+
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamWriter;
+
+/**
+ * Information item that can be serialized (written to an XML stream writer) and
+ * deserialized (retrieved from an XML parser) as a unit.
+ * This is the common super-interface for {@link OMDocument} and {@link OMNode}.
+ * Note that {@link OMAttribute} and {@link OMNamespace} are information items that don't
+ * match the definition of this interface because they can only be read from the parser
+ * as part of a larger unit, namely an element.
+ * <p>
+ * In accordance with the definition given above, this interface declares two sets of methods:
+ * <ul>
+ * <li>Methods allowing to control whether the information item has been completely built,
+ * i.e. whether all events corresponding to the information item have been retrieved
+ * from the parser.</li>
+ * <li>Methods to write the StAX events corresponding to the information item to an
+ * {@link XMLStreamWriter}.</li>
+ * </ul>
+ */
+public interface OMSerializable {
+ /**
+ * Returns the OMFactory that created this object
+ */
+ OMFactory getOMFactory();
+
+ /**
+ * Indicates whether parser has parsed this information item completely or not. If some 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 Returns boolean.
+ */
+ boolean isComplete();
+
+ /** Builds itself. */
+ void build();
+
+ /**
+ * Serializes the information item with caching.
+ *
+ * @param xmlWriter
+ * @throws XMLStreamException
+ */
+ void serialize(XMLStreamWriter xmlWriter) throws XMLStreamException;
+
+ /**
+ * Serializes the information item without caching.
+ *
+ * @param xmlWriter
+ * @throws XMLStreamException
+ */
+ void serializeAndConsume(XMLStreamWriter xmlWriter) throws XMLStreamException;
+}
Propchange: webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/OMSerializable.java
------------------------------------------------------------------------------
svn:mergeinfo =
Modified: webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/java/org/apache/axiom/om/OMDocumentTestBase.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/java/org/apache/axiom/om/OMDocumentTestBase.java?rev=786706&r1=786705&r2=786706&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/java/org/apache/axiom/om/OMDocumentTestBase.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/java/org/apache/axiom/om/OMDocumentTestBase.java Fri Jun 19 22:59:57 2009
@@ -19,8 +19,8 @@
package org.apache.axiom.om;
-import junit.framework.TestCase;
import org.apache.axiom.om.impl.builder.StAXOMBuilder;
+import org.apache.commons.io.input.CountingInputStream;
import javax.xml.stream.XMLInputFactory;
import javax.xml.stream.XMLStreamException;
@@ -29,7 +29,7 @@
import java.io.StringReader;
import java.util.Iterator;
-public class OMDocumentTestBase extends TestCase {
+public class OMDocumentTestBase extends AbstractTestCase {
private String sampleXML = "<?xml version='1.0' encoding='utf-8'?>" +
"<!--This is some comments at the start of the document-->" +
"<?PITarget PIData?>" +
@@ -120,4 +120,21 @@
// return omDocument;
// }
+ public void testBuild() throws Exception {
+ CountingInputStream in = new CountingInputStream(getTestResource(
+ TestConstants.REALLY_BIG_MESSAGE));
+ OMDocument doc = new StAXOMBuilder(omMetaFactory.getOMFactory(),
+ XMLInputFactory.newInstance().createXMLStreamReader(in)).getDocument();
+ assertFalse(doc.isComplete());
+ int countBeforeBuild = in.getCount();
+ doc.build();
+ assertTrue(doc.isComplete());
+ int countAfterBuild = in.getCount();
+ assertTrue(countAfterBuild > countBeforeBuild);
+ OMNode node = doc.getFirstOMChild();
+ while (node != null) {
+ node = node.getNextOMSibling();
+ }
+ assertEquals(countAfterBuild, in.getCount());
+ }
}
Modified: webservices/commons/trunk/modules/axiom/modules/axiom-dom/pom.xml
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-dom/pom.xml?rev=786706&r1=786705&r2=786706&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-dom/pom.xml (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-dom/pom.xml Fri Jun 19 22:59:57 2009
@@ -76,6 +76,12 @@
<version>2.7.1</version>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>commons-io</groupId>
+ <artifactId>commons-io</artifactId>
+ <version>1.4</version>
+ <scope>test</scope>
+ </dependency>
</dependencies>
<build>
<resources>
Modified: webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/DocumentImpl.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/DocumentImpl.java?rev=786706&r1=786705&r2=786706&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/DocumentImpl.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/DocumentImpl.java Fri Jun 19 22:59:57 2009
@@ -481,13 +481,6 @@
}
}
- public void build() {
- if (this.firstChild != null && !this.firstChild.done) {
- this.firstChild.build();
- }
- this.done = true;
- }
-
protected void addIdAttr(Attr attr) {
if (this.idAttrs == null) {
this.idAttrs = new Vector();
Modified: webservices/commons/trunk/modules/axiom/modules/axiom-impl/pom.xml
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-impl/pom.xml?rev=786706&r1=786705&r2=786706&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-impl/pom.xml (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-impl/pom.xml Fri Jun 19 22:59:57 2009
@@ -76,6 +76,12 @@
<version>2.7.1</version>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>commons-io</groupId>
+ <artifactId>commons-io</artifactId>
+ <version>1.4</version>
+ <scope>test</scope>
+ </dependency>
</dependencies>
<build>
<resources>
Modified: webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMDocumentImpl.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMDocumentImpl.java?rev=786706&r1=786705&r2=786706&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMDocumentImpl.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMDocumentImpl.java Fri Jun 19 22:59:57 2009
@@ -42,7 +42,7 @@
import java.util.Iterator;
/** Class OMDocumentImpl */
-public class OMDocumentImpl implements OMDocument, OMContainerEx {
+public class OMDocumentImpl extends OMSerializableImpl implements OMDocument, OMContainerEx {
/** Field documentElement */
protected OMElement documentElement;
@@ -52,12 +52,6 @@
/** Field lastChild */
protected OMNode lastChild;
- /** Field done */
- protected boolean done = false;
-
- /** Field parserWrapper */
- protected OMXMLParserWrapper parserWrapper;
-
/** Field charSetEncoding Default : UTF-8 */
protected String charSetEncoding = "UTF-8";
@@ -66,8 +60,6 @@
protected String isStandalone;
- protected OMFactory factory;
-
/** Default constructor */
public OMDocumentImpl() {
this.done = true;
@@ -79,12 +71,12 @@
*/
public OMDocumentImpl(OMElement documentElement, OMXMLParserWrapper parserWrapper) {
this.documentElement = documentElement;
- this.parserWrapper = parserWrapper;
+ this.builder = parserWrapper;
}
/** @param parserWrapper */
public OMDocumentImpl(OMXMLParserWrapper parserWrapper) {
- this.parserWrapper = parserWrapper;
+ this.builder = parserWrapper;
}
/**
@@ -129,8 +121,8 @@
* @return Returns OMElement.
*/
public OMElement getOMDocumentElement() {
- while (documentElement == null && parserWrapper != null) {
- parserWrapper.next();
+ while (documentElement == null && builder != null) {
+ builder.next();
}
return documentElement;
}
@@ -145,17 +137,6 @@
}
/**
- * Indicates whether parser has parsed this information item completely or not. If some
- * information is not available in the item, one has to check this attribute to make sure that,
- * this item has been parsed completely or not.
- *
- * @return Returns boolean.
- */
- public boolean isComplete() {
- return done;
- }
-
- /**
* Method setComplete.
*
* @param state
@@ -166,8 +147,8 @@
/** Forces the parser to proceed, if parser has not yet finished with the XML input. */
public void buildNext() {
- if (parserWrapper != null && !parserWrapper.isCompleted()) {
- parserWrapper.next();
+ if (builder != null && !builder.isCompleted()) {
+ builder.next();
}
}
@@ -411,10 +392,4 @@
boolean includeXMLDeclaration) throws XMLStreamException {
OMDocumentImplUtil.internalSerialize(this, writer, cache, includeXMLDeclaration);
}
-
- public OMFactory getOMFactory() {
- return this.getOMDocumentElement().getOMFactory();
- }
-
-
}
Modified: webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMElementImpl.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMElementImpl.java?rev=786706&r1=786705&r2=786706&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMElementImpl.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMElementImpl.java Fri Jun 19 22:59:57 2009
@@ -726,15 +726,6 @@
return this;
}
- /**
- * Method isComplete.
- *
- * @return Returns boolean.
- */
- public boolean isComplete() {
- return done;
- }
-
/** Gets the type of node, as this is the super class of all the nodes. */
public int getType() {
return OMNode.ELEMENT_NODE;
Modified: webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMNodeImpl.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMNodeImpl.java?rev=786706&r1=786705&r2=786706&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMNodeImpl.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMNodeImpl.java Fri Jun 19 22:59:57 2009
@@ -29,7 +29,6 @@
import org.apache.axiom.om.OMOutputFormat;
import org.apache.axiom.om.OMProcessingInstruction;
import org.apache.axiom.om.OMText;
-import org.apache.axiom.om.OMXMLParserWrapper;
import org.apache.axiom.om.impl.MTOMXMLStreamWriter;
import org.apache.axiom.om.impl.OMContainerEx;
import org.apache.axiom.om.impl.OMNodeEx;
@@ -37,8 +36,6 @@
import org.apache.axiom.om.impl.builder.StAXOMBuilder;
import org.apache.axiom.om.impl.llom.factory.OMLinkedListImplFactory;
import org.apache.axiom.om.util.StAXUtils;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamWriter;
@@ -46,10 +43,7 @@
import java.io.Writer;
/** Class OMNodeImpl */
-public abstract class OMNodeImpl implements OMNode, OMNodeEx {
-
- private static final Log log = LogFactory.getLog(OMNodeImpl.class);
- private static boolean DEBUG_ENABLED = log.isDebugEnabled();
+public abstract class OMNodeImpl extends OMSerializableImpl implements OMNode, OMNodeEx {
/** Field parent */
protected OMContainerEx parent;
@@ -59,17 +53,10 @@
/** Field previousSibling */
protected OMNodeImpl previousSibling;
- /** Field builder */
- public OMXMLParserWrapper builder;
-
- /** Field done */
- protected boolean done = false;
/** Field nodeType */
protected int nodeType;
- protected OMFactory factory;
-
/**
* Constructor OMNodeImpl
*
@@ -161,18 +148,6 @@
this.nextSibling = (OMNodeImpl) node;
}
-
- /**
- * Indicates whether parser has parsed this information item completely or not. If some
- * information is not available in the item, one has to check this attribute to make sure that,
- * this item has been parsed completely or not.
- *
- * @return Returns boolean.
- */
- public boolean isComplete() {
- return done;
- }
-
/**
* Method setComplete.
*
@@ -322,31 +297,6 @@
}
/**
- * Parses this node and builds the object structure in memory. However a node, created
- * programmatically, will have done set to true by default and this will cause populateyourself
- * not to work properly!
- *
- * @throws OMException
- */
- public void build() throws OMException {
- if (builder != null && builder.isCompleted()) {
- if (DEBUG_ENABLED) {
- log.debug("Builder is already complete.");
- }
- }
- while (!done) {
-
- builder.next();
- if (builder.isCompleted() && !done) {
- if (DEBUG_ENABLED) {
- log.debug("Builder is complete. Setting OMNode to complete.");
- }
- setComplete(true);
- }
- }
- }
-
- /**
* Parses this node and builds the object structure in memory. AXIOM supports two levels of
* deffered building. First is deffered building of AXIOM using StAX. Second level is the
* deffered building of attachments. AXIOM reads in the attachements from the stream only when
@@ -375,59 +325,6 @@
}
}
- /**
- * Serializes the node with caching.
- *
- * @param xmlWriter
- * @throws javax.xml.stream.XMLStreamException
- *
- */
- public void serialize(XMLStreamWriter xmlWriter) throws XMLStreamException {
-
- // If the input xmlWriter is not an MTOMXMLStreamWriter, then wrapper it
- MTOMXMLStreamWriter writer = xmlWriter instanceof MTOMXMLStreamWriter ?
- (MTOMXMLStreamWriter) xmlWriter :
- new MTOMXMLStreamWriter(xmlWriter);
- internalSerialize(writer);
- writer.flush();
- }
-
- /**
- * Serializes the node without caching.
- *
- * @param xmlWriter
- * @throws javax.xml.stream.XMLStreamException
- *
- */
- public void serializeAndConsume(XMLStreamWriter xmlWriter) throws XMLStreamException {
- // If the input xmlWriter is not an MTOMXMLStreamWriter, then wrapper it
- MTOMXMLStreamWriter writer = xmlWriter instanceof MTOMXMLStreamWriter ?
- (MTOMXMLStreamWriter) xmlWriter :
- new MTOMXMLStreamWriter(xmlWriter);
- internalSerializeAndConsume(writer);
- writer.flush();
- }
-
- /**
- * Serializes the node with caching.
- *
- * @param writer
- * @throws XMLStreamException
- */
- public void internalSerialize(XMLStreamWriter writer) throws XMLStreamException {
- throw new RuntimeException("Not implemented yet!");
- }
-
- /**
- * Serializes the node without caching.
- *
- * @param writer
- * @throws XMLStreamException
- */
- public void internalSerializeAndConsume(XMLStreamWriter writer) throws XMLStreamException {
- throw new RuntimeException("Not implemented yet!");
- }
-
public void serialize(OutputStream output) throws XMLStreamException {
XMLStreamWriter xmlStreamWriter = StAXUtils.createXMLStreamWriter(output);
try {
@@ -506,10 +403,6 @@
}
}
- public OMFactory getOMFactory() {
- return this.factory;
- }
-
/**
* This method is intended only to be used by Axiom intenals when merging Objects from different
* Axiom implementations to the LLOM implementation.
Added: webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMSerializableImpl.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMSerializableImpl.java?rev=786706&view=auto
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMSerializableImpl.java (added)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMSerializableImpl.java Fri Jun 19 22:59:57 2009
@@ -0,0 +1,115 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.axiom.om.impl.llom;
+
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamWriter;
+
+import org.apache.axiom.om.OMException;
+import org.apache.axiom.om.OMFactory;
+import org.apache.axiom.om.OMSerializable;
+import org.apache.axiom.om.OMXMLParserWrapper;
+import org.apache.axiom.om.impl.MTOMXMLStreamWriter;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+public abstract class OMSerializableImpl implements OMSerializable {
+ private static final Log log = LogFactory.getLog(OMSerializableImpl.class);
+ private static boolean DEBUG_ENABLED = log.isDebugEnabled();
+
+ /** Field parserWrapper */
+ public OMXMLParserWrapper builder;
+
+ /** Field done */
+ protected boolean done = false;
+
+ protected OMFactory factory;
+
+ public final OMFactory getOMFactory() {
+ return factory;
+ }
+
+ public boolean isComplete() {
+ return done;
+ }
+
+ /**
+ * Parses this node and builds the object structure in memory. However a node, created
+ * programmatically, will have done set to true by default and this will cause populateyourself
+ * not to work properly!
+ *
+ * @throws OMException
+ */
+ public void build() throws OMException {
+ if (builder != null && builder.isCompleted()) {
+ if (DEBUG_ENABLED) {
+ log.debug("Builder is already complete.");
+ }
+ }
+ while (!done) {
+
+ builder.next();
+ if (builder.isCompleted() && !done) {
+ if (DEBUG_ENABLED) {
+ log.debug("Builder is complete. Setting OMObject to complete.");
+ }
+ setComplete(true);
+ }
+ }
+ }
+
+ public abstract void setComplete(boolean state);
+
+ /**
+ * Serializes the node with caching.
+ *
+ * @param writer
+ * @throws XMLStreamException
+ */
+ public abstract void internalSerialize(XMLStreamWriter writer) throws XMLStreamException;
+
+ /**
+ * Serializes the node without caching.
+ *
+ * @param writer
+ * @throws XMLStreamException
+ */
+ public abstract void internalSerializeAndConsume(XMLStreamWriter writer)
+ throws XMLStreamException;
+
+ public void serialize(XMLStreamWriter xmlWriter) throws XMLStreamException {
+
+ // If the input xmlWriter is not an MTOMXMLStreamWriter, then wrapper it
+ MTOMXMLStreamWriter writer = xmlWriter instanceof MTOMXMLStreamWriter ?
+ (MTOMXMLStreamWriter) xmlWriter :
+ new MTOMXMLStreamWriter(xmlWriter);
+ internalSerialize(writer);
+ writer.flush();
+ }
+
+ public void serializeAndConsume(XMLStreamWriter xmlWriter) throws XMLStreamException {
+ // If the input xmlWriter is not an MTOMXMLStreamWriter, then wrapper it
+ MTOMXMLStreamWriter writer = xmlWriter instanceof MTOMXMLStreamWriter ?
+ (MTOMXMLStreamWriter) xmlWriter :
+ new MTOMXMLStreamWriter(xmlWriter);
+ internalSerializeAndConsume(writer);
+ writer.flush();
+ }
+}
Propchange: webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMSerializableImpl.java
------------------------------------------------------------------------------
svn:mergeinfo =