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


Java SimpleNumberCoercerFactory.getCoercer方法代码示例

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


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

示例1: getCoercer

import com.espertech.esper.util.SimpleNumberCoercerFactory; //导入方法依赖的package包/类
private static SimpleNumberCoercer getCoercer(Class typeOne, Class typeTwo) throws ExprValidationException {
    // Get the common type such as Bool, String or Double and Long
    Class coercionType;
    boolean mustCoerce;
    try {
        coercionType = JavaClassHelper.getCompareToCoercionType(typeOne, typeTwo);
    } catch (CoercionException ex) {
        throw new ExprValidationException("Implicit conversion from datatype '" +
                typeTwo.getSimpleName() +
                "' to '" +
                typeOne.getSimpleName() +
                "' is not allowed");
    }

    // Check if we need to coerce
    mustCoerce = false;
    if ((coercionType != JavaClassHelper.getBoxedType(typeOne)) ||
            (coercionType != JavaClassHelper.getBoxedType(typeTwo))) {
        if (JavaClassHelper.isNumeric(coercionType)) {
            mustCoerce = true;
        }
    }
    return !mustCoerce ? null : SimpleNumberCoercerFactory.getCoercer(null, coercionType);
}
 
开发者ID:espertechinc,项目名称:esper,代码行数:25,代码来源:SubselectEvalStrategyNRFactory.java

示例2: SubselectEvalStrategyEqualsAny

import com.espertech.esper.util.SimpleNumberCoercerFactory; //导入方法依赖的package包/类
/**
 * Ctor.
 * @param notIn false for =, true for !=
 * @param mustCoerce coercion required
 * @param coercionType type to coerce to
 * @param valueExpr LHS
 * @param selectClauseExpr select clause or null
 * @param filterExpr filter or null
 */
public SubselectEvalStrategyEqualsAny(boolean notIn, boolean mustCoerce, Class coercionType, ExprEvaluator valueExpr, ExprEvaluator selectClauseExpr, ExprEvaluator filterExpr)
{
    isNot = notIn;
    this.mustCoerce = mustCoerce;
    if (mustCoerce)
    {
        coercer = SimpleNumberCoercerFactory.getCoercer(null, coercionType);
    }
    else
    {
        coercer = null;
    }
    this.valueExpr = valueExpr;
    this.filterExpr = filterExpr;
    this.selectClauseExpr = selectClauseExpr;
}
 
开发者ID:mobile-event-processing,项目名称:Asper,代码行数:26,代码来源:SubselectEvalStrategyEqualsAny.java

示例3: SubselectEvalStrategyEqualsIn

import com.espertech.esper.util.SimpleNumberCoercerFactory; //导入方法依赖的package包/类
/**
 * Ctor.
 * @param notIn false for =, true for !=
 * @param mustCoerce coercion required
 * @param coercionType type to coerce to
 * @param valueExpr LHS
 * @param selectClauseExpr select clause or null
 * @param filterExpr filter or null
 */
public SubselectEvalStrategyEqualsIn(boolean notIn, boolean mustCoerce, Class coercionType, ExprEvaluator valueExpr, ExprEvaluator selectClauseExpr, ExprEvaluator filterExpr)
{
    isNotIn = notIn;
    this.mustCoerce = mustCoerce;
    if (mustCoerce)
    {
        coercer = SimpleNumberCoercerFactory.getCoercer(null, coercionType);
    }
    else
    {
        coercer = null;
    }
    this.valueExpr = valueExpr;
    this.filterExpr = filterExpr;
    this.selectClauseExpr = selectClauseExpr;
}
 
开发者ID:mobile-event-processing,项目名称:Asper,代码行数:26,代码来源:SubselectEvalStrategyEqualsIn.java

示例4: SubselectEvalStrategyEqualsAll

import com.espertech.esper.util.SimpleNumberCoercerFactory; //导入方法依赖的package包/类
/**
 * Ctor.
 * @param notIn false for =, true for !=
 * @param mustCoerce coercion required
 * @param coercionType type to coerce to
 * @param valueExpr LHS
 * @param selectClauseExpr select clause or null
 * @param filterExpr filter or null
 */
public SubselectEvalStrategyEqualsAll(boolean notIn, boolean mustCoerce, Class coercionType, ExprEvaluator valueExpr, ExprEvaluator selectClauseExpr, ExprEvaluator filterExpr)
{
    isNot = notIn;
    this.mustCoerce = mustCoerce;
    if (mustCoerce)
    {
        coercer = SimpleNumberCoercerFactory.getCoercer(null, coercionType);
    }
    else
    {
        coercer = null;
    }
    this.valueExpr = valueExpr;
    this.filterExpr = filterExpr;
    this.selectClauseExpr = selectClauseExpr;
}
 
开发者ID:mobile-event-processing,项目名称:Asper,代码行数:26,代码来源:SubselectEvalStrategyEqualsAll.java

示例5: ExprNodeScriptEvalBase

import com.espertech.esper.util.SimpleNumberCoercerFactory; //导入方法依赖的package包/类
public ExprNodeScriptEvalBase(ExprNodeScript parent, String statementName, String[] names, ExprForge[] parameters, Class returnType, EventType eventTypeCollection) {
    this.parent = parent;
    this.statementName = statementName;
    this.names = names;
    this.parameters = parameters;
    this.returnType = returnType;
    this.eventTypeCollection = eventTypeCollection;

    if (JavaClassHelper.isNumeric(returnType)) {
        coercer = SimpleNumberCoercerFactory.getCoercer(Number.class, JavaClassHelper.getBoxedType(returnType));
    } else {
        coercer = null;
    }
}
 
开发者ID:espertechinc,项目名称:esper,代码行数:15,代码来源:ExprNodeScriptEvalBase.java

示例6: PropertyIndexedEventTableSingleCoerceAddFactory

import com.espertech.esper.util.SimpleNumberCoercerFactory; //导入方法依赖的package包/类
/**
 * Ctor.
 *
 * @param streamNum    is the stream number of the indexed stream
 * @param eventType    is the event type of the indexed stream
 * @param propertyName are the property names to get property values
 * @param coercionType are the classes to coerce indexed values to
 */
public PropertyIndexedEventTableSingleCoerceAddFactory(int streamNum, EventType eventType, String propertyName, Class coercionType) {
    super(streamNum, eventType, propertyName, false, null);
    this.coercionType = coercionType;
    if (JavaClassHelper.isNumeric(coercionType)) {
        coercer = SimpleNumberCoercerFactory.getCoercer(null, coercionType);
    } else {
        coercer = null;
    }
}
 
开发者ID:espertechinc,项目名称:esper,代码行数:18,代码来源:PropertyIndexedEventTableSingleCoerceAddFactory.java

示例7: PropertyIndexedEventTableCoerceAddFactory

import com.espertech.esper.util.SimpleNumberCoercerFactory; //导入方法依赖的package包/类
/**
 * Ctor.
 *
 * @param streamNum     is the stream number of the indexed stream
 * @param eventType     is the event type of the indexed stream
 * @param propertyNames are the property names to get property values
 * @param coercionType  are the classes to coerce indexed values to
 */
public PropertyIndexedEventTableCoerceAddFactory(int streamNum, EventType eventType, String[] propertyNames, Class[] coercionType) {
    super(streamNum, eventType, propertyNames, false, null);
    this.coercionType = coercionType;
    coercers = new SimpleNumberCoercer[coercionType.length];
    for (int i = 0; i < coercionType.length; i++) {
        if (JavaClassHelper.isNumeric(coercionType[i])) {
            coercers[i] = SimpleNumberCoercerFactory.getCoercer(null, coercionType[i]);
        }
    }
}
 
开发者ID:espertechinc,项目名称:esper,代码行数:19,代码来源:PropertyIndexedEventTableCoerceAddFactory.java

示例8: getNumberCoercer

import com.espertech.esper.util.SimpleNumberCoercerFactory; //导入方法依赖的package包/类
private static SimpleNumberCoercer getNumberCoercer(Class leftType, Class rightType, String expression) throws ExprValidationException {
    Class numericCoercionType = JavaClassHelper.getBoxedType(leftType);
    if (rightType != leftType) {
        if (JavaClassHelper.isNumeric(rightType)) {
            if (!JavaClassHelper.canCoerce(rightType, leftType)) {
                throwConversionError(rightType, leftType, expression);
            }
            return SimpleNumberCoercerFactory.getCoercer(rightType, numericCoercionType);
        }
    }
    return null;
}
 
开发者ID:espertechinc,项目名称:esper,代码行数:13,代码来源:FilterSpecCompilerMakeParamUtil.java

示例9: testGetValueSet

import com.espertech.esper.util.SimpleNumberCoercerFactory; //导入方法依赖的package包/类
public void testGetValueSet() {
    List<FilterSpecParam> parameters = SupportFilterSpecBuilder.buildList(eventType, new Object[]
            {"intPrimitive", FilterOperator.EQUAL, 2});
    SimpleNumberCoercer numberCoercer = SimpleNumberCoercerFactory.getCoercer(int.class, Double.class);
    parameters.add(new FilterSpecParamEventProp(makeLookupable("doubleBoxed"), FilterOperator.EQUAL, "asName", "doublePrimitive", false, numberCoercer, Double.class, "Test"));
    FilterSpecCompiled filterSpec = new FilterSpecCompiled(eventType, "SupportBean", new List[]{parameters}, null);

    SupportBean eventBean = new SupportBean();
    eventBean.setDoublePrimitive(999.999);
    EventBean theEvent = SupportEventBeanFactory.createObject(eventBean);
    MatchedEventMap matchedEvents = new MatchedEventMapImpl(new MatchedEventMapMeta(new String[]{"asName"}, false));
    matchedEvents.add(0, theEvent);
    FilterValueSet valueSet = filterSpec.getValueSet(matchedEvents, null, null, null, null);

    // Assert the generated filter value container
    assertSame(eventType, valueSet.getEventType());
    assertEquals(2, valueSet.getParameters()[0].length);

    // Assert the first param
    FilterValueSetParam param = valueSet.getParameters()[0][0];
    assertEquals("intPrimitive", param.getLookupable().getExpression());
    assertEquals(FilterOperator.EQUAL, param.getFilterOperator());
    assertEquals(2, param.getFilterForValue());

    // Assert the second param
    param = (FilterValueSetParam) valueSet.getParameters()[0][1];
    assertEquals("doubleBoxed", param.getLookupable().getExpression());
    assertEquals(FilterOperator.EQUAL, param.getFilterOperator());
    assertEquals(999.999, param.getFilterForValue());
}
 
开发者ID:espertechinc,项目名称:esper,代码行数:31,代码来源:TestFilterSpecCompiled.java

示例10: ExprNodeScriptEvalBase

import com.espertech.esper.util.SimpleNumberCoercerFactory; //导入方法依赖的package包/类
public ExprNodeScriptEvalBase(String scriptName, String statementName, String[] names, ExprEvaluator[] parameters, Class returnType) {
    this.scriptName = scriptName;
    this.statementName = statementName;
    this.names = names;
    this.parameters = parameters;
    this.returnType = returnType;

    if (JavaClassHelper.isNumeric(returnType)) {
        coercer = SimpleNumberCoercerFactory.getCoercer(Number.class, JavaClassHelper.getBoxedType(returnType));
    }
    else {
        coercer = null;
    }
}
 
开发者ID:mobile-event-processing,项目名称:Asper,代码行数:15,代码来源:ExprNodeScriptEvalBase.java

示例11: PropertyIndexedEventTableSingleCoerceAddFactory

import com.espertech.esper.util.SimpleNumberCoercerFactory; //导入方法依赖的package包/类
/**
 * Ctor.
 * @param streamNum is the stream number of the indexed stream
 * @param eventType is the event type of the indexed stream
 * @param propertyName are the property names to get property values
 * @param coercionType are the classes to coerce indexed values to
 */
public PropertyIndexedEventTableSingleCoerceAddFactory(int streamNum, EventType eventType, String propertyName, Class coercionType)
{
    super(streamNum, eventType, propertyName, false, null);
    this.coercionType = coercionType;
    if (JavaClassHelper.isNumeric(coercionType)) {
        coercer = SimpleNumberCoercerFactory.getCoercer(null, coercionType);
    }
    else {
        coercer = null;
    }
}
 
开发者ID:mobile-event-processing,项目名称:Asper,代码行数:19,代码来源:PropertyIndexedEventTableSingleCoerceAddFactory.java

示例12: PropertyIndexedEventTableCoerceAddFactory

import com.espertech.esper.util.SimpleNumberCoercerFactory; //导入方法依赖的package包/类
/**
 * Ctor.
 * @param streamNum is the stream number of the indexed stream
 * @param eventType is the event type of the indexed stream
 * @param propertyNames are the property names to get property values
 * @param coercionType are the classes to coerce indexed values to
 */
public PropertyIndexedEventTableCoerceAddFactory(int streamNum, EventType eventType, String[] propertyNames, Class[] coercionType)
{
    super(streamNum, eventType, propertyNames, false, null);
    this.coercionType = coercionType;
    coercers = new SimpleNumberCoercer[coercionType.length];
    for (int i = 0; i < coercionType.length; i++)
    {
        if (JavaClassHelper.isNumeric(coercionType[i])) {
            coercers[i] = SimpleNumberCoercerFactory.getCoercer(null, coercionType[i]);
        }
    }
}
 
开发者ID:mobile-event-processing,项目名称:Asper,代码行数:20,代码来源:PropertyIndexedEventTableCoerceAddFactory.java

示例13: validateCaseTwo

import com.espertech.esper.util.SimpleNumberCoercerFactory; //导入方法依赖的package包/类
private void validateCaseTwo() throws ExprValidationException
{
    // validate we can compare result types
    List<Class> comparedTypes = new LinkedList<Class>();
    comparedTypes.add(optionalCompareExprNode.getType());
    for (UniformPair<ExprEvaluator> pair : whenThenNodeList)
    {
        comparedTypes.add(pair.getFirst().getType());
    }

    // Determine common denominator type
    try {
        Class coercionType = JavaClassHelper.getCommonCoercionType(comparedTypes.toArray(new Class[comparedTypes.size()]));

        // Determine if we need to coerce numbers when one type doesn't match any other type
        if (JavaClassHelper.isNumeric(coercionType))
        {
            mustCoerce = false;
            for (Class comparedType : comparedTypes)
            {
                if (comparedType != coercionType)
                {
                    mustCoerce = true;
                }
            }
            if (mustCoerce)
            {
                coercer = SimpleNumberCoercerFactory.getCoercer(null, coercionType);
            }
        }
    }
    catch (CoercionException ex)
    {
        throw new ExprValidationException("Implicit conversion not allowed: " + ex.getMessage());
    }
}
 
开发者ID:mobile-event-processing,项目名称:Asper,代码行数:37,代码来源:ExprCaseNode.java

示例14: getNumberCoercer

import com.espertech.esper.util.SimpleNumberCoercerFactory; //导入方法依赖的package包/类
private static SimpleNumberCoercer getNumberCoercer(Class leftType, Class rightType, String expression) throws ExprValidationException {
    Class numericCoercionType = JavaClassHelper.getBoxedType(leftType);
    if (rightType != leftType)
    {
        if (JavaClassHelper.isNumeric(rightType))
        {
            if (!JavaClassHelper.canCoerce(rightType, leftType))
            {
                throwConversionError(rightType, leftType, expression);
            }
            return SimpleNumberCoercerFactory.getCoercer(rightType, numericCoercionType);
        }
    }
    return null;
}
 
开发者ID:mobile-event-processing,项目名称:Asper,代码行数:16,代码来源:FilterSpecCompiler.java

示例15: testGetValueSet

import com.espertech.esper.util.SimpleNumberCoercerFactory; //导入方法依赖的package包/类
public void testGetValueSet()
{
    List<FilterSpecParam> parameters = SupportFilterSpecBuilder.buildList(eventType, new Object[]
                                { "intPrimitive", FilterOperator.EQUAL, 2 });
    SimpleNumberCoercer numberCoercer = SimpleNumberCoercerFactory.getCoercer(int.class, Double.class);
    parameters.add(new FilterSpecParamEventProp(makeLookupable("doubleBoxed"), FilterOperator.EQUAL, "asName", "doublePrimitive", false, numberCoercer, Double.class, "Test"));
    FilterSpecCompiled filterSpec = new FilterSpecCompiled(eventType, "SupportBean", parameters, null);

    SupportBean eventBean = new SupportBean();
    eventBean.setDoublePrimitive(999.999);
    EventBean theEvent = SupportEventBeanFactory.createObject(eventBean);
    MatchedEventMap matchedEvents = new MatchedEventMapImpl(new MatchedEventMapMeta(new String[] {"asName"}, false));
    matchedEvents.add(0, theEvent);
    FilterValueSet valueSet = filterSpec.getValueSet(matchedEvents, null, null);

    // Assert the generated filter value container
    assertSame(eventType, valueSet.getEventType());
    assertEquals(2, valueSet.getParameters().size());

    // Assert the first param
    FilterValueSetParam param = valueSet.getParameters().getFirst();
    assertEquals("intPrimitive", param.getLookupable().getExpression());
    assertEquals(FilterOperator.EQUAL, param.getFilterOperator());
    assertEquals(2, param.getFilterForValue());

    // Assert the second param
    param = (FilterValueSetParam) valueSet.getParameters().toArray()[1];
    assertEquals("doubleBoxed", param.getLookupable().getExpression());
    assertEquals(FilterOperator.EQUAL, param.getFilterOperator());
    assertEquals(999.999, param.getFilterForValue());
}
 
开发者ID:mobile-event-processing,项目名称:Asper,代码行数:32,代码来源:TestFilterSpecCompiled.java


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