jetif.handler
Class CollectionHandler
java.lang.Object
jetif.Handler
jetif.handler.CollectionHandler
- public class CollectionHandler
- extends Handler
The CollectionHandler maps string to a collection.
This handler takes a full class name as argument, which will be treated as element type
of this collection.
For example:
<handler name="collection" class="jetif.handler.CollectionHandler">java.lang.Integer</handler>
The element will be converted to Integer type and put into the collection.
To use the handler, the intput value should be some elements separated with comma.
For example:
<param type="java.util.Vector" handler="collection">element0, element1, element2</param>
- Author:
- Vicky Wang
|
Method Summary |
boolean |
reusable()
Indicate that if this handler can be reuse for different object.
|
boolean |
supports(String type,
Class clazz)
Test if a type can be converted to specified class with this handler.
|
Object |
toObject(String v,
String type,
Class clazz)
Convert a string value to object of specified class. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
CollectionHandler
public CollectionHandler(String arg)
throws ClassNotFoundException
toObject
public Object toObject(String v,
String type,
Class clazz)
throws UnsupportedTypeException,
ConversionException
- Description copied from class:
Handler
- Convert a string value to object of specified class.
- Specified by:
toObject in class Handler
- Parameters:
v - the string value to be converted.type - the desired type in spec, it may be a derived class
of the target class, and will be null if it's not defined.clazz - the specified type of object.
- Returns:
- the object instance.
- Throws:
ConversionException - error occurs when convert the object.
UnsupportedTypeException - occurs if the desired class not supported
by this handler.
supports
public boolean supports(String type,
Class clazz)
- Description copied from class:
Handler
- Test if a type can be converted to specified class with this handler.
Overwrite this method to custom procedure to determine if a type
is supported by custom handler.
The default implementation return true if the type is not specified,
or the target class is assignable from the desired type.
- Overrides:
supports in class Handler
- Parameters:
type - the desired type in spec, it may be a derived class of
target class, and will be null if undefined.clazz - the target class.
- Returns:
- true if the conversion is supported by this handler.
reusable
public boolean reusable()
- Description copied from class:
Handler
- Indicate that if this handler can be reuse for different object.
The framework will cache all reusable handler, while create a new instance for
each object if it can't be reused.
Note: It may be a performance issue if the handler is not reusable.
- Specified by:
reusable in class Handler
- Returns:
- true if this handler can be reuse.
Copyright © 2004,2005 Vicky Wang - All Rights Reserved.