SmartFrog 3.10.000

org.smartfrog.sfcore.common
Interface Context

All Superinterfaces:
Copying, PrettyPrinting, java.io.Serializable
All Known Implementing Classes:
ContextImpl

public interface Context
extends PrettyPrinting, Copying, java.io.Serializable

Defines the context interface used by Components. Context implementations need to respect the ordering and copying requirements imposed by Components.

See Also:
Copying

Method Summary
 java.lang.Object clone()
          Returns a normal (shallow) clone of the context.
 boolean contains(java.lang.Object value)
          Returns true if the context contains value.
 boolean containsKey(java.lang.Object key)
          Returns true if the context contains the key.
 java.util.Enumeration elements()
          Returns the values of the context.
 java.lang.Object get(java.lang.Object key)
          Returns object stored under given key, null if not found.
 boolean isEmpty()
          Returns true if the context is empty.
 java.lang.Object keyFor(java.lang.Object value)
          Returns the first key which has a particular value in the table.
 java.util.Enumeration keys()
          Returns an enumeration over the keys of the context.
 java.lang.Object put(java.lang.Object key, java.lang.Object value)
          Adds an object value under given key to context.
 java.lang.Object remove(java.lang.Object key)
          Removes context entry under given key.
 java.lang.Object rename(java.lang.Object key1, java.lang.Object key2)
          Renames an entry in the otable, leaving its position in the table unchanged.
 java.lang.Object sfAddAttribute(java.lang.Object name, java.lang.Object value)
          Add an attribute to context.
 java.lang.Object sfAttributeFor(java.lang.Object value)
          Returns the first attribute which has a particular value in the table.
 java.lang.Object sfAttributeKeyFor(java.lang.Object value)
          Returns the attribute key for a given value.
 java.util.Iterator sfAttributes()
          Returns an iterator over the attribute names of the context.
 boolean sfContainsAttribute(java.lang.Object attribute)
          Returns true if the context contains attribute.
 boolean sfContainsValue(java.lang.Object value)
          Returns true if the context contains value.
 java.lang.Object sfRemoveAttribute(java.lang.Object name)
          Remove named attribute from component context.
 java.lang.Object sfReplaceAttribute(java.lang.Object name, java.lang.Object value)
          Replace named attribute in context.
 java.lang.Object sfResolveAttribute(java.lang.Object name)
          Find an attribute in this context.
 java.util.Iterator sfValues()
          Returns an iterator over the values of the context.
 int size()
          Returns the number of context entries.
 java.lang.String toString()
          Return string representation of context.
 
Methods inherited from interface org.smartfrog.sfcore.common.PrettyPrinting
writeOn, writeOn
 
Methods inherited from interface org.smartfrog.sfcore.common.Copying
copy
 

Method Detail

contains

boolean contains(java.lang.Object value)
Returns true if the context contains value. Deprecated: replaced by sfContainsValue()

Parameters:
value - object to check
Returns:
true if context contains value, false otherwise

containsKey

boolean containsKey(java.lang.Object key)
Returns true if the context contains the key. Deprecated: replaced by sfContainsAttribute()

Parameters:
key - to check
Returns:
true if context contains key, false otherwise

elements

java.util.Enumeration elements()
Returns the values of the context. Deprecated: replaced by sfValues();

Returns:
enumeration over the values of the context
See Also:
Enumeration

get

java.lang.Object get(java.lang.Object key)
Returns object stored under given key, null if not found.

Parameters:
key - to look up
Returns:
object under key if found, null otherwise

isEmpty

boolean isEmpty()
Returns true if the context is empty.

Returns:
true if context empty, false otherwise

keys

java.util.Enumeration keys()
Returns an enumeration over the keys of the context. Deprecated: replaced by sfAttributes();

Returns:
enumeration

put

java.lang.Object put(java.lang.Object key,
                     java.lang.Object value)
Adds an object value under given key to context.

Parameters:
key - key of addition
value - value of addition
Returns:
the previous value under key, or null if none

rename

java.lang.Object rename(java.lang.Object key1,
                        java.lang.Object key2)
Renames an entry in the otable, leaving its position in the table unchanged.

Parameters:
key1 - the initial key to be renamed
key2 - the new key name
Returns:
the initial key, or null if it wasn't in the table

remove

java.lang.Object remove(java.lang.Object key)
Removes context entry under given key.

Parameters:
key - context entry to be removed
Returns:
object that was removed

size

int size()
Returns the number of context entries.

Returns:
size of context (in entries)

keyFor

java.lang.Object keyFor(java.lang.Object value)
Returns the first key which has a particular value in the table. Deprecated: sfAttributeFor should be used instead.

Parameters:
value - value to find in table
Returns:
key for value or null if none

toString

java.lang.String toString()
Return string representation of context.

Overrides:
toString in class java.lang.Object
Returns:
string representation

clone

java.lang.Object clone()
Returns a normal (shallow) clone of the context.

Specified by:
clone in interface Copying
Returns:
clone of context

sfAttributeFor

java.lang.Object sfAttributeFor(java.lang.Object value)
Returns the first attribute which has a particular value in the table.

Parameters:
value - value to find in table
Returns:
attibute object for value or null if none

sfContainsValue

boolean sfContainsValue(java.lang.Object value)
Returns true if the context contains value. Replaces contains()

Parameters:
value - object to check
Returns:
true if context contains value, false otherwise

sfContainsAttribute

boolean sfContainsAttribute(java.lang.Object attribute)
Returns true if the context contains attribute. Replaces containsKey()

Parameters:
attribute - to check
Returns:
true if context contains key, false otherwise

sfAttributes

java.util.Iterator sfAttributes()
Returns an iterator over the attribute names of the context. The remove operation of this Iterator won't affect the contents of Context

Returns:
iterator

sfValues

java.util.Iterator sfValues()
Returns an iterator over the values of the context. The remove operation of this Iterator won't affect the contents of Context

Returns:
iterator

sfAddAttribute

java.lang.Object sfAddAttribute(java.lang.Object name,
                                java.lang.Object value)
                                throws SmartFrogContextException
Add an attribute to context. Values should be marshallable types if they are to be referenced remotely at run-time. If an attribute with this name already exists it is not replaced.

Parameters:
name - name of attribute
value - object to be added in context
Returns:
value if successfull, null otherwise
Throws:
SmartFrogContextException - when name or value are null

sfRemoveAttribute

java.lang.Object sfRemoveAttribute(java.lang.Object name)
                                   throws SmartFrogContextException
Remove named attribute from component context. Non present attribute names are ignored.

Parameters:
name - name of attribute to be removed
Returns:
the removed value if successfull, null otherwise
Throws:
SmartFrogContextException - when name is null

sfAttributeKeyFor

java.lang.Object sfAttributeKeyFor(java.lang.Object value)
Returns the attribute key for a given value.

Parameters:
value - value to look up the key for
Returns:
key for given value or null if not found

sfReplaceAttribute

java.lang.Object sfReplaceAttribute(java.lang.Object name,
                                    java.lang.Object value)
                                    throws SmartFrogContextException
Replace named attribute in context. If attribute is not present it is added to the context.

Parameters:
name - of attribute to replace
value - attribute value to replace or add
Returns:
the old value if present, null otherwise
Throws:
SmartFrogContextException - when name or value are null

sfResolveAttribute

java.lang.Object sfResolveAttribute(java.lang.Object name)
                                    throws SmartFrogContextException
Find an attribute in this context.

Parameters:
name - attribute key to resolve
Returns:
Object Reference
Throws:
SmartFrogContextException - failed to find attribute

SmartFrog CORE 3.10.000

(C) Copyright 1998-2006 Hewlett-Packard Development Company, LP