Examples of SaveableData


Examples of net.sourceforge.processdash.data.SaveableData

            // lazy default value.
            return;
     
        Object defaultValue = lookupDefaultValueObject(name, d);

        SaveableData value = null;
        if (defaultValue != null) {
            String prefix = "";
            boolean readOnly = false;
            if (d.datafile != null) {
                prefix = d.datafile.prefix;
View Full Code Here

Examples of net.sourceforge.processdash.data.SaveableData

    }

    private SaveableData instantiateValue(String name, String dataPrefix,
                                          Object valueObj, boolean readOnly) {

      SaveableData o = null;

      if (valueObj instanceof SimpleData) {
        o = (SimpleData) valueObj;
        if (readOnly) o = o.getEditable(false);

      } else if (valueObj instanceof CompiledScript) {
        o = new CompiledFunction(name, (CompiledScript) valueObj,
                                 this, dataPrefix);

      } else if (valueObj instanceof SearchFactory) {
        o = ((SearchFactory) valueObj).buildFor(name, this, dataPrefix);

      } else if (valueObj instanceof String) {
        String value = (String) valueObj;
        if (value.startsWith("=")) {
          readOnly = true;
          value = value.substring(1);
        }

        try {
          o = ValueFactory.createQuickly(name, value, this, dataPrefix);
        } catch (MalformedValueException mfe) {
          // temporary fix to allow old PSP for Engineers add-on to work in 1.7
          if ("![(&&\tCompleted)]".equals(value)) {
              valueObj = Compiler.compile("[Completed]");
              o = new CompiledFunction(name, (CompiledScript) valueObj,
                                       this, dataPrefix);
          } else {
              o = new MalformedData(value);
          }
        }
        if (readOnly && o != null) o.setEditable(false);
      }

      return o;
    }
View Full Code Here

Examples of net.sourceforge.processdash.data.SaveableData

                localName, valueObj);
        globalDataDefinitions.put(localName, valueObj);
        definitionsDirty = true;
     
        if (e != null) {
            SaveableData o = instantiateValue(name, "", valueObj, false);
            if (o != null)
                putValue(name, o, IS_DEFAULT_VAL);
        } else if (!(valueObj instanceof DataRenamingOperation)) {
            if (globalDataIsMounted)
                repositoryListenerList.dispatchAdded(name);
View Full Code Here

Examples of net.sourceforge.processdash.data.SaveableData

          for (Iterator i = values.entrySet().iterator(); i.hasNext();) {
              Map.Entry defn = (Map.Entry) i.next();
              String localName = (String) defn.getKey();
              Object valueObj = defn.getValue();
              String dataName = createDataName(dataPrefix, localName);
              SaveableData o = instantiateValue(dataName, dataPrefix, valueObj,
                      !fileEditable);

              if (o instanceof MalformedData)
                  logger.warning("Data value for '" + dataName + "' in file '"
                          + datafilePath + "' is malformed.");

              DataElement d = (DataElement)data.get(dataName);
              if (d == null) {
                  boolean isDefaultName = defaultData.containsKey(localName);
                  if (o != null || isDefaultName) {
                      try {
                          add(dataName, isDefaultName, o, IS_NOT_DEFAULT_VAL,
                                  dataFile, DO_NOTIFY);
                      } catch (DataElementAlreadyExistsException e) {
                          d = e.elem;
                      }
                  }
              }
              if (d != null) {
                  putValue(dataName, o, IS_NOT_DEFAULT_VAL,
                          NOT_MODIFYING_DATAFILE);
                  d = (DataElement)data.get(dataName);
                  if (d != null) {
                      d.datafile = dataFile;
                      d.isDefaultName = defaultData.containsKey(localName);
                  }
              }

              if (registerDataNames && (o instanceof DoubleData
                      || o instanceof CompiledFunction))
                  dataElementNameSet.add(localName);
          }
         
          // Next, handle the default values that this datafile inherits.
          String dataPrefixSlash = dataPrefix + "/";
          for (Iterator i = defaultData.entrySet().iterator(); i.hasNext();) {
              Map.Entry defn = (Map.Entry) i.next();
              String localName = (String) defn.getKey();
              Object valueObj = defn.getValue();
             
              // if we already processed an explicit value with this same
              // name, do nothing.
              if (values.containsKey(localName))
                  continue;
             
              // Ignore renaming operations; they are not relevant.
              if (valueObj instanceof DataRenamingOperation)
                  continue;

              boolean shouldCreateEagerly = shouldCreateEagerly(valueObj);
              if ("@now".equals(valueObj))
                  shouldCreateEagerly = datafileModified = true;
             
              String dataName = dataPrefixSlash + localName;
              DataElement d = (DataElement)data.get(dataName);
              if (d == null) {
                  // this data element does not already exist in the repository.
                  // most such items do not need to be created; we can let them
                  // be lazily created later if needed.

                  if (shouldCreateEagerly) {
                      // the item doesn't exist, but we should create it anyway.
                      SaveableData o = instantiateValue(dataName,
                              dataPrefix, valueObj, !fileEditable);
                      if (o != null) {
                          try {
                              add(dataName, IS_DEFAULT_NAME, o, IS_DEFAULT_VAL,
                                      dataFile, DO_NOT_NOTIFY);
                          } catch (DataElementAlreadyExistsException e) {
                              d = e.elem;
                          }
                      }
                  }
              }

              if (d != null) {
                  // a matching data element exists.
                  d.datafile = dataFile;
                  d.isDefaultName = true;
                  dataName = d.name;
                 
                  if (instantiatedDataMatches(valueObj, d.getValue())) {
                      // the data element already has the proper value. (This
                      // will be common, as clients registering data listeners
                      // will cause lazy data to spring to life even as this
                      // for loop is executing.) Nothing needs to be done.

                  } else if (!d.hasListeners()) {
                      // This element has the wrong value, but no one is
                      // listening to it.  Revert the element to a lazy
                      // default value.
                      janitor.cleanup(d);
                     
                  } else {
                      // This element has the wrong value, and clients are
                      // listening to it.  Create and save the correct value.
                      SaveableData o = instantiateValue(dataName,
                              dataPrefix, valueObj, !fileEditable);
                      putValue(dataName, o, IS_DEFAULT_VAL,
                              NOT_MODIFYING_DATAFILE);
                  }
              }
View Full Code Here

Examples of net.sourceforge.processdash.data.SaveableData

                    || element.isDefaultValue())
                // if there is no such element, if it doesn't belong to this
                // DataFile, or if it has a default value, skip it.
                continue;

            SaveableData value = element.getValue();
            String valStr = null;
            boolean editable = true;

            if (value != null) {
                valStr = value.saveString();
                editable = value.isEditable();
            } else if (element.isDefaultName()) {
                // store the fact that the default is overwritten with null
                valStr = "null";
            }
View Full Code Here

Examples of net.sourceforge.processdash.data.SaveableData

            this.value = d;
            this.isDefaultValue = isDefault;
        }

        public void disposeValue() {
            SaveableData value;
            synchronized (this) {
                if (disposalLockCount > 0)
                    // if some other thread is currently using this element,
                    // give them a moment or two (but no more) to finish.
                    // Don't wait forever, in case someone just forgot to
                    // clean up their lock.
                    try { wait(500); } catch (InterruptedException e) {}
                value = this.value;
                this.value = null;
            }

            if (value != null) {
                try {
                    value.dispose();
                } catch (Exception e) {}
                activeData.remove(value);
            }
        }
View Full Code Here

Examples of net.sourceforge.processdash.data.SaveableData

      private void performFreeze(String dataName, DataElement element) {       
        // Make certain no data values are currently in a state of flux
        dataNotifier.flush();
       
        // Retrieve the value of the element
        SaveableData value = element.getValue();

        // For now, lets add this in - don't doubly freeze data.  Supporting
        // double freezing of data might make it easier for the people who
        // write freeze flag expressions, but it makes things more confusing
        // for end users:
        //  * data items that are frozen by multiple freeze flags perplex
        //    the user: they toggle some boolean value and can't figure out
        //    why the data isn't thawing
        //  * sometimes it is possible for data accidentally to become doubly
        //    frozen by the SAME freeze flag.  Then users toggle the flag and
        //    their data toggles between frozen and doubly frozen.
        if (value instanceof FrozenData)
          return;

        // Determine the prefix of the data element.
        String prefix = "";
        if (element.datafile != null) {
          // don't freeze data elements in imported files.
          if (element.datafile.isImported) return;
          prefix = element.datafile.prefix;
        }

        // Don't freeze null data elements when there is no default value.
        if (value == null && !element.isDefaultName()) return;

        // Create the frozen version of the value.
        SaveableData frozenValue = new FrozenData(dataName, value,
                    DataRepository.this, prefix, element.isDefaultValue());
       
        // Make one last check to ensure that some other thread hasn't
        // disposed of or altered the element we were freezing.
        if (element.getValue() == value && data.get(dataName) == element) {
View Full Code Here

Examples of net.sourceforge.processdash.data.SaveableData

        DataElement element = (DataElement) data.get(dataName);
        if (element == null) return;
        if (element.datafile != null && element.datafile.isImported) return;
        logger.log(Level.FINE, "Thawing data element {0}", dataName);

        SaveableData value = element.getValue(), thawedValue;
        if (value instanceof FrozenData) {
          // Thaw the value.
          FrozenData fd = (FrozenData) value;
          thawedValue = fd.thaw();
          boolean isDefaultVal = (thawedValue == FrozenData.DEFAULT);
View Full Code Here

Examples of net.sourceforge.processdash.data.SaveableData

            return;           // don't freeze freeze flags!
          if (!freezeRegexp.matcher(dataName).matches())
            return;           // only freeze data which matches the regexp.

          DataElement e = (DataElement) data.get(dataName);
          SaveableData value = (e == null ? null : e.getValue());
          boolean valueIsFrozen = (value instanceof FrozenData);

          synchronized (this) {
            if (currentState == FDS_GRANDFATHERED && valueIsFrozen) {
              freezeAll(dataItems);
View Full Code Here

Examples of net.sourceforge.processdash.data.SaveableData

            }

        } else {
            // We need to see if this element matches the expression.
            String condName = getAnonymousConditionName(dataPrefix);
            SaveableData condition = new CompiledFunction
                (condName, script, data, dataPrefix);
            data.putValue(condName, condition);

            // Keep a list of the conditions we're watching.
            condList.add(condName);

            // Listen for changes to this condition expression.
            data.addActiveDataListener(condName, this, name, false);

            // If the condition evaluates to true, add this prefix to our
            // value.
            if (test(condition.getSimpleValue())) {
                if (doAdd(dataPrefix))
                    doNotify();
            }
        }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.