|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectelectric.util.Context
Context is a collection of key/value pairs, and is an enhanced form of the standard Java electric.util.Properties class because it allows more than one value to be associated with a particular key. You can associate a Context object with a service or proxy to modify its behavior. For example, you can use a Context object to set the activation mode of a service or the authentication credentials of a proxy. You can add one or more listeners to a context to receive callbacks when properties are added or deleted.
Constructor Summary | |
Context()
Construct an empty Context. |
|
Context(Context context)
Construct a shallow copy of the specified context. |
Method Summary | |
void |
addContext(Context context)
Add the properties in the specified context using addProperty(). |
void |
addListener(IContextListener listener)
Add the specified listener to this context. |
void |
addProperty(java.lang.String name,
java.lang.Object value)
Add a new assocation between the specified name and property. |
static Context |
application()
Return the context associated with this application. |
static Context |
get(java.lang.Object object)
Return the context associated with the specified object, or null if not found. |
boolean |
getBooleanProperty(java.lang.String name,
boolean defaultValue)
Return the first value associated with the specified name as a boolean value, or the defaultValue if not found. |
static Context |
getContext(java.lang.Object object)
If the object is an instance of IContextHolder, return its context, otherwise return null. |
int |
getIntProperty(java.lang.String name,
int defaultValue)
Return the first value associated with the specified name as an int, or the defaultValue if not found. |
java.util.Enumeration |
getProperties(java.lang.String name)
Return an enumeration over all the values associated with the specified name. |
static java.lang.Object |
getProperty(Context context,
java.lang.String name)
If the specified context has a property with the specified name, return its value. |
static java.lang.Object |
getProperty(Context context,
java.lang.String name,
java.lang.Object defaultValue)
If the specified context has a property with the specified name, return its value. |
java.lang.Object |
getProperty(java.lang.String name)
Return the first value associated with the specified name, or null if not found. |
java.lang.Object |
getProperty(java.lang.String name,
java.lang.Object defaultValue)
Return the first value associated with the specified name, or the specified defaultValue if not found. |
java.util.Enumeration |
getPropertyNames()
Return an enumeration over the property names. |
java.lang.String |
getStringProperty(java.lang.String name)
Return the first value associated with the specified name as a string. |
java.lang.String |
getStringProperty(java.lang.String name,
java.lang.String defaultValue)
Return the first value associated with the specified name as a string, or the defaultValue if not found. |
static java.lang.String |
getSystemProperty(java.lang.String name)
Return the system property associated with the specified name. |
static java.lang.String |
getSystemProperty(java.lang.String name,
java.lang.String defaultValue)
Return the system property associated with the specified name. |
static Context |
of(java.lang.Object object)
Return the context associated with the specified object. |
static Context |
remove(java.lang.Object object)
Return and remove the context associated with the specified object, or null if not found. |
void |
removeListener(IContextListener listener)
Remove the specified listener from this context. |
java.util.Enumeration |
removeProperties(java.lang.String name)
Remove all the properties with the specified name and return an enumeration over the removed properties. |
java.lang.Object |
removeProperty(java.lang.String name)
Remove and return the first property with the specified name, or null if not found. |
java.lang.Object |
removeProperty(java.lang.String name,
java.lang.Object value)
Remove and return the first property with the specified name and value, or null if not found. |
static void |
removeThreadContext()
Clean up the current thread context. |
static void |
set(java.lang.Object object,
Context context)
Associate the specified context with the specified object. |
static void |
setContext(java.lang.Object object,
Context context)
If the object is an instance of IContextHolder, set its context to the new value, otherwise throw an IllegalArgumentException. |
void |
setProperty(java.lang.String name,
java.lang.Object value)
Associate a property with the specified name, replacing any previous associations if present. |
static Context |
thread()
Return the context associated with the calling thread. |
java.lang.String |
toString()
Return a description of the Context. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
public Context()
public Context(Context context)
context
- The context to copy.Method Detail |
public java.lang.String toString()
public void setProperty(java.lang.String name, java.lang.Object value)
name
- The property name.value
- The property value.public void addProperty(java.lang.String name, java.lang.Object value)
name
- The property name.value
- The property value.public java.lang.Object getProperty(java.lang.String name)
name
- The property name.public java.lang.Object getProperty(java.lang.String name, java.lang.Object defaultValue)
name
- The property name.defaultValue
- The default value.public java.util.Enumeration getProperties(java.lang.String name)
name
- The property name.public boolean getBooleanProperty(java.lang.String name, boolean defaultValue)
name
- The property name.defaultValue
- The default value.public java.lang.String getStringProperty(java.lang.String name)
name
- The property name.public java.lang.String getStringProperty(java.lang.String name, java.lang.String defaultValue)
name
- The property name.defaultValue
- The default value.public int getIntProperty(java.lang.String name, int defaultValue)
name
- The property name.defaultValue
- The default value.public java.util.Enumeration getPropertyNames()
public java.lang.Object removeProperty(java.lang.String name, java.lang.Object value)
name
- The property name.value
- The property value.public java.lang.Object removeProperty(java.lang.String name)
name
- The property name.public java.util.Enumeration removeProperties(java.lang.String name)
name
- The property name.public void addContext(Context context)
context
- The context whose properties are added.public static Context thread()
public static void removeThreadContext()
public static Context application()
public static Context of(java.lang.Object object)
object
- public static void set(java.lang.Object object, Context context)
object
- The object.context
- The context.public static Context get(java.lang.Object object)
object
- The object.public static Context remove(java.lang.Object object)
object
- The object.public static Context getContext(java.lang.Object object)
object
- The object.public static void setContext(java.lang.Object object, Context context)
object
- The object.context
- The new context.
java.lang.IllegalArgumentException
public void addListener(IContextListener listener)
listener
- The listener.public void removeListener(IContextListener listener)
listener
- The listener.public static java.lang.String getSystemProperty(java.lang.String name)
name
- The name of the system property.public static java.lang.String getSystemProperty(java.lang.String name, java.lang.String defaultValue)
name
- The name of the system property.defaultValue
- The default value.public static java.lang.Object getProperty(Context context, java.lang.String name)
context
- The context.name
- The property name.public static java.lang.Object getProperty(Context context, java.lang.String name, java.lang.Object defaultValue)
context
- The context.name
- The property name.defaultValue
- The default value.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |