|
Holger's Java API |
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.antelmann.db.AbstractDBEntry
com.antelmann.db.Stub<T>
public class Stub<T extends DBEntry>
a Stub is a small object that can serve as a proxy for larger objects,
so that you can maintain a lot of these in memory and only access the
full object if needed.
All this object maintains is the ID, a String to properly display
the instance via toString() and a reference to the original class.
A Stub is useful to allow displaying a huge list of objects w/o actually
having to instantiate the entire object at the time of selecting one from
the list. Accessing the full instance can then be delayed until a single
Stub is selected.
As opposed to a standard DBReference, a Stub cannot be an 'empty' reference.
Database,
DefaultDBReference,
Serialized Form| Field Summary |
|---|
| Fields inherited from interface com.antelmann.db.DBReference |
|---|
REFERENCE_FLAVOR, REFERENCE_LIST_FLAVOR |
| Fields inherited from interface com.antelmann.db.DBEntry |
|---|
ENTRY_FLAVOR, ENTRY_LIST_FLAVOR |
| Constructor Summary | |
|---|---|
Stub(Object id,
Object displayValue,
Class<T> originalClass)
|
|
| Method Summary | ||
|---|---|---|
static
|
asStub(T entry)
|
|
static
|
castStub(Stub<?> stub,
Class<T> t)
|
|
int |
compareTo(Stub<?> stub)
uses the default UniversalComparator on the displayValue and then on the ID |
|
void |
ensureReferenceString(Database<?> db)
|
|
void |
ensureReferenceString(DBClassStore<T> store)
|
|
boolean |
equals(Object obj)
|
|
Object |
getDisplayValue()
|
|
static PatternExtractor<Stub<?>,Object> |
getIDExtractor()
|
|
Class<T> |
getOriginalClass()
returns the class that this stub represents, so that it is available at runtime and can be used to find the right DBClassStore from a Database. |
|
T |
getOriginalInstance(Database<?> db)
retrieves and returns the original object for this stub |
|
T |
getOriginalInstance(DBClassStore<T> store)
retrieves and returns the original object for this stub |
|
Class<? extends DBEntry> |
getReferenceClass()
indicates the type of DBEntry that represents the class of the reference ID, so that the instance could be looked up in a Database; this may be null only if the reference itself is null, too. |
|
Object |
getReferenceID()
returns the ID of the DBEntry this instance refers to; this may be null only if the reference type returns null, too. |
|
String |
getReferenceString()
provides a meaningful (displayable) description for the referenceID/referenceType or null if there is no reference for this entry. |
|
static
|
getStubExtractor()
|
|
boolean |
isSameReference(DBReference ref)
|
|
static boolean |
isSameReference(DBReference ref1,
DBReference ref2)
|
|
static Stub<?> |
makeStub(DBReference ref)
if the given reference is already a stub, the same is returned; null parameter or empty references result in null as a return value |
|
static
|
makeStub(DBReference ref,
Class<T> type)
combines makeStub(DBReference) and castStub(Stub, Class) |
|
static
|
makeStub(Object id,
Object displayValue,
Class<T> type)
|
|
boolean |
refersTo(DBEntry entry)
|
|
void |
reloadDisplayValue(Database<?> db)
|
|
void |
reloadDisplayValue(DBClassStore<T> store)
|
|
Stub<T> |
reloadInstance(Database<?> db)
|
|
Stub<T> |
reloadInstance(DBClassStore<T> store)
|
|
void |
setDisplayValue(Object displayValue)
|
|
String |
toDetailedString()
provides full details of this instance in a String. |
|
String |
toString()
returns the toString() value of the displayValue or an empty String if displayValue is null |
|
static
|
verify(Stub<?> stub,
Class<T> type)
verifies that the given stub is indeed of the given type |
|
| Methods inherited from class com.antelmann.db.AbstractDBEntry |
|---|
getID, hashCode, hashEntry, sameEntry |
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public Stub(Object id,
Object displayValue,
Class<T> originalClass)
| Method Detail |
|---|
@Warning(value="this unchecked call may actually contain a stub of ? extends T") public static <T extends DBEntry> Stub<T> asStub(T entry)
public static <T extends DBEntry> PatternExtractor<T,Stub<T>> getStubExtractor()
public static PatternExtractor<Stub<?>,Object> getIDExtractor()
public static <T extends DBEntry> Stub<T> makeStub(Object id,
Object displayValue,
Class<T> type)
public static Stub<?> makeStub(DBReference ref)
public static <T extends DBEntry> Stub<T> makeStub(DBReference ref,
Class<T> type)
throws ClassCastException
makeStub(DBReference) and castStub(Stub, Class)
ClassCastException
public static <T extends DBEntry> Stub<T> castStub(Stub<?> stub,
Class<T> t)
throws ClassCastException
ClassCastException
public static <T extends DBEntry> Stub<T> verify(Stub<?> stub,
Class<T> type)
throws IllegalArgumentException
stub - the reference to be checkedtype - the expected type for the reference
IllegalArgumentException - if the given reference was not of the given typeDefaultDBReference.verify(DBReference, Class)public Object getDisplayValue()
public void setDisplayValue(Object displayValue)
public int compareTo(Stub<?> stub)
compareTo in interface Comparable<Stub<?>>public String toString()
toString in class AbstractDBEntrypublic String toDetailedString()
DetailedString
toDetailedString in interface DetailedStringpublic final Class<T> getOriginalClass()
public void ensureReferenceString(Database<?> db)
throws DatabaseException
DatabaseException
public void ensureReferenceString(DBClassStore<T> store)
throws DatabaseException
DatabaseException
public Stub<T> reloadInstance(Database<?> db)
throws DatabaseException
DatabaseException
public Stub<T> reloadInstance(DBClassStore<T> store)
throws DatabaseException
DatabaseException
public void reloadDisplayValue(Database<?> db)
throws DatabaseException
DatabaseException
public void reloadDisplayValue(DBClassStore<T> store)
throws DatabaseException
DatabaseException
public T getOriginalInstance(Database<?> db)
throws DatabaseException
DatabaseException
public T getOriginalInstance(DBClassStore<T> store)
throws DatabaseException
DatabaseExceptionpublic boolean equals(Object obj)
equals in class AbstractDBEntrypublic final boolean refersTo(DBEntry entry)
public final boolean isSameReference(DBReference ref)
public static boolean isSameReference(DBReference ref1,
DBReference ref2)
DefaultDBReference.sameReference(DBReference, DBReference)public final Object getReferenceID()
DBReference
getReferenceID in interface DBReferenceDBEntry.getID(),
DefaultDBReference.isConsistent(DBReference)public final Class<? extends DBEntry> getReferenceClass()
DBReference
getReferenceClass in interface DBReferenceDatabase,
DBEntry#getClass(),
DefaultDBReference.isConsistent(DBReference)public String getReferenceString()
DBReference
getReferenceString in interface DBReference
|
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||