Back to project page improv-referee.
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.
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; } }