org.mmbase.util.magicfile
Class MagicParser

java.lang.Object
  extended by org.mmbase.util.magicfile.MagicParser
All Implemented Interfaces:
DetectorProvider

public class MagicParser
extends Object
implements DetectorProvider

This Parser translates the configuration file of UNIX's file to a list of Detectors (and to a magic.xml)

Version:
$Id: MagicParser.java 41710 2010-04-01 08:58:34Z michiel $

Field Summary
static String DEFAULT_MAGIC_FILE
          the default files used to create the Detectors DEFAULT_MAGIC_FILE = "/etc/mime-magic"
 
Constructor Summary
MagicParser()
           
MagicParser(String fileName)
          Construct a new MagicParser with configuration file
 
Method Summary
 List<Detector> getDetectors()
           
static void main(String[] argv)
           
protected  int nextNonWhiteSpace(String s, int startIndex)
           
protected  int nextWhiteSpace(String s)
           
protected  int nextWhiteSpace(String s, int startIndex)
           
 boolean toXML(File f)
          Write the current data structure to an XML file
 boolean toXML(String path)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_MAGIC_FILE

public static final String DEFAULT_MAGIC_FILE
the default files used to create the Detectors DEFAULT_MAGIC_FILE = "/etc/mime-magic"

See Also:
Constant Field Values
Constructor Detail

MagicParser

public MagicParser()

MagicParser

public MagicParser(String fileName)
Construct a new MagicParser with configuration file

Parameters:
fileName - File which contains the magic data
Since:
MMBase-1.7
Method Detail

getDetectors

public List<Detector> getDetectors()
Specified by:
getDetectors in interface DetectorProvider

nextWhiteSpace

protected int nextWhiteSpace(String s)

nextWhiteSpace

protected int nextWhiteSpace(String s,
                             int startIndex)

nextNonWhiteSpace

protected int nextNonWhiteSpace(String s,
                                int startIndex)

toXML

public boolean toXML(String path)
              throws IOException
Throws:
IOException

toXML

public boolean toXML(File f)
              throws IOException
Write the current data structure to an XML file

Parameters:
f - File to write to
Returns:
written successful or not
Throws:
IOException - Throws an exception when parsing failed

main

public static void main(String[] argv)
                 throws IOException
Throws:
IOException


MMBase 2.0-SNAPSHOT - null