| java.lang.Object org.mmbase.util.magicfile.Detector
Detector | public class Detector (Code) | | A Detector stores one entry from the magic.xml file, and contains
the functionality to determines if a certain byte[] satisfies it.
Implementation made on the basis of actual magic file and its manual.
TODO:
- link the info with mimetypes
- add test modifiers
- add commandline switches for warning, error and debugging messages
Ignored features of magic:
- date types
- indirect offsets (prefix of '&' in sublevel match or (address+bytes) where offset = value of address plus bytes
- AND'ing of type
BUGS:
- test string isn't read when end of line is reached in absence of a message string
Tested:
- .doc
- .rtf
- .pdf
- .sh
- .gz
- .bz2
- .html
- .rpm
- .wav
Not supported by magic file:
- StarOffice
version: $Id: Detector.java,v 1.13 2007/02/24 21:57:50 nklasens Exp $ |
Constructor Summary | |
| Detector() Detectors are instanciated by MagicXMLReader, and by Parser. |
Detector | Detector()(Code) | | Detectors are instanciated by MagicXMLReader, and by Parser.
|
addChild | public void addChild(Detector detector, int level)(Code) | | Add an embedded detector object that searches for more details after an initial match.
|
getComparator | public char getComparator()(Code) | | |
getDesignation | public String getDesignation()(Code) | | todo: I noticed there is also a %5.5s variation in magic...
|
getOffset | public int getOffset()(Code) | | |
getRawInput | public String getRawInput()(Code) | | Original unprocessed input line since: MMBase-1.7 |
setComparator | public void setComparator(char comparator)(Code) | | |
setDesignation | public void setDesignation(String designation)(Code) | | |
setExtension | public void setExtension(String extension)(Code) | | Adds a possible extension. The last added one is the default (returned by 'getExtension').
|
setInvalid | public void setInvalid()(Code) | | |
test | public boolean test(byte[] lithmus)(Code) | | Whether detector matches the prefix/lithmus of the file |
testByte | protected boolean testByte(byte[] lithmus)(Code) | | Test whether a byte matches
|
testLong | protected boolean testLong(byte[] lithmus, int endian)(Code) | | Test whether a long matches
|
testShort | protected boolean testShort(byte[] lithmus, int endian)(Code) | | Test whether a short matches
|
testString | protected boolean testString(byte[] lithmus)(Code) | | Test whether a string matches
|
toString | public String toString()(Code) | | String representation of Detector object. |
valid | public boolean valid()(Code) | | Whether parsing of magic line for this detector succeeded |
|
|