|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.openadaptor.dataobjects.AbstractDataObject
org.openadaptor.dataobjects.SimpleDataObject
public class SimpleDataObject
The SimpleDataObject extends the AbstractDataObject class to provide a concrete implementation of the DataObject interface. It adds an SDOType instance variable to define the type of the DataObject, and adds a new method "addAttributeValue" which adds an attribute to the SDOType and sets the value for that instance at the same time. In addition it provides some useful general-purpose class methods for comparing attribute values and sdisplaying debugging information about individual DataObjects.
AbstractDataObject
,
Serialized FormField Summary | |
---|---|
(package private) static long |
serialVersionUID
|
protected SDOType |
type
The DOType of this instance |
Fields inherited from class org.openadaptor.dataobjects.AbstractDataObject |
---|
log, values |
Constructor Summary | |
---|---|
|
SimpleDataObject(DOType type)
Creates a new SimpleDataObject instance with the SDOType type . |
|
SimpleDataObject(SDOType type)
Creates a new SimpleDataObject instance with the SDOType type . |
protected |
SimpleDataObject(SDOType type,
java.util.Hashtable values)
Creates a new SimpleDataObject instance with the type and attribute values . |
|
SimpleDataObject(java.lang.String newTypename)
Creates a new SimpleDataObject instance with a new SDOType named from newTypeName . |
Method Summary | |
---|---|
protected static java.lang.String |
_debugString(DataObject obj,
int indent)
Produce a terse dump of the attributes names and value in obj . |
void |
addAttributeValue(java.lang.String attrName,
java.lang.Object value)
If an attribute name does not exists, create it and set
it to value . |
void |
addAttributeValue(java.lang.String attrName,
java.lang.Object value,
DOType valueType)
If an attribute name does not exists, create it and set
it to value . |
DataObject |
cloneEmpty()
Returns another object of this type with the same DOType, but no values. |
static boolean |
compareAttributes(DataObject obj1,
DataObject obj2,
java.lang.String attrName)
|
void |
copyValues(DataObject dob)
|
static java.lang.String |
debugString(DataObject obj)
Produce a terse dump of the attributes names and value in obj . |
static java.lang.String |
debugString(DataObject[] dobs)
Produce a terse dump of the DataObjects in dobs . |
static DataObject[] |
deepArrayCopy(DataObject[] dobs)
** Array copy ** |
static CollectionDataObject |
deepCollectionCopy(CollectionDataObject dob)
** Collection copy ** |
static SimpleDataObject |
deepCopy(DataObject dob)
** Unary copy ** |
static DOType |
getDOType(DataObject[] dobs)
Returns the DOType shared by all the objects in the array, or null if not all the same. |
protected static java.lang.String |
getIndentStr(int indent)
Returns a string of indent spaces in length
Note that indent is constrained to a range of 0 to about 40, the
string returned will contain between 0 and about 40 spaces. |
DOType |
getType()
Get the type for this object, this is analogous to the "class" of the DataObject. |
boolean |
isPresent(java.lang.String name)
|
Methods inherited from class org.openadaptor.dataobjects.AbstractDataObject |
---|
equals, getAttributePathValue, getAttributeValue, isAssociativeArrayIndexing, isNullValue, main, replaceAssociativeArrayIndexFrom, setAssociativeArrayIndexing, setAttributePathValue, setAttributeValue, toString |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
static final long serialVersionUID
protected SDOType type
Constructor Detail |
---|
public SimpleDataObject(java.lang.String newTypename)
newTypeName
.
Note that the type name is not checked for validity; you can
pass null
or a string containing spaces or starting
with digits. These problems will only be flagged if you try and
serialise the DataObject (using XMLFormatter, for example).
newTypename
- String containing name for new SDOType.public SimpleDataObject(DOType type) throws InvalidParameterException
type
.
If type is not an SDOType, an SDOType copy is made of it.
type
- SDOType type for this instance.
InvalidParameterException
- If there was a problem making an SDOType
copy of type.public SimpleDataObject(SDOType type)
type
.
type
- SDOType type for this instance.protected SimpleDataObject(SDOType type, java.util.Hashtable values)
type
and attribute values
.
This method is protected as it is only intended for use by trusted code;
no validity checking on the contents if the values
Hashtable
takes place.
type
- SDOType type for this instance.Method Detail |
---|
public static DOType getDOType(DataObject[] dobs)
equals()
, not ==
.
dobs
- DataObject array to be checked.
public static boolean compareAttributes(DataObject obj1, DataObject obj2, java.lang.String attrName) throws InvalidParameterException
InvalidParameterException
public static java.lang.String debugString(DataObject obj)
obj
.
The attributes are on separate lines, indented by indent
spaces.
Nested DataObject arrays are indented by two spaces.
obj
- DataObject to be dumped.
obj
.public static java.lang.String debugString(DataObject[] dobs)
dobs
.
dobs
- DataObject Array to be dumped.
dobs
.protected static java.lang.String _debugString(DataObject obj, int indent)
obj
.
The attributes are on separate lines, indented by indent
spaces.
Nested DataObject arrays are indented by two spaces.
obj
- DataObject to be dumped.indent
- level of indent for this object
obj
(returns null pointer for null object).protected static java.lang.String getIndentStr(int indent)
indent
spaces in length
Note that indent is constrained to a range of 0 to about 40, the
string returned will contain between 0 and about 40 spaces.
public DataObject cloneEmpty()
cloneEmpty
in interface DataObject
cloneEmpty
in class AbstractDataObject
public DOType getType()
getType
in interface DataObject
getType
in class AbstractDataObject
public void copyValues(DataObject dob)
public void addAttributeValue(java.lang.String attrName, java.lang.Object value) throws InvalidParameterException
name
does not exists, create it and set
it to value
.
If it already exists, just set its value.
attrName
- Attribute namevalue
- New attribute value
InvalidParameterException
- If an attribute with that name
exists, and its type does not match value's type.public void addAttributeValue(java.lang.String attrName, java.lang.Object value, DOType valueType) throws InvalidParameterException
name
does not exists, create it and set
it to value
. If valueType is not null, check it matches the
value type. If value is null, use valueType to determine the attribute
type.
If it already exists, just set its value.
attrName
- Attribute namevalue
- New attribute valuevalueType
- New attribute type
InvalidParameterException
- If an attribute with that name
exists, and its type does not match value's type or valueType, or if
both value and valueType are null, so we cannot determine the type of
attribute to create.public boolean isPresent(java.lang.String name)
public static DataObject[] deepArrayCopy(DataObject[] dobs) throws DataObjectException
DataObjectException
public static CollectionDataObject deepCollectionCopy(CollectionDataObject dob) throws DataObjectException
DataObjectException
public static SimpleDataObject deepCopy(DataObject dob) throws DataObjectException
DataObjectException
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |