Example #1
0
  /**
   * Recursively find link to node given by path name
   *
   * @param pathname
   * @return node or null if not found
   */
  public HDF5NodeLink findNodeLink(String pathname) {
    int i = pathname.indexOf(SEPARATOR);

    if (i == 0) {
      pathname = pathname.substring(1);
      i = pathname.indexOf(SEPARATOR);
    }

    String link = i < 0 ? pathname : pathname.substring(0, i);

    if (nodes.containsKey(link)) {
      HDF5NodeLink node = nodes.get(link);
      if (i < 0) {
        return node;
      }
      String path = pathname.substring(i + 1);
      if (node.isDestinationAGroup()) {
        return ((HDF5Group) node.getDestination()).findNodeLink(path);
      }
    } else { // is attribute?
      i = link.indexOf(ATTRIBUTE);
      if (i > 0) {
        link = pathname.substring(0, i);
        String attr = pathname.substring(i + 1);
        if (nodes.containsKey(link)) {
          HDF5NodeLink node = nodes.get(link);
          if (node.getDestination().containsAttribute(attr)) {
            return node;
          }
        }
      }
    }
    return null;
  }
Example #2
0
 /**
  * Remove given dataset
  *
  * @param d dataset
  */
 public void removeDataset(final HDF5Dataset d) {
   for (String n : nodes.keySet()) {
     HDF5NodeLink l = nodes.get(n);
     if (l.getDestination().equals(d)) {
       nodes.remove(n);
       datasets--;
       return;
     }
   }
   throw new IllegalArgumentException("Given dataset does not exist in this group");
 }
Example #3
0
 /**
  * Remove given group
  *
  * @param g group
  */
 public void removeGroup(final HDF5Group g) {
   for (String n : nodes.keySet()) {
     HDF5NodeLink l = nodes.get(n);
     if (l.getDestination().equals(g)) {
       nodes.remove(n);
       groups--;
       return;
     }
   }
   throw new IllegalArgumentException("Given group does not exist in this group");
 }
Example #4
0
  private void findDatasets(
      final String name, final List<ILazyDataset> list, final HDF5NodeLink link) {
    HDF5Node n = null;
    if (link.isDestinationASymLink()) {
      if (link.getName().equals(name)) {}
      HDF5SymLink slink = (HDF5SymLink) link.getDestination();
      if (slink.isDataset()) n = slink.getNode();
    } else {
      n = link.getDestination();
    }

    if (n == null) return;

    if (n instanceof HDF5Group) {
      for (HDF5NodeLink l : (HDF5Group) n) findDatasets(name, list, l);
    } else if (n instanceof HDF5Dataset) {
      if (link.getName().equals(name)) {
        ILazyDataset dataset = ((HDF5Dataset) n).getDataset();
        if (!list.contains(dataset)) list.add(dataset);
      }
    }
  }