Android Open Source - improv-referee Improv Line Reader






From Project

Back to project page improv-referee.

License

The source code is released under:

Copyright (C) <2011> by <Pierre-Henri Trivier> Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to de...

If you think the Android project improv-referee listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package fr.pht.improv.reader;
//from w w w . j  a v  a 2s.c om
import java.io.IOException;

import org.apache.commons.csv.CSVParser;
import org.apache.commons.csv.CSVUtils;

import fr.pht.improv.model.Improv;
import fr.pht.improv.model.ImprovType;

import android.util.Log;

public class ImprovLineReader {
    
    public boolean isBlank(String str) {
        return str == null || "".equals(str);
    }
    
    public Improv readLine(String line) {
        
        Improv res = new Improv();
        
        String[] tokens;
        try {
            // TODO(pht) some error handling ...
            tokens = CSVUtils.parseLine(line);
        
            if (!isBlank(tokens[0])) {
                if ("M".equals(tokens[0])) {
                    res.setType(ImprovType.MIXT);
                } else {
                    res.setType(ImprovType.COMPARED);
                }
            }
            
            res.setTitle(tokens[1]);
            
            res.setCategory(tokens[2]);
            
            if (!isBlank(tokens[3])) {
                res.setPlayerCount(Integer.parseInt(tokens[3]));
            }
            
            res.setDuration(Integer.parseInt(tokens[4]));
            
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
            res = null;
        }

        return res;
    }
}




Java Source Code List

fr.pht.improv.db.ImprovDbHelper.java
fr.pht.improv.db.ImprovDbTable.java
fr.pht.improv.model.ImprovRenderer.java
fr.pht.improv.model.ImprovType.java
fr.pht.improv.model.Improv.java
fr.pht.improv.reader.ImprovDatabaseReader.java
fr.pht.improv.reader.ImprovLineReader.java
fr.pht.improv.referee.ImprovDetailActivity.java
fr.pht.improv.referee.ImprovListActivity.java
fr.pht.improv.referee.ImprovListFragment.java
fr.pht.improv.referee.ImprovRefereeActivity.java
fr.pht.improv.referee.ProgressListener.java
fr.pht.improv.referee.ProgressTimer.java
fr.pht.improv.referee.contentprovider.ImprovContentProvider.java