Class ALcdDAFIFDecoder

java.lang.Object
com.luciad.format.dafif.decoder.ALcdDAFIFDecoder
All Implemented Interfaces:
ILcdDAFIFDecoder, ILcdInputStreamFactoryCapable, ILcdModelDecoder
Direct Known Subclasses:
ALcdDAFIFMultiModelDecoder, ALcdDAFIFSingleModelDecoder

public abstract class ALcdDAFIFDecoder extends Object implements ILcdDAFIFDecoder, ILcdInputStreamFactoryCapable
This abstract implementation of the 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 Details

    • DAFIF_PROP_EXTENSION

      protected static final String DAFIF_PROP_EXTENSION
      See Also:
    • fRecordCount

      protected int fRecordCount
      Number of the current record.
  • Constructor Details

    • ALcdDAFIFDecoder

      public ALcdDAFIFDecoder(Properties aDAFIFProperties)
      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 - a Properties object containing for each domain object the name of its data file or NULL
  • Method Details

    • getDisplayName

      public String getDisplayName()
      Description copied from interface: ILcdModelDecoder
      Returns a short, displayable name for the format that is decoded by this ILcdModelDecoder.
      Specified by:
      getDisplayName in interface ILcdModelDecoder
      Returns:
      the displayable name of this ILcdModelDecoder.
    • canDecodeSource

      public 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
      Specified by:
      canDecodeSource in interface ILcdModelDecoder
      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

      public void setBounds(ILcdBounds aBounds)
      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 interface ILcdDAFIFDecoder
      Parameters:
      aBounds - the initial bounds for the model
      See Also:
    • getBounds

      public ILcdBounds getBounds()
      Description copied from interface: ILcdDAFIFDecoder
      Returns the initial bounds for the model.
      Specified by:
      getBounds in interface ILcdDAFIFDecoder
      Returns:
      the initial bounds for the model
      See Also:
    • getDecodingBounds

      public ILcdBounds getDecodingBounds()
      Description copied from interface: ILcdDAFIFDecoder
      Returns the bounds to filter on.
      Specified by:
      getDecodingBounds in interface ILcdDAFIFDecoder
      Returns:
      the bounds to be filtered on
      See Also:
    • setDecodingBounds

      public void setDecodingBounds(ILcdBounds aBoundsToFilterOn)
      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 interface ILcdDAFIFDecoder
      Parameters:
      aBoundsToFilterOn - the bounds to be used as a filter
      See Also:
    • setDomainFactory

      @Deprecated public void setDomainFactory(ALcdAISObjectFactory aDomainFactory)
      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 interface ILcdDAFIFDecoder
      Parameters:
      aDomainFactory - the domainFactory to be used to create domain objects
      See Also:
    • getDomainFactory

      @Deprecated public ALcdAISObjectFactory getDomainFactory()
      Deprecated.
      Returns the domainFactory to be used to create domain objects.
      Specified by:
      getDomainFactory in interface ILcdDAFIFDecoder
      Returns:
      the domainFactory to be used to create domain objects
      See Also:
    • setDataObjectFactory

      public void setDataObjectFactory(TLcdAISDataObjectFactory aFactory)
      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 interface ILcdDAFIFDecoder
      Parameters:
      aFactory - the domainFactory to be used to create domain objects
      See Also:
    • getDataObjectFactory

      public TLcdAISDataObjectFactory getDataObjectFactory()
      Description copied from interface: ILcdDAFIFDecoder
      Returns the Factory to be used to create domain objects.
      Specified by:
      getDataObjectFactory in interface ILcdDAFIFDecoder
      Returns:
      the factory to be used to create domain objects
      See Also:
    • getErrorMessage

      public String 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 interface ILcdDAFIFDecoder
      Returns:
      a String object containing the errors occurred during the last decode process
    • getDAFIFProperties

      public Properties getDAFIFProperties()
      Description copied from interface: ILcdDAFIFDecoder
      Returns a DAFIF Properties object. The DAFIF properties contain -among other things- the links between domain objects and their data file names.
      Specified by:
      getDAFIFProperties in interface ILcdDAFIFDecoder
      Returns:
      the DAFIF Properties object that is used to retrieve the decode file name from
      See Also:
    • setDAFIFProperties

      public void setDAFIFProperties(Properties aDAFIFProperties)
      Description copied from interface: ILcdDAFIFDecoder
      Specifies a Properties 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 interface ILcdDAFIFDecoder
      Parameters:
      aDAFIFProperties - a Properties object containing the DAFIF properties
      See Also:
    • setDAFIFModelFilter

      public void setDAFIFModelFilter(ILcdDAFIFModelFilter aFilter)
      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 interface ILcdDAFIFDecoder
      Parameters:
      aFilter - an ILcdDAFIFModelFilter to filter the model objects
    • setInputStreamFactory

      public void setInputStreamFactory(ILcdInputStreamFactory aInputStreamFactory)
      Sets the input stream factory that will be used for creating input streams given source names.
      Specified by:
      setInputStreamFactory in interface ILcdInputStreamFactoryCapable
      Parameters:
      aInputStreamFactory - the input stream factory to be used.
    • getInputStreamFactory

      public ILcdInputStreamFactory getInputStreamFactory()
      Returns the input stream factory that is currently used for creating input streams given source names.
      Specified by:
      getInputStreamFactory in interface ILcdInputStreamFactoryCapable
      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.
      Returns true 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 either 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.
      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

      protected ILcdDAFIFModelFilter getModelFilter()
    • loadCFGProperties

      protected void loadCFGProperties(String aSource)
      Loads the dafif.toc file into a Properties object.
      Parameters:
      aSource - the path to the dafif.toc file. this path should include the dafif.toc file name.
    • addErrorReport

      protected void addErrorReport(String aErrorReport)
      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

      protected char[] readRecord(BufferedReader aReader) throws IOException
      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

      protected ILcdGeodeticDatum getLocalHorizontalDatum(String aGeodeticDatumCode)
      Returns an instance of an implementation of the 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.

      Parameters:
      aGeodeticDatumCode - the code for the geodetic datum to be returned
      Returns:
      the geodetic datum according to the given code
    • getBearingTypeForChar

      protected TLcdBearingType getBearingTypeForChar(char aType)
      Returns the TLcdBearingType 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

      protected TLcdAltitudeType getAltitudeType(String aAltitudeType)
      Returns a TLcdAltitudeType 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 resulting 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.

      Parameters:
      aRecord - the record to be read of
      aStart - the start position for reading
      aLength - the length of the String to be read
      aMinLength - the length of the result should be larger than this parameter
      aFieldName - the name of the field whose data has been reading by this method (used in the IllegalArgumentException object thrown if aMinLength is not reached)
    • read

      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.
      Parameters:
      aRecord - the record to be read of
      aStart - the start position for reading
      aLength - the length of the String to be read
      Returns:
      a trimmed String object
    • readExactValue

      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.

      The resulting String is not trimmed!

      Parameters:
      aRecord - the record to be read of
      aStart - the start position for reading
      aLength - the length of the String to be read
      Returns:
      the resulting String, not trimmed!
    • getInputStream

      protected InputStream getInputStream(String aSource) throws IOException
      Creates and returns an InputStream 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 (see getDecodeFileName()).
      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

      protected void transformPointToReferenceDatumSFCT(ILcd3DEditablePoint aPointSFCT)
      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 interface ILcdDAFIFDecoder
    • isStoreOriginalReference

      public boolean isStoreOriginalReference()