当前位置: 首页>>代码示例>>Java>>正文


Java Navigator.isElement方法代码示例

本文整理汇总了Java中org.jaxen.Navigator.isElement方法的典型用法代码示例。如果您正苦于以下问题:Java Navigator.isElement方法的具体用法?Java Navigator.isElement怎么用?Java Navigator.isElement使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.jaxen.Navigator的用法示例。


在下文中一共展示了Navigator.isElement方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
 
开发者ID:jaxen-xpath,项目名称:jaxen,代码行数:20,代码来源:NamespaceTest.java

示例2: evaluate

import org.jaxen.Navigator; //导入方法依赖的package包/类
private static boolean evaluate(Object node, String lang, Navigator nav)
  throws UnsupportedAxisException
{
    
    Object element = node;
    if (! nav.isElement(element)) {
        element = nav.getParentNode(node);
    }
    while (element != null && nav.isElement(element)) 
    {
        Iterator attrs = nav.getAttributeAxisIterator(element);
        while(attrs.hasNext())
        {
            Object attr = attrs.next();
            if(LANG_LOCALNAME.equals(nav.getAttributeName(attr)) && 
               XMLNS_URI.equals(nav.getAttributeNamespaceUri(attr)))
            {
                return 
                    isSublang(nav.getAttributeStringValue(attr), lang);
            }
        }
        element = nav.getParentNode(element);
    }
    return false;
}
 
开发者ID:jaxen-xpath,项目名称:jaxen,代码行数:26,代码来源:LangFunction.java

示例3: 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;
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:38,代码来源:NodeServiceXPath.java

示例4: 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;
}
 
开发者ID:jaxen-xpath,项目名称:jaxen,代码行数:30,代码来源:NameTest.java

示例5: 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 "";
}
 
开发者ID:jaxen-xpath,项目名称:jaxen,代码行数:58,代码来源:LocalNameFunction.java

示例6: 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;
}
 
开发者ID:jaxen-xpath,项目名称:jaxen,代码行数:52,代码来源:NumberFunction.java

示例7: 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 "";

}
 
开发者ID:jaxen-xpath,项目名称:jaxen,代码行数:63,代码来源:NamespaceUriFunction.java

示例8: 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 "";

}
 
开发者ID:jaxen-xpath,项目名称:jaxen,代码行数:59,代码来源:NameFunction.java

示例9: 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;
}
 
开发者ID:jaxen-xpath,项目名称:jaxen,代码行数:70,代码来源:DefaultNameStep.java


注:本文中的org.jaxen.Navigator.isElement方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。