- java.lang.Object
-
- org.refcodes.textual.CsvBuilder
-
- All Implemented Interfaces:
org.refcodes.mixin.DelimiterAccessor
,org.refcodes.mixin.DelimiterAccessor.DelimiterBuilder<CsvMixin>
,org.refcodes.mixin.DelimiterAccessor.DelimiterMutator
,org.refcodes.mixin.DelimiterAccessor.DelimiterProperty
,org.refcodes.mixin.TrimAccessor
,org.refcodes.mixin.TrimAccessor.TrimBuilder<CsvMixin>
,org.refcodes.mixin.TrimAccessor.TrimMutator
,org.refcodes.mixin.TrimAccessor.TrimProperty
,CsvEscapeModeAccessor
,CsvEscapeModeAccessor.CsvEscapeModeBuilder<CsvMixin>
,CsvEscapeModeAccessor.CsvEscapeModeMutator
,CsvEscapeModeAccessor.CsvEscapeModeProperty
,CsvMixin
public class CsvBuilder extends Object implements CsvMixin
This class implements CSV processing functionality.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.refcodes.textual.CsvEscapeModeAccessor
CsvEscapeModeAccessor.CsvEscapeModeBuilder<B extends CsvEscapeModeAccessor.CsvEscapeModeBuilder<?>>, CsvEscapeModeAccessor.CsvEscapeModeMutator, CsvEscapeModeAccessor.CsvEscapeModeProperty
-
Nested classes/interfaces inherited from interface org.refcodes.mixin.DelimiterAccessor
org.refcodes.mixin.DelimiterAccessor.DelimiterBuilder<B extends org.refcodes.mixin.DelimiterAccessor.DelimiterBuilder<B>>, org.refcodes.mixin.DelimiterAccessor.DelimiterMutator, org.refcodes.mixin.DelimiterAccessor.DelimiterProperty
-
-
Constructor Summary
Constructors Constructor Description CsvBuilder()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static List<String>
asFields(String aRecord, char aDelimiter, CsvEscapeMode aCsvEscapeMode, boolean isTrim)
Creates fields from the given record.static String
asRecord(Collection<Object> aFields, char aDelimiter, CsvEscapeMode aCsvEscapeMode)
Creates a record from the given fields.static String[]
asStrings(String aRecord, char aDelimiterChar, CsvEscapeMode aCsvEscapeMode, boolean isTrim, String[] aCommentPrefixes)
Splits a record into dedicated fields.void
clearCommentPrefixes()
Clears the prefixes used to identify CSV lines to be ignored.String[]
getCommentPrefixes()
Gets the prefixes used to identify CSV lines to be ignored.CsvEscapeMode
getCsvEscapeMode()
Gets the currently setCsvEscapeMode
being used.char
getDelimiter()
Collection<Object>
getFields()
Retrieves the CSV elements from the CSV elements property.String
getRecord()
Retrieves the CSV line from the CSV line property.boolean
isTrim()
void
setCommentPrefixes(String... aCommentPrefixes)
Sets the prefixes used to identify CSV lines to be ignored.void
setCsvEscapeMode(CsvEscapeMode aCsvEscapeMode)
Sets theCsvEscapeMode
to be used.void
setDelimiter(char aDelimiterChar)
void
setFields(boolean... aFields)
Sets the CSV elements for the CSV elements property.void
setFields(byte... aFields)
Sets the CSV elements for the CSV elements property.void
setFields(char... aFields)
Sets the CSV elements for the CSV elements property.void
setFields(double... aFields)
Sets the CSV elements for the CSV elements property.void
setFields(float... aFields)
Sets the CSV elements for the CSV elements property.void
setFields(int... aFields)
Sets the CSV elements for the CSV elements property.void
setFields(long... aFields)
Sets the CSV elements for the CSV elements property.void
setFields(short... aFields)
Sets the CSV elements for the CSV elements property.void
setFields(Boolean... aFields)
Sets the CSV elements for the CSV elements property.void
setFields(Byte... aFields)
Sets the CSV elements for the CSV elements property.void
setFields(Character... aFields)
Sets the CSV elements for the CSV elements property.void
setFields(Double... aFields)
Sets the CSV elements for the CSV elements property.void
setFields(Float... aFields)
Sets the CSV elements for the CSV elements property.void
setFields(Integer... aFields)
Sets the CSV elements for the CSV elements property.void
setFields(Long... aFields)
Sets the CSV elements for the CSV elements property.void
setFields(Object... aFields)
Sets the CSV elements for the CSV elements property.void
setFields(Short... aFields)
Sets the CSV elements for the CSV elements property.void
setFields(String... aFields)
Sets the CSV elements for the CSV elements property.void
setFields(Collection<Object> aFields)
Sets the CSV elements for the CSV elements property.void
setRecord(String aRecord)
Sets the CSV line for the CSV line property.void
setTrim(boolean isTrim)
List<String>
toFields()
Creates a list ofString
elements from the CSV line being set viasetRecord(String)
orwithRecord(String)
.String[]
toFields(String aRecord)
Creates an array ofString
s from the CSV line being set viasetRecord(String)
orwithRecord(String)
.String
toRecord()
Creates a CSV line from the elements being set viasetFields(String[])
orwithFields(String[])
.String
toRecord(boolean... aFields)
Creates a CSV line from the fields being provided This method is to be side effect free in terms of the fields (and the resulting record) is not part of the state for this instance (from the point of view of this method).String
toRecord(byte... aFields)
Creates a CSV line from the fields being provided This method is to be side effect free in terms of the fields (and the resulting record) is not part of the state for this instance (from the point of view of this method).String
toRecord(char... aFields)
Creates a CSV line from the fields being provided This method is to be side effect free in terms of the fields (and the resulting record) is not part of the state for this instance (from the point of view of this method).String
toRecord(double... aFields)
Creates a CSV line from the fields being provided This method is to be side effect free in terms of the fields (and the resulting record) is not part of the state for this instance (from the point of view of this method).String
toRecord(float... aFields)
Creates a CSV line from the fields being provided This method is to be side effect free in terms of the fields (and the resulting record) is not part of the state for this instance (from the point of view of this method).String
toRecord(int... aFields)
Creates a CSV line from the fields being provided This method is to be side effect free in terms of the fields (and the resulting record) is not part of the state for this instance (from the point of view of this method).String
toRecord(long... aFields)
Creates a CSV line from the fields being provided This method is to be side effect free in terms of the fields (and the resulting record) is not part of the state for this instance (from the point of view of this method).String
toRecord(short... aFields)
Creates a CSV line from the fields being provided This method is to be side effect free in terms of the fields (and the resulting record) is not part of the state for this instance (from the point of view of this method).String
toRecord(Boolean... aFields)
Creates a CSV line from the fields being provided This method is to be side effect free in terms of the fields (and the resulting record) is not part of the state for this instance (from the point of view of this method).String
toRecord(Byte... aFields)
Creates a CSV line from the fields being provided This method is to be side effect free in terms of the fields (and the resulting record) is not part of the state for this instance (from the point of view of this method).String
toRecord(Character... aFields)
Creates a CSV line from the fields being provided This method is to be side effect free in terms of the fields (and the resulting record) is not part of the state for this instance (from the point of view of this method).String
toRecord(Double... aFields)
Creates a CSV line from the fields being provided This method is to be side effect free in terms of the fields (and the resulting record) is not part of the state for this instance (from the point of view of this method).String
toRecord(Float... aFields)
Creates a CSV line from the fields being provided This method is to be side effect free in terms of the fields (and the resulting record) is not part of the state for this instance (from the point of view of this method).String
toRecord(Integer... aFields)
Creates a CSV line from the fields being provided This method is to be side effect free in terms of the fields (and the resulting record) is not part of the state for this instance (from the point of view of this method).String
toRecord(Long... aFields)
Creates a CSV line from the fields being provided This method is to be side effect free in terms of the fields (and the resulting record) is not part of the state for this instance (from the point of view of this method).String
toRecord(Object... aFields)
Creates a CSV line from the fields being provided This method is to be side effect free in terms of the fields (and the resulting record) is not part of the state for this instance (from the point of view of this method).String
toRecord(Short... aFields)
To record.String
toRecord(String... aFields)
Creates a CSV line from the fields being provided This method is to be side effect free in terms of the fields (and the resulting record) is not part of the state for this instance (from the point of view of this method).String
toRecord(Collection<Object> aFields)
Creates a CSV line from the fields being provided This method is to be side effect free in terms of the fields (and the resulting record) is not part of the state for this instance (from the point of view of this method).String
toString()
TheString
being build by the builder upon the settings of the attributes.String
toString(Object... aFields)
Creates a CSV line from the fields being provided This method is to be side effect free in terms of the fields (and the resulting record) is not part of the state for this instance (from the point of view of this method).String
toString(String... aFields)
Creates a CSV line from the fields being provided This method is to be side effect free in terms of the fields (and the resulting record) is not part of the state for this instance (from the point of view of this method).String
toString(Collection<Object> aFields)
Creates a CSV line from the fields being provided This method is to be side effect free in terms of the fields (and the resulting record) is not part of the state for this instance (from the point of view of this method).String[]
toStrings()
Creates an array ofString
s from the CSV line being set viasetRecord(String)
orwithRecord(String)
.String[]
toStrings(String aRecord)
Convenience method for thetoFields(String)
method.CsvBuilder
withCommentPrefixes(String... aCommentPrefixes)
Sets the prefixes used to identify CSV lines to be ignored.CsvBuilder
withCsvEscapeMode(CsvEscapeMode aCsvEscapeMode)
Sets the rowsCsvEscapeMode
to use returns this builder as of the Builder-Pattern.CsvBuilder
withDelimiter(char aDelimiterChar)
CsvBuilder
withFields(boolean... aFields)
Sets the CSV elements for the CSV elements property.CsvBuilder
withFields(byte... aFields)
Sets the CSV elements for the CSV elements property.CsvBuilder
withFields(char... aFields)
Sets the CSV elements for the CSV elements property.CsvBuilder
withFields(double... aFields)
Sets the CSV elements for the CSV elements property.CsvBuilder
withFields(float... aFields)
Sets the CSV elements for the CSV elements property.CsvBuilder
withFields(int... aFields)
Sets the CSV elements for the CSV elements property.CsvBuilder
withFields(long... aFields)
Sets the CSV elements for the CSV elements property.CsvBuilder
withFields(short... aFields)
Sets the CSV elements for the CSV elements property.CsvBuilder
withFields(Boolean... aFields)
Sets the CSV elements for the CSV elements property.CsvBuilder
withFields(Byte... aFields)
Sets the CSV elements for the CSV elements property.CsvBuilder
withFields(Character... aFields)
Sets the CSV elements for the CSV elements property.CsvBuilder
withFields(Double... aFields)
Sets the CSV elements for the CSV elements property.CsvBuilder
withFields(Float... aFields)
Sets the CSV elements for the CSV elements property.CsvBuilder
withFields(Integer... aFields)
Sets the CSV elements for the CSV elements property.CsvBuilder
withFields(Long... aFields)
Sets the CSV elements for the CSV elements property.CsvBuilder
withFields(Object... aFields)
Sets the CSV elements for the CSV elements property.CsvBuilder
withFields(Short... aFields)
Sets the CSV elements for the CSV elements property.CsvBuilder
withFields(String... aFields)
Sets the CSV elements for the CSV elements property.CsvBuilder
withFields(Collection<Object> aFields)
Sets the CSV elements for the CSV elements property.CsvBuilder
withRecord(String aRecord)
Sets the CSV line for the CSV line property.CsvBuilder
withTrim(boolean isTrim)
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.refcodes.textual.CsvEscapeModeAccessor.CsvEscapeModeProperty
letCsvEscapeMode
-
-
-
-
Method Detail
-
setTrim
public void setTrim(boolean isTrim)
- Specified by:
setTrim
in interfaceorg.refcodes.mixin.TrimAccessor.TrimMutator
-
isTrim
public boolean isTrim()
- Specified by:
isTrim
in interfaceorg.refcodes.mixin.TrimAccessor
-
getCsvEscapeMode
public CsvEscapeMode getCsvEscapeMode()
Gets the currently setCsvEscapeMode
being used.- Specified by:
getCsvEscapeMode
in interfaceCsvEscapeModeAccessor
- Returns:
- The currently configured
CsvEscapeMode
s.
-
setCsvEscapeMode
public void setCsvEscapeMode(CsvEscapeMode aCsvEscapeMode)
Sets theCsvEscapeMode
to be used.- Specified by:
setCsvEscapeMode
in interfaceCsvEscapeModeAccessor.CsvEscapeModeMutator
- Parameters:
aCsvEscapeMode
- TheCsvEscapeMode
to be stored by theCsvEscapeMode
property.
-
setRecord
public void setRecord(String aRecord)
Sets the CSV line for the CSV line property.- Parameters:
aRecord
- The CSV line to be stored by the CSV line property.
-
getRecord
public String getRecord()
Retrieves the CSV line from the CSV line property.- Returns:
- The CSV line stored by the CSV line property.
-
setFields
public void setFields(Object... aFields)
Sets the CSV elements for the CSV elements property.- Parameters:
aFields
- The CSV elements to be stored by the CSV elements property.
-
getFields
public Collection<Object> getFields()
Retrieves the CSV elements from the CSV elements property.- Returns:
- The CSV elements stored by the CSV elements property.
-
setFields
public void setFields(Collection<Object> aFields)
Sets the CSV elements for the CSV elements property.- Parameters:
aFields
- The CSV elements to be stored by the CSV elements property.
-
getDelimiter
public char getDelimiter()
- Specified by:
getDelimiter
in interfaceorg.refcodes.mixin.DelimiterAccessor
-
setDelimiter
public void setDelimiter(char aDelimiterChar)
- Specified by:
setDelimiter
in interfaceorg.refcodes.mixin.DelimiterAccessor.DelimiterMutator
-
toFields
public List<String> toFields() throws IllegalStateException
Creates a list ofString
elements from the CSV line being set viasetRecord(String)
orwithRecord(String)
.- Returns:
- The elements created from the CSV line.
- Throws:
IllegalStateException
- Thrown in case no elements have been set via thewithFields(String[])
orsetFields(String[])
methods.
-
toRecord
public String toRecord() throws IllegalStateException
Creates a CSV line from the elements being set viasetFields(String[])
orwithFields(String[])
.- Returns:
- The CSV line created from the CSV line.
- Throws:
IllegalStateException
- Thrown in case no CSV line has been set via thewithRecord(String)
orsetRecord(String)
methods.
-
toRecord
public String toRecord(Object... aFields)
Creates a CSV line from the fields being provided This method is to be side effect free in terms of the fields (and the resulting record) is not part of the state for this instance (from the point of view of this method). Still changing for example the delimiter viawithDelimiter(char)
can cause side effects! For avoiding thread race conditions / side effects regarding the fields (and the resulting record), use this method instead of the combination ofwithFields(String...)
withtoRecord()
.- Parameters:
aFields
- The CSV elements to be converted into a record.- Returns:
- The CSV line created from the fields.
-
toRecord
public String toRecord(Collection<Object> aFields)
Creates a CSV line from the fields being provided This method is to be side effect free in terms of the fields (and the resulting record) is not part of the state for this instance (from the point of view of this method). Still changing for example the delimiter viawithDelimiter(char)
can cause side effects! For avoiding thread race conditions / side effects regarding the fields (and the resulting record), use this method instead of the combination ofwithFields(String...)
withtoRecord()
.- Parameters:
aFields
- The CSV elements to be converted into a record.- Returns:
- The CSV line created from the fields.
-
toStrings
public String[] toStrings() throws IllegalStateException
Creates an array ofString
s from the CSV line being set viasetRecord(String)
orwithRecord(String)
. It should return the same result as an array as a call totoFields()
. Returns null if the record is a comment as ofCsvMixin.isComment(String)
.- Returns:
- The elements created from the CSV line or null if the record is a comment.
- Throws:
IllegalStateException
-
toRecord
public String toRecord(String... aFields) throws IllegalStateException
Creates a CSV line from the fields being provided This method is to be side effect free in terms of the fields (and the resulting record) is not part of the state for this instance (from the point of view of this method). Still changing for example the delimiter viawithDelimiter(char)
can cause side effects! For avoiding thread race conditions / side effects regarding the fields (and the resulting record), use this method instead of the combination ofwithFields(String...)
withtoRecord()
.- Parameters:
aFields
- The CSV elements to be converted into a record.- Returns:
- The CSV line created from the fields.
- Throws:
IllegalStateException
-
toStrings
public String[] toStrings(String aRecord)
Convenience method for thetoFields(String)
method.- Parameters:
aRecord
- The CSV line to be stored by the CSV line property.- Returns:
- The elements created from the CSV line or null if the record is a comment.
-
toString
public String toString() throws IllegalStateException
TheString
being build by the builder upon the settings of the attributes. It should return the same result as a call totoRecord()
.- Overrides:
toString
in classObject
- Returns:
- The according resulting
String
- Throws:
IllegalStateException
-
setCommentPrefixes
public void setCommentPrefixes(String... aCommentPrefixes)
Sets the prefixes used to identify CSV lines to be ignored.- Specified by:
setCommentPrefixes
in interfaceCsvMixin
- Parameters:
aCommentPrefixes
- The prefixes used to identify CSV lines to be ignored.
-
getCommentPrefixes
public String[] getCommentPrefixes()
Gets the prefixes used to identify CSV lines to be ignored.- Specified by:
getCommentPrefixes
in interfaceCsvMixin
- Returns:
- return The prefixes used to identify CSV lines to be ignored.
-
clearCommentPrefixes
public void clearCommentPrefixes()
Clears the prefixes used to identify CSV lines to be ignored. No CSV lines will be ignored any more.- Specified by:
clearCommentPrefixes
in interfaceCsvMixin
-
withTrim
public CsvBuilder withTrim(boolean isTrim)
- Specified by:
withTrim
in interfaceorg.refcodes.mixin.TrimAccessor.TrimBuilder<CsvMixin>
-
withCsvEscapeMode
public CsvBuilder withCsvEscapeMode(CsvEscapeMode aCsvEscapeMode)
Sets the rowsCsvEscapeMode
to use returns this builder as of the Builder-Pattern.- Specified by:
withCsvEscapeMode
in interfaceCsvEscapeModeAccessor.CsvEscapeModeBuilder<CsvMixin>
- Parameters:
aCsvEscapeMode
- TheCsvEscapeMode
to be used when printing a row or the header.- Returns:
- This
CsvEscapeModeAccessor.CsvEscapeModeBuilder
instance to continue configuration.
-
withDelimiter
public CsvBuilder withDelimiter(char aDelimiterChar)
- Specified by:
withDelimiter
in interfaceorg.refcodes.mixin.DelimiterAccessor.DelimiterBuilder<CsvMixin>
-
withCommentPrefixes
public CsvBuilder withCommentPrefixes(String... aCommentPrefixes)
Sets the prefixes used to identify CSV lines to be ignored.- Specified by:
withCommentPrefixes
in interfaceCsvMixin
- Parameters:
aCommentPrefixes
- The prefixes used to identify CSV lines to be ignored.- Returns:
- The instance on which this method has been invoked as of the builder pattern.
-
withRecord
public CsvBuilder withRecord(String aRecord)
Sets the CSV line for the CSV line property.- Parameters:
aRecord
- The CSV line to be stored by the CSV line property.- Returns:
- The builder for applying multiple build operations.
-
setFields
public void setFields(boolean... aFields)
Sets the CSV elements for the CSV elements property.- Parameters:
aFields
- The CSV elements to be stored by the CSV elements property.
-
setFields
public void setFields(byte... aFields)
Sets the CSV elements for the CSV elements property.- Parameters:
aFields
- The CSV elements to be stored by the CSV elements property.
-
setFields
public void setFields(short... aFields)
Sets the CSV elements for the CSV elements property.- Parameters:
aFields
- The CSV elements to be stored by the CSV elements property.
-
setFields
public void setFields(int... aFields)
Sets the CSV elements for the CSV elements property.- Parameters:
aFields
- The CSV elements to be stored by the CSV elements property.
-
setFields
public void setFields(long... aFields)
Sets the CSV elements for the CSV elements property.- Parameters:
aFields
- The CSV elements to be stored by the CSV elements property.
-
setFields
public void setFields(float... aFields)
Sets the CSV elements for the CSV elements property.- Parameters:
aFields
- The CSV elements to be stored by the CSV elements property.
-
setFields
public void setFields(double... aFields)
Sets the CSV elements for the CSV elements property.- Parameters:
aFields
- The CSV elements to be stored by the CSV elements property.
-
setFields
public void setFields(char... aFields)
Sets the CSV elements for the CSV elements property.- Parameters:
aFields
- The CSV elements to be stored by the CSV elements property.
-
withFields
public CsvBuilder withFields(boolean... aFields)
Sets the CSV elements for the CSV elements property.- Parameters:
aFields
- The CSV elements to be stored by the CSV elements property.- Returns:
- The builder for applying multiple build operations.
-
withFields
public CsvBuilder withFields(byte... aFields)
Sets the CSV elements for the CSV elements property.- Parameters:
aFields
- The CSV elements to be stored by the CSV elements property.- Returns:
- The builder for applying multiple build operations.
-
withFields
public CsvBuilder withFields(short... aFields)
Sets the CSV elements for the CSV elements property.- Parameters:
aFields
- The CSV elements to be stored by the CSV elements property.- Returns:
- The builder for applying multiple build operations.
-
withFields
public CsvBuilder withFields(int... aFields)
Sets the CSV elements for the CSV elements property.- Parameters:
aFields
- The CSV elements to be stored by the CSV elements property.- Returns:
- The builder for applying multiple build operations.
-
withFields
public CsvBuilder withFields(long... aFields)
Sets the CSV elements for the CSV elements property.- Parameters:
aFields
- The CSV elements to be stored by the CSV elements property.- Returns:
- The builder for applying multiple build operations.
-
withFields
public CsvBuilder withFields(float... aFields)
Sets the CSV elements for the CSV elements property.- Parameters:
aFields
- The CSV elements to be stored by the CSV elements property.- Returns:
- The builder for applying multiple build operations.
-
withFields
public CsvBuilder withFields(double... aFields)
Sets the CSV elements for the CSV elements property.- Parameters:
aFields
- The CSV elements to be stored by the CSV elements property.- Returns:
- The builder for applying multiple build operations.
-
withFields
public CsvBuilder withFields(char... aFields)
Sets the CSV elements for the CSV elements property.- Parameters:
aFields
- The CSV elements to be stored by the CSV elements property.- Returns:
- The builder for applying multiple build operations.
-
setFields
public void setFields(Boolean... aFields)
Sets the CSV elements for the CSV elements property.- Parameters:
aFields
- The CSV elements to be stored by the CSV elements property.
-
setFields
public void setFields(Byte... aFields)
Sets the CSV elements for the CSV elements property.- Parameters:
aFields
- The CSV elements to be stored by the CSV elements property.
-
setFields
public void setFields(Short... aFields)
Sets the CSV elements for the CSV elements property.- Parameters:
aFields
- The CSV elements to be stored by the CSV elements property.
-
setFields
public void setFields(Integer... aFields)
Sets the CSV elements for the CSV elements property.- Parameters:
aFields
- The CSV elements to be stored by the CSV elements property.
-
setFields
public void setFields(Long... aFields)
Sets the CSV elements for the CSV elements property.- Parameters:
aFields
- The CSV elements to be stored by the CSV elements property.
-
setFields
public void setFields(Float... aFields)
Sets the CSV elements for the CSV elements property.- Parameters:
aFields
- The CSV elements to be stored by the CSV elements property.
-
setFields
public void setFields(Double... aFields)
Sets the CSV elements for the CSV elements property.- Parameters:
aFields
- The CSV elements to be stored by the CSV elements property.
-
setFields
public void setFields(Character... aFields)
Sets the CSV elements for the CSV elements property.- Parameters:
aFields
- The CSV elements to be stored by the CSV elements property.
-
setFields
public void setFields(String... aFields)
Sets the CSV elements for the CSV elements property.- Parameters:
aFields
- The CSV elements to be stored by the CSV elements property.
-
withFields
public CsvBuilder withFields(Object... aFields)
Sets the CSV elements for the CSV elements property.- Parameters:
aFields
- The CSV elements to be stored by the CSV elements property.- Returns:
- The builder for applying multiple build operations.
-
withFields
public CsvBuilder withFields(Boolean... aFields)
Sets the CSV elements for the CSV elements property.- Parameters:
aFields
- The CSV elements to be stored by the CSV elements property.- Returns:
- The builder for applying multiple build operations.
-
withFields
public CsvBuilder withFields(Byte... aFields)
Sets the CSV elements for the CSV elements property.- Parameters:
aFields
- The CSV elements to be stored by the CSV elements property.- Returns:
- The builder for applying multiple build operations.
-
withFields
public CsvBuilder withFields(Short... aFields)
Sets the CSV elements for the CSV elements property.- Parameters:
aFields
- The CSV elements to be stored by the CSV elements property.- Returns:
- The builder for applying multiple build operations.
-
withFields
public CsvBuilder withFields(Integer... aFields)
Sets the CSV elements for the CSV elements property.- Parameters:
aFields
- The CSV elements to be stored by the CSV elements property.- Returns:
- The builder for applying multiple build operations.
-
withFields
public CsvBuilder withFields(Long... aFields)
Sets the CSV elements for the CSV elements property.- Parameters:
aFields
- The CSV elements to be stored by the CSV elements property.- Returns:
- The builder for applying multiple build operations.
-
withFields
public CsvBuilder withFields(Float... aFields)
Sets the CSV elements for the CSV elements property.- Parameters:
aFields
- The CSV elements to be stored by the CSV elements property.- Returns:
- The builder for applying multiple build operations.
-
withFields
public CsvBuilder withFields(Double... aFields)
Sets the CSV elements for the CSV elements property.- Parameters:
aFields
- The CSV elements to be stored by the CSV elements property.- Returns:
- The builder for applying multiple build operations.
-
withFields
public CsvBuilder withFields(Character... aFields)
Sets the CSV elements for the CSV elements property.- Parameters:
aFields
- The CSV elements to be stored by the CSV elements property.- Returns:
- The builder for applying multiple build operations.
-
withFields
public CsvBuilder withFields(String... aFields)
Sets the CSV elements for the CSV elements property.- Parameters:
aFields
- The CSV elements to be stored by the CSV elements property.- Returns:
- The builder for applying multiple build operations.
-
withFields
public CsvBuilder withFields(Collection<Object> aFields)
Sets the CSV elements for the CSV elements property.- Parameters:
aFields
- The CSV elements to be stored by the CSV elements property.- Returns:
- The builder for applying multiple build operations.
-
toRecord
public String toRecord(boolean... aFields)
Creates a CSV line from the fields being provided This method is to be side effect free in terms of the fields (and the resulting record) is not part of the state for this instance (from the point of view of this method). Still changing for example the delimiter viawithDelimiter(char)
can cause side effects! For avoiding thread race conditions / side effects regarding the fields (and the resulting record), use this method instead of the combination ofwithFields(String...)
withtoRecord()
.- Parameters:
aFields
- The CSV elements to be converted into a record.- Returns:
- The CSV line created from the fields.
-
toRecord
public String toRecord(byte... aFields)
Creates a CSV line from the fields being provided This method is to be side effect free in terms of the fields (and the resulting record) is not part of the state for this instance (from the point of view of this method). Still changing for example the delimiter viawithDelimiter(char)
can cause side effects! For avoiding thread race conditions / side effects regarding the fields (and the resulting record), use this method instead of the combination ofwithFields(String...)
withtoRecord()
.- Parameters:
aFields
- The CSV elements to be converted into a record.- Returns:
- The CSV line created from the fields.
-
toRecord
public String toRecord(short... aFields)
Creates a CSV line from the fields being provided This method is to be side effect free in terms of the fields (and the resulting record) is not part of the state for this instance (from the point of view of this method). Still changing for example the delimiter viawithDelimiter(char)
can cause side effects! For avoiding thread race conditions / side effects regarding the fields (and the resulting record), use this method instead of the combination ofwithFields(String...)
withtoRecord()
.- Parameters:
aFields
- The CSV elements to be converted into a record.- Returns:
- The CSV line created from the fields.
-
toRecord
public String toRecord(int... aFields)
Creates a CSV line from the fields being provided This method is to be side effect free in terms of the fields (and the resulting record) is not part of the state for this instance (from the point of view of this method). Still changing for example the delimiter viawithDelimiter(char)
can cause side effects! For avoiding thread race conditions / side effects regarding the fields (and the resulting record), use this method instead of the combination ofwithFields(String...)
withtoRecord()
.- Parameters:
aFields
- The CSV elements to be converted into a record.- Returns:
- The CSV line created from the fields.
-
toRecord
public String toRecord(long... aFields)
Creates a CSV line from the fields being provided This method is to be side effect free in terms of the fields (and the resulting record) is not part of the state for this instance (from the point of view of this method). Still changing for example the delimiter viawithDelimiter(char)
can cause side effects! For avoiding thread race conditions / side effects regarding the fields (and the resulting record), use this method instead of the combination ofwithFields(String...)
withtoRecord()
.- Parameters:
aFields
- The CSV elements to be converted into a record.- Returns:
- The CSV line created from the fields.
-
toRecord
public String toRecord(float... aFields)
Creates a CSV line from the fields being provided This method is to be side effect free in terms of the fields (and the resulting record) is not part of the state for this instance (from the point of view of this method). Still changing for example the delimiter viawithDelimiter(char)
can cause side effects! For avoiding thread race conditions / side effects regarding the fields (and the resulting record), use this method instead of the combination ofwithFields(String...)
withtoRecord()
.- Parameters:
aFields
- The CSV elements to be converted into a record.- Returns:
- The CSV line created from the fields.
-
toRecord
public String toRecord(double... aFields)
Creates a CSV line from the fields being provided This method is to be side effect free in terms of the fields (and the resulting record) is not part of the state for this instance (from the point of view of this method). Still changing for example the delimiter viawithDelimiter(char)
can cause side effects! For avoiding thread race conditions / side effects regarding the fields (and the resulting record), use this method instead of the combination ofwithFields(String...)
withtoRecord()
.- Parameters:
aFields
- The CSV elements to be converted into a record.- Returns:
- The CSV line created from the fields.
-
toRecord
public String toRecord(char... aFields)
Creates a CSV line from the fields being provided This method is to be side effect free in terms of the fields (and the resulting record) is not part of the state for this instance (from the point of view of this method). Still changing for example the delimiter viawithDelimiter(char)
can cause side effects! For avoiding thread race conditions / side effects regarding the fields (and the resulting record), use this method instead of the combination ofwithFields(String...)
withtoRecord()
.- Parameters:
aFields
- The CSV elements to be converted into a record.- Returns:
- The CSV line created from the fields.
-
toString
public String toString(Object... aFields)
Creates a CSV line from the fields being provided This method is to be side effect free in terms of the fields (and the resulting record) is not part of the state for this instance (from the point of view of this method). Still changing for example the delimiter viawithDelimiter(char)
can cause side effects! For avoiding thread race conditions / side effects regarding the fields (and the resulting record), use this method instead of the combination ofwithFields(String...)
withtoRecord()
.- Parameters:
aFields
- The CSV elements to be converted into a record.- Returns:
- The CSV line created from the fields.
-
toRecord
public String toRecord(Boolean... aFields)
Creates a CSV line from the fields being provided This method is to be side effect free in terms of the fields (and the resulting record) is not part of the state for this instance (from the point of view of this method). Still changing for example the delimiter viawithDelimiter(char)
can cause side effects! For avoiding thread race conditions / side effects regarding the fields (and the resulting record), use this method instead of the combination ofwithFields(String...)
withtoRecord()
.- Parameters:
aFields
- The CSV elements to be converted into a record.- Returns:
- The CSV line created from the fields.
-
toRecord
public String toRecord(Byte... aFields)
Creates a CSV line from the fields being provided This method is to be side effect free in terms of the fields (and the resulting record) is not part of the state for this instance (from the point of view of this method). Still changing for example the delimiter viawithDelimiter(char)
can cause side effects! For avoiding thread race conditions / side effects regarding the fields (and the resulting record), use this method instead of the combination ofwithFields(String...)
withtoRecord()
.- Parameters:
aFields
- The CSV elements to be converted into a record.- Returns:
- The CSV line created from the fields.
-
toRecord
public String toRecord(Short... aFields)
To record.- Parameters:
aFields
- the fields- Returns:
- the string
-
toRecord
public String toRecord(Integer... aFields)
Creates a CSV line from the fields being provided This method is to be side effect free in terms of the fields (and the resulting record) is not part of the state for this instance (from the point of view of this method). Still changing for example the delimiter viawithDelimiter(char)
can cause side effects! For avoiding thread race conditions / side effects regarding the fields (and the resulting record), use this method instead of the combination ofwithFields(String...)
withtoRecord()
.- Parameters:
aFields
- The CSV elements to be converted into a record.- Returns:
- The CSV line created from the fields.
-
toRecord
public String toRecord(Long... aFields)
Creates a CSV line from the fields being provided This method is to be side effect free in terms of the fields (and the resulting record) is not part of the state for this instance (from the point of view of this method). Still changing for example the delimiter viawithDelimiter(char)
can cause side effects! For avoiding thread race conditions / side effects regarding the fields (and the resulting record), use this method instead of the combination ofwithFields(String...)
withtoRecord()
.- Parameters:
aFields
- The CSV elements to be converted into a record.- Returns:
- The CSV line created from the fields.
-
toRecord
public String toRecord(Float... aFields)
Creates a CSV line from the fields being provided This method is to be side effect free in terms of the fields (and the resulting record) is not part of the state for this instance (from the point of view of this method). Still changing for example the delimiter viawithDelimiter(char)
can cause side effects! For avoiding thread race conditions / side effects regarding the fields (and the resulting record), use this method instead of the combination ofwithFields(String...)
withtoRecord()
.- Parameters:
aFields
- The CSV elements to be converted into a record.- Returns:
- The CSV line created from the fields.
-
toRecord
public String toRecord(Double... aFields)
Creates a CSV line from the fields being provided This method is to be side effect free in terms of the fields (and the resulting record) is not part of the state for this instance (from the point of view of this method). Still changing for example the delimiter viawithDelimiter(char)
can cause side effects! For avoiding thread race conditions / side effects regarding the fields (and the resulting record), use this method instead of the combination ofwithFields(String...)
withtoRecord()
.- Parameters:
aFields
- The CSV elements to be converted into a record.- Returns:
- The CSV line created from the fields.
-
toRecord
public String toRecord(Character... aFields)
Creates a CSV line from the fields being provided This method is to be side effect free in terms of the fields (and the resulting record) is not part of the state for this instance (from the point of view of this method). Still changing for example the delimiter viawithDelimiter(char)
can cause side effects! For avoiding thread race conditions / side effects regarding the fields (and the resulting record), use this method instead of the combination ofwithFields(String...)
withtoRecord()
.- Parameters:
aFields
- The CSV elements to be converted into a record.- Returns:
- The CSV line created from the fields.
-
toString
public String toString(String... aFields)
Creates a CSV line from the fields being provided This method is to be side effect free in terms of the fields (and the resulting record) is not part of the state for this instance (from the point of view of this method). Still changing for example the delimiter viawithDelimiter(char)
can cause side effects! For avoiding thread race conditions / side effects regarding the fields (and the resulting record), use this method instead of the combination ofwithFields(String...)
withtoRecord()
.- Parameters:
aFields
- The CSV elements to be converted into a record.- Returns:
- The CSV line created from the fields.
-
toString
public String toString(Collection<Object> aFields)
Creates a CSV line from the fields being provided This method is to be side effect free in terms of the fields (and the resulting record) is not part of the state for this instance (from the point of view of this method). Still changing for example the delimiter viawithDelimiter(char)
can cause side effects! For avoiding thread race conditions / side effects regarding the fields (and the resulting record), use this method instead of the combination ofwithFields(String...)
withtoRecord()
.- Parameters:
aFields
- The CSV elements to be converted into a record.- Returns:
- The CSV line created from the fields.
-
toFields
public String[] toFields(String aRecord)
Creates an array ofString
s from the CSV line being set viasetRecord(String)
orwithRecord(String)
. It should return the same result as an array as a call totoFields()
. Returns null if the record is a comment as ofCsvMixin.isComment(String)
. This method is to be side effect free in terms of the record (and the resulting fields) is not part of the state for this instance (from the point of view of this method). Still changing for example the delimiter viawithDelimiter(char)
can cause side effects! For avoiding thread race conditions / side effects regarding the record (and the resulting fields), use this method instead of the combination ofwithRecord(String)
withtoStrings()
.- Parameters:
aRecord
- The CSV line to be stored by the CSV line property.- Returns:
- The elements created from the CSV line or null if the record is a comment.
-
asFields
public static List<String> asFields(String aRecord, char aDelimiter, CsvEscapeMode aCsvEscapeMode, boolean isTrim)
Creates fields from the given record.- Parameters:
aRecord
- The record to use.aDelimiter
- The delimiter to use.aCsvEscapeMode
- TheCsvEscapeMode
to use.isTrim
- True in case the record and the resulting fields are to be trimmed.- Returns:
- The according record.
-
asRecord
public static String asRecord(Collection<Object> aFields, char aDelimiter, CsvEscapeMode aCsvEscapeMode)
Creates a record from the given fields.- Parameters:
aFields
- The fields to use.aDelimiter
- The delimiter to use.aCsvEscapeMode
- TheCsvEscapeMode
to use.- Returns:
- The according record.
-
asStrings
public static String[] asStrings(String aRecord, char aDelimiterChar, CsvEscapeMode aCsvEscapeMode, boolean isTrim, String[] aCommentPrefixes)
Splits a record into dedicated fields.- Parameters:
aRecord
- The record which to split into dedicated fields.aDelimiterChar
- The delimiter denoting the end of a value.aCsvEscapeMode
- TheCsvEscapeMode
to use.isTrim
- Whether to trim the record and the resulting fields.aCommentPrefixes
- The prefixes used to identify comments.- Returns:
- The according fields from the record.
-
-