Package de.xima.fc.common.text.newline
Class Newlines
- java.lang.Object
-
- de.xima.fc.common.text.newline.Newlines
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static NewlineProcessor
map(NewlineProcessor processor, UnaryOperator<String> mapper)
Creates a newline processor that behaves like the given processor, but maps each line using the given mapper.static NewlineProcessor
newlineAsSeparator(Newline... newlines)
Creates a newline processor that interprets the newlines as a separator.static NewlineProcessor
newlineAsSeparator(Iterable<? extends Newline> newlines)
Creates a newline processor that interprets the newlines as a separator.static NewlineProcessor
newlineAsTerminator(Newline... newlines)
Creates a newline processor that interprets the newlines as a terminator.static NewlineProcessor
newlineAsTerminator(Iterable<? extends Newline> newlines)
Creates a newline processor that interprets the newlines as a terminator.static NewlineProcessor
newlineFiltering(NewlineProcessor processor, Predicate<? super String> filter)
Creates a newline processor that behaves like the given processor, but filters out lines that do not match the given predicate.static Newline
newlineOfToken(String token)
static NewlineProcessor
newlineTokenAsSeparator(Iterable<String> tokens)
Creates a newline processor that interprets the newlines as a separator.static NewlineProcessor
newlineTokenAsSeparator(String... tokens)
Creates a newline processor that interprets the newlines as a separator.static NewlineProcessor
newlineTokenAsTerminator(Iterable<String> tokens)
Creates a newline processor that interprets the newlines as a terminator.static NewlineProcessor
newlineTokenAsTerminator(String... tokens)
Creates a newline processor that interprets the newlines as a terminator.
-
-
-
Method Detail
-
map
public static NewlineProcessor map(NewlineProcessor processor, UnaryOperator<String> mapper)
Creates a newline processor that behaves like the given processor, but maps each line using the given mapper. When splitting, the lines are mapped before being returned. When formatting, the lines are mapped before being formatted.- Parameters:
processor
- The processor to wrap.mapper
- The mapper to apply.- Returns:
- A newline processor that behaves like the given processor, but maps each line using the given mapper.
-
newlineAsSeparator
public static NewlineProcessor newlineAsSeparator(Iterable<? extends Newline> newlines)
Creates a newline processor that interprets the newlines as a separator. SeeNewline.asSeparator()
for more information. Splits line on any of the given tokens, formats using the first token.- Parameters:
newlines
- The newlines.- Returns:
- A newline processor that interprets the newlines as a separator.
-
newlineAsSeparator
public static NewlineProcessor newlineAsSeparator(Newline... newlines)
Creates a newline processor that interprets the newlines as a separator. SeeNewline.asSeparator()
for more information. Splits line on any of the given tokens, formats using the first token.- Parameters:
newlines
- The newlines.- Returns:
- A newline processor that interprets the newlines as a separator.
-
newlineAsTerminator
public static NewlineProcessor newlineAsTerminator(Iterable<? extends Newline> newlines)
Creates a newline processor that interprets the newlines as a terminator. SeeNewline.asTerminator()
for more information. Splits line on any of the given tokens, formats using the first token.- Parameters:
newlines
- The newlines.- Returns:
- A newline processor that interprets the newlines as a terminator.
-
newlineAsTerminator
public static NewlineProcessor newlineAsTerminator(Newline... newlines)
Creates a newline processor that interprets the newlines as a terminator. SeeNewline.asTerminator()
for more information. Splits line on any of the given tokens, formats using the first token.- Parameters:
newlines
- The newlines.- Returns:
- A newline processor that interprets the newlines as a terminator.
-
newlineFiltering
public static NewlineProcessor newlineFiltering(NewlineProcessor processor, Predicate<? super String> filter)
Creates a newline processor that behaves like the given processor, but filters out lines that do not match the given predicate. When splitting, such lines are omitted from the returned lines. When formatting, such lines are omitted from the formatted output.- Parameters:
processor
- The processor to wrap.filter
- The filter to apply.- Returns:
- A newline processor that behaves like the given processor, but filters out lines that do not match the
-
newlineTokenAsSeparator
public static NewlineProcessor newlineTokenAsSeparator(String... tokens)
Creates a newline processor that interprets the newlines as a separator. SeeNewline.asSeparator()
for more information. Splits line on any of the given tokens, formats using the first token.- Parameters:
tokens
- The string tokens that represents the newlines, e.g. "\n" for Unix newlines.- Returns:
- A newline processor that interprets the newlines as a separator.
-
newlineTokenAsSeparator
public static NewlineProcessor newlineTokenAsSeparator(Iterable<String> tokens)
Creates a newline processor that interprets the newlines as a separator. SeeNewline.asSeparator()
for more information. Splits line on any of the given tokens, formats using the first token.- Parameters:
tokens
- The string tokens that represents the newlines, e.g. "\n" for Unix newlines.- Returns:
- A newline processor that interprets the newlines as a separator.
-
newlineTokenAsTerminator
public static NewlineProcessor newlineTokenAsTerminator(Iterable<String> tokens)
Creates a newline processor that interprets the newlines as a terminator. SeeNewline.asTerminator()
for more information. Splits line on any of the given tokens, formats using the first token.- Parameters:
tokens
- The string tokens that represents the newlines, e.g. "\n" for Unix newlines.- Returns:
- A newline processor that interprets the newlines as a terminator.
-
newlineTokenAsTerminator
public static NewlineProcessor newlineTokenAsTerminator(String... tokens)
Creates a newline processor that interprets the newlines as a terminator. SeeNewline.asTerminator()
for more information. Splits line on any of the given tokens, formats using the first token.- Parameters:
tokens
- The string tokens that represents the newlines, e.g. "\n" for Unix newlines.- Returns:
- A newline processor that interprets the newlines as a terminator.
-
-