コード例 #1
0
ファイル: GAMLWriterV10.java プロジェクト: potikanond/GAM
  private void writeContours(XMLEventWriter writer, XMLEvent indent, TDRStructure structure) {

    XMLEventFactory efac = XMLEventFactory.newInstance();

    Collection<XMLEvent> attrContour = new ArrayList<XMLEvent>();
    XMLEvent startContour;
    XMLEvent endContour = efac.createEndElement("", "", "contour");

    Vector<TDRContour> contours = structure.getContours();
    Iterator<TDRContour> it = contours.iterator();

    try {

      while (it.hasNext()) {
        TDRContour contour = it.next();
        String section = String.valueOf(contour.getSection().getNumber());
        String startpoint = contour.get_startpoint_x() + "," + contour.get_startpoint_y();
        String offset = String.valueOf(contour.get_offset());
        String numpoints = String.valueOf(contour.get_numpoints());

        /* prepare contour's attributes */
        attrContour.clear(); /*clear existing attributes*/
        attrContour.add(efac.createAttribute("section", section));
        attrContour.add(efac.createAttribute("startpoint", startpoint));
        attrContour.add(efac.createAttribute("offset", offset));
        attrContour.add(efac.createAttribute("numpoints", numpoints));
        startContour = efac.createStartElement("", "", "contour", attrContour.iterator(), null);

        /*<contour>*/
        writer.add(indent);
        writer.add(startContour);
        writer.add(endContour);
        writer.add(newLine);
      }

    } catch (XMLStreamException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
  }