View Javadoc

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-2005, by Sasa Markovic.
9    *
10   * Developers:    Sasa Markovic (saxon@jrobin.org)
11   *
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  import java.io.IOException;
29  
30  class RrdDoubleArray extends RrdPrimitive {
31  	private int length;
32  
33  	RrdDoubleArray(RrdUpdater updater, int length) throws IOException {
34  		super(updater, RrdPrimitive.RRD_DOUBLE, length, false);
35  		this.length = length;
36  	}
37  
38  	void set(int index, double value) throws IOException {
39  		set(index, value, 1);
40  	}
41  
42  	void set(int index, double value, int count) throws IOException {
43  		// rollovers not allowed!
44  		assert index + count <= length:	"Invalid robin index supplied: index=" + index +
45  				", count=" + count + ", length=" + length;
46  		writeDouble(index, value, count);
47  	}
48  
49  	double get(int index) throws IOException {
50  		assert index < length: "Invalid index supplied: " + index + ", length=" + length;
51  		return readDouble(index);
52  	}
53  
54  	double[] get(int index, int count) throws IOException {
55  		assert index + count <= length: "Invalid index/count supplied: " + index +
56  				"/" + count + " (length=" + length + ")";
57  		return readDouble(index, count);
58  	}
59  
60  }