Package org.apache.axiom.om

Examples of org.apache.axiom.om.OMDataSource


        // If not startAtNext, then seed the processing with the current element.
        boolean useCurrentEvent = !startAtNext;
       
        while (reader.hasNext() || useCurrentEvent) {
            int event = 0;
            OMDataSource ds = null;
            if (useCurrentEvent) {
                event = reader.getEventType();
                useCurrentEvent = false;
            } else {
                event = reader.next();
            }
           
            // If the reader is exposing a DataSourc
            // for this event, then simply serialize the
            // DataSource
            if (reader instanceof OMStAXWrapper) {
                ds = ((OMStAXWrapper) reader).getDataSource();
            }
            if (ds != null) {
                ds.serialize(writer);
            } else {
                switch (event) {
                case START_ELEMENT:
                    serializeElement(reader, writer);
                    depth++;
View Full Code Here


    private static void copyOMSourcedElement(SOAPFactory factory,
                                             OMContainer targetParent,
                                             OMSourcedElement sourceOMSE) {
        // If already expanded or this is not an OMDataSourceExt, then
        // create a copy of the OM Tree
        OMDataSource ds = sourceOMSE.getDataSource();
        if (ds == null ||
            sourceOMSE.isExpanded() ||
            !(ds instanceof OMDataSourceExt)) {
            copyOMElement(factory, targetParent, sourceOMSE);
            return;
View Full Code Here

    private static void copySOAPHeaderBlock(SOAPFactory factory,
                                            OMContainer targetParent,
                                            SOAPHeaderBlock sourceSHB) {
        // If already expanded or this is not an OMDataSourceExt, then
        // create a copy of the OM Tree
        OMDataSource ds = sourceSHB.getDataSource();
        if (ds == null ||
            sourceSHB.isExpanded() ||
            !(ds instanceof OMDataSourceExt)) {
            copySOAPHeaderBlock_NoDataSource(factory, targetParent, sourceSHB);
            return;
View Full Code Here

        if (getEventType() != XMLStreamReader.START_ELEMENT ||
                !(state == this.NAVIGABLE ||
                  state == this.SWITCH_AT_NEXT)) {
            return null;
        }
        OMDataSource ds = null;
        if (lastNode != null &&
            lastNode instanceof OMSourcedElement) {
            try {
                ds = ((OMSourcedElement) lastNode).getDataSource();
            } catch (UnsupportedOperationException e) {
View Full Code Here

     * @return true if this OMNode should be considered a leaf node
     */
    private boolean isLeaf(OMSerializable n) {
        if (n instanceof OMContainer) {
            if (this.isDataSourceALeaf && (n instanceof OMSourcedElement) && n != root) {
                OMDataSource ds = null;
                try {
                    ds = ((OMSourcedElement) n).getDataSource();
                } catch (UnsupportedOperationException e) {
                    ; // Operation unsupported for some implementations
                }
View Full Code Here

        for (int i=0; i<40000; i++) {
            buffer.append((char)(32 + random.nextInt(96)));
        }
        String testData = buffer.toString();
        QName qname = new QName("data");
        OMDataSource ds = new WrappedTextNodeOMDataSourceFromReader(qname, new StringReader(testData));
        OMFactory factory = OMAbstractFactory.getOMFactory();
        OMSourcedElement element = new OMSourcedElementImpl(qname, factory, ds);
        assertEquals(testData, element.getText());
    }
View Full Code Here

    /**
     * setOMDataSource
     */
    public OMDataSource setDataSource(OMDataSource dataSource) {
        if (!isExpanded()) {
            OMDataSource oldDS = this.dataSource;
            this.dataSource = dataSource;
            return oldDS;  // Caller is responsible for closing the data source
        } else {
            // TODO
            // Remove the entire subtree and replace with
            // new datasource.  There maybe a more performant way to do this.
            OMDataSource oldDS = this.dataSource;
            Iterator it = getChildren();
            while(it.hasNext()) {
                it.next();
                it.remove();
            }
View Full Code Here

        super(metaFactory);
    }

    protected void runTest() throws Throwable {
        OMFactory omFactory = metaFactory.getOMFactory();
        OMDataSource ds = new CharArrayDataSource("<a>test</a>".toCharArray());
        OMElement root = omFactory.createOMElement(new QName("root"));
        OMSourcedElement child = omFactory.createOMElement(ds, "a", null);
        root.addChild(child);
        assertFalse(child.isExpanded());
        XMLStreamReader stream = root.getXMLStreamReader();
View Full Code Here

            // Create an OMSourcedElement backed by an unmarshalled JAXB object
            OMNamespace ns = factory.createOMNamespace(namespace, reader.getPrefix());

            Object jaxb = jdsContext.unmarshal(reader);

            OMDataSource ds = new JAXBDataSourceExt(jaxb, jdsContext);
            OMElement omse = factory.createOMElement(ds, localPart, ns);

            parent.addChild(omse);
            // JAXBCustomBuilderMonitor.updateTotalCreates();
            return omse;
View Full Code Here

public class TextFileDataSourceTest extends TestCase {

    public void testWithXMLChars() throws Exception {
        String testString = "Test string with ampersand (&)";
        OMDataSource dataSource
            = new TextFileDataSource(new ByteArrayDataSource(testString.getBytes("UTF-8")));
        OMFactory omFactory = OMAbstractFactory.getOMFactory();
        OMSourcedElementImpl element
            = new OMSourcedElementImpl(BaseConstants.DEFAULT_TEXT_WRAPPER, omFactory, dataSource);
        assertEquals(testString, element.getText());
View Full Code Here

TOP

Related Classes of org.apache.axiom.om.OMDataSource

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.