コード例 #1
0
  /**
   * Build up save data as ESIS tree, then write that out. Makes node with GI = behavior name, same
   * attributes, and possibly some children. Attributes are cloned, so if you want to stuff
   * attributes from state, do that before <code>super.save()</code>. Always have {@link
   * #ATTR_BEHAVIOR} from save (short) classname.
   */
  public ESISNode save() {
    // if (getAttr(ATTR_BEHAVIOR)==null) putAttr(ATTR_BEHAVIOR, classname_);	//NOT getName(), NOT
    // getClass().getName());	// temporary.  X remove BEHAVIOR attribute in favor of name => want
    // names for things other than behvaior so no way to distinguish be from non-be
    Map<String, Object> attrs = getAttributes();
    if (attrs != null) {
      Map<String, Object> newattrs = new HashMap<String, Object>(attrs.size());
      newattrs.putAll(attrs);
      attrs = newattrs;
    } // make copy (ok if inefficient here)
    ESISNode e = new ESISNode(getName(), attrs);

    // take ATTR_BEHAVIOR if exists, else use value cached in field
    e.putAttr(
        Behavior.ATTR_BEHAVIOR,
        getAttr(
            Behavior.ATTR_BEHAVIOR,
            classname_)); // maintain classname_ in attribute, since few behaviors and above is
    // disgusting

    return e;
  }