com.j256.simplemagic.types
Class DefaultType

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

public class DefaultType
extends Object
implements MagicMatcher

This is intended to be used with the test x (which is always true) and a message that is to be used if there are no other matches.

WARNING: This type _is_ used in the magic files.

Author:
graywatson

Constructor Summary
DefaultType()
           
 
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
 

Constructor Detail

DefaultType

public DefaultType()
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.