Пример #1
0
  public void save(final HObject parent, boolean isLink, boolean forceSave) throws Exception {
    if (dirty || forceSave) {
      H5Datatype dataType;
      Object valueObject = getValue().getStorage();
      if (valueObject instanceof String[]) {
        String[] strArray = (String[]) valueObject;
        // valueObject = strArray[0];
        dataType = new H5Datatype(Datatype.CLASS_STRING, strArray[0].length() + 1, -1, -1);
      } else {
        int type_id = HdfObjectUtils.getNativeHdfDataTypeForClass(value.getElementType());
        dataType = new H5Datatype(type_id);
      }

      Attribute attr = HdfObjectUtils.getAttribute(parent, getName());

      if (isLink && attr != null) {
        return;
      }

      if (attr == null) {
        attr = new Attribute(getName(), dataType, null, valueObject);
      } else {
        attr.setValue(valueObject);
      }

      parent.writeMetadata(attr);
    }
  }