SPT Core API

com.sptci.jdo
Class StartLetter

java.lang.Object
  extended by com.sptci.jdo.StartLetter
All Implemented Interfaces:
Serializable, Comparable<StartLetter>

public class StartLetter
extends Object
implements Comparable<StartLetter>, Serializable

A simple object that is used to implement efficient alphabetical indexing of persistent objects. Querying instances of this object can return the starting characters for the associated object very efficiently instead of running through the extent for the object instances.

© Copyright 2007, Sans Pareil Technologies, Inc.

Version:
$Id: StartLetter.java 4594 2009-01-29 17:43:03Z rakesh $
Author:
Rakesh Vidyadharan 2007-05-25
See Also:
Serialized Form

Constructor Summary
protected StartLetter()
          Default constructor.
  StartLetter(char letter, Class source)
          Create a new instance of the object with the specified values.
  StartLetter(char letter, String source)
          Create a new instance of the object with the specified values.
 
Method Summary
 int compareTo(StartLetter object)
          Compares this object with the specified object for order.
 boolean equals(Object object)
          Compare the specified object with this instance for equality.
 char getLetter()
          Returns letter.
 String getObjectId()
          Return the ObjectId of this persistent instance.
 String getSource()
          Returns source.
 int hashCode()
          Calculate the hash code for this instance.
 String toString()
          Return a string representation of this object.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

StartLetter

protected StartLetter()
Default constructor. Cannot be instantiated.


StartLetter

public StartLetter(char letter,
                   String source)
Create a new instance of the object with the specified values. It is important that sub-classes invoke this method for the oid primary key field to be initialised.

Parameters:
letter - The starting letter to associate.
source - The object with which the starting letter is associated.

StartLetter

public StartLetter(char letter,
                   Class source)
Create a new instance of the object with the specified values. The source is assigned the fully qualified class name of the specified source parameter.

Parameters:
letter - The starting letter to associate.
source - The object with which the starting letter is associated.
Method Detail

getObjectId

public String getObjectId()
Return the ObjectId of this persistent instance.

Returns:
The ObjectId of this instance. Returns null if this instance is transient.

equals

public boolean equals(Object object)
Compare the specified object with this instance for equality. Two objects are considered equal if they have the same ObjectId, or if they have the same values for the fields.

Overrides:
equals in class Object
Parameters:
object - The object that is to be compared for equality.
Returns:
Return true if the specified object is of the same type as this object and has the same ObjectId.

hashCode

public int hashCode()
Calculate the hash code for this instance. Returns the hash code of its ObjectId or the fields.

Overrides:
hashCode in class Object
Returns:
The hash code for this object.

toString

public String toString()
Return a string representation of this object.

Overrides:
toString in class Object
Returns:
The string representation of this instance.

compareTo

public int compareTo(StartLetter object)
Compares this object with the specified object for order. Returns a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.

Compare the values of letter

Specified by:
compareTo in interface Comparable<StartLetter>
Parameters:
object - The object that is to be compared with this object.
Returns:
int A negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.

getLetter

public char getLetter()
Returns letter.

Returns:
The value/reference of/to letter.

getSource

public String getSource()
Returns source.

Returns:
The value/reference of/to source.

SPT Core API