|
2.17.2: 2011-06-17 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface ValueConverter
Interface for classes that wants to inspect/convert parameters from the XML file before they are passed to factory setter methods.
Instances of this class are registered with an XML loader
with the XmlLoader.addValueConverter(ValueConverter)
method.
Before a factory setter method is called, all registered
converters will get the chance to convert(String, Method)
the parameter value from the XML file. The converters are
called in the order they are registered.
A typical implementation of a converter is to check if the setter method has been annotated with some specific annotation. If, so the value is converted, otherwise it is returned without modification.
// Add a prefix to all strings. @Override public String convert(String in, Method method) { if (!method.isAnnotationPresent(AddPrefix.class)) return in; return in == null ? PREFIX : PREFIX + in; }
Note! Since each registered converter is invoked everytime a
factory setter method is about to be called, we recommend that
the convert(String, Method)
method is kept as quick
as possible.
Method Summary | |
---|---|
String |
convert(String in,
Method method)
Convert a value. |
Method Detail |
---|
String convert(String in, Method method)
in
- The value to convertmethod
- The factory setter method
|
2.17.2: 2011-06-17 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |