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


Java IntValue类代码示例

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


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

示例1: isPipelineActive

import net.ssehub.easy.varModel.model.values.IntValue; //导入依赖的package包/类
/**
 * Returns whether the pipeline in <code>var</code> is active.
 * 
 * @param var the variable to treat as pipeline
 * @param pipStatus a pipeline - pipeline status mapping
 * @return <code>true</code> if the resource is active, <code>false</code> else
 */
private static boolean isPipelineActive(IDecisionVariable var, 
    Map<String, PipelineLifecycleEvent.Status> pipStatus) {
    boolean result = false;
    String name = VariableHelper.getName(var);
    if (null != name) {
        PipelineLifecycleEvent.Status status = pipStatus.get(name);
        if (PipelineLifecycleEvent.Status.STARTED == status) {
            Value val = getCompoundValue(var, "executors");
            if (val instanceof IntValue) {
                Integer iVal = ((IntValue) val).getValue();
                if (null != iVal) {
                    result = iVal.intValue() > 0;
                }
            }
        }
    }
    return result;
}
 
开发者ID:QualiMaster,项目名称:Infrastructure,代码行数:26,代码来源:ReasoningTask.java

示例2: getDouble

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

示例3: evaluate

import net.ssehub.easy.varModel.model.values.IntValue; //导入依赖的package包/类
@Override
public EvaluationAccessor evaluate(EvaluationAccessor operand, EvaluationAccessor[] arguments) {
    EvaluationAccessor result = null;
    if (2 == arguments.length) {
        Value oValue = operand.getValue();
        Value aValue = arguments[0].getValue();
        Value insValue = arguments[1].getValue();
        if (oValue instanceof ContainerValue && aValue instanceof IntValue && null != insValue) {
            ContainerValue cont = (ContainerValue) oValue;
            int index = OclKeyWords.toJavaIndex(((IntValue) aValue).getValue());
            if (0 <= index && index <= cont.getElementSize()) { // this is an insert!
                ArrayList<Value> tmp = new ArrayList<Value>();
                ContainerOperations.addAll(cont, tmp);
                tmp.add(index, insValue);
                try {
                    Value rValue = ValueFactory.createValue(cont.getType(), tmp.toArray());
                    result = ConstantAccessor.POOL.getInstance().bind(rValue, operand.getContext());
                } catch (ValueDoesNotMatchTypeException e) {
                    // result -> null
                }
            }
        }
    }
    return result;
}
 
开发者ID:SSEHUB,项目名称:EASyProducer,代码行数:26,代码来源:SequenceOperations.java

示例4: getIndex

import net.ssehub.easy.varModel.model.values.IntValue; //导入依赖的package包/类
/**
 * Returns the (valid) index from <code>accessor</code> for <code>value</code>.
 * 
 * @param value the container to be accessed
 * @param accessor the accessor expression
 * @return the index value (invalid if <b>null</b>)
 */
private Integer getIndex(ContainerValue value, EvaluationAccessor accessor) {
    Integer result = null;
    EvaluationContext context = accessor.getContext();
    Value iValue = accessor.getValue();
    if (iValue instanceof IntValue) {
        int index = OclKeyWords.toJavaIndex(((IntValue) iValue).getValue());
        if (index < 0) {
            context.addErrorMessage("index < 0");
        } else if (index >= value.getElementSize()) {
            context.addErrorMessage("index >= " + value.getElementSize());
        } else {
            result = index;
        }
    } else {
        context.addErrorMessage("index must happen trough an integer");
    }
    return result;
}
 
开发者ID:SSEHUB,项目名称:EASyProducer,代码行数:26,代码来源:VariableAccessor.java

示例5: equalsRealInt

import net.ssehub.easy.varModel.model.values.IntValue; //导入依赖的package包/类
/**
 * Implements the mixed int-real equality operation.
 * 
 * @param operand the operand
 * @param arguments the arguments
 * @param negate whether the result shall be negated
 * @return the comparison result, <b>null</b> if the operation cannot be applied
 */
static EvaluationAccessor equalsRealInt(EvaluationAccessor operand, EvaluationAccessor[] arguments, 
    boolean negate) {
    EvaluationAccessor result = null;
    if (arguments.length == 1) {
        Value oValue = operand.getValue();
        Value aValue = arguments[0].getValue();
        if (aValue instanceof IntValue) {
            if (oValue instanceof RealValue) {
                double op = ((RealValue) oValue).getValue();
                int arg = ((IntValue) aValue).getValue();
                boolean equals = ((int) op == arg);
                if (negate) {
                    equals = !equals;
                }
                result = ConstantAccessor.POOL.getInstance().bind(
                    BooleanValue.toBooleanValue(equals), operand.getContext());
            } else if (oValue == NullValue.INSTANCE) {
                result = ConstantAccessor.POOL.getInstance().bind(
                    BooleanValue.toBooleanValue(negate), operand.getContext());
            }
        }
    }
    return result;
}
 
开发者ID:SSEHUB,项目名称:EASyProducer,代码行数:33,代码来源:RealOperations.java

示例6: getValue

import net.ssehub.easy.varModel.model.values.IntValue; //导入依赖的package包/类
@Override
public EvaluationAccessor getValue(EvaluationAccessor accessor) {
    EvaluationAccessor result = null;
    if (value instanceof ContainerValue) {
        Value aValue = accessor.getValue();
        if (aValue instanceof IntValue) {
            ContainerValue cVal = (ContainerValue) value;
            int index = OclKeyWords.toJavaIndex(((IntValue) aValue).getValue());
            if (0 <= index && index < cVal.getElementSize()) {
                result = ConstantAccessor.POOL.getInstance().bind(cVal.getElement(index), getContext());
            } else {
                getContext().addErrorMessage("invalid index value");
            }
        } else {
            getContext().addErrorMessage("index must be an integer value");
        }
    } else {
        getContext().addErrorMessage("left side of accessor must be a compound value");
    }
    return result;
}
 
开发者ID:SSEHUB,项目名称:EASyProducer,代码行数:22,代码来源:ConstantAccessor.java

示例7: equalsIntReal

import net.ssehub.easy.varModel.model.values.IntValue; //导入依赖的package包/类
/**
 * Implements the mixed int-real equality operation.
 * 
 * @param operand the operand
 * @param arguments the arguments
 * @param negate whether the result shall be negated
 * @return the comparison result, <b>null</b> if the operation cannot be applied
 */
static EvaluationAccessor equalsIntReal(EvaluationAccessor operand, EvaluationAccessor[] arguments, 
    boolean negate) {
    EvaluationAccessor result = null;
    if (arguments.length == 1) {
        Value oValue = operand.getValue();
        Value aValue = arguments[0].getValue();
        if (aValue instanceof RealValue) {
            if (oValue instanceof IntValue) {
                int op = ((IntValue) oValue).getValue();
                double arg = ((RealValue) aValue).getValue();
                boolean equals = (op == (int) arg);
                if (negate) {
                    equals = !equals;
                }
                result = ConstantAccessor.POOL.getInstance().bind(
                    BooleanValue.toBooleanValue(equals), operand.getContext());
            }
        }
    }
    return result;
}
 
开发者ID:SSEHUB,项目名称:EASyProducer,代码行数:30,代码来源:IntegerOperations.java

示例8: visitIntValue

import net.ssehub.easy.varModel.model.values.IntValue; //导入依赖的package包/类
@Override
public void visitIntValue(IntValue value) {
    if (this.visitingNonNested) {
        if (visitingConatinerValue) {
            this.value += value.getValue();
        } else {
            this.declaration += " = " + value.getValue();
        }
    } else if (visitingNested) {
        if (visitingConatinerValue) {
            this.value += value.getValue();
        } else {
            this.compDeclaration += " = " + value.getValue();
        }
    } else if (visitingConfiguration) {
        this.value += value.getValue();
    }
}
 
开发者ID:SSEHUB,项目名称:EASyProducer,代码行数:19,代码来源:DroolsVisitor.java

示例9: visitConstantValue

import net.ssehub.easy.varModel.model.values.IntValue; //导入依赖的package包/类
@Override
    public void visitConstantValue(ConstantValue value) {
        if (currentVariable.equals(currentVariablesBeingVisited)) {
            
            if (value.getConstantValue() instanceof IntValue) {
                IntValue val = (IntValue) value.getConstantValue();
                boundaries++;
                boundaryValues.add(val.getValue().toString());
            }
            // Currently only for Integer values.
//            else if (value.getConstantValue() instanceof RealValue) {
//                RealValue val = (RealValue) value.getConstantValue();
//                boundaries++;
//                boundaryValues.add(val.getValue().toString());
//            }
        }
    }
 
开发者ID:SSEHUB,项目名称:EASyProducer,代码行数:18,代码来源:ConstraintChecker.java

示例10: getIntegerValue

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

示例11: getInteger

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

示例12: visitIntValue

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

示例13: visitIntegerType

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

示例14: toDouble

import net.ssehub.easy.varModel.model.values.IntValue; //导入依赖的package包/类
/**
 * Turns an evaluation <code>accessor</code> into its double value if possible.
 * 
 * @param accessor the accessor (may be <b>null</b> resulting in <b>null</b>)
 * @return the double value or <b>null</b> if the conversion is not possible
 */
private Double toDouble(EvaluationAccessor accessor) {
    Double result = null;
    if (null != accessor) {
        Value value = accessor.getValue();
        if (value instanceof IntValue) {
            result = ((IntValue) value).getValue().doubleValue();
        } else if (value instanceof RealValue) {
            result = ((RealValue) value).getValue();
        }
    }
    return result;
}
 
开发者ID:SSEHUB,项目名称:EASyProducer,代码行数:19,代码来源:AbstractAnalyzerVisitor.java

示例15: testCustomOperationDispatch

import net.ssehub.easy.varModel.model.values.IntValue; //导入依赖的package包/类
/**
 * Tests dynamic dispatch for custom operations.
 * 
 * @throws ValueDoesNotMatchTypeException in case that value assignments fail (shall not occur)
 * @throws ConfigurationException in case that initial assignment of values fail (shall not occur)
 * @throws CSTSemanticException in case that the expressions created during this test are not 
 *   valid (shall not occur)
 */
@Test
public void testCustomOperationDispatch() throws ValueDoesNotMatchTypeException, ConfigurationException, 
    CSTSemanticException {
    
    Project project = new Project("Test");

    // compound Base {};
    Compound cBase = new Compound("Base", project);
    project.add(cBase);

    // compound Refined refines Base {};
    Compound cRefined = new Compound("Refined", project, cBase);
    project.add(cRefined);

    // def Integer test(Base b) = 0;
    createConstantIntOperation(project, false, "test", cBase, 0);

    // def Integer test(Refined r) = 1;
    createConstantIntOperation(project, false, "test", cRefined, 1);

    DecisionVariableDeclaration var = new DecisionVariableDeclaration("r", cRefined, project);
    project.add(var);
    
    ConstraintSyntaxTree cst = new OCLFeatureCall(null, "test", project, new Variable(var));
    cst.inferDatatype();
    
    Configuration config = new Configuration(project);
    config.getDecision(var).setValue(ValueFactory.createValue(cRefined, (Object[]) null), AssignmentState.ASSIGNED);
    
    EvaluationVisitor visitor = new EvaluationVisitor();
    visitor.init(config, AssignmentState.DEFAULT, false, null);
    visitor.setDispatchScope(project); // this is important!
    cst.accept(visitor);
    Assert.assertTrue(visitor.getResult() instanceof IntValue);
    // use the more specific one due to dynamic dispatch
    Assert.assertEquals(1, ((IntValue) visitor.getResult()).getValue().intValue());
    visitor.clear();
}
 
开发者ID:SSEHUB,项目名称:EASyProducer,代码行数:47,代码来源:DynamicDispatchTest.java


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