public class DbaseFileHeader extends Object
Modifier and Type | Field and Description |
---|---|
static long |
MILLIS_SINCE_4713
Returns the number of millis at January 1st 4713 BC
Calendar refCal = (Calendar) new GregorianCalendar(TimeZone.getTimeZone("UTC"));
refCal.set(Calendar.ERA, GregorianCalendar.BC); refCal.set(Calendar.YEAR, 4713);
refCal.set(Calendar.MONTH, Calendar.JANUARY); refCal.set(Calendar.DAY_OF_MONTH, 1);
refCal.set(Calendar.HOUR, 12); refCal.set(Calendar.MINUTE, 0); refCal.set(Calendar.SECOND,
0); refCal.set(Calendar.MILLISECOND, 0); MILLIS_SINCE_4713 = refCal.getTimeInMillis() -
43200000L; //(43200000L: 12 hour correction factor taken from DBFViewer2000)
|
Constructor and Description |
---|
DbaseFileHeader() |
Modifier and Type | Method and Description |
---|---|
void |
addColumn(String inFieldName,
char inFieldType,
int inFieldLength,
int inDecimalCount)
Add a column to this DbaseFileHeader.
|
Class |
getFieldClass(int i)
Determine the most appropriate Java Class for representing the data in the field.
|
int |
getFieldDecimalCount(int inIndex)
Get the decimal count of this field.
|
int |
getFieldLength(int inIndex)
Returns the field length in bytes.
|
String |
getFieldName(int inIndex)
Get the field name.
|
char |
getFieldType(int inIndex)
Get the character class of the field.
|
int |
getHeaderLength()
Get the length of the header
|
int |
getLargestFieldSize()
Get the largest field size of this table.
|
Date |
getLastUpdateDate()
Get the date this file was last updated.
|
long |
getLengthForRecords(int records)
Returns the expected file size for the given number of records in the file
|
int |
getNumFields()
Return the number of fields in the records.
|
int |
getNumRecords()
Return the number of records in the file
|
int |
getRecordLength()
Get the length of the records in bytes.
|
void |
readHeader(ByteBuffer in)
Read the header data from the DBF file.
|
void |
readHeader(ReadableByteChannel channel)
Read the header data from the DBF file.
|
void |
readHeader(ReadableByteChannel channel,
Charset charset)
Read the header data from the DBF file.
|
int |
removeColumn(String inFieldName)
Remove a column from this DbaseFileHeader.
|
void |
setNumRecords(int inNumRecords)
Set the number of records in the file
|
String |
toString()
Get a simple representation of this header.
|
void |
writeHeader(WritableByteChannel out)
Write the header data to the DBF file.
|
public static long MILLIS_SINCE_4713
Calendar refCal = (Calendar) new GregorianCalendar(TimeZone.getTimeZone("UTC")); refCal.set(Calendar.ERA, GregorianCalendar.BC); refCal.set(Calendar.YEAR, 4713); refCal.set(Calendar.MONTH, Calendar.JANUARY); refCal.set(Calendar.DAY_OF_MONTH, 1); refCal.set(Calendar.HOUR, 12); refCal.set(Calendar.MINUTE, 0); refCal.set(Calendar.SECOND, 0); refCal.set(Calendar.MILLISECOND, 0); MILLIS_SINCE_4713 = refCal.getTimeInMillis() - 43200000L; //(43200000L: 12 hour correction factor taken from DBFViewer2000)
public Class getFieldClass(int i)
All packages are java.lang unless otherwise specified. C (Character) -> String N (Numeric) -> Integer or Long or Double (depends on field's decimal count and fieldLength) F (Floating) -> Double L (Logical) -> Boolean D (Date) -> java.util.Date (Without time)
i
- The index of the field, from 0 to getNumFields() - 1
.public void addColumn(String inFieldName, char inFieldType, int inFieldLength, int inDecimalCount) throws DbaseFileException
Field Type MaxLength ---------- --------- C 254 D 8
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 ( see above )inDecimalCount
- For numeric fields, the number of decimal places to track.DbaseFileException
- If the type is not recognized.public int removeColumn(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 String getFieldName(int inIndex)
inIndex
- The field index.public char getFieldType(int inIndex)
inIndex
- The field index.public Date getLastUpdateDate()
public int getNumFields()
public int getNumRecords()
public int getRecordLength()
public int getHeaderLength()
public void readHeader(ReadableByteChannel channel) throws IOException
channel
- A readable byte channel. If you have an InputStream you need to use, you can
call java.nio.Channels.getChannel(InputStream in).IOException
- If errors occur while reading.public void readHeader(ReadableByteChannel channel, Charset charset) throws IOException
channel
- A readable byte channel. If you have an InputStream you need to use, you can
call java.nio.Channels.getChannel(InputStream in).IOException
- If errors occur while reading.public void readHeader(ByteBuffer in) throws IOException
channel
- A readable byte channel. If you have an InputStream you need to use, you can
call java.nio.Channels.getChannel(InputStream in).IOException
- If errors occur while reading.public int getLargestFieldSize()
public void setNumRecords(int inNumRecords)
inNumRecords
- The number of records.public void writeHeader(WritableByteChannel out) throws 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).IOException
- If errors occur.public String toString()
public long getLengthForRecords(int records)
records
- Copyright © 1996–2019 Geotools. All rights reserved.