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


Java Context类代码示例

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


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

示例1: call

import org.jaxen.Context; //导入依赖的package包/类
@Override
public Object call(Context context, List args) throws FunctionCallException {
    try {
        String clazzName = (String) (args.get(0));
        String methodName = (String) (args.get(1));
        LOGGER.info("XEditor extension function calling {} {}", clazzName, methodName);

        Class[] argTypes = new Class[args.size() - 2];
        Object[] params = new Object[args.size() - 2];
        for (int i = 0; i < argTypes.length; i++) {
            argTypes[i] = args.get(i + 2).getClass();
            params[i] = args.get(i + 2);
        }

        Class clazz = ClassUtils.getClass(clazzName);
        Method method = MethodUtils.getMatchingAccessibleMethod(clazz, methodName, argTypes);
        return method.invoke(null, params);
    } catch (Exception ex) {
        LOGGER.warn("Exception in call to external java method", ex);
        return ex.getMessage();
    }
}
 
开发者ID:MyCoRe-Org,项目名称:mycore,代码行数:23,代码来源:MCRFunctionCallJava.java

示例2: call

import org.jaxen.Context; //导入依赖的package包/类
@Nullable
@SuppressWarnings({ "RawUseOfParameterizedType" })
public Object call(Context context, List list) throws FunctionCallException {
    final Object arg;
    if (list.size() == 0) {
        arg = context.getNodeSet().get(0);
    } else {
        final Object o = list.get(0);
        arg = o instanceof List ? ((List)o).get(0) : o;
    }
    if (!(arg instanceof PsiElement)) {
        throw new FunctionCallException("NodeSet expected");
    }
    final PsiFile psiFile = ((PsiElement)arg).getContainingFile();

    assert psiFile != null;
    return extractInfo(psiFile);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:19,代码来源:BasicFileInfoFunction.java

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

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

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

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

示例7: call

import org.jaxen.Context; //导入依赖的package包/类
/**
 * <p>
 * Returns the number of Unicode characters in the string-value of the argument.
 * </p>
 * 
 * @param context the context at the point in the
 *         expression when the function is called
 * @param args a list containing the item whose string-value is to be counted.
 *     If empty, the length of the context node's string-value is returned.
 * 
 * @return a <code>Double</code> giving the number of Unicode characters
 * 
 * @throws FunctionCallException if args has more than one item
 */
public Object call(Context context,
                   List args) throws FunctionCallException
{
    if (args.size() == 0)
    {
        return evaluate( context.getNodeSet(),
                         context.getNavigator() );
    } 
    else if (args.size() == 1)
    {
        return evaluate( args.get(0),
                         context.getNavigator() );
    }

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

示例8: call

import org.jaxen.Context; //导入依赖的package包/类
/**
 * Returns the local-name of the specified node or the context node if 
 * no arguments are provided.
 * 
 * @param context the context at the point in the
 *         expression where the function is called
 * @param args a <code>List</code> containing zero or one items
 * 
 * @return a <code>String</code> containing the local-name
 * 
 * @throws FunctionCallException if <code>args</code> has more than one item
 */
public Object call(Context context,
                   List args) throws FunctionCallException
{
    if ( args.size() == 0 )
    {
        return evaluate( context.getNodeSet(),
                         context.getNavigator() ); 
    }

    if ( args.size() == 1 )
    {
        return evaluate( args,
                         context.getNavigator() );
    }

    throw new FunctionCallException( "local-name() requires zero or one argument." );
}
 
开发者ID:jaxen-xpath,项目名称:jaxen,代码行数:30,代码来源:LocalNameFunction.java

示例9: call

import org.jaxen.Context; //导入依赖的package包/类
/**
 * <p>
 * Determines whether or not the context node is written in the language specified
 * by the XPath string-value of <code>args.get(0)</code>,
 * as determined by the nearest <code>xml:lang</code> attribute in scope. 
 * </p>
 * 
 * @param context the context in which to evaluate the <code>lang()</code> function
 * @param args the arguments to the lang function
 * @return a <code>Boolean</code> indicating whether the context node is written in
 *     the specified language
 * @throws FunctionCallException if <code>args</code> does not have length one
 * 
 */
public Object call(Context context,
                   List args) throws FunctionCallException
{
    if (args.size() != 1) {
        throw new FunctionCallException("lang() requires exactly one argument.");   
    }
    
    Object arg = args.get(0);
        
    try {
        return evaluate(context.getNodeSet(), arg, context.getNavigator() );
    }
    catch(UnsupportedAxisException e) {
        throw new FunctionCallException("Can't evaluate lang()", 
                                             e);
    }
   
}
 
开发者ID:jaxen-xpath,项目名称:jaxen,代码行数:33,代码来源:LangFunction.java

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

示例11: call

import org.jaxen.Context; //导入依赖的package包/类
/**
 * Returns the namespace URI of the specified node or the namespace URI of the context node if 
 * no arguments are provided.
 * 
 * @param context the context at the point in the
 *         expression where the function is called
 * @param args a <code>List</code> containing zero or one items
 * 
 * @return a <code>String</code> containing the namespace URI
 * 
 * @throws FunctionCallException if <code>args</code> has more than one item
 */
public Object call(Context context,
                   List args) throws FunctionCallException
{
    if (args.size() == 0)
    {
        return evaluate( context.getNodeSet(),
                         context.getNavigator() );
    }

    if ( args.size() == 1 )
    {
        return evaluate( args,
                         context.getNavigator() );
    }

    throw new FunctionCallException( "namespace-uri() requires zero or one argument." );
}
 
开发者ID:jaxen-xpath,项目名称:jaxen,代码行数:30,代码来源:NamespaceUriFunction.java

示例12: call

import org.jaxen.Context; //导入依赖的package包/类
/** 
 * Returns the string-value of the first item in <code>args</code>
 * after removing all leading and trailing white space, and 
 * replacing each other sequence of whitespace by a single space.
 * Whitespace consists of the characters space (0x32), carriage return (0x0D),
 * linefeed (0x0A), and tab (0x09).
 *
 * @param context the context at the point in the
 *         expression when the function is called
 * @param args a list that contains exactly one item
 * 
 * @return a normalized <code>String</code>
 * 
 * @throws FunctionCallException if <code>args</code> does not have length one
 */
public Object call(Context context,
                   List args) throws FunctionCallException
{
    
    if (args.size() == 0) {
        return evaluate( context.getNodeSet(),
                         context.getNavigator() );
    }
    else if (args.size() == 1)
    {
        return evaluate( args.get(0),
                         context.getNavigator() );
    }

    throw new FunctionCallException( "normalize-space() cannot have more than one argument" );
}
 
开发者ID:jaxen-xpath,项目名称:jaxen,代码行数:32,代码来源:NormalizeSpaceFunction.java

示例13: call

import org.jaxen.Context; //导入依赖的package包/类
/**
 * Returns the name of the specified node or the name of the context node if 
 * no arguments are provided.
 * 
 * @param context the context at the point in the
 *         expression where the function is called
 * @param args a <code>List</code> containing zero or one items
 * 
 * @return a <code>String</code> containing the name
 * 
 * @throws FunctionCallException if <code>args</code> has more than one item
 */
public Object call(Context context,
                   List args) throws FunctionCallException
{
    if ( args.size() == 0 )
    {
        return evaluate( context.getNodeSet(),
                         context.getNavigator() );
    }

    if ( args.size() == 1 )
    {
        return evaluate( args,
                         context.getNavigator() );
    }

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

示例14: call

import org.jaxen.Context; //导入依赖的package包/类
/**
 * Returns the string-value of <code>args.get(0)</code> 
 * or of the context node if <code>args</code> is empty.
 * 
 * @param context the context at the point in the
 *         expression where the function is called
 * @param args list with zero or one element
 * 
 * @return a <code>String</code> 
 * 
 * @throws FunctionCallException if <code>args</code> has more than one item
 */    
public Object call(Context context,
                   List args) throws FunctionCallException
{
    int size = args.size();

    if ( size == 0 )
    {
        return evaluate( context.getNodeSet(),
                         context.getNavigator() );
    }
    else if ( size == 1 )
    {
        return evaluate( args.get(0),
                         context.getNavigator() );
    }

    throw new FunctionCallException( "string() takes at most argument." );
}
 
开发者ID:jaxen-xpath,项目名称:jaxen,代码行数:31,代码来源:StringFunction.java

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


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