Package net.sf.jmimemagic
Class MagicMatch
- java.lang.Object
-
- net.sf.jmimemagic.MagicMatch
-
- All Implemented Interfaces:
java.io.Serializable
,java.lang.Cloneable
public final class MagicMatch extends java.lang.Object implements java.lang.Cloneable, java.io.Serializable
This class represents a single match test- Version:
- $Revision: 1.10 $
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description private long
bitmask
private char
comparator
private java.lang.String
description
private java.lang.String
extension
private int
length
private java.lang.String
mimeType
private int
offset
private java.util.Map<java.lang.String,java.lang.String>
properties
private static long
serialVersionUID
private java.util.ArrayList<MagicMatch>
subMatches
private byte[]
test
private java.lang.String
type
-
Constructor Summary
Constructors Constructor Description MagicMatch()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addSubMatch(MagicMatch m)
Add a submatch to this magic match.protected java.lang.Object
clone()
boolean
descriptionMatches(java.lang.String desc)
determine if this match or any submatches has the descriptionlong
getBitmask()
get the bitmask that will be applied for this magic matchchar
getComparator()
get the comparator for this magic matchjava.lang.String
getDescription()
Get the description for this magic match.java.lang.String
getExtension()
Get the extension for this magic match.int
getLength()
get the length we are restricting the comparison to for this magic matchjava.lang.String
getMimeType()
Get the magic match for this magic match.int
getOffset()
get the offset in the stream we are comparing to the test value for this magic matchjava.util.Map<java.lang.String,java.lang.String>
getProperties()
get the properties for this magic matchjava.util.Collection<MagicMatch>
getSubMatches()
get all submatches for this magic matchjava.nio.ByteBuffer
getTest()
get the test value for this magic matchjava.lang.String
getType()
get the type of match for this magic matchboolean
mimeTypeMatches(java.lang.String desc)
determine if this match or any submatches has the descriptionvoid
setBitmask(java.lang.String value)
set the bitmask that will be applied for this magic matchvoid
setComparator(java.lang.String value)
set the comparator for this magic match(package private) void
setDescription(java.lang.String value)
Set the description for this magic match.(package private) void
setExtension(java.lang.String value)
Set the extension for this magic match.void
setLength(int value)
set the length we are restricting the comparison to for this magic match(package private) void
setMimeType(java.lang.String value)
Set the mime type for this magic match.void
setOffset(int value)
set the offset in the stream we are comparing to the test value for this magic matchvoid
setProperties(java.util.Map<java.lang.String,java.lang.String> properties)
set the properties for this magic matchvoid
setSubMatches(java.util.Collection<MagicMatch> a)
Set all submatches.void
setTest(java.nio.ByteBuffer value)
set the test value for thie magic matchvoid
setType(java.lang.String value)
set the type of match to perform for this magic match
-
-
-
Field Detail
-
serialVersionUID
private static final long serialVersionUID
- See Also:
- Constant Field Values
-
mimeType
private java.lang.String mimeType
-
extension
private java.lang.String extension
-
description
private java.lang.String description
-
test
private byte[] test
-
offset
private int offset
-
length
private int length
-
type
private java.lang.String type
-
bitmask
private long bitmask
-
comparator
private char comparator
-
subMatches
private final java.util.ArrayList<MagicMatch> subMatches
-
properties
private java.util.Map<java.lang.String,java.lang.String> properties
-
-
Method Detail
-
setMimeType
void setMimeType(java.lang.String value)
Set the mime type for this magic match.
-
getMimeType
public java.lang.String getMimeType()
Get the magic match for this magic match.- Returns:
- The magic match for this magic match
-
setExtension
void setExtension(java.lang.String value)
Set the extension for this magic match.
-
getExtension
public java.lang.String getExtension()
Get the extension for this magic match.- Returns:
- the extension for this magic match
-
setDescription
void setDescription(java.lang.String value)
Set the description for this magic match.
-
getDescription
public java.lang.String getDescription()
Get the description for this magic match.- Returns:
- the description for thie magic match
-
setTest
public void setTest(java.nio.ByteBuffer value)
set the test value for thie magic match- Parameters:
value
- DOCUMENT ME!
-
getTest
public java.nio.ByteBuffer getTest()
get the test value for this magic match- Returns:
- DOCUMENT ME!
-
setOffset
public void setOffset(int value)
set the offset in the stream we are comparing to the test value for this magic match- Parameters:
value
- DOCUMENT ME!
-
getOffset
public int getOffset()
get the offset in the stream we are comparing to the test value for this magic match- Returns:
- the offset for this magic match
-
setLength
public void setLength(int value)
set the length we are restricting the comparison to for this magic match- Parameters:
value
- DOCUMENT ME!
-
getLength
public int getLength()
get the length we are restricting the comparison to for this magic match- Returns:
- DOCUMENT ME!
-
setType
public void setType(java.lang.String value)
set the type of match to perform for this magic match- Parameters:
value
- DOCUMENT ME!
-
getType
public java.lang.String getType()
get the type of match for this magic match- Returns:
- DOCUMENT ME!
-
setBitmask
public void setBitmask(java.lang.String value)
set the bitmask that will be applied for this magic match- Parameters:
value
- DOCUMENT ME!
-
getBitmask
public long getBitmask()
get the bitmask that will be applied for this magic match- Returns:
- the bitmask for this magic match
-
setComparator
public void setComparator(java.lang.String value)
set the comparator for this magic match- Parameters:
value
- DOCUMENT ME!
-
getComparator
public char getComparator()
get the comparator for this magic match- Returns:
- the comparator for this magic match
-
setProperties
public void setProperties(java.util.Map<java.lang.String,java.lang.String> properties)
set the properties for this magic match- Parameters:
properties
- DOCUMENT ME!
-
getProperties
public java.util.Map<java.lang.String,java.lang.String> getProperties()
get the properties for this magic match- Returns:
- the properties for this magic match
-
addSubMatch
public void addSubMatch(MagicMatch m)
Add a submatch to this magic match.- Parameters:
m
- a magic match
-
setSubMatches
public void setSubMatches(java.util.Collection<MagicMatch> a)
Set all submatches.- Parameters:
a
- a collection of submatches
-
getSubMatches
public java.util.Collection<MagicMatch> getSubMatches()
get all submatches for this magic match- Returns:
- a collection of submatches
-
descriptionMatches
public boolean descriptionMatches(java.lang.String desc)
determine if this match or any submatches has the description- Parameters:
desc
- DOCUMENT ME!- Returns:
- whether or not the description matches
-
mimeTypeMatches
public boolean mimeTypeMatches(java.lang.String desc)
determine if this match or any submatches has the description- Parameters:
desc
- DOCUMENT ME!- Returns:
- whether or not the description matches
-
clone
protected java.lang.Object clone()
- Overrides:
clone
in classjava.lang.Object
-
-