Class BinaryGuesser
java.lang.Object
org.apache.rat.document.impl.guesser.BinaryGuesser
TODO: factor into MIME guesser and MIME->binary guesser
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic booleancontainsExtension(String name, String[] exts)static booleanextensionMatches(String name, String[] exts)static booleanstatic booleanisBinary(InputStream in)static booleanstatic booleanstatic booleanstatic booleanisBinaryData(String name)static booleanisBytecode(String name)static booleanisExecutable(String name)static booleanstatic booleanisKeystore(String name)static booleanisNonBinary(String name)
-
Field Details
-
JAR_MANIFEST
- See Also:
- Constant Field Values
-
JAVA
- See Also:
- Constant Field Values
-
HIGH_BYTES_RATIO
public static final int HIGH_BYTES_RATIO- See Also:
- Constant Field Values
-
TOTAL_READ_RATIO
public static final int TOTAL_READ_RATIO- See Also:
- Constant Field Values
-
NON_ASCII_THRESHOLD
public static final int NON_ASCII_THRESHOLD- See Also:
- Constant Field Values
-
ASCII_CHAR_THRESHOLD
public static final int ASCII_CHAR_THRESHOLD- See Also:
- Constant Field Values
-
-
Constructor Details
-
BinaryGuesser
public BinaryGuesser()
-
-
Method Details
-
isBinary
- Parameters:
in- the file to check.- Returns:
- Do the first few bytes of the stream hint at a binary file?
Any IOException is swallowed internally and the test returns false.
This method may lead to false negatives if the reader throws an exception because it can't read characters according to the reader's encoding from the underlying stream.
-
isBinary
- Parameters:
in- the file to check.- Returns:
- Do the first few bytes of the stream hint at a binary file?
Any IOException is swallowed internally and the test returns false.
This method will try to read bytes from the stream and translate them to characters according to the platform's default encoding. If any bytes can not be translated to characters it will assume the original data must be binary and return true.
-
isBinaryData
- Parameters:
name- current file name.- Returns:
- whether given name is binary.
-
isNonBinary
- Parameters:
name- current file name.- Returns:
- Is a file by that name a known non-binary file?
-
isExecutable
- Parameters:
name- current file name.- Returns:
- Is a file by that name an executable/binary file?
-
containsExtension
-
extensionMatches
-
isBytecode
-
isImage
-
isKeystore
-
isAudio
-
isBinary
- Parameters:
name- file name.- Returns:
- Is a file by that name a known binary file?
-
isBinary
-