Package org.apache.axiom.om

Examples of org.apache.axiom.om.OMText


        HessianTestHelper hessianTestHelper = new HessianTestHelper();
        MessageContext msgContext = hessianTestHelper.createAxis2MessageContext(synEnv);
        OMElement element = hessianTestHelper.buildHessianTestMessage(testMessageName, msgContext);
        OMNode hessianNode = element.getFirstOMChild();
        OMText hessianTextNode = (OMText) hessianNode;
        SynapseBinaryDataSource synapseBinaryDataSource = (SynapseBinaryDataSource)
            ((DataHandler) hessianTextNode.getDataHandler()).getDataSource();
        InputStream inputStream = synapseBinaryDataSource.getInputStream();
        byte[] originalByteArray = IOUtils.toByteArray(getClass().getResourceAsStream(
                testMessageName));
        byte[] builderByteArray = IOUtils.toByteArray(inputStream);
        assertTrue(Arrays.equals(originalByteArray, builderByteArray));
View Full Code Here


                } else if (o instanceof Byte) {
                    entry.addAttribute(TYPE, BYTE, attrNS);
                    entry.setText(o.toString());
                } else if (o instanceof byte[]) {
                    entry.addAttribute(TYPE, BYTEARRAY, attrNS);
                    OMText text = fac.createOMText(new DataHandler(
                            new ByteArrayDataSource((byte[]) o)), true);
                    entry.addChild(text);
                } else if (o instanceof Float) {
                    entry.addAttribute(TYPE, FLOAT, attrNS);
                    entry.setText(o.toString());
View Full Code Here

                    }
                    OMNode data = child.getFirstOMChild();
                    if (data.getType() != OMNode.TEXT_NODE) {
                        continue; // BAD!
                    }
                    OMText text = (OMText)data;
                    if (type.equals(INTEGER)) {
                        this.put(name, new Integer(text.getText()));
                    } else if (type.equals(CHAR)) {
                        this.put(name, (text.getText().charAt(0)));
                    } else if (type.equals(DOUBLE)) {
                        this.put(name, new Double(text.getText()));
                    } else if (type.equals(FLOAT)) {
                        this.put(name, new Float(text.getText()));
                    } else if (type.equals(BYTE)) {
                        this.put(name, text.getText().getBytes()[0]);
                    } else if (type.equals(SHORT)) {
                        this.put(name, new Short(text.getText()));
                    } else if (type.equals(LONG)) {
                        this.put(name, new Long(text.getText()));
                    } else if (type.equals(STRING)) {
                        this.put(name, text.getText());
                    } else if (type.equals(BYTEARRAY)) {
                        DataHandler dh = (DataHandler) text.getDataHandler();
                        ByteArrayOutputStream baos = new ByteArrayOutputStream();
                        try {
                            dh.writeTo(baos);
                            this.put(name, baos.toByteArray());
                        } catch (IOException e) {
View Full Code Here

        if (child != null) {
          _copyElement(element, child);
          dest.addChild(child);
        }
      } else if (node.getType() == OMNode.CDATA_SECTION_NODE) {
        OMText text = (OMText) node;
        factory.createOMText(dest,text.getText(), OMNode.CDATA_SECTION_NODE);
      } else if (node.getType() == OMNode.TEXT_NODE) {
        OMText text = (OMText) node;
        factory.createOMText(dest,text.getText());
      } else if (node.getType() == OMNode.COMMENT_NODE) {
        OMComment comment = (OMComment) node;
        factory.createOMComment(dest, comment.getValue());
      } else if (node.getType() == OMNode.PI_NODE) {
        OMProcessingInstruction pi = (OMProcessingInstruction) node;
        factory.createOMProcessingInstruction(dest, pi.getTarget(), pi.getValue());
      } else if (node.getType() == OMNode.SPACE_NODE) {
        OMText text = (OMText) node;
        factory.createOMText(dest, text.getText(), OMNode.SPACE_NODE);
      } else if (node.getType() == OMNode.ENTITY_REFERENCE_NODE) {
        OMText text = (OMText) node;
        factory.createOMText(dest, text.getText(), OMNode.ENTITY_REFERENCE_NODE);
      }
    }
    return dest;
  }
View Full Code Here

        OMElement stmntElt = fac.createOMElement(
            AbstractDBMediatorFactory.STMNT_Q.getLocalPart(), synNS);

        OMElement sqlElt = fac.createOMElement(
            AbstractDBMediatorFactory.SQL_Q.getLocalPart(), synNS);
        OMText sqlText = fac.createOMText(statement.getRawStatement(), XMLStreamConstants.CDATA);
        sqlElt.addChild(sqlText);
        stmntElt.addChild(sqlElt);

        // serialize parameters of the statement
        for (Statement.Parameter param : statement.getParameters()) {
View Full Code Here

        OMFactory doomFactory = OMAbstractFactory.getMetaFactory(OMAbstractFactory.FEATURE_DOM).getOMFactory();
        OMFactory llomFactory = OMAbstractFactory.getOMFactory();
        String text = "This was a DOOM Text";

        OMElement llomRoot = llomFactory.createOMElement("root", null);
        OMText doomText = doomFactory.createOMText(text);
        llomRoot.addChild(doomText);

        OMElement newElement = (OMXMLBuilderFactory.createStAXOMBuilder(this.factory, llomRoot
                .getXMLStreamReader())).getDocumentElement();
        newElement.build();
View Full Code Here

        OMFactory doomFactory = OMAbstractFactory.getMetaFactory(OMAbstractFactory.FEATURE_DOM).getOMFactory();
        OMFactory llomFactory = OMAbstractFactory.getOMFactory();
        String text = "This was a DOOM Text";

        OMElement doomRoot = doomFactory.createOMElement("root", null);
        OMText llomText = llomFactory.createOMText(text);
        OMComment comment = llomFactory.createOMComment(null, "comment");
        doomRoot.addChild(llomText);
        doomRoot.addChild(comment);

        OMElement newElement = (OMXMLBuilderFactory.createStAXOMBuilder(this.factory, doomRoot
View Full Code Here

    }

    protected void runTest() throws Throwable {
        OMFactory factory = metaFactory.getOMFactory();
        OMElement element = factory.createOMElement("test", null);
        OMText text = factory.createOMText("test");
        element.addChild(text);
        assertSame(element, text.getParent());
        assertSame(text, element.getFirstOMChild());
    }
View Full Code Here

        OMNode child = element.getFirstOMChild();

        while (child != null) {
            final int type = child.getType();
            if (type == OMNode.TEXT_NODE || type == OMNode.CDATA_SECTION_NODE) {
                OMText textNode = (OMText) child;
                String textValue = textNode.getText();
                if (textValue != null && textValue.length() != 0) {
                    if (childText == null) {
                        // This is the first non empty text node. Just save the string.
                        childText = textValue;
                    } else {
View Full Code Here

    }

    protected void runTest() throws Throwable {
        OMFactory omfactory = metaFactory.getOMFactory();
        OMElement element = omfactory.createOMElement("test", null);
        OMText cdata = omfactory.createOMText("hello world", OMNode.CDATA_SECTION_NODE);
        element.addChild(cdata);
       
        // Get the XMLStreamReader for the element. This will return an OMStAXWrapper.
        XMLStreamReader reader2 = element.getXMLStreamReader();
        // Check the sequence of events
View Full Code Here

TOP

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

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.