|
intarsys PDF library API | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectde.intarsys.pdf.cos.COSBasedObject
public abstract class COSBasedObject
The abstract superclass for all objects/data structures that are build on the basic COSObject types.
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.
Nested Class Summary | |
---|---|
static class |
COSBasedObject.MetaClass
The meta class implementation |
Field Summary | |
---|---|
static COSBasedObject.MetaClass |
META
The meta class instance |
Method Summary | |
---|---|
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)
The COSObject associated with name in the receiver
or COSNull . |
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)
get an attribute from the context |
boolean |
getFieldBoolean(COSName name,
boolean defaultValue)
The value of a field within this as a boolean or the
defaultValue if not found or not a COSBoolean . |
CDSDate |
getFieldDate(COSName name,
CDSDate defaultValue)
The value of a field within this as a CDSDate or the
defaultValue if not found or not a COSString . |
float |
getFieldFixed(COSName name,
float defaultValue)
The value of a field within this as a float or the
defaultValue if not found or not a COSNumber . |
float[] |
getFieldFixedArray(COSName name,
float[] defaultValue)
The value of a field within this as a float[] or the
defaultValue if not found or not a COSArray . |
int |
getFieldInt(COSName name,
int defaultValue)
The value of a field within this as a int or the
defaultValue if not found or not a COSNumber . |
String |
getFieldMLString(COSName name,
String defaultValue)
The value of a field within this as a String or the
defaultValue if not found or not a COSString . |
String |
getFieldString(COSName name,
String defaultValue)
The value of a field within this as a String or the
defaultValue if not found or not a COSString . |
void |
invalidateCaches()
Invalidate all local caches as the base object may have changed. |
Object |
removeAttribute(Object key)
remove an attribute in the context |
Object |
setAttribute(Object key,
Object value)
set the value of an attribute in the context |
void |
setFieldBoolean(COSName name,
boolean value)
Set the value of field name within this. |
void |
setFieldFixed(COSName name,
float value)
Set the value of field name within this. |
void |
setFieldInt(COSName name,
int value)
Set the value of field name within this. |
void |
setFieldMLString(COSName name,
String value)
Set the value of field name within this. |
void |
setFieldName(COSName name,
String value)
Set the value of field name within this. |
void |
setFieldObject(COSName name,
COSBasedObject value)
Set the value of field name within this. |
void |
setFieldString(COSName name,
String value)
Set the value of field name within this. |
String |
toString()
|
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final COSBasedObject.MetaClass META
Method Detail |
---|
public void changed(COSObject pObject, Object slot, Object oldValue, Object newValue)
ICOSObjectListener
COSObject
this may be a change in containement (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 ICOSObjectListener
pObject
- 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 read
COSObject
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 check
true
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 receiver
public 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 field
public Object getAttribute(Object key)
IAttributeSupport
getAttribute
in interface IAttributeSupport
key
- the name of the attribute to get
public 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.
boolean
public 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.
CDSDate
public 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.
float
public 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.
int
public 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.
String
public 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.
String
public void invalidateCaches()
public Object removeAttribute(Object key)
IAttributeSupport
removeAttribute
in interface IAttributeSupport
key
- the name of the attribute to remove
key
public Object setAttribute(Object key, Object value)
IAttributeSupport
setAttribute
in interface IAttributeSupport
key
- the name of the attribute to setvalue
- the new value the attribute
key
public void setFieldBoolean(COSName name, boolean value)
name
within 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 void setFieldFixed(COSName name, float value)
name
within 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 void setFieldInt(COSName name, int value)
name
within 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 void setFieldMLString(COSName name, String value)
name
within 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 void setFieldName(COSName name, String value)
name
within 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 void setFieldString(COSName name, String value)
name
within 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 void setFieldObject(COSName name, COSBasedObject value)
name
within 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 String toString()
toString
in class Object
|
intarsys PDF library API | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |