本文整理汇总了Java中org.dom4j.Text类的典型用法代码示例。如果您正苦于以下问题:Java Text类的具体用法?Java Text怎么用?Java Text使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Text类属于org.dom4j包,在下文中一共展示了Text类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: deepCopyElement
import org.dom4j.Text; //导入依赖的package包/类
/**
* 复制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());
}
}
}
示例2: renderAllChildNodes
import org.dom4j.Text; //导入依赖的package包/类
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);
}
}
}
}
示例3: visit
import org.dom4j.Text; //导入依赖的package包/类
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);
}
}
示例4: getCollectionKeyFromDDS
import org.dom4j.Text; //导入依赖的package包/类
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;
}
示例5: assertNodesEqual
import org.dom4j.Text; //导入依赖的package包/类
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 );
}
}
示例6: add
import org.dom4j.Text; //导入依赖的package包/类
public void add(Text text) {
element.add( text );
}
示例7: remove
import org.dom4j.Text; //导入依赖的package包/类
public boolean remove(Text text) {
return element.remove( text );
}
示例8: text
import org.dom4j.Text; //导入依赖的package包/类
default Text text(final String string) {
return DocumentHelper.createText(string);
}
示例9: add
import org.dom4j.Text; //导入依赖的package包/类
public void add(Text text) {
target().add( text );
}
示例10: remove
import org.dom4j.Text; //导入依赖的package包/类
public boolean remove(Text text) {
return target().remove( text );
}
示例11: isText
import org.dom4j.Text; //导入依赖的package包/类
public boolean isText(Object obj)
{
return ( obj instanceof Text
||
obj instanceof CDATA );
}
示例12: write
import org.dom4j.Text; //导入依赖的package包/类
/**
* 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();
}
}