protected class JContextFactory.JContext extends JComponent implements Context
Context
.Modifier and Type | Class and Description |
---|---|
protected class |
JContextFactory.JContext.InnerEnumeration |
Context.NO_VALUE
Modifier and Type | Field and Description |
---|---|
protected Context |
enclosing_context
The enclosing context (scope)
|
protected int |
id
Identifies the target context
|
int_value, reference, type, value
Modifier | Constructor and Description |
---|---|
protected |
JContext()
Constructs a new JContext instance.
|
protected |
JContext(Context _scope)
Creates a new JContext with the specified enclosing context.
|
Modifier and Type | Method and Description |
---|---|
void |
acquire()
Acquires the target context.
|
Element |
addElement(Name _name,
java.lang.Class _type,
int _value)
Adds an element to the target context.
|
Element |
addElement(Name _name,
java.lang.Class _type,
java.lang.Object _value)
Adds an element in the target context.
|
Element |
addElement(Name _name,
Component _component)
Adds an element in the target context.
|
Element |
addElement(java.lang.String name,
java.lang.Class type,
int value,
char separator)
Adds an element to the target context.
|
Element |
addElement(java.lang.String name,
java.lang.Class type,
java.lang.Object value,
char separator)
Adds an element to the target context.
|
Element |
addElement(java.lang.String _name,
Component _component,
char separator)
Adds an element to the target context.
|
protected Element |
addLocalElement(JContextFactory.ContextElement element,
boolean _check_types)
Adds an Element to the Context if no other exists with the same name.
|
Context |
addOrGetContext(Name _name) |
Context |
addOrGetContext(java.lang.String _name,
char _separator) |
protected JContextFactory.JContext |
addOrGetLocalContext(java.lang.String _id) |
Component |
duplicate() |
protected void |
finalize() |
Component |
getComponent(java.lang.String name,
char separator)
Returns the component contained in the element registered in the target context under
the name
name . |
Element |
getElement(Name _name)
may need to be synchronized
|
protected Element |
getElement(java.lang.String name,
boolean local)
Returns the local element identified by name, or null if none exists.
|
Element |
getElement(java.lang.String _name,
char _separator)
Returns the element in the target context identified by
name ,
null if no element is registered under name name . |
java.util.Enumeration |
getElements()
Returns an enumeration of the elements found in the target context.
|
java.lang.Object |
getFactoryValue(java.lang.String name,
char separator) |
int |
getIntValue(Name _name)
Returns the value of the element registered in the target context under
the name
name . |
int |
getIntValue(java.lang.String name,
char separator)
Returns the value of the element registered in the target context under
the name
name . |
Context |
getScope()
Returns the scope of the target context;
|
java.lang.Object |
getValue(java.lang.String name,
char separator)
Returns the value of the element registered in the target context under
the name
name . |
protected Element |
handleScopeElement(Element element) |
Component |
internalFork() |
protected Component |
newComponent(java.lang.Class type,
int value) |
protected Component |
newComponent(java.lang.Class type,
java.lang.Object value) |
protected JContextFactory.ContextElement |
newContextElement(Context _container)
Creates a new empty context element.
|
protected JContextFactory.ContextElement |
newContextElement(java.lang.String name,
Component component,
Context container)
Creates a new context element, using the provided parameters
to initialize it.
|
protected void |
recycle() |
void |
release()
Releases the target context, releasing all the resources it uses, if no one still
uses it.
|
void |
reset()
needs to be synchronized.
|
Context |
setScope(Context scope)
Sets the scope of the target context;
|
java.lang.String |
toString() |
fork, getComponent, getFactoryValue, getIntValue, getReference, getType, getValue, getValue, setReference
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
fork, getComponent, getFactoryValue, getIntValue, getReference, getType, getValue, getValue, setReference
protected Context enclosing_context
protected final int id
protected JContext()
protected JContext(Context _scope)
_scope
- a Context.public final Element getElement(Name _name)
getElement
in interface Component
getElement
in class JComponent
_name
- _name
, if any.public final int getIntValue(Name _name)
Context
name
.
A call to getIntValue(name)
is equivalent to
if the provided name actually corresponds to an
element. If it is not the case,
getElement(name)
.getIntValue()
Integer.MAX_VALUE
is returned.
getIntValue
in interface Context
_name
- the name of the element whose value is seeked;Integer.MAX_VALUE
public final Element getElement(java.lang.String _name, char _separator)
Context
name
,
null if no element is registered under name name
.
This method is equivalent to getElement(Name)
, except that the name to use
is specified by a string and a separator separating the different elements of
the name.
If separator == 0
, the name corresponds to an object
local to the target context.
If the name begins with the separator, the name is an absolute name (this
only makes sense if the context has a tree structure); otherwise, the name is
relative to the target context.getElement
in interface Context
_name
- a string representing the name of the seeked element;_separator
- the separator character used to parse name
;public final Component getComponent(java.lang.String name, char separator)
Context
name
.
This method is equivalent to getComponent(Name)
, except that the name to use
is specified by a string and a separator separating the different elements of
the name.
If separator == 0
, the name corresponds to an object
local to the target context.
If the name begins with the separator, the name is an absolute name (this
only makes sense if the context has a tree structure); otherwise, the name is
relative to the target context.getComponent
in interface Context
name
- the name of the element whose component is seeked;separator
- the separator character used to parse name
;public final java.lang.Object getFactoryValue(java.lang.String name, char separator) throws JonathanException
JonathanException
public final java.lang.Object getValue(java.lang.String name, char separator)
Context
name
.
This method is equivalent to getValue(Name)
, except that the name to use
is specified by a string and a separator separating the different elements of
the name.
If separator == 0
, the name corresponds to an object
local to the target context.
If the name begins with the separator, the name is an absolute name (this
only makes sense if the context has a tree structure); otherwise, the name is
relative to the target context.public final int getIntValue(java.lang.String name, char separator)
Context
name
.
This method is equivalent to getIntValue(Name)
, except that the name to use
is specified by a string and a separator separating the different elements of
the name.
If separator == 0
, the name corresponds to an object
local to the target context.
If the name begins with the separator, the name is an absolute name (this
only makes sense if the context has a tree structure); otherwise, the name is
relative to the target context.getIntValue
in interface Context
name
- the name of the element whose value is seeked;separator
- the separator character used to parse name
;Integer.MAX_VALUE
public final Element addElement(Name _name, Component _component) throws JonathanException
Context
addElement
in interface Context
_name
- the name of the element to be added;_component
- the component to be added;JonathanException
- if something goes wrong (usually, a type
exception).public final Element addElement(Name _name, java.lang.Class _type, java.lang.Object _value) throws JonathanException
Context
addElement
in interface Context
_name
- the name of the object to be added;_type
- the type of the object to be added;_value
- the object to be added.JonathanException
- if something goes wrong (usually, a type
exception).public final Element addElement(Name _name, java.lang.Class _type, int _value) throws JonathanException
Context
Class
is one of int.class, short.class, char.class,
or byte.class.addElement
in interface Context
_name
- the name of the element to be added;_value
- the integer value of the element to be added;JonathanException
- if something goes wrong (usually, a type
exception).public final Element addElement(java.lang.String _name, Component _component, char separator) throws JonathanException
Context
addElement(Name,Component)
, except that the name to use
is specified by a string and a separator separating the different elements of
the name.
If separator == 0
, the name corresponds to an object
local to the target context.
If the name begins with the separator, the name is an absolute name (this
only makes sense if the context has a tree structure); otherwise, the name is
relative to the target context.addElement
in interface Context
_name
- a string representing the name of the added element;_component
- the component to be added;separator
- the separator character used to parse name
;JonathanException
- if something goes wrong (usually, a type
exception).public final Element addElement(java.lang.String name, java.lang.Class type, java.lang.Object value, char separator) throws JonathanException
Context
addElement(Name,Class,Object)
, except that the name to use
is specified by a string and a separator separating the different elements of
the name.
If separator == 0
, the name corresponds to an object
local to the target context.
If the name begins with the separator, the name is an absolute name (this
only makes sense if the context has a tree structure); otherwise, the name is
relative to the target context.addElement
in interface Context
name
- a string representing the name of the seeked element;type
- the type of the object to be added;value
- the object to be added;separator
- the separator character used to parse name
;JonathanException
- if something goes wrong (usually, a type
exception).public final Element addElement(java.lang.String name, java.lang.Class type, int value, char separator) throws JonathanException
Context
addElement(Name,Class,int)
, except that the name to use
is specified by a string and a separator separating the different elements of
the name.
If separator == 0
, the name corresponds to an object
local to the target context.
If the name begins with the separator, the name is an absolute name (this
only makes sense if the context has a tree structure); otherwise, the name is
relative to the target context.addElement
in interface Context
name
- a string representing the name of the seeked element;value
- the integer value of the element to be added;separator
- the separator character used to parse name
;JonathanException
- if something goes wrong (usually, a type
exception).public Context addOrGetContext(java.lang.String _name, char _separator) throws JonathanException
addOrGetContext
in interface Context
JonathanException
public Context addOrGetContext(Name _name) throws JonathanException
addOrGetContext
in interface Context
JonathanException
public java.util.Enumeration getElements()
Context
getElements
in interface Context
public Context getScope()
Context
public Component internalFork()
internalFork
in interface Forkable
internalFork
in class JComponent
public Context setScope(Context scope)
Context
public void reset()
reset
in interface Context
reset
in class JComponent
public void acquire()
Context
public void release()
Context
public Component duplicate()
duplicate
in class JComponent
public java.lang.String toString()
toString
in class JComponent
protected void recycle()
protected Element getElement(java.lang.String name, boolean local)
name
- a local name;local
- if true, don't search the enclosing context.protected Element addLocalElement(JContextFactory.ContextElement element, boolean _check_types) throws JonathanException
must be called in a synchronized context
name
- the name of the new Element.type
- the declared type of the new Element.value
- the value of the Element to be inserted.JonathanException
protected JContextFactory.ContextElement newContextElement(Context _container)
protected final JContextFactory.ContextElement newContextElement(java.lang.String name, Component component, Context container)
name
- a name;type
- a type;value
- an object reference value;int_value
- an integer value;protected Component newComponent(java.lang.Class type, java.lang.Object value)
protected Component newComponent(java.lang.Class type, int value)
protected void finalize() throws java.lang.Throwable
finalize
in class java.lang.Object
java.lang.Throwable
protected JContextFactory.JContext addOrGetLocalContext(java.lang.String _id) throws JonathanException
JonathanException