public abstract class COSBasedObject extends Object implements de.intarsys.tools.attribute.IAttributeSupport, ICOSObjectListener
The base COSObject will represent the state while this wrapper will
provide the behavior.
The COSBasedObject and its base COSObject are always closely
related, all changes are immediately reflected in both objects.
The COSBasedObject uses a META framework that ensures identity (you
will always get the identical COSBasedObject for a COSObject
created via META) and defines the lifecycle of the COSBasedObject.
A COSBasedObject should always be created using
META.createNew or META.createFromCos.
A COSBasedObject based on a COSDictionary can use some
convenience methods for generic access to its fields. As a convention, filed
names are always declared with the associated COSBasedObject as
public static final COSName DK_.
The COSBasedObject implements IAttributeSupport. Client code
can use this feature to transparently associate objects with objects from
client code, for example for caching or client defined relationships.
| Modifier and Type | Class and Description |
|---|---|
static class |
COSBasedObject.MetaClass
The meta class implementation
|
| Modifier and Type | Field and Description |
|---|---|
static COSBasedObject.MetaClass |
META
The meta class instance
|
| Modifier and Type | Method and Description |
|---|---|
void |
changed(COSObject pObject,
Object slot,
Object oldValue,
Object newValue)
A COSObject has changed its internal state.
|
COSArray |
cosGetArray()
Get the base object as a
COSArray. |
COSDictionary |
cosGetDict()
Get the base object as a
COSDictionary. |
COSDocument |
cosGetDoc()
The
COSDocument for this. |
COSObject |
cosGetField(COSName name)
|
COSObject |
cosGetObject()
The base
COSObject for this. |
COSStream |
cosGetStream()
Get the base object as a
COSStream. |
boolean |
cosHasField(COSName name)
Answer
true if this has a field named name. |
COSObject |
cosRemoveField(COSName name)
Remove a field in this.
|
COSObject |
cosSetField(COSName name,
COSObject cosObj)
Set a field value in this.
|
Object |
getAttribute(Object key) |
boolean |
getFieldBoolean(COSName name,
boolean defaultValue)
|
CDSDate |
getFieldDate(COSName name,
CDSDate defaultValue)
|
float |
getFieldFixed(COSName name,
float defaultValue)
|
float[] |
getFieldFixedArray(COSName name,
float[] defaultValue)
|
int |
getFieldInt(COSName name,
int defaultValue)
|
String |
getFieldMLString(COSName name,
String defaultValue)
|
String |
getFieldString(COSName name,
String defaultValue)
|
void |
invalidateCaches()
Invalidate all local caches as the base object may have changed.
|
Object |
removeAttribute(Object key) |
Object |
setAttribute(Object key,
Object value) |
COSObject |
setFieldBoolean(COSName name,
boolean value)
Set the value of field
namewithin this. |
COSObject |
setFieldFixed(COSName name,
float value)
Set the value of field
namewithin this. |
COSObject |
setFieldInt(COSName name,
int value)
Set the value of field
namewithin this. |
COSObject |
setFieldMLString(COSName name,
String value)
Set the value of field
namewithin this. |
COSObject |
setFieldName(COSName name,
String value)
Set the value of field
namewithin this. |
COSObject |
setFieldObject(COSName name,
COSBasedObject value)
Set the value of field
namewithin this. |
COSObject |
setFieldString(COSName name,
String value)
Set the value of field
namewithin this. |
String |
toString() |
public static final COSBasedObject.MetaClass META
public void changed(COSObject pObject, Object slot, Object oldValue, Object newValue)
ICOSObjectListenerCOSObject
this may be a change in containment (slot == COSObject.SLOT_CONTAINER).
For containers itself, this may be a change in the collection of
contained objects. For dictionaries, slot will be the COSName of
the changed entry, for arrays slot will be the Integer key. A
stream may indicate a change in its byte content using (slot ==
COSStream.SLOT_BYTES).
A slot value of null may indicate a "changed all" event.
For example you can expect for a clear operation on an
array only a single "changed all" event.
changed in interface ICOSObjectListenerpObject - The object that has changedslot - The slot in the object that has changed (or null for
unspecified change).oldValue - The old value of the slot if known.newValue - The new value of the slot if known.public COSArray cosGetArray()
COSArray.
This will throw a ClassCastException if the base type is not
appropriate!
COSArray.public COSDictionary cosGetDict()
COSDictionary.
This will throw a ClassCastException if the base type is not
appropriate!
COSDictionary.public COSDocument cosGetDoc()
COSDocument for this.COSDocument for this.public COSObject cosGetField(COSName name)
COSObject associated with name in the receiver
or COSNull.
This method requires the base object to be a COSDictionary.
name - The COSDictionary field to readCOSObject associated with name in the
receiver or COSNull.public COSObject cosGetObject()
COSObject for this.COSObject for this.public COSStream cosGetStream()
COSStream.
This will throw a ClassCastException if the base type is not
appropriate!
COSStream.public boolean cosHasField(COSName name)
true if this has a field named name.
This method requires the base object to be a COSDictionary.
name - the field to checktrue if this has a field named
name.public COSObject cosRemoveField(COSName name)
This method requires the base object to be a COSDictionary.
name - the field to remove from the receiverpublic COSObject cosSetField(COSName name, COSObject cosObj)
This method requires the base object to be a COSDictionary.
name - The field to setcosObj - The object to set in the fieldpublic Object getAttribute(Object key)
getAttribute in interface de.intarsys.tools.attribute.IAttributeSupportpublic boolean getFieldBoolean(COSName name, boolean defaultValue)
boolean or the
defaultValue if not found or not a COSBoolean.
This method requires the base object to be a COSDictionary.
name - The name of the field.defaultValue - The default value to return if field is not found or not of
appropriate type.booleanpublic CDSDate getFieldDate(COSName name, CDSDate defaultValue)
CDSDate or the
defaultValue if not found or not a COSString.
This method requires the base object to be a COSDictionary.
name - The name of the field.defaultValue - The default value to return if field is not found or not of
appropriate type.CDSDatepublic float getFieldFixed(COSName name, float defaultValue)
float or the
defaultValue if not found or not a COSNumber.
This method requires the base object to be a COSDictionary.
name - The name of the field.defaultValue - The default value to return if field is not found or not of
appropriate type.floatpublic float[] getFieldFixedArray(COSName name, float[] defaultValue)
float[] or the
defaultValue if not found or not a COSArray.
This method requires the base object to be a COSDictionary.
name - The name of the field.defaultValue - The default value to return if field is not found or not of
appropriate type.float[]public int getFieldInt(COSName name, int defaultValue)
int or the
defaultValue if not found or not a COSNumber.
This method requires the base object to be a COSDictionary.
name - The name of the field.defaultValue - The default value to return if field is not found or not of
appropriate type.intpublic String getFieldMLString(COSName name, String defaultValue)
String or the
defaultValue if not found or not a COSString. The
String is "expanded" to containn the correct new line characters.
This method requires the base object to be a COSDictionary.
name - The name of the field.defaultValue - The default value to return if field is not found or not of
appropriate type.Stringpublic String getFieldString(COSName name, String defaultValue)
String or the
defaultValue if not found or not a COSString.
This method requires the base object to be a COSDictionary.
name - The name of the field.defaultValue - The default value to return if field is not found or not of
appropriate type.Stringpublic void invalidateCaches()
public Object removeAttribute(Object key)
removeAttribute in interface de.intarsys.tools.attribute.IAttributeSupportpublic Object setAttribute(Object key, Object value)
setAttribute in interface de.intarsys.tools.attribute.IAttributeSupportpublic COSObject setFieldBoolean(COSName name, boolean value)
namewithin this.
This method requires the base object to be a COSDictionary.
name - The name of the field.value - The new value of the field.public COSObject setFieldFixed(COSName name, float value)
namewithin this.
This method requires the base object to be a COSDictionary.
name - The name of the field.value - The new value of the field.public COSObject setFieldInt(COSName name, int value)
namewithin this.
This method requires the base object to be a COSDictionary.
name - The name of the field.value - The new value of the field.public COSObject setFieldMLString(COSName name, String value)
namewithin this.
This method requires the base object to be a COSDictionary.
name - The name of the field.value - The new value of the field.public COSObject setFieldName(COSName name, String value)
namewithin this.
This method requires the base object to be a COSDictionary.
name - The name of the field.value - The new value of the field.public COSObject setFieldObject(COSName name, COSBasedObject value)
namewithin this.
This method requires the base object to be a COSDictionary.
name - The name of the field.value - The new value of the field.public COSObject setFieldString(COSName name, String value)
namewithin this.
This method requires the base object to be a COSDictionary.
name - The name of the field.value - The new value of the field.Copyright © 2013 intarsys consulting GmbH. All Rights Reserved.