Skip to content

Commit 194e21c

Browse files
committed
More Javadoc for CSVFormat
git-svn-id: https://svn.apache.org/repos/asf/commons/sandbox/csv/trunk@1298176 13f79535-47bb-0310-9956-ffa450edef68
1 parent ca7bbae commit 194e21c

1 file changed

Lines changed: 117 additions & 2 deletions

File tree

src/main/java/org/apache/commons/csv/CSVFormat.java

Lines changed: 117 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,20 +126,42 @@ public class CSVFormat implements Cloneable, Serializable {
126126
this.emptyLinesIgnored = emptyLinesIgnored;
127127
}
128128

129+
/**
130+
* Returns the character delimiting the values (typically ';', ',' or '\t').
131+
*
132+
* @return the delimiter character
133+
*/
129134
public char getDelimiter() {
130135
return delimiter;
131136
}
132137

138+
/**
139+
* Returns a copy of this format using the specified delimiter character.
140+
*
141+
* @param delimiter the delimiter character
142+
* @return A copy of this format using the specified delimiter character
143+
*/
133144
public CSVFormat withDelimiter(char delimiter) {
134145
CSVFormat format = clone();
135146
format.delimiter = delimiter;
136147
return format;
137148
}
138149

150+
/**
151+
* Returns the character used to encapsulate values containing special characters.
152+
*
153+
* @return the encapsulator character
154+
*/
139155
public char getEncapsulator() {
140156
return encapsulator;
141157
}
142158

159+
/**
160+
* Returns a copy of this format using the specified encapsulator character.
161+
*
162+
* @param encapsulator the encapsulator character
163+
* @return A copy of this format using the specified encapsulator character
164+
*/
143165
public CSVFormat withEncapsulator(char encapsulator) {
144166
CSVFormat format = clone();
145167
format.encapsulator = encapsulator;
@@ -150,24 +172,51 @@ boolean isEncapsulating() {
150172
return this.encapsulator != DISABLED;
151173
}
152174

175+
/**
176+
* Returns the character marking the start of a line comment.
177+
*
178+
* @return the comment start marker.
179+
*/
153180
public char getCommentStart() {
154181
return commentStart;
155182
}
156183

184+
/**
185+
* Returns a copy of this format using the specified character as the comment start marker.
186+
*
187+
* @param commentStart the comment start marker
188+
* @return A copy of this format using the specified character as the comment start marker
189+
*/
157190
public CSVFormat withCommentStart(char commentStart) {
158191
CSVFormat format = clone();
159192
format.commentStart = commentStart;
160193
return format;
161194
}
162195

196+
/**
197+
* Tells if comments are supported by this format.
198+
*
199+
* @return <tt>true</tt> is comments are supported, <tt>false</tt> otherwise
200+
*/
163201
public boolean isCommentingDisabled() {
164202
return this.commentStart == DISABLED;
165203
}
166204

205+
/**
206+
* Returns the escape character.
207+
*
208+
* @return the escape character
209+
*/
167210
public char getEscape() {
168211
return escape;
169212
}
170213

214+
/**
215+
* Returns a copy of this format using the specified escape character.
216+
*
217+
* @param escape the escape character
218+
* @return A copy of this format using the specified escape character
219+
*/
171220
public CSVFormat withEscape(char escape) {
172221
CSVFormat format = clone();
173222
format.escape = escape;
@@ -178,57 +227,123 @@ boolean isEscaping() {
178227
return this.escape != DISABLED;
179228
}
180229

230+
/**
231+
* Tells if the spaces characters at the beginning of the values are ignored when parsing a file.
232+
*
233+
* @return <tt>true</tt> if leading spaces are removed, <tt>false</tt> if they are preserved.
234+
*/
181235
public boolean isLeadingSpacesIgnored() {
182236
return leadingSpacesIgnored;
183237
}
184238

239+
/**
240+
* Returns a copy of this format with the specified left trimming behavior.
241+
*
242+
* @param leadingSpacesIgnored the left trimming behavior, <tt>true</tt> to remove the leading spaces,
243+
* <tt>false</tt> to leave the spaces as is.
244+
* @return A copy of this format with the specified left trimming behavior.
245+
*/
185246
public CSVFormat withLeadingSpacesIgnored(boolean leadingSpacesIgnored) {
186247
CSVFormat format = clone();
187248
format.leadingSpacesIgnored = leadingSpacesIgnored;
188249
return format;
189250
}
190251

252+
/**
253+
* Tells if the spaces characters at the end of the values are ignored when parsing a file.
254+
*
255+
* @return <tt>true</tt> if trailing spaces are removed, <tt>false</tt> if they are preserved.
256+
*/
191257
public boolean isTrailingSpacesIgnored() {
192258
return trailingSpacesIgnored;
193259
}
194260

261+
/**
262+
* Returns a copy of this format with the specified right trimming behavior.
263+
*
264+
* @param trailingSpacesIgnored the right trimming behavior, <tt>true</tt> to remove the trailing spaces,
265+
* <tt>false</tt> to leave the spaces as is.
266+
* @return A copy of this format with the specified right trimming behavior.
267+
*/
195268
public CSVFormat withTrailingSpacesIgnored(boolean trailingSpacesIgnored) {
196269
CSVFormat format = clone();
197270
format.trailingSpacesIgnored = trailingSpacesIgnored;
198271
return format;
199272
}
200273

274+
/**
275+
* Returns a copy of this format with the specified trimming behavior.
276+
*
277+
* @param surroundingSpacesIgnored the trimming behavior, <tt>true</tt> to remove the surrounding spaces,
278+
* <tt>false</tt> to leave the spaces as is.
279+
* @return A copy of this format with the specified trimming behavior.
280+
*/
201281
public CSVFormat withSurroundingSpacesIgnored(boolean surroundingSpacesIgnored) {
202282
CSVFormat format = clone();
203283
format.leadingSpacesIgnored = surroundingSpacesIgnored;
204284
format.trailingSpacesIgnored = surroundingSpacesIgnored;
205285
return format;
206286
}
207-
287+
288+
/**
289+
* Tells if unicode escape sequences (i.e <span>\</span>u1234) are turned into their corresponding character.
290+
*
291+
* @return <tt>true</tt> if unicode escape sequences are interpreted, <tt>false</tt> if they are left as is.
292+
*/
208293
public boolean isUnicodeEscapesInterpreted() {
209294
return unicodeEscapesInterpreted;
210295
}
211296

297+
/**
298+
* Returns a copy of this format with the specified unicode escaping behavior.
299+
*
300+
* @param unicodeEscapesInterpreted the escaping behavior, <tt>true</tt> to interpret unicode escape sequences,
301+
* <tt>false</tt> to leave the escape sequences as is.
302+
* @return A copy of this format with the specified unicode escaping behavior.
303+
*/
212304
public CSVFormat withUnicodeEscapesInterpreted(boolean unicodeEscapesInterpreted) {
213305
CSVFormat format = clone();
214306
format.unicodeEscapesInterpreted = unicodeEscapesInterpreted;
215307
return format;
216308
}
217309

310+
/**
311+
* Tells if the empty lines between the records are ignored.
312+
*
313+
* @return <tt>true</tt> if empty lines between records are ignore, <tt>false</tt> if they are turned into empty records.
314+
*/
218315
public boolean isEmptyLinesIgnored() {
219316
return emptyLinesIgnored;
220317
}
221318

319+
/**
320+
* Returns a copy of this format with the specified empty line skipping behavior.
321+
*
322+
* @param emptyLinesIgnored the empty line skipping behavior, <tt>true</tt> to ignore the empty lines
323+
* between the records, <tt>false</tt> to translate empty lines to empty records.
324+
* @return A copy of this format with the specified empty line skipping behavior.
325+
*/
222326
public CSVFormat withEmptyLinesIgnored(boolean emptyLinesIgnored) {
223327
CSVFormat format = clone();
224328
format.emptyLinesIgnored = emptyLinesIgnored;
225329
return format;
226330
}
227331

332+
/**
333+
* Returns the line separator delimiting the records.
334+
*
335+
* @return the line separator
336+
*/
228337
public String getLineSeparator() {
229338
return lineSeparator;
230339
}
231340

341+
/**
342+
* Returns a copy of this format using the specified line separator.
343+
*
344+
* @param lineSeparator the line separator
345+
* @return A copy of this format using the specified line separator
346+
*/
232347
public CSVFormat withLineSeparator(String lineSeparator) {
233348
CSVFormat format = clone();
234349
format.lineSeparator = lineSeparator;
@@ -238,7 +353,7 @@ public CSVFormat withLineSeparator(String lineSeparator) {
238353
/**
239354
* Parses the specified content.
240355
*
241-
* @param in
356+
* @param in the input stream
242357
*/
243358
public Iterable<String[]> parse(Reader in) {
244359
return new CSVParser(in, this);

0 commit comments

Comments
 (0)