Class ScriptAttributes
- Object
-
- ScriptAttributes
-
public class ScriptAttributes extends Object
This class defines an interface for scripts to store and retrieve named objects of arbitrary types, the so-called 'attributes'. The creator of an instance of this class can decide whether the attributes are writable & readable or just read-only.- Version:
- 7.5.0
-
-
Constructor Summary
Constructors Constructor Description ScriptAttributes(Map<String,Object> _mAttributes, boolean _bModifiable, String _sScope)
Creates a new instance of ScriptAttributes.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Object
get(String _sName)
Returns a specified attribute ornull
if the attribute doesn't exist.Object
get(String _sName, Object _default)
Returns a specified attribute or a specified default value if the attribute doesn't exist.void
put(String _sName, Object _value)
Sets an attribute to a specified value.void
putAll(Map<String,Object> _mAttributes)
Copies all attributes from a specifiedMap
into this attribute collection.void
remove(String _sName)
Removes a specified attribute from the collection.
-
-
-
Constructor Detail
-
ScriptAttributes
public ScriptAttributes(Map<String,Object> _mAttributes, boolean _bModifiable, String _sScope)
Creates a new instance of ScriptAttributes.- Parameters:
_mAttributes
- the collection of named attributes_bModifiable
- decides whether collection of attributes is modifiable_sScope
- scope name of the attribute, used only for error message texts
-
-
Method Detail
-
put
public void put(String _sName, Object _value) throws UnsupportedOperationException, NullPointerException
Sets an attribute to a specified value. If an attribute with the specified name already exists in the collection it is replaced by the new value.CAUTION: Be careful when storing a modifiable object. If such object is fetched and modified by a session script, the modification is visible by all sessions. Since the modification is performed concurrently with other sessions, usually some means of locking is required while doing the modification.The script is responsible for implementing common programming techniques which ensure thread-safeness when accessing such objects.
- Parameters:
_sName
- the name of the attribute_value
- the attribute's value- Throws:
UnsupportedOperationException
- if the collection of attributes is not modifiableNullPointerException
- if the passed attribute name isnull
-
putAll
public void putAll(Map<String,Object> _mAttributes) throws UnsupportedOperationException, NullPointerException
Copies all attributes from a specifiedMap
into this attribute collection. If an attribute already existed in the collection it is replaced by the new value.CAUTION: Be careful when adding attributes with modifiable objects. If such object is fetched and modified by a session script, the modification is visible by all sessions. Since the modification is perfomed concurrently with other sessions, usually some means of locking is required while doing the modification. The script is responsible for implementing common programming techniques which ensure thread-safeness when accessing such objects.
- Parameters:
_mAttributes
- the attributes to add- Throws:
UnsupportedOperationException
- if the collection of attributes is not modifiableNullPointerException
- if the passed attribute name isnull
-
get
public Object get(String _sName, Object _default)
Returns a specified attribute or a specified default value if the attribute doesn't exist.CAUTION: Be careful when fetching a modifiable object. If such object is modified by a session script, the modification is visible by all sessions. Since the modification is performed concurrently with other sessions, usually some means of locking is required while doing the modification. The script is responsible for implementing common programming techniques which ensure thread-safeness when accessing such objects.
- Parameters:
_sName
- the name of the attribute- Throws:
NullPointerException
- if the passed attribute name isnull
-
get
public Object get(String _sName)
Returns a specified attribute ornull
if the attribute doesn't exist.CAUTION: Be careful when fetching a modifiable object. If such object is modified by a session script, the modification is visible by all sessions. Since the modification is performed concurrently with other sessions, usually some means of locking is required while doing the modification. The script is responsible for implementing common programming techniques which ensure thread-safeness when accessing such objects.
-
remove
public void remove(String _sName) throws UnsupportedOperationException, NullPointerException
Removes a specified attribute from the collection.- Parameters:
_sName
- the name of the attribute- Throws:
UnsupportedOperationException
- if the collection of attributes is not modifiableNullPointerException
- if the passed attribute name isnull
-
-