本文整理汇总了Java中org.jaxen.Navigator.isAttribute方法的典型用法代码示例。如果您正苦于以下问题:Java Navigator.isAttribute方法的具体用法?Java Navigator.isAttribute怎么用?Java Navigator.isAttribute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.jaxen.Navigator
的用法示例。
在下文中一共展示了Navigator.isAttribute方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: matches
import org.jaxen.Navigator; //导入方法依赖的package包/类
/** @return true if the pattern matches the given node
*/
public boolean matches( Object node, Context context )
{
Navigator navigator = context.getNavigator();
String uri = getURI( node, context );
if ( nodeType == Pattern.ELEMENT_NODE )
{
return navigator.isElement( node )
&& uri.equals( navigator.getElementNamespaceUri( node ) );
}
else if ( nodeType == Pattern.ATTRIBUTE_NODE )
{
return navigator.isAttribute( node )
&& uri.equals( navigator.getAttributeNamespaceUri( node ) );
}
return false;
}
示例2: evaluate
import org.jaxen.Navigator; //导入方法依赖的package包/类
public Object evaluate(List nodes, Object qnameObj, Navigator nav)
{
if (nodes.size() != 1)
{
return false;
}
// resolve the qname of the type we are checking for
String qnameStr = StringFunction.evaluate(qnameObj, nav);
if (qnameStr.equals("*"))
{
return true;
}
QName typeQName;
if (qnameStr.startsWith("{"))
{
typeQName = QName.createQName(qnameStr);
}
else
{
typeQName = QName.createQName(qnameStr, ((DocumentNavigator) nav).getNamespacePrefixResolver());
}
// resolve the noderef
NodeRef nodeRef = null;
if (nav.isElement(nodes.get(0)))
{
nodeRef = ((ChildAssociationRef) nodes.get(0)).getChildRef();
}
else if (nav.isAttribute(nodes.get(0)))
{
nodeRef = ((DocumentNavigator.Property) nodes.get(0)).parent;
}
DocumentNavigator dNav = (DocumentNavigator) nav;
boolean result = dNav.isSubtypeOf(nodeRef, typeQName);
return result;
}
示例3: matches
import org.jaxen.Navigator; //导入方法依赖的package包/类
/** @return true if the pattern matches the given node
*/
public boolean matches( Object node, Context context )
{
Navigator navigator = context.getNavigator();
if ( nodeType == Pattern.ELEMENT_NODE )
{
return navigator.isElement( node )
&& name.equals( navigator.getElementName( node ) );
}
else if ( nodeType == Pattern.ATTRIBUTE_NODE )
{
return navigator.isAttribute( node )
&& name.equals( navigator.getAttributeName( node ) );
}
else
{
if ( navigator.isElement( node ) )
{
return name.equals( navigator.getElementName( node ) );
}
else
if ( navigator.isAttribute( node ) )
{
return name.equals( navigator.getAttributeName( node ) );
}
}
return false;
}
示例4: evaluate
import org.jaxen.Navigator; //导入方法依赖的package包/类
/**
* Returns the local-name of <code>list.get(0)</code>
*
* @param list a list of nodes
* @param nav the <code>Navigator</code> used to retrieve the local name
*
* @return the local-name of <code>list.get(0)</code>
*
* @throws FunctionCallException if <code>list.get(0)</code> is not a node
*/
public static String evaluate(List list,
Navigator nav) throws FunctionCallException
{
if ( ! list.isEmpty() )
{
Object first = list.get(0);
if (first instanceof List)
{
return evaluate( (List) first,
nav );
}
else if ( nav.isElement( first ) )
{
return nav.getElementName( first );
}
else if ( nav.isAttribute( first ) )
{
return nav.getAttributeName( first );
}
else if ( nav.isProcessingInstruction( first ) )
{
return nav.getProcessingInstructionTarget( first );
}
else if ( nav.isNamespace( first ) )
{
return nav.getNamespacePrefix( first );
}
else if ( nav.isDocument( first ) )
{
return "";
}
else if ( nav.isComment( first ) )
{
return "";
}
else if ( nav.isText( first ) )
{
return "";
}
else {
throw new FunctionCallException("The argument to the local-name function must be a node-set");
}
}
return "";
}
示例5: evaluate
import org.jaxen.Navigator; //导入方法依赖的package包/类
/**
* Returns the number value of <code>obj</code>.
*
* @param obj the object to be converted to a number
* @param nav the <code>Navigator</code> used to calculate the string-value
* of node-sets
*
* @return a <code>Double</code>
*/
public static Double evaluate(Object obj, Navigator nav)
{
if( obj instanceof Double )
{
return (Double) obj;
}
else if ( obj instanceof String )
{
String str = (String) obj;
try
{
Double doubleValue = new Double( str );
return doubleValue;
}
catch (NumberFormatException e)
{
return NaN;
}
}
else if ( obj instanceof List || obj instanceof Iterator )
{
return evaluate( StringFunction.evaluate( obj, nav ), nav );
}
else if ( nav.isElement( obj ) || nav.isAttribute( obj )
|| nav.isText( obj ) || nav.isComment( obj ) || nav.isProcessingInstruction( obj )
|| nav.isDocument( obj ) || nav.isNamespace( obj ))
{
return evaluate( StringFunction.evaluate( obj, nav ), nav );
}
else if ( obj instanceof Boolean )
{
if ( Boolean.TRUE.equals(obj) )
{
return new Double( 1 );
}
else
{
return new Double( 0 );
}
}
return NaN;
}
示例6: evaluate
import org.jaxen.Navigator; //导入方法依赖的package包/类
/**
* Returns the namespace URI of <code>list.get(0)</code>
*
* @param list a list of nodes
* @param nav the <code>Navigator</code> used to retrieve the namespace
*
* @return the namespace URI of <code>list.get(0)</code>
*
* @throws FunctionCallException if <code>list.get(0)</code> is not a node
*/
public static String evaluate(List list,
Navigator nav) throws FunctionCallException
{
if ( ! list.isEmpty() )
{
Object first = list.get(0);
if ( first instanceof List )
{
return evaluate( (List) first,
nav );
}
else if ( nav.isElement( first ) )
{
return nav.getElementNamespaceUri( first );
}
else if ( nav.isAttribute( first ) )
{
String uri = nav.getAttributeNamespaceUri( first );
if (uri == null) return "";
return uri;
}
else if ( nav.isProcessingInstruction( first ) )
{
return "";
}
else if ( nav.isNamespace( first ) )
{
return "";
}
else if ( nav.isDocument( first ) )
{
return "";
}
else if ( nav.isComment( first ) )
{
return "";
}
else if ( nav.isText( first ) )
{
return "";
}
else {
throw new FunctionCallException(
"The argument to the namespace-uri function must be a node-set");
}
}
return "";
}
示例7: evaluate
import org.jaxen.Navigator; //导入方法依赖的package包/类
/**
* Returns the name of <code>list.get(0)</code>
*
* @param list a list of nodes
* @param nav the <code>Navigator</code> used to retrieve the name
*
* @return the name of <code>list.get(0)</code>
*
* @throws FunctionCallException if <code>list.get(0)</code> is not a node
*/
public static String evaluate(List list,
Navigator nav) throws FunctionCallException
{
if ( ! list.isEmpty() )
{
Object first = list.get(0);
if (first instanceof List)
{
return evaluate( (List) first,
nav );
}
else if ( nav.isElement( first ) )
{
return nav.getElementQName( first );
}
else if ( nav.isAttribute( first ) )
{
return nav.getAttributeQName( first );
}
else if ( nav.isProcessingInstruction( first ) )
{
return nav.getProcessingInstructionTarget( first );
}
else if ( nav.isNamespace( first ) )
{
return nav.getNamespacePrefix( first );
}
else if ( nav.isDocument( first ) )
{
return "";
}
else if ( nav.isComment( first ) )
{
return "";
}
else if ( nav.isText( first ) )
{
return "";
}
else {
throw new FunctionCallException("The argument to the name function must be a node-set");
}
}
return "";
}
示例8: matches
import org.jaxen.Navigator; //导入方法依赖的package包/类
/**
* Checks whether the node matches this step.
*
* @param node the node to check
* @param contextSupport the context support
* @return true if matches
* @throws JaxenException
*/
public boolean matches(Object node, ContextSupport contextSupport) throws JaxenException {
Navigator nav = contextSupport.getNavigator();
String myUri = null;
String nodeName = null;
String nodeUri = null;
if (nav.isElement(node)) {
nodeName = nav.getElementName(node);
nodeUri = nav.getElementNamespaceUri(node);
}
else if (nav.isText(node)) {
return false;
}
else if (nav.isAttribute(node)) {
if (getAxis() != Axis.ATTRIBUTE) {
return false;
}
nodeName = nav.getAttributeName(node);
nodeUri = nav.getAttributeNamespaceUri(node);
}
else if (nav.isDocument(node)) {
return false;
}
else if (nav.isNamespace(node)) {
if (getAxis() != Axis.NAMESPACE) {
// Only works for namespace::*
return false;
}
nodeName = nav.getNamespacePrefix(node);
}
else {
return false;
}
if (hasPrefix) {
myUri = contextSupport.translateNamespacePrefixToUri(this.prefix);
if (myUri == null) {
throw new UnresolvableException("Cannot resolve namespace prefix '"+this.prefix+"'");
}
}
else if (matchesAnyName) {
return true;
}
// If we map to a non-empty namespace and the node does not
// or vice-versa, fail-fast.
if (hasNamespace(myUri) != hasNamespace(nodeUri)) {
return false;
}
// To fail-fast, we check the equality of
// local-names first. Shorter strings compare
// quicker.
if (matchesAnyName || nodeName.equals(getLocalName())) {
return matchesNamespaceURIs(myUri, nodeUri);
}
return false;
}