Package org.apache.axiom.om

Examples of org.apache.axiom.om.OMText


        String prefix = "axis2";
        String tempText = "The quick brown fox jumps over the lazy dog";
        String textToAppend = " followed by another fox";

        OMElement elem = factory.createOMElement(localName, namespace, prefix);
        OMText textNode = factory.createOMText(elem, tempText);

        ((Text) textNode).appendData(textToAppend);

        assertEquals("Text value mismatch", tempText + textToAppend, textNode
                .getText());
    }
View Full Code Here


        String prefix = "axis2";
        String tempText = "The quick brown fox jumps over the lazy dog";
        String textToAppend = " followed by another";

        OMElement elem = factory.createOMElement(localName, namespace, prefix);
        OMText textNode = factory.createOMText(elem, tempText);

        ((Text) textNode).appendData(textToAppend);
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        try {
            elem.serialize(baos);
View Full Code Here

   */
  private OMNode createOMText(String value, OMElement omElement, int textType) {
      try {
          if (isDataHandlerAware && Boolean.TRUE == parser.getProperty(OMConstants.IS_BINARY)) {
              Object dataHandler = parser.getProperty(OMConstants.DATA_HANDLER);
              OMText text = omfactory.createOMText(dataHandler, true);
              omElement.addChild(text);
              return text;
          } else {
              return omfactory.createOMText(omElement, value, textType);
          }
View Full Code Here

    OMNode textNode = el.getFirstOMChild();
    if (textNode.getType() != OMNode.TEXT_NODE) {
      log.error("Text Node not found");
      return null;
    }
    OMText text = (OMText) textNode;
        try {
            return (DataHandler) text.getDataHandler();
        } catch (ClassCastException ce) {
            log.error("cannot get DataHandler" + ce.getMessage());
            return null;
        }
  }
View Full Code Here

  public static void setBinaryPayload(SOAPEnvelope envelope, DataHandler dh) {
    OMFactory fac = envelope.getOMFactory();
    OMElement binaryElt = envelope.getOMFactory()
        .createOMElement(BINARYELT);
    OMText text = fac.createOMText(dh, true);
    binaryElt.addChild(text);
    setXMLPayload(envelope, binaryElt);
  }
View Full Code Here

  }

  public static void setTextPayload(SOAPEnvelope envelope, String text) {
    OMFactory fac = envelope.getOMFactory();
    OMElement textElt = envelope.getOMFactory().createOMElement(TEXTELT);
    OMText textNode = fac.createOMText(text);
    textElt.addChild(textNode);
    setXMLPayload(envelope, textElt);
  }
View Full Code Here

                            return reqProperties.getProperty(propName);
                        }
                    }
                } else if (propEntry.getValue() != null) {
                    if (propEntry.getValue() instanceof OMText) {
                        OMText omText = (OMText) propEntry.getValue();
                        DataHandler dh = (DataHandler) omText.getDataHandler();
                        if (omText.getDataHandler() != null) {
                            try {
                                InputStreamReader streamReader = new InputStreamReader(dh.getInputStream());
                                BufferedReader stringReader = new BufferedReader(streamReader);
                                String omTextString = NULL_STRING;
                                String tempStr;
                                while ((tempStr = stringReader.readLine()) != null) {
                                    omTextString = omTextString + tempStr;
                                }
                                return omTextString;
                            } catch (IOException e) {
                                return NULL_STRING;
                            }
                        } else {
                            omText.getText();
                        }
                    }
                    return propEntry.getValue().toString();
                }
            }
View Full Code Here

            if (targetObj instanceof OMElement) {
                OMElement targetElem = (OMElement) targetObj;
                insertElement(sourceNodeList, targetElem, synLog);
            } else if (targetObj instanceof OMText) {
                OMText targetText = (OMText) targetObj;
                if (sourceNodeList.get(0) instanceof OMText) {
                    if (targetText.getParent() != null) {
                        Object parent = targetText.getParent();
                        if (parent instanceof OMElement) {
                            ((OMElement)parent).setText(((OMText) sourceNodeList.get(0)).getText());
                        }
                    }
                } else if (sourceNodeList.get(0) instanceof OMElement) {
                    Object targetParent = targetText.getParent();
                    if (targetParent instanceof OMElement) {
                        targetText.detach();
                        ((OMElement)targetParent).addChild(sourceNodeList.get(0));
                    }
                }
            } else {
                synLog.error("Invalid Target object to be enrich.");
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

        try {
            // TODO:Check on this. I'm not sure it's actually used
            // if (isDataHandlerAware && Boolean.TRUE == parser.getProperty(OMConstants.IS_BINARY)) {
            if (Boolean.TRUE == parser.getProperty(OMConstants.IS_BINARY)) {
                Object dataHandler = parser.getProperty(OMConstants.DATA_HANDLER);
                OMText text = new FOMTextValue(dataHandler, true, (OMFactory)this);
                omElement.addChild(text);
                return text;
            } else {
                return new FOMTextValue(omElement, value, textType, (OMFactory)this.fomfactory);
            }
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.