public abstract class ALcdDAFIFDecoder extends Object implements ILcdDAFIFDecoder, ILcdInputStreamFactoryCapable
ILcdDAFIFDecoder
interface defines
the most primitive methods used when decoding a DAFIF file.
It implements most of the getters and setters in of the ILcdDAFIFDecoder
interface
and it has the code to initialize the DAFIF properties. These Dafif properties will be used
to retrieve the name of the DAFIF data file.
Furthermore this abstract class contains some methods to get a geodetic datum, a bearing type or an altitude type by using a code read from a DAFIF data file.
All Dafif decoders will use the functionality given by this class.
Modifier and Type | Field and Description |
---|---|
protected static String |
DAFIF_PROP_EXTENSION |
protected int |
fRecordCount
Number of the current record.
|
Constructor and Description |
---|
ALcdDAFIFDecoder(Properties aDAFIFProperties)
Initializes the DAFIFProperties field with the
specified properties object.
|
Modifier and Type | Method and Description |
---|---|
protected void |
addErrorReport(String aErrorReport)
Adds information about an error to the error message.
|
boolean |
canDecodeSource(String aSource)
Returns
true if the specified source is:
A file with the specific name corresponding to the object type of this decoder
A directory containing such a file
A .toc file in a directory, pointing to such a file
|
protected abstract void |
cleanUp()
This method should be implemented by a concrete class.
|
protected TLcdAltitudeType |
getAltitudeType(String aAltitudeType)
Returns a
TLcdAltitudeType object according to
the code aAltitudeType. |
protected TLcdBearingType |
getBearingTypeForChar(char aType)
Returns the
TLcdBearingType according to
aType. |
ILcdBounds |
getBounds()
Returns the initial bounds for the model.
|
Properties |
getDAFIFProperties()
Returns a DAFIF
Properties object. |
TLcdAISDataObjectFactory |
getDataObjectFactory()
Returns the Factory to be used to
create domain objects.
|
ILcdBounds |
getDecodingBounds()
Returns the bounds to filter on.
|
String |
getDisplayName()
Returns a short, displayable name for the format that is decoded by this
ILcdModelDecoder . |
ALcdAISObjectFactory |
getDomainFactory()
Deprecated.
|
String |
getErrorMessage()
Returns the error message of the last decode call.
|
protected InputStream |
getInputStream(String aSource)
Creates and returns an
InputStream object for the given source. |
ILcdInputStreamFactory |
getInputStreamFactory()
Returns the input stream factory that is currently used for creating input streams
given source names.
|
protected ILcdGeodeticDatum |
getLocalHorizontalDatum(String aGeodeticDatumCode)
Returns an instance of an implementation of the
ILcdGeodeticDatum interface according
to the specified code. |
protected ILcdDAFIFModelFilter |
getModelFilter() |
protected int |
getRecordCount()
Returns the number of records that are
already read on the moment of the call.
|
protected void |
initializeErrorMessage()
Initializes the error message with an introduction.
|
boolean |
isStoreOriginalReference() |
boolean |
isTraceOn()
Deprecated.
This method has been deprecated. It is recommended to use the
standard Java logging framework directly.
|
protected void |
loadCFGProperties(String aSource)
Loads the
dafif.toc file into
a Properties object. |
protected String |
read(char[] aRecord,
int aStart,
int aLength)
Reads data from position aStart to aStart + aLength - 1 in aRecord, trims the
resulting
String object and returns it. |
protected String |
readExactValue(char[] aRecord,
int aStart,
int aLength)
Reads from aRecord from position aStart to aStart + aLength - 1 and
returns the resulting
String object. |
protected int |
readFormat(char[] aRecord)
Reads the format from a given record.
|
protected String |
readMinLength(char[] aRecord,
int aStart,
int aLength,
int aMinLength,
String aFieldName)
Reads data from position aStart to aStart + aLength - 1 in aRecord,
and checks the length of the resulting
String after trimming. |
protected char[] |
readRecord(BufferedReader aReader)
Reads one record from the given reader.
|
void |
setBounds(ILcdBounds aBounds)
Specifies a bounds to be used as initial bounds for the model.
|
void |
setDAFIFModelFilter(ILcdDAFIFModelFilter aFilter)
Specifies a filter to be used while creating the model.
|
void |
setDAFIFProperties(Properties aDAFIFProperties)
Specifies a
Properties object containing the DAFIF properties. |
void |
setDataObjectFactory(TLcdAISDataObjectFactory aFactory)
Specifies the factory to be used to
create domain objects.
|
void |
setDecodingBounds(ILcdBounds aBoundsToFilterOn)
Specifies a bounds that will be used to filter on.
|
void |
setDomainFactory(ALcdAISObjectFactory aDomainFactory)
Deprecated.
|
void |
setInputStreamFactory(ILcdInputStreamFactory aInputStreamFactory)
Sets the input stream factory that will be used for creating input streams
given source names.
|
void |
setStoreOriginalReference(boolean aStoreReference) |
static void |
setTraceOn(boolean aTraceOn)
Deprecated.
This method has been deprecated. It is recommended to use the
standard Java logging framework directly.
|
protected void |
transformPointToReferenceDatumSFCT(ILcd3DEditablePoint aPointSFCT)
Transforms the given point to the reference WGS84 datum.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getDecodeFileName
canDecodeSource, decode, decodeModelMetadata, decodeModelMetadata, decodeSource, discoverDataSources
protected static final String DAFIF_PROP_EXTENSION
protected int fRecordCount
public ALcdDAFIFDecoder(Properties aDAFIFProperties)
If you don't have a properties object here, you can still specify it by decoding a .toc file containing the dafif properties. The decoder will read the properties from the .toc file and look for the data file to be decoded in the directory containing this .toc file.
aDAFIFProperties
- a Properties
object containing for each domain
object the name of its data file or NULLpublic String getDisplayName()
ILcdModelDecoder
ILcdModelDecoder
.getDisplayName
in interface ILcdModelDecoder
ILcdModelDecoder
.public boolean canDecodeSource(String aSource)
true
if the specified source is:
.toc
file in a directory, pointing to such a filecanDecodeSource
in interface ILcdModelDecoder
aSource
- the name of the source file or directory that you want to decodeILcdModelDecoder.decode(String)
,
ILcdModelDecoder.decodeModelMetadata(String)
public void setBounds(ILcdBounds aBounds)
ILcdDAFIFDecoder
This bounds should be large enough to enclose (most of) the model objects. This option is used to avoid to many expansions of the model bounds.
This parameter may be NULL.
Note: this bounds is not a filter! If a model objects bounds does not interact with aInitialBounds, aInitialBounds will be enlarged until it does interact.
setBounds
in interface ILcdDAFIFDecoder
aBounds
- the initial bounds for the modelILcdDAFIFDecoder.getBounds()
public ILcdBounds getBounds()
ILcdDAFIFDecoder
getBounds
in interface ILcdDAFIFDecoder
ILcdDAFIFDecoder.setBounds(com.luciad.shape.ILcdBounds)
public ILcdBounds getDecodingBounds()
ILcdDAFIFDecoder
getDecodingBounds
in interface ILcdDAFIFDecoder
ILcdDAFIFDecoder.setDecodingBounds(com.luciad.shape.ILcdBounds)
public void setDecodingBounds(ILcdBounds aBoundsToFilterOn)
ILcdDAFIFDecoder
If this bounds is null, all objects found in the input file will be inserted into the model.
If this bounds is not null, only the objects whose bounds interact with the specified bounds will be inserted into the model.
setDecodingBounds
in interface ILcdDAFIFDecoder
aBoundsToFilterOn
- the bounds to be used as a filterILcdDAFIFDecoder.getDecodingBounds()
@Deprecated public void setDomainFactory(ALcdAISObjectFactory aDomainFactory)
setDataObjectFactory(TLcdAISDataObjectFactory)
The given domainFactory must not be null. Note that if a data object factory is set, the domain factory will not be used.
setDomainFactory
in interface ILcdDAFIFDecoder
aDomainFactory
- the domainFactory to be used to
create domain objectsILcdDAFIFDecoder.getDomainFactory()
@Deprecated public ALcdAISObjectFactory getDomainFactory()
getDataObjectFactory()
getDomainFactory
in interface ILcdDAFIFDecoder
ILcdDAFIFDecoder.setDomainFactory(com.luciad.ais.model.ALcdAISObjectFactory)
public void setDataObjectFactory(TLcdAISDataObjectFactory aFactory)
ILcdDAFIFDecoder
The given factory must not be null.
setDataObjectFactory
in interface ILcdDAFIFDecoder
aFactory
- the domainFactory to be used to
create domain objectsILcdDAFIFDecoder.getDataObjectFactory()
public TLcdAISDataObjectFactory getDataObjectFactory()
ILcdDAFIFDecoder
getDataObjectFactory
in interface ILcdDAFIFDecoder
ILcdDAFIFDecoder.setDataObjectFactory(TLcdAISDataObjectFactory)
public String getErrorMessage()
ILcdDAFIFDecoder
Note: the error message can only be retrieved once after a decode call.
getErrorMessage
in interface ILcdDAFIFDecoder
String
object containing the errors occurred during the last decode processpublic Properties getDAFIFProperties()
ILcdDAFIFDecoder
Properties
object.
The DAFIF properties contain -among other things- the links between domain
objects and their data file names.getDAFIFProperties
in interface ILcdDAFIFDecoder
Properties
object that is used to retrieve the decode file name fromILcdDAFIFDecoder.setDAFIFProperties(java.util.Properties)
public void setDAFIFProperties(Properties aDAFIFProperties)
ILcdDAFIFDecoder
Properties
object containing the DAFIF properties.
This object should contain for each domain object its data file name (e.g. source.refuelingTracksFile=FILE7).setDAFIFProperties
in interface ILcdDAFIFDecoder
aDAFIFProperties
- a Properties
object containing the DAFIF propertiesILcdDAFIFDecoder.getDAFIFProperties()
,
TLcdDAFIFDataPreparatorMain
public void setDAFIFModelFilter(ILcdDAFIFModelFilter aFilter)
ILcdDAFIFDecoder
setDAFIFModelFilter
in interface ILcdDAFIFDecoder
aFilter
- an ILcdDAFIFModelFilter
to filter the model
objectspublic void setInputStreamFactory(ILcdInputStreamFactory aInputStreamFactory)
setInputStreamFactory
in interface ILcdInputStreamFactoryCapable
aInputStreamFactory
- the input stream factory to be used.public ILcdInputStreamFactory getInputStreamFactory()
getInputStreamFactory
in interface ILcdInputStreamFactoryCapable
public boolean isTraceOn()
true
if tracing is enabled for this class.public static void setTraceOn(boolean aTraceOn)
true
or false
as argument automatically turns
off tracing for all other class instances for which
setTraceOn
has not been called.
If the argument is false
then only the informative, warning
and error log messages are recorded.aTraceOn
- if true then all log messages are recorded for this
instance. If false, then only the informative, warning and
error log messages are recorded.protected ILcdDAFIFModelFilter getModelFilter()
protected void loadCFGProperties(String aSource)
dafif.toc
file into
a Properties
object.aSource
- the path to the dafif.toc file.
this path should include the dafif.toc file name.protected void addErrorReport(String aErrorReport)
aErrorReport
- the reporting of one error to be added to the error messageprotected void initializeErrorMessage()
protected char[] readRecord(BufferedReader aReader) throws IOException
aReader
- the reader to be read ofIOException
- if an error occurs during the reading processprotected int readFormat(char[] aRecord)
The format is always stored in the first two characters of a record.
If no valid format is found (e.g. a NumberFormatException occurs), 0 will be returned and an error report will be added to the error message.
aRecord
- the record whose format is readprotected ILcdGeodeticDatum getLocalHorizontalDatum(String aGeodeticDatumCode)
ILcdGeodeticDatum
interface according
to the specified code.
For the code 'U' (unknown), null
is returned.
If the code is not supported, an IllegalArgumentException
object will
be thrown.aGeodeticDatumCode
- the code for the geodetic datum to be returnedprotected TLcdBearingType getBearingTypeForChar(char aType)
TLcdBearingType
according to
aType.
If the given type is invalid, an IllegalArgumentException
object will
be thrown.
aType
- the code for the bearingType to be returnedprotected TLcdAltitudeType getAltitudeType(String aAltitudeType)
TLcdAltitudeType
object according to
the code aAltitudeType.
If the given type is invalid, an IllegalArgumentException
object will
be thrown.
aAltitudeType
- the code whose altitudeType should be returnedprotected String readMinLength(char[] aRecord, int aStart, int aLength, int aMinLength, String aFieldName)
String
after trimming.
The length should be larger than aMinLength. If it is, the trimmed String
is returned.
If it is not, an IllegalArgumentException
object
is thrown, indicating that the field with name aFieldName is not valid.
aRecord
- the record to be read ofaStart
- the start position for readingaLength
- the length of the String
to be readaMinLength
- the length of the result should be larger than this parameteraFieldName
- the name of the field whose data has been reading by this method (used in
the IllegalArgumentException
object thrown if aMinLength is not reached)protected String read(char[] aRecord, int aStart, int aLength)
String
object and returns it.aRecord
- the record to be read ofaStart
- the start position for readingaLength
- the length of the String
to be readString
objectprotected String readExactValue(char[] aRecord, int aStart, int aLength)
String
object.
The resulting String
is not trimmed!
aRecord
- the record to be read ofaStart
- the start position for readingaLength
- the length of the String
to be readString
, not trimmed!protected InputStream getInputStream(String aSource) throws IOException
InputStream
object for the given source.aSource
- the directory where to find the file to be decoded,
or the name of the file that corresponds to the file name associated
with this decoder (see getDecodeFileName()
).InputStream
object for the given source.IOException
protected abstract void cleanUp()
It should empty all temporary data structures used during the decoding process.
protected int getRecordCount()
protected void transformPointToReferenceDatumSFCT(ILcd3DEditablePoint aPointSFCT)
aPointSFCT
- public void setStoreOriginalReference(boolean aStoreReference)
setStoreOriginalReference
in interface ILcdDAFIFDecoder
public boolean isStoreOriginalReference()