public abstract class DmcObject extends Object implements Serializable
The DMC object is basically a typed holder for a collection of attributes. At this level, the DMC is abstract; it is the derived, auto-generated, Dark Matter Objects (DMOs) that give a DMC identity. Storing the attributes as a collection introduces a small amount of overhead to DMOs, but allows for operational concepts such as serialization, modification, formatting, cloning, staging etc. that are all provided automatically. It also allows for the use of DMOs in environments where accessing values by name (for example in GWT-based applications) is a necessity.
In addition to the attribute collection, the only constant overhead for a DMC object is the info Vector. The info Vector will contain various information at various times during the life cycle of an object, but will only take up additional space as required. Again, there is some overhead, but the benefits of that overhead are very useful.
There are currently 6 additional pieces of information stored for a DMC object:
| Modifier and Type | Field and Description |
|---|---|
static DmcAttributeInfo |
__objectClass |
protected Map<Integer,DmcAttribute<?>> |
attributes |
| Modifier | Constructor and Description |
|---|---|
|
DmcObject() |
protected |
DmcObject(String oc)
A protected constructor for derived classes that lets us set the object class
attribute from the most specific derived class.
|
| Modifier and Type | Method and Description |
|---|---|
<T extends DmcAttribute<?>> |
add(DmcAttributeInfo ai,
DmcAttribute<?> attr)
This method adds a value to a multi-valued attribute.
|
<T extends DmcAttribute<?>> |
add(String attrName,
DmcAttribute<?> attr)
This method adds a value to a multi-valued attribute.
|
void |
addAux(ClassDefinitionREF cd)
Adds the specified auxiliary class name to the object.
|
void |
addAux(String cd)
Adds the specified auxiliary class name to the object.
|
void |
addBackref(Modifier mod)
This method is used when we're tracking backrefs.
|
boolean |
allowsAttribute(DmcAttributeInfo ai)
We cycle through the DmcClassInfo associated with our object class and any auxiliary classes
and determine if the attribute is allowable.
|
boolean |
applyModifier(DmcTypeModifier mods)
This method applies the modification operations defined in the modifier to this object.
|
void |
clearReferenceInfo()
This method should be used with extreme caution! It will forceably unresolve all
reference attributes on the object and clear any back reference tracking information.
|
DmcObject |
cloneIt() |
<T extends DmcAttribute<?>> |
del(DmcAttributeInfo ai,
Object value)
This method deletes a value from a multi-valued attribute.
|
<T extends DmcAttribute<?>> |
del(String attrName,
Object value)
This method deletes a value from a multi-valued attribute.
|
protected void |
delFromEmptyAttribute(DmcAttribute<?> mod,
Object value)
This method is called in generated DMOs to handle the case where we're
using an empty DMO to create a modifier.
|
void |
deserializeIt(DmcInputStreamIF dis)
Deserializes an object.
|
boolean |
equals(Object obj)
This method performs an attribute by attribute comparison of this
object with the specified object and returns true if they are equal.
|
DmcAttribute<?> |
get(DmcAttributeInfo ai)
Returns the holder of the value for the named attribute.
|
DmcAttribute<?> |
get(Integer id)
Returns the holder of the value for the named attribute.
|
DmcAttribute<?> |
get(String name)
Returns the holder of value for the named attribute.
|
Map<Integer,DmcAttribute<?>> |
getAdditionalAttributes()
If this object has a class type of EXTENSIBLE, we return the set of
attributes that are not part of the class or its auxiliary classes
i.e.
|
DmcAttributeInfo |
getAttributeInfo(Integer id)
This method is generally used by object parsers to determine whether or not an attribute
is allowed by any of the classes in our objectClass attribute.
|
DmcAttributeInfo |
getAttributeInfo(String an)
This method is generally used by object parsers to determine whether or not an attribute
is natively supported by a DMO (in which case it returns the attribute info) or whether
the attribute in question is associated with an auxiliary class (in which case we get
the appropriate attribute info from the AttributeDefinition).
|
Iterator<DmcAttribute<?>> |
getAttributeIterator() |
ArrayList<String> |
getAttributeNames(boolean onlySV)
Retrieves the names of attributes in this object.
|
Map<Integer,DmcAttribute<?>> |
getAttributes() |
protected Map<Integer,HashMap<String,DmcAttributeValidator>> |
getAttributeValidators() |
DmcTypeModifierMV |
getBackref()
Returns the set of modifiers that indicate the back references to this object from other objects.
|
String |
getBackRefs()
Returns the references to this object formatted as a String.
|
ClassDefinitionREF |
getConstructionClass() |
DmcClassInfo |
getConstructionClassInfo() |
String |
getConstructionClassName() |
DmcContainerIF |
getContainer() |
DataTypeEnum |
getDataType() |
String |
getFullClassName() |
protected Object |
getLastValue()
This method is used within DmcObject when adding modify operations for add()/del().
|
DmcTypeModifierMV |
getModifier() |
abstract DmcObject |
getNew()
Auto-generated derived classes override this to return an empty instance
of themselves.
|
Iterator<ClassDefinitionREF> |
getObjectClass() |
protected Map<String,DmcObjectValidator> |
getObjectValidators() |
ArrayList<DmcObject> |
getReferringObjects()
Returns the objects that are referring to this object.
|
ArrayList<DmcObject> |
getReferringObjectsViaAttribute(DmcAttributeInfo ai) |
abstract DmcObject |
getSlice(DmcSliceInfo info)
Auto-generated derived classes override this to return an instance of themselves
with just the specified slice of attributes.
|
DmcObject |
getStagingObject(DmcTypeModifier mods)
This method will return a "staging" object associated with the proposed
modifications that are passed as argument.
|
boolean |
hasAux(String cd)
Determines if the specified class is in our ocl.
|
boolean |
hasValue(DmcAttributeInfo ai)
Indicates if there's an explicit value set for the specified attribute.
|
protected Boolean |
isModrec() |
boolean |
isReferenced() |
protected Boolean |
isStaging() |
protected void |
modrec(Boolean f) |
protected <T extends DmcAttribute<?>> |
nth(DmcAttributeInfo ai,
int index,
DmcAttribute<?> attr,
Object previous)
This method adds a value to a multi-valued attribute.
|
protected void |
nthNullFromEmptyAttribute(DmcAttributeInfo ai,
int idx)
This method is called in generated DMOs to handle the case where we're
using an empty DMO to create a modifier.
|
int |
numberOfAttributes() |
protected void |
populateSlice(DmcObject sliceContainer,
DmcSliceInfo info)
This method will take the specified slice of attributes out of this object and
populate the object that holds the slice.
|
int |
referenceCount() |
<T extends DmcAttribute<?>> |
rem(DmcAttributeInfo ai)
Removes the specified attribute from the object.
|
<T extends DmcAttribute<?>> |
rem(String attrName)
Removes the specified attribute from the object.
|
void |
removeAux(String cd)
Removes the specified auxiliary class name from the object.
|
void |
removeBackref(Modifier mod)
This method is used to remove back references from an object to the objects
that refer to it.
|
void |
resolveReferences(DmcNameResolverIF rx)
This method is generally called by code that uses a DmoObjectFactory to create DMO
instances.
|
protected void |
resolveReferences(DmcNameResolverIF rx,
boolean skipClass,
DmcNameClashResolverIF ncr)
We perform object resolution and optionally skip the class attribute.
|
void |
resolveReferences(DmcNameResolverWithClashSupportIF rx,
DmcNameClashResolverIF ncr)
This method is used to resolve references in names spaces where object names can clash.
|
void |
resolveReferencesExceptClass(DmcNameResolverIF rx)
This method is used to resolve references in environments where the complete schema
and its associated ClassDefinition objects are not available e.g.
|
void |
resolveReferencesExceptClass(DmcNameResolverWithClashSupportIF rx,
DmcNameClashResolverIF ncr)
This method is used to resolve references in environments where the complete schema
and its associated ClassDefinition objects are not available e.g.
|
void |
serializeIt(DmcOutputStreamIF dos)
Serializes the object using Dark Matter serialization techniques.
|
<T extends DmcAttribute<?>> |
set(DmcAttributeInfo ai,
DmcAttribute<?> attr)
This method sets the value of a single-valued attribute.
|
<T extends DmcAttribute<?>> |
set(String attrName,
DmcAttribute<?> attr)
This method sets the value of a single-valued attribute.
|
void |
setContainer(DmcContainerIF c)
Sets the container that's currently wrapping this object.
|
protected void |
setLastValue(Object val)
This method is called in the add()/del() methods on DMOs to store the last value that was
added/deleted from a multi-valued attribute.
|
void |
setModifier(DmcTypeModifierMV m)
This method sets the modifier of the object which will track all changes made
to the object.
|
DmcObject |
shallowCopy() |
protected void |
staging(Boolean f) |
boolean |
supportsBackrefTracking()
If a class of object doesn't support back reference tracking, it will overload this
method to return false.
|
String |
toCompactJSON() |
void |
toCompactJSON(StringBuffer sb) |
String |
toJSON() |
String |
toJSON(int padding,
String indent) |
void |
toJSON(StringBuffer sb,
int padding,
String indent) |
String |
toOIF()
Returns the object in Object Instance Format (OIF).
|
String |
toOIF(int padding)
Returns the object in Object Instance Format (OIF) with the attribute name left
justified in an amount of space indicated by padding.
|
String |
toOIFNoPadding()
Returns the object in Object Instance Format (OIF).
|
String |
toPersistentOIF()
Returns the object in Object Instance Format (OIF).
|
String |
toPersistentOIF(int padding)
Returns the object in Object Instance Format (OIF) with the attribute name left
justified in an amount of space indicated by padding.
|
String |
toString()
Returns the object in its native Object Instance Format.
|
void |
youAreDeleted()
This method should be called by whatever mechanism you're using to manage a collection
of DMOs.
|
public static final DmcAttributeInfo __objectClass
protected Map<Integer,DmcAttribute<?>> attributes
public DmcObject()
protected DmcObject(String oc)
oc - The class name.public int numberOfAttributes()
public Iterator<ClassDefinitionREF> getObjectClass()
public ClassDefinitionREF getConstructionClass()
public DmcClassInfo getConstructionClassInfo()
public Iterator<DmcAttribute<?>> getAttributeIterator()
public boolean supportsBackrefTracking()
public boolean allowsAttribute(DmcAttributeInfo ai)
ai - The attribute info for the attribute in question.public abstract DmcObject getNew()
public abstract DmcObject getSlice(DmcSliceInfo info)
info - the slice infoprotected Map<Integer,HashMap<String,DmcAttributeValidator>> getAttributeValidators()
protected Map<String,DmcObjectValidator> getObjectValidators()
public void setContainer(DmcContainerIF c)
c - the container.public DmcContainerIF getContainer()
public void addBackref(Modifier mod)
mod - the modifierpublic boolean isReferenced()
public int referenceCount()
public void removeBackref(Modifier mod)
mod - The modifier representing the removal operation for the back reference.public DmcTypeModifierMV getBackref()
public void setModifier(DmcTypeModifierMV m)
m - where modifications will be storedpublic DmcTypeModifierMV getModifier()
protected void setLastValue(Object val)
val - the last value added/deletedprotected Object getLastValue()
protected void modrec(Boolean f)
f - When a DMO is constructed with A DmcTypeModifier, this flag is set to true.protected Boolean isModrec()
protected void staging(Boolean f)
f - when a DMO is constructed in staging mode, this flag is set to true.protected Boolean isStaging()
public void youAreDeleted()
public DmcAttributeInfo getAttributeInfo(String an)
an - The attribute id.public DmcAttributeInfo getAttributeInfo(Integer id)
id - The attribute id.public String getConstructionClassName()
public String getFullClassName()
public void addAux(String cd) throws DmcValueException
cd - The auxiliary class name.DmcValueException - if class name not validpublic void addAux(ClassDefinitionREF cd) throws DmcValueException
cd - The auxiliary class name.DmcValueException - if class reference incorrectpublic void removeAux(String cd)
cd - The auxiliary class name.public boolean hasAux(String cd)
cd - The auxiliary class name.public DmcAttribute<?> get(String name)
name - The name of the attribute.public DmcAttribute<?> get(Integer id)
id - the id of the attribute.public DmcAttribute<?> get(DmcAttributeInfo ai)
ai - the attribute info definition.public boolean hasValue(DmcAttributeInfo ai)
ai - the attribute info definition.public ArrayList<String> getAttributeNames(boolean onlySV)
onlySV - if true, will only return single valued attribute names.public Map<Integer,DmcAttribute<?>> getAttributes()
public <T extends DmcAttribute<?>> T set(String attrName, DmcAttribute<?> attr) throws DmcValueException
T - the attribute typeattrName - The attribute name.attr - The attribute to be stored.DmcValueException - if value is incorrectpublic <T extends DmcAttribute<?>> T set(DmcAttributeInfo ai, DmcAttribute<?> attr) throws DmcValueException
T - the attribute typeai - the attribute info.attr - the attribute to be stored.DmcValueException - if value is incorrectpublic <T extends DmcAttribute<?>> T add(String attrName, DmcAttribute<?> attr) throws DmcValueException
T - the attribute typeattrName - The attribute name.attr - The attribute value to be stored.DmcValueException - if value is incorrectpublic <T extends DmcAttribute<?>> T add(DmcAttributeInfo ai, DmcAttribute<?> attr) throws DmcValueException
T - the attribute typeai - The attribute info.attr - The attribute value to be stored.DmcValueException - if value is incorrectpublic <T extends DmcAttribute<?>> T del(String attrName, Object value)
T - The classattrName - The attribute name.value - The value to be stored.protected void delFromEmptyAttribute(DmcAttribute<?> mod, Object value)
mod - The appropriately typed attribute holder.value - The value to be deleted.public <T extends DmcAttribute<?>> T del(DmcAttributeInfo ai, Object value)
T - The classai - the attribute info.value - the value to be stored.public <T extends DmcAttribute<?>> T rem(String attrName)
T - the attribute typeattrName - The attribute name.public <T extends DmcAttribute<?>> T rem(DmcAttributeInfo ai)
T - the attribute typeai - the attribute info.protected void nthNullFromEmptyAttribute(DmcAttributeInfo ai, int idx)
ai - The attribute infoidx - The index of the value to be deleted.protected <T extends DmcAttribute<?>> T nth(DmcAttributeInfo ai, int index, DmcAttribute<?> attr, Object previous) throws DmcValueException
T - the attribute typeai - The attribute info.index - The insertion index.attr - The attribute value to be stored.previous - The previous value.DmcValueException - if the value is incorrectpublic String toString()
public String getBackRefs()
References to: obj1 (1395193582) (ObjWithRefs) obj3 via SV objRefThe first line indicates the name of the object followed by the identity hash code for the object, which can be useful when determining the actual object instance you're referring to. The subsequent lines indicate the class of object doing the referring, its name and the attribute via which the reference is maintained.
public ArrayList<DmcObject> getReferringObjects()
public ArrayList<DmcObject> getReferringObjectsViaAttribute(DmcAttributeInfo ai)
ai - the attribute infopublic String toOIF()
public String toPersistentOIF()
public String toOIFNoPadding()
public String toOIF(int padding)
padding - The amount of space in which to display the attribute names.public String toPersistentOIF(int padding)
Only attributes with DataType PERSISTENT will be displayed.
padding - The amount of space in which to display the attribute names.public String toJSON()
public void toJSON(StringBuffer sb, int padding, String indent)
public String toCompactJSON()
public void toCompactJSON(StringBuffer sb)
public void resolveReferences(DmcNameResolverIF rx) throws DmcValueExceptionSet
rx - A name resolver.DmcValueExceptionSet - if there are problems resolvingpublic void resolveReferencesExceptClass(DmcNameResolverIF rx) throws DmcValueExceptionSet
rx - A name resolver.DmcValueExceptionSet - if there are problems resolvingpublic void resolveReferences(DmcNameResolverWithClashSupportIF rx, DmcNameClashResolverIF ncr) throws DmcValueExceptionSet
rx - the name resolverncr - the clash resolverDmcValueExceptionSet - if there are problems resolvingpublic void resolveReferencesExceptClass(DmcNameResolverWithClashSupportIF rx, DmcNameClashResolverIF ncr) throws DmcValueExceptionSet
rx - the name resolverncr - the clash resolverDmcValueExceptionSet - if there are problems resolvingprotected void resolveReferences(DmcNameResolverIF rx, boolean skipClass, DmcNameClashResolverIF ncr) throws DmcValueExceptionSet
rx - A name resolver.skipClass - Indicates whether we should skip the class attribute or not.ncr - the name clash resolverDmcValueExceptionSet - if there are problems resolvingpublic DmcObject cloneIt()
public DmcObject shallowCopy()
protected void populateSlice(DmcObject sliceContainer, DmcSliceInfo info)
sliceContainer - the container that will get the slice of attributes if they exist.info - The specification of the slice.public boolean applyModifier(DmcTypeModifier mods) throws DmcValueExceptionSet, DmcValueException
mods - The modifications to be applied.DmcValueExceptionSet - if multiple value problemsDmcValueException - if value problemspublic Map<Integer,DmcAttribute<?>> getAdditionalAttributes()
public DataTypeEnum getDataType()
public void serializeIt(DmcOutputStreamIF dos) throws Exception, DmcValueException
dos - Exception - if there are IO problemsDmcValueException - if there are value problemspublic void deserializeIt(DmcInputStreamIF dis) throws Exception
dis - the input streamException - if any problems encountered.public boolean equals(Object obj)
public void clearReferenceInfo()
public DmcObject getStagingObject(DmcTypeModifier mods)
mods - the modification that might be appliedCopyright © 2023. All rights reserved.