jaxx.runtime.context
Class DefaultJAXXContext

java.lang.Object
  extended by jaxx.runtime.context.DefaultJAXXContext
All Implemented Interfaces:
JAXXContext
Direct Known Subclasses:
DefaultApplicationContext, JAXXInitialContext

public class DefaultJAXXContext
extends Object
implements JAXXContext

The default JAXXContext to be used in a JAXXObject by delegation.

The values are store in a Map but we can not use directly the values as key.

Because, it does not work if we add for the same object multi entries (named and unamed)...

We prefer use as entry the JAXXContextEntryDef associated with the value.

Author:
tchemit

Field Summary
protected  Map<JAXXContextEntryDef<?>,Object> data
          les donnĂ©es contenues dans le context
protected static JAXXContextEntryDef<JAXXContext> PARENT_CONTEXT_ENTRY
          entry of the parent context
protected  JAXXContext parentContext
          le context parent
 
Constructor Summary
DefaultJAXXContext()
           
 
Method Summary
 void clear()
           
<T> T
getContextValue(Class<T> clazz)
          Seek for a unamed entry in the context

This is an exemple to call a method in JAXX :

<JButton onActionPerformed='{getContextValue(Action.class).method(args[])}'/>

<T> T
getContextValue(Class<T> clazz, String name)
          Seek for a named entry in the context
protected  JAXXContextEntryDef<?> getEntry(Class<?> klass, String name)
           
protected  JAXXContextEntryDef<?> getKey(String name, Class<?> klass)
           
 String[] getKeys(Class<?> klass)
          Obtain all the keys of data for a given type.
protected  JAXXContext getParentContext()
           
protected
<T> T
remove0(Class<T> klass, String name)
           
<T> void
removeContextValue(Class<T> klazz)
          Remove from context the value with the given klazz as an unamed entry
<T> void
removeContextValue(Class<T> klazz, String name)
          Remove from context the value with the given klazz as an unamed (if name is null) or named entry
<T> void
setContextValue(T o)
          Push in the context a new unamed entry.
<T> void
setContextValue(T o, String name)
          * Push in the context a new amed entry.
protected  void setParentContext(JAXXContext parentContext)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PARENT_CONTEXT_ENTRY

protected static final JAXXContextEntryDef<JAXXContext> PARENT_CONTEXT_ENTRY
entry of the parent context


parentContext

protected JAXXContext parentContext
le context parent


data

protected final Map<JAXXContextEntryDef<?>,Object> data
les données contenues dans le context

Constructor Detail

DefaultJAXXContext

public DefaultJAXXContext()
Method Detail

setContextValue

public <T> void setContextValue(T o)
Description copied from interface: JAXXContext
Push in the context a new unamed entry.

If a previous entry exists in context (unamed and same class), it will be removed.

Specified by:
setContextValue in interface JAXXContext
Type Parameters:
T - type of data to set in context
Parameters:
o - the value to push in context

setContextValue

public <T> void setContextValue(T o,
                                String name)
Description copied from interface: JAXXContext
* Push in the context a new amed entry.

If a previous entry exists in context (same name and class), it will be removed.

Specified by:
setContextValue in interface JAXXContext
Type Parameters:
T - type of data to set in context
Parameters:
o - the value to push in context
name - the name of the new entry

getContextValue

public <T> T getContextValue(Class<T> clazz)
Description copied from interface: JAXXContext
Seek for a unamed entry in the context

This is an exemple to call a method in JAXX :

<JButton onActionPerformed='{getContextValue(Action.class).method(args[])}'/>

Specified by:
getContextValue in interface JAXXContext
Type Parameters:
T - type of data to obtain from context
Parameters:
clazz - the class of unamed entry to seek in context
Returns:
the value of the unamed entry for the given class, or null if no such entry.

getContextValue

public <T> T getContextValue(Class<T> clazz,
                             String name)
Description copied from interface: JAXXContext
Seek for a named entry in the context

Specified by:
getContextValue in interface JAXXContext
Type Parameters:
T - type of data to obtain from context
Parameters:
clazz - the class of named entry to seek in context
name - the name of the entry to seek in context
Returns:
the value of the named entry for the given class, or null if no such entry.

removeContextValue

public <T> void removeContextValue(Class<T> klazz)
Description copied from interface: JAXXContext
Remove from context the value with the given klazz as an unamed entry

Specified by:
removeContextValue in interface JAXXContext
Type Parameters:
T - type of data to remove from context
Parameters:
klazz - the klazz entry

removeContextValue

public <T> void removeContextValue(Class<T> klazz,
                                   String name)
Description copied from interface: JAXXContext
Remove from context the value with the given klazz as an unamed (if name is null) or named entry

Specified by:
removeContextValue in interface JAXXContext
Type Parameters:
T - type of data to remove from context
Parameters:
klazz - the klazz entry
name - extra name of the entry

getKeys

public String[] getKeys(Class<?> klass)
Obtain all the keys of data for a given type.

Parameters:
klass - the type of searched keys
Returns:
the array of all names of keys for the given type of data
Since:
1.3

clear

public void clear()

getKey

protected JAXXContextEntryDef<?> getKey(String name,
                                        Class<?> klass)

remove0

protected <T> T remove0(Class<T> klass,
                        String name)

getEntry

protected JAXXContextEntryDef<?> getEntry(Class<?> klass,
                                          String name)

getParentContext

protected JAXXContext getParentContext()

setParentContext

protected void setParentContext(JAXXContext parentContext)


Copyright © 2008-2012 CodeLutin. All Rights Reserved.