Package libsidutils.stringsearch
Klasse StringSearch
java.lang.Object
libsidutils.stringsearch.StringSearch
- Bekannte direkte Unterklassen:
BNDM,MismatchSearch
The base class for String searching implementations. String searching
implementations do not maintain state and are thread safe - one instance can
be used by as many threads as required.
Most pattern-matching algorithms pre-process the pattern to search for in some way. Subclasses of StringSearch allow retrieving the pre-processed pattern to save the time required to build up character tables.
Some of the Objects returned from processBytes(byte[]),
processChars(char[]), might implement the
Serializable interface and enable you to serialize
pre-processed Objects to disk, see concrete implementations for details.
- Version:
- 1.2
- Autor:
- Johann Burkard
-
Konstruktorübersicht
Konstruktoren -
Methodenübersicht
Modifizierer und TypMethodeBeschreibungprotected CharIntMapcreateCharIntMap(char[] pattern) Returns aCharIntMapof the extent of the given pattern, using no default value.protected CharIntMapcreateCharIntMap(char[] pattern, int defaultValue) Returns aCharIntMapof the extent of the given pattern, using the specified default value.final booleanReturns if the Object's class name matches this Object's class name.final inthashCode()Returns the hashCode of the Object's Class because all instances of this Class are equal.protected final intindex(byte idx) Converts the givenbyteto anint.abstract ObjectprocessBytes(byte[] pattern) Pre-processes abytearray.abstract ObjectprocessChars(char[] pattern) Pre-processes achararrayfinal intsearchBytes(byte[] text, byte[] pattern) Returns the position in the text at which the pattern was found.final intsearchBytes(byte[] text, byte[] pattern, Object processed) Returns the position in the text at which the pattern was found.final intsearchBytes(byte[] text, int textStart, byte[] pattern) Returns the position in the text at which the pattern was found.final intsearchBytes(byte[] text, int textStart, byte[] pattern, Object processed) Returns the position in the text at which the pattern was found.final intsearchBytes(byte[] text, int textStart, int textEnd, byte[] pattern) Returns the position in the text at which the pattern was found.abstract intsearchBytes(byte[] text, int textStart, int textEnd, byte[] pattern, Object processed) Returns the position in the text at which the pattern was found.final intsearchChars(char[] text, char[] pattern) Returns the position in the text at which the pattern was found.final intsearchChars(char[] text, char[] pattern, Object processed) Returns the index of the pattern in the text using the pre-processed Object.final intsearchChars(char[] text, int textStart, char[] pattern) Returns the position in the text at which the pattern was found.final intsearchChars(char[] text, int textStart, char[] pattern, Object processed) Returns the index of the pattern in the text using the pre-processed Object.final intsearchChars(char[] text, int textStart, int textEnd, char[] pattern) Returns the position in the text at which the pattern was found.abstract intsearchChars(char[] text, int textStart, int textEnd, char[] pattern, Object processed) Returns the index of the pattern in the text using the pre-processed Object.final StringtoString()Returns a String representation of this.Appends a String representation of this to the givenStringBufferor creates a new one if none is given.
-
Konstruktordetails
-
StringSearch
StringSearch()
-
-
Methodendetails
-
processBytes
Pre-processes abytearray.- Parameter:
pattern- thebytearray containing the pattern, may not benull- Gibt zurück:
- an Object
-
processChars
Pre-processes achararray- Parameter:
pattern- achararray containing the pattern, may not benull- Gibt zurück:
- an Object
-
searchBytes
public final int searchBytes(byte[] text, byte[] pattern) Returns the position in the text at which the pattern was found. Returns -1 if the pattern was not found.- Parameter:
text- thebytearray containing the text, may not benullpattern- thebytearray containing the pattern, may not benull- Gibt zurück:
- the position in the text or -1 if the pattern was not found
- Siehe auch:
-
searchBytes
Returns the position in the text at which the pattern was found. Returns -1 if the pattern was not found.- Parameter:
text- thebytearray containing the text, may not benullpattern- the pattern to search for, may not benullprocessed- an Object as returned fromprocessBytes(byte[]), may not benull- Gibt zurück:
- the position in the text or -1 if the pattern was not found
- Siehe auch:
-
searchBytes
public final int searchBytes(byte[] text, int textStart, byte[] pattern) Returns the position in the text at which the pattern was found. Returns -1 if the pattern was not found.- Parameter:
text- thebytearray containing the text, may not benulltextStart- at which position in the text the comparing should startpattern- thebytearray containing the pattern, may not benull- Gibt zurück:
- int the position in the text or -1 if the pattern was not found
- Siehe auch:
-
searchBytes
Returns the position in the text at which the pattern was found. Returns -1 if the pattern was not found.- Parameter:
text- thebytearray containing the text, may not benulltextStart- at which position in the text the comparing should startpattern- the pattern to search for, may not benullprocessed-- Gibt zurück:
- the position in the text or -1 if the pattern was not found
- Siehe auch:
-
searchBytes
public final int searchBytes(byte[] text, int textStart, int textEnd, byte[] pattern) Returns the position in the text at which the pattern was found. Returns -1 if the pattern was not found.- Parameter:
text- text thebytearray containing the text, may not benulltextStart- at which position in the text the comparing should starttextEnd- at which position in the text comparing should stoppattern- thebytearray containing the pattern, may not benull- Gibt zurück:
- the position in the text or -1 if the pattern was not found
- Siehe auch:
-
searchBytes
public abstract int searchBytes(byte[] text, int textStart, int textEnd, byte[] pattern, Object processed) Returns the position in the text at which the pattern was found. Returns -1 if the pattern was not found.- Parameter:
text- text thebytearray containing the text, may not benulltextStart- at which position in the text the comparing should starttextEnd- at which position in the text comparing should stoppattern- the pattern to search for, may not benullprocessed- an Object as returned fromprocessBytes(byte[]), may not benull- Gibt zurück:
- the position in the text or -1 if the pattern was not found
- Siehe auch:
-
searchChars
public final int searchChars(char[] text, char[] pattern) Returns the position in the text at which the pattern was found. Returns -1 if the pattern was not found.- Parameter:
text- the character array containing the text, may not benullpattern- thechararray containing the pattern, may not benull- Gibt zurück:
- the position in the text or -1 if the pattern was not found
- Siehe auch:
-
searchChars
Returns the index of the pattern in the text using the pre-processed Object. Returns -1 if the pattern was not found.- Parameter:
text- the character array containing the text, may not benullpattern- thechararray containing the pattern, may not benullprocessed- an Object as returned fromprocessChars(char[]), may not benull- Gibt zurück:
- the position in the text or -1 if the pattern was not found
- Siehe auch:
-
searchChars
public final int searchChars(char[] text, int textStart, char[] pattern) Returns the position in the text at which the pattern was found. Returns -1 if the pattern was not found.- Parameter:
text- the character array containing the text, may not benulltextStart- at which position in the text the comparing should startpattern- thechararray containing the pattern, may not benull- Gibt zurück:
- the position in the text or -1 if the pattern was not found
- Siehe auch:
-
searchChars
Returns the index of the pattern in the text using the pre-processed Object. Returns -1 if the pattern was not found.- Parameter:
text- the String containing the text, may not benulltextStart- at which position in the text the comparing should startpattern- thechararray containing the pattern, may not benullprocessed- an Object as returned fromprocessChars(char[]), may not benull- Gibt zurück:
- the position in the text or -1 if the pattern was not found
- Siehe auch:
-
searchChars
public final int searchChars(char[] text, int textStart, int textEnd, char[] pattern) Returns the position in the text at which the pattern was found. Returns -1 if the pattern was not found.- Parameter:
text- the character array containing the text, may not benulltextStart- at which position in the text the comparing should starttextEnd- at which position in the text comparing should stoppattern- thechararray containing the pattern, may not benull- Gibt zurück:
- the position in the text or -1 if the pattern was not found
- Siehe auch:
-
searchChars
public abstract int searchChars(char[] text, int textStart, int textEnd, char[] pattern, Object processed) Returns the index of the pattern in the text using the pre-processed Object. Returns -1 if the pattern was not found.- Parameter:
text- the String containing the text, may not benulltextStart- at which position in the text the comparing should starttextEnd- at which position in the text comparing should stoppattern- the pattern to search for, may not benullprocessed- an Object as returned fromprocessChars(char[]), may not benull- Gibt zurück:
- the position in the text or -1 if the pattern was not found
-
equals
Returns if the Object's class name matches this Object's class name. -
hashCode
public final int hashCode()Returns the hashCode of the Object's Class because all instances of this Class are equal. -
toString
Returns a String representation of this. Simply returns the name of the Class. -
toStringBuffer
Appends a String representation of this to the givenStringBufferor creates a new one if none is given. This method is notfinalbecause subclasses might want a different String format.- Parameter:
in- the StringBuffer to append to, may benull- Gibt zurück:
- a StringBuffer
-
createCharIntMap
Returns aCharIntMapof the extent of the given pattern, using no default value.- Parameter:
pattern- the pattern- Gibt zurück:
- a CharIntMap
- Siehe auch:
-
createCharIntMap
Returns aCharIntMapof the extent of the given pattern, using the specified default value.- Parameter:
pattern- the patterndefaultValue- the default value- Gibt zurück:
- a CharIntMap
- Siehe auch:
-
index
protected final int index(byte idx) Converts the givenbyteto anint.- Parameter:
idx- the byte- Gibt zurück:
- an int
-