當前位置: 首頁>>代碼示例>>Java>>正文


Java Expression類代碼示例

本文整理匯總了Java中org.apache.xpath.Expression的典型用法代碼示例。如果您正苦於以下問題:Java Expression類的具體用法?Java Expression怎麽用?Java Expression使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Expression類屬於org.apache.xpath包,在下文中一共展示了Expression類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getPriorityOrScore

import org.apache.xpath.Expression; //導入依賴的package包/類
/**
 * Given a match pattern and template association, return the 
 * score of that match.  This score or priority can always be 
 * statically calculated.
 *
 * @param matchPat The match pattern to template association.
 *
 * @return {@link org.apache.xpath.patterns.NodeTest#SCORE_NODETEST}, 
 *         {@link org.apache.xpath.patterns.NodeTest#SCORE_NONE}, 
 *         {@link org.apache.xpath.patterns.NodeTest#SCORE_NSWILD}, 
 *         {@link org.apache.xpath.patterns.NodeTest#SCORE_QNAME}, or
 *         {@link org.apache.xpath.patterns.NodeTest#SCORE_OTHER}, or 
 *         the value defined by the priority attribute of the template.
 *
 */
private double getPriorityOrScore(TemplateSubPatternAssociation matchPat)
{

  double priority = matchPat.getTemplate().getPriority();

  if (priority == XPath.MATCH_SCORE_NONE)
  {
    Expression ex = matchPat.getStepPattern();

    if (ex instanceof NodeTest)
    {
      return ((NodeTest) ex).getDefaultScore();
    }
  }

  return priority;
}
 
開發者ID:keplersj,項目名稱:In-the-Box-Fork,代碼行數:33,代碼來源:TemplateList.java

示例2: getAnalysisBits

import org.apache.xpath.Expression; //導入依賴的package包/類
/** 
 * Get the analysis bits for this walker, as defined in the WalkerFactory.
 * @return One of WalkerFactory#BIT_DESCENDANT, etc.
 */
public int getAnalysisBits()
{
	org.apache.xalan.templates.ElemVariable vvar = getElemVariable();
	if(null != vvar)
	{
		XPath xpath = vvar.getSelect();
		if(null != xpath)
		{
 		Expression expr = xpath.getExpression();
 		if(null != expr && expr instanceof PathComponent)
 		{
 			return ((PathComponent)expr).getAnalysisBits();
 		}
		}
	}
  return WalkerFactory.BIT_FILTER;
}
 
開發者ID:keplersj,項目名稱:In-the-Box-Fork,代碼行數:22,代碼來源:Variable.java

示例3: deepEquals

import org.apache.xpath.Expression; //導入依賴的package包/類
/**
 * @see Expression#deepEquals(Expression)
 */
public boolean deepEquals(Expression expr)
{
	if(!isSameClass(expr))
		return false;
		
	if(!m_qname.equals(((Variable)expr).m_qname))
		return false;
		
	// We have to make sure that the qname really references 
	// the same variable element.
  if(getElemVariable() != ((Variable)expr).getElemVariable())
  	return false;
		
	return true;
}
 
開發者ID:keplersj,項目名稱:In-the-Box-Fork,代碼行數:19,代碼來源:Variable.java

示例4: deepEquals

import org.apache.xpath.Expression; //導入依賴的package包/類
/**
 * @see Expression#deepEquals(Expression)
 */
public boolean deepEquals(Expression expr)
{
  if (!super.deepEquals(expr))
            return false;

  AxesWalker walker1 = m_firstWalker;
  AxesWalker walker2 = ((WalkingIterator)expr).m_firstWalker;
  while ((null != walker1) && (null != walker2))
  {
    if(!walker1.deepEquals(walker2))
    	return false;
    walker1 = walker1.getNextWalker();
    walker2 = walker2.getNextWalker();
  }
  
  if((null != walker1) || (null != walker2))
  	return false;

  return true;
}
 
開發者ID:keplersj,項目名稱:In-the-Box-Fork,代碼行數:24,代碼來源:WalkingIterator.java

示例5: setPredicateCount

import org.apache.xpath.Expression; //導入依賴的package包/類
/**
 * Set the number of predicates that this walker has.  This does more 
 * that one would think, as it creates a new predicate array of the 
 * size of the count argument, and copies count predicates into the new 
 * one from the old, and then reassigns the predicates value.  All this 
 * to keep from having to have a predicate count value.
 *
 * @param count The number of predicates, which must be equal or less 
 *               than the existing count.
 */
public void setPredicateCount(int count)
{
  if(count > 0)
  {
    Expression[] newPredicates = new Expression[count];
    for (int i = 0; i < count; i++) 
    {
      newPredicates[i] = m_predicates[i];
    }
    m_predicates = newPredicates;
  }
  else
    m_predicates = null;
  
}
 
開發者ID:keplersj,項目名稱:In-the-Box-Fork,代碼行數:26,代碼來源:PredicatedNodeTest.java

示例6: deepEquals

import org.apache.xpath.Expression; //導入依賴的package包/類
/**
 * @see Expression#deepEquals(Expression)
 */
public boolean deepEquals(Expression expr)
{
  if (!super.deepEquals(expr))
        return false;

  PredicatedNodeTest pnt = (PredicatedNodeTest) expr;
  if (null != m_predicates)
  {

    int n = m_predicates.length;
    if ((null == pnt.m_predicates) || (pnt.m_predicates.length != n))
          return false;
    for (int i = 0; i < n; i++)
    {
      if (!m_predicates[i].deepEquals(pnt.m_predicates[i]))
      	return false; 
    }
  }
  else if (null != pnt.m_predicates)
          return false; 
          
  return true; 
}
 
開發者ID:keplersj,項目名稱:In-the-Box-Fork,代碼行數:27,代碼來源:PredicatedNodeTest.java

示例7: deepEquals

import org.apache.xpath.Expression; //導入依賴的package包/類
/**
 * @see Expression#deepEquals(Expression)
 */
public boolean deepEquals(Expression expr)
{
	if(!super.deepEquals(expr))
		return false;
		
	if(null != m_arg0)
	{
		if(null == ((FunctionOneArg)expr).m_arg0)
			return false;
			
		if(!m_arg0.deepEquals(((FunctionOneArg)expr).m_arg0))
			return false;
	}
	else if(null != ((FunctionOneArg)expr).m_arg0)
		return false;

	return true;
}
 
開發者ID:keplersj,項目名稱:In-the-Box-Fork,代碼行數:22,代碼來源:FunctionOneArg.java

示例8: setExpression

import org.apache.xpath.Expression; //導入依賴的package包/類
/**
 * @see ExpressionOwner#setExpression(Expression)
 */
public void setExpression(Expression exp)
{
	
	if(!(exp instanceof LocPathIterator))
	{
		// Yuck.  Need FilterExprIter.  Or make it so m_exprs can be just 
		// plain expressions?
		WalkingIterator wi = new WalkingIterator(getPrefixResolver());
		FilterExprWalker few = new FilterExprWalker(wi);
		wi.setFirstWalker(few);
		few.setInnerExpression(exp);
		wi.exprSetParent(UnionPathIterator.this);
		few.exprSetParent(wi);
		exp.exprSetParent(few);
		exp = wi;
	}
	else
		exp.exprSetParent(UnionPathIterator.this);
	m_exprs[m_index] = (LocPathIterator)exp;
}
 
開發者ID:keplersj,項目名稱:In-the-Box-Fork,代碼行數:24,代碼來源:UnionPathIterator.java

示例9: setArg

import org.apache.xpath.Expression; //導入依賴的package包/類
/**
 * Set an argument expression for a function.  This method is called by the 
 * XPath compiler.
 *
 * @param arg non-null expression that represents the argument.
 * @param argNum The argument number index.
 *
 * @throws WrongNumberArgsException If the argNum parameter is greater than 1.
 */
public void setArg(Expression arg, int argNum)
        throws WrongNumberArgsException
{

  // System.out.println("argNum: "+argNum);
  if (argNum == 0)
    super.setArg(arg, argNum);
  else if (1 == argNum)
  {
    m_arg1 = arg;
    arg.exprSetParent(this);
  }
  else
  reportWrongNumberArgs();
}
 
開發者ID:keplersj,項目名稱:In-the-Box-Fork,代碼行數:25,代碼來源:Function2Args.java

示例10: getCompiledPredicates

import org.apache.xpath.Expression; //導入依賴的package包/類
/**
 * Compile a zero or more predicates for a given match pattern.
 * 
 * @param opPos The position of the first predicate the m_opMap array.
 *
 * @return reference to array of {@link org.apache.xpath.Expression} instances.
 *
 * @throws TransformerException if a error occurs creating the Expression.
 */
public Expression[] getCompiledPredicates(int opPos)
        throws TransformerException
{

  int count = countPredicates(opPos);

  if (count > 0)
  {
    Expression[] predicates = new Expression[count];

    compilePredicates(opPos, predicates);

    return predicates;
  }

  return null;
}
 
開發者ID:keplersj,項目名稱:In-the-Box-Fork,代碼行數:27,代碼來源:Compiler.java

示例11: execute

import org.apache.xpath.Expression; //導入依賴的package包/類
/**
 * Execute the function.  The function must return
 * a valid object.
 * @param xctxt The current execution context.
 * @return A valid XObject.
 *
 * @throws javax.xml.transform.TransformerException
 */
public XObject execute(XPathContext xctxt)
        throws javax.xml.transform.TransformerException
{
  if (xctxt.isSecureProcessing())
    throw new javax.xml.transform.TransformerException(
      XPATHMessages.createXPATHMessage(
        XPATHErrorResources.ER_EXTENSION_FUNCTION_CANNOT_BE_INVOKED,
        new Object[] {toString()}));
    
  XObject result;
  Vector argVec = new Vector();
  int nArgs = m_argVec.size();

  for (int i = 0; i < nArgs; i++)
  {
    Expression arg = (Expression) m_argVec.elementAt(i);
    
    XObject xobj = arg.execute(xctxt);
    /*
     * Should cache the arguments for func:function
     */
    xobj.allowDetachToRelease(false); 
    argVec.addElement(xobj);
  }
  //dml
  ExtensionsProvider extProvider = (ExtensionsProvider)xctxt.getOwnerObject();
  Object val = extProvider.extFunction(this, argVec);

  if (null != val)
  {
    result = XObject.create(val, xctxt);
  }
  else
  {
    result = new XNull();
  }

  return result;
}
 
開發者ID:keplersj,項目名稱:In-the-Box-Fork,代碼行數:48,代碼來源:FuncExtFunction.java

示例12: visitLocationPath

import org.apache.xpath.Expression; //導入依賴的package包/類
/**
 * Visit a LocationPath.
 * @param owner The owner of the expression, to which the expression can 
 *              be reset if rewriting takes place.
 * @param path The LocationPath object.
 * @return true if the sub expressions should be traversed.
 */
public boolean visitLocationPath(ExpressionOwner owner, LocPathIterator path)
{
	// Don't optimize "." or single step variable paths.
	// Both of these cases could use some further optimization by themselves.
	if(path instanceof SelfIteratorNoPredicate)
	{
		return true;
	}
	else if(path instanceof WalkingIterator)
	{
		WalkingIterator wi = (WalkingIterator)path;
		AxesWalker aw = wi.getFirstWalker();
		if((aw instanceof FilterExprWalker) && (null == aw.getNextWalker()))
		{
			FilterExprWalker few = (FilterExprWalker)aw;
			Expression exp = few.getInnerExpression();
			if(exp instanceof Variable)
				return true;
		}
	}

  if (isAbsolute(path) && (null != m_absPaths))
  {
    if(DEBUG)
      validateNewAddition(m_absPaths, owner, path);
    m_absPaths.addElement(owner);
  }
  else if (m_isSameContext && (null != m_paths))
  {
    if(DEBUG)
      validateNewAddition(m_paths, owner, path);
    m_paths.addElement(owner);
  }

  return true;
}
 
開發者ID:keplersj,項目名稱:In-the-Box-Fork,代碼行數:44,代碼來源:RedundentExprEliminator.java

示例13: exprSetParent

import org.apache.xpath.Expression; //導入依賴的package包/類
/**
 * Set the parent node.
 * For an extension function, we also need to set the parent
 * node for all argument expressions.
 * 
 * @param n The parent node
 */
public void exprSetParent(ExpressionNode n) 
{
	
  super.exprSetParent(n);
    
  int nArgs = m_argVec.size();

  for (int i = 0; i < nArgs; i++)
  {
    Expression arg = (Expression) m_argVec.elementAt(i);

    arg.exprSetParent(n);
  }		
}
 
開發者ID:keplersj,項目名稱:In-the-Box-Fork,代碼行數:22,代碼來源:FuncExtFunction.java

示例14: FunctionPattern

import org.apache.xpath.Expression; //導入依賴的package包/類
/**
 * Construct a FunctionPattern from a
 * {@link org.apache.xpath.functions.Function expression}.
 *
 * NEEDSDOC @param expr
 */
public FunctionPattern(Expression expr, int axis, int predaxis)
{

  super(0, null, null, axis, predaxis);

  m_functionExpr = expr;
}
 
開發者ID:keplersj,項目名稱:In-the-Box-Fork,代碼行數:14,代碼來源:FunctionPattern.java

示例15: compileUnary

import org.apache.xpath.Expression; //導入依賴的package包/類
/**
 * Bottle-neck compilation of a unary operation.
 *
 * @param unary The parent unary operation.
 * @param opPos The position in the op map of the parent operation.
 *
 * @return The unary argument.
 *
 * @throws TransformerException if syntax or other error occurs.
 */
private Expression compileUnary(UnaryOperation unary, int opPos)
        throws TransformerException
{

  int rightPos = getFirstChildPos(opPos);

  unary.setRight(compile(rightPos));

  return unary;
}
 
開發者ID:keplersj,項目名稱:In-the-Box-Fork,代碼行數:21,代碼來源:Compiler.java


注:本文中的org.apache.xpath.Expression類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。