Exemple #1
0
  protected DataItem getDataItem(int iRank) throws NexusException {
    DataItem dataItem;
    NexusNode nnNode = getCurrentPath().getCurrentNode();
    String sNodeName = nnNode.getNodeName();
    String sNodeClass = nnNode.getClassName();

    // If encountered a DataItem get its datas
    if (!nnNode.isGroup() && !sNodeClass.equals("NXtechnical_data")) {
      dataItem = readDataItem(iRank);
      dataItem.setNodeName(sNodeName);

      return dataItem;
    }
    // else if we encountered a NXtechnical_data group: we get its "data"
    // and "description"
    else if (!nnNode.isGroup() && sNodeClass.equals("NXtechnical_data")) {
      // Get the "data" node
      openData("data");
      dataItem = readDataItem(iRank);
      dataItem.setNodeName(sNodeName);
      closeData();
      // Try to get a description for the technical data
      try {
        // Set to "data" as description attribute the "description" node
        // beside
        openData("description");
        dataItem.setDesc(readDataItem(iRank).getData());
        closeData();
      } catch (NexusException ne) {
        closeData();
      }
      dataItem.setPath(getCurrentPath().clone());

      return dataItem;
    } else {
      return null;
    }
  }
Exemple #2
0
  /**
   * readDataInfo Return the DataItem fitting the opened DataItem, without main data. The DataItem
   * is initialized with dimsize, type... but the DataItem isn't read.
   */
  public DataItem readDataInfo() throws NexusException {
    NexusNode nnNode = getCurrentPath().getCurrentNode();
    if (!nnNode.isGroup() && nnNode.getClassName().equals("NXtechnical_data")) {
      return getDataItem();
    }

    // Get infos on DataItem (data type, rank, dimsize)
    int[] iNodeSize = new int[RANK_MAX]; // whole DataItem dimension's sizes
    int[] iDimSize; // data dimension's sizes
    int[] iDataInf = new int[2]; // iDataInf[0] = DataItem rank ;
    // iDataInf[1]= data type

    openFile();
    getNexusFile().getinfo(iNodeSize, iDataInf);

    // Initialize dimension's sizes
    iDimSize = new int[iDataInf[0]];
    System.arraycopy(iNodeSize, 0, iDimSize, 0, iDataInf[0]);

    // Check if DataItem is linked to an external DataItem
    DataItem dsData = new DataItem();
    dsData.setType(iDataInf[1]);
    dsData.setSize(iDimSize);
    dsData.setSlabSize(iDimSize);
    dsData.setStart(new int[iDimSize.length]);
    dsData.setNodeName(getCurrentPath().getDataItemName());
    dsData.setPath(getCurrentPath().clone());
    dsData.isSingleRawArray(m_bResultAsSingleRaw);

    if (dsData.getType() == NexusFile.NX_CHAR) {
      dsData.setData(readNodeValue(iDataInf, dsData.getSize(), iDimSize.length));
    }
    closeFile();

    // Initialize DataItem's attributes
    getDataItemAttribute(dsData);
    return dsData;
  }