- java.lang.Object
-
- de.bernd_michaely.x3f.types.X3fDataFactory
-
- de.bernd_michaely.x3i.types.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.
-
-
Field Summary
-
Fields inherited from class de.bernd_michaely.x3f.types.X3fDataFactory
FOVB_ID_FILE_TYPE, FOVB_ID_SECTION_DIRECTORY
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
FovDataFactory()
Protected constructor.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description protected static X3fData
createByRecoveryParser(RandomAccessData randomAccessData, boolean skipFileType, long offsetEmbedded)
Passed through method from X3fDataFactory.protected static X3fData
createByStandardParser(RandomAccessData randomAccessData, boolean skipFileType, long offsetEmbedded)
Passed through method from X3fDataFactory.static FovDataType
parse(RandomAccessData data, boolean readFirstFOVbOnly)
Parses the given data source using a standard parser.protected static FovDataType
parse(RandomAccessData data, boolean readFirstFOVbOnly, boolean recoveryMode, long offsetEmbedded)
Parses the given data source and returns the result.static void
parseOrRecover(byte[] bytes, boolean readFirstFOVbOnly, BiConsumer<RandomAccessData,FovDataType> resultHandler)
Parses the given data source using the standard parser and if it fails, immediately tries the recovery parser.static <R> Optional<R>
parseOrRecover(byte[] bytes, boolean readFirstFOVbOnly, BiFunction<RandomAccessData,FovDataType,Optional<R>> resultHandler)
Parses the given data source using the standard parser and if it fails, immediately tries the recovery parser.static void
parseOrRecover(File file, boolean readFirstFOVbOnly, BiConsumer<RandomAccessData,FovDataType> resultHandler)
Parses the given data source using the standard parser and if it fails, immediately tries the recovery parser.static <R> Optional<R>
parseOrRecover(File file, boolean readFirstFOVbOnly, BiFunction<RandomAccessData,FovDataType,Optional<R>> resultHandler)
Parses the given data source using the standard parser and if it fails, immediately tries the recovery parser.static void
parseOrRecover(Path file, boolean readFirstFOVbOnly, BiConsumer<RandomAccessData,FovDataType> resultHandler)
Parses the given data source using the standard parser and if it fails, immediately tries the recovery parser.static <R> Optional<R>
parseOrRecover(Path file, boolean readFirstFOVbOnly, BiFunction<RandomAccessData,FovDataType,Optional<R>> resultHandler)
Parses the given data source using the standard parser and if it fails, immediately tries the recovery parser.static FovDataType
recover(RandomAccessData data)
Parses the given data source using a recovery parser.-
Methods inherited from class de.bernd_michaely.x3f.types.X3fDataFactory
createByCombinedParser, createByRecoveryParser, createByStandardParser
-
-
-
-
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 fromskipFileType
- true, if it is assumed, that the file type has already been checked before, false to have it checkedoffsetEmbedded
- 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 fromskipFileType
- true, if it is assumed, that the file type has already been checked before, false to have it checkedoffsetEmbedded
- 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 parsereadFirstFOVbOnly
- read only the first FOVb entry from FOViresultHandler
- 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 parsereadFirstFOVbOnly
- read only the first FOVb entry from FOViresultHandler
- 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 parsereadFirstFOVbOnly
- read only the first FOVb entry from FOViresultHandler
- 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 parsereadFirstFOVbOnly
- read only the first FOVb entry from FOViresultHandler
- 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 parsereadFirstFOVbOnly
- read only the first FOVb entry from FOViresultHandler
- 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 parsereadFirstFOVbOnly
- read only the first FOVb entry from FOViresultHandler
- 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
public static FovDataType parse(RandomAccessData data, boolean readFirstFOVbOnly)
Parses the given data source using a standard parser. In the case of accessing a file directly, it is strongly recommended for performance reasons to use aRandomAccessFile
based access likeRandomAccessDataFactory.createInstance(File, AccessType)
usingAccessType.RANDOM
.- Parameters:
data
- the FOV[b|i] data to parsereadFirstFOVbOnly
- read only the first FOVb entry from FOVi- Returns:
- the parser result
- See Also:
parseOrRecover(File, boolean, BiConsumer)
-
recover
public static FovDataType recover(RandomAccessData data)
Parses the given data source using a recovery parser. In the case of accessing a file directly, it is strongly recommended for performance reasons to use aFileInputStream
based access likeRandomAccessDataFactory.createInstance(File, AccessType)
usingAccessType.STREAM
.- Parameters:
data
- the FOV[b|i] data to parse- Returns:
- the parser result
-
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 parsereadFirstFOVbOnly
- true, if only the first FOVb entry should be readrecoveryMode
- true to use a recovery mode for damaged dataoffsetEmbedded
- offset for embedded data (e.g. X3F embedded in X3I)- Returns:
- the parser result
-
-