|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.util.AbstractCollection<E>
java.util.AbstractList<E>
java.util.Vector
simtools.data.DataSourceCollection
simtools.data.AsciiFileDataSourceCollection
public class AsciiFileDataSourceCollection
A DataSourceCollection backed up by an ascii file containing the data source values. It could be a good idea to wrap a buffer around the collection, or around each individual source. The file is expected to be in the following format: on each line, there should be as many values as managed data sources The values may be integer (octal haxadecimal are OK) or floating point, and the maximum precision will be kept. For example, a 64-bit hexadecimal mask would be stored in a Long object.
Nested Class Summary | |
---|---|
class |
AsciiFileDataSourceCollection.InvalidFormatException
|
Nested classes/interfaces inherited from class simtools.data.DataSourceCollection |
---|
DataSourceCollection.Container |
Field Summary | |
---|---|
protected java.lang.String |
absoluteFileName
|
protected java.lang.Object[] |
cachedEntry
|
protected long |
cachedIndex
|
protected java.lang.String |
charsetName
|
protected boolean |
csv
|
protected long |
currentIndex
|
static java.text.SimpleDateFormat |
dateFormat
|
static int |
DEFAULT_GRANULARITY
|
protected java.io.RandomAccessFile |
file
|
protected java.lang.String |
fileName
|
protected int |
granularity
|
static java.lang.String |
ID_MARKER
|
protected java.util.Vector |
indexOffset
|
protected DataInfo[] |
info
|
static java.text.SimpleDateFormat |
longTimeFormat
|
protected java.lang.Object[] |
max
|
protected long |
maxReachedIndex
|
protected java.lang.Object[] |
min
|
protected DataInfo |
ourInfo
|
static java.text.SimpleDateFormat |
shortTimeFormat
|
protected long |
sliceEnd
|
protected int |
subsampling
Subsampling allows to drop values in big files. |
Fields inherited from class simtools.data.DataSourceCollection |
---|
buffers, endNotificationListeners, lastIndex, listeners, map, startIndex |
Fields inherited from class java.util.Vector |
---|
capacityIncrement, elementCount, elementData |
Fields inherited from class java.util.AbstractList |
---|
modCount |
Constructor Summary | |
---|---|
AsciiFileDataSourceCollection(java.io.File f,
boolean csv)
|
|
AsciiFileDataSourceCollection(java.io.File f,
int subsampling,
boolean csv)
|
|
AsciiFileDataSourceCollection(java.io.File f,
int subsampling,
int desiredGranularity,
boolean csv)
|
|
AsciiFileDataSourceCollection(java.io.File f,
int subsampling,
int desiredGranularity,
java.lang.String charsetName,
boolean csv)
|
|
AsciiFileDataSourceCollection(java.io.File f,
int subsampling,
java.lang.String charsetName,
boolean csv)
|
|
AsciiFileDataSourceCollection(java.io.File f,
java.lang.String charsetName,
boolean csv)
|
Method Summary | |
---|---|
long |
computeLastIndex()
|
java.lang.Object |
computeMax(int i)
|
java.lang.Object |
computeMin(int i)
|
protected java.lang.String |
convertToCharset(java.lang.String arg)
|
java.lang.String |
getCharsetName()
|
int |
getGranularity()
get without an equivalent set: not possibly to change the granularity dynamically (do it yourself in subclass!!!) |
DataInfo |
getInformation()
|
DataInfo |
getInformation(int i)
|
java.lang.Object |
getMax(int i)
|
protected java.lang.Object |
getMax(java.lang.Object o1,
java.lang.Object o2)
Returns the maximum of the 2 objects |
java.lang.Object |
getMin(int i)
|
protected java.lang.Object |
getMin(java.lang.Object o1,
java.lang.Object o2)
Returns the minimum of the 2 objects |
int |
getSubsampling()
|
java.lang.Object |
getValue(int i,
long index)
Function to get value does some buffer/cache handling job and should not be overloaded. |
java.lang.Object[] |
getValueArray(long index)
|
java.lang.Object[] |
readFile()
|
java.lang.Object[] |
readFile(boolean parse)
Reads a line from the ascii file, and split tokens to read double values. |
java.lang.String |
readLineIgnoreComment()
|
void |
setCharsetName(java.lang.String charsetName)
Specify a charset for this file. |
void |
setSlice(long min,
long max)
|
void |
setSubsampling(int subsampling)
|
static java.lang.Number |
stringToDateNumber(java.lang.String v)
|
static java.lang.Number |
stringToTimeNumber(java.lang.String v)
|
java.lang.Class |
valueClass(int i)
Returns the more specialized superclass of all objects returned by the i-th data source. |
Methods inherited from class java.util.Vector |
---|
add, add, addAll, addAll, addElement, capacity, clear, clone, contains, containsAll, copyInto, elementAt, elements, ensureCapacity, equals, firstElement, get, indexOf, indexOf, insertElementAt, isEmpty, lastElement, lastIndexOf, lastIndexOf, remove, remove, removeAll, removeElement, removeElementAt, removeRange, retainAll, set, setElementAt, setSize, size, subList, toArray, toArray, toString, trimToSize |
Methods inherited from class java.util.AbstractList |
---|
iterator, listIterator, listIterator |
Methods inherited from class java.lang.Object |
---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
Methods inherited from interface java.util.List |
---|
iterator, listIterator, listIterator |
Field Detail |
---|
protected DataInfo[] info
protected java.lang.Object[] min
protected java.lang.Object[] max
protected java.lang.Object[] cachedEntry
protected long cachedIndex
protected java.lang.String charsetName
protected int subsampling
public static final int DEFAULT_GRANULARITY
protected int granularity
protected transient java.util.Vector indexOffset
protected transient java.io.RandomAccessFile file
protected transient java.lang.String fileName
protected transient java.lang.String absoluteFileName
protected transient long currentIndex
protected transient long maxReachedIndex
protected final boolean csv
public static java.text.SimpleDateFormat longTimeFormat
public static java.text.SimpleDateFormat shortTimeFormat
public static java.text.SimpleDateFormat dateFormat
public static final java.lang.String ID_MARKER
protected DataInfo ourInfo
protected long sliceEnd
Constructor Detail |
---|
public AsciiFileDataSourceCollection(java.io.File f, boolean csv) throws java.io.IOException, AsciiFileDataSourceCollection.InvalidFormatException
java.io.IOException
AsciiFileDataSourceCollection.InvalidFormatException
public AsciiFileDataSourceCollection(java.io.File f, java.lang.String charsetName, boolean csv) throws java.io.IOException, AsciiFileDataSourceCollection.InvalidFormatException
java.io.IOException
AsciiFileDataSourceCollection.InvalidFormatException
public AsciiFileDataSourceCollection(java.io.File f, int subsampling, boolean csv) throws java.io.IOException, AsciiFileDataSourceCollection.InvalidFormatException
java.io.IOException
AsciiFileDataSourceCollection.InvalidFormatException
public AsciiFileDataSourceCollection(java.io.File f, int subsampling, java.lang.String charsetName, boolean csv) throws java.io.IOException, AsciiFileDataSourceCollection.InvalidFormatException
java.io.IOException
AsciiFileDataSourceCollection.InvalidFormatException
public AsciiFileDataSourceCollection(java.io.File f, int subsampling, int desiredGranularity, boolean csv) throws java.io.IOException, AsciiFileDataSourceCollection.InvalidFormatException
java.io.IOException
AsciiFileDataSourceCollection.InvalidFormatException
public AsciiFileDataSourceCollection(java.io.File f, int subsampling, int desiredGranularity, java.lang.String charsetName, boolean csv) throws java.io.IOException, AsciiFileDataSourceCollection.InvalidFormatException
java.io.IOException
AsciiFileDataSourceCollection.InvalidFormatException
Method Detail |
---|
public java.lang.String getCharsetName()
public void setCharsetName(java.lang.String charsetName)
charsetName
- The charsetName to set. May be null for direct reading.public static java.lang.Number stringToTimeNumber(java.lang.String v)
public static java.lang.Number stringToDateNumber(java.lang.String v)
public DataInfo getInformation(int i)
getInformation
in class DataSourceCollection
public int getGranularity()
public int getSubsampling()
public void setSubsampling(int subsampling)
subsampling
- public DataInfo getInformation()
getInformation
in class DataSourceCollection
public java.lang.Object getMin(int i) throws UnsupportedOperation
getMin
in class DataSourceCollection
UnsupportedOperation
public java.lang.Object getMax(int i) throws UnsupportedOperation
getMax
in class DataSourceCollection
UnsupportedOperation
public void setSlice(long min, long max)
setSlice
in class DataSourceCollection
public java.lang.Object getValue(int i, long index) throws DataException
getValue
in class DataSourceCollection
DataException
public java.lang.Object computeMin(int i) throws UnsupportedOperation
computeMin
in class DataSourceCollection
UnsupportedOperation
public java.lang.Object computeMax(int i) throws UnsupportedOperation
computeMax
in class DataSourceCollection
UnsupportedOperation
public long computeLastIndex() throws UnsupportedOperation
computeLastIndex
in class DataSourceCollection
UnsupportedOperation
public java.lang.String readLineIgnoreComment() throws java.io.IOException
java.io.IOException
protected java.lang.String convertToCharset(java.lang.String arg) throws java.io.IOException
java.io.IOException
public java.lang.Object[] readFile(boolean parse) throws NoSuchIndex, DataException
parse
- If the values should be parsed or if they could be skipped
Since this function has been called on each line when
reaching EOF, it's possible to omit computations of min/max
once we've done it once.
NoSuchIndex
DataException
protected java.lang.Object getMax(java.lang.Object o1, java.lang.Object o2) throws java.lang.ClassCastException
o1.
- Must be of type Long or Doubleo2.
- Must be of type Long or Double
java.lang.ClassCastException
protected java.lang.Object getMin(java.lang.Object o1, java.lang.Object o2)
o1.
- Must be of type Long or Doubleo2.
- Must be of type Long or Double
public java.lang.Object[] readFile() throws NoSuchIndex, DataException
NoSuchIndex
DataException
public java.lang.Object[] getValueArray(long index) throws DataException
DataException
public java.lang.Class valueClass(int i)
DataSourceCollection
valueClass
in class DataSourceCollection
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |