Class PyChartScope

  • All Implemented Interfaces:
    java.io.Serializable, java.util.concurrent.ConcurrentMap, java.util.Map, org.python.core.Traverseproc

    public class PyChartScope
    extends org.python.core.PyDictionary
    This class represents any "scope" in the SFC system, and is fundamentally just an observable dictionary. Despite its name, it is not limited to chart scope. This class notifies listeners when values are changed, and wraps any dictionaries assigned to it as PyChartScopes as well.
    See Also:
    Serialized Form
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      static interface  PyChartScope.ScopeObserver
      An observer that gets notified when the scope is modified.
      • Nested classes/interfaces inherited from class org.python.core.PyObject

        org.python.core.PyObject.ConversionException
      • Nested classes/interfaces inherited from interface java.util.Map

        java.util.Map.Entry<K extends java.lang.Object,​V extends java.lang.Object>
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected java.util.List<PyChartScope.ScopeObserver> observers  
      • Fields inherited from class org.python.core.PyDictionary

        TYPE
      • Fields inherited from class org.python.core.PyObject

        attributes, gcMonitorGlobal, objtype
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
        PyChartScope()  
      protected PyChartScope​(java.util.Map<org.python.core.PyObject,​org.python.core.PyObject> map)  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      org.python.core.PyObject __findattr_ex__​(java.lang.String name)  
      void __set__​(org.python.core.PyObject obj, org.python.core.PyObject value)  
      void __setattr__​(java.lang.String name, org.python.core.PyObject value)  
      void __setitem__​(org.python.core.PyObject key, org.python.core.PyObject value)  
      void addScopeObserver​(PyChartScope.ScopeObserver observer)  
      org.python.core.PyDictionary copy()  
      protected static PyChartScope createFrom​(org.python.core.PyDictionary dict)
      This goes deep through a dictionary and creates PyChartScopes for any embedded dictionaries.*
      org.python.core.PyDictionary createSerializableVersion()  
      JSONObject createSnapshot()  
      java.util.HashMap<java.lang.Object,​java.lang.Object> getSerializableMap()  
      PyChartScope getSubScope​(java.lang.String id)
      A convenience function for obtaining sub scopes.
      boolean hasKey​(java.lang.Object key)  
      void insert​(JSONObject json)
      Takes a JSON object and inserts it into this scope, creating deep observable scopes for all sub dictionaries.
      protected void notifyObservers​(java.lang.String key, org.python.core.PyObject value)  
      protected void notifyObservers​(org.python.core.PyObject key, org.python.core.PyObject value)  
      void removeScopeObserver​(PyChartScope.ScopeObserver observer)  
      void setVariable​(java.lang.Object key, java.lang.Object value)
      Set or update a variable in the chart scope.
      boolean supportsSubScopes()
      If TRUE, keys of the nature "a.b.c" will be treated as sub scopes "a","b","c" under this one, and will be obtained through getSubScope.
      protected com.google.common.base.Optional<java.lang.Object> toJson​(org.python.core.PyObject value)  
      protected void transferObservers​(PyChartScope newScope, PyChartScope existing)
      When we're replacing a scope, we need to notify everyone who is watching something in that scope.
      • Methods inherited from class org.python.core.PyDictionary

        __cmp__, __contains__, __delitem__, __eq__, __finditem__, __finditem__, __iter__, __len__, __ne__, __nonzero__, clear, containsKey, containsValue, dict___getitem__, dict___init__, entrySet, equals, fromkeys, fromkeys, get, get, get, getMap, has_key, hashCode, isEmpty, isMappingType, isSequenceType, items, iteritems, iterkeys, itervalues, keys, keySet, merge, mergeFromKeys, mergeFromSeq, pop, pop, popitem, put, putAll, putIfAbsent, pyKeySet, refersDirectlyTo, remove, remove, replace, replace, setdefault, setdefault, size, toString, traverse, update, updateCommon, values, viewitems, viewkeys, viewvalues
      • Methods inherited from class org.python.core.PyObject

        __abs__, __add__, __and__, __call__, __call__, __call__, __call__, __call__, __call__, __call__, __call__, __call__, __call__, __call__, __call__, __call__, __call__, __call__, __call__, __coerce__, __coerce_ex__, __complex__, __delattr__, __delattr__, __delete__, __delitem__, __delslice__, __delslice__, __dir__, __div__, __divmod__, __ensure_finalizer__, __findattr__, __findattr__, __finditem__, __float__, __floordiv__, __format__, __ge__, __get__, __getattr__, __getattr__, __getitem__, __getitem__, __getnewargs__, __getslice__, __getslice__, __gt__, __hash__, __hex__, __iadd__, __iand__, __idiv__, __idivmod__, __ifloordiv__, __ilshift__, __imod__, __imul__, __index__, __int__, __invert__, __ior__, __ipow__, __irshift__, __isub__, __iternext__, __itruediv__, __ixor__, __le__, __long__, __lshift__, __lt__, __mod__, __mul__, __neg__, __not__, __oct__, __or__, __pos__, __pow__, __pow__, __radd__, __rand__, __rawdir__, __rdiv__, __rdivmod__, __reduce__, __reduce_ex__, __reduce_ex__, __repr__, __rfloordiv__, __rlshift__, __rmod__, __rmul__, __ror__, __rpow__, __rrshift__, __rshift__, __rsub__, __rtruediv__, __rxor__, __setattr__, __setitem__, __setitem__, __setslice__, __setslice__, __str__, __sub__, __tojava__, __truediv__, __trunc__, __unicode__, __xor__, _add, _and, _callextra, _cmp, _div, _divmod, _doget, _doget, _doset, _eq, _floordiv, _ge, _gt, _iadd, _iand, _idiv, _idivmod, _ifloordiv, _ilshift, _imod, _imul, _in, _ior, _ipow, _irshift, _is, _isnot, _isub, _itruediv, _ixor, _jcall, _jcallexc, _jthrow, _le, _lshift, _lt, _mod, _mul, _ne, _notin, _or, _pow, _rshift, _sub, _truediv, _unsupportedop, _xor, adaptToCoerceTuple, asDouble, asIndex, asIndex, asInt, asInt, asIterable, asLong, asLong, asName, asName, asString, asString, asStringOrNull, asStringOrNull, bit_length, conjugate, delDict, delType, dispatch__init__, fastGetClass, fastGetDict, finalize, getDict, getJavaProxy, getType, impAttr, implementsDescrDelete, implementsDescrGet, implementsDescrSet, invoke, invoke, invoke, invoke, invoke, invoke, isCallable, isDataDescr, isIndex, isInteger, isNumberType, mergeClassDict, mergeDictAttr, mergeListAttr, noAttributeError, object___subclasshook__, readonlyAttributeError, runsupportedopMessage, setDict, setType, unsupportedopMessage
      • Methods inherited from class java.lang.Object

        clone, getClass, notify, notifyAll, wait, wait, wait
      • Methods inherited from interface java.util.concurrent.ConcurrentMap

        compute, computeIfAbsent, computeIfPresent, forEach, getOrDefault, merge, replaceAll
    • Constructor Detail

      • PyChartScope

        public PyChartScope()
      • PyChartScope

        protected PyChartScope​(java.util.Map<org.python.core.PyObject,​org.python.core.PyObject> map)
    • Method Detail

      • createFrom

        protected static PyChartScope createFrom​(org.python.core.PyDictionary dict)
        This goes deep through a dictionary and creates PyChartScopes for any embedded dictionaries.*
      • copy

        public org.python.core.PyDictionary copy()
        Overrides:
        copy in class org.python.core.PyDictionary
      • supportsSubScopes

        public boolean supportsSubScopes()
        If TRUE, keys of the nature "a.b.c" will be treated as sub scopes "a","b","c" under this one, and will be obtained through getSubScope. If FALSE, such a key will be treated as a flat key value.
      • getSubScope

        public PyChartScope getSubScope​(java.lang.String id)
        A convenience function for obtaining sub scopes. *
      • hasKey

        public boolean hasKey​(java.lang.Object key)
      • setVariable

        public void setVariable​(java.lang.Object key,
                                java.lang.Object value)
        Set or update a variable in the chart scope.

        This method (or __setitem__(PyObject, PyObject)) must be used in order for observers to be notified.

        Parameters:
        key - entry key.
        value - entry value.
      • __setitem__

        public void __setitem__​(org.python.core.PyObject key,
                                org.python.core.PyObject value)
        Overrides:
        __setitem__ in class org.python.core.PyDictionary
      • transferObservers

        protected void transferObservers​(PyChartScope newScope,
                                         PyChartScope existing)
        When we're replacing a scope, we need to notify everyone who is watching something in that scope. Also, we need to go deep and transfer observers/notify for any deeper dictionaries.
      • __findattr_ex__

        public org.python.core.PyObject __findattr_ex__​(java.lang.String name)
        Overrides:
        __findattr_ex__ in class org.python.core.PyObject
      • __setattr__

        public void __setattr__​(java.lang.String name,
                                org.python.core.PyObject value)
        Overrides:
        __setattr__ in class org.python.core.PyObject
      • __set__

        public void __set__​(org.python.core.PyObject obj,
                            org.python.core.PyObject value)
        Overrides:
        __set__ in class org.python.core.PyObject
      • notifyObservers

        protected void notifyObservers​(org.python.core.PyObject key,
                                       org.python.core.PyObject value)
      • notifyObservers

        protected void notifyObservers​(java.lang.String key,
                                       org.python.core.PyObject value)
      • createSerializableVersion

        public org.python.core.PyDictionary createSerializableVersion()
      • createSnapshot

        public JSONObject createSnapshot()
                                  throws java.lang.Exception
        Throws:
        java.lang.Exception
      • toJson

        protected com.google.common.base.Optional<java.lang.Object> toJson​(org.python.core.PyObject value)
                                                                    throws java.lang.Exception
        Throws:
        java.lang.Exception
      • insert

        public void insert​(JSONObject json)
        Takes a JSON object and inserts it into this scope, creating deep observable scopes for all sub dictionaries.
      • getSerializableMap

        public java.util.HashMap<java.lang.Object,​java.lang.Object> getSerializableMap()
        Returns:
        a HashMap of the PyChartScope's internal map that can be safely serialized and deserialized.