Search in sources :

Example 1 with AxiomComment

use of org.apache.axiom.om.impl.intf.AxiomComment in project webservices-axiom by apache.

the class OMFactoryImpl method importChildNode.

private AxiomChildNode importChildNode(OMNode child) {
    int type = child.getType();
    switch(type) {
        case OMNode.ELEMENT_NODE:
            return importElement((OMElement) child, AxiomElement.class);
        case OMNode.TEXT_NODE:
        case OMNode.SPACE_NODE:
        case OMNode.CDATA_SECTION_NODE:
            {
                OMText text = (OMText) child;
                Object content;
                if (text.isBinary()) {
                    content = new TextContent(text.getContentID(), text.getDataHandler(), text.isOptimized());
                } else {
                    content = text.getText();
                }
                return createAxiomText(null, content, type);
            }
        case OMNode.PI_NODE:
            {
                OMProcessingInstruction pi = (OMProcessingInstruction) child;
                AxiomProcessingInstruction importedPI = createNode(AxiomProcessingInstruction.class);
                importedPI.setTarget(pi.getTarget());
                importedPI.setValue(pi.getValue());
                return importedPI;
            }
        case OMNode.COMMENT_NODE:
            {
                OMComment comment = (OMComment) child;
                AxiomComment importedComment = createNode(AxiomComment.class);
                importedComment.setValue(comment.getValue());
                return importedComment;
            }
        case OMNode.DTD_NODE:
            {
                OMDocType docType = (OMDocType) child;
                AxiomDocType importedDocType = createNode(AxiomDocType.class);
                importedDocType.coreSetRootName(docType.getRootName());
                importedDocType.coreSetPublicId(docType.getPublicId());
                importedDocType.coreSetSystemId(docType.getSystemId());
                importedDocType.coreSetInternalSubset(docType.getInternalSubset());
                return importedDocType;
            }
        case OMNode.ENTITY_REFERENCE_NODE:
            AxiomEntityReference importedEntityRef = createNode(AxiomEntityReference.class);
            importedEntityRef.coreSetName(((OMEntityReference) child).getName());
            return importedEntityRef;
        default:
            throw new IllegalArgumentException("Unsupported node type");
    }
}
Also used : OMProcessingInstruction(org.apache.axiom.om.OMProcessingInstruction) OMDocType(org.apache.axiom.om.OMDocType) AxiomDocType(org.apache.axiom.om.impl.intf.AxiomDocType) AxiomProcessingInstruction(org.apache.axiom.om.impl.intf.AxiomProcessingInstruction) OMComment(org.apache.axiom.om.OMComment) AxiomEntityReference(org.apache.axiom.om.impl.intf.AxiomEntityReference) AxiomComment(org.apache.axiom.om.impl.intf.AxiomComment) OMText(org.apache.axiom.om.OMText) TextContent(org.apache.axiom.om.impl.intf.TextContent)

Aggregations

OMComment (org.apache.axiom.om.OMComment)1 OMDocType (org.apache.axiom.om.OMDocType)1 OMProcessingInstruction (org.apache.axiom.om.OMProcessingInstruction)1 OMText (org.apache.axiom.om.OMText)1 AxiomComment (org.apache.axiom.om.impl.intf.AxiomComment)1 AxiomDocType (org.apache.axiom.om.impl.intf.AxiomDocType)1 AxiomEntityReference (org.apache.axiom.om.impl.intf.AxiomEntityReference)1 AxiomProcessingInstruction (org.apache.axiom.om.impl.intf.AxiomProcessingInstruction)1 TextContent (org.apache.axiom.om.impl.intf.TextContent)1