Java Code Examples for org.dom4j.Element.isTextOnly()

The following are Jave code examples for showing how to use isTextOnly() of the org.dom4j.Element class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: ats-framework   File: XmlText.java   View Source Code Vote up 7 votes
/**
 * @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());
    }
}
 
Example 2
Project: ats-framework   File: XmlText.java   View Source Code Vote up 5 votes
/**
 * @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());
    }
}
 
Example 3
Project: ats-framework   File: XmlText.java   View Source Code Vote up 4 votes
/**
 * @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;
}
 
Example 4
Project: ats-framework   File: XmlText.java   View Source Code Vote up 4 votes
/**
 * @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());
    }
}