org.deegree_impl.io.mapinfo
Class MapInfoDataSource

java.lang.Object
  extended byorg.deegree_impl.io.mapinfo.MapInfoDataSource

public class MapInfoDataSource
extends java.lang.Object

Version:
$Revision: 1.8 $
Author:
$author$

Field Summary
static java.lang.String CLAUSE_BRUSH
           
static java.lang.String CLAUSE_CENTER
           
static java.lang.String CLAUSE_CHARSET
           
static java.lang.String CLAUSE_COLUMNS
           
static java.lang.String CLAUSE_DELIMETER
           
static java.lang.String CLAUSE_INDEX
           
static java.lang.String CLAUSE_PEN
           
static java.lang.String CLAUSE_SMOOTH
           
static java.lang.String CLAUSE_SYMBOL
           
static java.lang.String CLAUSE_UNIQUE
           
static java.lang.String CLAUSE_VERSION
           
private  java.lang.String filename
           
private  GeometryFactory geomFactory
           
private  java.lang.String hCharset
           
private  java.util.ArrayList hColumnsNames
           
private  java.util.ArrayList hColumnsTypes
           
private  java.lang.String hDelimeter
           
private  java.util.ArrayList hIndex
           
private  java.util.ArrayList hUnique
           
private  java.lang.String hVersion
           
private  java.lang.String line
           
private  FeatureType lineType
           
private  FeatureType pointType
           
private  FeatureType polygonType
           
static java.lang.String TYPE_ARC
           
static java.lang.String TYPE_ELLIPSE
           
static java.lang.String TYPE_LINE
           
static java.lang.String TYPE_NONE
           
static java.lang.String TYPE_PLINE
           
static java.lang.String TYPE_POINT
           
static java.lang.String TYPE_RECT
           
static java.lang.String TYPE_REGION
           
static java.lang.String TYPE_ROUNDRECT
           
static java.lang.String TYPE_TEXT
           
 
Constructor Summary
MapInfoDataSource(java.net.URL url)
          Creates a new MapInfoDataSource object.
 
Method Summary
private  void addAttribute(java.lang.String type, java.lang.String token, java.util.ArrayList midValues)
           
private  Feature buildFeature(FeatureType featureType, Geometry geom, java.util.ArrayList attribs)
          Builds a complete Feature object using the given FeatureType, with the Geometry geom, and the given attributes.
private  java.lang.String clause(java.lang.String line)
          A 'Clause' is stored as a single string at the start of a line.
private  java.lang.String clause(java.lang.String line, char delimiter)
           
 void getFeatures(FeatureCollection collection, WFSQuery query)
          Loads features from the datasource into the passed collection, based on the passed filter.
 FeatureType getSchema()
          Retrieves the featureType that features extracted from this datasource will be created with.
private  boolean isShadingClause(java.lang.String line)
          Test whether the given line contains a known shading clause keyword (PEN, STYLE, etc.)
private  Feature readLineObject(java.io.BufferedReader mifReader, java.io.BufferedReader midReader)
          Reads Line information from the MIF stream
private  java.util.ArrayList readMid(java.io.BufferedReader midReader)
          Reads a single line of the given MID file stream, and returns a hashtable of the data in it, keyed byt he keys in the hColumns hash
private  void readMifHeader(java.io.BufferedReader mifReader)
          Reads the header from the given MIF file stream
private  java.lang.String readMifLine(java.io.BufferedReader reader)
          Reads the next line in the reader, ignoring lines which are nothing but whitespace.
protected  java.util.ArrayList readMifMid()
          Reads the MIF and MID files and returns a ArrayList of the Features they contain
private  java.util.ArrayList readMifMid(java.io.BufferedReader mifReader, java.io.BufferedReader midReader)
          Reads an entire MID/MIF file.
private  Feature readObject(java.io.BufferedReader mifReader, java.io.BufferedReader midReader)
          Reads a single MIF Object (Point, Line, Region, etc.) as a Feature
private  Feature readPLineObject(java.io.BufferedReader mifReader, java.io.BufferedReader midReader)
          Reads Multi-Line (PLine) information from the MIF stream
private  Feature readPointObject(java.io.BufferedReader mifReader, java.io.BufferedReader midReader)
          Reads Point information from the MIF stream
private  Feature readRegionObject(java.io.BufferedReader mifReader, java.io.BufferedReader midReader)
          Reads Region (Polygon) information from the MIF stream
private  java.lang.String remainder(java.lang.String line)
          returns the last word of the string
private  java.lang.String remainder(java.lang.String line, char delimiter)
           
private  java.lang.String setExtension(java.lang.String filename, java.lang.String ext)
           
private  void setUpFactories()
          This private method constructs the factories used to create the Feature, and Geometries as they are read It takes it's setup values from the value of the COLUMNS clause in the MIF file
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

TYPE_NONE

public static final java.lang.String TYPE_NONE
See Also:
Constant Field Values

TYPE_POINT

public static final java.lang.String TYPE_POINT
See Also:
Constant Field Values

TYPE_LINE

public static final java.lang.String TYPE_LINE
See Also:
Constant Field Values

TYPE_PLINE

public static final java.lang.String TYPE_PLINE
See Also:
Constant Field Values

TYPE_REGION

public static final java.lang.String TYPE_REGION
See Also:
Constant Field Values

TYPE_ARC

public static final java.lang.String TYPE_ARC
See Also:
Constant Field Values

TYPE_TEXT

public static final java.lang.String TYPE_TEXT
See Also:
Constant Field Values

TYPE_RECT

public static final java.lang.String TYPE_RECT
See Also:
Constant Field Values

TYPE_ROUNDRECT

public static final java.lang.String TYPE_ROUNDRECT
See Also:
Constant Field Values

TYPE_ELLIPSE

public static final java.lang.String TYPE_ELLIPSE
See Also:
Constant Field Values

CLAUSE_SYMBOL

public static final java.lang.String CLAUSE_SYMBOL
See Also:
Constant Field Values

CLAUSE_PEN

public static final java.lang.String CLAUSE_PEN
See Also:
Constant Field Values

CLAUSE_SMOOTH

public static final java.lang.String CLAUSE_SMOOTH
See Also:
Constant Field Values

CLAUSE_CENTER

public static final java.lang.String CLAUSE_CENTER
See Also:
Constant Field Values

CLAUSE_BRUSH

public static final java.lang.String CLAUSE_BRUSH
See Also:
Constant Field Values

CLAUSE_VERSION

public static final java.lang.String CLAUSE_VERSION
See Also:
Constant Field Values

CLAUSE_CHARSET

public static final java.lang.String CLAUSE_CHARSET
See Also:
Constant Field Values

CLAUSE_DELIMETER

public static final java.lang.String CLAUSE_DELIMETER
See Also:
Constant Field Values

CLAUSE_UNIQUE

public static final java.lang.String CLAUSE_UNIQUE
See Also:
Constant Field Values

CLAUSE_INDEX

public static final java.lang.String CLAUSE_INDEX
See Also:
Constant Field Values

CLAUSE_COLUMNS

public static final java.lang.String CLAUSE_COLUMNS
See Also:
Constant Field Values

hColumnsNames

private java.util.ArrayList hColumnsNames

hColumnsTypes

private java.util.ArrayList hColumnsTypes

hIndex

private java.util.ArrayList hIndex

hUnique

private java.util.ArrayList hUnique

lineType

private FeatureType lineType

pointType

private FeatureType pointType

polygonType

private FeatureType polygonType

geomFactory

private GeometryFactory geomFactory

filename

private java.lang.String filename

hCharset

private java.lang.String hCharset

hDelimeter

private java.lang.String hDelimeter

hVersion

private java.lang.String hVersion

line

private java.lang.String line
Constructor Detail

MapInfoDataSource

public MapInfoDataSource(java.net.URL url)
                  throws java.net.MalformedURLException
Creates a new MapInfoDataSource object.

Parameters:
url -
Throws:
java.net.MalformedURLException
Method Detail

readMifMid

protected java.util.ArrayList readMifMid()
                                  throws java.lang.Exception
Reads the MIF and MID files and returns a ArrayList of the Features they contain

Returns:
a ArrayList of features?
Throws:
java.lang.Exception - if file doesn't exist or is not readable etc

setExtension

private java.lang.String setExtension(java.lang.String filename,
                                      java.lang.String ext)
Parameters:
filename -
ext -
Returns:

setUpFactories

private void setUpFactories()
                     throws java.lang.Exception
This private method constructs the factories used to create the Feature, and Geometries as they are read It takes it's setup values from the value of the COLUMNS clause in the MIF file

Throws:
java.lang.Exception

readMifMid

private java.util.ArrayList readMifMid(java.io.BufferedReader mifReader,
                                       java.io.BufferedReader midReader)
                                throws java.lang.Exception
Reads an entire MID/MIF file. (Two files, actually, separately opened)

Parameters:
mifReader - An opened BufferedReader to the MIF file.
midReader - An opened BufferedReader to the MID file.
Returns:
Throws:
java.lang.Exception

readMifHeader

private void readMifHeader(java.io.BufferedReader mifReader)
                    throws java.lang.Exception
Reads the header from the given MIF file stream

Parameters:
mifReader -
Throws:
java.lang.Exception

clause

private java.lang.String clause(java.lang.String line)
A 'Clause' is stored as a single string at the start of a line. This rips the clause name out of the given line.

Parameters:
line -
Returns:

clause

private java.lang.String clause(java.lang.String line,
                                char delimiter)
Parameters:
line -
delimiter -
Returns:

remainder

private java.lang.String remainder(java.lang.String line)
returns the last word of the string

Parameters:
line -
Returns:

remainder

private java.lang.String remainder(java.lang.String line,
                                   char delimiter)
Parameters:
line -
delimiter -
Returns:

readMifLine

private java.lang.String readMifLine(java.io.BufferedReader reader)
                              throws java.io.IOException,
                                     java.lang.Exception
Reads the next line in the reader, ignoring lines which are nothing but whitespace. Sets the global 'line' variable to the currently read line

Parameters:
reader -
Returns:
Throws:
java.io.IOException
java.lang.Exception

readObject

private Feature readObject(java.io.BufferedReader mifReader,
                           java.io.BufferedReader midReader)
                    throws java.lang.Exception
Reads a single MIF Object (Point, Line, Region, etc.) as a Feature

Parameters:
mifReader -
midReader -
Returns:
Throws:
java.lang.Exception

readPointObject

private Feature readPointObject(java.io.BufferedReader mifReader,
                                java.io.BufferedReader midReader)
                         throws java.lang.Exception
Reads Point information from the MIF stream

Parameters:
mifReader -
midReader -
Returns:
Throws:
java.lang.Exception

readLineObject

private Feature readLineObject(java.io.BufferedReader mifReader,
                               java.io.BufferedReader midReader)
                        throws java.lang.Exception
Reads Line information from the MIF stream

Parameters:
mifReader -
midReader -
Returns:
Throws:
java.lang.Exception

readPLineObject

private Feature readPLineObject(java.io.BufferedReader mifReader,
                                java.io.BufferedReader midReader)
                         throws java.lang.Exception
Reads Multi-Line (PLine) information from the MIF stream

Parameters:
mifReader -
midReader -
Returns:
Throws:
java.lang.Exception

readRegionObject

private Feature readRegionObject(java.io.BufferedReader mifReader,
                                 java.io.BufferedReader midReader)
                          throws java.lang.Exception
Reads Region (Polygon) information from the MIF stream

Parameters:
mifReader -
midReader -
Returns:
Throws:
java.lang.Exception

buildFeature

private Feature buildFeature(FeatureType featureType,
                             Geometry geom,
                             java.util.ArrayList attribs)
                      throws java.lang.Exception
Builds a complete Feature object using the given FeatureType, with the Geometry geom, and the given attributes.

Parameters:
featureType - The FeatureType to use to constuct the Feature
geom - The Geometry to use as the default Geometry
attribs - The attibutes to use as the Feature's attributes (Attributes must be set up in the FeatureType)
Returns:
A fully-formed Feature
Throws:
java.lang.Exception

readMid

private java.util.ArrayList readMid(java.io.BufferedReader midReader)
                             throws java.lang.Exception
Reads a single line of the given MID file stream, and returns a hashtable of the data in it, keyed byt he keys in the hColumns hash

Parameters:
midReader -
Returns:
Throws:
java.lang.Exception

addAttribute

private void addAttribute(java.lang.String type,
                          java.lang.String token,
                          java.util.ArrayList midValues)
Parameters:
type -
token -
midValues -

isShadingClause

private boolean isShadingClause(java.lang.String line)
Test whether the given line contains a known shading clause keyword (PEN, STYLE, etc.)

Parameters:
line -
Returns:

getFeatures

public void getFeatures(FeatureCollection collection,
                        WFSQuery query)
                 throws java.lang.Exception
Loads features from the datasource into the passed collection, based on the passed filter. Note that all data sources must support this method at a minimum.

Parameters:
collection - The collection to put the features into.
query - contains info about request of which features to retrieve.
Throws:
java.lang.Exception - For all data source errors.

getSchema

public FeatureType getSchema()
Retrieves the featureType that features extracted from this datasource will be created with.