public abstract class Configurator extends Object
<config car.engine.sparkPlug.condition="poor"/>
Given a Car instance car and assuming the method setCondition(String) exists within the SparkPlug class,
Configurator does the following:
car.getEngine().getSparkPlug().setCondition("poor");
Now let's pretend that setCondition takes an instance of the Condition enum as it's argument.
Configurator then does the following:
car.getEngine().getSparkPlug().setCondition(Condition.valueOf("poor");
Now let's look at how ints are handled. Given the following xml:
| Modifier and Type | Field and Description |
|---|---|
protected static String |
CFG_ELEMENT_NAME |
| Constructor and Description |
|---|
Configurator() |
| Modifier and Type | Method and Description |
|---|---|
protected static String |
argArrToString(Object[] args) |
static void |
configure(android.content.Context ctx,
Object obj,
HashMap<String,String> params) |
static void |
configure(android.content.Context ctx,
Object obj,
int xmlFileId) |
protected static void |
configure(android.content.Context ctx,
Object obj,
String key,
String value)
Recursively descend into an object using key as the pathway and invoking the corresponding setter
if one exists.
|
protected static Method |
getGetter(Class clazz,
String fieldId) |
protected static Object |
getObjectContaining(Object obj,
String path)
Returns the object containing the field specified by path.
|
protected static Method |
getSetter(Class clazz,
String fieldId) |
protected static float |
parseFloatAttr(android.content.Context ctx,
String value)
Treats value as a float parameter.
|
protected static int |
parseIntAttr(android.content.Context ctx,
String value) |
protected static int |
parseResId(android.content.Context ctx,
String prefix,
String value) |
protected static String |
parseStringAttr(android.content.Context ctx,
String value) |
protected static final String CFG_ELEMENT_NAME
protected static int parseResId(android.content.Context ctx,
String prefix,
String value)
protected static int parseIntAttr(android.content.Context ctx,
String value)
protected static float parseFloatAttr(android.content.Context ctx,
String value)
ctx - value - protected static Method getSetter(Class clazz, String fieldId) throws NoSuchMethodException
NoSuchMethodExceptionprotected static Method getGetter(Class clazz, String fieldId) throws NoSuchMethodException
NoSuchMethodExceptionprotected static Object getObjectContaining(Object obj, String path) throws InvocationTargetException, IllegalAccessException, NoSuchMethodException
obj - path - Path through member hierarchy to the destination field.InvocationTargetExceptionIllegalAccessExceptionNoSuchMethodExceptionpublic static void configure(android.content.Context ctx,
Object obj,
int xmlFileId)
ctx - obj - xmlFileId - ID of the XML config file within /res/xmlpublic static void configure(android.content.Context ctx,
Object obj,
HashMap<String,String> params)
protected static void configure(android.content.Context ctx,
Object obj,
String key,
String value)
throws InvocationTargetException,
IllegalAccessException,
NoSuchMethodException
key - value - InvocationTargetExceptionIllegalAccessExceptionNoSuchMethodException