model.util
Class GeneralUtils

java.lang.Object
  extended by model.util.GeneralUtils

public class GeneralUtils
extends Object

This class contains various utility methods that are used throughout the program.


Constructor Summary
GeneralUtils()
           
 
Method Summary
static String genDataSet(String key, String data)
          This method will create a set of XML tags with the proper new lines and the given data inbetween.
static String parseDataSet(String key, String data)
          This method will take a set of data, and find the first instance of the given key.
static String[] parseDataSets(String key, String data)
          This method will search through a set a data and pull out the data every time a key pair occurs.
static String shortToString(short value)
          This method takes a short value (ranged 0 to 255) and converts it to a String (ranged 0 to 100).
static short stringToShort(String value)
          This method takes in a string (that should be between 0 and 100) and returns a short with a range of 0 to 255.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GeneralUtils

public GeneralUtils()
Method Detail

stringToShort

public static short stringToShort(String value)
This method takes in a string (that should be between 0 and 100) and returns a short with a range of 0 to 255. Negative values have special meanings.

Parameters:
value - The string to convert.
Returns:
The short value of the string.

shortToString

public static String shortToString(short value)
This method takes a short value (ranged 0 to 255) and converts it to a String (ranged 0 to 100).

Parameters:
value - The short value, range 0 to 255, or negative.
Returns:
The string value ranged 0 to 100, or blank is the value is negative.

genDataSet

public static String genDataSet(String key,
                                String data)
This method will create a set of XML tags with the proper new lines and the given data inbetween.

Parameters:
key - The key to use inside the XML tags.
data - The data to put between the tags.

parseDataSet

public static String parseDataSet(String key,
                                  String data)
This method will take a set of data, and find the first instance of the given key. It will then return the data between this first set of the key, without the key itself.

Parameters:
key - The XML tag key.
data - The data to search through.

parseDataSets

public static String[] parseDataSets(String key,
                                     String data)
This method will search through a set a data and pull out the data every time a key pair occurs.

Parameters:
key - The XML key to search for.
data - The data to search in.
Returns:
The array of data between the tags, not including the tags themselves.