View Javadoc

1   package org.catacomb.serial.om;
2   
3   
4   public class OmWriter {
5   
6       protected String formatDouble(double d) {
7           String ret = "0";
8           if (d != 0.0) {
9               ret = String.format("%8.3g", new Double(d)).trim();
10          }
11          return ret;
12      }
13  
14      public void addBodyElement(OmElement ome, String sn, String sv) {
15          if (sv != null && sv.length() > 0) {
16              OmElement elt = new OmElement(sn);
17              elt.setBody(sv);
18              ome.addElement(elt);
19          }
20      }
21  
22      public void addAttribute(OmElement ome, String sn, String sv) {
23          if (sv != null && sv.length() > 0) {
24              ome.addAttribute(sn, sv);
25          }
26      }
27  
28      public void addAttribute(OmElement ome, String sn, double d) {
29          addAttribute(ome, sn, formatDouble(d));
30      }
31  
32  }