JMMF API
pre-release v0.8

fr.umlv.jmmf.adapter
Class AdapterFactory

java.lang.Object
  |
  +--fr.umlv.jmmf.adapter.AdapterFactory

public class AdapterFactory
extends java.lang.Object

a factory for a generated specialized adapter. There 3 parts in the factory interface :

All adapter created by this factory implements the Adapter interface.
code code code
TO DO: cache generated classes. must improve object allocations.

Version:
0.8.4
Author:
Remi Forax
See Also:
Adapter

Field Summary
static int SEND_ADAPTEE
           
static int SEND_ADAPTER
           
static int SEND_NONE
           
 
Constructor Summary
AdapterFactory()
          construct a default adapter factory.
 
Method Summary
 void addField(java.lang.String name)
          ask to create a new field for all adapters.
 void addField(java.lang.String name, java.lang.Object defaultValue)
          ask to create a new field for all adapters.
 void addField(java.lang.String name, java.lang.Object defaultValue, java.util.Map map)
          ask to create a new field for all adapters.
 void addInterface(java.lang.Class interfaze)
          add an interface for all generated adapter.
 void addInterface(java.lang.Class adapteeClass, java.lang.Class interfaze)
          add an interface for all adapter for which the adaptee implements adapteeClass.
 void addInterface(java.lang.Class adapteeClass, java.lang.Class interfaze, boolean wrappable)
          add an interface for all adapter for which the adaptee implements adapteeClass.
 void addMultiMethod(java.lang.Object target, MultiMethod mm)
          add multimethod as an implementation of all adapter.
 void addMultiMethod(java.lang.Object target, MultiMethod mm, int invocationOption)
          add multimethod for an adaptee class.
 java.lang.Object create(java.lang.Object adaptee)
          generate a specialized adapter.
protected  java.lang.Object defaultTraversal(java.lang.reflect.Method method, java.lang.Object adaptee, java.lang.Object adapter, java.lang.Object[] args)
          called if no method matching.
 AdapterHook getHook()
          get the hook for all adapters.
protected  java.lang.Class[] getInterfaces(java.lang.Class adapteeClass)
           
 boolean getTransparency()
          get the transparency flag. if this flag is true, the interfaces of the adaptee is implemented by the generic adapter.
 boolean isWrappable(java.lang.Class clazz)
          return true if the class object is register as wrappable.
protected  boolean isWrappable(java.lang.Object object)
           
 void setAdapteeMultiFactory(MultiFactory multiFactory)
          set the multi-method factory for adaptee.
 void setAdapterUnicity(boolean unicity)
          garantee unicity of association between adaptee and adapter.
 void setHook(AdapterHook hook)
          set the hook for all adapters.
 void setTransparency(boolean transparency)
          set the transparency flag. if this flag is true, the interfaces of the adaptee is implemented by the generic adapter.
 void setWrappable(java.lang.Class aClass, boolean wrappable)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SEND_NONE

public static final int SEND_NONE

SEND_ADAPTEE

public static final int SEND_ADAPTEE

SEND_ADAPTER

public static final int SEND_ADAPTER
Constructor Detail

AdapterFactory

public AdapterFactory()
construct a default adapter factory.
Method Detail

setHook

public void setHook(AdapterHook hook)
set the hook for all adapters.
Throws:
java.lang.IllegalArgumentException - if hook is null.

getHook

public AdapterHook getHook()
get the hook for all adapters.

setAdapterUnicity

public void setAdapterUnicity(boolean unicity)
garantee unicity of association between adaptee and adapter. There is only one adapter for an adaptee. adapter unicity is false by default.

setAdapteeMultiFactory

public void setAdapteeMultiFactory(MultiFactory multiFactory)
set the multi-method factory for adaptee.

setTransparency

public void setTransparency(boolean transparency)
set the transparency flag. if this flag is true, the interfaces of the adaptee is implemented by the generic adapter.
Parameters:
keepAdapteeInterfaces - the new value of the flag.

getTransparency

public boolean getTransparency()
get the transparency flag. if this flag is true, the interfaces of the adaptee is implemented by the generic adapter.
Returns:
the value of the transparency flag.

setWrappable

public void setWrappable(java.lang.Class aClass,
                         boolean wrappable)

addInterface

public void addInterface(java.lang.Class interfaze)
add an interface for all generated adapter.
Parameters:
interfaze - interface that all generated adapter must implements.

addInterface

public void addInterface(java.lang.Class adapteeClass,
                         java.lang.Class interfaze)
add an interface for all adapter for which the adaptee implements adapteeClass.
Parameters:
adapteeClass - class of one adaptee.
interfaze - all generated adapter that wrapped an adaptee that implements the adapteeClass must implements this interface.

addInterface

public void addInterface(java.lang.Class adapteeClass,
                         java.lang.Class interfaze,
                         boolean wrappable)
add an interface for all adapter for which the adaptee implements adapteeClass.
Parameters:
adapteeClass - class of one adaptee.
interfaze - all generated adapter that wrapped an adaptee that implements the adapteeClass must implements this interface.
wrappable - a flag that
See Also:
setWrappable(Class,boolean)

addMultiMethod

public void addMultiMethod(java.lang.Object target,
                           MultiMethod mm)
add multimethod as an implementation of all adapter.
Parameters:
target - target of the multi-method, the target may be null.
mm - multi-method.

addMultiMethod

public void addMultiMethod(java.lang.Object target,
                           MultiMethod mm,
                           int invocationOption)
add multimethod for an adaptee class.
Parameters:
target - target of the multi-method, the target may be null.
mm - multi-method.
invocationOption - which first parameter is send to the multi-method.
This flag could contains three differents values :
SEND_NONE
if there no new first parameter.
SEND_ADAPTEE
if the adaptee is send as first parameter.
SEND_ADAPTER
if the adapter is send as first parameter.

addField

public void addField(java.lang.String name)
ask to create a new field for all adapters.
Parameters:
name - name of the field.

addField

public void addField(java.lang.String name,
                     java.lang.Object defaultValue)
ask to create a new field for all adapters.
Parameters:
name - name of the field.
defaultValue - initial value of the field.

addField

public void addField(java.lang.String name,
                     java.lang.Object defaultValue,
                     java.util.Map map)
ask to create a new field for all adapters.
Parameters:
name - name of the field.
defaultValue - initial value of the field.
map - associative map between adaptee and field value.

create

public java.lang.Object create(java.lang.Object adaptee)
generate a specialized adapter.
Parameters:
adaptee - object wrapped in the adapter.
Returns:
a specialized adapter that implements all interfaces.

isWrappable

protected boolean isWrappable(java.lang.Object object)

isWrappable

public boolean isWrappable(java.lang.Class clazz)
return true if the class object is register as wrappable.
See Also:
setWrappable(Class,boolean)

getInterfaces

protected java.lang.Class[] getInterfaces(java.lang.Class adapteeClass)

defaultTraversal

protected java.lang.Object defaultTraversal(java.lang.reflect.Method method,
                                            java.lang.Object adaptee,
                                            java.lang.Object adapter,
                                            java.lang.Object[] args)
called if no method matching. Default implementation throw a UnsupportedOperationException.
Throws:
UnsupportedOperationException - always thrown.

JMMF API
pre-release v0.8

Rémi Forax 1999,2000 Université de Marne la Vallée