Class Splitter

java.lang.Object
com.landawn.abacus.util.Splitter

public final class Splitter extends Object
Since:
0.8
Author:
Haiyang Li
  • Field Details

    • WHITE_SPACE_PATTERN

      public static final Pattern WHITE_SPACE_PATTERN
  • Method Details

    • defauLt

      public static Splitter defauLt()
      Returns the Splitter with the default delimiter: ", ".
      Returns:
    • with

      public static Splitter with(char delimiter)
      Parameters:
      delimiter -
      Returns:
    • with

      public static Splitter with(CharSequence delimiter) throws IllegalArgumentException
      Parameters:
      delimiter -
      Returns:
      Throws:
      IllegalArgumentException - if the specified delimiter is null or empty.
    • with

      public static Splitter with(Pattern delimiter) throws IllegalArgumentException
      Parameters:
      delimiter -
      Returns:
      Throws:
      IllegalArgumentException - if the specified delimiter is null, or empty string may be matched by it.
    • pattern

      public static Splitter pattern(CharSequence delimiterRegex) throws IllegalArgumentException
      Parameters:
      delimiterRegex -
      Returns:
      Throws:
      IllegalArgumentException - if the specified delimiter is null or empty, or empty string may be matched by it.
    • omitEmptyStrings

      @Deprecated public Splitter omitEmptyStrings(boolean omitEmptyStrings)
      Deprecated.
      replaced by omitEmptyStrings()
      Omit empty strings.
      Parameters:
      omitEmptyStrings -
      Returns:
    • omitEmptyStrings

      public Splitter omitEmptyStrings()
      Returns:
    • trim

      @Deprecated public Splitter trim(boolean trim)
      Deprecated.
      replaced by trimResults()
      Parameters:
      trim -
      Returns:
    • trimResults

      public Splitter trimResults()
      Returns:
    • strip

      @Deprecated public Splitter strip(boolean strip)
      Deprecated.
      replaced by stripResults()
      Removes the starting and ending white space characters if strip is true.
      Parameters:
      strip -
      Returns:
      See Also:
    • stripResults

      public Splitter stripResults()
      Returns:
    • limit

      public Splitter limit(int limit)
      Parameters:
      limit -
      Returns:
    • split

      public List<String> split(CharSequence source)
      Parameters:
      source -
      Returns:
    • split

      public <C extends Collection<String>> C split(CharSequence source, Supplier<? extends C> supplier)
      Type Parameters:
      C -
      Parameters:
      source -
      supplier -
      Returns:
    • split

      public <T, E extends Exception> List<T> split(CharSequence source, Throwables.Function<? super String,? extends T,E> mapper) throws E
      Type Parameters:
      T -
      E -
      Parameters:
      source -
      mapper -
      Returns:
      Throws:
      E
    • split

      public <T> List<T> split(CharSequence source, Class<? extends T> targetType)
      Type Parameters:
      T -
      Parameters:
      source -
      targetType -
      Returns:
    • split

      public <T, C extends Collection<T>> C split(CharSequence source, Class<? extends T> targetType, Supplier<? extends C> supplier)
      Type Parameters:
      T -
      C -
      Parameters:
      source -
      targetType -
      supplier -
      Returns:
    • split

      public <T> List<T> split(CharSequence source, com.landawn.abacus.type.Type<? extends T> targetType)
      Type Parameters:
      T -
      Parameters:
      source -
      targetType -
      Returns:
    • split

      public <T, C extends Collection<T>> C split(CharSequence source, com.landawn.abacus.type.Type<? extends T> targetType, Supplier<? extends C> supplier)
      Type Parameters:
      T -
      C -
      Parameters:
      source -
      targetType -
      supplier -
      Returns:
    • split

      public <C extends Collection<String>> C split(C output, CharSequence source)
      Type Parameters:
      C -
      Parameters:
      output -
      source -
      Returns:
    • split

      public <T, C extends Collection<T>> C split(C output, CharSequence source, Class<? extends T> targetType)
      Type Parameters:
      T -
      C -
      Parameters:
      output -
      source -
      targetType -
      Returns:
    • split

      public <T, C extends Collection<T>> C split(C output, CharSequence source, com.landawn.abacus.type.Type<? extends T> targetType)
      Type Parameters:
      T -
      C -
      Parameters:
      output -
      source -
      targetType -
      Returns:
    • splitToImmutableList

      public ImmutableList<String> splitToImmutableList(CharSequence source)
      Split to array.
      Parameters:
      source -
      Returns:
    • splitToImmutableList

      public <T> ImmutableList<T> splitToImmutableList(CharSequence source, Class<? extends T> targetType)
      Split to array.
      Type Parameters:
      T -
      Parameters:
      source -
      targetType -
      Returns:
    • splitToArray

      public String[] splitToArray(CharSequence source)
      Split to array.
      Parameters:
      source -
      Returns:
    • splitToArray

      public <E extends Exception> String[] splitToArray(CharSequence source, Throwables.Function<? super String,String,E> mapper) throws E
      Split to array.
      Type Parameters:
      E -
      Parameters:
      source -
      mapper -
      Returns:
      Throws:
      E
    • splitToArray

      public <T> T splitToArray(CharSequence source, Class<T> arrayType)
      Split to array.
      Type Parameters:
      T -
      Parameters:
      source -
      arrayType -
      Returns:
    • splitToArray

      public String[] splitToArray(String[] output, CharSequence source)
      Split to array.
      Parameters:
      output -
      source -
      Returns:
    • splitToStream

      public Stream<String> splitToStream(CharSequence source)
      Split to stream.
      Parameters:
      source -
      Returns:
    • splitThenApply

      public <T, E extends Exception> T splitThenApply(CharSequence source, Throwables.Function<? super List<String>,T,E> converter) throws E
      Type Parameters:
      T -
      E -
      Parameters:
      source -
      converter -
      Returns:
      Throws:
      E - the e
    • splitThenAccept

      public <E extends Exception> void splitThenAccept(CharSequence source, Throwables.Consumer<? super List<String>,E> consumer) throws E
      Type Parameters:
      E -
      Parameters:
      source -
      converter -
      Throws:
      E - the e