Package net.sourceforge.processdash.data

Examples of net.sourceforge.processdash.data.SaveableData


    public SaveableData getValue(String name) {
        return (SaveableData) elements.get(name);
    }

    public SimpleData getSimpleValue(String name) {
        SaveableData result = getValue(name);
        if (result == null)
            return null;
        else
            return result.getSimpleValue();
    }
View Full Code Here


    private boolean shouldBeVisible(String path) {
        if (path == null)
            return false;

        SaveableData enabledVal = dashCtx.getData().getInheritableValue(path,
                ENABLED_DATA_NAME);
        if (enabledVal == null)
            return Settings.getBool(ENABLED_SETTING_NAME, true);

        SimpleData enabled = enabledVal.getSimpleValue();
        return (enabled != null && enabled.test());
    }
View Full Code Here

    public static boolean taskIsPruned(DataRepository data,
                                       String taskListName,
                                       String taskPath)
    {
        SaveableData d = data.getInheritableValue
            (taskPath, TASK_PRUNING_PREFIX + taskListName);
        int pruningFlag = INFER_FROM_CONTEXT;

        if (d != null && d.getSimpleValue() instanceof NumberData)
            pruningFlag = ((NumberData) d.getSimpleValue()).getInteger();

        return pruningFlag == USER_PRUNED;
    }
View Full Code Here

    /** this renames data values in the global datafile. */
    private void remapDataNames(String oldPrefix, String newPrefix) {

      String name, newName;
      DataElement element;
      SaveableData value;

      oldPrefix = oldPrefix + "/";
      newPrefix = newPrefix + "/";
      int oldPrefixLen = oldPrefix.length();
      Iterator k = getInternalKeys();
      while (k.hasNext()) {
        name = (String) k.next();
        if (!name.startsWith(oldPrefix))
          continue;

        element = (DataElement) data.get(name);
        if (element == null ||
            element.isDefaultName() ||
            element.datafile == null ||
            element.datafile.prefix == null ||
            element.datafile.prefix.length() > 0)
          // only remap data which lives in the global datafile.
          continue;

        value = element.getValue();

        // At this point, we will not rename data elements unless they
        // are SimpleData.  Non-simple data (e.g., functions, etc) needs
        // to know its name and prefix, so it would be more complicated to
        // move - but none of that stuff should be moving.
        if (value instanceof SimpleData) {
          newName = newPrefix + name.substring(oldPrefixLen);
          newName = intern(newName, false);
          //System.out.println("renaming " + name + " to " + newName);
          putValue(newName, value.getSimpleValue(), IS_NOT_DEFAULT_VAL);
          putValue(name, null, IS_NOT_DEFAULT_VAL);
        }
      }
    }
View Full Code Here

                try {
                    DataElement de = getOrCreateDefaultDataElement(name);
                    if (de == null || de.datafile == null)
                        continue;

                    SaveableData sd;
                    if (style == DUMP_STYLE_CALC)
                        sd = de.getValue();
                    else
                        sd = de.getSimpleValue();
                    if (sd == null)
                        continue;

                    String value = null;
                    if (style != DUMP_STYLE_TEXT) {
                        value = sd.saveString();
                    } else if (sd instanceof DateData) {
                        value = ((DateData) sd).formatDate();
                    } else if (sd instanceof StringData) {
                        value = StringData.escapeString(((StringData) sd)
                                .getString());
                    } else
                        value = sd.toString();

                    if (style == DUMP_STYLE_TEXT) {
                        if (name.indexOf(',') != -1)
                            name = EscapeString.escape(name, '\\', ",", "c");
                        out.println(name + "," + value);
View Full Code Here

        // constructed, do not create the default value.
        if (d == null && lookupDefaultValueObject(name, null) != null)
            return;

        if (d == null || d.getValue() == null) {
            SaveableData v;  
            try {
                v = ValueFactory.create(name, value, this, prefix);
            } catch (MalformedValueException e) {
                v = new MalformedData(value);
            }
View Full Code Here

        String localName = name.substring(f.prefix.length() + 1);
        Object defaultValueObject = f.inheritedDefinitions.get(localName);
        if (defaultValueObject == null)
            return null;
     
        SaveableData value = instantiateValue(name, f.prefix,
                defaultValueObject, !f.canWrite);
        return janitor.itemWasCreated(add(name, IS_DEFAULT_NAME, value,
                IS_DEFAULT_VAL, f, DO_NOT_NOTIFY));
    }
View Full Code Here

      try {
        // Note: this is creating the new percentage object in the null
        // datafile.  This helps prevent it from being saved, but if the
        // user edits it, it will never be saved.  Is this correct?
        SaveableData result = new PercentageFunction(name, this);
        return add(name, IS_DEFAULT_NAME, result, IS_DEFAULT_VAL, null,
                DO_NOT_NOTIFY);
      } catch (MalformedValueException mve) {
        return null;
      }
View Full Code Here

    /** @since 2.0.9 */
    public static SaveableData getInheritableValue(DataContext ctx,
            StringBuffer prefix_, String name) {
      String prefix = prefix_.toString();
      String dataName = prefix + "/" + name;
      SaveableData result = ctx.getValue(dataName);
      int pos;
      while (result == null && prefix.length() > 0) {
        pos = prefix.lastIndexOf('/');
        if (pos == -1)
          prefix = "";
View Full Code Here

        recursion_depth++;
        DataElement d = (DataElement)data.get(name);

        if (d != null) {
                                // change the value of the data element.
          SaveableData oldValue = d.getValue();
          d.setValue(value, isDefaultValue);

                                // possibly mark the datafile as modified.
          if (checkDatafileModification &&
              d.datafile != null &&
              value != oldValue &&
              (oldValue == null || value == null ||
               !value.saveString().equals(oldValue.saveString()))) {

            // This data element has been changed and should be saved.

            if (PHANTOM_DATAFILES.contains(d.datafile)) {
              // move the item OUT of the phantom datafile so it will be saved.
              d.datafile = guessDataFile(name, REQUIRE_WRITABLE);
              d.isDefaultName = false;
            }

            datafileModified(d.datafile);
          }

                                // possibly throw away the old value.
          if (oldValue != null && oldValue != value)
              try {
                  oldValue.dispose();
              } catch (Exception ex) {}

                                // notify any listeners registed for the change
          dataNotifier.dataChanged(name, d);
View Full Code Here

TOP

Related Classes of net.sourceforge.processdash.data.SaveableData

Copyright © 2018 www.massapicom. 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.