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


Java Navigator类代码示例

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


Navigator类属于org.jaxen包,在下文中一共展示了Navigator类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: evaluate

import org.jaxen.Navigator; //导入依赖的package包/类
public Object evaluate(Object attributeName, Object pattern, Navigator nav)
{
    List<Object> answer = new ArrayList<Object>();
    String attributeValue = StringFunction.evaluate(attributeName, nav);
    String patternValue = StringFunction.evaluate(pattern, nav);

    // TODO: Ignore the pattern for now
    // Should do a type pattern test
    if ((attributeValue != null) && (attributeValue.length() > 0))
    {
        DocumentNavigator dNav = (DocumentNavigator) nav;
        NodeRef nodeRef = new NodeRef(attributeValue);
        if (patternValue.equals("*"))
        {
            answer.add(dNav.getNode(nodeRef));
        }
        else
        {
            QNamePattern qNamePattern = new JCRPatternMatch(patternValue, dNav.getNamespacePrefixResolver());
            answer.addAll(dNav.getNode(nodeRef, qNamePattern));
        }

    }
    return answer;

}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:27,代码来源:NodeServiceXPath.java

示例2: evaluate

import org.jaxen.Navigator; //导入依赖的package包/类
@Override
public Object evaluate(final Context context) throws JaxenException {
    final Object lhsValue = getLHS().evaluate(context);
    final Object rhsValue = getRHS().evaluate(context);
    final Navigator nav = context.getNavigator();

    if (bothAreSets(lhsValue, rhsValue)) {
        return evaluateSetSet((List) lhsValue, (List) rhsValue, nav);
    }

    if (eitherIsSet(lhsValue, rhsValue)) {
        if (isSet(lhsValue)) {
            return evaluateSetSet((List) lhsValue, convertToList(rhsValue), nav);
        } else {
            return evaluateSetSet(convertToList(lhsValue), (List) rhsValue, nav);
        }
    }

    return evaluateObjectObject(lhsValue, rhsValue, nav) ? Boolean.TRUE : Boolean.FALSE;
}
 
开发者ID:dkmfbk,项目名称:knowledgestore,代码行数:21,代码来源:DefaultRelationalExpr.java

示例3: evaluateSetSet

import org.jaxen.Navigator; //导入依赖的package包/类
private Object evaluateSetSet(final List lhsSet, final List rhsSet, final Navigator nav) {
    if (setIsEmpty(lhsSet) || setIsEmpty(rhsSet)) // return false if either is null or empty
    {
        return Boolean.FALSE;
    }

    for (final Iterator lhsIterator = lhsSet.iterator(); lhsIterator.hasNext();) {
        final Object lhs = lhsIterator.next();

        for (final Iterator rhsIterator = rhsSet.iterator(); rhsIterator.hasNext();) {
            final Object rhs = rhsIterator.next();

            if (evaluateObjectObject(lhs, rhs, nav)) {
                return Boolean.TRUE;
            }
        }
    }

    return Boolean.FALSE;
}
 
开发者ID:dkmfbk,项目名称:knowledgestore,代码行数:21,代码来源:DefaultRelationalExpr.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();
    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

示例5: call

import org.jaxen.Navigator; //导入依赖的package包/类
public Object call(Context context,
                   List args) throws FunctionCallException
{
    if (args.size() == 1)
    {
        Navigator nav = context.getNavigator();

        String    url = StringFunction.evaluate( args.get( 0 ),
                                                 nav );

        return evaluate( url,
                         nav );
    }

    throw new FunctionCallException( "document() requires one argument." );
}
 
开发者ID:jaxen-xpath,项目名称:jaxen,代码行数:17,代码来源:DocumentFunction.java

示例6: evaluate

import org.jaxen.Navigator; //导入依赖的package包/类
/** 
 * <p>Returns true if the first string contains the second string; false otherwise.
 * If necessary one or both arguments are converted to a string as if by the XPath
 * <code>string()</code> function.
 * </p>
 * 
 * @param strArg the containing string
 * @param matchArg the contained string
 * @param nav used to calculate the string-values of the first two arguments
 * 
 * @return <code>Boolean.TRUE</code> if true if the first string contains 
 *     the second string; <code>Boolean.FALSE</code> otherwise.
 */
public static Boolean evaluate(Object strArg,
                               Object matchArg,
                               Navigator nav) 
{
    String str   = StringFunction.evaluate( strArg,
                                            nav );

    String match = StringFunction.evaluate( matchArg,
                                            nav );

    return ( ( str.indexOf(match) >= 0)
             ? Boolean.TRUE
             : Boolean.FALSE
             );
}
 
开发者ID:jaxen-xpath,项目名称:jaxen,代码行数:29,代码来源:ContainsFunction.java

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

示例8: evaluate

import org.jaxen.Navigator; //导入依赖的package包/类
/** 
 * Returns true if the string-value of <code>strArg</code>
 * starts with the string-value of <code>matchArg</code>. 
 * Otherwise it returns false.
 * 
 * @param strArg the object whose string-value searched for the prefix
 * @param matchArg the object whose string-value becomes the prefix string to compare against
 * @param nav the navigator used to calculate the string-values of the arguments
 * 
 * @return <code>Boolean.TRUE</code> if the string-value of <code>strArg</code>
 *     starts with the string-value of <code>matchArg</code>;
 *     otherwise <code>Boolean.FALSE</code>
 * 
 */
public static Boolean evaluate(Object strArg,
                               Object matchArg,
                               Navigator nav)
{
    String str   = StringFunction.evaluate( strArg,
                                            nav );

    String match = StringFunction.evaluate( matchArg,
                                            nav );

    return ( str.startsWith(match)
             ? Boolean.TRUE
             : Boolean.FALSE
             );
}
 
开发者ID:jaxen-xpath,项目名称:jaxen,代码行数:30,代码来源:StartsWithFunction.java

示例9: evaluate

import org.jaxen.Navigator; //导入依赖的package包/类
/** 
 * Returns the sum of the items in a list.
 * If necessary, each item in the list is first converted to a <code>Double</code>
 * as if by the XPath <code>number()</code> function.
 * 
 * @param obj a <code>List</code> of numbers to be summed
 * @param nav ignored
 * 
 * @return the sum of the list
 * 
 * @throws FunctionCallException if <code>obj</code> is not a <code>List</code>
 */
public static Double evaluate(Object obj,
                              Navigator nav) throws FunctionCallException
{
    double sum  = 0;

    if (obj instanceof List)
    {
        Iterator nodeIter = ((List)obj).iterator();
        while ( nodeIter.hasNext() )
        {
            double term = NumberFunction.evaluate( nodeIter.next(),
                                            nav ).doubleValue();
            sum += term;
        }
    }
    else
    {
        throw new FunctionCallException("The argument to the sum function must be a node-set");
    }

    return new Double(sum);
}
 
开发者ID:jaxen-xpath,项目名称:jaxen,代码行数:35,代码来源:SumFunction.java

示例10: evaluate

import org.jaxen.Navigator; //导入依赖的package包/类
/** 
 * Returns the part of <code>strArg</code> that precedes the first occurence 
 * of <code>matchArg</code>; or the empty string if the 
 * <code>strArg</code> does not contain <code>matchArg</code>
 * 
 * @param strArg the string from which the substring is extracted
 * @param matchArg the string that marks the boundary of the substring
 * @param nav the <code>Navigator</code> used to calculate the string-values of
 *     the first two arguments
 * 
 * @return a <code>String</code> containing the part of <code>strArg</code> that precedes the first occurence 
 * of <code>matchArg</code>
 * 
 */
public static String evaluate(Object strArg,
                              Object matchArg,
                              Navigator nav)
{
    String str   = StringFunction.evaluate( strArg,
                                            nav );

    String match = StringFunction.evaluate( matchArg,
                                            nav );

    int loc = str.indexOf(match);

    if ( loc < 0 )
    {
        return "";
    }

    return str.substring(0, loc);

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

示例11: evaluate

import org.jaxen.Navigator; //导入依赖的package包/类
/** 
 * Returns the part of <code>strArg</code> that follows the first occurence 
 * of <code>matchArg</code>; or the empty string if the 
 * <code>strArg</code> does not contain <code>matchArg</code>
 * 
 * @param strArg the string from which the substring is extracted
 * @param matchArg the string that marks the boundary of the substring
 * @param nav the <code>Navigator</code> used to calculate the string-values of
 *     the first two arguments
 * 
 * @return a <code>String</code> containing
 *     the part of <code>strArg</code> that precedes the first occurence 
 *     of <code>matchArg</code>
 * 
 */
public static String evaluate(Object strArg,
                              Object matchArg,
                              Navigator nav)
{
    String str   = StringFunction.evaluate( strArg,
                                            nav );

    String match = StringFunction.evaluate( matchArg,
                                            nav );

    int loc = str.indexOf(match);

    if ( loc < 0 )
    {
        return "";
    }

    return str.substring(loc+match.length());
}
 
开发者ID:jaxen-xpath,项目名称:jaxen,代码行数:35,代码来源:SubstringAfterFunction.java

示例12: getLocale

import org.jaxen.Navigator; //导入依赖的package包/类
/** 
 * Attempts to convert the given function argument value 
 * into a Locale either via casting, extracting it from a List
 * or looking up the named Locale using reflection.
 *
 * @param value is either a Locale, a List containing a Locale
 *      or a String containing the name of a Locale
 *      as defined by the Locale static members.
 *
 * @return the Locale for the value or null if one could 
 *      not be deduced
 */
protected Locale getLocale(Object value, Navigator navigator) 
{
    if (value instanceof Locale)
    {
        return (Locale) value;
    }
    else if(value instanceof List)
    {
        List list = (List) value;
        if ( ! list.isEmpty() ) 
        {
            return getLocale( list.get(0), navigator );
        }
    }
    else {
        String text = StringFunction.evaluate( value, navigator );
        if (text != null && text.length() > 0) 
        {
            return findLocale( text );
        }
    }
    return null;
}
 
开发者ID:jaxen-xpath,项目名称:jaxen,代码行数:36,代码来源:LocaleFunctionSupport.java

示例13: call

import org.jaxen.Navigator; //导入依赖的package包/类
public Object call(Context context,
                   List args) throws FunctionCallException
{
    Navigator navigator = context.getNavigator();
    int size = args.size();
    if (size > 0)
    {
        Object text = args.get(0);
        Locale locale = null;
        if (size > 1)
        {  
            locale = getLocale( args.get(1), navigator );
        }
        return evaluate( text, locale, navigator );
    }
    throw new FunctionCallException( "lower-case() requires at least one argument." );
}
 
开发者ID:jaxen-xpath,项目名称:jaxen,代码行数:18,代码来源:LowerFunction.java

示例14: call

import org.jaxen.Navigator; //导入依赖的package包/类
public Object call(Context context,
                   List args) throws FunctionCallException
{
    Navigator navigator = context.getNavigator();
    int size = args.size();
    if (size > 0)
    {
        Object text = args.get(0);
        Locale locale = null;
        if (size > 1)
        {  
            locale = getLocale( args.get(1), navigator );
        }
        return evaluate( text, locale, navigator );
    }
    throw new FunctionCallException( "upper-case() requires at least one argument." );
}
 
开发者ID:jaxen-xpath,项目名称:jaxen,代码行数:18,代码来源:UpperFunction.java

示例15: evaluate

import org.jaxen.Navigator; //导入依赖的package包/类
public Object evaluate(Context context) throws JaxenException
{
    ContextSupport support = context.getContextSupport();
    Navigator      nav     = support.getNavigator();
    Context absContext = new Context( support );
    List contextNodes = context.getNodeSet();

    if ( contextNodes.isEmpty() )
    {
        return Collections.EMPTY_LIST;
    }

    Object firstNode = contextNodes.get( 0 );
    Object docNode   = nav.getDocumentNode( firstNode );

    if ( docNode == null )
    {
        return Collections.EMPTY_LIST;
    }

    List list = new SingletonList(docNode);

    absContext.setNodeSet( list );

    return super.evaluate( absContext );
}
 
开发者ID:jaxen-xpath,项目名称:jaxen,代码行数:27,代码来源:DefaultAbsoluteLocationPath.java


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