public class Magic extends Object
Constructor and Description |
---|
Magic()
constructor
|
Modifier and Type | Method and Description |
---|---|
static MagicMatch |
getMagicMatch(byte[] data)
get a match from a stream of data
|
static MagicMatch |
getMagicMatch(byte[] data,
boolean onlyMimeMatch)
get a match from a stream of data
|
static MagicMatch |
getMagicMatch(File file,
boolean extensionHints)
get a match from a file
|
static MagicMatch |
getMagicMatch(File file,
boolean extensionHints,
boolean onlyMimeMatch)
get a match from a file
|
static Collection<MagicMatcher> |
getMatchers()
return the parsed MagicMatch objects that were created from the magic.xml
definitions
|
static void |
initialize()
create a parser and initialize it
|
static void |
main(String[] args)
DOCUMENT ME!
|
static void |
printMagicFile(PrintStream stream)
print the contents of a magic file
|
static void |
printMagicMatch(PrintStream stream,
MagicMatch match,
String spacing)
print a magic match
|
public static void initialize() throws MagicParseException
MagicParseException
- DOCUMENT ME!public static Collection<MagicMatcher> getMatchers() throws MagicParseException
MagicParseException
- DOCUMENT ME!public static MagicMatch getMagicMatch(byte[] data) throws MagicParseException, MagicMatchNotFoundException, MagicException
data
- DOCUMENT ME!MagicParseException
- DOCUMENT ME!MagicMatchNotFoundException
- DOCUMENT ME!MagicException
- DOCUMENT ME!public static MagicMatch getMagicMatch(byte[] data, boolean onlyMimeMatch) throws MagicParseException, MagicMatchNotFoundException, MagicException
data
- DOCUMENT ME!onlyMimeMatch
- DOCUMENT ME!MagicParseException
- DOCUMENT ME!MagicMatchNotFoundException
- DOCUMENT ME!MagicException
- DOCUMENT ME!public static MagicMatch getMagicMatch(File file, boolean extensionHints) throws MagicParseException, MagicMatchNotFoundException, MagicException
file
- the file to match content inextensionHints
- whether or not to use extension to optimize order of content testsMagicParseException
- DOCUMENT ME!MagicMatchNotFoundException
- DOCUMENT ME!MagicException
- DOCUMENT ME!public static MagicMatch getMagicMatch(File file, boolean extensionHints, boolean onlyMimeMatch) throws MagicParseException, MagicMatchNotFoundException, MagicException
file
- the file to match content inextensionHints
- whether or not to use extension to optimize order of content testsonlyMimeMatch
- only try to get mime type, no submatches are processed when trueMagicParseException
- DOCUMENT ME!MagicMatchNotFoundException
- DOCUMENT ME!MagicException
- DOCUMENT ME!public static void printMagicFile(PrintStream stream) throws MagicParseException
stream
- DOCUMENT ME!MagicParseException
- DOCUMENT ME!public static void printMagicMatch(PrintStream stream, MagicMatch match, String spacing)
stream
- DOCUMENT ME!match
- DOCUMENT ME!spacing
- DOCUMENT ME!public static void main(String[] args)
args
- DOCUMENT ME!Copyright © 2017. All rights reserved.