FileDocCategorySizeDatePackage
CSVFormatter.javaAPI DocAndroid 5.1 API3220Thu Mar 12 22:22:44 GMT 2015com.android.locationtracker.data

CSVFormatter

public class CSVFormatter extends Object implements IFormatter
Formats tracker data as CSV output

Fields Summary
private static final String
DELIMITER
Constructors Summary
Methods Summary
public java.lang.StringgetFooter()

        // not needed, return empty string
        return "";
    
public java.lang.StringgetHeader()


       
        StringBuilder csvBuilder = new StringBuilder();
        for (String col : TrackerEntry.ATTRIBUTES) {
            // skip type and id column
            if (!TrackerEntry.ENTRY_TYPE.equals(col) &&
                !TrackerEntry.ID_COL.equals(col)) {
                csvBuilder.append(col);
                csvBuilder.append(DELIMITER);
            }
        }
        csvBuilder.append("\n");
        return csvBuilder.toString();
    
public java.lang.StringgetOutput(TrackerEntry entry)

        StringBuilder rowOutput = new StringBuilder();
        // these must match order of columns added in getHeader
        rowOutput.append(entry.getTimestamp());
        rowOutput.append(DELIMITER);
        rowOutput.append(entry.getTag());
        rowOutput.append(DELIMITER);
        //rowOutput.append(entry.getType());
        //rowOutput.append(DELIMITER);
        if (entry.getType() == EntryType.LOCATION_TYPE) {
            if (entry.getLocation().hasAccuracy()) {
                rowOutput.append(entry.getLocation().getAccuracy());
            }
            rowOutput.append(DELIMITER);
            rowOutput.append(entry.getLocation().getLatitude());
            rowOutput.append(DELIMITER);
            rowOutput.append(entry.getLocation().getLongitude());
            rowOutput.append(DELIMITER);
            if (entry.getLocation().hasAltitude()) {
                rowOutput.append(entry.getLocation().getAltitude());
            }
            rowOutput.append(DELIMITER);
            if (entry.getLocation().hasSpeed()) {
                rowOutput.append(entry.getLocation().getSpeed());
            }
            rowOutput.append(DELIMITER);
            if (entry.getLocation().hasBearing()) {
                rowOutput.append(entry.getLocation().getBearing());
            }
            rowOutput.append(DELIMITER);
            rowOutput.append(entry.getDistFromNetLocation());
            rowOutput.append(DELIMITER);
            rowOutput.append(DateUtils.getKMLTimestamp(entry.getLocation()
                    .getTime()));
            rowOutput.append(DELIMITER);
        }
        rowOutput.append(entry.getLogMsg());
        rowOutput.append("\n");
        return rowOutput.toString();