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


Java JexlContext类代码示例

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


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

示例1: matches

import org.apache.commons.jexl2.JexlContext; //导入依赖的package包/类
private boolean matches(Key k) {
  if (log.isDebugEnabled()) {
    log.debug("You've reached the match function!");
  }
  JexlContext ctx = new MapContext();
  // Add the field value from the key to the context
  // String fieldValue = k.getColumnQualifier().toString().split("\0")[0];
  // String fieldValue = getFieldValueFromKey(k);
  keyParser.parse(k);
  String fieldValue = keyParser.getFieldValue();
  
  ctx.set(fNameString, fieldValue);
  Object o = expr.evaluate(ctx);
  if (o instanceof Boolean && (((Boolean) o) == true)) {
    if (log.isDebugEnabled()) {
      log.debug("matches:: fName: " + fName + " , fValue: " + fieldValue + " ,  operator: " + fOperator + " , key: " + k);
    }
    return true;
  } else {
    if (log.isDebugEnabled()) {
      log.debug("NO MATCH:: fName: " + fName + " , fValue: " + fieldValue + " ,  operator: " + fOperator + " , key: " + k);
    }
    return false;
  }
}
 
开发者ID:apache,项目名称:accumulo-wikisearch,代码行数:26,代码来源:FieldIndexIterator.java

示例2: evaluate

import org.apache.commons.jexl2.JexlContext; //导入依赖的package包/类
public String evaluate(final String expression,
        final JexlContext jexlContext) {

    String result = "";

    if (expression != null
            && !expression.isEmpty() && jexlContext != null) {

        try {
            Expression jexlExpression =
                    jexlEngine.createExpression(expression);
            Object evaluated = jexlExpression.evaluate(jexlContext);
            if (evaluated != null) {
                result = evaluated.toString();
            }
        } catch (JexlException e) {
            LOG.error("Invalid jexl expression: " + expression, e);
            result = "";
        }
    } else {
        LOG.debug("Expression not provided or invalid context");
    }

    return result;
}
 
开发者ID:ilgrosso,项目名称:oldSyncopeIdM,代码行数:26,代码来源:JexlUtil.java

示例3: addAttrsToContext

import org.apache.commons.jexl2.JexlContext; //导入依赖的package包/类
public JexlContext addAttrsToContext(
        final Collection<? extends AbstractAttr> attributes,
        final JexlContext jexlContext) {

    JexlContext context = jexlContext == null
            ? new MapContext() : jexlContext;

    for (AbstractAttr attribute : attributes) {
        List<String> attributeValues = attribute.getValuesAsStrings();
        String expressionValue = attributeValues.isEmpty()
                ? "" : attributeValues.get(0);

        LOG.debug("Add attribute {} with value {}",
                new Object[]{attribute.getSchema().getName(),
                    expressionValue});

        context.set(attribute.getSchema().getName(), expressionValue);
    }

    return context;
}
 
开发者ID:ilgrosso,项目名称:oldSyncopeIdM,代码行数:22,代码来源:JexlUtil.java

示例4: addDerAttrsToContext

import org.apache.commons.jexl2.JexlContext; //导入依赖的package包/类
public JexlContext addDerAttrsToContext(
        final Collection<? extends AbstractDerAttr> derAttributes,
        final Collection<? extends AbstractAttr> attributes,
        final JexlContext jexlContext) {

    JexlContext context = jexlContext == null
            ? new MapContext() : jexlContext;

    for (AbstractDerAttr attribute : derAttributes) {
        String expressionValue = attribute.getValue(attributes);
        if (expressionValue == null) {
            expressionValue = "";
        }

        LOG.debug("Add derived attribute {} with value {}",
                new Object[]{attribute.getDerivedSchema().getName(),
                    expressionValue});

        context.set(
                attribute.getDerivedSchema().getName(), expressionValue);
    }

    return context;
}
 
开发者ID:ilgrosso,项目名称:oldSyncopeIdM,代码行数:25,代码来源:JexlUtil.java

示例5: isAboveThreshold

import org.apache.commons.jexl2.JexlContext; //导入依赖的package包/类
/**
 *
 */
@Override
public boolean isAboveThreshold(MetricTimeSeries timeSeries)
{
  Set<Long> timeWindowSet = timeSeries.getTimeWindowSet();
  JexlEngine jexl = new JexlEngine();
  JexlContext context = new MapContext();
  Expression e = jexl.createExpression(this.thresholdExpr);
  for(String metricName : metricNames){
    long sum = 0;
    for (Long timeWindow : timeWindowSet) {
      sum += timeSeries.get(timeWindow, metricName).longValue();
    }
    context.set(metricName, sum);
    if (LOGGER.isDebugEnabled()) {
      LOGGER.debug(metricName + " = " + sum);
    }
  }
  return ((Boolean)e.evaluate(context)).booleanValue();
}
 
开发者ID:Hanmourang,项目名称:Pinot,代码行数:23,代码来源:MultiMetricTotalAggregateBasedRollupFunction.java

示例6: testPower

import org.apache.commons.jexl2.JexlContext; //导入依赖的package包/类
@Test
public void testPower() {
	JexlEngine engine = ExpressionEvalFactory.getInstance();
	Expression expr = engine.createExpression("X^2");

	JexlContext context = new MapContext();
	// Don't need this really
	context.set("A", 20);
	context.set("B", 0);

	ArrayList<Double> actualList = new ArrayList<>();
	for (int i = -20; i < 20; i++) {
		context.set("X", i);
		Double result = (Double) expr.evaluate(context);
		actualList.add(result);
		System.out.println(result + ",");
	}

	Double[] actual = actualList.toArray(new Double[0]);
	Double[] expected = {400.0, 361.0, 324.0, 289.0, 256.0, 225.0, 196.0,
		169.0, 144.0, 121.0, 100.0, 81.0, 64.0, 49.0, 36.0, 25.0, 16.0,
		9.0, 4.0, 1.0, 0.0, 1.0, 4.0, 9.0, 16.0, 25.0, 36.0, 49.0, 64.0,
		81.0, 100.0, 121.0, 144.0, 169.0, 196.0, 225.0, 256.0, 289.0,
		324.0, 361.0};
	Assert.assertArrayEquals("results wrong", expected, actual);
}
 
开发者ID:umeding,项目名称:fuzzer,代码行数:27,代码来源:JEXLTest.java

示例7: getFirstFromSintax

import org.apache.commons.jexl2.JexlContext; //导入依赖的package包/类
public static Mention getFirstFromSintax(Mention s, Expression expression, JexlContext jexlContext) {
    Mention t = null;
    int minDist = Integer.MAX_VALUE;
    Mention prev = s.prev();
    while (prev != null) {
        if (s.type == Dictionaries.MentionType.NOMINAL && Filter.sentenceDistance(s, prev) > Constants.SENTENCE_WINDOW) {break;}
        if (s.type == Dictionaries.MentionType.PRONOMINAL && Filter.sentenceDistance(s, prev) > 3) {break;}
                    
        if (s != prev && _filterAgree(s, prev, expression, jexlContext)) {
            int dist = s.node.minDistance(prev.node);
            if (t == null || dist < minDist) {
                t = prev;
                minDist = dist;
            }
        }
        prev = prev.prev();
    }
    return t;
}
 
开发者ID:aznotins,项目名称:LVCoref,代码行数:20,代码来源:MentionBrowser.java

示例8: _resolveAllFromSameSentence

import org.apache.commons.jexl2.JexlContext; //导入依赖的package包/类
private static void _resolveAllFromSameSentence(Document d, String filter, String comment) {        
    JexlEngine jexl = new JexlEngine();
    jexl.setSilent(JEXL_SILENT);
    jexl.setLenient(JEXL_LENIENT);
    jexl.setDebug(JEXL_DBG);
    Expression expression = jexl.createExpression(filter);
    JexlContext jexlContext = new MapContext();
    jexlContext.set("Filter", Filter.class);
    for (Mention s: d.mentions) {
        jexlContext.set("s", s);
        List<Mention> tt = MentionBrowser.getAllFromSameSentence(s, expression, jexlContext);      
        for (Mention t : tt) {
            _resolve(d, s, t, comment);
        }
        
    }
}
 
开发者ID:aznotins,项目名称:LVCoref,代码行数:18,代码来源:Resolve.java

示例9: matches

import org.apache.commons.jexl2.JexlContext; //导入依赖的package包/类
private boolean matches(Key k) {
    if (log.isDebugEnabled()) {
        log.debug("You've reached the match function!");
    }
    JexlContext ctx = new MapContext();
    // Add the field value from the key to the context
    // String fieldValue = k.getColumnQualifier().toString().split("\0")[0];
    // String fieldValue = getFieldValueFromKey(k);
    keyParser.parse(k);
    String fieldValue = keyParser.getFieldValue();

    ctx.set(fNameString, fieldValue);
    Object o = expr.evaluate(ctx);
    if (o instanceof Boolean && (((Boolean) o) == true)) {
        if (log.isDebugEnabled()) {
            log.debug("matches:: fName: " + fName + " , fValue: " + fieldValue + " ,  operator: " + fOperator + " , key: " + k);
        }
        return true;
    } else {
        if (log.isDebugEnabled()) {
            log.debug("NO MATCH:: fName: " + fName + " , fValue: " + fieldValue + " ,  operator: " + fOperator + " , key: " + k);
        }
        return false;
    }
}
 
开发者ID:calrissian,项目名称:accumulo-recipes,代码行数:26,代码来源:FieldIndexIterator.java

示例10: getValue

import org.apache.commons.jexl2.JexlContext; //导入依赖的package包/类
/**
 * @see http://commons.apache.org/jexl/reference/index.html
 * @param attributes the set of attributes against which evaluate this
 * derived attribute
 * @return the value of this derived attribute
 */
public String getValue(
        final Collection<? extends AbstractAttr> attributes) {

    final ConfigurableApplicationContext context =
            ApplicationContextManager.getApplicationContext();
    final JexlUtil jexlUtil = context.getBean(JexlUtil.class);

    // Prepare context using user attributes
    final JexlContext jexlContext = jexlUtil.addAttrsToContext(
            attributes, null);

    final AbstractAttributable owner = getOwner();
    if (owner instanceof SyncopeUser) {
        jexlContext.set("username",
                ((SyncopeUser) owner).getUsername() != null
                ? ((SyncopeUser) owner).getUsername() : "");
        jexlContext.set("creationDate",
                ((SyncopeUser) owner).getCreationDate() != null
                ? ((SyncopeUser) owner).getDateFormatter().
                format(((SyncopeUser) owner).getCreationDate()) : "");
        jexlContext.set("lastLoginDate",
                ((SyncopeUser) owner).getLastLoginDate() != null
                ? ((SyncopeUser) owner).getDateFormatter().
                format(((SyncopeUser) owner).getLastLoginDate()) : "");
        jexlContext.set("failedLogins",
                ((SyncopeUser) owner).getFailedLogins() != null
                ? ((SyncopeUser) owner).getFailedLogins() : "");
        jexlContext.set("changePwdDate",
                ((SyncopeUser) owner).getChangePwdDate() != null
                ? ((SyncopeUser) owner).getDateFormatter().
                format(((SyncopeUser) owner).getChangePwdDate()) : "");
    }

    // Evaluate expression using the context prepared before
    return jexlUtil.evaluate(
            getDerivedSchema().getExpression(), jexlContext);
}
 
开发者ID:ilgrosso,项目名称:oldSyncopeIdM,代码行数:44,代码来源:AbstractDerAttr.java

示例11: evaluateMandatoryCondition

import org.apache.commons.jexl2.JexlContext; //导入依赖的package包/类
private boolean evaluateMandatoryCondition(
        final String mandatoryCondition,
        final List<? extends AbstractAttr> attributes) {

    JexlContext jexlContext = new MapContext();
    jexlUtil.addAttrsToContext(attributes, jexlContext);

    return Boolean.parseBoolean(
            jexlUtil.evaluate(
            mandatoryCondition, jexlContext));
}
 
开发者ID:ilgrosso,项目名称:oldSyncopeIdM,代码行数:12,代码来源:AbstractAttributableDataBinder.java

示例12: eval

import org.apache.commons.jexl2.JexlContext; //导入依赖的package包/类
public MediaMatrix eval(JexlContext context) throws Exception {
    MediaMatrix mat = null;
    for (CXMQLExpression exp : list) {
        exp.eval(context);
        if (exp.getName().equalsIgnoreCase("QUERY")) {
            mat = (MediaMatrix) context.get("QUERY");
        }
    }
    return mat;
}
 
开发者ID:shuichi,项目名称:MediaMatrix,代码行数:11,代码来源:QueryByClause.java

示例13: eval

import org.apache.commons.jexl2.JexlContext; //导入依赖的package包/类
public Double eval(JexlContext context) throws Exception {
    Double d = null;
    for (CXMQLExpression exp : list) {
        exp.eval(context);
        if (exp.getName().equalsIgnoreCase("SCORE")) {
            d = (Double) context.get("SCORE");
        }
    }
    return d;
}
 
开发者ID:shuichi,项目名称:MediaMatrix,代码行数:11,代码来源:RankByClause.java

示例14: populateJexlContext

import org.apache.commons.jexl2.JexlContext; //导入依赖的package包/类
@Override
protected ReadonlyContext populateJexlContext(String model, StringContext context) {
	JexlContext jexlContext = new MapContext();
	jexlContext.set("text", model);

	return new ReadonlyContext(jexlContext);
}
 
开发者ID:jramoyo,项目名称:flowee,代码行数:8,代码来源:AbstractJexlFilterTest.java

示例15: populateJexlContext

import org.apache.commons.jexl2.JexlContext; //导入依赖的package包/类
@Override
protected ReadonlyContext populateJexlContext(LoginRequest request,
		LoginContext context) {
	JexlContext jexlContext = new MapContext();
	jexlContext.set("request", request);
	return new ReadonlyContext(jexlContext);
}
 
开发者ID:jramoyo,项目名称:flowee,代码行数:8,代码来源:LoginFilter.java


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