1 package jimm.datavision.layout; 2 import jimm.datavision.*; 3 import jimm.datavision.field.*; 4 import jimm.util.XMLWriter; 5 6 11 public class XMLLE extends SortedLayoutEngine { 12 13 protected XMLWriter iout; 14 protected String encoding; 15 16 21 public XMLLE(XMLWriter out) { 22 this(out, Report.XML_ENCODING_ATTRIBUTE); 23 } 24 25 34 public XMLLE(XMLWriter out, String enc) { 35 super(out); 36 iout = out; 37 encoding = (enc == null ? Report.XML_ENCODING_ATTRIBUTE : enc); 38 } 39 40 protected void doStart() { 41 iout.xmlDecl(encoding); 42 iout.comment("Generated by DataVision version " + info.Version); 43 iout.comment(info.URL); 44 iout.startElement("report"); 45 } 46 47 protected void doEnd() { 48 iout.endElement(); 49 iout.flush(); 50 } 51 52 protected void doStartPage() { 53 iout.comment("============== Page " + pageNumber() 54 + " =============="); 55 iout.startElement("newpage"); 56 iout.attr("number", pageNumber()); 57 iout.endElement(); 58 } 59 60 protected void doOutputSection(Section s) { 61 iout.startElement("section"); 62 iout.attr("type", currentSectionTypeAsString()); 63 super.doOutputSection(s); 64 iout.endElement(); 65 } 66 67 protected void doOutputField(Field field) { 68 iout.startElement("field"); 69 iout.attr("id", field.getId()); 70 iout.attr("type", field.typeString()); 71 if (field instanceof SpecialField) 72 iout.attr("value", field.getValue()); 73 else if (field instanceof ColumnField) 74 iout.attr(" column", ((ColumnField)field).getColumn().fullName()); 75 else if (field instanceof AggregateField) { 76 AggregateField sf = (AggregateField)field; 77 if (sf.getGroup() != null) 78 iout.attr("group", sf.getGroup().getSelectable().getDisplayName()); 79 } 80 81 iout.cdata(field.toString()); 82 iout.endElement(); 83 } 84 85 protected void doOutputImage(ImageField image) { 86 doOutputField(image); 87 } 88 89 protected void doOutputLine(Line l) { 90 l.writeXML(iout); 91 } 92 93 } 94 95 | Popular Tags |