org.apache.rat.document.impl.guesser
Class BinaryGuesser
java.lang.Object
org.apache.rat.document.impl.guesser.BinaryGuesser
public class BinaryGuesser
- extends Object
TODO: factor into MIME guesser and MIME->binary guesser
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
DATA_EXTENSIONS
public static final String[] DATA_EXTENSIONS
EXE_EXTENSIONS
public static final String[] EXE_EXTENSIONS
KEYSTORE_EXTENSIONS
public static final String[] KEYSTORE_EXTENSIONS
IMAGE_EXTENSIONS
public static final String[] IMAGE_EXTENSIONS
BYTECODE_EXTENSIONS
public static final String[] BYTECODE_EXTENSIONS
NON_BINARY_EXTENSIONS
public static final String[] NON_BINARY_EXTENSIONS
- Based on http://www.apache.org/dev/svn-eol-style.txt
JAR_MANIFEST
public static final String JAR_MANIFEST
- See Also:
- Constant Field Values
JAVA
public static final String 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_THREASHOLD
public static final int NON_ASCII_THREASHOLD
- See Also:
- Constant Field Values
ASCII_CHAR_THREASHOLD
public static final int ASCII_CHAR_THREASHOLD
- See Also:
- Constant Field Values
BinaryGuesser
public BinaryGuesser()
isBinary
public static boolean isBinary(Reader in)
- 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
public static boolean isBinary(InputStream in)
- 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
public static final boolean isBinaryData(String name)
- Parameters:
name
- current file name.
- Returns:
- whether given name is binary.
isNonBinary
public static final boolean isNonBinary(String name)
- Parameters:
name
- current file name.
- Returns:
- Is a file by that name a known non-binary file?
isExecutable
public static final boolean isExecutable(String name)
- Parameters:
name
- current file name.
- Returns:
- Is a file by that name an executable/binary file?
containsExtension
public static boolean containsExtension(String name,
String[] exts)
extensionMatches
public static boolean extensionMatches(String name,
String[] exts)
isBytecode
public static boolean isBytecode(String name)
isImage
public static final boolean isImage(String name)
isKeystore
public static final boolean isKeystore(String name)
isBinary
public static final boolean isBinary(String name)
- Parameters:
name
- file name.
- Returns:
- Is a file by that name a known binary file?
isBinary
public static final boolean isBinary(Document document)
Copyright © 2006–2014 Apache Software Foundation. All rights reserved.