本文整理汇总了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();
}
}
示例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);
}
示例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;
}
示例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;
}
示例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;
}
示例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." );
}
示例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." );
}
示例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." );
}
示例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);
}
}
示例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;
}
示例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." );
}
示例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" );
}
示例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." );
}
示例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." );
}
示例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." );
}