Class LineCollector
Lines end with a LF which may optionally be followed by a CR.
Neither character is part of the result returned by getLine()
.
If no more input is expected and characters without trailing LF
remain, these remaining character are returned as a line as well.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionSets the charset to be used iffeed(ManagedBuffer)
is invoked withManagedBuffer<ByteBuffer>
.Configures a consumer for lines.boolean
eof()
Checks if more input may become available.<W extends Buffer>
voidFeed data to the collector.<W extends Buffer>
voidfeed
(ManagedBuffer<W> buffer) Feed data to the collector.<W extends Buffer>
voidfeed
(W buffer) Feed data to the collector.getLine()
Gets the next line.Sets the charset to be used iffeed(ManagedBuffer)
is invoked withManagedBuffer<ByteBuffer>
to the charset specified as system propertynative.encoding
.
-
Constructor Details
-
LineCollector
public LineCollector()
-
-
Method Details
-
charset
Sets the charset to be used iffeed(ManagedBuffer)
is invoked withManagedBuffer<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 iffeed(ManagedBuffer)
is invoked withManagedBuffer<ByteBuffer>
to the charset specified as system propertynative.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
-
consumer
Configures a consumer for lines.The consumer is invoked when a complete line has been detected. If a consumer is configured,
getLine()
may not be used (always returnsnull
).- Parameters:
consumer
- the consumer- Returns:
- the line collector
-
feed
Feed data to the collector.Calling this method with
null
as argument closes the feed.- Parameters:
buffer
- the buffer
-
feed
Feed data to the collector.Calling this method with
null
as argument closes the feed.- Parameters:
buffer
- the buffer
-
feed
Feed data to the collector.Calling this method with
null
as argument closes the feed.- Parameters:
event
- the event
-
eof
Checks if more input may become available.- Returns:
- true, if successful
-
getLine
Gets the next line.- Returns:
- the line
-