本文整理匯總了Java中org.dom4j.Element.getText方法的典型用法代碼示例。如果您正苦於以下問題:Java Element.getText方法的具體用法?Java Element.getText怎麽用?Java Element.getText使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.dom4j.Element
的用法示例。
在下文中一共展示了Element.getText方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getGradeRanges
import org.dom4j.Element; //導入方法依賴的package包/類
/**
* we want to collect all the gradeRange Values and return them as an Array
*
*@return The gradeRanges value
*@exception Exception Description of the Exception
*/
public String[] getGradeRanges()
throws Exception {
List list = docMap.selectNodes(gradeRangeXPath);
// create a normalized list, gr
ArrayList gr = new ArrayList();
for (Iterator i = list.iterator(); i.hasNext(); ) {
Element e = (Element) i.next();
String val = e.getText();
if (!val.trim().equals("")) {
gr.add(val);
}
}
// now return a string array
return (String[]) gr.toArray(new String[]{});
}
示例2: parseOozieEdge
import org.dom4j.Element; //導入方法依賴的package包/類
/** Parse a edge from xml
* @param enode edge node
*/
private static OozieEdge parseOozieEdge(Element enode) {
String src = "";
String dst = "";
List<Element> children = enode.elements();
for( Element child: children){
if ("source".equals(child.getName())) {
src = child.getText();
} else if ("destination".equals(child.getName())) {
dst = child.getText();
break;
}
}
if (src.isEmpty() || dst.isEmpty()) {
logger.warning("Empty edge, src:" + src + ", dst:" + dst);
return null;
}
else{
OozieEdge edge = new OozieEdge();
edge.init(src, dst);
return edge;
}
}
示例3: parseDatasetNode
import org.dom4j.Element; //導入方法依賴的package包/類
/** parse a dataset node from xml */
private static OozieDatasetNode parseDatasetNode(Element xml_node) {
List<Element> childNodes = xml_node.elements();
OozieDatasetNode node = new OozieDatasetNode();
for( Element child : childNodes){
String value = child.getText();
String name = child.getName();
if ("id".equals(name))
node.setId(value);
else if ("moduleId".equals(name))
node.setModuleId(value);
else if ("x".equals(name))
node.setX((int) Float.parseFloat(value));
else if ("y".equals(name))
node.setY((int) Float.parseFloat(value));
else if ("file".equals(name))
node.setFile(value);
}
return node;
}
示例4: getSubselect
import org.dom4j.Element; //導入方法依賴的package包/類
private static String getSubselect(Element element) {
String subselect = element.attributeValue( "subselect" );
if ( subselect != null ) {
return subselect;
}
else {
Element subselectElement = element.element( "subselect" );
return subselectElement == null ? null : subselectElement.getText();
}
}
示例5: getMirrorUrls
import org.dom4j.Element; //導入方法依賴的package包/類
public List getMirrorUrls () {
String xpath = "/itemRecord/technical/online/mirrorURLs/mirrorURL";
List nodes = getElements (xpath);
List mirrorUrls = new ArrayList ();
for (Iterator i=nodes.iterator();i.hasNext();) {
Element mElement = (Element)i.next();
String url = mElement.getText();
if (url != null && url.trim().length() > 0)
mirrorUrls.add (url.trim());
}
// return (String []) mirrorUrls.toArray(new String [] {});
return mirrorUrls;
}
示例6: parse
import org.dom4j.Element; //導入方法依賴的package包/類
@Override
public Value parse(Element element) {
SlashValue value=new SlashValue();
List<Slash> slashes=new ArrayList<Slash>();
value.setSlashes(slashes);
for(Object obj:element.elements()){
if(obj==null || !(obj instanceof Element)){
continue;
}
Element ele=(Element)obj;
if(ele.getName().equals("slash")){
Slash slash=new Slash();
slashes.add(slash);
slash.setDegree(Integer.valueOf(ele.attributeValue("degree")));
slash.setX(Integer.valueOf(ele.attributeValue("x")));
slash.setY(Integer.valueOf(ele.attributeValue("y")));
slash.setText(ele.attributeValue("text"));
}else if(ele.getName().equals("base64-data")){
String prefix="data:image/png;base64,";
String base64Data=ele.getText();
if(base64Data.startsWith(prefix)){
base64Data=base64Data.substring(prefix.length(),base64Data.length());
}
value.setBase64Data(base64Data);
}
}
return value;
}
示例7: RemoteResultDoc
import org.dom4j.Element; //導入方法依賴的package包/類
/**
* Construct a RemoteResultDoc from a MatchingRecord element (of the reponse
* from the UrlCheck Web Service)
*
*@param record matching record {@link org.dom4j.Element}
*@param rs instance of {@link RemoteSearcher}
*/
public RemoteResultDoc(Element record, RemoteSearcher rs) {
// prtln ("constructor with element:\n\t " + e.asXML());
this.rs = rs;
url = record.element("url").getText();
Element head = record.element("head");
try {
Element collectionElement = (Element) head.selectSingleNode("collection");
collection = collectionElement.getText();
id = head.selectSingleNode("id").getText();
} catch (Throwable te) {
prtln("RemoteResultDoc unable to parse element: " + te.getMessage());
}
}
示例8: SchemaPath
import org.dom4j.Element; //導入方法依賴的package包/類
/**
* Constructor for the SchemaPath object
*
*@param e Description of the Parameter
*/
public SchemaPath(Element e) {
// prtln ("SchemaPath with \n" + e.asXML());
xpath = e.getText();
pathName = e.attributeValue("pathName");
defaultValue = e.attributeValue("defaultValue");
valueType = e.attributeValue("valueType");
inputHelper = e.attributeValue("inputHelper");
initialFieldCollapse = e.attributeValue("initialFieldCollapse");
String copyRecord = e.attributeValue("requiredByCopyRecord");
if (copyRecord != null && copyRecord.equals("true")) {
requiredByCopyRecord = true;
}
String minimalRecord = e.attributeValue("requiredByMinimalRecord");
if (minimalRecord != null && minimalRecord.equals("true")) {
requiredByMinimalRecord = true;
}
String ro = e.attributeValue("readOnly");
if (ro != null && ro.equals("true")) {
readOnly = true;
}
String maxLenStr = e.attributeValue("maxLen");
if (maxLenStr != null) {
try {
maxLen = Integer.parseInt(maxLenStr);
} catch (NumberFormatException nfe) {
prtln ("WARNING: could not parse \"" + maxLenStr + "\" as an integer");
}
}
}
示例9: getPartOfDRC
import org.dom4j.Element; //導入方法依賴的package包/類
/**
* Gets whether the collection is part of the DRC [true|false].
*
* @return The partOfDRC Value
* @exception Exception If error
*/
protected String getPartOfDRC() throws Exception {
List nodes = getDom4jDoc().selectNodes("/*[local-name()='collectionRecord']/*[local-name()='access']/*[local-name()='drc']");
if (nodes.size() != 1)
return "false";
Element element = (Element) nodes.get(0);
return element.getText();
}
示例10: getUrls
import org.dom4j.Element; //導入方法依賴的package包/類
/**
* Gets the URL to the collection.
*
* @return The collectionUrl value
* @exception Exception If error
*/
public String[] getUrls() throws Exception {
List nodes = getDom4jDoc().selectNodes("/*[local-name()='collectionRecord']/*[local-name()='access']/*[local-name()='collectionLocation']");
if (nodes.size() == 0)
return null;
Element element = (Element) nodes.get(0);
return new String[]{element.getText()};
}
示例11: isEmpty
import org.dom4j.Element; //導入方法依賴的package包/類
/**
* isEmpty returns true if neither the element, or any children recursively, have textual content or have a
* non-empty attribute.
*
* @param e an Element to test
* @param ignoreWhiteSpace determines whether whitespace is considered as textual content .
* @return true if Element and all children recursively are empty
*/
public static boolean isEmpty(Element e, boolean ignoreWhiteSpace) {
String t = e.getText();
// if ((t == null) || (t.trim().length() > 0)) {
// 02/28/07 no longer ignore whitespace!
if (ignoreWhiteSpace && t.trim().length() > 0) {
return false;
}
if (!ignoreWhiteSpace && t.length() > 0) {
return false;
}
// is there a non-empty attribute? (note: we don't ignore whitespace for attributes ...)
for (Iterator i = e.attributeIterator(); i.hasNext(); ) {
Attribute a = (Attribute) i.next();
String value = a.getValue();
if ((value == null) || (value.trim().length() > 0)) {
return false;
}
}
// is there a non-empty child element?
for (Iterator i = e.elementIterator(); i.hasNext(); ) {
Element child = (Element) i.next();
boolean isChildEmpty = isEmpty(child);
if (!isChildEmpty) {
return false;
}
}
return true;
}
示例12: getTitle
import org.dom4j.Element; //導入方法依賴的package包/類
/**
* Returns the title for the collection.
*
* @return The title value
* @exception Exception If error reading XML.
*/
public String getTitle() throws Exception {
List nodes = getDom4jDoc().selectNodes("/record/general/title");
if (nodes.size() == 0)
return "";
Element element = (Element) nodes.get(0);
return element.getText();
}
示例13: parseChangeLog
import org.dom4j.Element; //導入方法依賴的package包/類
public List parseChangeLog(final File logFile) throws MalformedURLException, DocumentException {
final List result = new ArrayList(11);
final SAXReader saxReader = new SAXReader();
final Document document = saxReader.read(logFile);
final Element rootElement = document.getRootElement();
// if (LOG.isDebugEnabled()) {
// LOG.debug("rootElement: " + rootElement);
// }
// Iterate transactions
int changeListCounter = 0;
final Iterator iter = rootElement.elementIterator();
while (iter.hasNext() && changeListCounter++ < maxChangeLists) {
final Element transactionElement = (Element) iter.next();
if (!transactionElement.getName().equals("transaction")) {
continue;
}
// if (LOG.isDebugEnabled()) {
// LOG.debug("transactionElement: " + transactionElement);
// }
// Create change list
final String type = transactionElement.attributeValue("type");
final byte changeType = toChangeType(type);
if (changeType == Change.TYPE_UNKNOWN) {
continue;
}
final String id = transactionElement.attributeValue("id");
final String time = transactionElement.attributeValue("time");
final String user = transactionElement.attributeValue("user");
final Element elementComment = transactionElement.element("comment");
final String comment = elementComment.getText();
final ChangeList changeList = new ChangeList();
changeList.setCreatedAt(new Date(Long.parseLong(time) * 1000L));
changeList.setDescription(comment);
changeList.setNumber(id);
changeList.setUser(user);
// Iterate versions
int changeCounter = 0;
final Set changes = new HashSet(11);
final Iterator versionIter = transactionElement.elementIterator("version");
while (versionIter.hasNext() && changeCounter++ < maxChangeListSize) {
final Element versionElement = (Element) versionIter.next();
final String path = versionElement.attributeValue("path");
final String version = versionElement.attributeValue("virtualNamedVersion");
final Change change = new Change(path, version, changeType);
changes.add(change);
}
changeList.setChanges(changes);
// Add to result
result.add(changeList);
}
return result;
}
示例14: getSubElementText
import org.dom4j.Element; //導入方法依賴的package包/類
/**
* Gets the textual content of the named subelement of provided element.
*
* @param e element containing subelement
* @param subElementName name of subelement
* @return the textual content of named subelement
*/
public String getSubElementText(Element e, String subElementName) {
Element sub = e.element(subElementName);
if (sub == null) {
prtln("getSubElementText could not find subElement for " + subElementName);
return "";
}
return sub.getText();
}
示例15: parse
import org.dom4j.Element; //導入方法依賴的package包/類
@Override
public Value parse(Element element) {
SimpleValue simpleValue=new SimpleValue(element.getText());
return simpleValue;
}