org.android.activityminer.logic.util
Class CSVUtils

Package class diagram package CSVUtils
java.lang.Object
  extended by org.android.activityminer.logic.util.CSVUtils

public class CSVUtils
extends Object

Utility class for data export in CSV format


Constructor Summary
CSVUtils()
           
 
Method Summary
static String asCsvString(String string)
          Does quote a string to a CSV representation
static String fromCsvString(String string)
          Does remove CSV quotes from a string
static String[] readCSVHeader(BufferedReader reader)
          Does read the attribute names from an CSV header.
static String[] readCSVRow(BufferedReader reader)
          Does read a CSV row into a String array.
static Activity readCSVRow(BufferedReader reader, String[] attributes, android.support.v4.util.LongSparseArray<String> cNamesPerId)
          Does generate a training sample from a CSV row entry.
static void writeCSVHeader(TrainingActivity activity, PrintWriter writer)
          Does generate a CSV row from a training sample.
static void writeCSVRow(String[] values, PrintWriter writer)
          Does generate a CSV file row from a String array.
static void writeCSVRow(TrainingActivity activity, String activityName, PrintWriter writer)
          Does generate a CSV header from a training sample.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CSVUtils

public CSVUtils()
Method Detail

fromCsvString

public static final String fromCsvString(String string)
Does remove CSV quotes from a string

Parameters:
string - the string to convert
Returns:
a string without CSV quotes

asCsvString

public static final String asCsvString(String string)
Does quote a string to a CSV representation

Parameters:
string - the string to convert to a csv string
Returns:
a CSV compatible string

writeCSVRow

public static final void writeCSVRow(String[] values,
                                     PrintWriter writer)
Does generate a CSV file row from a String array.

Parameters:
values - the values to generate CSV row from
writer - the writer to use

readCSVRow

public static final String[] readCSVRow(BufferedReader reader)
                                 throws IOException
Does read a CSV row into a String array.

Parameters:
reader - the reader to use
Returns:
the string values from the CSV row
Throws:
IOException

writeCSVRow

public static final void writeCSVRow(TrainingActivity activity,
                                     String activityName,
                                     PrintWriter writer)
Does generate a CSV header from a training sample.

Parameters:
activity - the training sample to generate CSV header from
activityName - the activity class name
writer - the writer to use

writeCSVHeader

public static final void writeCSVHeader(TrainingActivity activity,
                                        PrintWriter writer)
Does generate a CSV row from a training sample.

Parameters:
activity - the training sample to generate CSV row from
writer - the writer to use

readCSVRow

public static final Activity readCSVRow(BufferedReader reader,
                                        String[] attributes,
                                        android.support.v4.util.LongSparseArray<String> cNamesPerId)
                                 throws IOException
Does generate a training sample from a CSV row entry.

Parameters:
reader - the reader to use
attributes - the attributes from the header
cNamesPerId - the class name to unique class identifier mapping
Returns:
a training activity created from the row
Throws:
IOException

readCSVHeader

public static final String[] readCSVHeader(BufferedReader reader)
                                    throws IOException
Does read the attribute names from an CSV header.

Parameters:
reader - the reader to use
Returns:
the attribute names
Throws:
IOException