Java 类org.dom4j.Text 实例源码

项目:qb-core    文件:RmXmlHelper.java   
/**
 * 复制from下的所有节点(包括Attribute, Element, Text)到to
 * 
 * @param from
 * @param to
 */
public static void deepCopyElement(Element from, Element to) {
    if(from == null || to == null) {
        return;
    }
    List<Node> lNode = from.selectNodes("@*|node()");
    for(Node node : lNode) {
        if(node instanceof Attribute) {
            Attribute attr = (Attribute)node;
            to.addAttribute(attr.getName(), attr.getText());
        } else if(node instanceof Element) {
            Element ele = (Element)node;
            to.add(ele.createCopy());
        } else if(node instanceof Text) {
            to.setText(node.getText());
        }
    }
}
项目:lexml-renderer-pdf    文件:PDFBuilder.java   
private void renderAllChildNodes(final Element el) throws Exception {

        if (el.isTextOnly()) {
            renderTextToContainer(el.getText());
        }
        else {
            for (Iterator< ? > it = el.nodeIterator(); it.hasNext();) {
                Node nFilho = (Node) it.next();

                if (nFilho instanceof Text) {
                    renderTextToContainer(nFilho.getText());
                }
                else if (nFilho instanceof Element) {
                    render((Element) nFilho);
                }
            }
        }

    }
项目:visual-programming    文件:XmlDomVisitor.java   
public void visit(Node node) {
    int type = node.getNodeType();
    switch (type) {
    case Node.ELEMENT_NODE:
        visit((Element) node);
        break;
    case Node.TEXT_NODE:
        visit((Text) node);
        break;

    case Node.CDATA_SECTION_NODE:
        visit((CDATA) node);
        break;

    default:

        push(null);
    }
}
项目:visual-programming    文件:XmlDomVisitor.java   
@Override
public void visit(Text node) {
    Text text = node;

    if (skipEmptyTextNode && text.getText().trim().isEmpty())
        push(null);
    else {

        StringValue obj = (StringValue) getObjectRepo().createObject(
                ObjectType.STRING, ObjectScope.ExecutionContext);
        String name = text.getNodeTypeName();
        obj.setName(name);
        obj.setValue(text.getText());

        push(obj);
    }
}
项目:javasec    文件:RmXmlHelper.java   
/**
 * 复制from下的所有节点(包括Attribute, Element, Text)到to
 * 
 * @param from
 * @param to
 */
public static void deepCopyElement(Element from, Element to) {
    if(from == null || to == null) {
        return;
    }
    List<Node> lNode = from.selectNodes("@*|node()");
    for(Node node : lNode) {
        if(node instanceof Attribute) {
            Attribute attr = (Attribute)node;
            to.addAttribute(attr.getName(), attr.getText());
        } else if(node instanceof Element) {
            Element ele = (Element)node;
            to.add(ele.createCopy());
        } else if(node instanceof Text) {
            to.setText(node.getText());
        }
    }
}
项目:joai-project    文件:CollectionImporter.java   
public String getCollectionKeyFromDDS( String _collectionName )
{
    String collectionKey = null;

    // make the call to DDS and get ListCollections 
    try { 
        URLConnection connection = new URL ("http://www.dlese.org/dds/services/ddsws1-1?verb=ListCollections" ).openConnection();           
        connection.setDoOutput( true );
        connection.setDoInput(true);

        ((HttpURLConnection)connection).setRequestMethod("GET");

        Map<String,String> uris = new HashMap<String,String>();
        uris.put( "ddsws", "http://www.dlese.org/Metadata/ddsws" );        
        uris.put( "ddswsnews", "http://www.dlese.org/Metadata/ddswsnews" );
        uris.put( "groups", "http://www.dlese.org/Metadata/groups/" );
        uris.put( "adn", "http://adn.dlese.org" );
        uris.put( "annotation", "http://www.dlese.org/Metadata/annotation" );

        XPath xpath = DocumentHelper.createXPath( "//collections/collection[vocabEntry=\"" + _collectionName + "\"]/searchKey/text()" );

        xpath.setNamespaceURIs( uris );

        SAXReader xmlReader = new SAXReader();

        this.document = xmlReader.read(connection.getInputStream());    

        Text t = ((Text)xpath.selectSingleNode(this.document));

        collectionKey = t.getStringValue();

    } catch ( Exception e ) {
        e.printStackTrace();
    }

    return collectionKey;
}
项目:dls-repository-stack    文件:CollectionImporter.java   
public String getCollectionKeyFromDDS( String _collectionName )
{
    String collectionKey = null;

    // make the call to DDS and get ListCollections 
    try { 
        URLConnection connection = new URL ("http://www.dlese.org/dds/services/ddsws1-1?verb=ListCollections" ).openConnection();           
        connection.setDoOutput( true );
        connection.setDoInput(true);

        ((HttpURLConnection)connection).setRequestMethod("GET");

        Map<String,String> uris = new HashMap<String,String>();
        uris.put( "ddsws", "http://www.dlese.org/Metadata/ddsws" );        
        uris.put( "ddswsnews", "http://www.dlese.org/Metadata/ddswsnews" );
        uris.put( "groups", "http://www.dlese.org/Metadata/groups/" );
        uris.put( "adn", "http://adn.dlese.org" );
        uris.put( "annotation", "http://www.dlese.org/Metadata/annotation" );

        XPath xpath = DocumentHelper.createXPath( "//collections/collection[vocabEntry=\"" + _collectionName + "\"]/searchKey/text()" );

        xpath.setNamespaceURIs( uris );

        SAXReader xmlReader = new SAXReader();

        this.document = xmlReader.read(connection.getInputStream());    

        Text t = ((Text)xpath.selectSingleNode(this.document));

        collectionKey = t.getStringValue();

    } catch ( Exception e ) {
        e.printStackTrace();
    }

    return collectionKey;
}
项目:dls-repository-stack    文件:AbstractTestCase.java   
public void assertNodesEqual( Node n1, Node n2 ) {
    int nodeType1 = n1.getNodeType();
    int nodeType2 = n2.getNodeType();
    assertTrue( "Nodes are of same type: ", nodeType1 == nodeType2 );

    switch (nodeType1) {
        case Node.ELEMENT_NODE:
            assertNodesEqual((Element) n1, (Element) n2);
            break;
        case Node.DOCUMENT_NODE:
            assertNodesEqual((Document) n1, (Document) n2);
            break;
        case Node.ATTRIBUTE_NODE:
            assertNodesEqual((Attribute) n1, (Attribute) n2);
            break;
        case Node.TEXT_NODE:
            assertNodesEqual((Text) n1, (Text) n2);
            break;
        case Node.CDATA_SECTION_NODE:
            assertNodesEqual((CDATA) n1, (CDATA) n2);
            break;
        case Node.ENTITY_REFERENCE_NODE:
            assertNodesEqual((Entity) n1, (Entity) n2);
            break;
        case Node.PROCESSING_INSTRUCTION_NODE:
            assertNodesEqual((ProcessingInstruction) n1, (ProcessingInstruction) n2);
            break;
        case Node.COMMENT_NODE:
            assertNodesEqual((Comment) n1, (Comment) n2);
            break;
        case Node.DOCUMENT_TYPE_NODE:
            assertNodesEqual((DocumentType) n1, (DocumentType) n2);
            break;
        case Node.NAMESPACE_NODE:
            assertNodesEqual((Namespace) n1, (Namespace) n2);
            break;
        default:
            assertTrue( "Invalid node types. node1: " + n1 + " and node2: " + n2, false );
    }
}
项目:lams    文件:ElementWrapper.java   
public void add(Text text) {
    element.add( text );
}
项目:lams    文件:ElementWrapper.java   
public boolean remove(Text text) {
    return element.remove( text );
}
项目:libraries    文件:IObjectToDomConverter.java   
default Text text(final String string) {
  return DocumentHelper.createText(string);
}
项目:cacheonix-core    文件:ElementWrapper.java   
public void add(Text text) {
    element.add( text );
}
项目:cacheonix-core    文件:ElementWrapper.java   
public boolean remove(Text text) {
    return element.remove( text );
}
项目:cacheonix-core    文件:Dom4jProxy.java   
public void add(Text text) {
    target().add( text );
}
项目:cacheonix-core    文件:Dom4jProxy.java   
public boolean remove(Text text) {
    return target().remove( text );
}
项目:jaxen    文件:DocumentNavigator.java   
public boolean isText(Object obj)
{
    return ( obj instanceof Text 
             ||
             obj instanceof CDATA );
}
项目:Gargoyle    文件:XMLAttibuteFormatWriter.java   
/**
 * Writes the given {@link Text}.
 * 
 * @param text
 *            <code>Text</code> to output.
 * 
 * @throws IOException
 *             DOCUMENT ME!
 */
public void write(Text text) throws IOException {
    writeString(text.getText());

    if (autoFlush) {
        flush();
    }
}