org.deegree_impl.io.bnaapi
Class BNAFile

java.lang.Object
  extended byorg.deegree_impl.io.bnaapi.BNAFile

public class BNAFile
extends java.lang.Object

Class representing a BNA File. Provides methods to load and parse a file in BNA format. Data are returned as a BNAFeatureSet

Version:
2003.08.04
Author:
Emanuele Tajariol

Field Summary
private  BNAFeatureSet _fs
          The featureSet collected from the file.
 
Constructor Summary
BNAFile(java.lang.String url)
          Construct a MainFile from a file name.
 
Method Summary
 BNAFeatureSet getFeatureSet()
           
private  java.lang.String[] getHeaderByQuote(java.lang.String header)
          Search for quote-delimited headers We are looking for a header with this format: "name1", "name2", ... , numpoints The split array will be something like this: 0 1 2 3 4 len-1 "A","B",...
private  java.lang.String[] getHeaderBySpace(java.lang.String header)
          Search for space-delimited headers We are looking for a header with this format: name1 TAB name2 TAB ...
private  java.lang.String[] getHeaderByTab(java.lang.String header)
          Search for tab-delimited headers We are looking for a header with this format: name1 TAB name2 TAB ...
private  void loadFile(java.io.RandomAccessFile raf)
          Parses a BNA file.
static void main(java.lang.String[] args)
          Just for some debug
private  BNAGeometry readGeometry(java.io.RandomAccessFile raf, int n)
          Reads n points from a file.
private  boolean skippable(java.io.RandomAccessFile raf)
          Checks if remaining chars can be skipped.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_fs

private BNAFeatureSet _fs
The featureSet collected from the file.

Constructor Detail

BNAFile

public BNAFile(java.lang.String url)
        throws java.io.IOException
Construct a MainFile from a file name.

Method Detail

loadFile

private void loadFile(java.io.RandomAccessFile raf)
               throws java.io.IOException
Parses a BNA file. TODO: improve parser.

Parameters:
raf - a RandomAccessFile
Throws:
java.io.IOException

getHeaderByQuote

private java.lang.String[] getHeaderByQuote(java.lang.String header)
                                     throws java.io.IOException
Search for quote-delimited headers We are looking for a header with this format: "name1", "name2", ... , numpoints The split array will be something like this: 0 1 2 3 4 len-1 "A","B",...,n => null / A / , / B / , / ... / , / n

Parameters:
header - The header to be parsed
Returns:
a String[] with the parsed headers (last element in array will be the numpoints) or null if the header is not parsable by quotes.
Throws:
java.io.IOException

getHeaderByTab

private java.lang.String[] getHeaderByTab(java.lang.String header)
                                   throws java.io.IOException
Search for tab-delimited headers We are looking for a header with this format: name1 TAB name2 TAB ... TAB numpoints The split array will be something like this: 0 1 len-1 A / B / ... / n

Parameters:
header - The header to be parsed
Returns:
a String[] with the parsed headers (last element in array will be the numpoints) or null if the header is not parsable by tabs.
Throws:
java.io.IOException

getHeaderBySpace

private java.lang.String[] getHeaderBySpace(java.lang.String header)
                                     throws java.io.IOException
Search for space-delimited headers We are looking for a header with this format: name1 TAB name2 TAB ... TAB numpoints The split array will be something like this: 0 1 len-1 A / B / ... / n

Parameters:
header - The header to be parsed
Returns:
a String[] with the parsed headers (last element in array will be the numpoints) or null if the header is not parsable by tabs.
Throws:
java.io.IOException

skippable

private boolean skippable(java.io.RandomAccessFile raf)
                   throws java.io.IOException
Checks if remaining chars can be skipped.

Parameters:
raf - a RandomAccessFile
Returns:
a boolean
Throws:
java.io.IOException

readGeometry

private BNAGeometry readGeometry(java.io.RandomAccessFile raf,
                                 int n)
                          throws java.io.IOException
Reads n points from a file. This methods reads n line from file raf. In each line there's a pair of coords, comma- or tab-separated.

Parameters:
raf - The input file
n - Number of points (file lines) to be read
Returns:
a BNAGeometry built from the points read from the file.
Throws:
java.io.IOException

getFeatureSet

public BNAFeatureSet getFeatureSet()
Returns:

main

public static void main(java.lang.String[] args)
                 throws java.io.IOException
Just for some debug

Throws:
java.io.IOException