|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.ryanm.preflect.VariableType<T>
T - Type of variable to handlepublic abstract class VariableType<T>
Extend this to define new variable types. You'll need code to encode an
decode a value to and from strings, construct an appropriate
Preference, and optionally to validate/format user input. Remember to
register(VariableType) your new variable type or it won't be used
| Field Summary | |
|---|---|
java.lang.Class<? extends T> |
type
Variable type |
| Constructor Summary | |
|---|---|
protected |
VariableType(java.lang.Class<? extends T> type)
|
| Method Summary | |
|---|---|
protected abstract Preference |
buildPreference(Context context,
java.lang.Class type,
java.lang.String value)
Build a widget to control the supplied variable. |
abstract T |
decode(java.lang.String encoded,
java.lang.Class runtimeType)
Decodes the encoded string into a value object |
abstract java.lang.String |
encode(T value)
Encodes the value of a given object |
protected java.lang.String |
formatInput(java.lang.Object input)
Default format behaviour, just does toString(). |
static void |
register(VariableType varType)
Call this to register your VariableTypes |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public final java.lang.Class<? extends T> type
| Constructor Detail |
|---|
protected VariableType(java.lang.Class<? extends T> type)
type - | Method Detail |
|---|
public abstract java.lang.String encode(T value)
value - The value to encode
public abstract T decode(java.lang.String encoded,
java.lang.Class runtimeType)
throws ParseException
encoded - The encoded stringruntimeType - The desired type of the object
ParseException - If there is a problem parsing the encoded string
protected abstract Preference buildPreference(Context context,
java.lang.Class type,
java.lang.String value)
context - Well who'd have thought it! A context!type - runtime type of the variable. Needed to get enum values, not
much use otherwisevalue - The current value of the variable
ViewformatInput(Object)protected java.lang.String formatInput(java.lang.Object input)
Toasted at the user
input - The user input, fresh from the Preference created in
buildPreference(Context, Class, String)
public static void register(VariableType varType)
VariableTypes
varType -
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||