|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object blackboard.persist.Id blackboard.persist.PkId
public class PkId
The PkId
class provides the means of describing an Id
within a Blackboard database container.
Field Summary | |
---|---|
static int |
DEFAULT_PK2
|
Fields inherited from class blackboard.persist.Id |
---|
UNSET_ID |
Constructor Summary | |
---|---|
PkId(Container container,
DataType dataType,
int nPk1,
int nPk2)
Instantiate a new PkId with the given Container ,
DataType , and pk key values as integers. |
|
PkId(Container container,
DataType dataType,
java.lang.String strPk)
Instantiate a new PkId with the given Container ,
DataType , and pk key values as a single string. |
|
PkId(Container container,
DataType dataType,
java.lang.String strPk1,
java.lang.String strPk2)
Instantiate a new PkId with the given Container ,
DataType , and pk key values as strings. |
Method Summary | |
---|---|
int |
compareTo(java.lang.Object obj)
The sole method of the Comparable interface. |
boolean |
equals(java.lang.Object obj)
Overrides the equals() method in
Object to provide a simple way to compare two PkId s. |
int |
getPk1()
Returns the primary key value of this PkId (PK1). |
int |
getPk2()
Returns the secondary key value of this PkId (PK2 or SOS_ID). |
int |
hashCode()
Allow Ids to be used as a key in a hashtable. |
boolean |
isSet()
Determines if the PkId has been set. |
BbObject |
load()
Overrides load method in the base class to implement a "load
by id" operation for a database id (and thus for a database container). |
java.lang.String |
toExternalString()
Converts this PkId into its String representation. |
java.lang.String |
toString()
Converts this PkId into its String representation. |
Methods inherited from class blackboard.persist.Id |
---|
assertIsSet, assertMatchesContainer, assertMatchesDataType, generateId, generateId, generateId, getContainer, getDataType, hasSameContainer, hasSameDataType, matchesContainer, matchesDataType, newId, setContainer, setDataType |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final int DEFAULT_PK2
Constructor Detail |
---|
public PkId(Container container, DataType dataType, int nPk1, int nPk2) throws java.lang.IllegalArgumentException
PkId
with the given Container
,
DataType
, and pk key values as integers.
container
- the Container
in which the object this Id
refers to residesdataType
- the DataType
of the object that this Id
refers tonPk1
- An int representing the primary key value.nPk2
- An int representing the secondary primary key value (SOS_ID).
java.lang.IllegalArgumentException
- thrown if either of the integer values
is not a valid key representation (i.e., a negative value).public PkId(Container container, DataType dataType, java.lang.String strPk1, java.lang.String strPk2) throws java.lang.IllegalArgumentException
PkId
with the given Container
,
DataType
, and pk key values as strings.
container
- the Container
in which the object this Id
refers to residesdataType
- the DataType
of the object that this Id
refers tostrPk1
- A String representing the primary key value.strPk2
- A String representing the secondary primary key value (SOS_ID).
java.lang.IllegalArgumentException
- thrown if either of the String values
is not a valid key representation (i.e., an int) or null.public PkId(Container container, DataType dataType, java.lang.String strPk) throws java.lang.IllegalArgumentException
PkId
with the given Container
,
DataType
, and pk key values as a single string. The string
provided as the key value should be of the form as generated by toExternalString()
.
container
- the Container
in which the object this id
refers to residesdataType
- the DataType
of the object that this id
refers tostrPk
- A String representing the intenal id value(s).
java.lang.IllegalArgumentException
- thrown if the String value can not be
interpreted as a valid key representation.Method Detail |
---|
public boolean isSet()
PkId
has been set.
isSet
in class Id
public int getPk1()
PkId
(PK1).
pkId
.public int getPk2()
PkId
(PK2 or SOS_ID).
PkId
.public boolean equals(java.lang.Object obj)
equals()
method in
Object
to provide a simple way to compare two PkId
s.
equals
in class Id
obj
- the object to be compared.
public int compareTo(java.lang.Object obj) throws java.lang.ClassCastException
Comparable
interface.
Used for sorting and natural-ordering algorithms.
compareTo
in interface java.lang.Comparable
compareTo
in class Id
obj
- the object to be compared to.
java.lang.ClassCastException
- thrown if the specified object's type
prevents it from being compared to this Objectpublic int hashCode()
hashCode
in class Id
public java.lang.String toExternalString()
PkId
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 PkId
value. If a human-
readable form of this PkId
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 PkId
value.
toExternalString
in class Id
PkId
that is able to
be parsed.toString()
,
BbPersistenceManager.generateId(DataType,String)
,
Container.generateId(DataType,String)
public java.lang.String toString()
PkId
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 PkId
value. If an "able
to be parsed" form of this PkId
is desired, use toExternalString()
.
toString
in class Id
PkId
that is human-
readable.toExternalString()
public BbObject load() throws PersistenceException
load
method in the base class to implement a "load
by id" operation for a database id (and thus for a database container).
Id
object contains enough information to uniquely identify an
object in the system. First, it contains a Container
, which for a
PkId
(us) should be a DatabaseContainer
. This value
describes the database the object should reside in. Second, an Id
contains a DataType
value. This value describes the type
of object we are looking for, and thus for a PkId, describes
what database loader we can use to pull the object. Finally, an Id
contains a key. For a PkId
, this value identifies the
individual object (among the type) that we are looking. This typically
means an individual row within an individual table in the database.
- Overrides:
load
in class Id
- Returns:
- the
BbObject
derived value that matches the current id value
- Throws:
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 |