本文整理匯總了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;
}