Package org.apache.axiom.om

Examples of org.apache.axiom.om.OMText


        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


    DataSource dataSource = new FileDataSource(file);
    assertNotNull(dataSource);
    DataHandler dataHandler = new DataHandler(dataSource);

    OMText textData = fac.createOMText(dataHandler, true);
    attachElem.addChild(textData);
    pingElem.addChild(attachElem);

    return pingElem;
  }
View Full Code Here

    OMElement payload = body.getFirstElement();
    OMElement attachmentElem = payload.getFirstChildWithName(new QName(applicationNamespaceName, Attachment));
    if (attachmentElem == null)
      throw new AxisFault("'Attachment' element is not present as a child of the 'Ping' element");

    OMText binaryElem = (OMText) attachmentElem.getFirstOMChild();

    binaryElem.setOptimize(true);
    DataHandler dataHandler = (DataHandler) binaryElem.getDataHandler();

    try {
      File destinationFile = new File(DESTINATION_IMAGE_FILE);
      if (destinationFile.exists())
        destinationFile.delete();
View Full Code Here

        } else if (o instanceof Byte) {
          entry.addAttribute(TYPE, BYTE, attrNS);
          entry.setText(((Byte) 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((Object)name, new Integer(text.getText()));
          } else if (type.equals(CHAR)) {
            this.put((Object)name, new Character((text.getText().charAt(0))));
          } else if (type.equals(DOUBLE)) {
            this.put((Object)name, new Double(text.getText()));
          } else if (type.equals(FLOAT)) {
            this.put((Object)name, new Float(text.getText()));
          } else if (type.equals(BYTE)) {
            this.put((Object)name, new Byte(text.getText().getBytes()[0]));
          } else if (type.equals(SHORT)) {
            this.put((Object)name, new Short(text.getText()));
          } else if (type.equals(LONG)) {
            this.put((Object)name, new Long(text.getText()));
          } else if (type.equals(STRING)) {
            this.put((Object)name, text.getText());
          } else if (type.equals(BYTEARRAY)) {
            DataHandler dh = (DataHandler)text.getDataHandler();
            ByteArrayOutputStream baos = new ByteArrayOutputStream();
            dh.writeTo(baos);
            this.put((Object)name, baos.toByteArray());
          }
          } catch (Exception e) {
View Full Code Here

  public void MTOMPing(OMElement in) throws Exception  {
    OMElement attachmentElem = in.getFirstChildWithName(new QName(applicationNamespaceName, Attachment));
    if (attachmentElem == null)
      throw new AxisFault("'Attachment' element is not present as a child of the 'Ping' element");

    OMText binaryElem = (OMText) attachmentElem.getFirstOMChild();

    binaryElem.setOptimize(true);
    DataHandler dataHandler = (DataHandler) binaryElem.getDataHandler();

    try {
     
      File destinationFile = new File(DESTINATION_IMAGE_FILE);
      if (destinationFile.exists())
View Full Code Here

      throw AxisFault.makeFault (e);
    }
   
      DataHandler dataHandler = new DataHandler(dataSource);

      OMText textData = fac.createOMText(dataHandler, true);
      attachmentElem.addChild(textData);
   
    pingElem.addChild(attachmentElem);

    return pingElem;
View Full Code Here

     * @see org.apache.axiom.om.OMElement#getText()
     */
    public String getText() {
        String childText = "";
        OMNode child = this.getFirstOMChild();
        OMText textNode;

        while (child != null) {
            if (child.getType() == OMNode.TEXT_NODE) {
                textNode = (OMText) child;
                if (textNode.getText() != null
                        && !"".equals(textNode.getText())) {
                    childText += textNode.getText();
                }
            }
            child = child.getNextOMSibling();
        }

View Full Code Here

    }

    public QName getTextAsQName() {
        String childText = "";
        OMNode child = this.getFirstOMChild();
        OMText textNode;

        while (child != null) {
            if (child.getType() == OMNode.TEXT_NODE) {
                textNode = (OMText) child;
                if (textNode.getText() != null
                        && !"".equals(textNode.getText())) {
                    String namespaceURI = textNode.getTextAsQName().getNamespaceURI();
                    if (namespaceURI != null && !"".equals(namespaceURI)) {
                        return textNode.getTextAsQName();
                    }
                    childText += textNode.getText();
                }
            }
            child = child.getNextOMSibling();
        }
View Full Code Here

        String namespace = "http://ws.apache.org/axis2/ns";
        String prefix = "axis2";
        String tempText = "The quick brown fox jumps over the lazy dog";

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

        assertEquals("Text value mismatch", tempText, textNode.getText());
    }
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.