com.j256.simplemagic.entries
Interface MagicMatcher

All Known Implementing Classes:
BigEndianString16Type, ByteType, DefaultType, DoubleType, FloatType, IntegerType, LittleEndianString16Type, LocalDateType, LocalLongDateType, LongType, PStringType, RegexType, SearchType, ShortType, StringType, UtcDateType, UtcLongDateType

public interface MagicMatcher

Classes which are able to match content according to operations and output description.

Author:
graywatson

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.
 

Method Detail

convertTestString

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[]).


extractValueFromBytes

Object extractValueFromBytes(int offset,
                             byte[] bytes)
Extract the value from the bytes.

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

isMatch

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


renderValue

void renderValue(StringBuilder sb,
                 Object extractedValue,
                 Formatter formatter)
Returns the string version of the extracted value.



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