ccs.utils
Class TextBoxParser

java.lang.Object
  extended by ccs.utils.TextBoxParser

public class TextBoxParser
extends java.lang.Object

A multiline text box is an easy way to obtain a list of items from a user: one item per line, you're laughing. However, you then have to parse the contents of the text box into your data structure. This utility class does that for you. It also does the inverse - assembling an array of strings into a string you can feed to the text box.


Constructor Summary
TextBoxParser()
           
 
Method Summary
static java.lang.String assembleTextBox(java.lang.String[] srcs)
          parses the supplied string array into a string suitable for JTextArea.setText() which is returned.
static java.lang.String[] parseTextBox(java.lang.String src)
          parses the result of JTextArea.getText() into strings (one per line) which are returned.
static void parseTextBox(java.lang.String source, java.util.Collection<java.lang.String> target, boolean shouldClear)
          parses the result of JTextArea.getText() into strings (one per line) which are appended to the supplied Vector.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TextBoxParser

public TextBoxParser()
Method Detail

parseTextBox

public static void parseTextBox(java.lang.String source,
                                java.util.Collection<java.lang.String> target,
                                boolean shouldClear)
parses the result of JTextArea.getText() into strings (one per line) which are appended to the supplied Vector.

Parameters:
source - The multi-line string.
target - Where to put the results.
shouldClear - whether any pre-existing elements should be removed first.

parseTextBox

public static java.lang.String[] parseTextBox(java.lang.String src)
parses the result of JTextArea.getText() into strings (one per line) which are returned. This is implemented as a wrapper around the method of three parameters.

Parameters:
src - The multi-line string.
Returns:
The parsed strings.

assembleTextBox

public static java.lang.String assembleTextBox(java.lang.String[] srcs)
parses the supplied string array into a string suitable for JTextArea.setText() which is returned.

Parameters:
srcs - The strings to assemble
Returns:
The assembled string.