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


Java Context.getNavigator方法代码示例

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


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

示例1: evaluate

import org.jaxen.Context; //导入方法依赖的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

示例2: matches

import org.jaxen.Context; //导入方法依赖的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

示例3: call

import org.jaxen.Context; //导入方法依赖的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

示例4: call

import org.jaxen.Context; //导入方法依赖的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

示例5: call

import org.jaxen.Context; //导入方法依赖的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

示例6: evaluate

import org.jaxen.Context; //导入方法依赖的package包/类
public Object evaluate(Context context) throws JaxenException
{
    Navigator nav = context.getNavigator();
    Boolean lhsValue = BooleanFunction.evaluate( getLHS().evaluate( context ), nav );

    if ( lhsValue.booleanValue() )
    {
        return Boolean.TRUE;
    }

    // Short circuits are required in XPath. "The right operand is not 
    // evaluated if the left operand evaluates to true."
    Boolean rhsValue = BooleanFunction.evaluate( getRHS().evaluate( context ), nav );

    if ( rhsValue.booleanValue() )
    {
        return Boolean.TRUE;
    }

    return Boolean.FALSE;
}
 
开发者ID:jaxen-xpath,项目名称:jaxen,代码行数:22,代码来源:DefaultOrExpr.java

示例7: evaluate

import org.jaxen.Context; //导入方法依赖的package包/类
public Object evaluate( Context context ) throws JaxenException
{
Object lhsValue = getLHS().evaluate( context );
Object rhsValue = getRHS().evaluate( context );
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:jaxen-xpath,项目名称:jaxen,代码行数:26,代码来源:DefaultRelationalExpr.java

示例8: evaluate

import org.jaxen.Context; //导入方法依赖的package包/类
public Object evaluate(Context context) throws JaxenException
{
    Navigator nav = context.getNavigator();
    Boolean lhsValue = BooleanFunction.evaluate( getLHS().evaluate( context ), nav );

    if ( !lhsValue.booleanValue() )
    {
        return Boolean.FALSE;
    }

    // Short circuits are required in XPath. "The right operand is not 
    // evaluated if the left operand evaluates to false."
    Boolean rhsValue = BooleanFunction.evaluate( getRHS().evaluate( context ), nav );

    if ( !rhsValue.booleanValue() )
    {
        return Boolean.FALSE;
    }

    return Boolean.TRUE;
}
 
开发者ID:jaxen-xpath,项目名称:jaxen,代码行数:22,代码来源:DefaultAndExpr.java

示例9: matches

import org.jaxen.Context; //导入方法依赖的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

示例10: evaluate

import org.jaxen.Context; //导入方法依赖的package包/类
public static List evaluate (Context context, Object arg)
    throws FunctionCallException
{
    List contextNodes = context.getNodeSet();
    
    if (contextNodes.size() == 0)
        return Collections.EMPTY_LIST;
  
    Navigator nav = context.getNavigator();

    String xpathString;
    if ( arg instanceof String )
        xpathString = (String)arg;
    else
        xpathString = StringFunction.evaluate(arg, nav);

    try {
        XPath xpath = nav.parseXPath(xpathString);
        ContextSupport support = context.getContextSupport();
        xpath.setVariableContext( support.getVariableContext() );
        xpath.setFunctionContext( support.getFunctionContext() );
        xpath.setNamespaceContext( support.getNamespaceContext() );
        return xpath.selectNodes( context.duplicate() );
    }
    catch ( org.jaxen.saxpath.SAXPathException e ) {
        throw new FunctionCallException(e.toString());
    }
}
 
开发者ID:jaxen-xpath,项目名称:jaxen,代码行数:29,代码来源:EvaluateFunction.java

示例11: matches

import org.jaxen.Context; //导入方法依赖的package包/类
/** @return true if the pattern matches the given node
      */
    public boolean matches( Object node, Context context ) throws JaxenException
    {
        Navigator navigator = context.getNavigator();

/*        
        if ( isAbsolute() )
        {
            node = navigator.getDocumentNode( node );
        }
*/
        if (! nodeTest.matches(node, context) )
        {
            return false;
        }
        
        if (parentPattern != null) 
        {
            Object parent = navigator.getParentNode( node );
            if ( parent == null ) 
            {
                return false;
            }
            if ( ! parentPattern.matches( parent, context ) ) 
            {
                return false;
            }
        }

        if (ancestorPattern != null) {
            Object ancestor = navigator.getParentNode( node );
            while (true)
            {
                if ( ancestorPattern.matches( ancestor, context ) )
                {
                    break;
                }
                if ( ancestor == null )
                {
                    return false;
                }
                if ( navigator.isDocument( ancestor ) )
                {
                    return false;
                }
                ancestor = navigator.getParentNode( ancestor );
            }
        }
        
        if (filters != null) 
        {
            List list = new SingletonList(node);

            context.setNodeSet( list );
            
            // XXXX: filters aren't positional, so should we clone context?

            boolean answer = true;

            for (Iterator iter = filters.iterator(); iter.hasNext(); ) 
            {
                FilterExpr filter = (FilterExpr) iter.next();

                if ( ! filter.asBoolean( context ) )
                {
                    answer = false;
                    break;
                }
            }
            // restore context

            context.setNodeSet( list );

            return answer;
        }
        return true;
    }
 
开发者ID:jaxen-xpath,项目名称:jaxen,代码行数:79,代码来源:LocationPathPattern.java

示例12: call

import org.jaxen.Context; //导入方法依赖的package包/类
/** Returns a substring of an XPath string-value by character index.
 *
 * @param context the context at the point in the
 *         expression when the function is called
 * @param args a list that contains two or three items
 * 
 * @return a <code>String</code> containing the specifed character subsequence of 
 *     the original string or the string-value of the context node
 * 
 * @throws FunctionCallException if <code>args</code> has more than three
 *     or less than two items
 */
public Object call(Context context,
                   List args) throws FunctionCallException
{
    final int argc = args.size();
    if (argc < 2 || argc > 3){
        throw new FunctionCallException( "substring() requires two or three arguments." );
    }

    final Navigator nav = context.getNavigator();

    final String str = StringFunction.evaluate(args.get(0), nav );
    // The spec doesn't really address this case
    if (str == null) {
        return "";
    }

    final int stringLength = (StringLengthFunction.evaluate(args.get(0), nav )).intValue();

    if (stringLength == 0) {
        return "";
    }

    Double d1 = NumberFunction.evaluate(args.get(1), nav);

    if (d1.isNaN()){
        return "";
    }
    // Round the value and subtract 1 as Java strings are zero based
    int start = RoundFunction.evaluate(d1, nav).intValue() - 1;

    int substringLength = stringLength;
    if (argc == 3){
        Double d2 = NumberFunction.evaluate(args.get(2), nav);

        if (!d2.isNaN()){
            substringLength = RoundFunction.evaluate(d2, nav ).intValue();
        }
        else {
            substringLength = 0;
        }
    }
    
    if (substringLength < 0) return "";

    int end = start + substringLength;
    if (argc == 2) end = stringLength;
        
    // negative start is treated as 0
    if ( start < 0){
        start = 0;
    }
    else if (start > stringLength){
        return "";
    }

    if (end > stringLength){
        end = stringLength;
    }
    else if (end < start) return "";
    
    if (stringLength == str.length()) {
        // easy case; no surrogate pairs
        return str.substring(start, end);
    }
    else {
        return unicodeSubstring(str, start, end);
    }
    
}
 
开发者ID:jaxen-xpath,项目名称:jaxen,代码行数:82,代码来源:SubstringFunction.java


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