Class FovDataFactory


  • public class FovDataFactory
    extends X3fDataFactory
    This class is the main entry point to this module. It provides methods for parsing X3F (FOVb) and X3I (FOVi) data.
    • Constructor Detail

      • FovDataFactory

        protected FovDataFactory()
        Protected constructor.
    • Method Detail

      • createByStandardParser

        protected static X3fData createByStandardParser​(RandomAccessData randomAccessData,
                                                        boolean skipFileType,
                                                        long offsetEmbedded)
        Passed through method from X3fDataFactory.
        Parameters:
        randomAccessData - the data source to read from
        skipFileType - true, if it is assumed, that the file type has already been checked before, false to have it checked
        offsetEmbedded - an offset within a surrounding file in which this FOVb is embedded
        Returns:
        the extracted X3F data or null, if it fails
      • createByRecoveryParser

        protected static X3fData createByRecoveryParser​(RandomAccessData randomAccessData,
                                                        boolean skipFileType,
                                                        long offsetEmbedded)
        Passed through method from X3fDataFactory.
        Parameters:
        randomAccessData - the data source to read from
        skipFileType - true, if it is assumed, that the file type has already been checked before, false to have it checked
        offsetEmbedded - an offset within a surrounding file in which this FOVb is embedded
        Returns:
        the extracted X3F data or null, if it fails
      • parseOrRecover

        public static void parseOrRecover​(byte[] bytes,
                                          boolean readFirstFOVbOnly,
                                          BiConsumer<RandomAccessData,​FovDataType> resultHandler)
                                   throws RandomAccessDataException
        Parses the given data source using the standard parser and if it fails, immediately tries the recovery parser.
        Parameters:
        bytes - the data to parse
        readFirstFOVbOnly - read only the first FOVb entry from FOVi
        resultHandler - callback to handle the parser result and to reuse the internally created RandomAccessData source, e.g. for extraction of embedded data. The RandomAccessData can only be used in the callback and will be closed afterwards.
        Throws:
        RandomAccessDataException - if an error occurs during data access
      • parseOrRecover

        public static <R> Optional<R> parseOrRecover​(byte[] bytes,
                                                     boolean readFirstFOVbOnly,
                                                     BiFunction<RandomAccessData,​FovDataType,​Optional<R>> resultHandler)
                                              throws RandomAccessDataException
        Parses the given data source using the standard parser and if it fails, immediately tries the recovery parser.
        Type Parameters:
        R - a generic return type for the callback handler
        Parameters:
        bytes - the data to parse
        readFirstFOVbOnly - read only the first FOVb entry from FOVi
        resultHandler - callback to handle the parser result and to reuse the internally created RandomAccessData source, e.g. for extraction of embedded data. The RandomAccessData can only be used in the callback and will be closed afterwards.
        Returns:
        the value passed through by the callback handler
        Throws:
        RandomAccessDataException - if an error occurs during data access
      • parseOrRecover

        public static void parseOrRecover​(File file,
                                          boolean readFirstFOVbOnly,
                                          BiConsumer<RandomAccessData,​FovDataType> resultHandler)
                                   throws RandomAccessDataException
        Parses the given data source using the standard parser and if it fails, immediately tries the recovery parser.
        Parameters:
        file - the file to parse
        readFirstFOVbOnly - read only the first FOVb entry from FOVi
        resultHandler - callback to handle the parser result and to reuse the internally created RandomAccessData source, e.g. for extraction of embedded data. The RandomAccessData can only be used in the callback and will be closed afterwards.
        Throws:
        RandomAccessDataException - if an error occurs during data access
      • parseOrRecover

        public static <R> Optional<R> parseOrRecover​(File file,
                                                     boolean readFirstFOVbOnly,
                                                     BiFunction<RandomAccessData,​FovDataType,​Optional<R>> resultHandler)
                                              throws RandomAccessDataException
        Parses the given data source using the standard parser and if it fails, immediately tries the recovery parser.
        Type Parameters:
        R - a generic return type for the callback handler
        Parameters:
        file - the file to parse
        readFirstFOVbOnly - read only the first FOVb entry from FOVi
        resultHandler - callback to handle the parser result and to reuse the internally created RandomAccessData source, e.g. for extraction of embedded data. The RandomAccessData can only be used in the callback and will be closed afterwards.
        Returns:
        the value passed through by the callback handler
        Throws:
        RandomAccessDataException - if an error occurs during data access
      • parseOrRecover

        public static void parseOrRecover​(Path file,
                                          boolean readFirstFOVbOnly,
                                          BiConsumer<RandomAccessData,​FovDataType> resultHandler)
                                   throws RandomAccessDataException
        Parses the given data source using the standard parser and if it fails, immediately tries the recovery parser.
        Parameters:
        file - the file to parse
        readFirstFOVbOnly - read only the first FOVb entry from FOVi
        resultHandler - callback to handle the parser result and to reuse the internally created RandomAccessData source, e.g. for extraction of embedded data. The RandomAccessData can only be used in the callback and will be closed afterwards.
        Throws:
        RandomAccessDataException - if an error occurs during data access
      • parseOrRecover

        public static <R> Optional<R> parseOrRecover​(Path file,
                                                     boolean readFirstFOVbOnly,
                                                     BiFunction<RandomAccessData,​FovDataType,​Optional<R>> resultHandler)
                                              throws RandomAccessDataException
        Parses the given data source using the standard parser and if it fails, immediately tries the recovery parser.
        Type Parameters:
        R - a generic return type for the callback handler
        Parameters:
        file - the file to parse
        readFirstFOVbOnly - read only the first FOVb entry from FOVi
        resultHandler - callback to handle the parser result and to reuse the internally created RandomAccessData source, e.g. for extraction of embedded data. The RandomAccessData can only be used in the callback and will be closed afterwards.
        Returns:
        the value passed through by the callback handler
        Throws:
        RandomAccessDataException - if an error occurs during data access
      • parse

        protected static FovDataType parse​(RandomAccessData data,
                                           boolean readFirstFOVbOnly,
                                           boolean recoveryMode,
                                           long offsetEmbedded)
        Parses the given data source and returns the result.
        Parameters:
        data - the FOV[b|i] data to parse
        readFirstFOVbOnly - true, if only the first FOVb entry should be read
        recoveryMode - true to use a recovery mode for damaged data
        offsetEmbedded - offset for embedded data (e.g. X3F embedded in X3I)
        Returns:
        the parser result