|
Version 4.10.0 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Object hirondelle.web4j.model.Id
public final class Id
Building block class for identifiers.
Identifiers are both common and important. Unfortunately, there is no class in the JDK specifically for identifiers.
An Id class is useful for these reasons :
The underlying database column may be modeled as either text or as a number.
If the underlying column is of a numeric type, however, then a Data Access Object
will need to pass Id parameters to Db
using asInteger()
or asLong()
.
Design Note :
This class is final, immutable, Serializable
,
and Comparable
, in imitation of the other building block classes
such as String
, Integer
, and so on.
Constructor Summary | |
---|---|
Id(String aText)
Construct an identifier using an arbitrary String . |
Method Summary | |
---|---|
Integer |
asInteger()
Return this id as an Integer , if possible. |
Long |
asLong()
Return this id as a Long , if possible. |
int |
compareTo(Id aThat)
|
boolean |
equals(Object aThat)
|
static Id |
from(String aText)
Factory method. |
String |
getRawString()
Return the text passed to the constructor. |
String |
getXmlSafe()
Return the text with special XML characters esacped. |
int |
hashCode()
|
String |
toString()
Return the id, with special characters escaped. |
Methods inherited from class Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public Id(String aText)
String
.
This class uses a SafeText
object internally.
aText
- is non-null, and contains characters that are allowed
by PermittedCharacters
.Method Detail |
---|
public static Id from(String aText)
public Integer asInteger()
Integer
, if possible.
See class comment.
If this Id is not convertible to an Integer
, then a RuntimeException
is
thrown.
public Long asLong()
Long
, if possible.
See class comment.
If this Id is not convertible to a Long
,
then a RuntimeException
is thrown.
public String toString()
The return value either has content (with no leading or trailing spaces),
or is empty.
See EscapeChars.forHTML(String)
for a list of escaped
characters.
toString
in class Object
public String getRawString()
public String getXmlSafe()
SafeText.getXmlSafe()
.
public boolean equals(Object aThat)
equals
in class Object
public int hashCode()
hashCode
in class Object
public int compareTo(Id aThat)
compareTo
in interface Comparable<Id>
|
Version 4.10.0 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |