/* local Storage 
Local Storage API - returned from LocalStorageFactory
@constructor AbstractLocalStorage
@name AbstractLocalStorage
@memberof Augmented
@param {boolean} persist Persistant storage or not
335479
function(persist) {
          /**
          * is Persistant or not
          * @property {boolean} isPersisted Persistant property
          * @memberof AbstractLocalStorage
          */
          this.isPersisted = persist;

          this.myStore = null;
          /**
          * Is storage supported
          * @method isSupported
          * @memberof AbstractLocalStorage
          * @returns {boolean} Returns true if supported
          */
          this.isSupported = function() {
            return (typeof (Storage) !== "undefined");
          };

          // true = localStorage, false = sessionStorage
          if (this.isSupported()) {
            //logger.debug("AUGMENTED: localStorage exists");

            if (this.isPersisted) {
              this.myStore = localStorage;
            } else {
              this.myStore = sessionStorage;
            }
          } else {
            logger.warn("AUGMENTED: No localStorage.");
          }

          /**
          * Gets an item from storage
          * @method getItem
          * @memberof AbstractLocalStorage
          * @param {string} key The key in storage
          * @returns {object} Returns object from storage
          */
          this.getItem = function(itemKey) {
            var item = this.myStore.getItem(itemKey);
            if (item) {
              return JSON.parse(item);
            }
            return null;
          };

          /**
          * Sets an item to storage
          * @method setItem
          * @memberof AbstractLocalStorage
          * @param {string} key The key in storage
          * @param {object} object The data to set
          */
          this.setItem = function(itemKey, object) {
            this.myStore.setItem(itemKey, JSON.stringify(object));
          };

          /**
          * Removes an item from storage
          * @method removeItem
          * @memberof AbstractLocalStorage
          * @param {string} key The key in storage
          */
          this.removeItem = function(itemKey) {
            this.myStore.removeItem(itemKey);
          };

          /**
          * Clears storage - <b>Warning: Destructive in non-namespaced instances!</b>
          * @method clear
          * @memberof AbstractLocalStorage
          */
          this.clear = function() {
            this.myStore.clear();
          };

          /**
          * Gets the key from storage for index
          * @method key
          * @memberof AbstractLocalStorage
          * @param {number} i The index in storage
          * @returns {string} Returns the key from storage
          */
          this.key = function(i) {
            return this.myStore.key(i);
          };

          /**
          * The length of storage by keys
          * @method length
          * @memberof AbstractLocalStorage
          * @returns {number} Returns the length of storage by keys
          */
          this.length = function() {
            return this.myStore.length;
          };
        }
321939
public void store(String savePoint, Object obj)
   {
	if (savePoint == null)
	   throw new RequiredException("savePoint");
	
	if (obj == null)
	   throw new RequiredException("obj");
	
	String location = whereIs(savePoint, obj.getClass());

	Debugger.println(this,"Storing in "+location);
	
	IO.serializeToFile(obj, new File(location));
   }
698701
function (options) {
            var isIE7 = ariaCoreBrowser.isIE7;

            // Throw an error only in IE7
            this.$HTML5Storage.constructor.call(this, options, "localStorage", !isIE7);

            if (!this.storage && isIE7) {
                var instance = new ariaStorageUserData(options);
                fallback(this, instance);

                /**
                 * Whether or not this instance is using a fallback mechanism for localStorage
                 * @type aria.storage.UserData
                 * @protected
                 */
                this._fallback = instance;
            }
        }
216629
function(doc) {
      try {
        localStorage.setItem(prefix + doc.id, doc.serialize());
        return true;
      } catch (error) {
        // QUOTA_EXCEEDED
        console.error("Error while saving document to local storage",
            error);
        return false;
      }
    }
257630
function(callback) {
                var _this = this

                var initStorage = function() {
                    var obj = JSON.stringify([])
                    var _set = {}
                    _set[_this.key] = obj
                    storage.set(_set)

                    obj = JSON.parse(obj)

                    return obj
                }

                storage.get(this.key, function(items) {
                    var obj
                    if (Object.keys(items).length > 0) {
                        for (itemKey in items) {
                            obj = items[itemKey]
                            if (obj) {
                                obj = JSON.parse(obj)
                            }

                            if (obj === null || typeof obj === 'undefined') {
                                obj = initStorage()
                            } 
                            
                            if (callback) {
                                callback(obj)
                            }
                        }
                    } else {
                        obj = initStorage()
                        callback(obj)
                    }
                })
            }
464113
function LocalStorageKeyEnvironment(key) {
  this.key = key;
  var store = this.onStorage = this.onStorage.bind(this);
  var storage;

  try {
    storage = window.localStorage;
    storage.setItem(key, storage.getItem(key));
  } catch (e) {
    storage = null;
  }

  this.storage = storage || {
    data: {},
    getItem: function(itemKey) {return this.data[itemKey]; },
    setItem: function(itemKey, val) {
      this.data[itemKey] = val;
      clearTimeout(this.storeEvent);
      this.storeEvent = setTimeout(store, 1);
    }
  };

  Environment.call(this);
}
559300
@Override
    public Object beforeInsert(S storable) throws PersistException {
        // Capture user lob values for later and replace with new locators.
        int length = mLobProperties.length;
        Object[] userLobs = new Object[length];
        for (int i=0; i<length; i++) {
            LobProperty<Lob> prop = mLobProperties[i];
            Object userLob = storable.getPropertyValue(prop.mName);
            userLobs[i] = userLob;
            if (userLob != null) {
                Object lob = prop.createNewLob(mBlockSize);
                storable.setPropertyValue(prop.mName, lob);
            }
        }
        return userLobs;
    }
111274
function saveResolvedLocalsInData() {
    var localNames = previousOrParentNode.tNode.localNames;
    if (localNames) {
        for (var i = 0; i < localNames.length; i += 2) {
            var index = localNames[i + 1];
            var value = index === -1 ? previousOrParentNode.native : directives[index];
            viewData.push(value);
        }
    }
}
676865
function (key, value) {
      if (!supported) {
        try {
          $cookieStore.set(key, value);
          return value;
        } catch (e) {
          console.log('Local Storage not supported, make sure you have the $cookieStore supported.');
        }
      }
      var saver = JSON.stringify(value);
      storage.setItem(key, saver);
      return privateMethods.parseValue(saver);
    }
12267
function persistSubscriptionLocally(subscription) {
    let subscriptionJSON = JSON.stringify(subscription);
    idb.open('web-push-db', 1).then(db => {
        let tx = db.transaction(['web-push-subcription'], 'readwrite');
        tx.objectStore('web-push-subcription').put({
            id: 1,
            data: subscriptionJSON
        });
        return tx.complete;
    });
}
1182745
public void put(@NotNull final PersistentStoreTransaction txn,
                    final long localId,
                    @NotNull final ByteIterable value,
                    @Nullable final ByteIterable oldValue,
                    final int propertyId,
                    @NotNull final ComparableValueType type) {
        final Store valueIdx = getOrCreateValueIndex(txn, propertyId);
        final ByteIterable key = PropertyKey.propertyKeyToEntry(new PropertyKey(localId, propertyId));
        final Transaction envTxn = txn.getEnvironmentTransaction();
        primaryStore.put(envTxn, key, value);
        final ByteIterable secondaryValue = LongBinding.longToCompressedEntry(localId);
        boolean success;
        if (oldValue == null) {
            success = allPropsIndex.put(envTxn, IntegerBinding.intToCompressedEntry(propertyId), secondaryValue);
        } else {
            success = deleteFromStore(envTxn, valueIdx, secondaryValue, createSecondaryKeys(store.getPropertyTypes(), oldValue, type));
        }
        if (success) {
            for (final ByteIterable secondaryKey : createSecondaryKeys(store.getPropertyTypes(), value, type)) {
                valueIdx.put(envTxn, secondaryKey, secondaryValue);
            }
        }
        checkStatus(success, "Failed to put");
    }
742755
function(api, id, key) {
  // get storage object
  var rval = _getStorageObject(api, id);
  if(rval !== null) {
    // return data at key
    rval = (key in rval) ? rval[key] : null;
  }

  return rval;
}
774456
function LocalStorageHandle(success, error, intent, operation, args) {
    var reference = args[0];
    var variable = args[1];

    if (operation.startsWith('put') || operation.startsWith('set')) {
        try {
            var varAsString = JSON.stringify(variable);
            if (reference === null) {
                error(NativeStorageError.NULL_REFERENCE);
                return;
            }
            localStorage.setItem(reference, varAsString);
            success(variable);
        } catch (err) {
            error(NativeStorageError.JSON_ERROR);
        }
    } else if (operation.startsWith('get')) {
        var item = {};
        item = localStorage.getItem(reference);
        if (item === null) {
            error(NativeStorageError.ITEM_NOT_FOUND);
            return;
        }
        try {
            var obj = JSON.parse(item);
            //console.log("LocalStorage Reading: "+obj);
            success(obj);
        } catch (err) {
            error(NativeStorageError.JSON_ERROR);
        }
    } else if (operation === 'keys') {
      var keys = [];
      for(var i = 0; i < localStorage.length; i++){
         keys.push(localStorage.key(i));
      }
      success(keys);
    }
}
490807
function (key) {
      if (!browserSupportsLocalStorage || self.storageType === 'cookie') {
        if (!browserSupportsLocalStorage) {
          $rootScope.$broadcast('LocalStorageModule.notification.warning', 'LOCAL_STORAGE_NOT_SUPPORTED');
        }

        if (notify.removeItem) {
          $rootScope.$broadcast('LocalStorageModule.notification.removeitem', {key: key, storageType: 'cookie'});
        }
        return removeFromCookies(key);
      }

      try {
        webStorage.removeItem(deriveQualifiedKey(key));
        if (notify.removeItem) {
          $rootScope.$broadcast('LocalStorageModule.notification.removeitem', {key: key, storageType: self.storageType});
        }
      } catch (e) {
        $rootScope.$broadcast('LocalStorageModule.notification.error', e.message);
        return removeFromCookies(key);
      }
      return true;
    }
1228123
function(){
            if (!!_localStorage) return;
            // append storage flash
            _e._$flash({
                hidden:!0,
                src:_c._$get('storage.swf'),
                params:{
                    AllowScriptAccess:'sameDomain'
                },
                onready:function(_flash){
                    if (!_flash){
                        console.log('flash for localStorage unavailable');
                    }else{
                        _localStorage = _flash;
                        _localStorage.initStorage('nej-storage');
                    }
                    _v._$dispatchEvent(document,'storageready');
                }
            });
        }
1037509
function(func, args, location) {
  var rval = null;

  // default storage types
  if(typeof(location) === 'undefined') {
    location = ['web', 'flash'];
  }

  // apply storage types in order of preference
  var type;
  var done = false;
  var exception = null;
  for(var idx in location) {
    type = location[idx];
    try {
      if(type === 'flash' || type === 'both') {
        if(args[0] === null) {
          throw new Error('Flash local storage not available.');
        } else {
          rval = func.apply(this, args);
          done = (type === 'flash');
        }
      }
      if(type === 'web' || type === 'both') {
        args[0] = localStorage;
        rval = func.apply(this, args);
        done = true;
      }
    } catch(ex) {
      exception = ex;
    }
    if(done) {
      break;
    }
  }

  if(!done) {
    throw exception;
  }

  return rval;
}
317772
function LocalfsStorageAttachments(options) {
  if(options.removePrefix) {
    this.prefix = options.removePrefix;
  }
  attachments.StorageProvider.call(this, options);
}