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


Java Parser.parse方法代码示例

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


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

示例1: TreeBuilder

import org.apache.commons.jexl2.parser.Parser; //导入方法依赖的package包/类
public TreeBuilder(String query) throws ParseException {
  Parser p = new Parser(new StringReader(";"));
  ASTJexlScript script = p.parse(new StringReader(query), null);
  // Check to see if the child node is an AND or OR. If not, then
  // there must be just a single value in the query expression
  rootNode = new TreeNode();
  rootNode.setType(RootNode.class);
  currentNode = rootNode;
  EvaluationContext ctx = new EvaluationContext();
  script.childrenAccept(this, ctx);
}
 
开发者ID:apache,项目名称:accumulo-wikisearch,代码行数:12,代码来源:TreeBuilder.java

示例2: execute

import org.apache.commons.jexl2.parser.Parser; //导入方法依赖的package包/类
public void execute(String query) throws ParseException {
  reset();
  query = query.replaceAll("\\s+AND\\s+", " and ");
  query = query.replaceAll("\\s+OR\\s+", " or ");
  query = query.replaceAll("\\s+NOT\\s+", " not ");
  
  // Check to see if its in the cache
  Hash hash = MurmurHash.getInstance();
  this.hashVal = hash.hash(query.getBytes(), SEED);
  CacheEntry entry = null;
  synchronized (cache) {
    entry = (CacheEntry) cache.get(hashVal);
  }
  if (entry != null) {
    this.negatedTerms = entry.getNegatedTerms();
    this.andTerms = entry.getAndTerms();
    this.orTerms = entry.getOrTerms();
    this.literals = entry.getLiterals();
    this.terms = entry.getTerms();
    this.rootNode = entry.getRootNode();
    this.tree = entry.getTree();
  } else {
    Parser p = new Parser(new StringReader(";"));
    rootNode = p.parse(new StringReader(query), null);
    rootNode.childrenAccept(this, null);
    TreeBuilder builder = new TreeBuilder(rootNode);
    tree = builder.getRootNode();
    entry = new CacheEntry(this.negatedTerms, this.andTerms, this.orTerms, this.literals, this.terms, rootNode, tree);
    synchronized (cache) {
      cache.put(hashVal, entry);
    }
  }
  
}
 
开发者ID:apache,项目名称:accumulo-wikisearch,代码行数:35,代码来源:QueryParser.java

示例3: getValueIndicatingImplicitCollection

import org.apache.commons.jexl2.parser.Parser; //导入方法依赖的package包/类
/**
 * <p>Determines whether this represents implicit Collections access, which
 * would result in an implicit collections processing loop.  If so, then it
 * returns the substring representing the <code>Collection</code>, else it
 * returns <code>null</code>.</p>
 * <p>This method uses JEXL internal parser logic.</p>
 *
 * @param beans A <code>Map</code> mapping strings to objects.
 * @param noImplProcCollNames Don't return a collection expression whose
 *    collection property name is found in this <code>List</code>.
 * @return The string representing the <code>Collection</code>, or
 *    <code>null</code> if it doesn't represent implicit Collections access.
 */
public String getValueIndicatingImplicitCollection(Map<String, Object> beans,
   List<String> noImplProcCollNames)
{
   String expression = myExpression;
   // Try cache first.
   String cachedResult = MAP_EXPRESSION_TO_COLL_NAMES.get(expression);
   if (cachedResult != null)
   {
      return cachedResult;
   }

   Parser parser = new Parser(new StringReader(";"));
   try
   {
      SimpleNode tree = parser.parse(new StringReader(expression), null);
      List<ASTReference> references = findReferences(tree);
      for (ASTReference node : references)
      {
         if (DEBUG)
            System.err.println("  Reference...");
         String collectionName = findCollectionName(node, beans, noImplProcCollNames);
         if (collectionName != null)
         {
            // Cache this result.
            MAP_EXPRESSION_TO_COLL_NAMES.put(expression, collectionName);
            return collectionName;
         }
      }
   }
   catch (org.apache.commons.jexl2.parser.ParseException e)
   {
      throw new ParseException("JEXL ParseException caught: " + e.getMessage(), e);
   }
   // If we get here, then there is no Collection name reference.
   MAP_EXPRESSION_TO_COLL_NAMES.put(expression, "");
   return null;
}
 
开发者ID:rmage,项目名称:gnvc-ims,代码行数:51,代码来源:Expression.java


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