Package emissary.util
Class UnixFile
- java.lang.Object
-
- emissary.util.UnixFile
-
public class UnixFile extends Object
-
-
Field Summary
Fields Modifier and Type Field Description static String
FILETYPE_ASCII
The ASCII file type descriptionstatic String
FILETYPE_BINARY
The Binary file type descriptionstatic String
FILETYPE_EMPTY
The empty file type description
-
Constructor Summary
Constructors Constructor Description UnixFile(File magicFile)
Constructor to load instance using the specified File.UnixFile(File magicFile, boolean swallowParseException)
Constructor to load instance using the specified File.UnixFile(List<String> magicPaths)
Load multiple magic files into one identification engineUnixFile(List<String> magicPaths, boolean swallowParseException)
Load multiple magic files into one identification engine
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static String
evaluateBinaryProperty(byte[] bytes)
Statically tests a byte array to determine if the file representation can be of type ASCII or is binary.String
evaluateByMagicNumber(byte[] bytes)
Evaluates the byte array against the collection of Magic numbersString
execute(byte[] bytes)
Behaves just like the UNIX file command.int
magicEntryCount()
static void
main(String[] args)
Test standalone main
-
-
-
Field Detail
-
FILETYPE_BINARY
public static final String FILETYPE_BINARY
The Binary file type description- See Also:
- Constant Field Values
-
FILETYPE_ASCII
public static final String FILETYPE_ASCII
The ASCII file type description- See Also:
- Constant Field Values
-
FILETYPE_EMPTY
public static final String FILETYPE_EMPTY
The empty file type description- See Also:
- Constant Field Values
-
-
Constructor Detail
-
UnixFile
public UnixFile(File magicFile) throws IOException
Constructor to load instance using the specified File. If the specified file is invalid, an exception will be thrown when attempting utilize theexecute
method.- Parameters:
magicFile
- theFile
containing magic number entries- Throws:
IOException
-
UnixFile
public UnixFile(File magicFile, boolean swallowParseException) throws IOException
Constructor to load instance using the specified File. If the specified file is invalid, an exception will be thrown when attempting utilize theexecute
method.- Parameters:
magicFile
- theFile
containing magic number entriesswallowParseException
- should we swallow Ignorable ParseException or bubble them up- Throws:
IOException
-
UnixFile
public UnixFile(List<String> magicPaths) throws IOException
Load multiple magic files into one identification engine- Parameters:
magicPaths
- the String names of magic files to load- Throws:
IOException
-
UnixFile
public UnixFile(List<String> magicPaths, boolean swallowParseException) throws IOException
Load multiple magic files into one identification engine- Parameters:
magicPaths
- the String names of magic files to loadswallowParseException
- should we swallow Ignorable ParseException or bubble them up- Throws:
IOException
-
-
Method Detail
-
magicEntryCount
public int magicEntryCount()
-
execute
public String execute(@Nullable byte[] bytes) throws IOException
Behaves just like the UNIX file command. First performs a magic number test, then an ascii or binary file test. This is also the same as callingevaluateByMagicNumber (bytes : byte[])
and then callingevaluateBinaryProperty (bytes : byte[])
- Throws:
IOException
-
evaluateBinaryProperty
public static String evaluateBinaryProperty(@Nullable byte[] bytes)
Statically tests a byte array to determine if the file representation can be of type ASCII or is binary. Simply checks each byte value to be less then greater/equal then 127.
-
evaluateByMagicNumber
public String evaluateByMagicNumber(byte[] bytes) throws IOException
Evaluates the byte array against the collection of Magic numbers- Throws:
IOException
-
-