userguide.xml | userguide.xml | |||
---|---|---|---|---|
skipping to change at line 50 | skipping to change at line 50 | |||
The global constant is quick and easy to use, but is shared between all use rs in the <code>ClassLoader</code>. | The global constant is quick and easy to use, but is shared between all use rs in the <code>ClassLoader</code>. | |||
It also cannot be extended. | It also cannot be extended. | |||
</p> | </p> | |||
<p> | <p> | |||
The alternative approach is to instantiate your own instance of <code>Strin gConvert</code>. | The alternative approach is to instantiate your own instance of <code>Strin gConvert</code>. | |||
This would normally be stored in your own static variable, or made availabl e as needed by dependency injection. | This would normally be stored in your own static variable, or made availabl e as needed by dependency injection. | |||
This may be updated by registering your own converters. | This may be updated by registering your own converters. | |||
</p> | </p> | |||
</subsection> | </subsection> | |||
<subsection name="Registering new converters"> | <subsection name="Converters"> | |||
<p> | <p> | |||
Each instance of <code>StringConvert</code>, other than the global singleto | Each instance of <code>StringConvert</code>, including the global singleton | |||
n, may have additional converters registered. | , includes a standard set of JDK-based converters. | |||
These cover all the standard JDK types for which conversion to and from a s | ||||
tring is sensible. | ||||
The set also includes JSR-310 types, but these are optional and loaded by r | ||||
eflection. The system will run without any dependency. | ||||
</p> | ||||
<p> | ||||
Each <code>StringConvert</code> instance, other than the global singleton, | ||||
may have additional converters registered manually. | ||||
Each converter implements the <code>StringConverter</code> interface, which is self explanatory. | Each converter implements the <code>StringConverter</code> interface, which is self explanatory. | |||
</p> | </p> | |||
<p> | <p> | |||
Converters may also be manually added by method name. | ||||
This is equivalent to using annotations, but suitable when you don't own th | ||||
e code to add them. | ||||
See <code>StringConvert.registerMethods</code> and <code>StringConvert.regi | ||||
sterMethodConstructor</code>. | ||||
</p> | ||||
<p> | ||||
A converter can only be registered if one is not already registered for tha t type. | A converter can only be registered if one is not already registered for tha t type. | |||
</p> | </p> | |||
</subsection> | </subsection> | |||
<subsection name="Annotation based conversion"> | <subsection name="Annotation based conversion"> | |||
<p> | <p> | |||
If there is no registered converter for a type, then a search by annotation is performed. | If there is no registered converter for a type, then a search by annotation is performed. | |||
This will search for the <code>ToString</code> and <code>FromString</code> annotation on the type. | This will search for the <code>ToString</code> and <code>FromString</code> annotation on the type. | |||
These annotations will indicate which method should be called to perform th e conversion. | These annotations will indicate which method should be called to perform th e conversion. | |||
</p> | </p> | |||
End of changes. 3 change blocks. | ||||
3 lines changed or deleted | 18 lines changed or added | |||
This html diff was produced by rfcdiff 1.41. The latest version is available from http://tools.ietf.org/tools/rfcdiff/ |