Java Code Examples for org.apache.jackrabbit.webdav.xml.DomUtil#getText()

The following examples show how to use org.apache.jackrabbit.webdav.xml.DomUtil#getText() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: StandardDavProperty.java    From cosmo with Apache License 2.0 6 votes vote down vote up
/**
 * <p>
 * If the property value is an <code>Element</code>, the text and character
 * data content of the element and every child element are concatenated.
 * </p>
 * <p>
 * If the property is a <code>Set</code>, the set is sorted and joined.
 * </p>
 * <p>
 * If the property value is otherwise not null, {@link Object.toString()} is
 * called upon it, and the result is returned.
 * </p>
 */
public String getValueText() {
    if (value == null) {
        return null;
    }
    if (value instanceof Element) {
        String text = DomUtil.getText((Element) value);
        if (text != null) {
            return text;
        }
    }
    if (value instanceof Set) {
        TreeSet<Object> sorted = new TreeSet<Object>((Set)value);
        return StringUtils.join(sorted, ", ");
    }
    return value.toString();
}
 
Example 2
Source File: PrincipalPropertySearchReport.java    From cosmo with Apache License 2.0 5 votes vote down vote up
public static SearchSpec createFromXml(Element root)
    throws CosmoDavException {
    if (! DomUtil.matches(root, "property-search", NAMESPACE)) {
        throw new IllegalArgumentException("Expected root element DAV:property-search");
    }

    Element p = DomUtil.getChildElement(root, "prop", NAMESPACE);
    if (p == null) {
        throw new BadRequestException("Expected DAV:prop child of DAV:property-search");
    }
    ElementIterator pi = DomUtil.getChildren(p);
    if (! pi.hasNext()) {
        throw new BadRequestException("Expected at least one child of DAV:prop");
    }

    HashSet<DavPropertyName> properties =
        new HashSet<DavPropertyName>();
    while (pi.hasNext()) {
        DavPropertyName name =
            DavPropertyName.createFromXml(pi.nextElement());
        properties.add(name);
    }

    Element m = DomUtil.getChildElement(root, "match", NAMESPACE);
    if (m == null) {
        throw new BadRequestException("Expected DAV:match child of DAV:property-search");
    }
    String match = DomUtil.getText(m);
    
    return new SearchSpec(properties, match);
}