List of usage examples for org.dom4j Node getText
String getText();
Returns the text of this node.
From source file:com.cladonia.xml.XMLFormatter.java
License:Mozilla Public License
protected void writeMixedNode(Node node) throws IOException { if (DEBUG)/*from ww w. ja v a2 s .c o m*/ System.out.println("XMLFormatter.writeMixedNode( " + node + ")"); int nodeType = node.getNodeType(); switch (nodeType) { case Node.ELEMENT_NODE: writeMixedElement((Element) node); break; case Node.ATTRIBUTE_NODE: writeAttribute((Attribute) node); break; case Node.TEXT_NODE: writeString(node.getText()); //write((Text) node); break; case Node.CDATA_SECTION_NODE: writeCDATA(node.getText()); break; case Node.ENTITY_REFERENCE_NODE: writeEntity((Entity) node); break; case Node.PROCESSING_INSTRUCTION_NODE: writeProcessingInstruction((ProcessingInstruction) node); break; case Node.COMMENT_NODE: writeComment(node.getText()); break; case Node.DOCUMENT_NODE: write((Document) node); break; case Node.DOCUMENT_TYPE_NODE: writeDocType((DocumentType) node); break; case Node.NAMESPACE_NODE: // Will be output with attributes //write((Namespace) node); break; default: throw new IOException("Invalid node type: " + node); } }
From source file:com.cladonia.xml.XMLFormatter.java
License:Mozilla Public License
protected void writePreservedNode(Node node) throws IOException { if (DEBUG)// w w w . j a va 2s.c om System.out.println("XMLFormatter.writeMixedNode( " + node + ")"); int nodeType = node.getNodeType(); switch (nodeType) { case Node.ELEMENT_NODE: writePreservedElement((Element) node); break; case Node.ATTRIBUTE_NODE: writeAttribute((Attribute) node); break; case Node.TEXT_NODE: writeString(node.getText()); //write((Text) node); break; case Node.CDATA_SECTION_NODE: writeCDATA(node.getText()); break; case Node.ENTITY_REFERENCE_NODE: writeEntity((Entity) node); break; case Node.PROCESSING_INSTRUCTION_NODE: writeProcessingInstruction((ProcessingInstruction) node); break; case Node.COMMENT_NODE: writeComment(node.getText()); break; case Node.DOCUMENT_NODE: write((Document) node); break; case Node.DOCUMENT_TYPE_NODE: writeDocType((DocumentType) node); break; case Node.NAMESPACE_NODE: // Will be output with attributes //write((Namespace) node); break; default: throw new IOException("Invalid node type: " + node); } }
From source file:com.cladonia.xngreditor.actions.ToolsCapitalizeAction.java
License:Open Source License
private static boolean isWhiteSpace(Node node) throws Exception { return node.getText().trim().length() == 0; }
From source file:com.cladonia.xngreditor.actions.ToolsDeCapitalizeAction.java
License:Open Source License
/** * check whether this is a whitespace node or not * @param node the node to check/*from w w w.j a v a2 s . c om*/ * @return boolean true if node is whitespace else false * @throws Exception */ private static boolean isWhiteSpace(Node node) throws Exception { return node.getText().trim().length() == 0; }
From source file:com.cladonia.xngreditor.actions.ToolsStripTextAction.java
License:Open Source License
private void treeWalk(XElement element, boolean stripElements, boolean stripAttributes, boolean stripMixedContent, boolean traverseChildren) throws Exception { for (int i = 0, size = element.nodeCount(); i < size; i++) { Node node = element.node(i); if ((node instanceof Element) && (traverseChildren)) { //remove the attributes first XElement e = (XElement) node; if (stripAttributes) { if (e.attributeCount() > 0) { int attCount = e.attributeCount(); for (int cnt = 0; cnt < attCount; ++cnt) { Attribute att = e.attribute(cnt); att.setText(""); }/*from w ww . ja v a 2 s .com*/ } } //check if it is mixed if ((stripMixedContent) && (isMixed((XElement) node))) { e.removeAllChildren(); } else { treeWalk(e, stripElements, stripAttributes, stripMixedContent, traverseChildren); } } else if ((stripElements) && (node instanceof Text)) { //these are all text nodes // blank but need to preserve formatting String value = node.getText(); //if it does not contain a new line char then can blank // straight away if (value.indexOf("\n") == -1) { node.setText(""); } else { //id does contain a newline if (value.charAt(0) == '\n') { //if the first char is new line //the new value should have all the spaces, \n and \t // but no letters or digits String newValue = ""; for (int cnt = 0; cnt < value.length(); ++cnt) { //look for the first occurence of a real character if (Character.isLetterOrDigit(value.charAt(cnt))) { //cnt = value.length(); } else if ((value.charAt(cnt) == '\n') || (value.charAt(cnt) == '\t') || (value.charAt(cnt) == ' ')) { newValue += value.charAt(cnt); } } node.setText(newValue); } else { String newValue = ""; for (int cnt = 0; cnt < value.length(); ++cnt) { //look for the first occurence of a real character if (Character.isLetterOrDigit(value.charAt(cnt))) { //cnt = value.length(); } else if ((value.charAt(cnt) == '\n') || (value.charAt(cnt) == '\t') || (value.charAt(cnt) == ' ')) { newValue += value.charAt(cnt); } } node.setText(newValue); } } } } }
From source file:com.cladonia.xngreditor.actions.ToolsStripTextAction.java
License:Open Source License
private static boolean isWhiteSpace(Node node) throws Exception { return node.getText().trim().length() == 0; }
From source file:com.collabnet.ccf.core.AbstractReader.java
License:Open Source License
public String getArtifactLastModifiedTime(Document syncInfo) { Node node = syncInfo.selectSingleNode(ARTIFACT_LAST_MODIFIED_DATE); if (node == null) return null; String dbTime = node.getText(); if (!StringUtils.isEmpty(dbTime)) { java.sql.Timestamp ts = java.sql.Timestamp.valueOf(dbTime); long time = ts.getTime(); Date date = new Date(time); return DateUtil.format(date); }/*from w ww . j av a2 s . c om*/ return null; }
From source file:com.collabnet.ccf.core.AbstractReader.java
License:Open Source License
public String getArtifactLastModifiedVersion(Document syncInfo) { Node node = syncInfo.selectSingleNode(ARTIFACT_LAST_MODIFIED_VERSION); if (node == null) return null; return node.getText(); }
From source file:com.collabnet.ccf.core.AbstractReader.java
License:Open Source License
/** * Extracts and returns the conflictResolutionPriority for the source * repository./*from w w w . j av a2 s. c om*/ * * @param syncInfo * @return */ public String getConflictResolutionPriority(Document syncInfo) { Node node = syncInfo.selectSingleNode(CONFLICT_RESOLUTION_PRIORITY); if (node == null) return null; return node.getText(); }
From source file:com.collabnet.ccf.core.AbstractReader.java
License:Open Source License
/** * Extracts and returns the last modified time of the artifact that was * sync-ed last./* w w w . ja v a 2 s .co m*/ * * @param syncInfo * @return */ public String getLastSourceArtifactModificationDate(Document syncInfo) { // LAST_SOURCE_ARTIFACT_MODIFICATION_DATE Node node = syncInfo.selectSingleNode(LAST_SOURCE_ARTIFACT_MODIFICATION_DATE); if (node == null) return null; String dbTime = node.getText(); if (!StringUtils.isEmpty(dbTime)) { java.sql.Timestamp ts = java.sql.Timestamp.valueOf(dbTime); long time = ts.getTime(); Date date = new Date(time); return DateUtil.format(date); } return null; }