Class Newlines
java.lang.Object
de.xima.fc.common.text.newline.Newlines
-
Method Summary
Modifier and TypeMethodDescriptionstatic NewlineProcessormap(NewlineProcessor processor, UnaryOperator<String> mapper) Creates a newline processor that behaves like the given processor, but maps each line using the given mapper.static NewlineProcessornewlineAsSeparator(Newline... newlines) Creates a newline processor that interprets the newlines as a separator.static NewlineProcessornewlineAsSeparator(Iterable<? extends Newline> newlines) Creates a newline processor that interprets the newlines as a separator.static NewlineProcessornewlineAsTerminator(Newline... newlines) Creates a newline processor that interprets the newlines as a terminator.static NewlineProcessornewlineAsTerminator(Iterable<? extends Newline> newlines) Creates a newline processor that interprets the newlines as a terminator.static NewlineProcessornewlineFiltering(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 NewlinenewlineOfToken(String token) static NewlineProcessornewlineTokenAsSeparator(Iterable<String> tokens) Creates a newline processor that interprets the newlines as a separator.static NewlineProcessornewlineTokenAsSeparator(String... tokens) Creates a newline processor that interprets the newlines as a separator.static NewlineProcessornewlineTokenAsTerminator(Iterable<String> tokens) Creates a newline processor that interprets the newlines as a terminator.static NewlineProcessornewlineTokenAsTerminator(String... tokens) Creates a newline processor that interprets the newlines as a terminator.
-
Method Details
-
map
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
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
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
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
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
-
newlineOfToken
-
newlineTokenAsSeparator
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
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
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
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.
-