Ejemplo n.º 1
0
  protected void createPath(PathNexus paPath, boolean bKeepOpen) throws NexusException {
    String sCurClass = ""; // Class name of the group we are processing
    String sCurName = ""; // Name of the group we are processing
    NexusNode nCurStep = null; // Currently opened node name in the NexusFile
    int iCurDepth = 0; // Current depth in the path
    int iPathDepth = paPath.getDepth();

    // Return to root node
    closeAll();

    // Create each group
    NexusNode nnNode;
    while (iCurDepth < iPathDepth) {
      // Determine group and class names
      nnNode = paPath.getNode(iCurDepth);
      sCurName = nnNode.getNodeName();
      sCurClass = nnNode.getClassName();

      // Create appropriate group and open it
      nCurStep = getCurrentRealPath().getCurrentNode();
      if (nnNode.isGroup() || "NXtechnical_data".equals(nnNode.getClassName())) {
        try {
          openGroup(sCurName, sCurClass);
        } catch (NexusException ne) {
          // Ensure we are still in the expected group
          if (nCurStep != null && !nCurStep.equals(getCurrentRealPath().getCurrentNode()))
            closeGroup();

          // Create the requested group
          getNexusFile().makegroup(sCurName, sCurClass);

          // Force the buffer node list to be updated
          pushNodeInBuffer(sCurName, sCurClass);

          // Open created group
          openGroup(sCurName, sCurClass);
        }
      }
      // Go one step forward in path
      iCurDepth++;
    }

    // Return to root node if necessary
    if (!bKeepOpen) closeAll();
  }