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
FieldsModifier and TypeFieldDescriptionprotected static final Stringprotected intNumber of the current record. -
Constructor Summary
ConstructorsConstructorDescriptionALcdDAFIFDecoder(Properties aDAFIFProperties) Initializes the DAFIFProperties field with the specified properties object. -
Method Summary
Modifier and TypeMethodDescriptionprotected voidaddErrorReport(String aErrorReport) Adds information about an error to the error message.booleancanDecodeSource(String aSource) Returnstrueif 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.tocfile in a directory, pointing to such a fileprotected abstract voidcleanUp()This method should be implemented by a concrete class.protected TLcdAltitudeTypegetAltitudeType(String aAltitudeType) Returns aTLcdAltitudeTypeobject according to the code aAltitudeType.protected TLcdBearingTypegetBearingTypeForChar(char aType) Returns theTLcdBearingTypeaccording to aType.Returns the initial bounds for the model.Returns a DAFIFPropertiesobject.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 InputStreamgetInputStream(String aSource) Creates and returns anInputStreamobject for the given source.Returns the input stream factory that is currently used for creating input streams given source names.protected ILcdGeodeticDatumgetLocalHorizontalDatum(String aGeodeticDatumCode) Returns an instance of an implementation of theILcdGeodeticDatuminterface according to the specified code.protected ILcdDAFIFModelFilterprotected intReturns the number of records that are already read on the moment of the call.protected voidInitializes the error message with an introduction.booleanbooleanDeprecated.This method has been deprecated.protected voidloadCFGProperties(String aSource) Loads thedafif.tocfile into aPropertiesobject.protected Stringread(char[] aRecord, int aStart, int aLength) Reads data from position aStart to aStart + aLength - 1 in aRecord, trims the resultingStringobject and returns it.protected StringreadExactValue(char[] aRecord, int aStart, int aLength) Reads from aRecord from position aStart to aStart + aLength - 1 and returns the resultingStringobject.protected intreadFormat(char[] aRecord) Reads the format from a given record.protected StringreadMinLength(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 resultingStringafter trimming.protected char[]readRecord(BufferedReader aReader) Reads one record from the given reader.voidsetBounds(ILcdBounds aBounds) Specifies a bounds to be used as initial bounds for the model.voidsetDAFIFModelFilter(ILcdDAFIFModelFilter aFilter) Specifies a filter to be used while creating the model.voidsetDAFIFProperties(Properties aDAFIFProperties) Specifies aPropertiesobject containing the DAFIF properties.voidsetDataObjectFactory(TLcdAISDataObjectFactory aFactory) Specifies the factory to be used to create domain objects.voidsetDecodingBounds(ILcdBounds aBoundsToFilterOn) Specifies a bounds that will be used to filter on.voidsetDomainFactory(ALcdAISObjectFactory aDomainFactory) Deprecated.voidsetInputStreamFactory(ILcdInputStreamFactory aInputStreamFactory) Sets the input stream factory that will be used for creating input streams given source names.voidsetStoreOriginalReference(boolean aStoreReference) static voidsetTraceOn(boolean aTraceOn) Deprecated.This method has been deprecated.protected voidTransforms 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, waitMethods inherited from interface com.luciad.format.dafif.decoder.ILcdDAFIFDecoder
getDecodeFileNameMethods 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- aPropertiesobject containing for each domain object the name of its data file or NULL
-
-
Method Details
-
getDisplayName
Description copied from interface:ILcdModelDecoderReturns a short, displayable name for the format that is decoded by thisILcdModelDecoder.- Specified by:
getDisplayNamein interfaceILcdModelDecoder- Returns:
- the displayable name of this
ILcdModelDecoder.
-
canDecodeSource
Returnstrueif 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
.tocfile in a directory, pointing to such a file
- Specified by:
canDecodeSourcein 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:ILcdDAFIFDecoderSpecifies 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:
setBoundsin interfaceILcdDAFIFDecoder- Parameters:
aBounds- the initial bounds for the model- See Also:
-
getBounds
Description copied from interface:ILcdDAFIFDecoderReturns the initial bounds for the model.- Specified by:
getBoundsin interfaceILcdDAFIFDecoder- Returns:
- the initial bounds for the model
- See Also:
-
getDecodingBounds
Description copied from interface:ILcdDAFIFDecoderReturns the bounds to filter on.- Specified by:
getDecodingBoundsin interfaceILcdDAFIFDecoder- Returns:
- the bounds to be filtered on
- See Also:
-
setDecodingBounds
Description copied from interface:ILcdDAFIFDecoderSpecifies 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:
setDecodingBoundsin 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:
setDomainFactoryin 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:
getDomainFactoryin interfaceILcdDAFIFDecoder- Returns:
- the domainFactory to be used to create domain objects
- See Also:
-
setDataObjectFactory
Description copied from interface:ILcdDAFIFDecoderSpecifies the factory to be used to create domain objects.The given factory must not be null.
- Specified by:
setDataObjectFactoryin interfaceILcdDAFIFDecoder- Parameters:
aFactory- the domainFactory to be used to create domain objects- See Also:
-
getDataObjectFactory
Description copied from interface:ILcdDAFIFDecoderReturns the Factory to be used to create domain objects.- Specified by:
getDataObjectFactoryin interfaceILcdDAFIFDecoder- Returns:
- the factory to be used to create domain objects
- See Also:
-
getErrorMessage
Description copied from interface:ILcdDAFIFDecoderReturns the error message of the last decode call.Note: the error message can only be retrieved once after a decode call.
- Specified by:
getErrorMessagein interfaceILcdDAFIFDecoder- Returns:
- a
Stringobject containing the errors occurred during the last decode process
-
getDAFIFProperties
Description copied from interface:ILcdDAFIFDecoderReturns a DAFIFPropertiesobject. The DAFIF properties contain -among other things- the links between domain objects and their data file names.- Specified by:
getDAFIFPropertiesin interfaceILcdDAFIFDecoder- Returns:
- the DAFIF
Propertiesobject that is used to retrieve the decode file name from - See Also:
-
setDAFIFProperties
Description copied from interface:ILcdDAFIFDecoderSpecifies aPropertiesobject containing the DAFIF properties. This object should contain for each domain object its data file name (e.g. source.refuelingTracksFile=FILE7).- Specified by:
setDAFIFPropertiesin interfaceILcdDAFIFDecoder- Parameters:
aDAFIFProperties- aPropertiesobject containing the DAFIF properties- See Also:
-
setDAFIFModelFilter
Description copied from interface:ILcdDAFIFDecoderSpecifies 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:
setDAFIFModelFilterin interfaceILcdDAFIFDecoder- Parameters:
aFilter- anILcdDAFIFModelFilterto filter the model objects
-
setInputStreamFactory
Sets the input stream factory that will be used for creating input streams given source names.- Specified by:
setInputStreamFactoryin 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:
getInputStreamFactoryin 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.Returnstrueif 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 eithertrueorfalseas argument automatically turns off tracing for all other class instances for whichsetTraceOnhas not been called. If the argument isfalsethen 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.tocfile into aPropertiesobject.- 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 theILcdGeodeticDatuminterface according to the specified code. For the code 'U' (unknown),nullis returned. If the code is not supported, anIllegalArgumentExceptionobject 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 theTLcdBearingTypeaccording to aType.If the given type is invalid, an
IllegalArgumentExceptionobject will be thrown.- Parameters:
aType- the code for the bearingType to be returned- Returns:
- the bearingType according to the given code
-
getAltitudeType
Returns aTLcdAltitudeTypeobject according to the code aAltitudeType.If the given type is invalid, an
IllegalArgumentExceptionobject 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 resultingStringafter trimming.The length should be larger than aMinLength. If it is, the trimmed
Stringis returned. If it is not, anIllegalArgumentExceptionobject 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 theStringto 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 theIllegalArgumentExceptionobject thrown if aMinLength is not reached)
-
read
Reads data from position aStart to aStart + aLength - 1 in aRecord, trims the resultingStringobject and returns it.- Parameters:
aRecord- the record to be read ofaStart- the start position for readingaLength- the length of theStringto be read- Returns:
- a trimmed
Stringobject
-
readExactValue
Reads from aRecord from position aStart to aStart + aLength - 1 and returns the resultingStringobject.The resulting
Stringis not trimmed!- Parameters:
aRecord- the record to be read ofaStart- the start position for readingaLength- the length of theStringto be read- Returns:
- the resulting
String, not trimmed!
-
getInputStream
Creates and returns anInputStreamobject 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
InputStreamobject 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:
setStoreOriginalReferencein interfaceILcdDAFIFDecoder
-
isStoreOriginalReference
public boolean isStoreOriginalReference()
-
getDataObjectFactory()