本文整理汇总了Java中com.sun.org.apache.xpath.internal.objects.XObject.str方法的典型用法代码示例。如果您正苦于以下问题:Java XObject.str方法的具体用法?Java XObject.str怎么用?Java XObject.str使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.sun.org.apache.xpath.internal.objects.XObject
的用法示例。
在下文中一共展示了XObject.str方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getResultAsType
import com.sun.org.apache.xpath.internal.objects.XObject; //导入方法依赖的package包/类
private Object getResultAsType( XObject resultObject, QName returnType )
throws javax.xml.transform.TransformerException {
// XPathConstants.STRING
if ( returnType.equals( XPathConstants.STRING ) ) {
return resultObject.str();
}
// XPathConstants.NUMBER
if ( returnType.equals( XPathConstants.NUMBER ) ) {
return new Double ( resultObject.num());
}
// XPathConstants.BOOLEAN
if ( returnType.equals( XPathConstants.BOOLEAN ) ) {
return new Boolean( resultObject.bool());
}
// XPathConstants.NODESET ---ORdered, UNOrdered???
if ( returnType.equals( XPathConstants.NODESET ) ) {
return resultObject.nodelist();
}
// XPathConstants.NODE
if ( returnType.equals( XPathConstants.NODE ) ) {
NodeIterator ni = resultObject.nodeset();
//Return the first node, or null
return ni.nextNode();
}
String fmsg = XSLMessages.createXPATHMessage(
XPATHErrorResources.ER_UNSUPPORTED_RETURN_TYPE,
new Object[] { returnType.toString()});
throw new IllegalArgumentException( fmsg );
}
示例2: getResultAsType
import com.sun.org.apache.xpath.internal.objects.XObject; //导入方法依赖的package包/类
private Object getResultAsType( XObject resultObject, QName returnType )
throws javax.xml.transform.TransformerException {
// XPathConstants.STRING
if ( returnType.equals( XPathConstants.STRING ) ) {
return resultObject.str();
}
// XPathConstants.NUMBER
if ( returnType.equals( XPathConstants.NUMBER ) ) {
return new Double ( resultObject.num());
}
// XPathConstants.BOOLEAN
if ( returnType.equals( XPathConstants.BOOLEAN ) ) {
return new Boolean( resultObject.bool());
}
// XPathConstants.NODESET ---ORdered, UNOrdered???
if ( returnType.equals( XPathConstants.NODESET ) ) {
return resultObject.nodelist();
}
// XPathConstants.NODE
if ( returnType.equals( XPathConstants.NODE ) ) {
NodeIterator ni = resultObject.nodeset();
//Return the first node, or null
return ni.nextNode();
}
// If isSupported check is already done then the execution path
// shouldn't come here. Being defensive
String fmsg = XSLMessages.createXPATHMessage(
XPATHErrorResources.ER_UNSUPPORTED_RETURN_TYPE,
new Object[] { returnType.toString()});
throw new IllegalArgumentException ( fmsg );
}
示例3: getResult
import com.sun.org.apache.xpath.internal.objects.XObject; //导入方法依赖的package包/类
/**
* Read the XObject and set values in accordance with the result type
* @param resultObject internal XPath result object
* @throws TransformerException if there is an error reading the XPath
* result.
*/
private void getResult(XObject resultObject) throws TransformerException {
switch (resultType) {
case XObject.CLASS_BOOLEAN:
boolValue = resultObject.bool();
mapToType = XPathResultType.BOOLEAN;
break;
case XObject.CLASS_NUMBER:
numValue = resultObject.num();
mapToType = XPathResultType.NUMBER;
break;
case XObject.CLASS_STRING:
strValue = resultObject.str();
mapToType = XPathResultType.STRING;
break;
case XObject.CLASS_NODESET:
mapToType = XPathResultType.NODESET;
nodeList = resultObject.nodelist();
break;
case XObject.CLASS_RTREEFRAG: //NODE
mapToType = XPathResultType.NODE;
NodeIterator ni = resultObject.nodeset();
//Return the first node, or null
node = ni.nextNode();
break;
}
}
示例4: getResultAsType
import com.sun.org.apache.xpath.internal.objects.XObject; //导入方法依赖的package包/类
/**
* Get result depending on the QName type defined in XPathConstants
* @param resultObject the result of an evaluation
* @param returnType the return type
* @return result per the return type
* @throws TransformerException if the result can not be converted to
* the specified return type.
*/
Object getResultAsType(XObject resultObject, QName returnType)
throws TransformerException {
// XPathConstants.STRING
if (returnType.equals(XPathConstants.STRING)) {
return resultObject.str();
}
// XPathConstants.NUMBER
if (returnType.equals(XPathConstants.NUMBER)) {
return resultObject.num();
}
// XPathConstants.BOOLEAN
if (returnType.equals(XPathConstants.BOOLEAN)) {
return resultObject.bool();
}
// XPathConstants.NODESET ---ORdered, UNOrdered???
if (returnType.equals(XPathConstants.NODESET)) {
return resultObject.nodelist();
}
// XPathConstants.NODE
if (returnType.equals(XPathConstants.NODE)) {
NodeIterator ni = resultObject.nodeset();
//Return the first node, or null
return ni.nextNode();
}
// If isSupported check is already done then the execution path
// shouldn't come here. Being defensive
String fmsg = XSLMessages.createXPATHMessage(
XPATHErrorResources.ER_UNSUPPORTED_RETURN_TYPE,
new Object[] { returnType.toString()});
throw new IllegalArgumentException (fmsg);
}