Class CommaSeparatedValues

java.lang.Object
com.northconcepts.datapipeline.csv.CommaSeparatedValues

public class CommaSeparatedValues extends Object
A collection of comma delimited values. The values are stored separately internally, but can be parsed or assembled as a simple CSV string.
  • Constructor Details

    • CommaSeparatedValues

      public CommaSeparatedValues(String csvString)
      Parses the first line of the given comma-separated text; unquoted values are trimmed and become null when empty.
    • CommaSeparatedValues

      public CommaSeparatedValues(Collection<String> collection)
      Creates an instance backed by the given collection when it is an ArrayList (changes are shared), otherwise by a copy of it.
    • CommaSeparatedValues

      public CommaSeparatedValues()
  • Method Details

    • fromValue

      public static CommaSeparatedValues fromValue(String valuesAsString)
      Parses the given comma-separated text or returns null if it is null or blank.
    • fromArray

      public static CommaSeparatedValues fromArray(String... array)
      Creates an instance holding the given values or returns null if the array is null or empty.
    • getValues

      public ArrayList<String> getValues()
    • toCsvString

      public String toCsvString()
      Joins the values with a comma and a space, without quoting or escaping them.
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • size

      public int size()
    • isEmpty

      public boolean isEmpty()
    • contains

      public boolean contains(String o)
    • add

      public CommaSeparatedValues add(String e)
    • remove

      public boolean remove(String o)
    • addAll

      public boolean addAll(Collection<String> c)
    • clear

      public CommaSeparatedValues clear()
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • get

      public String get(int index)
    • remove

      public String remove(int index)
    • indexOf

      public int indexOf(String o)
    • lastIndexOf

      public int lastIndexOf(Object o)
    • subList

      public CommaSeparatedValues subList(int fromIndex, int toIndex)
      Returns a new instance holding a copy of the values from fromIndex (inclusive) to toIndex (exclusive).