|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.josql.functions.AbstractFunctionHandler org.josql.functions.StringFunctions
public class StringFunctions
This class holds functions that operate on strings in some way.
Field Summary | |
---|---|
static String |
HANDLER_ID
|
Fields inherited from class org.josql.functions.AbstractFunctionHandler |
---|
q |
Constructor Summary | |
---|---|
StringFunctions()
|
Method Summary | |
---|---|
List |
grep(File f,
String s)
grep through a file, line by line, and determine what matches there are to the nominated String. |
List |
grep(File f,
String s,
boolean ignoreCase)
grep through a file, line by line, and determine what matches there are to the nominated String. |
double |
lastIndexOf(Object o,
Object i)
A thinly veiled wrapper around the String.lastIndexOf(String) method. |
double |
length(Object o)
|
boolean |
regexp(Object o,
String re)
Match a regular expression against the object passed in. |
boolean |
regexp(Object o,
String re,
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 . |
List |
rgrep(File f,
String regexp)
grep through a file, line by line, and determine what matches there are to the nominated regular expression. |
List |
rgrep(File f,
String regexp,
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. |
String |
subStr(Object o,
double f)
Return a substring of the passed in object (in a string form). |
String |
subStr(Object o,
double f,
double t)
A function to return a substring of a String. |
String |
trim(Object o,
Object v)
Given a string trim the passed in string from the front and end, set v to null
to have just whitespace trimmed. |
Methods inherited from class org.josql.functions.AbstractFunctionHandler |
---|
setQuery |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final String HANDLER_ID
Constructor Detail |
---|
public StringFunctions()
Method Detail |
---|
public boolean regexp(Object o, 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(Object o, String re, 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 List grep(File f, 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.
QueryExecutionException
public List rgrep(File f, String regexp, 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 List rgrep(File f, 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 List grep(File f, String s) throws QueryExecutionException
FileMatch
objects.
f
- The File to match against.s
- The string to match.
FileMatch
objects.
QueryExecutionException
public String trim(Object o, 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(Object o, 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 String subStr(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 String subStr(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(Object o)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |