本文整理汇总了Java中org.pentaho.reporting.libraries.formula.FormulaContext类的典型用法代码示例。如果您正苦于以下问题:Java FormulaContext类的具体用法?Java FormulaContext怎么用?Java FormulaContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
FormulaContext类属于org.pentaho.reporting.libraries.formula包,在下文中一共展示了FormulaContext类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: evaluate
import org.pentaho.reporting.libraries.formula.FormulaContext; //导入依赖的package包/类
public TypeValuePair evaluate( final FormulaContext context, final ParameterCallback parameters )
throws EvaluationException {
final int parameterCount = parameters.getParameterCount();
if ( parameterCount != 2 ) {
throw new EvaluationException( LibFormulaErrorValue.ERROR_ARGUMENTS_VALUE );
}
final TypeRegistry typeRegistry = context.getTypeRegistry();
final Type textType1 = parameters.getType( 0 );
final Object textValue1 = parameters.getValue( 0 );
final Type textType2 = parameters.getType( 1 );
final Object textValue2 = parameters.getValue( 1 );
final String text = typeRegistry.convertToText( textType1, textValue1 );
final String substring = typeRegistry.convertToText( textType2, textValue2 );
return text.contains( substring ) ? RETURN_TRUE : RETURN_FALSE;
}
开发者ID:pentaho,项目名称:pentaho-metadata,代码行数:19,代码来源:ContainsFunction.java
示例2: evaluate
import org.pentaho.reporting.libraries.formula.FormulaContext; //导入依赖的package包/类
public TypeValuePair evaluate( final FormulaContext context, final ParameterCallback parameters )
throws EvaluationException {
final int parameterCount = parameters.getParameterCount();
if ( parameterCount != 2 ) {
throw new EvaluationException( LibFormulaErrorValue.ERROR_ARGUMENTS_VALUE );
}
final TypeRegistry typeRegistry = context.getTypeRegistry();
final Type textType1 = parameters.getType( 0 );
final Object textValue1 = parameters.getValue( 0 );
final Type textType2 = parameters.getType( 1 );
final Object textValue2 = parameters.getValue( 1 );
final String text = typeRegistry.convertToText( textType1, textValue1 );
final String substring = typeRegistry.convertToText( textType2, textValue2 );
return text.startsWith( substring ) ? RETURN_TRUE : RETURN_FALSE;
}
开发者ID:pentaho,项目名称:pentaho-metadata,代码行数:19,代码来源:BeginsWithFunction.java
示例3: evaluate
import org.pentaho.reporting.libraries.formula.FormulaContext; //导入依赖的package包/类
public TypeValuePair evaluate( final FormulaContext context, final ParameterCallback parameters )
throws EvaluationException {
final int length = parameters.getParameterCount();
if ( length != 2 ) {
throw EvaluationException.getInstance( LibFormulaErrorValue.ERROR_ARGUMENTS_VALUE );
}
final TypeRegistry typeRegistry = context.getTypeRegistry();
final Object value1Raw = parameters.getValue( 0 );
final Object value2Raw = parameters.getValue( 1 );
if ( value1Raw == null || value2Raw == null ) {
throw EvaluationException.getInstance( LibFormulaErrorValue.ERROR_NA_VALUE );
}
final Type type1 = parameters.getType( 0 );
final Type type2 = parameters.getType( 1 );
final ExtendedComparator comparator = typeRegistry.getComparator( type1, type2 );
final boolean result = comparator.isEqual( type1, value1Raw, type2, value2Raw );
if ( result ) {
return RETURN_TRUE;
} else {
return RETURN_FALSE;
}
}
开发者ID:pentaho,项目名称:pentaho-metadata,代码行数:26,代码来源:EqualsFunction.java
示例4: evaluate
import org.pentaho.reporting.libraries.formula.FormulaContext; //导入依赖的package包/类
public TypeValuePair evaluate( final FormulaContext context, final ParameterCallback parameters )
throws EvaluationException {
final int parameterCount = parameters.getParameterCount();
if ( parameterCount != 2 ) {
throw new EvaluationException( LibFormulaErrorValue.ERROR_ARGUMENTS_VALUE );
}
final TypeRegistry typeRegistry = context.getTypeRegistry();
final Type textType1 = parameters.getType( 0 );
final Object textValue1 = parameters.getValue( 0 );
final Type textType2 = parameters.getType( 1 );
final Object textValue2 = parameters.getValue( 1 );
final String text = typeRegistry.convertToText( textType1, textValue1 );
String regex = typeRegistry.convertToText( textType2, textValue2 );
// replace any * or % with .*
regex = regex.replaceAll( "\\*", ".*" ).replaceAll( "%", ".*" );
Pattern p = Pattern.compile( regex );
Matcher m = p.matcher( text );
return m.find() ? RETURN_TRUE : RETURN_FALSE;
}
开发者ID:pentaho,项目名称:pentaho-metadata,代码行数:26,代码来源:LikeFunction.java
示例5: evaluate
import org.pentaho.reporting.libraries.formula.FormulaContext; //导入依赖的package包/类
public TypeValuePair evaluate( final FormulaContext context, final ParameterCallback parameters )
throws EvaluationException {
final int length = parameters.getParameterCount();
if ( length < 2 ) {
throw EvaluationException.getInstance( LibFormulaErrorValue.ERROR_ARGUMENTS_VALUE );
}
final TypeRegistry typeRegistry = context.getTypeRegistry();
final Object value1Raw = parameters.getValue( 0 );
final Type type1 = parameters.getType( 0 );
for ( int i = 1; i < parameters.getParameterCount(); i++ ) {
final Object value2Raw = parameters.getValue( i );
if ( value1Raw == null || value2Raw == null ) {
throw EvaluationException.getInstance( LibFormulaErrorValue.ERROR_NA_VALUE );
}
final Type type2 = parameters.getType( i );
final ExtendedComparator comparator = typeRegistry.getComparator( type1, type2 );
final boolean result = comparator.isEqual( type1, value1Raw, type2, value2Raw );
if ( result ) {
return RETURN_TRUE;
}
}
return RETURN_FALSE;
}
开发者ID:pentaho,项目名称:pentaho-metadata,代码行数:26,代码来源:InFunction.java
示例6: evaluate
import org.pentaho.reporting.libraries.formula.FormulaContext; //导入依赖的package包/类
public TypeValuePair evaluate( final FormulaContext context, final ParameterCallback parameters )
throws EvaluationException {
final int parameterCount = parameters.getParameterCount();
if ( parameterCount != 2 ) {
throw new EvaluationException( LibFormulaErrorValue.ERROR_ARGUMENTS_VALUE );
}
final TypeRegistry typeRegistry = context.getTypeRegistry();
final Type textType1 = parameters.getType( 0 );
final Object textValue1 = parameters.getValue( 0 );
final Type textType2 = parameters.getType( 1 );
final Object textValue2 = parameters.getValue( 1 );
final String text = typeRegistry.convertToText( textType1, textValue1 );
final String substring = typeRegistry.convertToText( textType2, textValue2 );
return text.endsWith( substring ) ? RETURN_TRUE : RETURN_FALSE;
}
开发者ID:pentaho,项目名称:pentaho-metadata,代码行数:19,代码来源:EndsWithFunction.java
示例7: evaluate
import org.pentaho.reporting.libraries.formula.FormulaContext; //导入依赖的package包/类
public TypeValuePair evaluate(final FormulaContext formulaContext,
final ParameterCallback parameterCallback) throws EvaluationException
{
if (parameterCallback.getParameterCount() > 0)
{
Type type = parameterCallback.getType(0);
Object raw = parameterCallback.getValue(0);
String text = formulaContext.getTypeRegistry().convertToText(type, raw);
return new TypeValuePair(TextType.TYPE, String.format("Hello World, %s!", text));
}
else
{
return new TypeValuePair(TextType.TYPE, "Hello World!");
}
}
开发者ID:tmorgner,项目名称:pentaho-reporting-oem-sdk,代码行数:16,代码来源:HelloWorldFormulaFunction.java
示例8: performTest
import org.pentaho.reporting.libraries.formula.FormulaContext; //导入依赖的package包/类
protected void performTest(final String formul, final Object result, final FormulaContext context) throws Exception
{
final Formula formula = new Formula(formul);
formula.initialize(context);
final Object eval = formula.evaluateTyped().getValue();
if (result instanceof Comparable && eval instanceof Comparable)
{
final Comparable n = (Comparable) result;
try
{
assertTrue("Failure numeric comparison on " + formul + ": " + result + " vs. " + eval, n.compareTo(eval) == 0);
}
catch (final ClassCastException cce)
{
cce.printStackTrace();
fail("Failure numeric comparison on " + formul + ": " + result + " vs. " + eval);
}
}
else if (result instanceof Object[] && eval instanceof Object[])
{
final boolean b = ObjectUtilities.equalArray((Object[]) result, (Object[]) eval);
if (b == false)
{
System.out.println(printArray(result));
System.out.println(printArray(eval));
fail("Failure on array comparison: " + formul);
}
}
else
{
assertEquals("Failure on " + formul, result, eval);
}
}
开发者ID:tmorgner,项目名称:pentaho-reporting-oem-sdk,代码行数:34,代码来源:FormulaTestBase.java
示例9: evaluateFormula
import org.pentaho.reporting.libraries.formula.FormulaContext; //导入依赖的package包/类
public boolean evaluateFormula( FormulaContext context, String formulaStr, Object result ) throws Exception {
final Formula formula = new Formula( formulaStr );
formula.initialize( context );
final Object eval = (Boolean) formula.evaluateTyped().getValue();
return result.equals( eval );
}
开发者ID:pentaho,项目名称:pentaho-metadata,代码行数:7,代码来源:InlineEtlModelGeneratorIT.java
示例10: evaluateBadFormula
import org.pentaho.reporting.libraries.formula.FormulaContext; //导入依赖的package包/类
public String evaluateBadFormula( FormulaContext context, String formulaStr, Object result ) throws Exception {
final Formula formula = new Formula( formulaStr );
formula.initialize( context );
Object eval = formula.evaluateTyped().getValue();
return eval.toString();
}
开发者ID:pentaho,项目名称:pentaho-metadata,代码行数:7,代码来源:InlineEtlModelGeneratorIT.java
示例11: getContext
import org.pentaho.reporting.libraries.formula.FormulaContext; //导入依赖的package包/类
@Override
public FormulaContext getContext() {
return reportFormulaContext;
}
开发者ID:tmorgner,项目名称:pentaho-reporting-oem-sdk,代码行数:5,代码来源:PentahoEditableDrillDownFunctionTest.java
示例12: getContext
import org.pentaho.reporting.libraries.formula.FormulaContext; //导入依赖的package包/类
public FormulaContext getContext()
{
return context;
}
开发者ID:tmorgner,项目名称:pentaho-reporting-oem-sdk,代码行数:5,代码来源:FormulaTestBase.java
注:本文中的org.pentaho.reporting.libraries.formula.FormulaContext类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论