本文整理汇总了Java中net.ssehub.easy.varModel.model.values.ContainerValue类的典型用法代码示例。如果您正苦于以下问题:Java ContainerValue类的具体用法?Java ContainerValue怎么用?Java ContainerValue使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ContainerValue类属于net.ssehub.easy.varModel.model.values包,在下文中一共展示了ContainerValue类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getPipelineArtifact
import net.ssehub.easy.varModel.model.values.ContainerValue; //导入依赖的package包/类
/**
* Returns the pipeline artifact specification.
*
* @param config configuration the configuration of the model
* @param pipelineName the name of the pipeline
* @return the pipeline artifact in Maven notation (groupId:artifactId:version), <b>null</b> if not
* available / configured
*/
public static String getPipelineArtifact(Configuration config, String pipelineName) {
String artifact = null;
if (null != pipelineName && null != config) {
ContainerValue pipelines = getPipelines(config);
if (null != pipelines) {
for (int e = 0, n = pipelines.getElementSize(); null == artifact && e < n; e++) {
Value val = dereference(pipelines.getElement(e), config);
if (val instanceof CompoundValue) {
CompoundValue pipeline = (CompoundValue) val;
String name = pipeline.getStringValue(PIPELINE_NAME_VAR_NAME);
if (pipelineName.equals(name)) {
artifact = pipeline.getStringValue(PIPELINE_ARTIFACT_VAR_NAME);
}
} else {
getLogger().error("Pipeline value is not a compound rather than " + val.getType());
}
}
}
}
return artifact;
}
示例2: setValueForAvailableAlgorithms
import net.ssehub.easy.varModel.model.values.ContainerValue; //导入依赖的package包/类
/**
* Sets the specified value to all available algorithms of the given family element.
* @param value The value to set.
* @param familyElement A family element of a pipeline.
* @param slot The slot to configure with the given value.
* @throws ConfigurationException in case that the types of
* {@link #getDeclaration()} and <code>value</code> do not comply
*/
private void setValueForAvailableAlgorithms(Value value, IDecisionVariable familyElement, String slot)
throws ConfigurationException {
IDecisionVariable availableAlgos = familyElement.getNestedElement(QmConstants.SLOT_FAMILYELEMENT_AVAILABLE);
List<IDecisionVariable> algos = null;
if (null != availableAlgos) {
Value refferencedAlgos = availableAlgos.getValue();
if (null != refferencedAlgos && refferencedAlgos instanceof ContainerValue) {
ContainerValue container = (ContainerValue) refferencedAlgos;
algos = Utils.extractVariables(container, familyElement.getConfiguration());
}
}
// Set same value for all available algorithms
if (null != algos) {
for (IDecisionVariable algorithm : algos) {
IDecisionVariable algoSlot = algorithm.getNestedElement(slot);
if (null != algoSlot) {
algoSlot.setValue(value, getAssignmentState());
}
}
}
}
示例3: PipelineVisitor
import net.ssehub.easy.varModel.model.values.ContainerValue; //导入依赖的package包/类
/**
* Constructor for deciding whether runtime instances shall be mapped or whether this is not needed.
* @param pipeline The pipeline for which the information should be extracted.
* @param initializeRuntimeMapping <tt>true</tt> runtime variables will be mapped, <tt>false</tt> mapping is not
* needed. Mapping (<tt>true</tt>) is only needed during adaptation, no mapping (<tt>false</tt>) is needed
* in QM-Iconf application.
*/
public PipelineVisitor(IDecisionVariable pipeline, boolean initializeRuntimeMapping) {
this.initializeRuntimeMapping = initializeRuntimeMapping;
String pipelineName = VariableHelper.getName(pipeline);
if (null == pipelineName) {
pipelineName = pipeline.getDeclaration().getName();
}
container = new PipelineContentsContainer(pipelineName);
containerInitialized = false;
this.config = pipeline.getConfiguration();
ContainerValue sources = (ContainerValue) pipeline
.getNestedElement(QmConstants.SLOT_PIPELINE_SOURCES).getValue();
visitContainerValue(sources);
}
示例4: allInstances
import net.ssehub.easy.varModel.model.values.ContainerValue; //导入依赖的package包/类
/**
* Returns all instances of the given <code>type</code>.
*
* @param type the type to look for
* @return all instances (may be empty)
*/
public net.ssehub.easy.instantiation.core.model.vilTypes.Set<?> allInstances(TypeDescriptor<?> type) {
net.ssehub.easy.instantiation.core.model.vilTypes.Set<?> result = null;
if (type instanceof IvmlTypeDescriptor) {
IDatatype ivmlType = ((IvmlTypeDescriptor) type).getIvmlType();
Value val = configuration.getAllInstances(ivmlType);
if (val instanceof ContainerValue) {
ContainerValue cValue = (ContainerValue) val;
Set<Object> tmp = new HashSet<Object>(cValue.getElementSize());
for (int v = 0; v < cValue.getElementSize(); v++) {
resolveAndAddValue(cValue.getElement(v), tmp);
}
if (!tmp.isEmpty()) {
result = new SetSet<Object>(tmp, type);
}
}
}
if (null == result) {
result = new ArraySet<Object>(new Object[0], type);
}
return result;
}
示例5: 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);
}
}
}
}
示例6: collectReferences
import net.ssehub.easy.varModel.model.values.ContainerValue; //导入依赖的package包/类
/**
* Collects the references for a single variable.
*
* @param var the variable to collect the references for
* @param references the references in terms of a reference target - referring elements maps (modified as a side
* effect)
*/
private void collectReferences(IDecisionVariable var, Map<AbstractVariable, List<IDecisionVariable>> references) {
IDatatype type = var.getDeclaration().getType();
if (Reference.TYPE.isAssignableFrom(type)) {
collectReference(var, var.getValue(), references);
} else if (Container.TYPE.isAssignableFrom(type)) {
Value value = var.getValue();
if (value instanceof ContainerValue) { // NULLVALUE
ContainerValue val = (ContainerValue) value;
if (null != val) {
for (int e = 0; e < val.getElementSize(); e++) {
collectReference(var, val.getElement(e), references);
}
}
}
}
}
示例7: handleFurther
import net.ssehub.easy.varModel.model.values.ContainerValue; //导入依赖的package包/类
/**
* Assigns <code>value</code> to the further variables on <code>base</code> given in <code>names</code> at index
* positions larger than 0.
*
* @param base the base variable
* @param names the further variable names to initialize
* @param value the value to use for initialization
* @throws ConfigurationException in case that the configuration is not possible
*/
private void handleFurther(IDecisionVariable base, String[] names, Value value) throws ConfigurationException {
// value is reference?
IDatatype valueType = value.getType();
if (Reference.TYPE.isAssignableFrom(valueType)) { // prerequisite
valueType = Reference.dereference(valueType);
for (int t = 1; t < names.length; t++) {
IDecisionVariable further = findVariable(base, names[t]);
if (null != further && Reference.TYPE.isAssignableFrom(further.getDeclaration().getType())) {
// value is value, further is value -> assign
// value is collection, further is value -> assign first
if (Container.TYPE.isAssignableFrom(valueType)) {
ContainerValue cValue = (ContainerValue) value;
if (cValue.getElementSize() > 0) {
further.setValue(cValue.getElement(0), newState);
}
} else {
further.setValue(value, newState);
}
}
}
}
}
示例8: 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();
}
}
示例9: checkContainer
import net.ssehub.easy.varModel.model.values.ContainerValue; //导入依赖的package包/类
/**
* Checks a container for equality against expected values.
*
* @param expected the expected values
* @param value the potential container value
* @return a message if checking fails, <b>null</b> if ok
*/
private static String checkContainer(Object[] expected, Value value) {
String result = null;
if (value instanceof ContainerValue) {
ContainerValue cValue = (ContainerValue) value;
if (null != expected) {
if (expected.length == cValue.getElementSize()) {
if (Set.TYPE.isAssignableFrom(value.getType())) {
result = appendMessage(result, checkSetContainer(expected, cValue));
} else {
result = appendMessage(result, checkSequenceContainer(expected, cValue));
}
} else {
result = appendMessage(result, "lengths do not match");
}
} else {
result = appendMessage(result, "null expected but result obtained");
}
} else {
result = appendMessage(result, "value is not a container");
}
return result;
}
示例10: checkSetContainer
import net.ssehub.easy.varModel.model.values.ContainerValue; //导入依赖的package包/类
/**
* Checks a set container for equality against expected values.
*
* @param expected the expected values
* @param cValue the set container value
* @return a message if checking fails, <b>null</b> if ok
*/
private static String checkSetContainer(Object[] expected, ContainerValue cValue) {
String result = null;
for (int i = 0; i < expected.length; i++) {
String tmp = null;
// may also be done in linear time - reuse complex value test
for (int j = 0; j < cValue.getElementSize(); j++) {
tmp = checkContainerValue(expected[i], cValue.getElement(j));
if (null == tmp) {
break;
}
}
result = appendMessage(result, tmp);
}
return result;
}
示例11: checkContainerValue
import net.ssehub.easy.varModel.model.values.ContainerValue; //导入依赖的package包/类
/**
* Checks a single container value an expected value.
*
* @param expected the expected value
* @param eltVal the container element value
* @return a message if checking fails, <b>null</b> if ok
*/
private static String checkContainerValue(Object expected, Value eltVal) {
String result = null;
if (expected instanceof Value) {
if (!eltVal.equals(expected)) {
result = appendMessage(result, "values are not equal");
}
} else if (eltVal instanceof ContainerValue && expected.getClass().isArray()) {
result = appendMessage(result, checkContainer((Object[]) expected, eltVal));
} else {
if (!expected.equals(eltVal.getValue())) {
result = appendMessage(result, "values are not equal");
}
}
return result;
}
示例12: cloneContainerTest
import net.ssehub.easy.varModel.model.values.ContainerValue; //导入依赖的package包/类
/**
* Tests whether cloning of ContainerValue succeeds and if the cloned objects are the same.
* @throws ValueDoesNotMatchTypeException Must not occur, otherwise it the setValue method of {@link ContainerValue}
* is detecting duplicates but there are no duplicates.
*/
@Test
public void cloneContainerTest() throws ValueDoesNotMatchTypeException {
ContainerValue clone = (ContainerValue) value.clone();
Assert.assertNotSame(clone, value);
ContainerValue subValue = (ContainerValue) value.getElement(0);
int subsize = subValue.getElementSize();
Value integerValue = null;
try {
integerValue = ValueFactory.createValue(IntegerType.TYPE, "5");
} catch (ValueDoesNotMatchTypeException e) {
LOGGER.exception(e);
}
subValue.setValue(0, integerValue);
Assert.assertEquals(subsize, subValue.getElementSize());
Assert.assertNotSame(clone, value);
Assert.assertFalse("ContainerValue and its clone are the same!", value.equals(clone));
}
示例13: handleNextValue
import net.ssehub.easy.varModel.model.values.ContainerValue; //导入依赖的package包/类
/**
* Handles the next value by checking whether it was already added.
*
* @param value the value
* @param result the result container to be changed if not already added
* @param data the temporary data storing already added elements
* @param nextValues the next values to be considered for iteration
* @throws ValueDoesNotMatchTypeException if adding <code>value</code> to <code>result</code> is failing
*/
private void handleNextValue(Value value, ContainerValue result, Map<Object, Object> data,
List<Value> nextValues) throws ValueDoesNotMatchTypeException {
@SuppressWarnings("unchecked")
Set<Object> marking = (Set<Object>) data.get(DATA_CLOSURE_MARKED);
if (null == marking) {
marking = new HashSet<Object>();
data.put(DATA_CLOSURE_MARKED, marking);
}
if (!marking.contains(value)) {
nextValues.add(value);
if (null != result) {
result.addElement(value);
}
marking.add(value);
} else {
data.put(DATA_CLOSURE_CYCLIC, Boolean.TRUE);
}
}
示例14: postProcessResult
import net.ssehub.easy.varModel.model.values.ContainerValue; //导入依赖的package包/类
@Override
public void postProcessResult(EvaluationAccessor result, Map<Object, Object> data)
throws ValueDoesNotMatchTypeException {
Value rVal = result.getValue();
Object tmp = data.get(KEY_SORTED_BY);
if (null != tmp && rVal instanceof ContainerValue) {
ContainerValue container = (ContainerValue) rVal;
@SuppressWarnings("unchecked")
TreeMap<Value, List<Value>> keyMap = (TreeMap<Value, List<Value>>) tmp;
for (List<Value> valList : keyMap.values()) {
for (Value val: valList) {
container.addElement(val);
}
}
}
}
示例15: evaluate
import net.ssehub.easy.varModel.model.values.ContainerValue; //导入依赖的package包/类
@Override
public EvaluationAccessor evaluate(EvaluationAccessor operand, EvaluationAccessor[] arguments) {
// see VIL implementation
EvaluationAccessor result = null;
Value value = operand.getValue();
if (value instanceof ContainerValue) {
ContainerValue cont = (ContainerValue) value;
boolean hasDuplicates = false;
int size = cont.getElementSize();
if (size > 0) {
Set<Value> known = new HashSet<Value>(size);
for (int i = 0; !hasDuplicates && i < size; i++) {
hasDuplicates = !known.add(cont.getElement(i));
}
}
result = ConstantAccessor.POOL.getInstance().bind(
BooleanValue.toBooleanValue(hasDuplicates), operand.getContext());
}
return result;
}