站内搜索: 请输入搜索关键词
当前页面: 在线文档首页 > JBoss 4.0.1 sp1 common API Documentation 英文版文档

CoercionHandler (JBoss/Common API) - JBoss 4.0.1 sp1 common API Documentation 英文版文档


org.jboss.util.coerce
Class CoercionHandler

java.lang.Object
  extended byorg.jboss.util.coerce.CoercionHandler
Direct Known Subclasses:
BoundCoercionHandler

public abstract class CoercionHandler
extends Object

An abstract class to allow extending the default behavior of Objects.coerce(Object,Class) when it is not possible to implement Coercible directly in the target class or where coercion is desired from an unrelated class. Also provides a registry for all of the currently installed handlers.

Version:
$Revision: 1.5 $
Author:
Jason Dillon

Constructor Summary
CoercionHandler()
           
 
Method Summary
abstract  Object coerce(Object value, Class type)
          Coerce the given value into the specified type.
static CoercionHandler create(Class type)
          Create a CoercionHandler for the given class type.
 Class getType()
          Get the target class type for this CoercionHandler.
static void install(BoundCoercionHandler handler)
          Install a BoundCoercionHandler.
static void install(Class type, CoercionHandler handler)
          Install a CoercionHandler for a given class type.
static boolean isInstalled(Class type)
          Check if there is a CoercionHandler installed for the given class.
static CoercionHandler lookup(Class type)
          Lookup the CoercionHandler for a given class.
static void uninstall(Class type)
          Uninstall a CoercionHandler for a given class type.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CoercionHandler

public CoercionHandler()
Method Detail

coerce

public abstract Object coerce(Object value,
                              Class type)
                       throws CoercionException
Coerce the given value into the specified type.

Parameters:
value - Value to coerce
type - Object type to coerce into
Returns:
Coerced value
Throws:
CoercionException - Failed to coerce

getType

public Class getType()
Get the target class type for this CoercionHandler.

Returns:
Class type
Throws:
NotImplementedException - Handler is not bound

install

public static void install(Class type,
                           CoercionHandler handler)
Install a CoercionHandler for a given class type.

Parameters:
handler - Coercion handler
Throws:
NullArgumentException - type or handler

install

public static void install(BoundCoercionHandler handler)
Install a BoundCoercionHandler.

Parameters:
handler - Bound coercion handler
Throws:
NullArgumentException - handler

uninstall

public static void uninstall(Class type)
Uninstall a CoercionHandler for a given class type.

Parameters:
type - Class type
Throws:
NullArgumentException - type

isInstalled

public static boolean isInstalled(Class type)
Check if there is a CoercionHandler installed for the given class.

Parameters:
type - Class type
Returns:
True if there is a CoercionHandler

lookup

public static CoercionHandler lookup(Class type)
Lookup the CoercionHandler for a given class.

Parameters:
type - Class type
Returns:
A CoercionHandler or null if there is no installed handler
Throws:
NullArgumentException - type

create

public static CoercionHandler create(Class type)
Create a CoercionHandler for the given class type.

Parameters:
type - Class type
Returns:
A CoercionHandler instance for the given class type.
Throws:
CoercionException - No installed handler for type


Copyright © 2002 JBoss Group, LLC. All Rights Reserved.