|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.arsdigita.persistence.OID
An OID represents a unique object ID. An OID is composed of an object type and 1 or more values.
The OID class encapsulates the details of the primary key of an object. You use instances of OID for retrieving an object from the database and you would set the OID to a known value. You can also get an OID object from a DataObject.
Note that when the object type is a subtype of ACS Object, we
know that the object_id
uniquely identifies the
object. The OID class is meant to handle both this special case and
the more general case where there does not exist a single, unique
integer.
Field Summary | |
static String |
versionId
|
Constructor Summary | |
OID(ObjectType type)
Creates an OID for the Object type. |
|
OID(ObjectType type,
int value)
Creates an OID with a single attribute for the key. |
|
OID(ObjectType type,
Object value)
Creates an OID with a single attribute for the key. |
|
OID(String typeName)
Creates an OID for the named ObjectType. |
|
OID(String typeName,
int value)
Creates an OID with a single attribute for the key. |
|
OID(String typeName,
Object value)
Creates an OID with a single attribute for the key. |
Method Summary | |
boolean |
arePropertiesNull()
Indicates if an OID contains no non-null information. |
boolean |
equals(Object obj)
Indicates if two OIDs have the same base type and contain the same values. |
Object |
get(String propertyName)
Obtains a property associated with the OID. |
ObjectType |
getDataObjectType()
Deprecated. |
int |
getNumberOfProperties()
|
ObjectType |
getObjectType()
|
int |
hashCode()
Simple hashcode method to calculate hashcode based on the information used in the equals method. |
boolean |
hasProperty(String name)
|
boolean |
isInitialized()
|
void |
set(String propertyName,
Object value)
Adds a property to the OID. |
String |
toString()
Serializes the OID. |
static OID |
valueOf(String s)
|
Methods inherited from class java.lang.Object |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
public static final String versionId
Constructor Detail |
public OID(ObjectType type)
set(String propertyName,
Object value)
method to set the value that corresponds with
the OID (this value must be part of the object key for the
passed in object type). For instance, if the code passes in
the ACSObject ObjectType then the code should also call
oid.set("id", valueOfID);
. The list of potential
parameters that can be set can be retrieved by calling
type.getObjectMap().getObjectKey()
.
This constructor is typically used when the ObjectType has
multiple keys (
type.getObjectMap().getObjectKey().getCount() > 1
)
but it can be used when there is only a single key however it
would probably be easier to use one of the other convenience
constructors when there is only a single key.
type
- The ObjectTypepublic OID(ObjectType type, Object value)
com.arsdigita.kernel.ACSObject
then the value
should be the object_id
. So, if developers wanted
to create the OID for ID zero, they would call
new OID(acsObjectType, new BigDecimal(0))
. A
BigDecimal
is passed in because the "id" attribute
for the ACSObject type is declared as BigDecimal
in
the PDL file.
type
- The ObjectType of the IDvalue
- The value of the ID
PersistenceException
- will be thrown if the given
object type does not have exactly a single key (if
type.getObjectMap().getObjectKey().getCount()
!= 1
).public OID(String typeName)
public ACSObject() {
super("com.arsdigita.kernel.ACSObject");
}
and the call to super contains "new OID(typeName)
"
typeName
- The name of the ObjectType.public OID(String typeName, Object value)
com.arsdigita.kernel.ACSObject
then the value
should be the object_id
. So, if developers wanted
to create the OID for ID zero, they would call new
OID("com.arsdigita.kernel.ACSObject", new
BigDecimal(0))
. A BigDecimal
is passed in
because the "id" attribute for the ACSObject type is declared
as BigDecimal
in the PDL file. This is analogous
to OID(ObjectType type, Object value)
except that a string
is used to lookup the correct object type.
The typename of the ObjectType must be defined in the MetadataRoot.
value
- The value of the ID
PersistenceException
- will be thrown if the given
object type does not have exactly a single key (if
type.getObjectMap().getObjectKey().getCount()
!= 1
).public OID(String typeName, int value)
com.arsdigita.kernel.ACSObject
then the value
should be the object_id
. So, if developers wanted
to create the OID for ID zero, they would call new
OID("com.arsdigita.kernel.ACSObject", 0)
. This is analogous
to OID(ObjectType type, Object value)
except that a string
is used to lookup the correct object type and the passed in
int
is converted to a BigDecimal
object.
The typename of the ObjectType must be defined in the MetadataRoot.
value
- The integer value of the ID
PersistenceException
- will be thrown if the given
object type does not have exactly a single key (if
type.getObjectMap().getObjectKey().getCount()
!= 1
).public OID(ObjectType type, int value)
com.arsdigita.kernel.ACSObject
then the value
should be the object_id
. So, if developers wanted
to create the OID for ID zero, they would call new
OID(acsObjectType, 0)
. This is analogous to OID(ObjectType type, Object value)
except that the passed in
int
is converted to a BigDecimal
object.
type
- The ObjectType of the IDvalue
- The value of the property
PersistenceException
- will be thrown if the given
object type does not have exactly a single key (if
type.getObjectMap().getObjectKey().getCount()
!= 1
).Method Detail |
public void set(String propertyName, Object value)
propertyName
- Name of the propertyvalue
- The propertypublic Object get(String propertyName)
propertyName
- Name of the property
public boolean hasProperty(String name)
name
- The name of the property
public boolean isInitialized()
public int getNumberOfProperties()
public boolean arePropertiesNull()
public ObjectType getDataObjectType()
public ObjectType getObjectType()
public String toString()
public static OID valueOf(String s) throws IllegalArgumentException
IllegalArgumentException
public boolean equals(Object obj)
public int hashCode()
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |