Class SetCssConverter<T>

java.lang.Object
org.jhotdraw8.css.converter.SetCssConverter<T>
Type Parameters:
T - the element type
All Implemented Interfaces:
Converter<ImmutableSequencedSet<T>>, CssConverter<ImmutableSequencedSet<T>>

public class SetCssConverter<T> extends Object implements CssConverter<ImmutableSequencedSet<T>>
Parses a set with items separated by configurable optional delimiters.

If the delimiter consists of multiple character tokens, then the parser accepts each of the character tokens and any combination of them.

The delimiters are optional when the list is parsed from a String. When the list is converted into a String, then the specified delimiters are used to separate the items.

Stops parsing at EOF, semicolon and closing bracket.

This parser is intentionally forgiving, so that sets can be output with nice delimiters, but the user does not need to type the delimiter.

In CSS set elements are separated by a comma character.

References:

CSS Syntax Module Level 3, 5.3.11. Parse a comma-separated list of component values
w3.org
  • Constructor Details

    • SetCssConverter

      public SetCssConverter(CssConverter<T> elementConverter)
    • SetCssConverter

      public SetCssConverter(CssConverter<T> elementConverter, @Nullable String delimiter)
    • SetCssConverter

      public SetCssConverter(CssConverter<T> elementConverter, @Nullable String delimiter, @Nullable String prefix, @Nullable String suffix)
    • SetCssConverter

      public SetCssConverter(CssConverter<T> elementConverter, @Nullable String delimiter, @Nullable String prefix, @Nullable String suffix, @Nullable Comparator<T> comparatorForSorting)
      Parameters:
      elementConverter - the convert for a single element
      delimiter - a String which must be parsable into character tokens, each token and any combination of them is accepted as an optional delimiter
      prefix - the prefix of the list, for example a left bracket
      suffix - the suffix of the list, for example a right bracket
      comparatorForSorting - if this value is non-null, then it is used to sort the list
    • SetCssConverter

      public SetCssConverter(CssConverter<T> elementConverter, Iterable<CssToken> delimiter, Iterable<CssToken> prefix, Iterable<CssToken> suffix)
      Creates a new instance that does not sort the elements.
      Parameters:
      elementConverter - converter for elements
      delimiter - optional delimiter for parsing; the delimiter is used for pretty printing
      prefix - white-space tokens for pretty printing that are used when producing tokens or a String
      suffix - white-space tokens for pretty printing that are used when producing tokens or a String
    • SetCssConverter

      public SetCssConverter(CssConverter<T> elementConverter, Iterable<CssToken> delimiter, Iterable<CssToken> prefix, Iterable<CssToken> suffix, @Nullable Comparator<T> comparatorForSorting)
      Creates a new instance.
      Parameters:
      elementConverter - converter for elements
      delimiter - optional delimiter for parsing; the delimiter is used for pretty printing
      prefix - white-space tokens for pretty printing that are used when producing tokens or a String
      suffix - white-space tokens for pretty printing that are used when producing tokens or a String
      comparatorForSorting - optional comparator for sorting; null means no sorting
  • Method Details