public class UmlAttribute extends AbstractUmlObject
Implementation note: We distinguish among kinds of attributes by their UmlAttribute.Kind
, which
implements the UmlKind
interface and internally piggy-backs kinds of UmlClass
.
Knowing the kinds of attributes allows us to do model validation and also to correctly print
documentation (and on the fly, calculate detailed statistics).
A cleaner design would be to effectively create subclasses instead of using the above kinds, but it would be overkill for minor differences in functionality per kind.
Modifier and Type | Class and Description |
---|---|
static class |
UmlAttribute.Data
Data from the UML model repository specific to
UmlAttribute . |
static class |
UmlAttribute.Kind
Kinds of UML attributes - correspond mainly to the kind of the class used as the attribute's
type.
|
Modifier and Type | Field and Description |
---|---|
private UmlClass |
_containingClass |
private UmlAttribute.Data |
_data |
private NameDecomposition |
_decomposedTerms |
private java.lang.Integer |
_initValueAsInteger |
private UmlKind |
_kind |
private static org.apache.log4j.Logger |
_logger |
private java.util.List<UmlConstraint> |
_ownConstraints |
private java.util.List<PresenceCondition> |
_presConditions |
private UmlClass |
_type |
private ValueRange |
_valueRange |
private static java.util.List<java.lang.String> |
CIM_TAGS
Allowed tags for CIM attributes.
|
static int |
DO_MAX_LENGTH |
private static java.util.List<java.lang.String> |
IEC61850_TAGS
Allowed tags for IEC 61850 attributes.
|
static java.util.List<java.lang.String> |
STEREOTYPES
Allowed stereotypes for UML attributes.
|
CLASS_SEPARATOR, NULL_OBJ_NAME, PACKAGE_SEPARATOR
Constructor and Description |
---|
UmlAttribute(UmlClass containingClass,
UmlClass type,
UmlObjectData objData,
UmlAttribute.Data data)
Intended to be called by
UmlClass and tests only. |
Modifier and Type | Method and Description |
---|---|
UmlConstraint |
addOwnConstraint(UmlObjectData objData,
UmlConstraint.Data data)
Creates attribute constraint from arguments, adds it to this attribute and returns the new
constraint.
|
(package private) static UmlAttribute |
basic(UmlClass containingClass,
UmlClass type,
java.lang.String name)
For tests only: Constructs attribute (that is not literal) with given name.
|
(package private) static UmlAttribute |
basic(UmlClass containingClass,
UmlClass type,
java.lang.String name,
java.lang.String initVal)
For tests only: Constructs attribute with given constant value (static and const true).
|
(package private) static UmlAttribute |
basic(UmlClass containingClass,
UmlClass type,
java.lang.String name,
UmlMultiplicity mult)
For tests only: Constructs attribute with given multiplicity.
|
(package private) static UmlAttribute |
basicLiteral(UmlClass containingClass,
java.lang.String name)
For tests only: Constructs literal with given name.
|
private UmlAttribute.Kind |
determineKind(UmlClass containingClass,
UmlClass type) |
boolean |
displayEmptyValue()
Returns true if this is an enumeration literal whose name needs to be translated as empty
string in SCL XML, or simply an attribute with a default value that again needs to be
translated as empty string in SCL XML (and in both Word and XML auto-generated docs).
|
static java.util.Collection<UmlAttribute> |
findAbbreviationLiterals(java.util.Collection<UmlAttribute> attributes) |
static java.util.Collection<UmlAttribute> |
findEnumLiterals(java.util.Collection<UmlAttribute> attributes) |
static java.util.Collection<UmlAttribute> |
findPresenceConditionLiterals(java.util.Collection<UmlAttribute> attributes) |
java.util.Collection<UmlAttribute> |
getAllSiblings()
Returns all (native and inherited) sibling attributes.
|
java.lang.String |
getArrayBounds()
Returns formatted string "minId...maxId" created from attribute constraints if existing,
empty string otherwise.
|
java.lang.String |
getArrayBoundsWithBrackets() |
(package private) java.util.List<UmlConstraint> |
getConstraintsFromClass()
Returns constraints defined on the containing class, involving this attribute.
|
java.util.Map<java.lang.String,java.lang.String> |
getConstraintValues()
Returns map of {name, constraint} pairs defined as attribute constraints.
|
UmlClass |
getContainingClass()
Returns class containing this attribute.
|
java.util.List<PresenceCondition> |
getDsPresConditions(UmlClass context)
(IEC 61850) Returns derived statistics presence conditions.
|
int |
getEaTypeId()
|
java.lang.String |
getEaTypeInfo()
Returns known (string) info from EA; useful to display in case the type of this attribute in
EA model is not a valid UML class, so the model can be corrected.
|
java.lang.String |
getEaTypeName()
|
java.lang.Integer |
getInitialValueAsInteger()
Returns the initial value if it can be interpreted as integer, null otherwise.
|
java.lang.String |
getInitValue()
|
java.lang.String |
getInitValueWithPotentialOverrideForSCL()
(Special handling for IEC61850) Returns empty string as initial value for the case of an
attribute that returns
true from displayEmptyValue() . |
UmlKind |
getKind()
Returns kind of this UML object, as assigned by the application.
|
static java.util.List<UmlKind> |
getKinds(Nature nature)
Returns available classifications (kinds) for attributes.
|
UmlMultiplicity |
getMultiplicity()
|
NameDecomposition |
getNameDecomposition()
Equivalent to
getNameDecomposition(null) . |
NameDecomposition |
getNameDecomposition(java.util.Map<java.lang.String,java.lang.String> sortedAbbrTerms)
In case of a data object (attribute on LN, in IEC61850), returns decomposition of the
attribute name to abbreviated terms, null otherwise.
|
Nature |
getNature()
Returns the nature of this UML object, which determines the validation rules to apply, and
sometimes document generation formats.
|
java.util.List<UmlConstraint> |
getOwnConstraints()
Returns constraints defined on this attribute.
|
OwningWg |
getOwner()
Returns the IEC working group owning this UML object, as calculated by the application based
on the UML model structure.
|
java.util.Set<java.lang.String> |
getPredefinedTagNames()
Returns allowed tag names, as expected to be found in the UML model.
|
java.util.List<PresenceCondition> |
getPresConditions() |
java.lang.String |
getQualifiedName()
Returns the name of this UML object combined with some container-related information (e.g.,
packageName.className, or containingPackageName.packageName).
|
UmlAttribute |
getSiblingToMoveAfter()
Returns (native or inherited) sibling attribute whose name is defined as value of the tag
UML.TAG_moveAfter if found, null otherwise; in case there are multiple sibling
attributes with that same name, returns the first one. |
UmlClass |
getType()
Returns
UmlClass used as type of this attribute for a non-literal, null otherwise. |
ValueRange |
getValueRange()
Returns value range if specified, null otherwise.
|
boolean |
hasConstValue()
Returns whether the attribute has a constant value (for all instances of the class).
|
boolean |
hasDefaultValue()
Returns whether the attribute has a default initial value (semantic: value applies to any
instance of a class and can be changed later).
|
(package private) boolean |
hasInitialValue()
Returns whether this attribute has an initial value, as defined in UML repository.
|
boolean |
hasInitialValueAsInteger()
Returns whether the initial value (when present) was interpreted as integer.
|
boolean |
hasSuperfluousType()
|
boolean |
hasValueRange()
Returns whether the attribute has a range specified.
|
private java.lang.Integer |
initInitialValueAsInteger(java.lang.String initValue) |
private ValueRange |
initValueRange(java.lang.String initValue) |
boolean |
isConditional()
Returns whether this attribute has presence condition derived from its containing class.
|
boolean |
isConst()
|
boolean |
isDO()
IEC61850
|
boolean |
isInformative()
Returns whether this UML object is informative (and thus should be ignored when generating
official IEC documents).
|
boolean |
isLiteral()
CIM and IEC61850
|
boolean |
isMultivalued()
Returns whether this attribute is multivalued.
|
boolean |
isOptional()
Returns whether the multiplicity is optional.
|
boolean |
isPublic()
Returns whether this attribute is public.
|
boolean |
isStatic()
|
java.lang.String |
toString() |
addTaggedValue, classifyPerScope, classifyPerScopePerTag, classifyPerTag, collectDuplicateDescriptions, collectDuplicateNames, collectForScope, collectNames, collectQNames, findWithSameUuidAndLog, getAlias, getDescription, getHtmlDescription, getId, getName, getSince, getStereotype, getTaggedValues, getUnallowedTagNames, getUuid, getVisibility, isDeprecated, saveTags, toShortString, toShortString, validateTag
private static final org.apache.log4j.Logger _logger
public static final java.util.List<java.lang.String> STEREOTYPES
private static final java.util.List<java.lang.String> IEC61850_TAGS
private static final java.util.List<java.lang.String> CIM_TAGS
public static final int DO_MAX_LENGTH
private final UmlClass _containingClass
private final UmlClass _type
private final UmlAttribute.Data _data
private final UmlKind _kind
private final ValueRange _valueRange
private final java.lang.Integer _initValueAsInteger
private final java.util.List<UmlConstraint> _ownConstraints
private java.util.List<PresenceCondition> _presConditions
private NameDecomposition _decomposedTerms
UmlAttribute(UmlClass containingClass, UmlClass type, UmlObjectData objData, UmlAttribute.Data data)
UmlClass
and tests only.java.lang.IllegalArgumentException
- if containingClass
and non-null type
are from different
models, or if type
is null and containingClass
is not
an enumerated type.public static java.util.List<UmlKind> getKinds(Nature nature)
nature
- ignored in this method.public static java.util.Collection<UmlAttribute> findEnumLiterals(java.util.Collection<UmlAttribute> attributes)
public static java.util.Collection<UmlAttribute> findAbbreviationLiterals(java.util.Collection<UmlAttribute> attributes)
public static java.util.Collection<UmlAttribute> findPresenceConditionLiterals(java.util.Collection<UmlAttribute> attributes)
static UmlAttribute basic(UmlClass containingClass, UmlClass type, java.lang.String name)
static UmlAttribute basicLiteral(UmlClass containingClass, java.lang.String name)
static UmlAttribute basic(UmlClass containingClass, UmlClass type, java.lang.String name, UmlMultiplicity mult)
static UmlAttribute basic(UmlClass containingClass, UmlClass type, java.lang.String name, java.lang.String initVal)
private UmlAttribute.Kind determineKind(UmlClass containingClass, UmlClass type)
private ValueRange initValueRange(java.lang.String initValue)
private java.lang.Integer initInitialValueAsInteger(java.lang.String initValue)
public UmlClass getContainingClass()
public UmlClass getType()
UmlClass
used as type of this attribute for a non-literal, null otherwise.public boolean isConst()
public boolean isStatic()
public UmlMultiplicity getMultiplicity()
public java.lang.String getInitValue()
public java.lang.String getInitValueWithPotentialOverrideForSCL()
true
from displayEmptyValue()
. Otherwise,
returns getInitValue()
.public int getEaTypeId()
public java.lang.String getEaTypeName()
public java.lang.String getEaTypeInfo()
public boolean hasSuperfluousType()
public boolean isOptional()
public boolean isMultivalued()
public boolean isPublic()
public boolean isLiteral()
public boolean isDO()
public java.util.List<PresenceCondition> getPresConditions()
java.util.List<UmlConstraint> getConstraintsFromClass()
public boolean isConditional()
public java.util.List<PresenceCondition> getDsPresConditions(UmlClass context)
context
- class for which this attribute is considered; i.e., it could be native to
context
or inherited (from a class other than context
).public NameDecomposition getNameDecomposition()
getNameDecomposition(null)
.public NameDecomposition getNameDecomposition(java.util.Map<java.lang.String,java.lang.String> sortedAbbrTerms)
sortedAbbrTerms
- (potentially null) abbreviated terms sorted correctly for comparison; if null,
this instance needs to find access to those abbreviated terms internally.public UmlConstraint addOwnConstraint(UmlObjectData objData, UmlConstraint.Data data)
public java.util.List<UmlConstraint> getOwnConstraints()
public java.lang.String getArrayBounds()
public java.lang.String getArrayBoundsWithBrackets()
public java.util.Map<java.lang.String,java.lang.String> getConstraintValues()
boolean hasInitialValue()
public boolean hasValueRange()
public ValueRange getValueRange()
public boolean hasConstValue()
public boolean hasDefaultValue()
public java.lang.Integer getInitialValueAsInteger()
public boolean hasInitialValueAsInteger()
public UmlAttribute getSiblingToMoveAfter()
UML.TAG_moveAfter
if found, null otherwise; in case there are multiple sibling
attributes with that same name, returns the first one.public boolean displayEmptyValue()
public java.util.Collection<UmlAttribute> getAllSiblings()
public OwningWg getOwner()
UmlObject
getOwner
in interface UmlObject
getOwner
in class AbstractUmlObject
public Nature getNature()
Returns the nature of containing clas.
getNature
in interface UmlObject
getNature
in class AbstractUmlObject
public boolean isInformative()
Returns true if the containing class is informative.
isInformative
in interface UmlObject
isInformative
in class AbstractUmlObject
public UmlKind getKind()
UmlObject
getKind
in interface UmlObject
getKind
in class AbstractUmlObject
public java.lang.String getQualifiedName()
UmlObject
getQualifiedName
in interface UmlObject
getQualifiedName
in class AbstractUmlObject
public java.util.Set<java.lang.String> getPredefinedTagNames()
AbstractUmlObject
This default implementation returns empty set, and should be overriden by subclasses that have something to return.
getPredefinedTagNames
in interface UmlObject
getPredefinedTagNames
in class AbstractUmlObject
public java.lang.String toString()
toString
in class java.lang.Object
Copyright 2009-2015 Tatjana (Tanja) Kostic