|
|||||||||||||||||||
30 day Evaluation Version distributed via the Maven Jar Repository. Clover is not free. You have 30 days to evaluate it. Please visit http://www.thecortex.net/clover to obtain a licensed version of Clover | |||||||||||||||||||
Source file | Conditionals | Statements | Methods | TOTAL | |||||||||||||||
SimpleSVParser.java | 50% | 78.6% | 66.7% | 70.8% |
|
1 |
/*
|
|
2 |
* brownies and its relative products are published under the terms
|
|
3 |
* of the Apache Software License.
|
|
4 |
*
|
|
5 |
* Created on 2004/05/19 14:03:29
|
|
6 |
*/
|
|
7 |
package org.asyrinx.brownie.core.csv;
|
|
8 |
|
|
9 |
import java.io.BufferedReader;
|
|
10 |
import java.io.IOException;
|
|
11 |
import java.io.Reader;
|
|
12 |
import java.util.ArrayList;
|
|
13 |
import java.util.List;
|
|
14 |
|
|
15 |
import org.asyrinx.brownie.core.lang.StringUtils;
|
|
16 |
|
|
17 |
/**
|
|
18 |
* @author akima
|
|
19 |
*/
|
|
20 |
public class SimpleSVParser implements SVParser { |
|
21 |
|
|
22 |
/**
|
|
23 |
*
|
|
24 |
*/
|
|
25 | 4 |
public SimpleSVParser() {
|
26 | 4 |
super();
|
27 |
} |
|
28 |
|
|
29 |
private SVParserListener listener;
|
|
30 |
|
|
31 |
private String delimeter = String.valueOf(DELIM_COMMA);
|
|
32 |
|
|
33 | 4 |
public void parse(Reader reader) throws IOException { |
34 | 4 |
final BufferedReader bufferedReader = new BufferedReader(reader);
|
35 | 4 |
String line = bufferedReader.readLine(); |
36 | 4 |
final List dest = new ArrayList();
|
37 | 4 |
while (line != null) { |
38 | 8 |
StringUtils.tokenize(dest, line, delimeter); |
39 | 8 |
listener.onLine(dest); |
40 | 8 |
line = bufferedReader.readLine(); |
41 | 8 |
dest.clear(); |
42 |
} |
|
43 |
} |
|
44 |
|
|
45 |
/**
|
|
46 |
* @return
|
|
47 |
*/
|
|
48 | 0 |
public String getDelimeter() {
|
49 | 0 |
return delimeter;
|
50 |
} |
|
51 |
|
|
52 |
/**
|
|
53 |
* @param string
|
|
54 |
*/
|
|
55 | 3 |
public void setDelimeter(String string) { |
56 | 3 |
delimeter = string; |
57 |
} |
|
58 |
|
|
59 | 4 |
public void addListener(SVParserListener l) { |
60 | 4 |
this.listener = l;
|
61 |
} |
|
62 |
|
|
63 | 0 |
public void removeListener(SVParserListener l) { |
64 | 0 |
if (this.listener == l) |
65 | 0 |
this.listener = null; |
66 |
} |
|
67 |
|
|
68 |
} |
|