KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jrobin > core > RrdCacher


1 /* ============================================================
2  * JRobin : Pure java implementation of RRDTool's functionality
3  * ============================================================
4  *
5  * Project Info: http://www.jrobin.org
6  * Project Lead: Sasa Markovic (saxon@jrobin.org);
7  *
8  * (C) Copyright 2003, by Sasa Markovic.
9  *
10  * Developers: Sasa Markovic (saxon@jrobin.org)
11  * Arne Vandamme (cobralord@jrobin.org)
12  *
13  * This library is free software; you can redistribute it and/or modify it under the terms
14  * of the GNU Lesser General Public License as published by the Free Software Foundation;
15  * either version 2.1 of the License, or (at your option) any later version.
16  *
17  * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
18  * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
19  * See the GNU Lesser General Public License for more details.
20  *
21  * You should have received a copy of the GNU Lesser General Public License along with this
22  * library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
23  * Boston, MA 02111-1307, USA.
24  */

25
26 package org.jrobin.core;
27
28 final class RrdCacher {
29     private boolean cached = false;
30     private int i;
31     private long l;
32     private double d;
33     private String JavaDoc s;
34
35     final boolean setInt(int value) {
36         if (cached && value == i) {
37             return false;
38         }
39         else {
40             i = value;
41             return cached = true;
42         }
43     }
44
45     final boolean setLong(long value) {
46         if(cached && value == l) {
47             return false;
48         }
49         else {
50             l = value;
51             return cached = true;
52         }
53     }
54
55     final boolean setDouble(double value) {
56         if(cached && value == d) {
57             return false;
58         }
59         else {
60             d = value;
61             return cached = true;
62         }
63     }
64
65     final boolean setString(String JavaDoc value) {
66         if(cached && value.equals(s)) {
67             return false;
68         }
69         else {
70             s = value;
71             return cached = true;
72         }
73     }
74
75     final boolean isEmpty() {
76         return !cached;
77     }
78
79     final int getInt() {
80         return i;
81     }
82
83     final long getLong() {
84         return l;
85     }
86
87     final double getDouble() {
88         return d;
89     }
90
91     final String JavaDoc getString() {
92         return s;
93     }
94
95     final void clearCache() {
96         cached = false;
97     }
98
99 }
100
Popular Tags