|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.moremotion.util.StringParser
public class StringParser
String Parser parses the items in a string with the specified delimiter. The difference of this class from the java.util.StringTokenizer is that this class ignores the delimiters enclosed with (), [], {} , '', "" characters.
Example:
StringParser sp = new StringParser("(xxx,yyy)',',[(qqq,www),(ppp,rrr)],zzz",','); sp.nextItem(); // returns "(xxx,yyy)','" sp.nextItem(); // returns "[(qqq,www),(ppp,rrr)] sp.nextItem(); // returns "zzz"
Constructor Summary | |
---|---|
StringParser(java.lang.String str,
char dlm)
Creates a new StringParser |
Method Summary | |
---|---|
boolean |
eos()
Returns true if end of string is reached. |
static java.lang.String |
extractParameter(java.lang.String str,
java.lang.String param)
This static method extracts the values of the parameters existing in a string in parm1=parm1value; parm2=parm2 value;
format. |
java.lang.String |
firstItem()
Returns the first item in the string. |
boolean |
hasMore()
|
int |
itemCount()
Returns the next item in the string. |
static int |
locateChar(java.lang.StringBuffer buffer,
int startPos,
char c)
This static method returns the position of the specified character in the given string buffer. |
static int |
locateChar(java.lang.String str,
int startPos,
char c)
This static method returns the position of the specified character in the given string. |
static void |
main(java.lang.String[] args)
|
java.lang.String |
nextEnclosed()
|
java.lang.String |
nextItem()
Returns the next item in the string. |
boolean |
nextItemAsBoolean()
Returns the next item as boolean . |
int |
nextItemAsInt(int defValue)
Returns the next item as int and if next item is not a number it returns the default value. |
void |
reset()
Moves the cursor to the first position. |
void |
trimmed()
|
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public StringParser(java.lang.String str, char dlm)
Method Detail |
---|
public boolean eos()
true
if end of string is reached.
public boolean hasMore()
public void trimmed()
public java.lang.String firstItem()
public java.lang.String nextItem()
public int itemCount()
public void reset()
public int nextItemAsInt(int defValue)
int
and if next item is not a number it returns the default value.
public java.lang.String nextEnclosed()
public boolean nextItemAsBoolean()
boolean
. If the next item is not "true" returns false
.
public static int locateChar(java.lang.String str, int startPos, char c)
str
- The string where c
will be searched.startPos
- Search Start Positionc
- The character to be searched.
c
in the str
. If c
is not found -1 is returned.public static int locateChar(java.lang.StringBuffer buffer, int startPos, char c)
buffer
- The string buffer where c
will be searched.startPos
- Search Start Positionc
- The character to be searched.
c
in the str
. If c
is not found -1 is returned.public static java.lang.String extractParameter(java.lang.String str, java.lang.String param)
parm1=parm1value; parm2=parm2 value;
format.
str
- The string where param
will be searched.param
- The name of the parameter whose value to be extracted.
public static void main(java.lang.String[] args) throws java.lang.Exception
java.lang.Exception
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |