com.oziexplorer
Class DataFile<T>

java.lang.Object
  extended by java.util.AbstractCollection<E>
      extended by java.util.AbstractList<E>
          extended by java.util.ArrayList<T>
              extended by com.oziexplorer.DataFile<T>
Type Parameters:
T - type of object the data file holds - Waypoints, Track points etc.
All Implemented Interfaces:
Serializable, Cloneable, Iterable<T>, Collection<T>, List<T>, RandomAccess
Direct Known Subclasses:
EventFile, PointFile, RouteFile, TrackFile, WaypointFile

public abstract class DataFile<T>
extends ArrayList<T>

Base class for OziExplorer datafile access classes - contains various utility routines that are common to all data file types.

See Also:
Serialized Form

Field Summary
protected static Charset C
          The character set used by the OziExplorer data files - assume the current Windows active code page is being used.
protected static Locale L
          The locale for the OziExploret data files (English).
protected static Pattern SepRE
          A pattern to match OziExplorer data file field separators.
protected static TimeZone T
          The timezone for the date/time values in the data files.
 
Fields inherited from class java.util.AbstractList
modCount
 
Constructor Summary
DataFile()
           
 
Method Summary
protected  double calendarToOziDate(Calendar cal)
          Convert a Java Calendar to an OziExplorer format date.
protected  String escapeCommas(String str)
          OziExplorer uses character 209(dec) to escape commas in data files.
protected  Calendar getDate(Scanner s)
          Get a date, or a default value (the current date).
protected  double getDouble(Scanner s, double defVal)
          Get a double, or a default value.
protected  int getInt(Scanner s, int defVal)
          Get an integer, or a default value.
protected  String getString(Scanner s)
          Get a string, or a default value (empty string).
protected  OziException newOziException(LineNumberReader in)
          Create a new exception containing the current line number in the input file, if possible.
protected  OziException newOziException(LineNumberReader in, Throwable e)
          Create a new exception containing the current line number in the input file, if possible and an nested exception.
protected  Scanner newScanner(String line)
          Trim any leading or trailing whitespace from the line and create a new Scanner to process it, assuming the standard OziExplorer comma separator and an English locale.
protected  Calendar oziDateToCalendar(double oziDate)
          Convert an OziExplorer format date into a Java Calendar object.
protected  void skipNext(Scanner s)
          If the next field exists, skip it.
protected  String unescapeCommas(String str)
          OziExplorer uses character 209(dec) to escape commas in data files.
 
Methods inherited from class java.util.ArrayList
add, add, addAll, addAll, clear, clone, contains, ensureCapacity, get, indexOf, isEmpty, lastIndexOf, remove, remove, removeRange, set, size, toArray, toArray, trimToSize
 
Methods inherited from class java.util.AbstractList
equals, hashCode, iterator, listIterator, listIterator, subList
 
Methods inherited from class java.util.AbstractCollection
containsAll, removeAll, retainAll, toString
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.List
containsAll, equals, hashCode, iterator, listIterator, listIterator, removeAll, retainAll, subList
 

Field Detail

SepRE

protected static final Pattern SepRE
A pattern to match OziExplorer data file field separators.


T

protected static final TimeZone T
The timezone for the date/time values in the data files. Assume UTC.


L

protected static final Locale L
The locale for the OziExploret data files (English).


C

protected static final Charset C
The character set used by the OziExplorer data files - assume the current Windows active code page is being used.

Constructor Detail

DataFile

public DataFile()
Method Detail

newScanner

protected Scanner newScanner(String line)
Trim any leading or trailing whitespace from the line and create a new Scanner to process it, assuming the standard OziExplorer comma separator and an English locale.

Parameters:
line - the line to be scanned.
Returns:
a Scanner to process the line.

getInt

protected int getInt(Scanner s,
                     int defVal)
Get an integer, or a default value.

Parameters:
s - the scanner to read from.
defVal - the default value.
Returns:
the next integer, or DEFVAL.

getDouble

protected double getDouble(Scanner s,
                           double defVal)
Get a double, or a default value.

Parameters:
s - the scanner to read from.
defVal -
Returns:
the next double, or DEFVAL.

getString

protected String getString(Scanner s)
Get a string, or a default value (empty string).

Parameters:
s - the scanner to read from.
Returns:
the next string, or an empty one.

getDate

protected Calendar getDate(Scanner s)
Get a date, or a default value (the current date).

Parameters:
s - the scanner to read from.
Returns:
the next date integer, or the current date.

skipNext

protected void skipNext(Scanner s)
If the next field exists, skip it.

Parameters:
s - the scanner to read from.

escapeCommas

protected String escapeCommas(String str)
OziExplorer uses character 209(dec) to escape commas in data files. Replace any occurences of comma with that character.

Parameters:
str - the string to escape.
Returns:
the escaped string.

unescapeCommas

protected String unescapeCommas(String str)
OziExplorer uses character 209(dec) to escape commas in data files. Replace any occurences of that character with comma.

Parameters:
str - the string to unescape.
Returns:
the unescaped string.

oziDateToCalendar

protected Calendar oziDateToCalendar(double oziDate)
Convert an OziExplorer format date into a Java Calendar object. Ozi dates are expressed as fractional days since midnight of 31/12/1899.

Parameters:
oziDate - the OziExplorer format date.
Returns:
the corresponding Calendar.

calendarToOziDate

protected double calendarToOziDate(Calendar cal)
Convert a Java Calendar to an OziExplorer format date. Ozi dates are expressed as fractional days since midnight of 31/12/1899.

Parameters:
cal - the Java Calendar format date.
Returns:
the corresponding Ozi format date.

newOziException

protected OziException newOziException(LineNumberReader in)
Create a new exception containing the current line number in the input file, if possible.

Parameters:
in - the LineNumberReader that is being used to read the file. May be null.
Returns:
the new exception.

newOziException

protected OziException newOziException(LineNumberReader in,
                                       Throwable e)
Create a new exception containing the current line number in the input file, if possible and an nested exception.

Parameters:
in - the LineNumberReader that is being used to read the file. May be null.
e - the nested exception.
Returns:
the new exception.