本文整理汇总了Java中net.ssehub.easy.varModel.model.values.ContainerValue.getElement方法的典型用法代码示例。如果您正苦于以下问题:Java ContainerValue.getElement方法的具体用法?Java ContainerValue.getElement怎么用?Java ContainerValue.getElement使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.ssehub.easy.varModel.model.values.ContainerValue
的用法示例。
在下文中一共展示了ContainerValue.getElement方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: initializeNested
import net.ssehub.easy.varModel.model.values.ContainerValue; //导入方法依赖的package包/类
/**
* Initializes nested variables.
*/
private void initializeNested() {
if (null == nested) {
if (value instanceof CompoundValue) {
CompoundValue comp = (CompoundValue) value;
Compound type = (Compound) comp.getType();
nested = new IDecisionVariable[type.getElementCount()];
for (int i = 0; i < nested.length; i++) {
DecisionVariableDeclaration d = type.getElement(i);
nested[i] = new DecVar(this, comp.getNestedValue(d.getName()), d);
}
} else if (value instanceof ContainerValue) {
ContainerValue cont = (ContainerValue) value;
nested = new IDecisionVariable[cont.getElementSize()];
for (int i = 0; i < nested.length; i++) {
nested[i] = new DecVar(this, cont.getElement(i), null);
}
}
}
}
示例2: assertConcatenatedSequence
import net.ssehub.easy.varModel.model.values.ContainerValue; //导入方法依赖的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();
}
}
示例3: getUsedTypes
import net.ssehub.easy.varModel.model.values.ContainerValue; //导入方法依赖的package包/类
/**
* Returns the used types if <code>value</code> is a container value.
*
* @param <D> the the to filter for
* @param val the value
* @param filter the type class to filter for
* @param result the result set to be modified as a side effect
* @return <code>true</code> if <code>val</code> is a container value, <code>false</code> else
*/
private static <D extends IDatatype> boolean getUsedTypes(Value val, Class<D> filter, Set<D> result) {
boolean done = false;
if (val instanceof ContainerValue) {
ContainerValue cVal = (ContainerValue) val;
for (int v = 0; v < cVal.getElementSize(); v++) {
Value tmp = cVal.getElement(v);
if (!getUsedTypes(tmp, filter, result)) {
IDatatype tType = tmp.getType();
if (filter.isInstance(tType)) {
result.add(filter.cast(tType));
}
}
}
done = true;
}
return done;
}
示例4: evaluate
import net.ssehub.easy.varModel.model.values.ContainerValue; //导入方法依赖的package包/类
@Override
public EvaluationAccessor evaluate(EvaluationAccessor operand, EvaluationAccessor[] arguments) {
EvaluationAccessor result = null;
if (1 == arguments.length) {
Value oValue = operand.getValue();
Value aValue = arguments[0].getValue();
if (oValue instanceof ContainerValue && aValue instanceof ContainerValue) {
ContainerValue coValue = (ContainerValue) oValue;
ContainerValue caValue = (ContainerValue) aValue;
boolean all = true;
for (int i = 0; all && i < caValue.getElementSize(); i++) {
Value val = caValue.getElement(i);
if (exclude) {
all &= coValue.indexOf(val) < 0; // exclude
} else {
all &= coValue.indexOf(val) >= 0;
}
}
result = ConstantAccessor.POOL.getInstance().bind(
BooleanValue.toBooleanValue(all), operand.getContext());
}
}
return result;
}
示例5: visitContainerValue
import net.ssehub.easy.varModel.model.values.ContainerValue; //导入方法依赖的package包/类
/**
* Iterates through a container, extracts all referenced variables, and calls the visit method.
* @param containerValue A container of references.
*/
private void visitContainerValue(ContainerValue containerValue) {
for (int i = 0, end = containerValue.getElementSize(); i < end; i++) {
ReferenceValue refValue = (ReferenceValue) containerValue.getElement(i);
IDecisionVariable referencedVariable = extractVar(refValue);
visitPipelineElement(referencedVariable);
}
}
示例6: collectAlgorithmFromFamily
import net.ssehub.easy.varModel.model.values.ContainerValue; //导入方法依赖的package包/类
/**
* Part of {@link #gatherAlgorithms()}, collects one (original) algorithm together with its mapped counterpart.
* @param config The top level configuration, needed for querying {@link IDecisionVariable}s.
* @param referencedOrgAlgos A container value containing reference values to algorithms.
* @param runtimeAlgorithms A list of already mapped counterparts. Maybe <tt>null</tt>,
* in this case no mapping will be created.
*/
private void collectAlgorithmFromFamily(Configuration config, ContainerValue referencedOrgAlgos,
List<IDecisionVariable> runtimeAlgorithms) {
int lastIndex = null != referencedOrgAlgos ? referencedOrgAlgos.getElementSize() : 0;
INameMapping nMapping = getNameMapping();
for (int i = 0; i < lastIndex; i++) {
ReferenceValue orgRef = (ReferenceValue) referencedOrgAlgos.getElement(i);
IDecisionVariable orgAlgorithm = Utils.extractVariable(orgRef, config);
String orgName = orgAlgorithm.getNestedElement(QmConstants.SLOT_NAME).getValue().getValue().toString();
if (null != runtimeAlgorithms) {
IDecisionVariable mappedAlgorithm = null;
for (int j = 0; j < runtimeAlgorithms.size() && null == mappedAlgorithm; j++) { // due to deletion
IDecisionVariable tmpAlgo = runtimeAlgorithms.get(j);
if (tmpAlgo.getNestedElement(QmConstants.SLOT_NAME).getValue().getValue().equals(orgName)) {
mappedAlgorithm = tmpAlgo;
runtimeAlgorithms.remove(j);
}
}
if (null != mappedAlgorithm) {
algorithmMapping.put(orgName, mappedAlgorithm);
String impl = NameMappingHelper.getAlgorithmImplName(nMapping, orgName);
if (null != impl && !impl.equals(orgName)) {
algorithmMapping.put(impl, mappedAlgorithm);
}
allMappedVariables.add(mappedAlgorithm);
}
}
}
}
示例7: extractVariables
import net.ssehub.easy.varModel.model.values.ContainerValue; //导入方法依赖的package包/类
/**
* Extracts all referenced {@link IDecisionVariable}s from a container of {@link ReferenceValue}s.
* @param refValues A value pointing other declarations, must not use an expression.
* @param config The complete configuration form where to take the {@link IDecisionVariable}.
* @return The referenced {@link IDecisionVariable}s or an empty list in case of any errors.
*/
public static List<IDecisionVariable> extractVariables(ContainerValue refValues, Configuration config) {
List<IDecisionVariable> result = new ArrayList<IDecisionVariable>();
for (int i = 0, end = refValues.getElementSize(); i < end; i++) {
Value nestedValue = refValues.getElement(i);
if (nestedValue instanceof ReferenceValue) {
IDecisionVariable referrencedVar = extractVariable((ReferenceValue) nestedValue, config);
if (null != referrencedVar) {
result.add(referrencedVar);
}
}
}
return result;
}
示例8: visitContainerValue
import net.ssehub.easy.varModel.model.values.ContainerValue; //导入方法依赖的package包/类
@Override
public void visitContainerValue(ContainerValue value) {
//Assert.assertNull(decl.getValue());
Sequence<DecisionVariable> seq = decl.variables();
for (int i = 0; i < value.getElementSize(); i++) {
Value val = value.getElement(i);
val.accept(new ValueTester(seq.get(i)));
}
}
示例9: testStepwiseExtentionOfSet
import net.ssehub.easy.varModel.model.values.ContainerValue; //导入方法依赖的package包/类
/**
* Tests the stepwise creation of nested Values of a set.
* This is needed for the stepwise configuration inside the GUI.
* @throws ValueDoesNotMatchTypeException Must not occur, otherwise {@link ValueFactory} is broken.
* @throws ConfigurationException Must not occur, otherwise {@link SetVariable#setValue(Value, IAssignmentState)}
* is broken.
*/
@Test
public void testStepwiseExtentionOfSet() throws ValueDoesNotMatchTypeException, ConfigurationException {
String testValue = "1";
// Retrieve setVariable
SetVariable setVar = retrieveSetVariable(set);
Container setType = (Container) setVar.getDeclaration().getType();
IDatatype setOfType = setType.getContainedType();
// Extend variable (insert new nested element) and configure nested element
IDecisionVariable nestedElement = createNestedElement(setVar);
Value tmpNestedValue = ValueFactory.createValue(setOfType, testValue);
nestedElement.setValue(tmpNestedValue, AssignmentState.ASSIGNED);
// Test correct behavior of configuring the nested element.
Assert.assertEquals(testValue, nestedElement.getValue().getValue().toString());
ContainerValue completeValue = (ContainerValue) setVar.getValue();
Value nestedValue = completeValue.getElement(0);
Assert.assertNotNull(nestedValue);
Assert.assertNotNull(nestedValue.getValue());
Assert.assertEquals(testValue, nestedValue.getValue().toString());
// Test whether the variable would be saved correctly
Project confProject = configuration.toProject(true);
StringWriter sWriter = new StringWriter();
IVMLWriter writer = new IVMLWriter(sWriter);
confProject.accept(writer);
StringBuffer output = sWriter.getBuffer();
String savedValueAssignment = getValue(output, 0);
String expected = set.getName() + " " + IvmlKeyWords.ASSIGNMENT + " "
+ StringProvider.toIvmlString(completeValue);
Assert.assertEquals(expected, savedValueAssignment);
}
示例10: evaluate
import net.ssehub.easy.varModel.model.values.ContainerValue; //导入方法依赖的package包/类
public void evaluate(ContainerValue c1, ContainerValue c2, List<Value> result) {
HashSet<Value> inC2 = new HashSet<Value>();
ContainerOperations.addAll(c2, inC2);
for (int e = 0; e < c1.getElementSize(); e++) {
Value val = c1.getElement(e);
if (!inC2.contains(val)) {
result.add(val);
}
}
}
示例11: createContainerConstraintValueConstraints
import net.ssehub.easy.varModel.model.values.ContainerValue; //导入方法依赖的package包/类
/**
* Checks a container value for nested constraint values, i.e., values of nested constraint variables.
*
* @param val the container value
* @param decl the variable declaration representing <i>self</i> in the container/constraint value
* @param parent the parent for new constraints
* @param nestedVariable the variable holding the constraint value
*/
private void createContainerConstraintValueConstraints(ContainerValue val, AbstractVariable decl,
IModelElement parent, IDecisionVariable nestedVariable) {
for (int n = 0; n < val.getElementSize(); n++) {
Value cVal = val.getElement(n);
if (cVal instanceof ConstraintValue) {
ConstraintValue constraint = (ConstraintValue) cVal;
createConstraintVariableConstraint(constraint.getValue(), decl, parent, nestedVariable);
}
}
}
示例12: getValue
import net.ssehub.easy.varModel.model.values.ContainerValue; //导入方法依赖的package包/类
@Override
protected Value getValue() {
Value value = null;
ContainerValue parentValue = (ContainerValue) getParent().getValue();
if (null != parentValue && parentValue.getElementSize() > index) {
value = parentValue.getElement(index);
}
return value;
}
示例13: evaluate
import net.ssehub.easy.varModel.model.values.ContainerValue; //导入方法依赖的package包/类
public void evaluate(ContainerValue cont, Value value, List<Value> result) {
for (int i = 0; i < cont.getElementSize(); i++) {
Value elt = cont.getElement(i);
if (!elt.equals(value)) {
result.add(elt);
}
}
}
示例14: convert
import net.ssehub.easy.varModel.model.values.ContainerValue; //导入方法依赖的package包/类
/**
* Performs the conversion of the operand to the given (container) datatype.
*
* @param operand the operand to be converted
* @param targetType the target datatype
* @return the converted operand
*/
private static final EvaluationAccessor convert(EvaluationAccessor operand, IDatatype targetType) {
EvaluationAccessor result = null;
Value oVal = operand.getValue();
if (oVal instanceof ContainerValue) {
ContainerValue cont = (ContainerValue) oVal;
// due to releasing Accessors create always
try {
Value rValue;
if (Set.TYPE.isAssignableFrom(targetType)) {
if (1 == oVal.getType().getGenericTypeCount()) {
targetType = new Set("set", oVal.getType().getGenericType(0), null);
}
HashSet<Object> done = new HashSet<Object>();
ArrayList<Object> tmp = new ArrayList<Object>();
for (int i = 0; i < cont.getElementSize(); i++) {
Object elt = cont.getElement(i);
if (!done.contains(elt)) {
done.add(elt);
tmp.add(elt); // for now we try to keep the sequence
}
}
Object[] array = new Object[tmp.size()];
tmp.toArray(array);
rValue = ValueFactory.createValue(targetType, (Object[]) array);
} else {
rValue = ValueFactory.createValue(targetType, (Object[]) null);
rValue.setValue(cont);
}
result = ConstantAccessor.POOL.getInstance().bind(rValue, operand.getContext());
} catch (ValueDoesNotMatchTypeException e) {
operand.getContext().addErrorMessage(e);
}
}
return result;
}
示例15: visitContainerValue
import net.ssehub.easy.varModel.model.values.ContainerValue; //导入方法依赖的package包/类
@Override
public void visitContainerValue(ContainerValue cValue) {
boolean setValue = Set.TYPE.isAssignableFrom(cValue.getType());
if (cValue.getElementSize() != 0) {
if (!setValue) {
this.value += " new java.util.ArrayList(java.util.Arrays.asList(";
} else {
this.value += " new java.util.HashSet(java.util.Arrays.asList(";
}
this.visitingConatinerValue = true;
for (int i = 0; i < cValue.getElementSize(); i++) {
if (cValue.getElement(i) instanceof ContainerValue) {
visitingConfiguration = true;
}
cValue.getElement(i).accept(this);
if (i != cValue.getElementSize() - 1) {
this.value += " , ";
}
}
this.value += "))";
if (visitingNonNested) {
declaration += " = " + this.value;
} else if (visitingNested) {
compDeclaration += " = " + this.value;
}
visitingConatinerValue = false;
if (!visitingConfiguration) {
this.value = "";
}
}
}