01: /*
02: * Copyright 2004-2006 Fouad HAMDI.
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
15: */
16: package org.csvbeans.parsers;
17:
18: import org.csvbeans.InvalidFieldException;
19: import org.csvbeans.specs.BeanSpecification;
20:
21: /**
22: * Define the specifications of a CSV line parser.
23: *
24: * @author Fouad Hamdi
25: * @since 0.5
26: */
27: public interface LineParser {
28: /**
29: * Parse the specified CSV line.
30: *
31: * @return the object representing the line according to the record
32: * specifications.
33: * @throws InvalidCSVLineException
34: * when there is a problem during the parsing.
35: */
36: Object parse() throws CSVLineException, InvalidFieldException;
37:
38: /**
39: * @param beanSpecification
40: * The beanSpecification to set.
41: */
42: void setBeanSpecification(BeanSpecification beanSpecification);
43:
44: /**
45: * Define the separator. By default, it is a ;
46: *
47: * @param separator
48: */
49: void setFieldSeparator(String separator);
50:
51: /**
52: * Specify that the empty values must be saved as empty strings instead of
53: * null values.
54: */
55: void setSaveEmptyTokens(boolean flag);
56:
57: /**
58: * Allow to know if the number of lines associated with the parser matches
59: * the number of lines needed to build the matching object.
60: */
61: boolean isThresholdReached();
62:
63: /**
64: * Add a line to build the matching object.
65: *
66: * @param line
67: */
68: void addToLineSet(String line);
69:
70: /**
71: * Clear the lines used to build the matching object.
72: *
73: */
74: void clearLineSet();
75:
76: /**
77: * Return the lineset currently parsed.
78: */
79: String getCurrentLineSet();
80:
81: /**
82: * Define the quote separator.
83: */
84: void setQuoteSeparator(String quoteSeparator);
85: }
|