com.j256.simplemagic.types
Class LongType

java.lang.Object
  extended by com.j256.simplemagic.types.LongType
All Implemented Interfaces:
MagicMatcher
Direct Known Subclasses:
ByteType, IntegerType, ShortType

public class LongType
extends Object
implements MagicMatcher

An eight-byte value.

Author:
graywatson

Field Summary
protected  EndianConverter endianConverter
           
 
Constructor Summary
LongType(EndianType endianType)
           
 
Method Summary
 Object convertTestString(String typeStr, String testStr, int offset)
          Converts the test-string from the magic line to be an object to be passed into #isMatch(Object, int, byte[]).
 Object extractValueFromBytes(int offset, byte[] bytes)
          Extract the value from the bytes.
 Object isMatch(Object testValue, Long andValue, boolean unsignedType, Object extractedValue, int offset, byte[] bytes)
          Matches if the bytes match at a certain offset.
 void renderValue(StringBuilder sb, Object extractedValue, Formatter formatter)
          Returns the string version of the extracted value.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

endianConverter

protected final EndianConverter endianConverter
Constructor Detail

LongType

public LongType(EndianType endianType)
Method Detail

convertTestString

public Object convertTestString(String typeStr,
                                String testStr,
                                int offset)
Description copied from interface: MagicMatcher
Converts the test-string from the magic line to be an object to be passed into #isMatch(Object, int, byte[]).

Specified by:
convertTestString in interface MagicMatcher

extractValueFromBytes

public Object extractValueFromBytes(int offset,
                                    byte[] bytes)
Description copied from interface: MagicMatcher
Extract the value from the bytes.

Specified by:
extractValueFromBytes in interface MagicMatcher
Returns:
The object to be passed to MagicMatcher.isMatch(Object, Long, boolean, Object, int, byte[]) or null if not enough bytes.

isMatch

public Object isMatch(Object testValue,
                      Long andValue,
                      boolean unsignedType,
                      Object extractedValue,
                      int offset,
                      byte[] bytes)
Description copied from interface: MagicMatcher
Matches if the bytes match at a certain offset. Returns the extracted-value object, or null if no match.

Specified by:
isMatch in interface MagicMatcher

renderValue

public void renderValue(StringBuilder sb,
                        Object extractedValue,
                        Formatter formatter)
Description copied from interface: MagicMatcher
Returns the string version of the extracted value.

Specified by:
renderValue in interface MagicMatcher


This content is licensed by Gray Watson under the Creative Commons Attribution-Share Alike 3.0 License.