|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.tapestry5.util.DefaultPrimaryKeyEncoder<K,V>
K
- the key type (which must be serializable)V
- the value typePrimaryKeyEncoder
.
public class DefaultPrimaryKeyEncoder<K extends java.io.Serializable,V>
A default, extensible version of PrimaryKeyEncoder
that is based on loading known values
into an internal map. When there's a reasonable number (hundreds, perhaps thousands) of items to choose from, and
those items are fast and cheap to read and instantiate, this implementation is a good bet. For very large result
sets, you'll need to create your own implementation of PrimaryKeyEncoder
.
Constructor Summary | |
---|---|
DefaultPrimaryKeyEncoder()
Deprecated. Compatibility with 5.0: new encoder, key type unknown. |
|
DefaultPrimaryKeyEncoder(java.lang.Class<K> keyType)
Deprecated. |
Method Summary | |
---|---|
void |
add(K key,
V value)
Deprecated. Adds a new key/value pair to the encoder. |
java.util.List<V> |
getAllValues()
Deprecated. |
java.lang.Class<K> |
getKeyType()
Deprecated. Returns the type of key. |
java.util.List<V> |
getValues()
Deprecated. Returns the values previously added to the encoder , in the order in which
they were added. |
protected boolean |
inKeySet(java.util.Set<K> keySet)
Deprecated. Returns true if the current key is in the provided set. |
boolean |
isDeleted()
Deprecated. |
protected java.util.Set<K> |
modifyKeySet(java.util.Set<K> keySet,
boolean value)
Deprecated. Modifies a keySet to add or remove the current key. |
void |
prepareForKeys(java.util.List<K> keys)
Deprecated. Does nothing. |
protected V |
provideMissingObject(K key)
Deprecated. Invoked by toValue(Serializable) whenever a key can not be converted to a value using the internal
cache. |
void |
setDeleted(boolean value)
Deprecated. |
K |
toKey(V value)
Deprecated. For a previously added key/value pair , returns the key corresponding to the
given value. |
V |
toValue(K key)
Deprecated. For a particular primary key, previously obtained via PrimaryKeyEncoder.toKey(Object) , this method returns the same or
equivalent object. |
protected java.util.List<V> |
valuesNotInKeySet(java.util.Set<K> keySet)
Deprecated. Returns a list of all the values except those values whose keys are in the provided set. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public DefaultPrimaryKeyEncoder()
public DefaultPrimaryKeyEncoder(java.lang.Class<K> keyType)
Method Detail |
---|
public java.lang.Class<K> getKeyType()
PrimaryKeyEncoder
ValueEncoder
.
getKeyType
in interface PrimaryKeyEncoder<K extends java.io.Serializable,V>
public final void add(K key, V value)
public final java.util.List<V> getValues()
added to the encoder
, in the order in which
they were added. Values that are deleted are not returned.
protected final java.util.List<V> valuesNotInKeySet(java.util.Set<K> keySet)
keySet
- set of keys identifying values to exclude, or null to exclude no values
public final java.util.List<V> getAllValues()
public final K toKey(V value)
added key/value pair
, returns the key corresponding to the
given value.
toKey
in interface PrimaryKeyEncoder<K extends java.io.Serializable,V>
value
- whose primary key is needed
public final V toValue(K key)
PrimaryKeyEncoder
PrimaryKeyEncoder.toKey(Object)
, this method returns the same or
equivalent object.
toValue
in interface PrimaryKeyEncoder<K extends java.io.Serializable,V>
key
- used to identify the object
protected V provideMissingObject(K key)
toValue(Serializable)
whenever a key can not be converted to a value using the internal
cache. This is an opportunity to record the fact that an error occured (they key was not valuable, possibly
because it points to a deleted entity object) and provide a temporary object. This method may return null, but in
a typical application, that will likely case NullPointerExceptions further down the processing chain.
This implementation returns null, and is intended to be overriden in subclasses.
key
- key for which a value is required
public final boolean isDeleted()
public final void setDeleted(boolean value)
protected final boolean inKeySet(java.util.Set<K> keySet)
keySet
- the set of keys to check, or null
protected final java.util.Set<K> modifyKeySet(java.util.Set<K> keySet, boolean value)
private Set myFlagKeys;
public boolean void setMyFlag(boolean value) { myFlagKeys = modifySet(myFlagKeys, value); }
keySet
- the set of keys, or nullvalue
- true to add the current key, false to remove
public void prepareForKeys(java.util.List<K> keys)
prepareForKeys
in interface PrimaryKeyEncoder<K extends java.io.Serializable,V>
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |