Class TLcdModelReferenceDecoder

java.lang.Object
com.luciad.reference.TLcdModelReferenceDecoder
All Implemented Interfaces:
ILcdInputStreamFactoryCapable, ILcdModelReferenceDecoder

This ILcdModelReferenceDecoder decodes model references based on .ref property files corresponding to the given source files.

It first tries to find a .ref file by replacing the extension of the source file by .ref, or adding the suffix '.ref' if there was no extension. It preserves upper or lower case of the replaced extension.

If this fails, it tries to find a directory.ref file next to the source file.

If this fails, it tries to find a DIRECTORY.REF file next to the source file.

If this fails, it throws an IOException.

See Also:
  • Constructor Details

    • TLcdModelReferenceDecoder

      public TLcdModelReferenceDecoder()
  • Method Details

    • setInputStreamFactory

      public void setInputStreamFactory(ILcdInputStreamFactory aInputStreamFactory)
      Sets the input stream factory that will be used for accessing .ref files.
      Specified by:
      setInputStreamFactory in interface ILcdInputStreamFactoryCapable
      Parameters:
      aInputStreamFactory - the factory responsible to generate input streams from which the model reference will be decoded.
      See Also:
    • getInputStreamFactory

      public ILcdInputStreamFactory getInputStreamFactory()
      Returns the input stream factory that is used for accessing .ref files.
      Specified by:
      getInputStreamFactory in interface ILcdInputStreamFactoryCapable
      Returns:
      the factory responsible to generate input streams from which the model reference will be decoded.
      See Also:
    • decodeModelReference

      public ILcdModelReference decodeModelReference(String aDataSourceName) throws IOException
      Returns the model reference, associated with the specified data source. This implementation delegates to findAndDecodeModelReference(java.lang.String) and returns the resulting model reference.
      Specified by:
      decodeModelReference in interface ILcdModelReferenceDecoder
      Parameters:
      aDataSourceName - a data source for which to return the model reference; typically a file name or a URL.
      Returns:
      the ILcdModelReference associated with the data source. While null is allowed, implementors are advised to throw an error instead.
      Throws:
      IOException - if the ILcdModelReference cannot be decoded.
      When the thread on which this method is called is interrupted, it is recommended to stop the decoding and throw an InterruptedIOException. This same exception can also be used if the decoder shows UI to the user, and the user cancels the decoding through the UI.
    • findAndDecodeModelReference

      public ILcdModelReferenceDecoder.ModelReferenceWithSource findAndDecodeModelReference(String aSource) throws IOException
      Locates and decodes a model reference file based on the location of the data file. Location of the model reference file is done by
      1. replacing the suffix by '.ref', or adding the suffix '.ref' if there was no suffix. It preserves upper or lower case of the replaced extension.
      2. looking for a 'directory.ref' in the same directory,
      3. looking for a 'DIRECTORY.REF' in the same directory.
      If no such file is found, an IOException is thrown.
      Specified by:
      findAndDecodeModelReference in interface ILcdModelReferenceDecoder
      Parameters:
      aSource - the location of the data file for which to locate and decode a reference file.
      Returns:
      an ILcdModelReference decoded from one of the files as described above, along with the location of that file.
      Throws:
      IOException - if none of the files as described above exists, or when the file found cannot be decoded as a properties file.