org.mycore.datamodel.ifs
Class MCRSimpleFCTDetector.MCRPatternRule
java.lang.Object
org.mycore.datamodel.ifs.MCRSimpleFCTDetector.MCRDetectionRule
org.mycore.datamodel.ifs.MCRSimpleFCTDetector.MCRPatternRule
- Enclosing class:
- MCRSimpleFCTDetector
class MCRSimpleFCTDetector.MCRPatternRule
- extends MCRSimpleFCTDetector.MCRDetectionRule
A rule that decides based on a magic bytes pattern that has to occur in
the file header at a given offset
|
Field Summary |
protected int |
offset
The offset where the magic bytes are located in the file header |
protected byte[] |
pattern
The byte pattern (magic bytes) |
|
Method Summary |
(package private) double |
getScore(String filename,
byte[] header)
Returns the score if filename and/or header matches this rule, or 0.0 |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
pattern
protected byte[] pattern
- The byte pattern (magic bytes)
offset
protected int offset
- The offset where the magic bytes are located in the file header
MCRSimpleFCTDetector.MCRPatternRule
MCRSimpleFCTDetector.MCRPatternRule(String pattern,
String format,
int offset,
double score)
- Creates a new rule for a match based on a magic bytes pattern at a
given offset
- Parameters:
pattern - the magic bytes pattern this rule matchesformat - the format in which the pattern is given, text | hex |
bytesoffset - the position where the pattern occurs in the file headerscore - the score for matching this rule, a value between 0.0 and
1.0
getScore
double getScore(String filename,
byte[] header)
- Description copied from class:
MCRSimpleFCTDetector.MCRDetectionRule
- Returns the score if filename and/or header matches this rule, or 0.0
- Specified by:
getScore in class MCRSimpleFCTDetector.MCRDetectionRule
- Parameters:
filename - the name of the file to detect the content type ofheader - the first bytes of the file content
- Returns:
- the score between 0.0 and 1.0 for matching this rule