Author: chinthaka
Date: Sun Apr 23 09:45:20 2006
New Revision: 396289
URL: http://svn.apache.org/viewcvs?rev=396289&view=rev
Log:
Re-applying Dennis' changes in OMDataSource.
Added:
webservices/commons/trunk/modules/axiom/src/org/apache/axiom/om/OMDataSource.java
- copied unchanged from r395441,
webservices/commons/trunk/modules/axiom/src/org/apache/axiom/om/OMDataSource.java
webservices/commons/trunk/modules/axiom/src/org/apache/axiom/om/impl/llom/OMSourcedElementImpl.java
- copied unchanged from r395734,
webservices/commons/trunk/modules/axiom/src/org/apache/axiom/om/impl/llom/OMSourcedElementImpl.java
webservices/commons/trunk/modules/axiom/test/org/apache/axiom/om/impl/llom/OMSourcedElementTest.java
- copied unchanged from r395441,
webservices/commons/trunk/modules/axiom/test/org/apache/axiom/om/impl/llom/OMSourcedElementTest.java
Modified:
webservices/commons/trunk/modules/axiom/src/org/apache/axiom/om/OMFactory.java
webservices/commons/trunk/modules/axiom/src/org/apache/axiom/om/impl/builder/StAXOMBuilder.java
webservices/commons/trunk/modules/axiom/src/org/apache/axiom/om/impl/dom/factory/OMDOMFactory.java
webservices/commons/trunk/modules/axiom/src/org/apache/axiom/om/impl/llom/factory/OMLinkedListImplFactory.java
Modified:
webservices/commons/trunk/modules/axiom/src/org/apache/axiom/om/OMFactory.java
URL:
http://svn.apache.org/viewcvs/webservices/commons/trunk/modules/axiom/src/org/apache/axiom/om/OMFactory.java?rev=396289&r1=396288&r2=396289&view=diff
==============================================================================
---
webservices/commons/trunk/modules/axiom/src/org/apache/axiom/om/OMFactory.java
(original)
+++
webservices/commons/trunk/modules/axiom/src/org/apache/axiom/om/OMFactory.java
Sun Apr 23 09:45:20 2006
@@ -50,6 +50,17 @@
OMXMLParserWrapper builder);
/**
+ * Construct element with arbitrary data source. This is an optional
+ * operation which may not be supported by all factories.
+ *
+ * @param source
+ * @param localName
+ * @param ns
+ */
+ public OMElement createOMElement(OMDataSource source, String localName,
+ OMNamespace ns);
+
+ /**
* This is almost the same as as createOMElement(localName,OMNamespace)
method above.
* But some people may, for some reason, need to use the conventional
method of putting a namespace.
* Or in other words people might not want to use the new OMNamespace.
@@ -94,6 +105,7 @@
/**
* @param parent
* @param text - This text itself can contain a namespace inside it.
+ * @return
*/
public OMText createOMText(OMElement parent, QName text);
@@ -111,6 +123,7 @@
* @param parent
* @param text - This text itself can contain a namespace inside it.
* @param type
+ * @return
*/
public OMText createOMText(OMElement parent, QName text, int type);
Modified:
webservices/commons/trunk/modules/axiom/src/org/apache/axiom/om/impl/builder/StAXOMBuilder.java
URL:
http://svn.apache.org/viewcvs/webservices/commons/trunk/modules/axiom/src/org/apache/axiom/om/impl/builder/StAXOMBuilder.java?rev=396289&r1=396288&r2=396289&view=diff
==============================================================================
---
webservices/commons/trunk/modules/axiom/src/org/apache/axiom/om/impl/builder/StAXOMBuilder.java
(original)
+++
webservices/commons/trunk/modules/axiom/src/org/apache/axiom/om/impl/builder/StAXOMBuilder.java
Sun Apr 23 09:45:20 2006
@@ -65,6 +65,21 @@
}
/**
+ * Constructor linked to existing element.
+ *
+ * @param factory
+ * @param parser
+ * @param element
+ */
+ public StAXOMBuilder(OMFactory factory, XMLStreamReader parser, OMElement
element) {
+ this(factory, parser);
+ lastNode = element;
+ document.setOMDocumentElement(element);
+ doDebug = log.isDebugEnabled();
+ populateOMElement(element);
+ }
+
+ /**
* @param filePath - Path to the XML file
* @throws XMLStreamException
* @throws FileNotFoundException
@@ -193,6 +208,20 @@
}
}
+ /**
+ * Populate element with data from parser START_ELEMENT event. This is used
+ * when the source of data for an element needs to be parsed on demand. The
+ * supplied element must already be set to the proper name and namespace.
+ *
+ * @param node element to be populated
+ */
+ private void populateOMElement(OMElement node) {
+ // create the namespaces
+ processNamespaceData(node);
+ // fill in the attributes
+ processAttributes(node);
+ node.setLineNumber(parser.getLocation().getLineNumber());
+ }
/**
* Method createOMElement.
@@ -216,11 +245,7 @@
(OMElement) lastNode, this);
e.setFirstChild(node);
}
- // create the namespaces
- processNamespaceData(node);
- // fill in the attributes
- processAttributes(node);
- node.setLineNumber(parser.getLocation().getLineNumber());
+ populateOMElement(node);
return node;
}
Modified:
webservices/commons/trunk/modules/axiom/src/org/apache/axiom/om/impl/dom/factory/OMDOMFactory.java
URL:
http://svn.apache.org/viewcvs/webservices/commons/trunk/modules/axiom/src/org/apache/axiom/om/impl/dom/factory/OMDOMFactory.java?rev=396289&r1=396288&r2=396289&view=diff
==============================================================================
---
webservices/commons/trunk/modules/axiom/src/org/apache/axiom/om/impl/dom/factory/OMDOMFactory.java
(original)
+++
webservices/commons/trunk/modules/axiom/src/org/apache/axiom/om/impl/dom/factory/OMDOMFactory.java
Sun Apr 23 09:45:20 2006
@@ -18,6 +18,7 @@
import org.apache.axiom.om.OMAttribute;
import org.apache.axiom.om.OMComment;
import org.apache.axiom.om.OMContainer;
+import org.apache.axiom.om.OMDataSource;
import org.apache.axiom.om.OMDocType;
import org.apache.axiom.om.OMDocument;
import org.apache.axiom.om.OMElement;
@@ -132,6 +133,20 @@
"The parent container can only be an ELEMENT, DOCUMENT " +
"or a DOCUMENT FRAGMENT");
}
+ }
+
+ /* (non-Javadoc)
+ * @see
org.apache.axiom.om.OMFactory#createOMElement(org.apache.axiom.om.OMDataSource,
java.lang.String, org.apache.axiom.om.OMNamespace,
org.apache.axiom.om.OMContainer)
+ */
+ public OMElement createOMElement(OMDataSource source, String localName,
OMNamespace ns, OMContainer parent) {
+ throw new UnsupportedOperationException("Not supported for DOM");
+ }
+
+ /* (non-Javadoc)
+ * @see
org.apache.axiom.om.OMFactory#createOMElement(org.apache.axiom.om.OMDataSource,
java.lang.String, org.apache.axiom.om.OMNamespace)
+ */
+ public OMElement createOMElement(OMDataSource source, String localName,
OMNamespace ns) {
+ throw new UnsupportedOperationException("Not supported for DOM");
}
/**
Modified:
webservices/commons/trunk/modules/axiom/src/org/apache/axiom/om/impl/llom/factory/OMLinkedListImplFactory.java
URL:
http://svn.apache.org/viewcvs/webservices/commons/trunk/modules/axiom/src/org/apache/axiom/om/impl/llom/factory/OMLinkedListImplFactory.java?rev=396289&r1=396288&r2=396289&view=diff
==============================================================================
---
webservices/commons/trunk/modules/axiom/src/org/apache/axiom/om/impl/llom/factory/OMLinkedListImplFactory.java
(original)
+++
webservices/commons/trunk/modules/axiom/src/org/apache/axiom/om/impl/llom/factory/OMLinkedListImplFactory.java
Sun Apr 23 09:45:20 2006
@@ -19,6 +19,7 @@
import org.apache.axiom.om.OMAttribute;
import org.apache.axiom.om.OMComment;
import org.apache.axiom.om.OMContainer;
+import org.apache.axiom.om.OMDataSource;
import org.apache.axiom.om.OMDocType;
import org.apache.axiom.om.OMDocument;
import org.apache.axiom.om.OMElement;
@@ -35,6 +36,7 @@
import org.apache.axiom.om.impl.llom.OMElementImpl;
import org.apache.axiom.om.impl.llom.OMNamespaceImpl;
import org.apache.axiom.om.impl.llom.OMProcessingInstructionImpl;
+import org.apache.axiom.om.impl.llom.OMSourcedElementImpl;
import org.apache.axiom.om.impl.llom.OMTextImpl;
import javax.xml.namespace.QName;
@@ -110,6 +112,17 @@
public OMElement createOMElement(QName qname, OMContainer parent)
throws OMException {
return new OMElementImpl(qname, parent, this);
+ }
+
+ /**
+ * Construct element with arbitrary data source.
+ *
+ * @param source
+ * @param localName
+ * @param ns
+ */
+ public OMElement createOMElement(OMDataSource source, String localName,
OMNamespace ns) {
+ return new OMSourcedElementImpl(localName, ns, this, source);
}
/**