cdm/src/main/java/ucar/nc2/ft/fmrc/GridDatasetInv.java
Document writeDocument(Date lastModified) {
    Element rootElem = new Element("gridInventory");
    Document doc = new Document(rootElem);
    rootElem.setAttribute("location", location);
    rootElem.setAttribute("runTime", runTimeString);
    if (lastModified != null) {
      rootElem.setAttribute("lastModified", CalendarDateFormatter.toDateTimeString(lastModified));
    }
    rootElem.setAttribute("version", Integer.toString(CURR_VERSION));

    // list all the vertical coords
    Collections.sort(vaxes);
    int count = 0;
    for (VertCoord vc : vaxes) {
      vc.setId(count++);
      Element vcElem = new Element("vertCoord");
      rootElem.addContent(vcElem);
      vcElem.setAttribute("id", Integer.toString(vc.getId()));
      vcElem.setAttribute("name", vc.getName());
      if (vc.getUnits() != null)
        vcElem.setAttribute(CDM.UNITS, vc.getUnits());

      StringBuilder sbuff = new StringBuilder();
      double[] values1 = vc.getValues1();
      double[] values2 = vc.getValues2();
      for (int j = 0; j < values1.length; j++) {
        if (j > 0) sbuff.append(" ");
        sbuff.append(Double.toString(values1[j]));
        if (values2 != null) {
          sbuff.append(",");
          sbuff.append(Double.toString(values2[j]));
        }
      }
      vcElem.addContent(sbuff.toString());
    }

    // list all the time coords
    count = 0;
    for (TimeCoord tc : times) {
      tc.setId(count++);
      Element timeElement = new Element("timeCoord");
      rootElem.addContent(timeElement);
      timeElement.setAttribute("id", Integer.toString(tc.getId()));
      timeElement.setAttribute("name", tc.getName());
      timeElement.setAttribute("isInterval", tc.isInterval() ? "true" : "false");

      Formatter sbuff = new Formatter();
      if (tc.isInterval()) {
        double[] bound1 = tc.getBound1();
        double[] bound2 = tc.getBound2();
        for (int j = 0; j < bound1.length; j++)
          sbuff.format((Locale) null, "%f %f,", bound1[j], bound2[j]);

      } else {
        for (double offset : tc.getOffsetTimes())
          sbuff.format((Locale) null, "%f,", offset);
      }
      timeElement.addContent(sbuff.toString());

      List<GridDatasetInv.Grid> vars = tc.getGridInventory();
      Collections.sort(vars);
      for (Grid grid : vars) {
        Element varElem = new Element("grid");
        timeElement.addContent(varElem);
        varElem.setAttribute("name", grid.name);
        if (grid.ec != null)
          varElem.setAttribute("ens_id", Integer.toString(grid.ec.getId()));
        if (grid.vc != null)
          varElem.setAttribute("vert_id", Integer.toString(grid.vc.getId()));
      }
    }

    return doc;
  }
Document writeDocument(Date lastModified) {
    Element rootElem = new Element("gridInventory");
    Document doc = new Document(rootElem);
    rootElem.setAttribute("location", location);
    rootElem.setAttribute("runTime", runTimeString);
    if (lastModified != null) {
      rootElem.setAttribute("lastModified", CalendarDateFormatter.toDateTimeString(lastModified));
    }
    rootElem.setAttribute("version", Integer.toString(CURR_VERSION));

    // list all the vertical coords
    Collections.sort(vaxes);
    int count = 0;
    for (VertCoord vc : vaxes) {
      vc.setId(count++);
      Element vcElem = new Element("vertCoord");
      rootElem.addContent(vcElem);
      vcElem.setAttribute("id", Integer.toString(vc.getId()));
      vcElem.setAttribute("name", vc.getName());
      if (vc.getUnits() != null)
        vcElem.setAttribute(CDM.UNITS, vc.getUnits());

      StringBuilder sbuff = new StringBuilder();
      double[] values1 = vc.getValues1();
      double[] values2 = vc.getValues2();
      for (int j = 0; j < values1.length; j++) {
        if (j > 0) sbuff.append(" ");
        sbuff.append(Double.toString(values1[j]));
        if (values2 != null) {
          sbuff.append(",");
          sbuff.append(Double.toString(values2[j]));
        }
      }
      vcElem.addContent(sbuff.toString());
    }

    // list all the time coords
    count = 0;
    for (TimeCoord tc : times) {
      tc.setId(count++);
      Element timeElement = new Element("timeCoord");
      rootElem.addContent(timeElement);
      timeElement.setAttribute("id", Integer.toString(tc.getId()));
      timeElement.setAttribute("name", tc.getName());
      timeElement.setAttribute("isInterval", tc.isInterval() ? "true" : "false");

      Formatter sbuff = new Formatter();
      if (tc.isInterval()) {
        double[] bound1 = tc.getBound1();
        double[] bound2 = tc.getBound2();
        for (int j = 0; j < bound1.length; j++)
          sbuff.format((Locale) null, "%f %f,", bound1[j], bound2[j]);

      } else {
        for (double offset : tc.getOffsetTimes())
          sbuff.format((Locale) null, "%f,", offset);
      }
      timeElement.addContent(sbuff.toString());

      List<GridDatasetInv.Grid> vars = tc.getGridInventory();
      Collections.sort(vars);
      for (Grid grid : vars) {
        Element varElem = new Element("grid");
        timeElement.addContent(varElem);
        varElem.setAttribute("name", grid.name);
        if (grid.ec != null)
          varElem.setAttribute("ens_id", Integer.toString(grid.ec.getId()));
        if (grid.vc != null)
          varElem.setAttribute("vert_id", Integer.toString(grid.vc.getId()));
      }
    }

    return doc;
  }
Document writeDocument ( Date lastModified ) { Element rootElem = new Element ( "gridInventory" ) ; Document doc = new Document ( rootElem ) ; rootElem . setAttribute ( "location" , location ) ; rootElem . setAttribute ( "runTime" , runTimeString ) ; if ( lastModified != null ) { rootElem . setAttribute ( "lastModified" , CalendarDateFormatter . toDateTimeString ( lastModified ) ) ; } rootElem . setAttribute ( "version" , Integer . toString ( CURR_VERSION ) ) ; // list all the vertical coords
 Collections . sort ( vaxes ) ; int count = 0 ; for ( VertCoord vc : vaxes ) { vc . setId ( count ++ ) ; Element vcElem = new Element ( "vertCoord" ) ; rootElem . addContent ( vcElem ) ; vcElem . setAttribute ( "id" , Integer . toString ( vc . getId ( ) ) ) ; vcElem . setAttribute ( "name" , vc . getName ( ) ) ; if ( vc . getUnits ( ) != null ) vcElem . setAttribute ( CDM . UNITS , vc . getUnits ( ) ) ; StringBuilder sbuff = new StringBuilder ( ) ; double [ ] values1 = vc . getValues1 ( ) ; double [ ] values2 = vc . getValues2 ( ) ; for ( int j = 0 ; j < values1 . length ; j ++ ) { if ( j > 0 ) sbuff . append ( " " ) ; sbuff . append ( Double . toString ( values1 [ j ] ) ) ; if ( values2 != null ) { sbuff . append ( "," ) ; sbuff . append ( Double . toString ( values2 [ j ] ) ) ; } } vcElem . addContent ( sbuff . toString ( ) ) ; } // list all the time coords
 count = 0 ; for ( TimeCoord tc : times ) { tc . setId ( count ++ ) ; Element timeElement = new Element ( "timeCoord" ) ; rootElem . addContent ( timeElement ) ; timeElement . setAttribute ( "id" , Integer . toString ( tc . getId ( ) ) ) ; timeElement . setAttribute ( "name" , tc . getName ( ) ) ; timeElement . setAttribute ( "isInterval" , tc . isInterval ( ) ? "true" : "false" ) ; Formatter sbuff = new Formatter ( ) ; if ( tc . isInterval ( ) ) { double [ ] bound1 = tc . getBound1 ( ) ; double [ ] bound2 = tc . getBound2 ( ) ; for ( int j = 0 ; j < bound1 . length ; j ++ ) sbuff . format ( ( Locale ) null , "%f %f," , bound1 [ j ] , bound2 [ j ] ) ; } else { for ( double offset : tc . getOffsetTimes ( ) ) sbuff . format ( ( Locale ) null , " % , " , offset ) ; } timeElement . addContent ( sbuff . toString ( ) ) ; List < GridDatasetInv . Grid > vars = tc . getGridInventory ( ) ; Collections . sort ( vars ) ; for ( Grid grid : vars ) { Element varElem = new Element ( "grid" ) ; timeElement . addContent ( varElem ) ; varElem . setAttribute ( "name" , grid . name ) ; if ( grid . ec != null ) varElem . setAttribute ( "ens_id" , Integer . toString ( grid . ec . getId ( ) ) ) ; if ( grid . vc != null ) varElem . setAttribute ( "vert_id" , Integer . toString ( grid . vc . getId ( ) ) ) ; } } return doc ; }
Create the XML representation of the GridDatasetInv

@return the XML representation as a Document
Create the XML representation of the GridDatasetInv