|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectblackboard.persist.Id
public abstract class Id
Provides the basis for object identifiers within the persistence framework.
| Field Summary | |
|---|---|
static Id |
UNSET_ID
|
| Constructor Summary | |
|---|---|
protected |
Id(Container container,
DataType dataType)
Creates Id identifying it with the given container and data
type values. |
protected |
Id(DataType dataType)
Creates an Id identifying it with the given data type value. |
| Method Summary | |
|---|---|
void |
assertIsSet()
Asserts that this Id is "set" -- has a value. |
void |
assertMatchesContainer(Container targetContainer)
Asserts that the Container value associated with this Id
matches the provided Container value. |
void |
assertMatchesDataType(DataType targetDataType)
Asserts that the DataType value associated with this Id
matches the provided DataType value. |
abstract int |
compareTo(java.lang.Object obj)
The sole method of the Comparable interface. |
abstract boolean |
equals(java.lang.Object obj)
Overrides the equals() method in
Object to provide a simple way to compare two Ids. |
static Id |
generateId(DataType dataType,
int nKey1)
Generates an Id instance using the default database persistence
manager as given by context. |
static Id |
generateId(DataType dataType,
int nKey1,
int nKey2)
Generates an Id instance using the default database persistence
manager as given by context. |
static Id |
generateId(DataType dataType,
java.lang.String strKey)
Generates an Id instance using the default database persistence
manager as given by context. |
Container |
getContainer()
Returns the Container associated with this Id. |
DataType |
getDataType()
Returns the DataType associated with this Id. |
java.lang.String |
getExternalString()
A simple bean-based wrapper around the method toExternalString()
which allows the external string to be accessed as a bean property. |
boolean |
getIsSet()
|
abstract int |
hashCode()
Returns a hash code value for the object. |
boolean |
hasSameContainer(Id id)
Returns true if the given Id has the same Container
as this Id instance. |
boolean |
hasSameDataType(Id id)
Returns true if the given Id has the same DataType
as this Id instance. |
abstract boolean |
isSet()
Determines if the Id has been set (is not in default state). |
static boolean |
isValid(Id id)
Determines if the given Id value is "valid". |
BbObject |
load()
Loads the BbObject derived value that matches the current id value. |
java.lang.Object |
loadObject()
Loads the Object derived value that matches the current id value. |
boolean |
matchesContainer(Container targetContainer)
Returns true if the given Container matches the Container
of this Id. |
boolean |
matchesDataType(DataType targetDataType)
Returns true if the given DataType matches the DataType
of this Id. |
static Id |
newId(DataType dataType)
Returns a new Id instance, using a default implementation. |
void |
setContainer(Container container)
Associates the given Container with this Id. |
void |
setDataType(DataType dataType)
Associates the given DataType with this Id. |
abstract java.lang.String |
toExternalString()
Converts the Id into its String representation. |
abstract java.lang.String |
toString()
Converts the Id into its String representation. |
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public static final Id UNSET_ID
| Constructor Detail |
|---|
protected Id(Container container,
DataType dataType)
Id identifying it with the given container and data
type values.
container - the Container in which the object this id
refers to resides. Can not be null.dataType - the DataType of the object that this id
refers to. Can not be null. If no data type is presently desired
pass in DataType.NULL_DATA_TYPE.protected Id(DataType dataType)
Id identifying it with the given data type value.
This method of Id construction should be used when creating an Id
that has no relationship to a container (such as UnsetId)
and the normal Id constructor (Id(Container,DataType))
would therefore complain regarding a null container value being provided.
This method of construction should never be used by an Id
type that could be used with a Container since it bypasses the null
checking performed on the container value.
container - the Container in which the object this Id
refers to residesdataType - the DataType of the object that this Id
refers to. Can not be null. If no data type is presently desired
pass in DataType.NULL_DATA_TYPE.| Method Detail |
|---|
public abstract boolean isSet()
Id has been set (is not in default state).
Id is set, false otherwise.public boolean getIsSet()
public final void assertIsSet()
throws KeyNotFoundException
Id is "set" -- has a value.
KeyNotFoundException - if this Id has not been set
public final void assertMatchesDataType(DataType targetDataType)
throws KeyNotFoundException
DataType value associated with this Id
matches the provided DataType value.
KeyNotFoundException - if the data type of this Id
does not match the provided data type
public final void assertMatchesContainer(Container targetContainer)
throws KeyNotFoundException
Container value associated with this Id
matches the provided Container value.
KeyNotFoundException - if the container of this Id
does not match the provided containerpublic boolean hasSameDataType(Id id)
Id has the same DataType
as this Id instance. If the data type in the given Id
is null, then true is returned only if this Id's data type is also
null.
id - the Id value to use in the comparison
public boolean hasSameContainer(Id id)
Id has the same Container
as this Id instance. If the container in the given
Id is null, then true is returned only if this Id's container
is also null.
id - the Id value to use in the comparison
public boolean matchesDataType(DataType targetDataType)
DataType matches the DataType
of this Id.
targetDataType - the DataType to use in the comparison
public boolean matchesContainer(Container targetContainer)
Container matches the Container
of this Id.
targetContainer - the Container to use in the comparison
public Container getContainer()
Container associated with this Id.
Container associated with this idpublic void setContainer(Container container)
Container with this Id.
container - the Container to associate with this id. Can not
be null.public DataType getDataType()
DataType associated with this Id.
DataType associated with this idpublic void setDataType(DataType dataType)
DataType with this Id.
dataType - the DataType to associate with this Id. Can not be
null. If no data type is presently desired pass in DataType.NULL_DATA_TYPE.public abstract boolean equals(java.lang.Object obj)
equals() method in
Object to provide a simple way to compare two Ids.
equals in class java.lang.Objectobj - the object to be compared.
public abstract int compareTo(java.lang.Object obj)
throws java.lang.ClassCastException
Comparable interface.
Used for sorting and natural-ordering algorithms.
compareTo in interface java.lang.Comparableobj - the object to be compared to.
java.lang.ClassCastException - thrown if the specified object's type
prevents it from being compared to this Objectpublic abstract int hashCode()
java.util.Hashtable
.
hashCode in class java.lang.Objectpublic abstract java.lang.String toExternalString()
Id into its String representation. The output of
this method is designed to create an able to be parsed (not necessarily human-
readable) representation of this Id value. If a human-readable
form of this Id is desired, use toString().
BbPersistenceManager and Container. The output of this method may be the same as that generated
by toString(), but it is not guaranteed to be. As a result, this
method should be used whenever a string value is desired that can later be
converted back into a proper Id value.
Id that is able to be
parsed. If the id has not been set, the string ("{unset id}")
should be returned.toString(),
BbPersistenceManager.generateId(DataType,String),
Container.generateId(DataType,String)public java.lang.String getExternalString()
toExternalString()
which allows the external string to be accessed as a bean property.
Id consistent with the
output generated by toExternalString()toExternalString()public abstract java.lang.String toString()
Id into its String representation. The output of
this method is designed to create a human-readable (not necessarily able to
be parsed) representation of this Id value. If an "able to be
parsed" form of this Id is desired, use toExternalString().
toString in class java.lang.ObjectId that is human-readable.toExternalString()public static Id newId(DataType dataType)
Id will be typed according to the supplied DataType
and have an automatically generated unique key value. The Id
generated from this call is not associated (and can not be) with a
container. It represents an object that has not come from a container but
has been created in memory. As a result, the Ids generated by
this call can not be used for performing container object lookups. Objects
with ids generated from this method can be persisted to a
container though. In order to generate Ids that can be used
for performing Container lookups, see BbPersistenceManager
and the Container type against which a lookup wishes to be performed.
dataType - the DataType to associate with created Id
BbPersistenceManager.generateId(DataType,String),
BbPersistenceManager.generateId(DataType,int,int),
Container.generateId(DataType,String),
Container.generateId(DataType,int,int)public static boolean isValid(Id id)
Id value is "valid". Valid is defined as
not being null, is set (see isSet()), and with a valid data type
value.
This method should not be used to determine if an id value is a valid id
for a specific container. To do that, use Container.isValidId(Id)
instead.
id - the Id value to check
Id is valid, false otherwise
public static Id generateId(DataType dataType,
java.lang.String strKey)
throws PersistenceException
Id instance using the default database persistence
manager as given by context.
BbPersistenceManager.generateId(DataType,String) for more
information.
dataType - the DataType of the object that the generated
Id instance will refer tostrKey - the String value to use when generating the key value
of the Id instance
Id generated from the provided datatype and key
PersistenceException
public static Id generateId(DataType dataType,
int nKey1,
int nKey2)
throws PersistenceException
Id instance using the default database persistence
manager as given by context.
BbPersistenceManager.generateId(DataType,int,int) for more
information.
dataType - the DataType of the object that the generated
Id instance will refer tonKey1 - an integer value to use when generating the key value of the
Id instancenKey2 - another integer value to use when generating the key value of
the Id instance
Id generated from the provided datatype and keys
PersistenceException
public static Id generateId(DataType dataType,
int nKey1)
throws PersistenceException
Id instance using the default database persistence
manager as given by context.
BbPersistenceManager.generateId(DataType,int) for more information.
dataType - the DataType of the object that the generated
Id instance will refer tonKey1 - an integer value to use when generating the key value of the
Id instance
Id generated from the provided datatype and key
PersistenceException
public final BbObject load()
throws PersistenceException
BbObject derived value that matches the current id value.
Container specific. As such, each
container-specific Id type should implement this method to
suit the needs of that specific container. This, default implementation
throws a RuntimeException.
BbObject derived value that matches the current id value
PersistenceException - if an error occurs while loading the object
public java.lang.Object loadObject()
throws PersistenceException
Object derived value that matches the current id value.
Container specific. As such, each
container-specific Id type should implement this method to
suit the needs of that specific container. This, default implementation
throws a RuntimeException.
Object derived value that matches the current id value
PersistenceException - if an error occurs while loading the object
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||