Class 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.6.0-SP1
    • 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 modifiable
        NullPointerException - if the passed attribute name is null
      • putAll

        public void putAll​(Map<String,​Object> _mAttributes)
                    throws UnsupportedOperationException,
                           NullPointerException
        Copies all attributes from a specified Map 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 modifiable
        NullPointerException - if the passed attribute name is null
      • 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 is null
      • get

        public Object get​(String _sName)
        Returns a specified attribute or null 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.