public class DbaseFileHeader
extends java.lang.Object
Constructor and Description |
---|
DbaseFileHeader()
Creates a class for representing a DBase III header.
|
DbaseFileHeader(java.util.logging.Logger logger)
Creates a class for representing a DBase III header with logged warning
and error messages.
|
Modifier and Type | Method and Description |
---|---|
void |
addColumn(java.lang.String inFieldName,
char inFieldType,
int inFieldLength,
int inDecimalCount)
Adds a column to this DbaseFileHeader.
|
java.lang.Class |
getFieldClass(int i)
Determines the most appropriate Java Class for representing the data in the
field.
|
int |
getFieldDecimalCount(int inIndex)
Reports the location of the decimal point within the field.
|
int |
getFieldLength(int inIndex)
Reports the field length in bytes.
|
java.lang.String |
getFieldName(int inIndex)
Reports the name of the field at the given index.
|
char |
getFieldType(int inIndex)
Reports the type of field at the given index.
|
int |
getHeaderLength()
Reports the length of the header.
|
int |
getLargestFieldSize()
Reports the largest field size of this table.
|
java.util.Date |
getLastUpdateDate()
Reports the date this file was last updated.
|
int |
getNumFields()
Reports the number of fields in the records.
|
int |
getNumRecords()
Reports the number of records in the file.
|
int |
getRecordLength()
Reports the length of the records in bytes.
|
void |
readHeader(java.nio.channels.ReadableByteChannel channel)
Reads the header data from the DBF file.
|
int |
removeColumn(java.lang.String inFieldName)
Removes a column from this DbaseFileHeader.
|
void |
setNumRecords(int inNumRecords)
Sets the number of records in the file.
|
java.lang.String |
toString()
Provides a simple representation of this header.
|
void |
writeHeader(java.nio.channels.WritableByteChannel out)
Writes the header data to the DBF file.
|
public DbaseFileHeader()
public DbaseFileHeader(java.util.logging.Logger logger)
logger
- Logger to monitor warning and error messages.public java.lang.Class getFieldClass(int i)
All packages are java.lang
unless otherwise specified.
C (Character) -> String
N (Numeric) -> Integer or Double (depends on field's decimal count)
F (Floating) -> Double
L (Logical) -> Boolean
D (Date) -> java.util.Date
Unknown -> String
i
- The index of the field, from 0 to getNumFields() - 1
.public void addColumn(java.lang.String inFieldName, char inFieldType, int inFieldLength, int inDecimalCount)
Field Type MaxLength ---------- --------- C 254 D 8 F 20 N 18
inFieldName
- The name of the new field, must be less than 10 characters or it
gets truncated.inFieldType
- A character representing the dBase field, (see above). Case insensitive.inFieldLength
- The length of the field, in bytes at 1 byte per digit (see above).inDecimalCount
- For numeric fields, the number of decimal places to track.public int removeColumn(java.lang.String inFieldName)
inFieldName
- The name of the field, will ignore case and trim.public int getFieldLength(int inIndex)
inIndex
- The field index.public int getFieldDecimalCount(int inIndex)
inIndex
- The field index.public java.lang.String getFieldName(int inIndex)
inIndex
- The field index.public char getFieldType(int inIndex)
inIndex
- The field index.public java.util.Date getLastUpdateDate()
public int getNumFields()
public int getNumRecords()
public int getRecordLength()
public int getHeaderLength()
public void readHeader(java.nio.channels.ReadableByteChannel channel) throws java.io.IOException
channel
- A readable byte channel. If you have an InputStream you need to use, you can
call java.nio.Channels.getChannel(InputStream in)
.java.io.IOException
- If errors occur while reading.public int getLargestFieldSize()
public void setNumRecords(int inNumRecords)
inNumRecords
- The number of records.public void writeHeader(java.nio.channels.WritableByteChannel out) throws java.io.IOException
out
- A channel to write to. If you have an OutputStream you can obtain the correct
channel by using java.nio.Channels.newChannel(OutputStream out).java.io.IOException
- If errors occur.public java.lang.String toString()
toString
in class java.lang.Object