Class TextCollector

java.lang.Object
org.jgrapes.webconlet.oidclogin.TextCollector
All Implemented Interfaces:
InputConsumer

public class TextCollector extends Object implements InputConsumer
Collects character data from buffers and makes it available as a text.
  • Constructor Details

  • Method Details

    • charset

      public TextCollector charset(Charset charset)
      Sets the charset to be used if feed(ManagedBuffer) is invoked with ManagedBuffer<ByteBuffer>.

      Defaults to UTF-8. Must be set before the first invocation of feed(ManagedBuffer).

      Parameters:
      charset - the charset
      Returns:
      the managed buffer reader
    • nativeCharset

      Sets the charset to be used if feed(ManagedBuffer) is invoked with ManagedBuffer<ByteBuffer> to the charset specified as system property native.encoding.

      If this property does not specify a valid charset, Charset.defaultCharset() is used.

      Must be invoked before the first invocation of feed(ManagedBuffer).

      Returns:
      the managed buffer reader
    • maximumSize

      public TextCollector maximumSize(int maximumLength)
      Configures the maximum length of the collected text.

      Input exceeding this size will be discarded.

      Parameters:
      maximumLength - the maximum length
      Returns:
      the maximum size
    • consumer

      public TextCollector consumer(Consumer<String> consumer)
      Configures a consumer for the collected text.

      The consumer is invoked once when the complete text is available.

      Parameters:
      consumer - the consumer
      Returns:
      the line collector
    • feed

      public <W extends Buffer> void feed(W buffer)
      Feed data to the collector.

      Calling this method with null as argument closes the feed.

      Parameters:
      buffer - the buffer
    • feed

      public <W extends Buffer> void feed(ManagedBuffer<W> buffer)
      Feed data to the collector.

      Calling this method with null as argument closes the feed.

      Specified by:
      feed in interface InputConsumer
      Parameters:
      buffer - the buffer
    • eof

      public boolean eof()
      Checks if more input may become available.
      Returns:
      true, if successful