Jetif v1.8.0

jetif.handler
Class ArrayHandler

java.lang.Object
  extended byjetif.Handler
      extended byjetif.handler.ArrayHandler

public class ArrayHandler
extends Handler

The ArrayHandler is used to handle array object.

Author:
Vicky Wang

Constructor Summary
ArrayHandler()
          Default contructor
 
Method Summary
 boolean matches(String value, String type, Object obj)
          Indicate an object matches the expected value.
 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 value, String type, Class clazz)
          Convert a string value to object of specified class.
 String toString(Object obj)
          Convert a result object to string.
 
Methods inherited from class jetif.Handler
getProperty, getProperty, isInstanceClass, setProperties
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ArrayHandler

public ArrayHandler()
Default contructor

Method Detail

toObject

public Object toObject(String value,
                       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:
value - 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.

toString

public String toString(Object obj)
Description copied from class: Handler
Convert a result object to string. The method allows the user custom the string representation in test result. The parameter is the object returned by test method or exception throwed by test method. The return string is only used for result recording, and will be contained by MethodResult. The test listener will get it through MethodResult.getActual().
Note: Be careful because the parameter may be null.

Overrides:
toString in class Handler
Parameters:
obj - the object to be converted.
Returns:
the string representation of the object.
See Also:
MethodResult.getActual()

matches

public boolean matches(String value,
                       String type,
                       Object obj)
Description copied from class: Handler
Indicate an object matches the expected value. This method is used to determine if a return value of test method matches the expected value.

Overrides:
matches in class Handler
Parameters:
value - the expected value.
type - the desired type in spec.
obj - the object to be tested.
Returns:
true if the object matches the expected value.

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.

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.

Jetif v1.8.0

Copyright © 2004,2005 Vicky Wang - All Rights Reserved.