Beispiel #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);
    }
  }
Beispiel #2
0
  /** { "Name", "Class", "Dims", "Type", "Size" }; */
  @Override
  public String getColumnText(Object element, int columnIndex) {

    if (!(element instanceof TreeNode)) return null;
    final TreeNode node = (TreeNode) element;

    HObject object = (HObject) ((DefaultMutableTreeNode) node).getUserObject();

    if (file.isClosed()) {
      try {
        this.file = HierarchicalDataFactory.getReader(file.getPath());

      } catch (Exception e) {
        logger.error("Cannot re-create link to " + file.getPath());
      }
    }

    try {
      object = (HObject) file.getData(object.getFullName());
    } catch (Exception e) {
      logger.error("Cannot re-create link to recorde " + object.getFullName());
    }

    if (object == null) return null;

    switch (columnIndex) {
      case 0:
        return object.getName();
      case 1:
        if (object instanceof Group) {
          return "Group";
        } else if (object instanceof Dataset) {
          return "Dataset";
        } else {
          return object.getClass().getConstructors()[0].getName();
        }
      case 2:
        if (object instanceof Dataset) {
          long[] shape;
          try {
            shape = HierarchicalDataUtils.getDims((Dataset) object);
          } catch (Exception e) {
            return "";
          }
          if (shape == null) return "";
          return Arrays.toString(shape);
        }
        return "";
      case 3:
        if (object instanceof Dataset) {
          return "" + ((Dataset) object).getDatatype().getDatatypeDescription();
        }
        return "";
      case 4:
        if (object instanceof Dataset) {
          long memSize;
          try {
            memSize = HierarchicalDataUtils.getSize((Dataset) object);
          } catch (Exception e) {
            return "";
          }
          if (memSize < 0) return "";
          return formatSize(memSize);
        }
        return "";
      default:
        return null;
    }
  }