com.j256.simplemagic.types
Class SearchType

java.lang.Object
  extended by com.j256.simplemagic.types.StringType
      extended by com.j256.simplemagic.types.SearchType
All Implemented Interfaces:
MagicMatcher

public class SearchType
extends StringType

From the magic(5) man page: A literal string search starting at the given line offset. The same modifier flags can be used as for string patterns. The modifier flags (if any) must be followed by /number the range, that is, the number of positions at which the match will be attempted, starting from the start offset. This is suitable for searching larger binary expressions with variable offsets, using \ escapes for special characters. The offset works as for regex.

NOTE: in our experience, the /number is _before_ the flags in 99% of the lines so that is how we implemented it.

Author:
graywatson

Nested Class Summary
 
Nested classes/interfaces inherited from class com.j256.simplemagic.types.StringType
StringType.StringTestInfo
 
Constructor Summary
SearchType()
           
 
Method Summary
 Object isMatch(Object testValue, Long andValue, boolean unsignedType, Object extractedValue, int offset, byte[] bytes)
          Matches if the bytes match at a certain offset.
 
Methods inherited from class com.j256.simplemagic.types.StringType
convertTestString, extractValueFromBytes, findOffsetMatch, renderValue
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SearchType

public SearchType()
Method Detail

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
Overrides:
isMatch in class StringType


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