本文整理汇总了Java中org.dom4j.Element.isTextOnly方法的典型用法代码示例。如果您正苦于以下问题:Java Element.isTextOnly方法的具体用法?Java Element.isTextOnly怎么用?Java Element.isTextOnly使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.dom4j.Element
的用法示例。
在下文中一共展示了Element.isTextOnly方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getFloat
import org.dom4j.Element; //导入方法依赖的package包/类
/**
* @param xpath XPath , pointing to a XML element
* @return a float XML value
* @throws XMLException
*/
@PublicAtsApi
public float getFloat(
String xpath ) throws XMLException {
Object object = get(xpath);
Element root = ((XmlText) object).root;
if (root.isTextOnly()) {
object = root.getText().trim();
} else {
object = "";
}
try {
return Float.parseFloat( ((String) object).trim());
} catch (NumberFormatException nfe) {
throw new XMLException("'" + xpath + "' does not point to a float value:\n"
+ object.toString());
}
}
示例2: getInt
import org.dom4j.Element; //导入方法依赖的package包/类
/**
* @param xpath XPath , pointing to a XML element
* @return an Integer XML value
* @throws XMLException
*/
@PublicAtsApi
public int getInt(
String xpath ) throws XMLException {
Object object = get(xpath);
Element root = ((XmlText) object).root;
if (root.isTextOnly()) {
object = root.getText().trim();
} else {
object = "";
}
try {
return Integer.parseInt( ((String) object).trim());
} catch (NumberFormatException nfe) {
throw new XMLException("'" + xpath + "' does not point to an int value:\n" + object.toString());
}
}
示例3: getBoolean
import org.dom4j.Element; //导入方法依赖的package包/类
/**
* @param xpath XPath , pointing to a XML element
* @return a boolean XML value
* @throws XMLException
*/
@PublicAtsApi
public boolean getBoolean(
String xpath ) throws XMLException {
Object object = get(xpath);
Element root = ((XmlText) object).root;
if (root.isTextOnly()) {
object = root.getText().trim();
} else {
object = "";
}
if ("true".equalsIgnoreCase((String) object)
|| "false".equalsIgnoreCase((String) object)) {
return Boolean.parseBoolean( ((String) object).trim());
} else {
throw new XMLException("'" + xpath + "' does not point to an boolean value:\n"
+ object.toString());
}
}
示例4: getString
import org.dom4j.Element; //导入方法依赖的package包/类
/**
* @param xpath XPath , pointing to a XML element
* @return a String XML value
* @throws XMLException
*/
@PublicAtsApi
public String getString(
String xpath ) throws XMLException {
Object object = get(xpath);
Element root = ((XmlText) object).root;
if (root.isTextOnly()) {
object = root.getText().trim();
} else {
throw new XMLException("'" + xpath + "' does not point to a String value:\n"
+ object.toString());
}
return (String) object;
}