org.mycore.datamodel.metadata
Class MCRObjectID

java.lang.Object
  extended by org.mycore.datamodel.metadata.MCRObjectID

public final class MCRObjectID
extends Object

This class holds all informations and methods to handle the MyCoRe Object ID. The MyCoRe Object ID is a special ID to identify each metadata object with three parts, they are the project identifier, the type identifier and a string with a number.

Version:
$Revision: 15621 $ $Date: 2009-07-25 08:32:01 +0200 (Sat, 25 Jul 2009) $
Author:
Jens Kupferschmidt, Thomas Scheffler (yagee)

Field Summary
protected static MCRConfiguration CONFIG
           
static int MAX_LENGTH
          public constant value for the MCRObjectID length
 
Constructor Summary
MCRObjectID()
          The constructor for an empty MCRObjectId.
MCRObjectID(String id)
          The constructor for MCRObjectID from a given string.
 
Method Summary
 boolean equals(MCRObjectID in)
          This method check this data again the input and retuns the result as boolean.
 boolean equals(Object in)
          This method check this data again the input and retuns the result as boolean.
 String getBase()
          This method get the basic string with project_id_ type_id.
 String getId()
          This method get the ID string with project_id_ type_id_number.
static MCRObjectID getLastID(String base_id)
          Returns the last ID used or reserved for the given object base type.
 int getNumberAsInteger()
          This method get the integer with number.
 String getNumberAsString()
          This method get the string with number.
 String getProjectId()
          This method get the string with project_id.
 String getTypeId()
          This method get the string with type_id.
 int hashCode()
          returns getId().hashCode()
 boolean isValid()
          This method return the validation value of a MCRObjectId.
static void isValidOrDie(String id)
          This method checks the value of a MCRObjectId.
 boolean setID(String id)
          This method return the validation value of a MCRObjectId and store the components in this class.
 void setNextFreeId()
          The method set the MCRObjectID from a given base ID string.
 void setNextFreeId(String base_id)
          The method set the MCRObjectID from a given base ID string.
 void setNextFreeId(String base_id, int maxInWorkflow)
           
 boolean setNumber(int num)
          This method set a new number in a existing MCRObjectID.
 boolean setType(String type)
          This method set a new type in a existing MCRObjectID.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

MAX_LENGTH

public static final int MAX_LENGTH
public constant value for the MCRObjectID length

See Also:
Constant Field Values

CONFIG

protected static MCRConfiguration CONFIG
Constructor Detail

MCRObjectID

public MCRObjectID()
The constructor for an empty MCRObjectId.


MCRObjectID

public MCRObjectID(String id)
            throws MCRException
The constructor for MCRObjectID from a given string.

Throws:
MCRException - if the given string is not valid.
Method Detail

setNextFreeId

public void setNextFreeId()
                   throws MCRException
The method set the MCRObjectID from a given base ID string. The number was computed from this methode. It is the next free number of an item in the database for the given project ID and type ID.

Throws:
MCRException - if the given string is not valid or can't connect to the MCRXMLTableManager.

setNextFreeId

public void setNextFreeId(String base_id)
                   throws MCRException
The method set the MCRObjectID from a given base ID string. A base ID is project_id_type_id. The number was computed from this methode. It is the next free number of an item in the database for the given project ID and type ID.

Parameters:
base_id - the basic ID
Throws:
MCRException - if the given string is not valid or can't connect to the MCRXMLTableManager.

setNextFreeId

public void setNextFreeId(String base_id,
                          int maxInWorkflow)
                   throws MCRException
Throws:
MCRException

getLastID

public static MCRObjectID getLastID(String base_id)
Returns the last ID used or reserved for the given object base type.


setType

public final boolean setType(String type)
This method set a new type in a existing MCRObjectID.

Parameters:
type - the new type

setNumber

public final boolean setNumber(int num)
This method set a new number in a existing MCRObjectID.

Parameters:
num - the new number

getProjectId

public final String getProjectId()
This method get the string with project_id. If the ID is not valid, an empty string was returned.

Returns:
the string of the project id

getTypeId

public final String getTypeId()
This method get the string with type_id. If the ID is not valid, an empty string was returned.

Returns:
the string of the type id

getNumberAsString

public final String getNumberAsString()
This method get the string with number. If the ID is not valid, an empty string was returned.

Returns:
the string of the number

getNumberAsInteger

public final int getNumberAsInteger()
This method get the integer with number. If the ID is not valid, a -1 was returned.

Returns:
the number as integer

getBase

public String getBase()
This method get the basic string with project_id_ type_id. If the Id is not valid, an empty string was returned.

Returns:
the string of the schema name

getId

public String getId()
This method get the ID string with project_id_ type_id_number. If the ID is not valid, an empty string was returned.

Returns:
the string of the schema name

isValid

public boolean isValid()
This method return the validation value of a MCRObjectId. The MCRObjectID is valid if:

Returns:
the validation value, true if the MCRObjectId is correct, otherwise return false

setID

public final boolean setID(String id)
This method return the validation value of a MCRObjectId and store the components in this class. The type_id was set to lower case. The MCRObjectID is valid if:

Parameters:
id - the MCRObjectId
Returns:
the validation value, true if the MCRObjectId is correct, otherwise return false

isValidOrDie

public static void isValidOrDie(String id)
This method checks the value of a MCRObjectId. The MCRObjectId is valid if:

Parameters:
id - the MCRObjectId
Throws:
MCRException - if ID is not valid

equals

public boolean equals(MCRObjectID in)
This method check this data again the input and retuns the result as boolean.

Parameters:
in - the MCRObjectID to check
Returns:
true if all parts are equal, else return false.

equals

public boolean equals(Object in)
This method check this data again the input and retuns the result as boolean.

Overrides:
equals in class Object
Parameters:
in - the MCRObjectID to check
Returns:
true if all parts are equal, else return false.
See Also:
Object.equals(Object)

toString

public String toString()
Overrides:
toString in class Object
See Also:
getId(), Object.toString()

hashCode

public int hashCode()
returns getId().hashCode()

Overrides:
hashCode in class Object
See Also:
getId(), Object.hashCode()