ilog.views.maps.format.shapefile
Class IlvDBFReader

java.lang.Object
  extended by ilog.views.maps.format.shapefile.IlvDBFReader

public class IlvDBFReader
extends Object

This class can be used to read Shapefiles with the .dbf extension. The .dbf files contain the attributes of the map objects.

This reader can be used as an iterator on a .dbf file. It can also be used to directly access the records in the file (or more precisely their index) if it was created with the constructor that takes a file name as argument.

Since:
ILOG JViews 3.0
See Also:
IlvShapeFileReader

Constructor Summary
IlvDBFReader(DataInput dataInput)
          Creates an instance of IlvDBFReader from a data input.
IlvDBFReader(String fileName)
          Creates an instance of IlvDBFReader for the specified file name.
IlvDBFReader(URL url)
          Creates an instance of IlvDBFReader for the specified URL.
 
Method Summary
 void dispose()
          Releases the resources allocated to the reader.
 void finalize()
          Is called by the Java Garbage Collector to release the resources allocated to the reader.
 IlvAttributeInfoProperty getAttributeInfo()
          Returns the types and names of the fields contained in the .dbf file.
 int getAttributeSize(int index)
          Return the size of the attribute specified by the index.
 int getCurrentIndex()
          Returns the index of the next field that will be read.
 IlvFeatureAttributeProperty getNextRecord()
          Reads the next record in the .dbf file.
 int getRecordCount()
          Returns the number of records contained in the .dbf file.
 String getStringEncoding()
          Returns the character encoding used when reading attributes.
 boolean isInterningStringAttributes()
          Returns true if the String attributes that are read are interned.
 boolean isReadingAttribute(int index)
          Returns true if the specified attribute is read.
 boolean isReadingAttribute(String name)
          Returns true if the specified attribute is read.
 boolean isTrimmingStringAttributes()
          Returns true if the String attributes that are read are trimmed, that is, leading and trailing spaces are removed.
 IlvFeatureAttributeProperty readRecord(int index)
          Reads the record corresponding to the specified index (see restrictions below).
 void setInterningStringAttributes(boolean set)
          Specifies whether the String attributes that are read are interned.
 void setReadingAttribute(int index, boolean set)
          Tells the reader whether to read the attribute whose index is specified.
 void setReadingAttribute(String name, boolean set)
          Tells the reader whether to read the attribute whose name is specified.
 void setStringEncoding(String encoding)
          Specifies which character encoding is used when reading attributes.
 void setTrimmingStringAttributes(boolean set)
          Specifies whether the String attributes that are read are trimmed, that is, leading and trailing spaces are removed.
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

IlvDBFReader

public IlvDBFReader(String fileName)
             throws IOException
Creates an instance of IlvDBFReader for the specified file name.

Parameters:
fileName - The name of the DBF file
Throws:
IOException - if the file cannot be opened.

IlvDBFReader

public IlvDBFReader(URL url)
             throws IOException
Creates an instance of IlvDBFReader for the specified URL.

Parameters:
url - The url of the DBF file (with the .dbf extension)
Throws:
IOException - if an error occurs while opening the file.

IlvDBFReader

public IlvDBFReader(DataInput dataInput)
             throws IOException
Creates an instance of IlvDBFReader from a data input.

Parameters:
dataInput - the data input.
Throws:
IOException - if the file cannot be opened.
Method Detail

setTrimmingStringAttributes

public void setTrimmingStringAttributes(boolean set)
Specifies whether the String attributes that are read are trimmed, that is, leading and trailing spaces are removed.

Parameters:
set - If true, String attributes are trimmed.
Since:
JViews 4.0

isTrimmingStringAttributes

public boolean isTrimmingStringAttributes()
Returns true if the String attributes that are read are trimmed, that is, leading and trailing spaces are removed. The default is false.

Since:
JViews 4.0

setInterningStringAttributes

public void setInterningStringAttributes(boolean set)
Specifies whether the String attributes that are read are interned. When String attributes are interned, the Strings returned by this reader are stored using their canonical form, leading to less memory usage. This is useful when the DBF database contains multiple instances of the same string (typically, street level databases).

Since:
JViews 5.5
See Also:
isInterningStringAttributes(), String.intern()

isInterningStringAttributes

public boolean isInterningStringAttributes()
Returns true if the String attributes that are read are interned. The default is false.

Since:
JViews 5.5
See Also:
setInterningStringAttributes(boolean)

setStringEncoding

public void setStringEncoding(String encoding)
Specifies which character encoding is used when reading attributes. The default is to use the default character encoding of the platform. See the Java internationalization documentation for the set of supported encodings.

Parameters:
encoding - The String encoding or null to read the attributes using the default encoding of the platform.
Since:
JViews 4.0

getStringEncoding

public String getStringEncoding()
Returns the character encoding used when reading attributes. The default is to use the default character encoding of the platform.

Returns:
The String encoding or null if using the default encoding of the platform.
Since:
JViews 4.0

setReadingAttribute

public void setReadingAttribute(String name,
                                boolean set)
Tells the reader whether to read the attribute whose name is specified. This leads to the attribute value being nullified. The default is to load all attributes.

Parameters:
name - The name of the attribute.
set - If true, the specified attribute is read.
Since:
JViews 4.0

isReadingAttribute

public boolean isReadingAttribute(String name)
Returns true if the specified attribute is read.

Parameters:
name - The name of the attribute.
Since:
JViews 4.0

setReadingAttribute

public void setReadingAttribute(int index,
                                boolean set)
Tells the reader whether to read the attribute whose index is specified. This leads to the attribute value being nullified. The default is to load all attributes.

Parameters:
index - The index of the attribute.
set - If true, the specified attribute is read.
Since:
JViews 5.5

isReadingAttribute

public boolean isReadingAttribute(int index)
Returns true if the specified attribute is read.

Parameters:
index - The index of the attribute.
Since:
JViews 5.5

getRecordCount

public final int getRecordCount()
Returns the number of records contained in the .dbf file.


getAttributeInfo

public final IlvAttributeInfoProperty getAttributeInfo()
Returns the types and names of the fields contained in the .dbf file. Each record has the same fields.


getAttributeSize

public int getAttributeSize(int index)
Return the size of the attribute specified by the index.

Parameters:
index - The index of the attribute.
Since:
JViews 4.0

getCurrentIndex

public int getCurrentIndex()
Returns the index of the next field that will be read.


getNextRecord

public IlvFeatureAttributeProperty getNextRecord()
                                          throws IOException
Reads the next record in the .dbf file. The returned attribute value is volatile and might be modified when the getNextRecord method is called again.

Throws:
IOException - if the end of the file is reached or if an IO exception is thrown.
See Also:
getCurrentIndex()

readRecord

public IlvFeatureAttributeProperty readRecord(int index)
                                       throws IOException
Reads the record corresponding to the specified index (see restrictions below).
Restrictions:

Throws:
IOException - if the end of the file is reached or if an IO exception is thrown.

dispose

public void dispose()
Releases the resources allocated to the reader. Once this method has been called, no other access to the reader should be performed.


finalize

public void finalize()
Is called by the Java Garbage Collector to release the resources allocated to the reader. If the dispose function was not called, it releases the resources used by the reader.

Overrides:
finalize in class Object
See Also:
dispose()


Copyright © 1996-2007 ILOG S.A. All rights reserved.   Documentation homepage.