public class AttributeValues
extends java.lang.Object
AttributeValues. However, this is indirectly supported
by this class by support for storing values (toString(Value)),
support for storing strings read from a persistent storage
(addUnresolved(String, List) and by finally resolving the
values in the context of a given model (resolveUsing(Project, boolean).| Modifier and Type | Class and Description |
|---|---|
private class |
AttributeValues.ResolutionVisitor
A visitor for resolving attribute values.
|
| Modifier and Type | Field and Description |
|---|---|
private java.util.Map<java.lang.String,java.util.List<java.lang.String>> |
unresolvedAssignments |
private java.util.Map<net.ssehub.easy.varModel.model.Attribute,java.util.List<net.ssehub.easy.varModel.model.values.Value>> |
valueAssignments |
| Constructor and Description |
|---|
AttributeValues()
Creates a new set of attribute values.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addUnresolved(java.lang.String attribute,
java.util.List<java.lang.String> values)
Adds unresolved attributes and values.
|
void |
addValue(net.ssehub.easy.varModel.model.Attribute attribute,
net.ssehub.easy.varModel.model.values.Value value)
Adds a
value for a given attribute. |
private static void |
appendError(java.lang.StringBuilder builder,
java.lang.String text)
Appends
text to builder. |
void |
clear()
Deletes all value assignments.
|
boolean |
contains(net.ssehub.easy.varModel.model.Attribute attribute)
Returns whether the given
attribute is contained in this value set. |
java.util.Iterator<net.ssehub.easy.varModel.model.Attribute> |
getAttributes()
Returns all attributes for which value assignments are stored.
|
java.util.List<net.ssehub.easy.varModel.model.Attribute> |
getAttributesAsList()
Returns all attributes for which value assignments are stored.
|
java.util.Set<net.ssehub.easy.varModel.model.Attribute> |
getAttributesAsSet()
Returns all attributes for which value assignments are stored.
|
int |
getAttributesCount()
Returns the number of attributes for which value assignments are
stored in this instance.
|
net.ssehub.easy.varModel.model.values.Value |
getAttributeValue(net.ssehub.easy.varModel.model.Attribute attribute,
int index)
Returns the specific value assigned to
attribute. |
int |
getAttributeValuesCount(net.ssehub.easy.varModel.model.Attribute attribute)
Returns the number of values assigned to
attribute. |
boolean |
hasValue(net.ssehub.easy.varModel.model.AbstractVariable attribute,
net.ssehub.easy.varModel.model.values.Value value)
Returns whether there is an assignment of
value to attribute. |
boolean |
isEmpty()
Returns whether there are value assignments.
|
static boolean |
isEmpty(AttributeValues values)
Returns whether there are value assignments in
values. |
void |
removeValue(net.ssehub.easy.varModel.model.Attribute attribute,
net.ssehub.easy.varModel.model.values.Value value)
Remove a given
value from the value assignment of
attribute. |
void |
resolveUsing(net.ssehub.easy.varModel.model.Project project,
boolean clear)
Resolve unresolved attributes in
project. |
void |
setValue(net.ssehub.easy.varModel.model.Attribute attribute,
net.ssehub.easy.varModel.model.values.Value value,
int index)
Adds a
value for a given attribute. |
void |
setValues(net.ssehub.easy.varModel.model.Attribute target,
net.ssehub.easy.varModel.model.Attribute source)
Transfers all value assignments from
source to target. |
java.lang.String |
toString()
Returns a textual description of this object.
|
static java.lang.String |
toString(net.ssehub.easy.varModel.model.values.Value value)
Turns a
value into a string. |
private java.util.Map<net.ssehub.easy.varModel.model.Attribute,java.util.List<net.ssehub.easy.varModel.model.values.Value>> valueAssignments
private java.util.Map<java.lang.String,java.util.List<java.lang.String>> unresolvedAssignments
public void setValue(net.ssehub.easy.varModel.model.Attribute attribute,
net.ssehub.easy.varModel.model.values.Value value,
int index)
throws AttributeException
value for a given attribute.attribute - the attribute to assign the value forvalue - the value to assignindex - the index of the value to be returnedjava.lang.IndexOutOfBoundsException - in case that index<0
|| index>=getAttributeValuesCount(Attribute) with
called same attribute (!)AttributeException - in case that value cannot be assigned to attributepublic void addValue(net.ssehub.easy.varModel.model.Attribute attribute,
net.ssehub.easy.varModel.model.values.Value value)
throws AttributeException
value for a given attribute.attribute - the attribute to assign the value forvalue - the value to assignAttributeException - in case that value cannot be assigned to attributepublic void removeValue(net.ssehub.easy.varModel.model.Attribute attribute,
net.ssehub.easy.varModel.model.values.Value value)
value from the value assignment of
attribute.attribute - the attribute to remove the value fromvalue - the value to be removedpublic int getAttributesCount()
public java.util.Iterator<net.ssehub.easy.varModel.model.Attribute> getAttributes()
public java.util.List<net.ssehub.easy.varModel.model.Attribute> getAttributesAsList()
public java.util.Set<net.ssehub.easy.varModel.model.Attribute> getAttributesAsSet()
public int getAttributeValuesCount(net.ssehub.easy.varModel.model.Attribute attribute)
attribute.attribute - the attribute to return the number of values for-1 if
attribute does not existpublic net.ssehub.easy.varModel.model.values.Value getAttributeValue(net.ssehub.easy.varModel.model.Attribute attribute,
int index)
attribute.attribute - the attribute to return the number of values forindex - the index of the value to be returnedattribute
does not existjava.lang.IndexOutOfBoundsException - in case that index<0
|| index>=getAttributeValuesCount(Attribute) with
called same attribute (!)public boolean hasValue(net.ssehub.easy.varModel.model.AbstractVariable attribute,
net.ssehub.easy.varModel.model.values.Value value)
value to attribute.attribute - the attribute to check (we use the more common type to avoid superfluous
type casts in the caller)value - the value to check for within attributetrue if value is set for attribute, false elsepublic void clear()
public boolean isEmpty()
true if there are no value assignments, false elsepublic static boolean isEmpty(AttributeValues values)
values.values - the value assignments instance to be testedtrue if there are no value assignments
(or values == null, false elsepublic void setValues(net.ssehub.easy.varModel.model.Attribute target,
net.ssehub.easy.varModel.model.Attribute source)
source to target.target - the target of the transfer (value assignments may be modified)source - the attribute where to take the assginments frompublic boolean contains(net.ssehub.easy.varModel.model.Attribute attribute)
attribute is contained in this value set.attribute - the attribute to search fortrue if it is contained, false elsepublic java.lang.String toString()
toString in class java.lang.Objectpublic void resolveUsing(net.ssehub.easy.varModel.model.Project project,
boolean clear)
throws AttributeException
project. In case that
resolution works properly, valueAssignments will be changed
and unresolvedAssignments will be set to null.project - the project used to resolve unresolved
attributes added by addUnresolved(String, List)clear - clear the contents of this instance before resolvingAttributeException - in case that the resolution fails and
this instance was not changedprivate static void appendError(java.lang.StringBuilder builder,
java.lang.String text)
text to builder.builder - the builder to append totext - the text to be appendedpublic void addUnresolved(java.lang.String attribute,
java.util.List<java.lang.String> values)
resolveUsing(Project, boolean).attribute - the name of the attributevalues - the individual valuespublic static java.lang.String toString(net.ssehub.easy.varModel.model.values.Value value)
value into a string. Do not directly print a
Value.value - the value to be convertedCopyright © 2009 - 2018 SSE. All Rights Reserved.