Class ALcyFileFormat


public abstract class ALcyFileFormat extends ALcyGeneralFormat

Extension of ALcyGeneralFormat that assumes working with files on disk. It assumes that the concrete subclass will implement the ALcyFormat.createModelDecoders() method and return an array containing a single ILcdModelDecoder:


   public class MyFormat extends ALcyFileFormat{
     ...
     @Override
     protected ILcdModelDecoder[] createModelDecoders(){
       return new ILcdModelDecoder[]{
         new MyFormatModelDecoder();
       }
     }
   }
 

In return, this format will provide a ALcyFileTypeDescriptor for that model decoder (see createModelDecoderFileTypeDescriptors() and createModelDecoderFileTypeDescriptorGroups()). The returned ALcyFileTypeDescriptor is parsed from the configuration file. The configuration file supports the following properties (where propertyPrefix. is the property prefix passed in the constructor):


   # This is the text that will be presented to the user to describe the format.
   # For example when using File | Open, the file chooser will contain this text
   propertyPrefix.fileTypeDescriptor.displayName = My Files

   # The default extension, that can be used encoding a model corresponding to this
   # file type descriptor. This default extension is used if
   # data needs to be saved in the format, and the user does
   # not enter the extension himself.
   # The extensions do not include the dot (.)
   propertyPrefix.fileTypeDescriptor.defaultExtension = ext

   # Comma separated list that contains the patterns to which
   # the filenames of the format needs to match.
   # E.g. "*.ext, SomePrefix*, *SomeSuffix" means that not only the files with extension "ext" will pass the filter,
   # but also all files which start with "SomePrefix" and the ones which end on "SomeSuffix".
   propertyPrefix.fileTypeDescriptor.filters = *.ext

   # Comma separated list of the display names of the groups to which this file type filters
   # must be added. E.g. "All Raster Files, SomeOtherGroup" means that this file type descriptor will
   # be added to both the "All Raster Files" and the "SomeOtherGroup" group.
   # These ID's are used to group several formats, so that the user can filter on a group basis. Eg. (s)he might only want
   # to see all raster files.
   # Note that there is a default "All Known Files" group, this group should not be added to the list, because every file type
   # descriptor which is registered to the ILcyLucyEnv is by default added to the "All Known Files" group.
   propertyPrefix.fileTypeDescriptor.groupIDs = All Vector Files
 

The configured file type descriptor will also be returned by the createModelEncoderFileTypeDescriptors() method when the concrete subclass implements the ALcyFormat.createModelEncoders() method and returns exactly one model encoder. Consult the javadoc of the createModelEncoderFileTypeDescriptors method for more details.

Note that when the concrete subclass creates multiple model decoder and/or encoder instances, it will be responsible to create file type descriptors for all those decoders and encoders by overriding the corresponding methods.

  • Constructor Details

    • ALcyFileFormat

      @Deprecated protected ALcyFileFormat(ILcyLucyEnv aLucyEnv, Class aClass, ALcyProperties aProperties)
      Deprecated.
      Better use the constructor with explicit long and short prefix, to avoid any confusion. Functionally equivalent to ALcyFileFormat(aLucyEnv, ALcyTool.getLongPrefix(aClass), ALcyTool.getShortPrefix(aClass), aProperties).
      Parameters:
      aLucyEnv - The Lucy backend for which to create this format. Must not be null.
      aClass - A representative class for using this ALcyApplicationPaneTool, normally an extension of ALcyAddOn. It is used to retrieve the long and short prefixes using getLongPrefix and getShortPrefix. These prefixes are stored in workspace files, so if backward compatibility is a concern (e.g. read an old workspace file), the given class or its name must never change.
      aProperties - The ALcyProperties holding the configuration of this format. Must not be null.
      See Also:
    • ALcyFileFormat

      protected ALcyFileFormat(ILcyLucyEnv aLucyEnv, String aLongPrefix, String aShortPrefix, ALcyProperties aProperties)

      Creates a ALcyFileFormat for the specified Lucy backend and configuration. Shorthand for ALcyFileFormat( aLucyEnv, aLongPrefix, aShortPrefix, aProperties, aShortPrefix )

      Parameters:
      aLucyEnv - The Lucy backend for which this format is created. Must not be null.
      aLongPrefix - The long prefix of this format. Must not be null.
      aShortPrefix - The short prefix of this format. This prefix will also be set as the property prefix and be used when reading values from aProperties. See ALcyGeneralFormat.getShortPrefix() and ALcyGeneralFormat.getPropertyPrefix(). Must not be null.
      aProperties - The ALcyProperties holding the configuration of this format. Must not be null.
    • ALcyFileFormat

      protected ALcyFileFormat(ILcyLucyEnv aLucyEnv, String aLongPrefix, String aShortPrefix, ALcyProperties aProperties, String aPropertyPrefix)

      Creates a ALcyFileFormat for the specified Lucy backend and properties.

      Parameters:
      aLucyEnv - The Lucy backend for which this format is created. Must not be null.
      aLongPrefix - The long prefix of this format. Must not be null.
      aShortPrefix - The short prefix of this format. Must not be null.
      aProperties - The ALcyProperties holding the configuration of this format. Must not be null.
      aPropertyPrefix - The prefix to use when deriving keys to use for the ALcyProperties.
  • Method Details

    • createModelDecoderFileTypeDescriptors

      protected ALcyFileTypeDescriptor[] createModelDecoderFileTypeDescriptors()

      Creates the ALcyFileTypeDescriptor instances corresponding to the ILcdModelDecoder instances created by this format.

      This implementation returns an array with only one element, parsed from the properties as described in the class comment. If there is not exactly one ILcdModelDecoder created, this method must be overridden to return an array of matching length.

      Specified by:
      createModelDecoderFileTypeDescriptors in class ALcyFormat
      Returns:
      The array of ALcyFileTypeDescriptor instances. Must not be null. Its length should be equal to the length of the array created by createModelDecoders. It may contain null.
    • createModelDecoderFileTypeDescriptorGroups

      protected String[][] createModelDecoderFileTypeDescriptorGroups()

      Creates file type descriptor groups for all decoders. The groups may be empty, but the group count must equal the decoder count.

      This implementation returns an array with only one element, parsed from the properties as described in the class comment. If there is not exactly one ILcdModelDecoder created, this method must be overridden to return an array of matching length.

      Overrides:
      createModelDecoderFileTypeDescriptorGroups in class ALcyFormat
      Returns:
      A two-dimensional array containing the groups for the ALcyFileTypeDescriptor instances of the ILcdModelDecoders. The first dimension must be equal to the length of the array of ILcdModelDecoder instances created by this format. It must not contain null, but may contain empty arrays.
    • createModelEncoderFileTypeDescriptors

      protected ALcyFileTypeDescriptor[] createModelEncoderFileTypeDescriptors()

      Creates the array of ALcyFileTypeDescriptor instances for the ILcdModelEncoder instances created by this format.

      When the ALcyFormat.createModelEncoders() and ALcyFormat.createModelDecoders() methods both return exactly one instance, this method will return the ALcyFileTypeDescriptor which is configured in the configuration file.

      Overrides:
      createModelEncoderFileTypeDescriptors in class ALcyFormat
      Returns:
      The array of ALcyFileTypeDescriptor instances. Must not be null and its length must be equal to the length of the array of ILcdModelEncoder instances created by this format. May contain null.
      See Also: