Java Code Examples for javax.xml.xpath.XPathConstants#STRING

The following examples show how to use javax.xml.xpath.XPathConstants#STRING . 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: XpathExpectationsHelper.java    From spring-analysis-note with MIT License 6 votes vote down vote up
private <T> QName toQName(Class<T> expectedClass) {
	QName evaluationType;
	if (Number.class.isAssignableFrom(expectedClass)) {
		evaluationType = XPathConstants.NUMBER;
	}
	else if (CharSequence.class.isAssignableFrom(expectedClass)) {
		evaluationType = XPathConstants.STRING;
	}
	else if (Boolean.class.isAssignableFrom(expectedClass)) {
		evaluationType = XPathConstants.BOOLEAN;
	}
	else if (Node.class.isAssignableFrom(expectedClass)) {
		evaluationType = XPathConstants.NODE;
	}
	else if (NodeList.class.isAssignableFrom(expectedClass)) {
		evaluationType = XPathConstants.NODESET;
	}
	else {
		throw new IllegalArgumentException("Unexpected target class " + expectedClass + ". " +
				"Supported: numbers, strings, boolean, and org.w3c.Node and NodeList");
	}
	return evaluationType;
}
 
Example 2
Source File: XpathExpectationsHelper.java    From java-technology-stack with MIT License 6 votes vote down vote up
private <T> QName toQName(Class<T> expectedClass) {
	QName evaluationType;
	if (Number.class.isAssignableFrom(expectedClass)) {
		evaluationType = XPathConstants.NUMBER;
	}
	else if (CharSequence.class.isAssignableFrom(expectedClass)) {
		evaluationType = XPathConstants.STRING;
	}
	else if (Boolean.class.isAssignableFrom(expectedClass)) {
		evaluationType = XPathConstants.BOOLEAN;
	}
	else if (Node.class.isAssignableFrom(expectedClass)) {
		evaluationType = XPathConstants.NODE;
	}
	else if (NodeList.class.isAssignableFrom(expectedClass)) {
		evaluationType = XPathConstants.NODESET;
	}
	else {
		throw new IllegalArgumentException("Unexpected target class " + expectedClass + ". " +
				"Supported: numbers, strings, boolean, and org.w3c.Node and NodeList");
	}
	return evaluationType;
}
 
Example 3
Source File: DOMHandle.java    From java-client-api with Apache License 2.0 6 votes vote down vote up
protected QName returnXPathConstant(Class<?> as) {
  if (as == null) {
    throw new IllegalArgumentException("cannot execute XPath as null");
  } else if (Node.class.isAssignableFrom(as)) {
    return XPathConstants.NODE;
  } else if (NodeList.class.isAssignableFrom(as)) {
    return XPathConstants.NODESET;
  } else if (String.class.isAssignableFrom(as)) {
    return XPathConstants.STRING;
  } else if (Number.class.isAssignableFrom(as)) {
    return XPathConstants.NUMBER;
  } else if (Boolean.class.isAssignableFrom(as)) {
    return XPathConstants.BOOLEAN;
  }
  throw new IllegalArgumentException("cannot execute XPath as "+as.getName());
}
 
Example 4
Source File: XPathFilter.java    From storm-crawler with Apache License 2.0 5 votes vote down vote up
public QName getReturnType() {
    switch (this) {
    case STRING:
        return XPathConstants.STRING;
    default:
        return XPathConstants.NODESET;
    }
}