org.jaffa.util
Class SplitString

java.lang.Object
  extended byorg.jaffa.util.SplitString

public class SplitString
extends Object

This class splits a String based on a separator. It then sets the prefix and suffix.


Constructor Summary
SplitString(String source, String separator)
          Creates an instance with the source String and separator.
SplitString(String source, String separator, boolean findFirst)
          Creates an instance with the source String and separator.
 
Method Summary
 String getPrefix()
          Returns the prefix String that was created as a result of the split.
 String getSuffix()
          Returns the suffix String that was created as a result of the split.
 boolean isValid()
          The definition of a valid split is one where either there was no split in the string, or the splitter resulted in two new strings.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SplitString

public SplitString(String source,
                   String separator)
Creates an instance with the source String and separator. The source String will be split based on the separator. This a short hand version of SplitString(source, separator, true)

Parameters:
source - The source String.
separator - The separator used for splitting the source String.

SplitString

public SplitString(String source,
                   String separator,
                   boolean findFirst)
Creates an instance with the source String and separator. The source String will be split based on the separator.

Parameters:
source - The source String.
separator - The separator used for splitting the source String.
findFirst - If true splits based on first occurence of seperator, if false split is done on the last occurence.
Method Detail

isValid

public boolean isValid()
The definition of a valid split is one where either there was no split in the string, or the splitter resulted in two new strings. (i.e the separator should not start or end the string)

Returns:
a true if the split is valid.

getPrefix

public String getPrefix()
Returns the prefix String that was created as a result of the split.

Returns:
the prefix String that was created as a result of the split.

getSuffix

public String getSuffix()
Returns the suffix String that was created as a result of the split.

Returns:
the suffix String that was created as a result of the split.


Copyright © 2002-2004 JAFFA Project.