|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.jscience.linguistics.search.StringSearch
public abstract class StringSearch
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 fromprocessBytes(byte[]), processChars(char[]), processString(String) might implement the
Serializable interface and enable you to serialize
pre-processed Objects to disk, see concrete implementations for details.
| Nested Class Summary | |
|---|---|
protected static class |
StringSearch.Dispatch
The Dispatch class implements the strategy to convert Strings to char arrays and calls the appropriate
searchChars method in the given StringSearch instance. |
protected static class |
StringSearch.ReflectionDispatch
The ReflectionDispatch class is used if Reflection can be used to access the underlying char array in Strings to avoid the cloning
overhead. |
| Field Summary | |
|---|---|
protected static StringSearch.Dispatch |
activeDispatch
The Dispatch instance. |
protected static boolean |
useNative
Stores if the native library should be loaded. |
| Constructor Summary | |
|---|---|
protected |
StringSearch()
Constructor for StringSearch. |
| Method Summary | |
|---|---|
protected CharIntMap |
createCharIntMap(char[] pattern)
Returns a CharIntMap of the extent of the given pattern, using
no default value. |
protected CharIntMap |
createCharIntMap(char[] pattern,
int defaultValue)
Returns a CharIntMap of the extent of the given pattern, using
the specified default value. |
boolean |
equals(java.lang.Object obj)
Returns if the Object's class name matches this Object's class name. |
int |
hashCode()
Returns the hashCode of the Object's Class because all instances of this Class are equal. |
protected int |
index(byte idx)
Converts the given byte to an int. |
abstract java.lang.Object |
processBytes(byte[] pattern)
Pre-processes a byte array. |
abstract java.lang.Object |
processChars(char[] pattern)
Pre-processes a char array |
java.lang.Object |
processString(java.lang.String pattern)
Pre-processes a String. |
int |
searchBytes(byte[] text,
byte[] pattern)
Returns the position in the text at which the pattern was found. |
int |
searchBytes(byte[] text,
byte[] pattern,
java.lang.Object processed)
Returns the position in the text at which the pattern was found. |
int |
searchBytes(byte[] text,
int textStart,
byte[] pattern)
Returns the position in the text at which the pattern was found. |
int |
searchBytes(byte[] text,
int textStart,
byte[] pattern,
java.lang.Object processed)
Returns the position in the text at which the pattern was found. |
int |
searchBytes(byte[] text,
int textStart,
int textEnd,
byte[] pattern)
Returns the position in the text at which the pattern was found. |
abstract int |
searchBytes(byte[] text,
int textStart,
int textEnd,
byte[] pattern,
java.lang.Object processed)
Returns the position in the text at which the pattern was found. |
int |
searchChars(char[] text,
char[] pattern)
Returns the position in the text at which the pattern was found. |
int |
searchChars(char[] text,
char[] pattern,
java.lang.Object processed)
Returns the index of the pattern in the text using the pre-processed Object. |
int |
searchChars(char[] text,
int textStart,
char[] pattern)
Returns the position in the text at which the pattern was found. |
int |
searchChars(char[] text,
int textStart,
char[] pattern,
java.lang.Object processed)
Returns the index of the pattern in the text using the pre-processed Object. |
int |
searchChars(char[] text,
int textStart,
int textEnd,
char[] pattern)
Returns the position in the text at which the pattern was found. |
abstract int |
searchChars(char[] text,
int textStart,
int textEnd,
char[] pattern,
java.lang.Object processed)
Returns the index of the pattern in the text using the pre-processed Object. |
int |
searchString(java.lang.String text,
int textStart,
int textEnd,
java.lang.String pattern)
Convenience method to search for patterns in Strings. |
int |
searchString(java.lang.String text,
int textStart,
int textEnd,
java.lang.String pattern,
java.lang.Object processed)
Convenience method to search for patterns in Strings. |
int |
searchString(java.lang.String text,
int textStart,
java.lang.String pattern)
Convenience method to search for patterns in Strings. |
int |
searchString(java.lang.String text,
int textStart,
java.lang.String pattern,
java.lang.Object processed)
Convenience method to search for patterns in Strings. |
int |
searchString(java.lang.String text,
java.lang.String pattern)
Convenience method to search for patterns in Strings. |
int |
searchString(java.lang.String text,
java.lang.String pattern,
java.lang.Object processed)
Convenience method to search for patterns in Strings. |
java.lang.String |
toString()
Returns a String representation of this. |
java.lang.StringBuffer |
toStringBuffer(java.lang.StringBuffer in)
Appends a String representation of this to the given StringBuffer or creates a new one if none is given. |
boolean |
usesNative()
Returns if this algorithm currently uses the native library - if it could be loaded. |
static boolean |
usesReflection()
Returns if Reflection is used to access the underlying char
array in Strings. |
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
protected static boolean useNative
null (not
defined) or "true" (ignoring case), an attempt is always made to load
the native library. Any other values will prevent the native library
from being loaded.
protected static StringSearch.Dispatch activeDispatch
| Constructor Detail |
|---|
protected StringSearch()
| Method Detail |
|---|
public static boolean usesReflection()
char
array in Strings.
true or falsepublic boolean usesNative()
false.
true or falsepublic abstract java.lang.Object processBytes(byte[] pattern)
byte array.
pattern - the byte array containing the pattern, may
not be null
public abstract java.lang.Object processChars(char[] pattern)
char array
pattern - a char array containing the pattern, may not
be null
public final java.lang.Object processString(java.lang.String pattern)
searchString(String,String)
methods.
pattern - the String containing the pattern, may not be
null
processChars(char[])
public final int searchBytes(byte[] text,
byte[] pattern)
text - the byte array containing the text, may not be
nullpattern - the byte array containing the pattern, may
not be null
searchBytes(byte[],int,int,byte[],Object)
public final int searchBytes(byte[] text,
byte[] pattern,
java.lang.Object processed)
text - the byte array containing the text, may not be
nullpattern - the pattern to search for, may not be nullprocessed - an Object as returned from processBytes(byte[]), may not be null
searchBytes(byte[],int,int,byte[],Object)
public final int searchBytes(byte[] text,
int textStart,
byte[] pattern)
text - the byte array containing the text, may not be
nulltextStart - at which position in the text the comparing should
startpattern - the byte array containing the pattern, may
not be null
searchBytes(byte[],int,int,byte[],Object)
public final int searchBytes(byte[] text,
int textStart,
byte[] pattern,
java.lang.Object processed)
text - the byte array containing the text, may not be
nulltextStart - at which position in the text the comparing should
startpattern - the pattern to search for, may not be nullprocessed -
searchBytes(byte[],int,int,byte[],Object)
public final int searchBytes(byte[] text,
int textStart,
int textEnd,
byte[] pattern)
text - text the byte array containing the text, may
not be nulltextStart - at which position in the text the comparing should
starttextEnd - at which position in the text comparing should stoppattern - the byte array containing the pattern, may
not be null
searchBytes(byte[],int,int,byte[],Object)
public abstract int searchBytes(byte[] text,
int textStart,
int textEnd,
byte[] pattern,
java.lang.Object processed)
text - text the byte array containing the text, may
not be nulltextStart - 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 be nullprocessed - an Object as returned from processBytes(byte[]), may not be null
processBytes(byte[])
public final int searchChars(char[] text,
char[] pattern)
text - the character array containing the text, may not be
nullpattern - the char array containing the pattern, may
not be null
searchChars(char[],int,int,char[],Object)
public final int searchChars(char[] text,
char[] pattern,
java.lang.Object processed)
text - the character array containing the text, may not be
nullpattern - the char array containing the pattern, may
not be nullprocessed - an Object as returned from processChars(char[]) or processString(String), may
not be null
searchChars(char[],int,int,char[],Object)
public final int searchChars(char[] text,
int textStart,
char[] pattern)
text - the character array containing the text, may not be
nulltextStart - at which position in the text the comparing should
startpattern - the char array containing the pattern, may
not be null
searchChars(char[],int,int,char[],Object)
public final int searchChars(char[] text,
int textStart,
char[] pattern,
java.lang.Object processed)
text - the String containing the text, may not be nulltextStart - at which position in the text the comparing should
startpattern - the char array containing the pattern, may
not be nullprocessed - an Object as returned from processChars(char[]) or processString(String), may
not be null
searchChars(char[],int,int,char[],Object)
public final int searchChars(char[] text,
int textStart,
int textEnd,
char[] pattern)
text - the character array containing the text, may not be
nulltextStart - at which position in the text the comparing should
starttextEnd - at which position in the text comparing should stoppattern - the char array containing the pattern, may
not be null
searchChars(char[],int,int,char[],Object)
public abstract int searchChars(char[] text,
int textStart,
int textEnd,
char[] pattern,
java.lang.Object processed)
text - the String containing the text, may not be nulltextStart - 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 be nullprocessed - an Object as returned from processChars(char[]) or processString(String), may
not be null
public final int searchString(java.lang.String text,
java.lang.String pattern)
text - the String containing the text, may not be nullpattern - the String containing the pattern, may not be
null
searchChars(char[],int,int,char[],Object)
public final int searchString(java.lang.String text,
java.lang.String pattern,
java.lang.Object processed)
text - the String containing the text, may not be nullpattern - the String containing the pattern, may not be
nullprocessed - an Object as returned from processChars(char[]) or processString(String), may
not be null
searchChars(char[],int,int,char[],Object)
public final int searchString(java.lang.String text,
int textStart,
java.lang.String pattern)
text - the String containing the text, may not be nulltextStart - at which position in the text the comparing should
startpattern - the String containing the pattern, may not be
null
searchChars(char[],int,int,char[],Object)
public final int searchString(java.lang.String text,
int textStart,
java.lang.String pattern,
java.lang.Object processed)
text - the String containing the text, may not be nulltextStart - at which position in the text the comparing should
startpattern - the String containing the pattern, may not be
nullprocessed - an Object as returned from processChars(char[]) or processString(String), may
not be null
searchChars(char[],int,int,char[],Object)
public final int searchString(java.lang.String text,
int textStart,
int textEnd,
java.lang.String pattern)
text - the String containing the text, may not be nulltextStart - at which position in the text the comparing should
starttextEnd - at which position in the text comparing should stoppattern - the String containing the pattern, may not be
null
searchChars(char[],int,int,char[])
public final int searchString(java.lang.String text,
int textStart,
int textEnd,
java.lang.String pattern,
java.lang.Object processed)
text - the String containing the text, may not be nulltextStart - at which position in the text the comparing should
starttextEnd - at which position in the text comparing should stoppattern - the String containing the pattern, may not be
nullprocessed - an Object as returned from processChars(char[]) or processString(String), may
not be null
searchChars(char[],int,int,char[])public final boolean equals(java.lang.Object obj)
equals in class java.lang.Objectobj - the other Object
Object.equals(Object)public final int hashCode()
hashCode in class java.lang.ObjectObject.hashCode()public final java.lang.String toString()
toString in class java.lang.ObjectObject.toString()public java.lang.StringBuffer toStringBuffer(java.lang.StringBuffer in)
StringBuffer or creates a new one if none is given. This method is not
final because subclasses might want a different String
format.
in - the StringBuffer to append to, may be null
protected CharIntMap createCharIntMap(char[] pattern)
CharIntMap of the extent of the given pattern, using
no default value.
pattern - the pattern
CharIntMap.CharIntMap(int,char)
protected CharIntMap createCharIntMap(char[] pattern,
int defaultValue)
CharIntMap of the extent of the given pattern, using
the specified default value.
pattern - the patterndefaultValue - the default value
CharIntMap.CharIntMap(int,char,int)protected final int index(byte idx)
byte to an int.
idx - the byte
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||