public abstract class AbstractUmlObject extends java.lang.Object implements UmlObject
UmlObject
-s.
Implementation note: Uses composition with CommonDataSource
for all the fields
that are initialised in the constructor, and in toShortString(boolean, String, boolean)
relies on abstract methods, to be implemented by concrete subtypes.
Modifier and Type | Field and Description |
---|---|
private static org.apache.log4j.Logger |
_logger |
private UmlObjectData |
_objData |
private java.util.Map<java.lang.String,java.lang.String> |
_taggedValues |
static java.lang.String |
CLASS_SEPARATOR
Class separator, for qualified names.
|
static java.lang.String |
NULL_OBJ_NAME |
static java.lang.String |
PACKAGE_SEPARATOR
Package separator, for qualified names.
|
Modifier | Constructor and Description |
---|---|
protected |
AbstractUmlObject(UmlObjectData objData)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
java.lang.String |
addTaggedValue(java.lang.String name,
java.lang.String value)
Adds the UML tagged value (
name , value pair) to this UML object, as
defined in the UML model. |
static <T extends UmlObject> |
classifyPerScope(java.util.Collection<T> objects,
java.util.EnumSet<OwningWg> scope)
Returns map of objects indexed per
scope ; skips null objects. |
static <T extends UmlObject> |
classifyPerScopePerTag(java.util.Map<java.lang.String,java.util.Set<T>> tags,
java.util.EnumSet<OwningWg> scope)
Returns map of objects indexed per
scope , then per tag name tags ;
skips null objects. |
static <T extends UmlObject> |
classifyPerTag(java.util.Map<java.lang.String,java.util.Set<T>> tags,
java.util.EnumSet<OwningWg> scope)
Returns restricted map with objects that have given scope.
|
static <T extends UmlObject> |
collectDuplicateDescriptions(java.util.Collection<T> objects)
Returns those
objects that have the same description (trimmed), indexed by that
description; skips null objects. |
static <T extends UmlObject> |
collectDuplicateNames(java.util.Collection<T> objects)
Returns those
objects that have the same name, indexed by name; skips null
objects. |
static <T extends UmlObject> |
collectForScope(java.util.Collection<T> objects,
java.util.EnumSet<OwningWg> scope)
Returns list of objects that belong to a
scope ; skips null objects. |
static <T extends UmlObject> |
collectNames(java.util.Collection<T> objects)
Returns list of names.
|
static <T extends UmlObject> |
collectQNames(java.util.Collection<T> objects,
boolean includeOwner)
Returns list of qualified names, with prepended owner if
includeOwner=true . |
static <T extends UmlObject> |
findWithSameUuidAndLog(org.apache.log4j.Level level,
UmlObject asker,
java.util.Collection<T> objects,
java.lang.String uuid)
Returns the object with
uuid found in objects and logs the message
with level ; returns null otherwise. |
java.lang.String |
getAlias()
Returns the alias of this UML object, as defined in the UML model, empty string if not
defined.
|
TextDescription |
getDescription()
Returns the raw text description for this UML object, as defined in the UML model.
|
TextDescription |
getHtmlDescription()
Returns the formatted description for this UML object, as defined in the UML model.
|
java.lang.Integer |
getId()
Returns the local ID of this UML object.
|
abstract UmlKind |
getKind()
Returns kind of this UML object, as assigned by the application.
|
java.lang.String |
getName()
Returns the name of this UML object, as defined in the UML model.
|
abstract Nature |
getNature()
Returns the nature of this UML object, which determines the validation rules to apply, and
sometimes document generation formats.
|
abstract 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.
|
abstract java.lang.String |
getQualifiedName()
Returns the name of this UML object combined with some container-related information (e.g.,
packageName.className, or containingPackageName.packageName).
|
java.lang.String |
getSince()
Returns the version of the model in which this UML object has been introduced, as defined in
the UML model.
|
UmlStereotype |
getStereotype()
Returns the stereotype of this UML object, as defined in the UML model.
|
java.util.Map<java.lang.String,java.lang.String> |
getTaggedValues()
Returns all the tagged values of this UML object, as defined in the UML model.
|
java.util.Set<java.lang.String> |
getUnallowedTagNames()
Returns actual tag names defined for this object, but not found in
UmlObject.getPredefinedTagNames() . |
java.lang.String |
getUuid()
Returns the universally unique ID of this UML object.
|
UmlVisibility |
getVisibility()
Returns visibility of this UML object, as defined in the UML model.
|
boolean |
isDeprecated()
Returns whether this UML object is deprecated; this may be defined directly on this object
with the stereotype
UmlStereotype.DEPRECATED , or derived (for instance, for
association ends of an association). |
abstract boolean |
isInformative()
Returns whether this UML object is informative (and thus should be ignored when generating
official IEC documents).
|
static void |
saveTags(UmlObject o,
java.util.Map<java.lang.String,java.util.Set<UmlObject>> destination)
Stores object indexed by all of its tag names.
|
java.lang.String |
toShortString(boolean includeId,
boolean isNameQualified)
Returns the context as string, for logging purposes:
|
protected java.lang.String |
toShortString(boolean includeId,
java.lang.String qualifier,
boolean isNameQualified)
Similar to
toShortString(boolean, boolean) , but allows to specify a qualifier. |
protected void |
validateTag(java.lang.String name,
java.lang.String value)
Subclasses should overwride this method in case some validation about the tagged value is
needed before adding it.
|
private static java.lang.String |
wrapToStringIfNull(java.lang.Object o) |
private static final org.apache.log4j.Logger _logger
public static final java.lang.String NULL_OBJ_NAME
public static final java.lang.String PACKAGE_SEPARATOR
public static final java.lang.String CLASS_SEPARATOR
private final UmlObjectData _objData
private final java.util.Map<java.lang.String,java.lang.String> _taggedValues
protected AbstractUmlObject(UmlObjectData objData)
objData
- public static <T extends UmlObject> java.util.List<java.lang.String> collectNames(java.util.Collection<T> objects)
objects
, returns the name
NULL_OBJ_NAME
.public static <T extends UmlObject> java.util.List<java.lang.String> collectQNames(java.util.Collection<T> objects, boolean includeOwner)
includeOwner=true
. For
a null object in objects
, returns the name NULL_OBJ_NAME
.public static <T extends UmlObject> MapOfCollections<java.lang.String,T> collectDuplicateNames(java.util.Collection<T> objects)
objects
that have the same name, indexed by name; skips null
objects.public static <T extends UmlObject> MapOfCollections<java.lang.String,T> collectDuplicateDescriptions(java.util.Collection<T> objects)
objects
that have the same description (trimmed), indexed by that
description; skips null objects.public static <T extends UmlObject> java.util.Map<OwningWg,java.util.Collection<T>> classifyPerScope(java.util.Collection<T> objects, java.util.EnumSet<OwningWg> scope)
scope
; skips null objects. For a simple list,
use collectForScope(Collection, EnumSet)
.public static <T extends UmlObject> java.util.List<T> collectForScope(java.util.Collection<T> objects, java.util.EnumSet<OwningWg> scope)
scope
; skips null objects. For a map
indexed per scope, use classifyPerScope(Collection, EnumSet)
.public static <T extends UmlObject> java.util.Map<OwningWg,java.util.Map<java.lang.String,java.util.Set<T>>> classifyPerScopePerTag(java.util.Map<java.lang.String,java.util.Set<T>> tags, java.util.EnumSet<OwningWg> scope)
scope
, then per tag name tags
;
skips null objects. For a simple map indexed per tag name only, use
classifyPerTag(Map, EnumSet)
.public static <T extends UmlObject> java.util.Map<java.lang.String,java.util.Set<T>> classifyPerTag(java.util.Map<java.lang.String,java.util.Set<T>> tags, java.util.EnumSet<OwningWg> scope)
public static void saveTags(UmlObject o, java.util.Map<java.lang.String,java.util.Set<UmlObject>> destination)
public static <T extends UmlObject> T findWithSameUuidAndLog(org.apache.log4j.Level level, UmlObject asker, java.util.Collection<T> objects, java.lang.String uuid)
uuid
found in objects
and logs the message
with level
; returns null otherwise.public final java.lang.Integer getId()
UmlObject
In case of EA, this is an integer, assigned per EA type of tables (i.e., it's a counter) that cannot be changed and is a real persistent identifier for the given scope, so the application should be using this number to ensure uniqueness. However, some EA objects do not have this identifier at all, and the application is free to assign any number, assuming that that kind of UML object will not be cached on its own (but rather accessed from its container).
public java.lang.String getUuid()
UmlObject
In case of EA, this is the UUID used for manipulating diagram objects (in contrast to everythin else) and when manipulating XMI, but it can be stripped off on model import/export so it cannot be considered as persistent. In case there is not UUID assigned within the model, the application should assign a valid UUID.
public java.lang.String getSince()
UmlObject
public abstract OwningWg getOwner()
UmlObject
public abstract Nature getNature()
UmlObject
public abstract boolean isInformative()
UmlObject
isInformative
in interface UmlObject
public final UmlVisibility getVisibility()
UmlObject
getVisibility
in interface UmlObject
public abstract UmlKind getKind()
UmlObject
public final java.lang.String getName()
UmlObject
public java.lang.String getAlias()
UmlObject
public abstract java.lang.String getQualifiedName()
UmlObject
getQualifiedName
in interface UmlObject
public java.lang.String toShortString(boolean includeId, boolean isNameQualified)
UmlObject
owner nature [inf] [visibility] [qualifier] kind [stereotype] [q]name;
toShortString
in interface UmlObject
includeId
- whether to print IDisNameQualified
- whether to print qualified nameprotected java.lang.String toShortString(boolean includeId, java.lang.String qualifier, boolean isNameQualified)
toShortString(boolean, boolean)
, but allows to specify a qualifier.qualifier
- optional qualifier, specific to subtypeprivate static java.lang.String wrapToStringIfNull(java.lang.Object o)
public final TextDescription getDescription()
UmlObject
UmlObject.getHtmlDescription()
.getDescription
in interface UmlObject
public final TextDescription getHtmlDescription()
UmlObject
UmlObject.getDescription()
.getHtmlDescription
in interface UmlObject
public final UmlStereotype getStereotype()
UmlObject
getStereotype
in interface UmlObject
public boolean isDeprecated()
UmlStereotype.DEPRECATED
, or derived (for instance, for
association ends of an association).
This default implementation returns whether the stereotype string of this object contains the
string UmlStereotype.DEPRECATED
.
isDeprecated
in interface UmlObject
public java.util.Set<java.lang.String> getPredefinedTagNames()
This default implementation returns empty set, and should be overriden by subclasses that have something to return.
getPredefinedTagNames
in interface UmlObject
public final java.util.Set<java.lang.String> getUnallowedTagNames()
UmlObject
UmlObject.getPredefinedTagNames()
.getUnallowedTagNames
in interface UmlObject
public final java.lang.String addTaggedValue(java.lang.String name, java.lang.String value) throws InvalidTagException
UmlObject
name
, value
pair) to this UML object, as
defined in the UML model.addTaggedValue
in interface UmlObject
name
- tag name.value
- tag value.name
is a new tag, otherwise old value for name
thas has been overwritten with value
.InvalidTagException
- if either name
or value
is invalid.protected void validateTag(java.lang.String name, java.lang.String value)
name
- value
- public final java.util.Map<java.lang.String,java.lang.String> getTaggedValues()
UmlObject
getTaggedValues
in interface UmlObject
Copyright 2009-2015 Tatjana (Tanja) Kostic