Update of /cvsroot/jrobin/src/org/jrobin/graph In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv324/org/jrobin/graph Modified Files: ExportData.java FetchSource.java FetchSourceList.java Gprint.java RrdExportDef.java RrdGraphDef.java Sdef.java Log Message: Strings like "AVERAGE" or "GAUGE" replaced with constants like ConsolFuns.AVERAGE and DsTypes.GAUGE. This change does not affect existing JRobin-based code (since constants are defined as Strings). Changes made in org.jrobin.core.* and org.jrobin.graph.* packages Index: RrdExportDef.java =================================================================== RCS file: /cvsroot/jrobin/src/org/jrobin/graph/RrdExportDef.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** RrdExportDef.java 11 Jul 2004 22:04:13 -0000 1.3 --- RrdExportDef.java 21 Sep 2004 08:42:10 -0000 1.4 *************** *** 183,187 **** * @param dsName Data source name defined in the RRD file. * @param consolFunc Consolidation function that will be used to extract data from the RRD ! * file ("AVERAGE", "MIN", "MAX" or "LAST"). */ public void datasource( String name, String file, String dsName, String consolFunc ) throws RrdException --- 183,188 ---- * @param dsName Data source name defined in the RRD file. * @param consolFunc Consolidation function that will be used to extract data from the RRD ! * file ("AVERAGE", "MIN", "MAX" or "LAST" - these string constants are conveniently defined ! * in the {@link org.jrobin.core.ConsolFuns ConsolFuns} class). */ public void datasource( String name, String file, String dsName, String consolFunc ) throws RrdException *************** *** 206,210 **** * @param dsName Data source name defined in the RRD file. * @param consolFunc Consolidation function that will be used to extract data from the RRD ! * file ("AVERAGE", "MIN", "MAX" or "LAST"). * @param backend Name of the RrdBackendFactory that should be used for this RrdDb. */ --- 207,212 ---- * @param dsName Data source name defined in the RRD file. * @param consolFunc Consolidation function that will be used to extract data from the RRD ! * file ("AVERAGE", "MIN", "MAX" or "LAST" - these string constants are conveniently defined ! * in the {@link org.jrobin.core.ConsolFuns ConsolFuns} class). * @param backend Name of the RrdBackendFactory that should be used for this RrdDb. */ Index: FetchSourceList.java =================================================================== RCS file: /cvsroot/jrobin/src/org/jrobin/graph/FetchSourceList.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** FetchSourceList.java 13 Jul 2004 16:20:07 -0000 1.3 --- FetchSourceList.java 21 Sep 2004 08:42:10 -0000 1.4 *************** *** 276,280 **** * @param dsName Data source name defined in the RRD file. * @param consolFunc Consolidation function that will be used to extract data from the RRD ! * file ("AVERAGE", "MIN", "MAX" or "LAST"). * @param backend Name of the RrdBackendFactory that should be used for this RrdDb. * @throws RrdException Thrown in case of a JRobin specific error. --- 276,281 ---- * @param dsName Data source name defined in the RRD file. * @param consolFunc Consolidation function that will be used to extract data from the RRD ! * file ("AVERAGE", "MIN", "MAX" or "LAST" - these string constants are conveniently defined ! * in the {@link org.jrobin.core.ConsolFuns ConsolFuns} class). * @param backend Name of the RrdBackendFactory that should be used for this RrdDb. * @throws RrdException Thrown in case of a JRobin specific error. *************** *** 306,310 **** * @param dsName Data source name defined in the RRD file. * @param consolFunc Consolidation function that will be used to extract data from the RRD ! * file ("AVERAGE", "MIN", "MAX" or "LAST"). * @throws RrdException Thrown in case of a JRobin specific error. */ --- 307,312 ---- * @param dsName Data source name defined in the RRD file. * @param consolFunc Consolidation function that will be used to extract data from the RRD ! * file ("AVERAGE", "MIN", "MAX" or "LAST" - these string constants are conveniently defined ! * in the {@link org.jrobin.core.ConsolFuns ConsolFuns} class). * @throws RrdException Thrown in case of a JRobin specific error. */ Index: Sdef.java =================================================================== RCS file: /cvsroot/jrobin/src/org/jrobin/graph/Sdef.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** Sdef.java 11 Jul 2004 22:04:14 -0000 1.3 --- Sdef.java 21 Sep 2004 08:42:10 -0000 1.4 *************** *** 5,17 **** import org.jrobin.core.RrdException; import org.jrobin.core.XmlWriter; /** * <p>Represents a 'static' datasource for a graph. A static datasource is a single value (constant), ! * but can only be the result of applying a consolidation function (AVG, MIN, MAX, LAST, FIRST or TOTAL) ! * to one of the other, already defined, datasources.</p> * * @author Arne Vandamme (cob...@jr...) */ ! class Sdef extends Cdef { // ================================================================ --- 5,19 ---- import org.jrobin.core.RrdException; import org.jrobin.core.XmlWriter; + import org.jrobin.core.ConsolFuns; /** * <p>Represents a 'static' datasource for a graph. A static datasource is a single value (constant), ! * but can only be the result of applying a consolidation function ! * ("AVERAGE", "MIN", "MAX", "LAST", "FIRST" or "TOTAL") to one of the other, ! * already defined, datasources.</p> * * @author Arne Vandamme (cob...@jr...) */ ! class Sdef extends Cdef implements ConsolFuns { // ================================================================ *************** *** 21,25 **** private String defName = ""; ! private String consolFunc = "AVERAGE"; private int aggregate = Source.AGG_AVERAGE; --- 23,27 ---- private String defName = ""; ! private String consolFunc = CF_AVERAGE; private int aggregate = Source.AGG_AVERAGE; *************** *** 48,62 **** // -- Parse the consolidation function to be used ! if ( consolFunc.equalsIgnoreCase("AVERAGE") || consolFunc.equalsIgnoreCase("AVG") ) aggregate = Source.AGG_AVERAGE; ! else if ( consolFunc.equalsIgnoreCase("MAX") || consolFunc.equalsIgnoreCase("MAXIMUM") ) aggregate = Source.AGG_MAXIMUM; ! else if ( consolFunc.equalsIgnoreCase("MIN") || consolFunc.equalsIgnoreCase("MINIMUM") ) aggregate = Source.AGG_MINIMUM; ! else if ( consolFunc.equalsIgnoreCase("LAST") ) aggregate = Source.AGG_LAST; ! else if ( consolFunc.equalsIgnoreCase("FIRST") ) aggregate = Source.AGG_FIRST; ! else if ( consolFunc.equalsIgnoreCase("TOTAL") ) aggregate = Source.AGG_TOTAL; else --- 50,64 ---- // -- Parse the consolidation function to be used ! if ( consolFunc.equalsIgnoreCase(CF_AVERAGE) || consolFunc.equalsIgnoreCase("AVG") ) aggregate = Source.AGG_AVERAGE; ! else if ( consolFunc.equalsIgnoreCase(CF_MAX) || consolFunc.equalsIgnoreCase("MAXIMUM") ) aggregate = Source.AGG_MAXIMUM; ! else if ( consolFunc.equalsIgnoreCase(CF_MIN) || consolFunc.equalsIgnoreCase("MINIMUM") ) aggregate = Source.AGG_MINIMUM; ! else if ( consolFunc.equalsIgnoreCase(CF_LAST) ) aggregate = Source.AGG_LAST; ! else if ( consolFunc.equalsIgnoreCase(CF_FIRST) ) aggregate = Source.AGG_FIRST; ! else if ( consolFunc.equalsIgnoreCase(CF_TOTAL) ) aggregate = Source.AGG_TOTAL; else Index: ExportData.java =================================================================== RCS file: /cvsroot/jrobin/src/org/jrobin/graph/ExportData.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** ExportData.java 27 Jul 2004 12:30:17 -0000 1.5 --- ExportData.java 21 Sep 2004 08:42:10 -0000 1.6 *************** *** 28,31 **** --- 28,32 ---- import org.jrobin.core.RrdException; import org.jrobin.core.Util; + import org.jrobin.core.ConsolFuns; import org.w3c.dom.Element; import org.w3c.dom.Node; *************** *** 39,43 **** * @author Arne Vandamme (cob...@jr...) */ ! public class ExportData implements RrdDataSet { // ================================================================ --- 40,44 ---- * @author Arne Vandamme (cob...@jr...) */ ! public class ExportData implements RrdDataSet, ConsolFuns { // ================================================================ *************** *** 302,307 **** * @param dsName Datasource name * @param consolFun Consolidation function to be applied to set datasource values datasource. ! * Valid consolidation functions are MIN, MAX, LAST, FIRST, AVERAGE and TOTAL ! * @return MIN, MAX, LAST, FIRST, AVERAGE or TOTAL value calculated from the dataset for the given datasource name * @throws RrdException Thrown if the given datasource name cannot be found in the dataset. */ --- 303,311 ---- * @param dsName Datasource name * @param consolFun Consolidation function to be applied to set datasource values datasource. ! * Valid consolidation functions are "MIN", "MAX", "LAST", "FIRST", "AVERAGE" and "TOTAL" ! * (These constants are conveniently defined in the ! * {@link org.jrobin.core.ConsolFuns ConsolFuns} class). ! * @return MIN, MAX, LAST, FIRST, AVERAGE or TOTAL value calculated from the dataset ! * for the given datasource name * @throws RrdException Thrown if the given datasource name cannot be found in the dataset. */ *************** *** 310,324 **** Source src = getSource( dsName ); ! if( consolFun.equalsIgnoreCase("MAX") ) return src.getAggregate( Source.AGG_MAXIMUM ); ! else if ( consolFun.equalsIgnoreCase("MIN") ) return src.getAggregate( Source.AGG_MINIMUM ); ! else if ( consolFun.equalsIgnoreCase("LAST") ) return src.getAggregate( Source.AGG_LAST); ! else if ( consolFun.equalsIgnoreCase("FIRST") ) return src.getAggregate( Source.AGG_FIRST ); ! else if ( consolFun.equalsIgnoreCase("TOTAL") ) return src.getAggregate( Source.AGG_TOTAL ); ! else if ( consolFun.equalsIgnoreCase("AVERAGE") ) return src.getAggregate( Source.AGG_AVERAGE ); else --- 314,328 ---- Source src = getSource( dsName ); ! if( consolFun.equalsIgnoreCase(CF_MAX) ) return src.getAggregate( Source.AGG_MAXIMUM ); ! else if ( consolFun.equalsIgnoreCase(CF_MIN) ) return src.getAggregate( Source.AGG_MINIMUM ); ! else if ( consolFun.equalsIgnoreCase(CF_LAST) ) return src.getAggregate( Source.AGG_LAST); ! else if ( consolFun.equalsIgnoreCase(CF_FIRST) ) return src.getAggregate( Source.AGG_FIRST ); ! else if ( consolFun.equalsIgnoreCase(CF_TOTAL) ) return src.getAggregate( Source.AGG_TOTAL ); ! else if ( consolFun.equalsIgnoreCase(CF_AVERAGE) ) return src.getAggregate( Source.AGG_AVERAGE ); else *************** *** 342,346 **** * @param sourceName Source name * @param consolFun Consolidation function to be used for calculation ("AVERAGE", ! * "MIN", "MAX", "LAST" or "TOTAL" (since 1.3.1) * @param format Format string. For example: "speed is @5.2 @sbits/sec@c", * "temperature = @0 degrees" --- 346,351 ---- * @param sourceName Source name * @param consolFun Consolidation function to be used for calculation ("AVERAGE", ! * "MIN", "MAX", "LAST" or "TOTAL" (since 1.3.1) - These constants are conveniently ! * defined in the {@link org.jrobin.core.ConsolFuns ConsolFuns} class. * @param format Format string. For example: "speed is @5.2 @sbits/sec@c", * "temperature = @0 degrees" *************** *** 367,371 **** * @param sourceName Source name * @param consolFun Consolidation function to be used for calculation ("AVERAGE", ! * "MIN", "MAX", "LAST" or "TOTAL" (since 1.3.1) * @param format Format string. For example: "speed is @5.2 @sbits/sec@c", * "temperature = @0 degrees" --- 372,377 ---- * @param sourceName Source name * @param consolFun Consolidation function to be used for calculation ("AVERAGE", ! * "MIN", "MAX", "LAST" or "TOTAL" (since 1.3.1) - These constants are conveniently ! * defined in the {@link org.jrobin.core.ConsolFuns ConsolFuns} class. * @param format Format string. For example: "speed is @5.2 @sbits/sec@c", * "temperature = @0 degrees" Index: FetchSource.java =================================================================== RCS file: /cvsroot/jrobin/src/org/jrobin/graph/FetchSource.java,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** FetchSource.java 25 Jul 2004 12:28:49 -0000 1.10 --- FetchSource.java 21 Sep 2004 08:42:10 -0000 1.11 *************** *** 39,43 **** * @author Arne Vandamme (cob...@jr...) */ ! class FetchSource { // ================================================================ --- 39,43 ---- * @author Arne Vandamme (cob...@jr...) */ ! class FetchSource implements ConsolFuns { // ================================================================ *************** *** 50,54 **** protected static final int MAX_CF = 4; ! protected static final String[] cfNames = new String[] { "AVERAGE", "MAX", "MIN", "LAST" }; private RrdDb rrd; --- 50,56 ---- protected static final int MAX_CF = 4; ! protected static final String[] cfNames = new String[] { ! CF_AVERAGE, CF_MAX, CF_MIN, CF_LAST ! }; private RrdDb rrd; *************** *** 131,141 **** protected void addSource( String consolFunc, String dsName, String name ) throws RrdException { ! if ( consolFunc.equalsIgnoreCase("AVERAGE") || consolFunc.equalsIgnoreCase("AVG") ) datasources[AVG].add( new String[] { dsName, name } ); ! else if ( consolFunc.equalsIgnoreCase("MAX") || consolFunc.equalsIgnoreCase("MAXIMUM") ) datasources[MAX].add( new String[] { dsName, name } ); ! else if ( consolFunc.equalsIgnoreCase("MIN") || consolFunc.equalsIgnoreCase("MINIMUM") ) datasources[MIN].add( new String[] { dsName, name } ); ! else if ( consolFunc.equalsIgnoreCase("LAST") ) datasources[LAST].add( new String[] { dsName, name } ); else --- 133,143 ---- protected void addSource( String consolFunc, String dsName, String name ) throws RrdException { ! if ( consolFunc.equalsIgnoreCase(CF_AVERAGE) || consolFunc.equalsIgnoreCase("AVG") ) datasources[AVG].add( new String[] { dsName, name } ); ! else if ( consolFunc.equalsIgnoreCase(CF_MAX) || consolFunc.equalsIgnoreCase("MAXIMUM") ) datasources[MAX].add( new String[] { dsName, name } ); ! else if ( consolFunc.equalsIgnoreCase(CF_MIN) || consolFunc.equalsIgnoreCase("MINIMUM") ) datasources[MIN].add( new String[] { dsName, name } ); ! else if ( consolFunc.equalsIgnoreCase(CF_LAST) ) datasources[LAST].add( new String[] { dsName, name } ); else Index: Gprint.java =================================================================== RCS file: /cvsroot/jrobin/src/org/jrobin/graph/Gprint.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** Gprint.java 11 Jul 2004 22:04:13 -0000 1.7 --- Gprint.java 21 Sep 2004 08:42:10 -0000 1.8 *************** *** 32,35 **** --- 32,36 ---- import org.jrobin.core.RrdException; import org.jrobin.core.XmlWriter; + import org.jrobin.core.ConsolFuns; /** *************** *** 39,43 **** * @author Sasa Markovic (sa...@jr...) */ ! class Gprint extends Comment { // ================================================================ --- 40,44 ---- * @author Sasa Markovic (sa...@jr...) */ ! class Gprint extends Comment implements ConsolFuns { // ================================================================ *************** *** 66,71 **** * Constructs a Gprint object based on a string of text (with a specific placement * marker in), a source from which to retrieve a value, and a consolidation function that ! * specifies which value to retrieve. Possible consolidation functions are <code>AVERAGE, MAX, MIN, FIRST, LAST</code> ! * and <code>TOTAL</code>. * @param sourceName Name of the datasource from which to retrieve the consolidated value. * @param consolFunc Consolidation function to use. --- 67,74 ---- * Constructs a Gprint object based on a string of text (with a specific placement * marker in), a source from which to retrieve a value, and a consolidation function that ! * specifies which value to retrieve. Possible consolidation functions are ! * <code>"AVERAGE", "MAX", "MIN", "FIRST", "LAST"</code> ! * and <code>"TOTAL"</code> - these string constants are conveniently defined ! * in the {@link org.jrobin.core.ConsolFuns ConsolFuns} class. * @param sourceName Name of the datasource from which to retrieve the consolidated value. * @param consolFunc Consolidation function to use. *************** *** 82,96 **** this.sourceName = sourceName; ! if ( consolFunc.equalsIgnoreCase("AVERAGE") || consolFunc.equalsIgnoreCase("AVG") ) aggregate = Source.AGG_AVERAGE; ! else if ( consolFunc.equalsIgnoreCase("MAX") || consolFunc.equalsIgnoreCase("MAXIMUM") ) aggregate = Source.AGG_MAXIMUM; ! else if ( consolFunc.equalsIgnoreCase("MIN") || consolFunc.equalsIgnoreCase("MINIMUM") ) aggregate = Source.AGG_MINIMUM; ! else if ( consolFunc.equalsIgnoreCase("LAST") ) aggregate = Source.AGG_LAST; ! else if ( consolFunc.equalsIgnoreCase("FIRST") ) aggregate = Source.AGG_FIRST; ! else if ( consolFunc.equalsIgnoreCase("TOTAL") ) aggregate = Source.AGG_TOTAL; else --- 85,99 ---- this.sourceName = sourceName; ! if ( consolFunc.equalsIgnoreCase(CF_AVERAGE) || consolFunc.equalsIgnoreCase("AVG") ) aggregate = Source.AGG_AVERAGE; ! else if ( consolFunc.equalsIgnoreCase(CF_MAX) || consolFunc.equalsIgnoreCase("MAXIMUM") ) aggregate = Source.AGG_MAXIMUM; ! else if ( consolFunc.equalsIgnoreCase(CF_MIN) || consolFunc.equalsIgnoreCase("MINIMUM") ) aggregate = Source.AGG_MINIMUM; ! else if ( consolFunc.equalsIgnoreCase(CF_LAST) ) aggregate = Source.AGG_LAST; ! else if ( consolFunc.equalsIgnoreCase(CF_FIRST) ) aggregate = Source.AGG_FIRST; ! else if ( consolFunc.equalsIgnoreCase(CF_TOTAL) ) aggregate = Source.AGG_TOTAL; else Index: RrdGraphDef.java =================================================================== RCS file: /cvsroot/jrobin/src/org/jrobin/graph/RrdGraphDef.java,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** RrdGraphDef.java 11 Jul 2004 22:04:13 -0000 1.19 --- RrdGraphDef.java 21 Sep 2004 08:42:10 -0000 1.20 *************** *** 907,911 **** * @param sourceName Graph source name * @param consolFun Consolidation function to be used for calculation ("AVERAGE", ! * "MIN", "MAX", "LAST" or "TOTAL" (since 1.3.1) * @param format Format string. For example: "speed is @5.2 @sbits/sec@c", * "temperature = @0 degrees" --- 907,912 ---- * @param sourceName Graph source name * @param consolFun Consolidation function to be used for calculation ("AVERAGE", ! * "MIN", "MAX", "LAST" or "TOTAL" (since 1.3.1) - these string constants are conveniently ! * defined in the {@link org.jrobin.core.ConsolFuns ConsolFuns} class. * @param format Format string. For example: "speed is @5.2 @sbits/sec@c", * "temperature = @0 degrees" *************** *** 926,930 **** * @param sourceName Graph source name * @param consolFun Consolidation function to be used for calculation ("AVERAGE", "MIN", "MAX", "LAST" ! * or "TOTAL" (since 1.3.1) * @param format Format string. For example: "speed is @5.2 @sbits/sec@c", "temperature = @0 degrees" * @param base Base value for the formatting, defaults to the graphing base value --- 927,932 ---- * @param sourceName Graph source name * @param consolFun Consolidation function to be used for calculation ("AVERAGE", "MIN", "MAX", "LAST" ! * or "TOTAL" (since 1.3.1) - these string constants are conveniently defined ! * in the {@link org.jrobin.core.ConsolFuns ConsolFuns} class. * @param format Format string. For example: "speed is @5.2 @sbits/sec@c", "temperature = @0 degrees" * @param base Base value for the formatting, defaults to the graphing base value |