public class StringFunctions extends AbstractFunctionHandler
| Modifier and Type | Field and Description |
|---|---|
static java.lang.String |
HANDLER_ID |
q| Constructor and Description |
|---|
StringFunctions() |
| Modifier and Type | Method and Description |
|---|---|
java.util.List |
grep(java.io.File f,
java.lang.String s)
grep
through a file, line by line, and determine what matches there are to the nominated
String.
|
java.util.List |
grep(java.io.File f,
java.lang.String s,
boolean ignoreCase)
grep
through a file, line by line, and determine what matches there are to the nominated
String.
|
double |
lastIndexOf(java.lang.Object o,
java.lang.Object i)
A thinly veiled wrapper around the
String.lastIndexOf(String) method. |
double |
length(java.lang.Object o) |
boolean |
regexp(java.lang.Object o,
java.lang.String re)
Match a regular expression against the object passed in.
|
boolean |
regexp(java.lang.Object o,
java.lang.String re,
java.lang.String instName)
Match a regular expression against the object passed in using the specified regular expression
library, pre-defined library names can be found in:
RegExpFactory. |
java.util.List |
rgrep(java.io.File f,
java.lang.String regexp)
grep
through a file, line by line, and determine what matches there are to the nominated
regular expression.
|
java.util.List |
rgrep(java.io.File f,
java.lang.String regexp,
java.lang.String instName)
grep
through a file, line by line, and determine what matches there are to the nominated
regular expression using the specified regular expression implementation.
|
java.lang.String |
subStr(java.lang.Object o,
double f)
Return a substring of the passed in object (in a string form).
|
java.lang.String |
subStr(java.lang.Object o,
double f,
double t)
A function to return a substring of a String.
|
java.lang.String |
trim(java.lang.Object o,
java.lang.Object v)
Given a string trim the passed in string from the front and end, set v to
null
to have just whitespace trimmed. |
setQuerypublic static final java.lang.String HANDLER_ID
public boolean regexp(java.lang.Object o,
java.lang.String re)
throws QueryExecutionException
o - The object to match against, toString is called on the object.re - The regular expression to match.true if the expression matches.QueryExecutionException - If the match cannot be performed, or if there is no suitable
regular expression library available to the RegExpFactory.public boolean regexp(java.lang.Object o,
java.lang.String re,
java.lang.String instName)
throws QueryExecutionException
RegExpFactory.o - The object to match against, toString is called on the object.re - The regular expression to match.instName - The name of the regular expression library to use.true if the expression matches.QueryExecutionException - If the match cannot be performed, or if the instName
regular expression library is not available to the RegExpFactory.public java.util.List grep(java.io.File f,
java.lang.String s,
boolean ignoreCase)
throws QueryExecutionException
FileMatch objects.f - The File to match against.s - The string to match.ignoreCase - If set to true then the case of the line and string to
match are ignored.FileMatch objects.QueryExecutionExceptionpublic java.util.List rgrep(java.io.File f,
java.lang.String regexp,
java.lang.String instName)
throws QueryExecutionException
FileMatch objects.f - The File to match against.regexp - The regular expression to match against each line. This will use the
default regular expression library. In this case the location of the match
(i.e. FileMatch.getColumn()) will be -1 since the regular expression
handling does not support location matching. Also, FileMatch.getString()
will contain the regular expression used.instName - The instance name to use.FileMatch objects.QueryExecutionException - If the default regular expression implementation is not
available or if the file cannot be read.public java.util.List rgrep(java.io.File f,
java.lang.String regexp)
throws QueryExecutionException
FileMatch objects.f - The File to match against.regexp - The regular expression to match against each line. This will use the
default regular expression library. In this case the location of the match
(i.e. FileMatch.getColumn()) will be -1 since the regular expression
handling does not support location matching. Also, FileMatch.getString()
will contain the regular expression used.FileMatch objects.QueryExecutionException - If the default regular expression implementation is not
available or if the file cannot be read.public java.util.List grep(java.io.File f,
java.lang.String s)
throws QueryExecutionException
FileMatch objects.f - The File to match against.s - The string to match.FileMatch objects.QueryExecutionExceptionpublic java.lang.String trim(java.lang.Object o,
java.lang.Object v)
null
to have just whitespace trimmed. Both are converted to strings first.o - The string to trim.v - The string to trim from the front and end. Set to null to just trim
whitespace.public double lastIndexOf(java.lang.Object o,
java.lang.Object i)
String.lastIndexOf(String) method.
Both o and i are converted to Strings and then the "lastIndexoOf" method
is called on o with i as the argument.o - The string to search.i - The string to match.null then
-1 is returned. If i is null then -1 is returned.public java.lang.String subStr(java.lang.Object o,
double f)
subStr(Object,double,double)
for the full details since this is just a thin-wrapper around that method with the t
parameter set to -1.o - The object to convert to a string and return the substring.f - The start index. If this is set to 0 then the entire string is returned.public java.lang.String subStr(java.lang.Object o,
double f,
double t)
o - The object to convert to a string and return the substring.f - The start index. If it's < 0 then "" is returned. If the start is out of
range of the string then "" is returned.t - The end index. If it's > f then it is reset to -1. If it's -1 then
it's ignored and the substring from the start is used. If the end is greater
than the length of the string then it is ignored.public double length(java.lang.Object o)