|
From: <sa...@us...> - 2004-03-01 09:09:08
|
Update of /cvsroot/jrobin/src/org/jrobin/core In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19077/org/jrobin/core Modified Files: FetchData.java RrdDb.java RrdDef.java XmlWriter.java Log Message: XML templates for RrdDef and RrdGraphDef completed. Index: FetchData.java =================================================================== RCS file: /cvsroot/jrobin/src/org/jrobin/core/FetchData.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** FetchData.java 19 Feb 2004 12:23:57 -0000 1.3 --- FetchData.java 1 Mar 2004 08:50:24 -0000 1.4 *************** *** 381,385 **** writer.closeTag(); // data writer.closeTag(); // fetch_data ! writer.finish(); } --- 381,385 ---- writer.closeTag(); // data writer.closeTag(); // fetch_data ! writer.flush(); } Index: RrdDb.java =================================================================== RCS file: /cvsroot/jrobin/src/org/jrobin/core/RrdDb.java,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** RrdDb.java 19 Feb 2004 12:23:57 -0000 1.10 --- RrdDb.java 1 Mar 2004 08:50:24 -0000 1.11 *************** *** 513,517 **** } writer.closeTag(); ! writer.finish(); } --- 513,517 ---- } writer.closeTag(); ! writer.flush(); } Index: RrdDef.java =================================================================== RCS file: /cvsroot/jrobin/src/org/jrobin/core/RrdDef.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** RrdDef.java 26 Feb 2004 13:15:54 -0000 1.8 --- RrdDef.java 1 Mar 2004 08:50:24 -0000 1.9 *************** *** 388,392 **** } xml.closeTag(); // rrd_def ! xml.finish(); } --- 388,392 ---- } xml.closeTag(); // rrd_def ! xml.flush(); } Index: XmlWriter.java =================================================================== RCS file: /cvsroot/jrobin/src/org/jrobin/core/XmlWriter.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** XmlWriter.java 26 Feb 2004 13:15:54 -0000 1.4 --- XmlWriter.java 1 Mar 2004 08:50:24 -0000 1.5 *************** *** 28,34 **** import java.io.OutputStream; import java.io.PrintWriter; import java.util.Stack; ! class XmlWriter { static final String INDENT_STR = " "; --- 28,39 ---- import java.io.OutputStream; import java.io.PrintWriter; + import java.io.File; import java.util.Stack; + import java.awt.*; ! /** ! * Extremely simple utility class used to create XML documents. ! */ ! public class XmlWriter { static final String INDENT_STR = " "; *************** *** 37,45 **** private Stack openTags = new Stack(); ! XmlWriter(OutputStream stream) { writer = new PrintWriter(stream); } ! void startTag(String tag) { writer.println(indent + "<" + tag + ">"); openTags.push(tag); --- 42,58 ---- private Stack openTags = new Stack(); ! /** ! * Creates XmlWriter with the specified output stream to send XML code to. ! * @param stream Output stream which receives XML code ! */ ! public XmlWriter(OutputStream stream) { writer = new PrintWriter(stream); } ! /** ! * Opens XML tag ! * @param tag XML tag name ! */ ! public void startTag(String tag) { writer.println(indent + "<" + tag + ">"); openTags.push(tag); *************** *** 47,51 **** } ! void closeTag() { String tag = (String) openTags.pop(); indent.setLength(indent.length() - INDENT_STR.length()); --- 60,67 ---- } ! /** ! * Closes the corresponding XML tag ! */ ! public void closeTag() { String tag = (String) openTags.pop(); indent.setLength(indent.length() - INDENT_STR.length()); *************** *** 53,59 **** } ! void writeTag(String tag, Object value) { if(value != null) { ! writer.println(indent + "<" + tag + ">" + value + "</" + tag + ">"); } else { --- 69,81 ---- } ! /** ! * Writes <tag>value</tag> to output stream ! * @param tag XML tag name ! * @param value value to be placed between <code><tag></code> and <code></tag></code> ! */ ! public void writeTag(String tag, Object value) { if(value != null) { ! writer.println(indent + "<" + tag + ">" + ! escape(value.toString()) + "</" + tag + ">"); } else { *************** *** 62,82 **** } ! void writeTag(String tag, int value) { writeTag(tag, "" + value); } ! void writeTag(String tag, long value) { writeTag(tag, "" + value); } ! void writeTag(String tag, double value, String nanString) { writeTag(tag, Util.formatDouble(value, nanString, true)); } ! void writeTag(String tag, double value) { writeTag(tag, Util.formatDouble(value, true)); } ! void finish() { writer.flush(); } --- 84,180 ---- } ! /** ! * Writes <tag>value</tag> to output stream ! * @param tag XML tag name ! * @param value value to be placed between <code><tag></code> and <code></tag></code> ! */ ! public void writeTag(String tag, int value) { writeTag(tag, "" + value); } ! /** ! * Writes <tag>value</tag> to output stream ! * @param tag XML tag name ! * @param value value to be placed between <code><tag></code> and <code></tag></code> ! */ ! public void writeTag(String tag, long value) { writeTag(tag, "" + value); } ! /** ! * Writes <tag>value</tag> to output stream ! * @param tag XML tag name ! * @param value value to be placed between <code><tag></code> and <code></tag></code> ! */ ! public void writeTag(String tag, double value, String nanString) { writeTag(tag, Util.formatDouble(value, nanString, true)); } ! /** ! * Writes <tag>value</tag> to output stream ! * @param tag XML tag name ! * @param value value to be placed between <code><tag></code> and <code></tag></code> ! */ ! public void writeTag(String tag, double value) { writeTag(tag, Util.formatDouble(value, true)); } ! /** ! * Writes <tag>value</tag> to output stream ! * @param tag XML tag name ! * @param value value to be placed between <code><tag></code> and <code></tag></code> ! */ ! public void writeTag(String tag, boolean value) { ! writeTag(tag, "" + value); ! } ! ! /** ! * Writes <tag>value</tag> to output stream ! * @param tag XML tag name ! * @param value value to be placed between <code><tag></code> and <code></tag></code> ! */ ! public void writeTag(String tag, Color value) { ! int rgb = value.getRGB() & 0xFFFFFF; ! writeTag(tag, "#" + Integer.toHexString(rgb).toUpperCase()); ! } ! ! /** ! * Writes <tag>value</tag> to output stream ! * @param tag XML tag name ! * @param value value to be placed between <code><tag></code> and <code></tag></code> ! */ ! public void writeTag(String tag, Font value) { ! startTag(tag); ! writeTag("name", value.getName()); ! int style = value.getStyle(); ! if((style & Font.BOLD) != 0 && (style & Font.ITALIC) != 0) { ! writeTag("style", "BOLDITALIC"); ! } ! else if((style & Font.BOLD) != 0) { ! writeTag("style", "BOLD"); ! } ! else if((style & Font.ITALIC) != 0) { ! writeTag("style", "ITALIC"); ! } ! else { ! writeTag("style", "PLAIN"); ! } ! writeTag("size", value.getSize()); ! closeTag(); ! } ! ! /** ! * Writes <tag>value</tag> to output stream ! * @param tag XML tag name ! * @param value value to be placed between <code><tag></code> and <code></tag></code> ! */ ! public void writeTag(String tag, File value) { ! writeTag(tag, value.getPath()); ! } ! ! /** ! * Flushes the output stream ! */ ! public void flush() { writer.flush(); } *************** *** 86,91 **** } ! void writeComment(Object comment) { ! writer.println(indent + "<!-- " + comment + " -->"); } } --- 184,201 ---- } ! /** ! * Writes XML comment to output stream ! * @param comment comment string ! */ ! public void writeComment(Object comment) { ! writer.println(indent + "<!-- " + escape(comment.toString()) + " -->"); ! } ! ! private static String escape(String s) { ! return s.replaceAll("<", "<").replaceAll(">", ">"); ! } ! ! public static void main(String[] args) { ! System.out.println(escape("<->")); } } |