本文整理汇总了Java中org.apache.commons.jexl2.parser.Parser类的典型用法代码示例。如果您正苦于以下问题:Java Parser类的具体用法?Java Parser怎么用?Java Parser使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Parser类属于org.apache.commons.jexl2.parser包,在下文中一共展示了Parser类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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;
}
示例2: 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);
}
示例3: 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);
}
}
}
示例4: RootNode
import org.apache.commons.jexl2.parser.Parser; //导入依赖的package包/类
public RootNode(Parser p, int id) {
super(p, id);
}