org.apache.xpath.compiler.FunctionTable Java Examples

The following examples show how to use org.apache.xpath.compiler.FunctionTable. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: WalkerFactory.java    From j2objc with Apache License 2.0 5 votes vote down vote up
static boolean functionProximateOrContainsProximate(Compiler compiler, 
                                                    int opPos)
{
  int endFunc = opPos + compiler.getOp(opPos + 1) - 1;
  opPos = OpMap.getFirstChildPos(opPos);
  int funcID = compiler.getOp(opPos);
  //  System.out.println("funcID: "+funcID);
  //  System.out.println("opPos: "+opPos);
  //  System.out.println("endFunc: "+endFunc);
  switch(funcID)
  {
    case FunctionTable.FUNC_LAST:
    case FunctionTable.FUNC_POSITION:
      return true;
    default:
      opPos++;
      int i = 0;
      for (int p = opPos; p < endFunc; p = compiler.getNextOpPos(p), i++)
      {
        int innerExprOpPos = p+2;
        int argOp = compiler.getOp(innerExprOpPos);
        boolean prox = isProximateInnerExpr(compiler, innerExprOpPos);
        if(prox)
          return true;
      }

  }
  return false;
}
 
Example #2
Source File: XPath.java    From j2objc with Apache License 2.0 5 votes vote down vote up
/**
 * Construct an XPath object.  
 *
 * (Needs review -sc) This method initializes an XPathParser/
 * Compiler and compiles the expression.
 * @param exprString The XPath expression.
 * @param locator The location of the expression, may be null.
 * @param prefixResolver A prefix resolver to use to resolve prefixes to 
 *                       namespace URIs.
 * @param type one of {@link #SELECT} or {@link #MATCH}.
 * @param errorListener The error listener, or null if default should be used.
 *
 * @throws javax.xml.transform.TransformerException if syntax or other error.
 */
public XPath(
        String exprString, SourceLocator locator, 
        PrefixResolver prefixResolver, int type,
        ErrorListener errorListener, FunctionTable aTable)
          throws javax.xml.transform.TransformerException
{ 
  m_funcTable = aTable;     
  if(null == errorListener)
    errorListener = new org.apache.xml.utils.DefaultErrorHandler();
  
  m_patternString = exprString;

  XPathParser parser = new XPathParser(errorListener, locator);
  Compiler compiler = new Compiler(errorListener, locator, m_funcTable);

  if (SELECT == type)
    parser.initXPath(compiler, exprString, prefixResolver);
  else if (MATCH == type)
    parser.initMatchPattern(compiler, exprString, prefixResolver);
  else
    throw new RuntimeException(XSLMessages.createXPATHMessage(
          XPATHErrorResources.ER_CANNOT_DEAL_XPATH_TYPE, 
          new Object[]{Integer.toString(type)})); 
          //"Can not deal with XPath type: " + type);

  // System.out.println("----------------");
  Expression expr = compiler.compile(0);

  // System.out.println("expr: "+expr);
  this.setExpression(expr);
  
  if((null != locator) && locator instanceof ExpressionNode)
  {
  	expr.exprSetParent((ExpressionNode)locator);
  }

}
 
Example #3
Source File: XPathAdapter.java    From htmlunit with Apache License 2.0 4 votes vote down vote up
/**
 * Initiates the function table.
 */
private void initFunctionTable() {
    funcTable_ = new FunctionTable();
    funcTable_.installFunction("lower-case", LowerCaseFunction.class);
}
 
Example #4
Source File: XPathAdapter.java    From HtmlUnit-Android with Apache License 2.0 4 votes vote down vote up
/**
 * Initiates the function table.
 */
private void initFunctionTable() {
    funcTable_ = new FunctionTable();
    funcTable_.installFunction("lower-case", LowerCaseFunction.class);
}
 
Example #5
Source File: XPath.java    From j2objc with Apache License 2.0 4 votes vote down vote up
/**
 * initial the function table
 */
private void initFunctionTable(){
	      m_funcTable = new FunctionTable();
}
 
Example #6
Source File: FuncExtFunctionAvailable.java    From j2objc with Apache License 2.0 2 votes vote down vote up
/**
 * The function table is an instance field. In order to access this instance 
 * field during evaluation, this method is called at compilation time to
 * insert function table information for later usage. It should only be used
 * during compiling of XPath expressions.
 * @param aTable an instance of the function table
 */
public void setFunctionTable(FunctionTable aTable){
        m_functionTable = aTable;
}