Class ALcdDAFIFDecoder
- All Implemented Interfaces:
ILcdDAFIFDecoder
,ILcdInputStreamFactoryCapable
,ILcdModelDecoder
- Direct Known Subclasses:
ALcdDAFIFMultiModelDecoder
,ALcdDAFIFSingleModelDecoder
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.
- See Also:
-
Field Summary
Modifier and TypeFieldDescriptionprotected static final String
protected int
Number of the current record. -
Constructor Summary
ConstructorDescriptionALcdDAFIFDecoder
(Properties aDAFIFProperties) Initializes the DAFIFProperties field with the specified properties object. -
Method Summary
Modifier and TypeMethodDescriptionprotected void
addErrorReport
(String aErrorReport) Adds information about an error to the error message.boolean
canDecodeSource
(String aSource) Returnstrue
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 fileprotected abstract void
cleanUp()
This method should be implemented by a concrete class.protected TLcdAltitudeType
getAltitudeType
(String aAltitudeType) Returns aTLcdAltitudeType
object according to the code aAltitudeType.protected TLcdBearingType
getBearingTypeForChar
(char aType) Returns theTLcdBearingType
according to aType.Returns the initial bounds for the model.Returns a DAFIFProperties
object.Returns the Factory to be used to create domain objects.Returns the bounds to filter on.Returns a short, displayable name for the format that is decoded by thisILcdModelDecoder
.Deprecated.Returns the error message of the last decode call.protected InputStream
getInputStream
(String aSource) Creates and returns anInputStream
object for the given source.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 theILcdGeodeticDatum
interface according to the specified code.protected ILcdDAFIFModelFilter
protected int
Returns the number of records that are already read on the moment of the call.protected void
Initializes the error message with an introduction.boolean
boolean
Deprecated.This method has been deprecated.protected void
loadCFGProperties
(String aSource) Loads thedafif.toc
file into aProperties
object.protected String
read
(char[] aRecord, int aStart, int aLength) Reads data from position aStart to aStart + aLength - 1 in aRecord, trims the resultingString
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 resultingString
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 resultingString
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 aProperties
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.protected void
Transforms the given point to the reference WGS84 datum.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.luciad.format.dafif.decoder.ILcdDAFIFDecoder
getDecodeFileName
Methods inherited from interface com.luciad.model.ILcdModelDecoder
canDecodeSource, decode, decodeModelMetadata, decodeModelMetadata, decodeSource, discoverDataSources
-
Field Details
-
DAFIF_PROP_EXTENSION
- See Also:
-
fRecordCount
protected int fRecordCountNumber of the current record.
-
-
Constructor Details
-
ALcdDAFIFDecoder
Initializes the DAFIFProperties field with the specified properties object. This object may be null.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.
- Parameters:
aDAFIFProperties
- aProperties
object containing for each domain object the name of its data file or NULL
-
-
Method Details
-
getDisplayName
Description copied from interface:ILcdModelDecoder
Returns a short, displayable name for the format that is decoded by thisILcdModelDecoder
.- Specified by:
getDisplayName
in interfaceILcdModelDecoder
- Returns:
- the displayable name of this
ILcdModelDecoder
.
-
canDecodeSource
Returnstrue
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
- Specified by:
canDecodeSource
in interfaceILcdModelDecoder
- Parameters:
aSource
- the name of the source file or directory that you want to decode- Returns:
- a boolean indicating whether the given source can be decoded
- See Also:
-
setBounds
Description copied from interface:ILcdDAFIFDecoder
Specifies a bounds to be used as initial bounds for the model.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.
- Specified by:
setBounds
in interfaceILcdDAFIFDecoder
- Parameters:
aBounds
- the initial bounds for the model- See Also:
-
getBounds
Description copied from interface:ILcdDAFIFDecoder
Returns the initial bounds for the model.- Specified by:
getBounds
in interfaceILcdDAFIFDecoder
- Returns:
- the initial bounds for the model
- See Also:
-
getDecodingBounds
Description copied from interface:ILcdDAFIFDecoder
Returns the bounds to filter on.- Specified by:
getDecodingBounds
in interfaceILcdDAFIFDecoder
- Returns:
- the bounds to be filtered on
- See Also:
-
setDecodingBounds
Description copied from interface:ILcdDAFIFDecoder
Specifies a bounds that will be used to filter on.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.
- Specified by:
setDecodingBounds
in interfaceILcdDAFIFDecoder
- Parameters:
aBoundsToFilterOn
- the bounds to be used as a filter- See Also:
-
setDomainFactory
Deprecated.Specifies the domainFactory to be used to create domain objects.The given domainFactory must not be null. Note that if a data object factory is set, the domain factory will not be used.
- Specified by:
setDomainFactory
in interfaceILcdDAFIFDecoder
- Parameters:
aDomainFactory
- the domainFactory to be used to create domain objects- See Also:
-
getDomainFactory
Deprecated.Returns the domainFactory to be used to create domain objects.- Specified by:
getDomainFactory
in interfaceILcdDAFIFDecoder
- Returns:
- the domainFactory to be used to create domain objects
- See Also:
-
setDataObjectFactory
Description copied from interface:ILcdDAFIFDecoder
Specifies the factory to be used to create domain objects.The given factory must not be null.
- Specified by:
setDataObjectFactory
in interfaceILcdDAFIFDecoder
- Parameters:
aFactory
- the domainFactory to be used to create domain objects- See Also:
-
getDataObjectFactory
Description copied from interface:ILcdDAFIFDecoder
Returns the Factory to be used to create domain objects.- Specified by:
getDataObjectFactory
in interfaceILcdDAFIFDecoder
- Returns:
- the factory to be used to create domain objects
- See Also:
-
getErrorMessage
Description copied from interface:ILcdDAFIFDecoder
Returns the error message of the last decode call.Note: the error message can only be retrieved once after a decode call.
- Specified by:
getErrorMessage
in interfaceILcdDAFIFDecoder
- Returns:
- a
String
object containing the errors occurred during the last decode process
-
getDAFIFProperties
Description copied from interface:ILcdDAFIFDecoder
Returns a DAFIFProperties
object. The DAFIF properties contain -among other things- the links between domain objects and their data file names.- Specified by:
getDAFIFProperties
in interfaceILcdDAFIFDecoder
- Returns:
- the DAFIF
Properties
object that is used to retrieve the decode file name from - See Also:
-
setDAFIFProperties
Description copied from interface:ILcdDAFIFDecoder
Specifies aProperties
object containing the DAFIF properties. This object should contain for each domain object its data file name (e.g. source.refuelingTracksFile=FILE7).- Specified by:
setDAFIFProperties
in interfaceILcdDAFIFDecoder
- Parameters:
aDAFIFProperties
- aProperties
object containing the DAFIF properties- See Also:
-
setDAFIFModelFilter
Description copied from interface:ILcdDAFIFDecoder
Specifies a filter to be used while creating the model. Only model objects that pass through the filter will be in the resulting model.- Specified by:
setDAFIFModelFilter
in interfaceILcdDAFIFDecoder
- Parameters:
aFilter
- anILcdDAFIFModelFilter
to filter the model objects
-
setInputStreamFactory
Sets the input stream factory that will be used for creating input streams given source names.- Specified by:
setInputStreamFactory
in interfaceILcdInputStreamFactoryCapable
- Parameters:
aInputStreamFactory
- the input stream factory to be used.
-
getInputStreamFactory
Returns the input stream factory that is currently used for creating input streams given source names.- Specified by:
getInputStreamFactory
in interfaceILcdInputStreamFactoryCapable
- Returns:
- the input stream factory that is currently used.
-
isTraceOn
public boolean isTraceOn()Deprecated.This method has been deprecated. It is recommended to use the standard Java logging framework directly.Returnstrue
if tracing is enabled for this class.- Returns:
- true if tracing is enabled for this class, false otherwise.
-
setTraceOn
public static void setTraceOn(boolean aTraceOn) Deprecated.This method has been deprecated. It is recommended to use the standard Java logging framework directly.Enables tracing for this class instance. Calling this method with eithertrue
orfalse
as argument automatically turns off tracing for all other class instances for whichsetTraceOn
has not been called. If the argument isfalse
then only the informative, warning and error log messages are recorded.- Parameters:
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.
-
getModelFilter
-
loadCFGProperties
Loads thedafif.toc
file into aProperties
object.- Parameters:
aSource
- the path to the dafif.toc file. this path should include the dafif.toc file name.
-
addErrorReport
Adds information about an error to the error message.- Parameters:
aErrorReport
- the reporting of one error to be added to the error message
-
initializeErrorMessage
protected void initializeErrorMessage()Initializes the error message with an introduction. -
readRecord
Reads one record from the given reader.- Parameters:
aReader
- the reader to be read of- Returns:
- the record read from aReader or NULL if the end of the stream has been reached
- Throws:
IOException
- if an error occurs during the reading process
-
readFormat
protected int readFormat(char[] aRecord) Reads the format from a given record.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.
- Parameters:
aRecord
- the record whose format is read- Returns:
- the format of the aRecord (e.g. 01, 02, ...)
-
getLocalHorizontalDatum
Returns an instance of an implementation of theILcdGeodeticDatum
interface according to the specified code. For the code 'U' (unknown),null
is returned. If the code is not supported, anIllegalArgumentException
object will be thrown.- Parameters:
aGeodeticDatumCode
- the code for the geodetic datum to be returned- Returns:
- the geodetic datum according to the given code
-
getBearingTypeForChar
Returns theTLcdBearingType
according to aType.If the given type is invalid, an
IllegalArgumentException
object will be thrown.- Parameters:
aType
- the code for the bearingType to be returned- Returns:
- the bearingType according to the given code
-
getAltitudeType
Returns aTLcdAltitudeType
object according to the code aAltitudeType.If the given type is invalid, an
IllegalArgumentException
object will be thrown.- Parameters:
aAltitudeType
- the code whose altitudeType should be returned- Returns:
- the altitudeType according to the given code
-
readMinLength
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 resultingString
after trimming.The length should be larger than aMinLength. If it is, the trimmed
String
is returned. If it is not, anIllegalArgumentException
object is thrown, indicating that the field with name aFieldName is not valid.- Parameters:
aRecord
- the record to be read ofaStart
- the start position for readingaLength
- the length of theString
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 theIllegalArgumentException
object thrown if aMinLength is not reached)
-
read
Reads data from position aStart to aStart + aLength - 1 in aRecord, trims the resultingString
object and returns it.- Parameters:
aRecord
- the record to be read ofaStart
- the start position for readingaLength
- the length of theString
to be read- Returns:
- a trimmed
String
object
-
readExactValue
Reads from aRecord from position aStart to aStart + aLength - 1 and returns the resultingString
object.The resulting
String
is not trimmed!- Parameters:
aRecord
- the record to be read ofaStart
- the start position for readingaLength
- the length of theString
to be read- Returns:
- the resulting
String
, not trimmed!
-
getInputStream
Creates and returns anInputStream
object for the given source.- Parameters:
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 (seegetDecodeFileName()
).- Returns:
- an
InputStream
object for the given source. - Throws:
IOException
-
cleanUp
protected abstract void cleanUp()This method should be implemented by a concrete class.It should empty all temporary data structures used during the decoding process.
-
getRecordCount
protected int getRecordCount()Returns the number of records that are already read on the moment of the call.- Returns:
- the number of records read when calling this method
-
transformPointToReferenceDatumSFCT
Transforms the given point to the reference WGS84 datum. The point's original datum is assumed to be in the point's last feature. If the point is not an ILcdFeatured or the last feature is not an ILcdGeodeticDatum, this method has no effect.- Parameters:
aPointSFCT
-
-
setStoreOriginalReference
public void setStoreOriginalReference(boolean aStoreReference) - Specified by:
setStoreOriginalReference
in interfaceILcdDAFIFDecoder
-
isStoreOriginalReference
public boolean isStoreOriginalReference()
-
getDataObjectFactory()