|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.j256.simplemagic.types.StringType
public class StringType
From the magic(5) man page: A string of bytes. The string type specification can be optionally followed by /[Bbc]*. The ``B'' flag compacts whitespace in the target, which must contain at least one whitespace character. If the magic has n consecutive blanks, the target needs at least n consecutive blanks to match. The ``b'' flag treats every blank in the target as an optional blank. Finally the ``c'' flag, specifies case insensitive matching: lower-case characters in the magic match both lower and upper case characters in the target, whereas upper case characters in the magic only match upper-case characters in the target.
Nested Class Summary | |
---|---|
protected static class |
StringType.StringTestInfo
Internal holder for test information about strings. |
Constructor Summary | |
---|---|
StringType()
|
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. |
protected String |
findOffsetMatch(StringType.StringTestInfo info,
int offset,
byte[] bytes,
String line)
Called from the string and search types to see if a string or byte array matches our pattern. |
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 |
---|
public StringType()
Method Detail |
---|
public Object convertTestString(String typeStr, String testStr, int offset)
MagicMatcher
#isMatch(Object, int, byte[])
.
convertTestString
in interface MagicMatcher
public Object extractValueFromBytes(int offset, byte[] bytes)
MagicMatcher
extractValueFromBytes
in interface MagicMatcher
MagicMatcher.isMatch(Object, Long, boolean, Object, int, byte[])
or null if not
enough bytes.public Object isMatch(Object testValue, Long andValue, boolean unsignedType, Object extractedValue, int offset, byte[] bytes)
MagicMatcher
isMatch
in interface MagicMatcher
public void renderValue(StringBuilder sb, Object extractedValue, Formatter formatter)
MagicMatcher
renderValue
in interface MagicMatcher
protected String findOffsetMatch(StringType.StringTestInfo info, int offset, byte[] bytes, String line)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |