org.sandev.basics.util
Class CSVTransforms

java.lang.Object
  extended by org.sandev.basics.util.CSVTransforms

public class CSVTransforms
extends java.lang.Object

Converts an array of basic types to a comma separated value String. Sample uses include simple UI displays or text reports. In at least some of these cases, going through an XML representation in the process of transforming is overkill, so this class covers the point-to-point conversion. This only works for basic types, not hierarchical data.

CSV output in this case means a value, then a comma, then a space, then a value. CSV input does its best with what it gets. Numbers are not quoted, Strings are surrounded in doublequotes using backslash escape character notation for internal doublequotes and backslashes.


Constructor Summary
CSVTransforms()
           
 
Method Summary
static boolean[] booleanArray(java.lang.String val)
          convert the CSV string to a boolean array
static java.lang.String csvString(boolean[] bools)
          convert the boolean array to a CSV string
static java.lang.String csvString(double[] doubles)
          convert the double array to a CSV string
static java.lang.String csvString(int[] ints)
          convert the int array to a CSV string
static java.lang.String csvString(long[] longs)
          convert the long array to a CSV string
static java.lang.String csvString(java.lang.String[] strings)
          convert the string array to a CSV string
static double[] doubleArray(java.lang.String val)
          convert the CSV string to a double array
static int[] intArray(java.lang.String val)
          convert the CSV string to an int array
static long[] longArray(java.lang.String val)
          convert the CSV string to a long array
static java.lang.String[] stringArray(java.lang.String val)
          convert the CSV string to an array of single Strings.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CSVTransforms

public CSVTransforms()
Method Detail

csvString

public static java.lang.String csvString(boolean[] bools)
convert the boolean array to a CSV string


booleanArray

public static boolean[] booleanArray(java.lang.String val)
convert the CSV string to a boolean array


csvString

public static java.lang.String csvString(int[] ints)
convert the int array to a CSV string


intArray

public static int[] intArray(java.lang.String val)
convert the CSV string to an int array


csvString

public static java.lang.String csvString(long[] longs)
convert the long array to a CSV string


longArray

public static long[] longArray(java.lang.String val)
convert the CSV string to a long array


csvString

public static java.lang.String csvString(double[] doubles)
convert the double array to a CSV string


doubleArray

public static double[] doubleArray(java.lang.String val)
convert the CSV string to a double array


csvString

public static java.lang.String csvString(java.lang.String[] strings)
convert the string array to a CSV string


stringArray

public static java.lang.String[] stringArray(java.lang.String val)
convert the CSV string to an array of single Strings. This method is also used as a general purpose workhorse for performing this piece of the transformation. It is aware of the double quoting and escape characters, but will work even if the comma separated values are not quoted.