public class UmlPackage extends UmlStructure
UmlStructure
(so we avoid code duplication).
Implementation note: We distinguish among hierarchy levels of packages by their UmlPackage.Kind
, to
ensure we can manage the actual UML model repositories in a loosely coupled way. This also allows
us to filter (opt in/out) parts of the in-memory model for e.g. validation, statistics or
document generation.
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 |
UmlPackage.Data
Data from the UML model repository specific to
UmlPackage . |
static class |
UmlPackage.Kind
Kind of UML package, reflecting hierarchical package containment and common properties for
the model content below a given level.
|
Modifier and Type | Field and Description |
---|---|
private java.util.Set<UmlPackage> |
_childPackages |
private java.util.Set<UmlClass> |
_classes |
private UmlPackage |
_containingPackage |
private UmlPackage.Data |
_data |
private int |
_depth |
private boolean |
_informative |
private UmlPackage.Kind |
_kind |
private static org.apache.log4j.Logger |
_logger |
private UmlModel |
_model |
private NamespaceInfo |
_namespaceInfo |
private Nature |
_nature |
private OwningWg |
_owner |
private VersionInfo |
_versionInfo |
static java.util.List<java.lang.String> |
STEREOTYPES
Allowed stereotypes for UML attributes.
|
CLASS_SEPARATOR, NULL_OBJ_NAME, PACKAGE_SEPARATOR
Modifier | Constructor and Description |
---|---|
(package private) |
UmlPackage(UmlModel model,
Nature nature)
Reserved for use by
UmlModel only: Creates the "null" model package of
nature ; it is the model's responsibility to add this instance where it wants to
(i.e., this constructor has no side effects on model ). |
|
UmlPackage(UmlModel model,
UmlObjectData objData,
UmlPackage.Data data)
Creates a model package (e.g.
|
private |
UmlPackage(UmlModel model,
UmlPackage containingPackage,
boolean isModelPackage,
UmlObjectData objData,
UmlPackage.Data data) |
|
UmlPackage(UmlPackage containingPackage,
UmlObjectData objData,
UmlPackage.Data data)
Creates a top-level or a regular package, and adds itself to
containingPackage . |
Modifier and Type | Method and Description |
---|---|
private UmlPackage |
addChildPackage(UmlPackage child)
Adds the non-null child package to this package and to the model, and returns the same
object.
|
(package private) UmlClass |
addClass(UmlClass clazz)
Adds the non-null class to this package and to the model (if the class' model is not
UmlPackage.Kind.NULL_MODEL ), and returns the same object. |
private boolean |
attributeNeedsInitialisation(UmlAttribute att,
java.lang.String expectedAttrName,
java.lang.String value) |
static UmlPackage |
basic(UmlModel model,
java.lang.String name)
Constructs minimal model package - useful for creation from profiles and testing.
|
static UmlPackage |
basic(UmlPackage containingPackage,
java.lang.String name)
Constructs minimal non-model package - useful for creation from profiles and testing.
|
private NamespaceInfo |
deduceNamespaceInfo()
Returns version information for this package, null if package does not contain a version
class.
|
private java.lang.String |
deduceUmlVersionForNamespace(UmlClass nsClass)
Needeed for IEC61850 namespaces; for CIM, namespace is deduced from UML version.
|
private VersionInfo |
deduceVersionInfo()
Returns version information for this package, null if package does not contain a version
class.
|
private boolean |
determineIsInformative(UmlPackage p) |
java.util.Set<UmlPackage> |
getChildPackages()
Returns all direct sub-packages.
|
java.util.Set<UmlPackage> |
getChildPackages(java.lang.String name)
Returns sub-packages with
name . |
java.util.Set<UmlClass> |
getClasses()
Returns all classes in this package.
|
UmlPackage |
getContainingPackage()
Returns the containing package, null for
UmlPackage.Kind.MODEL . |
int |
getDepth()
Returns the depth of this package, relative to the top-level package (i.e., for model package
returns -1, for top-level package returns 0, and for all other packages returns positive
offset relative to top-level package).
|
java.lang.String |
getExpectedNamespaceClassName()
Returns the expected name for the namespace class, as per IEC TC57 UMl models rules.
|
java.lang.String |
getExpectedVersionClassName()
Returns the expected name for the version class, as per IEC TC57 UMl models rules.
|
UmlKind |
getKind()
Returns kind of this UML object, as assigned by the application.
|
static java.util.List<UmlKind> |
getKinds(Nature nature)
Returns all available classifications (kinds) for packages.
|
UmlModel |
getModel()
Returns the model this structure belongs to.
|
NamespaceInfo |
getNamespaceInfo()
Returns the namespace information in case the relevant namespace class (for IEC61850) or
version class (for CIM) is defined in the package, null otherwise.
|
Nature |
getNature()
Returns the nature of this UML object, which determines the validation rules to apply, and
sometimes document generation formats.
|
OwningWg |
getOwner()
Returns the IEC working group owning this UML object, as calculated by the application based
on the UML model structure.
|
java.lang.String |
getQualifiedName()
Returns the name of this UML object combined with some container-related information (e.g.,
packageName.className, or containingPackageName.packageName).
|
VersionInfo |
getVersionInfo()
Returns the version information in case the relevant version class is defined in the package,
null otherwise.
|
private boolean |
isDocDiagramPackage() |
boolean |
isInformative()
Returns whether this UML object is informative (and thus should be ignored when generating
official IEC documents).
|
boolean |
isInOrUnderPackage(java.lang.String packageName)
Returns whether this package or anywhere below it (recursively) there is a package called
packageName . |
boolean |
isTop()
Returns whether this package is a top package (owned by a WG).
|
boolean |
isUnderPackage(java.lang.String packageName)
Returns whether anywhere below this package (recursively) there is a package called
packageName . |
void |
orderClasses(java.util.List<java.lang.String> uuids)
Orders classes in the order given in
uuids . |
boolean |
shouldExportDiagrams() |
java.lang.String |
toString() |
addDependency, addDependency, addDiagram, addDiagram, addSkippedUmlItem, addSkippedUmlItem, collectDependencyAfferentStructures, collectDependencyEfferentStructures, getDependenciesAsSource, getDependenciesAsTarget, getDiagrams, getSkippedUmlItems, isSelfDependent
addTaggedValue, classifyPerScope, classifyPerScopePerTag, classifyPerTag, collectDuplicateDescriptions, collectDuplicateNames, collectForScope, collectNames, collectQNames, findWithSameUuidAndLog, getAlias, getDescription, getHtmlDescription, getId, getName, getPredefinedTagNames, 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 final UmlPackage _containingPackage
private final UmlModel _model
private final UmlPackage.Data _data
private final UmlPackage.Kind _kind
private final int _depth
private final OwningWg _owner
private final Nature _nature
private final boolean _informative
private VersionInfo _versionInfo
private NamespaceInfo _namespaceInfo
private final java.util.Set<UmlClass> _classes
private final java.util.Set<UmlPackage> _childPackages
public UmlPackage(UmlModel model, UmlObjectData objData, UmlPackage.Data data)
model
. After creating this object, you may want to add tagged values, classes
and child packages (as well as other objects - see
UmlStructure.UmlStructure(UmlObjectData, UmlStructure.Data)
).model
- parent UML modelobjData
- common data for every UmlObject
s.data
- data proper to UmlPackage
.public UmlPackage(UmlPackage containingPackage, UmlObjectData objData, UmlPackage.Data data)
containingPackage
.
After creating this object, you may want to add tagged values, classes and child packages (as
well as other objects - see
UmlStructure.UmlStructure(UmlObjectData, UmlStructure.Data)
).containingPackage
- parent UML packageobjData
- common data for every UmlObject
.data
- data proper to UmlPackage
.UmlPackage(UmlModel model, Nature nature)
UmlModel
only: Creates the "null" model package of
nature
; it is the model's responsibility to add this instance where it wants to
(i.e., this constructor has no side effects on model
).model
- parent UML modelnature
- nature for this model package.private UmlPackage(UmlModel model, UmlPackage containingPackage, boolean isModelPackage, UmlObjectData objData, UmlPackage.Data data)
public static java.util.List<UmlKind> getKinds(Nature nature)
nature
- ignored in this methodpublic static UmlPackage basic(UmlModel model, java.lang.String name)
public static UmlPackage basic(UmlPackage containingPackage, java.lang.String name)
private boolean determineIsInformative(UmlPackage p)
private boolean isDocDiagramPackage()
public boolean shouldExportDiagrams()
public UmlPackage getContainingPackage()
UmlPackage.Kind.MODEL
.public boolean isTop()
public int getDepth()
UmlClass addClass(UmlClass clazz)
UmlPackage.Kind.NULL_MODEL
), and returns the same object. No-op in case clazz
has
already been added. Reserved for use by UmlClass
on its creation, and potentially by
tests.public java.util.Set<UmlClass> getClasses()
public void orderClasses(java.util.List<java.lang.String> uuids)
uuids
.public VersionInfo getVersionInfo()
public java.lang.String getExpectedVersionClassName()
private VersionInfo deduceVersionInfo()
public NamespaceInfo getNamespaceInfo()
public java.lang.String getExpectedNamespaceClassName()
private NamespaceInfo deduceNamespaceInfo()
private boolean attributeNeedsInitialisation(UmlAttribute att, java.lang.String expectedAttrName, java.lang.String value)
private java.lang.String deduceUmlVersionForNamespace(UmlClass nsClass)
private UmlPackage addChildPackage(UmlPackage child)
child
has already been added.public java.util.Set<UmlPackage> getChildPackages()
public java.util.Set<UmlPackage> getChildPackages(java.lang.String name)
name
. Normally, sub-packages should have name unique
within the containing package. However some tools allow this anomaly and we need to support
that kind of result (with a set returned).public boolean isUnderPackage(java.lang.String packageName)
packageName
. To include this package in the search, use
isInOrUnderPackage(String)
.public boolean isInOrUnderPackage(java.lang.String packageName)
packageName
. To exclude this package from the search, use
isUnderPackage(String)
.public UmlModel getModel()
Returns the model this package and all its recursive contents belongs to.
getModel
in class UmlStructure
public OwningWg getOwner()
UmlObject
getOwner
in interface UmlObject
getOwner
in class UmlStructure
public Nature getNature()
UmlObject
getNature
in interface UmlObject
getNature
in class UmlStructure
public boolean isInformative()
A package is considered as informative if any of the following is true:
UML.INF_PREFIX
,
UML.DetailedDiagrams
,
isInformative
in interface UmlObject
isInformative
in class UmlStructure
public UmlKind getKind()
UmlObject
getKind
in interface UmlObject
getKind
in class UmlStructure
public java.lang.String getQualifiedName()
UmlObject
getQualifiedName
in interface UmlObject
getQualifiedName
in class UmlStructure
public java.lang.String toString()
toString
in class java.lang.Object
Copyright 2009-2015 Tatjana (Tanja) Kostic