org.moremotion.util
Class StringParserEx

java.lang.Object
  extended by org.moremotion.util.StringParserEx

public class StringParserEx
extends java.lang.Object

String Parser parses the items in a string bwith 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"
 

Version:
$Id: StringParserEx.java 51 2008-03-10 11:46:54Z erkan $

Constructor Summary
StringParserEx(java.lang.String str, java.lang.String[] dlms, char[] oencls, char[] cencls)
          Creates a new StringParser
 
Method Summary
 java.lang.String firstItem()
          Returns the first item in the string.
 java.lang.String getDelimiter()
           
 boolean hasMore()
          Returns true if end of string is reached.
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

StringParserEx

public StringParserEx(java.lang.String str,
                      java.lang.String[] dlms,
                      char[] oencls,
                      char[] cencls)
Creates a new StringParser

Method Detail

hasMore

public boolean hasMore()
Returns true if end of string is reached.


trimmed

public void trimmed()

firstItem

public java.lang.String firstItem()
Returns the first item in the string.


nextItem

public java.lang.String nextItem()
Returns the next item in the string.


reset

public void reset()
Moves the cursor to the first position.


getDelimiter

public java.lang.String getDelimiter()

nextItemAsInt

public int nextItemAsInt(int defValue)
Returns the next item as int and if next item is not a number it returns the default value.


nextItemAsBoolean

public boolean nextItemAsBoolean()
Returns the next item as boolean. If the next item is not "true" returns false.


nextEnclosed

public java.lang.String nextEnclosed()

main

public static void main(java.lang.String[] args)


Copyright © 2002-2008 MOR YAZILIM. All Rights Reserved.