|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.mmbase.util.magicfile.AbstractDetector
org.mmbase.util.magicfile.BasicDetector
public class BasicDetector
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
| Field Summary |
|---|
| Fields inherited from class org.mmbase.util.magicfile.AbstractDetector |
|---|
childList, message, valid |
| Constructor Summary | |
|---|---|
BasicDetector()
|
|
| Method Summary | |
|---|---|
void |
configure(Element e)
|
char |
getComparator()
|
String |
getDesignation()
todo: I noticed there is also a %5.5s variation in magic... |
int |
getOffset()
|
String |
getRawInput()
|
String |
getTest()
|
String |
getType()
|
void |
setComparator(char comparator)
|
void |
setOffset(String offset)
|
void |
setTest(String test)
|
void |
setType(String type)
|
boolean |
test(byte[] lithmus)
|
protected boolean |
testByte(byte[] lithmus)
Test whether a byte matches |
protected boolean |
testLong(byte[] lithmus,
int endian)
Test whether a long matches |
protected boolean |
testShort(byte[] lithmus,
int endian)
Test whether a short matches |
protected boolean |
testString(byte[] lithmus)
Test whether a string matches |
String |
toString()
|
void |
toXML(FileWriter f)
XML notatie: |
void |
toXML(FileWriter f,
int level)
|
protected String |
xmlEntities(String s)
|
| Methods inherited from class org.mmbase.util.magicfile.AbstractDetector |
|---|
addChild, getExtension, getExtensions, getMimeType, setDesignation, setExtension, setMimeType, setValid, valid |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public BasicDetector()
| Method Detail |
|---|
public void setOffset(String offset)
public int getOffset()
public void setType(String type)
public String getType()
public void setTest(String test)
public String getTest()
public void setComparator(char comparator)
public char getComparator()
public boolean test(byte[] lithmus)
public String getDesignation()
getDesignation in interface DetectorgetDesignation in class AbstractDetectorprotected boolean testString(byte[] lithmus)
protected boolean testShort(byte[] lithmus,
int endian)
protected boolean testLong(byte[] lithmus,
int endian)
protected boolean testByte(byte[] lithmus)
public String getRawInput()
protected String xmlEntities(String s)
public void toXML(FileWriter f)
throws IOException
IOException
public void toXML(FileWriter f,
int level)
throws IOException
level - Indicates depth of (child) element
IOExceptionpublic void configure(Element e)
configure in interface Detectorconfigure in class AbstractDetectorpublic String toString()
toString in class AbstractDetector
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||