示例#1
0
  // Validate tagged values cache, filtering on tagged values defined within
  // ShapeChange ...
  public void validateTaggedValuesCache() {
    if (taggedValuesCache == null) {
      // Fetch tagged values collection
      Collection<TaggedValue> tvs = eaClassElement.GetTaggedValues();

      // ensure that there are tagged values
      if (tvs != null) {
        // Allocate cache
        int ntvs = tvs.GetCount();
        taggedValuesCache = options().taggedValueFactory(ntvs);
        // Copy tag-value-pairs, leave out non-ShapeChange stuff and
        // normalize deprecated tags.
        for (TaggedValue tv : tvs) {
          String t = tv.GetName();
          t = document.normalizeTaggedValue(t);
          if (t != null) {
            String v = tv.GetValue();
            if (v.equals("<memo>")) v = tv.GetNotes();
            taggedValuesCache.add(t, v);
          }
        }
      } else {
        taggedValuesCache = options().taggedValueFactory(0);
      }
    }
  } // validateTaggedValuesCache()
示例#2
0
 /** Set the tagged value for the tag given. */
 public void taggedValue(String tag, String value) {
   Collection<TaggedValue> cTV = eaClassElement.GetTaggedValues();
   TaggedValue tv = cTV.GetByName(tag);
   if (tv == null && value != null) {
     tv = cTV.AddNew(tag, value);
     tv.Update();
   } else if (tv != null) {
     if (value == null) value = "";
     if (!tv.GetValue().equals(value)) {
       tv.SetValue(value);
       tv.Update();
     }
   }
   // invalidate cache
   taggedValuesCache = null;
 } // taggedValue()