Package emissary.util.magic
Class MagicNumber
- java.lang.Object
-
- emissary.util.magic.MagicNumber
-
public class MagicNumber extends Object
-
-
Field Summary
Fields Modifier and Type Field Description protected int
dataType
protected int
dataTypeLength
static Charset
DEFAULT_CHARSET
The default charset used when loading the config file and when sampling dataprotected List<MagicNumber[]>
dependencies
protected int
depth
protected String
description
static String
EMPTYSTRING
Empty string constantstatic char
MAGICOPERATOR_AND
Unary Operator: Equalsstatic char
MAGICOPERATOR_BWAND
Unary Operator: All bits matchstatic char
MAGICOPERATOR_BWNOT
Unary Operator: None or some bits matchstatic char
MAGICOPERATOR_DEFAULT
Default Unary Operator - andstatic char
MAGICOPERATOR_EQUAL_GTHAN
Unary Operator: Greater than or equal tostatic char
MAGICOPERATOR_EQUAL_LTHAN
Unary operator: Less than or equal tostatic char
MAGICOPERATOR_GTHAN
Unary Operator: Greater thanstatic char
MAGICOPERATOR_LTHAN
Unary Operator: Less thanstatic char
MAGICOPERATOR_NOT
Unary Operator: Default Operator (AND)static char
MAGICOPERATOR_OR
Unary Operator: At least one bit matchesprotected byte[]
mask
protected int
offset
protected char
offsetUnary
protected boolean
signedValue
protected boolean
substitute
static int
TYPE_BEDATE
Big endian date data type idstatic int
TYPE_BELONG
Big endian long data type idstatic int
TYPE_BESHORT
Big endian short data type idstatic int
TYPE_BYTE
Byte data type idstatic int
TYPE_DATE
Date data type idstatic String
TYPE_KEY_BEDATE
Big endian date data typestatic String
TYPE_KEY_BELONG
Big endian long data typestatic String
TYPE_KEY_BESHORT
Big endian short data typestatic String
TYPE_KEY_BYTE
Byte data typestatic String
TYPE_KEY_DATE
Date data typestatic String
TYPE_KEY_LEDATE
Little endian long data typestatic String
TYPE_KEY_LELONG
Little endian long data typestatic String
TYPE_KEY_LESHORT
Little endian short data typestatic String
TYPE_KEY_LONG
Long data typestatic String
TYPE_KEY_SHORT
Short data typestatic String
TYPE_KEY_STRING
String data typestatic int
TYPE_LEDATE
Little endian date data type idstatic int
TYPE_LELONG
Little endian long data type idstatic int
TYPE_LESHORT
Little endian short data type idstatic int
TYPE_LONG
Long data type idstatic int
TYPE_SHORT
Short data type idstatic int
TYPE_STRING
String data type idstatic int
TYPE_UNKNOWN
Unknown data type idprotected char
unaryOperator
protected byte[]
value
-
Constructor Summary
Constructors Constructor Description MagicNumber()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addDependencyLayer(MagicNumber[] dependencyLayer)
Add child continuationsString
describe(byte[] data)
Tests the sample and if successful provides the descriptionboolean
test(byte[] data)
Tests this magic number against the given dataString
toString()
Re-creates the string magic number entry for this number onlyString
toStringAll()
Recreates the string entry for this magic number plus its child continuations under new lines preceded by a '>' character at the appropriate depth.
-
-
-
Field Detail
-
DEFAULT_CHARSET
public static final Charset DEFAULT_CHARSET
The default charset used when loading the config file and when sampling data
-
TYPE_KEY_BYTE
public static final String TYPE_KEY_BYTE
Byte data type- See Also:
- Constant Field Values
-
TYPE_KEY_SHORT
public static final String TYPE_KEY_SHORT
Short data type- See Also:
- Constant Field Values
-
TYPE_KEY_LONG
public static final String TYPE_KEY_LONG
Long data type- See Also:
- Constant Field Values
-
TYPE_KEY_STRING
public static final String TYPE_KEY_STRING
String data type- See Also:
- Constant Field Values
-
TYPE_KEY_DATE
public static final String TYPE_KEY_DATE
Date data type- See Also:
- Constant Field Values
-
TYPE_KEY_BESHORT
public static final String TYPE_KEY_BESHORT
Big endian short data type- See Also:
- Constant Field Values
-
TYPE_KEY_BELONG
public static final String TYPE_KEY_BELONG
Big endian long data type- See Also:
- Constant Field Values
-
TYPE_KEY_BEDATE
public static final String TYPE_KEY_BEDATE
Big endian date data type- See Also:
- Constant Field Values
-
TYPE_KEY_LESHORT
public static final String TYPE_KEY_LESHORT
Little endian short data type- See Also:
- Constant Field Values
-
TYPE_KEY_LELONG
public static final String TYPE_KEY_LELONG
Little endian long data type- See Also:
- Constant Field Values
-
TYPE_KEY_LEDATE
public static final String TYPE_KEY_LEDATE
Little endian long data type- See Also:
- Constant Field Values
-
TYPE_UNKNOWN
public static final int TYPE_UNKNOWN
Unknown data type id- See Also:
- Constant Field Values
-
TYPE_BYTE
public static final int TYPE_BYTE
Byte data type id- See Also:
- Constant Field Values
-
TYPE_SHORT
public static final int TYPE_SHORT
Short data type id- See Also:
- Constant Field Values
-
TYPE_LONG
public static final int TYPE_LONG
Long data type id- See Also:
- Constant Field Values
-
TYPE_STRING
public static final int TYPE_STRING
String data type id- See Also:
- Constant Field Values
-
TYPE_DATE
public static final int TYPE_DATE
Date data type id- See Also:
- Constant Field Values
-
TYPE_BESHORT
public static final int TYPE_BESHORT
Big endian short data type id- See Also:
- Constant Field Values
-
TYPE_BELONG
public static final int TYPE_BELONG
Big endian long data type id- See Also:
- Constant Field Values
-
TYPE_BEDATE
public static final int TYPE_BEDATE
Big endian date data type id- See Also:
- Constant Field Values
-
TYPE_LESHORT
public static final int TYPE_LESHORT
Little endian short data type id- See Also:
- Constant Field Values
-
TYPE_LELONG
public static final int TYPE_LELONG
Little endian long data type id- See Also:
- Constant Field Values
-
TYPE_LEDATE
public static final int TYPE_LEDATE
Little endian date data type id- See Also:
- Constant Field Values
-
EMPTYSTRING
public static final String EMPTYSTRING
Empty string constant- See Also:
- Constant Field Values
-
MAGICOPERATOR_AND
public static final char MAGICOPERATOR_AND
Unary Operator: Equals- See Also:
- Constant Field Values
-
MAGICOPERATOR_GTHAN
public static final char MAGICOPERATOR_GTHAN
Unary Operator: Greater than- See Also:
- Constant Field Values
-
MAGICOPERATOR_LTHAN
public static final char MAGICOPERATOR_LTHAN
Unary Operator: Less than- See Also:
- Constant Field Values
-
MAGICOPERATOR_OR
public static final char MAGICOPERATOR_OR
Unary Operator: At least one bit matches- See Also:
- Constant Field Values
-
MAGICOPERATOR_BWAND
public static final char MAGICOPERATOR_BWAND
Unary Operator: All bits match- See Also:
- Constant Field Values
-
MAGICOPERATOR_BWNOT
public static final char MAGICOPERATOR_BWNOT
Unary Operator: None or some bits match- See Also:
- Constant Field Values
-
MAGICOPERATOR_NOT
public static final char MAGICOPERATOR_NOT
Unary Operator: Default Operator (AND)- See Also:
- Constant Field Values
-
MAGICOPERATOR_EQUAL_GTHAN
public static final char MAGICOPERATOR_EQUAL_GTHAN
Unary Operator: Greater than or equal to- See Also:
- Constant Field Values
-
MAGICOPERATOR_EQUAL_LTHAN
public static final char MAGICOPERATOR_EQUAL_LTHAN
Unary operator: Less than or equal to- See Also:
- Constant Field Values
-
MAGICOPERATOR_DEFAULT
public static final char MAGICOPERATOR_DEFAULT
Default Unary Operator - and- See Also:
- Constant Field Values
-
depth
protected int depth
-
offset
protected int offset
-
offsetUnary
protected char offsetUnary
-
dataType
protected int dataType
-
dataTypeLength
protected int dataTypeLength
-
mask
protected byte[] mask
-
signedValue
protected boolean signedValue
-
unaryOperator
protected char unaryOperator
-
value
@Nullable protected byte[] value
-
substitute
protected boolean substitute
-
description
@Nullable protected String description
-
dependencies
protected List<MagicNumber[]> dependencies
-
-
Method Detail
-
toStringAll
public String toStringAll()
Recreates the string entry for this magic number plus its child continuations under new lines preceded by a '>' character at the appropriate depth.- Returns:
- String
-
describe
@Nullable public String describe(byte[] data)
Tests the sample and if successful provides the description
-
test
public boolean test(byte[] data)
Tests this magic number against the given data
-
addDependencyLayer
public void addDependencyLayer(MagicNumber[] dependencyLayer)
Add child continuations
-
-