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


Java StringValue类代码示例

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


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

示例1: createViolationInstance

import net.ssehub.easy.varModel.model.values.StringValue; //导入依赖的package包/类
@Override
protected ViolatingClause createViolationInstance(IDecisionVariable var, String operation, Double deviation, 
    Double deviationPercentage) {
    ViolatingClause clause = null;
    ActualViolation act = isActualViolation(var, operation, deviation); 
    if (null != act) {
        clause = new ViolatingClause(act.observable, Configuration.getInstanceName(act.variable, true), 
            operation, deviation, deviationPercentage);
        try {
            IDecisionVariable pVar = PipelineHelper.obtainPipeline(config, act.variable);
            if (null != pVar) {
                Value pValue = pVar.getValue();
                if (pValue instanceof CompoundValue) {
                    Value nValue = ((CompoundValue) pValue).getNestedValue(QmConstants.SLOT_NAME);
                    if (nValue instanceof StringValue) {
                        clause.setPipeline(((StringValue) nValue).getValue());
                    }
                }
            }
        } catch (ModelQueryException e) {
        }
    }
    return clause;
}
 
开发者ID:QualiMaster,项目名称:Infrastructure,代码行数:25,代码来源:ReasoningTask.java

示例2: assertConcatenatedSequence

import net.ssehub.easy.varModel.model.values.StringValue; //导入依赖的package包/类
/**
 * Asserts that <code>actual</code> is a container of String values and compares the concatenated
 * string values (in container given sequence) to <code>expected</code>. If <code>expected</code> is 
 * <b>null</b>, the value of <code>actual</code> must be null. Releases actual at the end.
 * 
 * @param expected the expected concatenated string
 * @param actual the actual evaluation result
 */
private static void assertConcatenatedSequence(String expected, EvaluationAccessor actual) {
    Value val = actual.getValue();
    if (null == expected) {
        Assert.assertNull(expected);
    } else {
        Assert.assertNotNull(expected);
        Assert.assertTrue(val instanceof ContainerValue);
        ContainerValue cValue = (ContainerValue) val;
        String sActual = "";
        for (int i = 0; i < cValue.getElementSize(); i++) {
            Value eVal = cValue.getElement(i);
            Assert.assertTrue(eVal instanceof StringValue);
            sActual += ((StringValue) eVal).getValue();
        }
        Assert.assertEquals(expected, sActual);
        actual.release();
    }
}
 
开发者ID:SSEHUB,项目名称:EASyProducer,代码行数:27,代码来源:StringOperationsTest.java

示例3: assertEquals

import net.ssehub.easy.varModel.model.values.StringValue; //导入依赖的package包/类
/**
 * Asserts equality between an expected String value and an actual evaluation accessor value.
 * Releases <code>actual</code>.
 * 
 * @param expected the expected value
 * @param actual the actual evaluation result
 */
static final void assertEquals(String expected, EvaluationAccessor actual) {
    Value val;
    if (null != actual) {
        val = actual.getValue();
        actual.release();
    } else {
        val = null;
    }
    if (null != expected && val instanceof StringValue) {
        Assert.assertEquals(expected, ((StringValue) val).getValue());
    } else if (null == expected && null == val) {
        Assert.assertTrue(true); // useless, I know
    } else {
        Assert.fail("expected " + expected + " is not equal to " + val);
    }
}
 
开发者ID:SSEHUB,项目名称:EASyProducer,代码行数:24,代码来源:Utils.java

示例4: evaluate

import net.ssehub.easy.varModel.model.values.StringValue; //导入依赖的package包/类
public EvaluationAccessor evaluate(EvaluationAccessor operand, EvaluationAccessor[] arguments) {
    EvaluationAccessor result = null;
    if (null != operand) {
        try {
            Value sv = operand.getValue();
            String sValue;
            if (sv instanceof StringValue) {
                // direct access, avoid IVML quoting
                sValue = ((StringValue) sv).getValue();
            } else {
                sValue = StringProvider.toIvmlString(operand.getValue());
            }
            result = ConstantAccessor.POOL.getInstance().bind(
                ValueFactory.createValue(StringType.TYPE, sValue), 
                operand.getContext());
        } catch (ValueDoesNotMatchTypeException e) {
            // result -> null
        } 
    }
    return result; 
}
 
开发者ID:SSEHUB,项目名称:EASyProducer,代码行数:22,代码来源:GenericOperations.java

示例5: evaluate

import net.ssehub.easy.varModel.model.values.StringValue; //导入依赖的package包/类
public EvaluationAccessor evaluate(EvaluationAccessor operand, EvaluationAccessor[] arguments) {
    EvaluationAccessor result = null;
    if (1 == arguments.length) {
        Value opValue = operand.getValue();
        Value argValue = arguments[0].getValue();
        if (opValue instanceof StringValue && argValue instanceof StringValue) {
            try {
                String opS = ((StringValue) opValue).getValue();
                String argS = ((StringValue) argValue).getValue();
                result = ConstantAccessor.POOL.getInstance().bind(
                    ValueFactory.createValue(StringType.TYPE, opS + argS), operand.getContext());
            } catch (ValueDoesNotMatchTypeException e) {
                // result -> null
            } 
        }
    }
    return result;
}
 
开发者ID:SSEHUB,项目名称:EASyProducer,代码行数:19,代码来源:StringOperations.java

示例6: visitStringValue

import net.ssehub.easy.varModel.model.values.StringValue; //导入依赖的package包/类
@Override
public void visitStringValue(StringValue value) {
    String val = value.getValue();
    val = DroolsVisitor.processStringEscapeSequences(val);

    if (this.visitingNonNested) {
        if (visitingConatinerValue) {
            this.value += "\"" + val + "\"";
        } else {
            this.declaration += " = " + "\"" + val + "\"";
        }
    } else if (visitingNested) {
        if (visitingConatinerValue) {
            this.value += "\"" + val + "\"";
        } else {
            this.compDeclaration += " = " + "\"" + val + "\"";
        }
    } else if (visitingConfiguration) {
        this.value += "(\"" + val + "\")";
    }       
}
 
开发者ID:SSEHUB,项目名称:EASyProducer,代码行数:22,代码来源:DroolsVisitor.java

示例7: getStringValue

import net.ssehub.easy.varModel.model.values.StringValue; //导入依赖的package包/类
/**
 * Returns the string value of a decision variable.
 * 
 * @param var the variable to return the string for
 * @return the value, only if <code>var</code> is not <b>null</b> and of type String
 */
public static String getStringValue(IDecisionVariable var) {
    String result = null;
    if (null != var) {
        Value value = var.getValue();
        if (value instanceof StringValue) {
            result = ((StringValue) value).getValue();
        }
    }
    return result;
}
 
开发者ID:QualiMaster,项目名称:Infrastructure,代码行数:17,代码来源:RepositoryConnector.java

示例8: getName

import net.ssehub.easy.varModel.model.values.StringValue; //导入依赖的package包/类
/**
 * Returns the logical name of <code>var</code> from slot {@link QmConstants#SLOT_NAME}.
 * 
 * @param var the variable (may be <b>null</b>)
 * @return the name of <code>var</code>, <b>null</b> if there is none
 */
public static String getName(IDecisionVariable var) {
    String result = null;
    if (null != var) {
        IDecisionVariable nameVar = var.getNestedElement(QmConstants.SLOT_NAME);
        if (null != nameVar) {
            Value nameValue = nameVar.getValue();
            if (nameValue instanceof StringValue) {
                result = ((StringValue) nameValue).getValue();
            }
        }
    }
    return result;
}
 
开发者ID:QualiMaster,项目名称:QM-EASyProducer,代码行数:20,代码来源:VariableHelper.java

示例9: getString

import net.ssehub.easy.varModel.model.values.StringValue; //导入依赖的package包/类
/**
 * Returns the value of a string compound slot.
 * 
 * @param var the variable to look into (may be <b>null</b>)
 * @param name the name of the slot
 * @return the string value of the slot, <b>null</b> if there is no variable, no slot or no string value in 
 *     the slot 
 */
public static final String getString(IDecisionVariable var, String name) {
    String result = null;
    if (null != var) {
        IDecisionVariable nested = var.getNestedElement(name);
        if (null != nested) {
            Value value = nested.getValue();
            if (value instanceof StringValue) {
                result = ((StringValue) value).getValue();
            }
        }
    }
    return result;
}
 
开发者ID:QualiMaster,项目名称:QM-EASyProducer,代码行数:22,代码来源:VariableHelper.java

示例10: visitStringValue

import net.ssehub.easy.varModel.model.values.StringValue; //导入依赖的package包/类
@Override
public void visitStringValue(StringValue value) {
    Assert.assertTrue(decl.getValue() instanceof String);
    Assert.assertNotNull(decl.getStringValue());
    Assert.assertTrue(decl.getStringValue().equals(decl.getValue()));
    Assert.assertEquals(value.getValue(), decl.getStringValue());
}
 
开发者ID:SSEHUB,项目名称:EASyProducer,代码行数:8,代码来源:ValueTester.java

示例11: visitStringType

import net.ssehub.easy.varModel.model.values.StringValue; //导入依赖的package包/类
@Override
public void visitStringType(StringType type) {
    variableName.append(variable.getDeclaration().getName());
    StringValue stringValue = (StringValue) variable.getValue();
    if (null != stringValue) {
        values.add(new VelocityContextItem(variableName.toString(), stringValue.getValue()));
    }
}
 
开发者ID:SSEHUB,项目名称:EASyProducer,代码行数:9,代码来源:VelocityContextInitializer.java

示例12: testToString

import net.ssehub.easy.varModel.model.values.StringValue; //导入依赖的package包/类
/**
 * Tests the "toString" operation. 
 * 
 * @param context the evaluation context
 * @param op the operation to be tested
 * @param operand the operand value to calculate the string representation for
 * @param expected the expected output
 * @param maxLen the maximum length to compare, ignored if negative
 * 
 * @throws ValueDoesNotMatchTypeException shall not occur
 */
static void testToString(EvaluationContext context, Operation op, EvaluationAccessor operand, String expected, 
    int maxLen) {
    EvaluationAccessor res = evaluate(op, operand);
    Assert.assertNotNull(res);
    Assert.assertNotNull(res.getValue());
    Assert.assertTrue(res.getValue() instanceof StringValue);
    Assert.assertEquals(cut(expected, maxLen), cut(((StringValue) res.getValue()).getValue(), maxLen));
    res.release();
    
    res = evaluate(op, null);
    Assert.assertNull(res);
}
 
开发者ID:SSEHUB,项目名称:EASyProducer,代码行数:24,代码来源:Utils.java

示例13: setUp

import net.ssehub.easy.varModel.model.values.StringValue; //导入依赖的package包/类
/**
 * setUp for all tests.
 * @throws ValueDoesNotMatchTypeException should not occur
 */
@Before
public void setUp() throws ValueDoesNotMatchTypeException {
    project = new Project("Projekt");
    str = "String";
    strDec = new DecisionVariableDeclaration("String", StringType.TYPE, project);
    strV = (StringValue) ValueFactory.createValue(strDec.getType(), str);
}
 
开发者ID:SSEHUB,项目名称:EASyProducer,代码行数:12,代码来源:StringValueTest.java

示例14: cloneString

import net.ssehub.easy.varModel.model.values.StringValue; //导入依赖的package包/类
/**
 * test to clone a stringValue.
 * @throws ValueDoesNotMatchTypeException should not occur
 */
@Test
public void cloneString() throws ValueDoesNotMatchTypeException {
    str = "Ersetzt";
    strV.setValue(str);
    Assert.assertEquals(str, strV.getValue());
    StringValue cloneStr = (StringValue) strV.clone();
    Assert.assertEquals(cloneStr.getValue(), strV.getValue());
    Assert.assertNotSame(cloneStr, strV);
}
 
开发者ID:SSEHUB,项目名称:EASyProducer,代码行数:14,代码来源:StringValueTest.java

示例15: basisDatatypeTest

import net.ssehub.easy.varModel.model.values.StringValue; //导入依赖的package包/类
/**
 * tests the BasisDataTypes.
 * @throws ValueDoesNotMatchTypeException .
 */
@Test
public void basisDatatypeTest() throws ValueDoesNotMatchTypeException {
    
    //StringValue
    DecisionVariableDeclaration string = new DecisionVariableDeclaration("string", StringType.TYPE, project);
    StringValue strV = (StringValue) ValueFactory.createValue(string.getType(), "Hallo");
    Assert.assertTrue(strV.isConfigured());
    
    //IntValue
    DecisionVariableDeclaration integer = new DecisionVariableDeclaration("integer", IntegerType.TYPE, project);
    int intValue = 5;
    IntValue intV = (IntValue) ValueFactory.createValue(integer.getType(), intValue);
    Assert.assertTrue(intV.isConfigured());
    Assert.assertEquals(intValue, (int) intV.getValue());               
    
    //BoolVBalue
    DecisionVariableDeclaration booleanD = new DecisionVariableDeclaration("bool", BooleanType.TYPE, project);
    BooleanValue boolV = (BooleanValue) ValueFactory.createValue(booleanD.getType(), "true");
    Assert.assertTrue(boolV.isConfigured());
    
    //RealValue
    DecisionVariableDeclaration real = new DecisionVariableDeclaration("real", RealType.TYPE, project);
    RealValue realV = (RealValue) ValueFactory.createValue(real.getType(), "5.5");
    Assert.assertTrue(realV.isConfigured());        
    
    //RealValue initialized with a double instead of a string
    DecisionVariableDeclaration realOfDouble = new DecisionVariableDeclaration("real", RealType.TYPE, project);
    Double value = 5.5;
    RealValue realOfDoubleV = (RealValue) ValueFactory.createValue(realOfDouble.getType(), value);
    Assert.assertTrue(realOfDoubleV.isConfigured());
    Assert.assertEquals(value, realOfDoubleV.getValue());
            
}
 
开发者ID:SSEHUB,项目名称:EASyProducer,代码行数:38,代码来源:ValueFactoryTest.java


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