|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object net.sf.fikin.pojostate.select.AbstractSelector net.sf.fikin.pojostate.select.BeanMethodsSelector net.sf.fikin.pojostate.select.NEFormatterSelector
public class NEFormatterSelector
Name Enahanced Formatter Selector
Based on BeanMethodsSelector
with extended formatting
support based on Method name's suffixes.
It scans Method.getName() and based on predefined set of "suffixes" it will decide what is the appropriate formatting object.
Suffixes and formatting rules are to be defined as Properties in the format: "suffix=class;format mask"
This is convenient when all methods are uniformly named according some rule which does allow one to determine what is the meaning of their returned values.
For example, the following properties file:
will be interpreted as following:
Date=java.text.SimpleDateFormat;dd MMM yyyy HH:mm
Ms=java.text.DurationFormat
Ch=java.text.ChoiceFormat;-1#negative|0#positive
Nested Class Summary | |
---|---|
class |
NEFormatterSelector.NEFMethodMeta
Overwrites default DefaultMethodMeta.getFormat() with custom
based formatters based on Method-name suffixes table. |
Constructor Summary | |
---|---|
NEFormatterSelector()
|
Method Summary | |
---|---|
void |
loadSuffixes(java.io.InputStream suffixes)
load the given input stream into the suffixes table old suffixes are replaced |
protected MethodMeta |
newMethodMeta(java.lang.Class clazz,
java.lang.reflect.Method method,
java.util.Locale locale,
java.lang.ClassLoader loader)
instantiate new NEFormatterSelector.NEFMethodMeta object |
protected java.text.Format |
resolveFormat(java.lang.reflect.Method method,
java.util.Locale locale,
java.lang.ClassLoader loader)
resolve the formatter based on "suffixes" defined in properties file. |
void |
setSuffixes(java.util.Properties suffixes)
assign list of suffixes and formatting rules |
Methods inherited from class net.sf.fikin.pojostate.select.BeanMethodsSelector |
---|
getFilteroutObject, isApplicable, setFilteroutObject |
Methods inherited from class net.sf.fikin.pojostate.select.AbstractSelector |
---|
getMethodMeta |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public NEFormatterSelector()
Method Detail |
---|
public void setSuffixes(java.util.Properties suffixes)
suffixes
- public void loadSuffixes(java.io.InputStream suffixes) throws java.io.IOException
old suffixes are replaced
suffixes
-
java.io.IOException
protected MethodMeta newMethodMeta(java.lang.Class clazz, java.lang.reflect.Method method, java.util.Locale locale, java.lang.ClassLoader loader) throws DecorationException
NEFormatterSelector.NEFMethodMeta
object
newMethodMeta
in class BeanMethodsSelector
clazz
- is POJO's classmethod
- to be includedlocale
- to be used when creating the metadataloader
- is the classloader to be used to load any resource
file (if required)
NEFormatterSelector.NEFMethodMeta
object
DecorationException
- in case of internal errorprotected java.text.Format resolveFormat(java.lang.reflect.Method method, java.util.Locale locale, java.lang.ClassLoader loader)
if no suitable formatter is found it will return null.
method
- is method being created meta forlocale
- to be used when creating the metadataloader
- is the classloader to be used to load any resource
file (if required)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |