net.sf.jmimemagic
Class Magic

java.lang.Object
  extended bynet.sf.jmimemagic.Magic

public class Magic
extends java.lang.Object

This class is the primary class for jMimeMagic

Version:
$Revision: 1.8 $
Author:
$Author: arimus $

Constructor Summary
Magic()
          constructor
 
Method Summary
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(java.io.File file, boolean extensionHints)
          get a match from a file
static MagicMatch getMagicMatch(java.io.File file, boolean extensionHints, boolean onlyMimeMatch)
          get a match from a file
static java.util.Collection 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(java.lang.String[] args)
          DOCUMENT ME!
static void printMagicFile(java.io.PrintStream stream)
          print the contents of a magic file
static void printMagicMatch(java.io.PrintStream stream, MagicMatch match, java.lang.String spacing)
          print a magic match
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Magic

public Magic()
constructor

Method Detail

initialize

public static void initialize()
                       throws MagicParseException
create a parser and initialize it

Throws:
MagicParseException - DOCUMENT ME!

getMatchers

public static java.util.Collection getMatchers()
                                        throws MagicParseException
return the parsed MagicMatch objects that were created from the magic.xml definitions

Returns:
the parsed MagicMatch objects
Throws:
MagicParseException - DOCUMENT ME!

getMagicMatch

public static MagicMatch getMagicMatch(byte[] data)
                                throws MagicParseException,
                                       MagicMatchNotFoundException,
                                       MagicException
get a match from a stream of data

Parameters:
data - DOCUMENT ME!
Returns:
DOCUMENT ME!
Throws:
MagicParseException - DOCUMENT ME!
MagicMatchNotFoundException - DOCUMENT ME!
MagicException - DOCUMENT ME!

getMagicMatch

public static MagicMatch getMagicMatch(byte[] data,
                                       boolean onlyMimeMatch)
                                throws MagicParseException,
                                       MagicMatchNotFoundException,
                                       MagicException
get a match from a stream of data

Parameters:
data - DOCUMENT ME!
onlyMimeMatch - DOCUMENT ME!
Returns:
DOCUMENT ME!
Throws:
MagicParseException - DOCUMENT ME!
MagicMatchNotFoundException - DOCUMENT ME!
MagicException - DOCUMENT ME!

getMagicMatch

public static MagicMatch getMagicMatch(java.io.File file,
                                       boolean extensionHints)
                                throws MagicParseException,
                                       MagicMatchNotFoundException,
                                       MagicException
get a match from a file

Parameters:
file - the file to match content in
extensionHints - whether or not to use extension to optimize order of content tests
Returns:
the MagicMatch object representing a match in the file
Throws:
MagicParseException - DOCUMENT ME!
MagicMatchNotFoundException - DOCUMENT ME!
MagicException - DOCUMENT ME!

getMagicMatch

public static MagicMatch getMagicMatch(java.io.File file,
                                       boolean extensionHints,
                                       boolean onlyMimeMatch)
                                throws MagicParseException,
                                       MagicMatchNotFoundException,
                                       MagicException
get a match from a file

Parameters:
file - the file to match content in
extensionHints - whether or not to use extension to optimize order of content tests
onlyMimeMatch - only try to get mime type, no submatches are processed when true
Returns:
the MagicMatch object representing a match in the file
Throws:
MagicParseException - DOCUMENT ME!
MagicMatchNotFoundException - DOCUMENT ME!
MagicException - DOCUMENT ME!

printMagicFile

public static void printMagicFile(java.io.PrintStream stream)
                           throws MagicParseException
print the contents of a magic file

Parameters:
stream - DOCUMENT ME!
Throws:
MagicParseException - DOCUMENT ME!

printMagicMatch

public static void printMagicMatch(java.io.PrintStream stream,
                                   MagicMatch match,
                                   java.lang.String spacing)
print a magic match

Parameters:
stream - DOCUMENT ME!
match - DOCUMENT ME!
spacing - DOCUMENT ME!

main

public static void main(java.lang.String[] args)
DOCUMENT ME!

Parameters:
args - DOCUMENT ME!


Copyright © 2003-2006 none. All Rights Reserved.