Interface Strings.TextFlow
- All Superinterfaces:
BiFunction<Strings.TextConsumer,,Strings.TextConsumer, Strings.TextConsumer> BinaryOperator<Strings.TextConsumer>
- Enclosing class:
Strings
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
Two text consumers are passed as arguments to the apply(eu.bandm.tools.util.java.Strings.TextConsumer, eu.bandm.tools.util.java.Strings.TextConsumer) method.
The result should be a text consumer that forwards
transformed/untransformed text to the first/second one, respectively.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Strings.TextFlowstatic final Strings.TextFlowstatic final Strings.TextFlow -
Method Summary
Modifier and TypeMethodDescriptiondefault Strings.TextFlowandAlways(Strings.TextFlow other) Returns a variant of this text flow that forwards both transformed and untransformed text to the given text flow.default Strings.TextFlowandThen(Strings.TextFlow other) Returns a text flow that forwards transformed text to the given text flow.apply(Strings.TextConsumer downstream, Strings.TextConsumer alternative) default Strings.TextConsumerapplyAlways(Strings.TextConsumer downstream) Passes the same downstream consumer for transformed and untransformed text.static Strings.TextFlowdrop()Returns a text flow that drops all text.static Strings.TextFlowempty()Returns a text flow that forwards all text untransformed.static Strings.TextFlowescapeNumeric(String prefix, String suffix, int radix, int minWidth, int maxWidth) Returns a text flow that encodes code points numerically.static Strings.TextFlowstatic Strings.TextFlowgeminate()static Strings.TextFlowidentity()Returns a text flow that forwards all text as if transformed.static Strings.TextFlowmap(IntUnaryOperator op) Returns a text flow that transforms each code point according to a given function.default Strings.TextFloworElse(Strings.TextFlow other) Returns a text flow that forwards untransformed text to the given text flow.static Strings.TextFlowselect(IntPredicate which) static Strings.TextFlowutf16()Methods inherited from interface java.util.function.BiFunction
andThen
-
Field Details
-
JAVA_STRING
-
XML
-
PASCAL_STRING
-
-
Method Details
-
apply
- Specified by:
applyin interfaceBiFunction<Strings.TextConsumer,Strings.TextConsumer, Strings.TextConsumer>
-
applyAlways
Passes the same downstream consumer for transformed and untransformed text.This method is a convenient shorthand for
apply(downstream, downstream).- Parameters:
downstream- the textconsumer to forward both transformed and untransformed text to- Returns:
- a text consumer that forwards both transformed and untransformed
text to
downstream - Throws:
NullPointerException- ifdownstreamis null
-
identity
Returns a text flow that forwards all text as if transformed.- Returns:
- a text flow that forwards all text to
downstream, without any transformation
-
empty
Returns a text flow that forwards all text untransformed.- Returns:
- a text flow that forwards all text to
alternative
-
map
Returns a text flow that transforms each code point according to a given function.- Parameters:
op- the function to transform code points with- Returns:
- a text flow that transforms each code point by applying
op - Throws:
NullPointerException- ifopis null
-
select
-
andAlways
Returns a variant of this text flow that forwards both transformed and untransformed text to the given text flow.- Parameters:
other- the text flow to forward to- Returns:
- a variant of this text flow that forwards both transformed and
untransformed text to
other - Throws:
NullPointerException- ifotheris null
-
andThen
Returns a text flow that forwards transformed text to the given text flow. Untransformed text bypasses the given text flow.- Parameters:
other- the text flow to forward transformed text to- Returns:
- a variant of this text flow that forwards transformed text to
other - Throws:
NullPointerException- ifotheris null
-
orElse
Returns a text flow that forwards untransformed text to the given text flow. Transformed text bypasses the given text flow.- Parameters:
other- the text flow to forward untransformed text to- Returns:
- a variant of this text flow that forwards untransformed text to
other - Throws:
NullPointerException- ifotheris null
-
drop
Returns a text flow that drops all text.This is useful in conjunction with
andThen(eu.bandm.tools.util.java.Strings.TextFlow)andorElse. For example, a positive filter operation can be expressed asselect(p).orElse(drop()), and a negative filter operation can be expressed asselect(p).andThen(drop()).- Returns:
- a text flow that drops all text
-
escapeNumeric
static Strings.TextFlow escapeNumeric(String prefix, String suffix, int radix, int minWidth, int maxWidth) Returns a text flow that encodes code points numerically.The resulting consumer will throw
IllegalArgumentExceptionlater, if a code point is encountered whose numerical escape sequence has more digits than specified bymaxWidth. By contrast, if the sequence has fewer digits than specified byminWidth, leading zeroes are silently added.This transformation applies to all code points. Use
select(java.util.function.IntPredicate)andandThen(eu.bandm.tools.util.java.Strings.TextFlow)ororElse(eu.bandm.tools.util.java.Strings.TextFlow)to restrict the transformation to a subset.- Parameters:
prefix- the common prefix of numerical escape sequencessuffix- the common suffix of numerical escape sequencesradix- the radix to use in numerical escape sequencesminWidth- the minimum number of digits in numerical escape sequencesmaxWidth- the maximum number of digits in numerical escape sequences- Returns:
- a text flow that encodes code points numerically
- Throws:
NullPointerException- if any ofprefix,suffixis nullIllegalArgumentException- ifradixis out of the meaningful bounds, or ifminWidthis less than one or greater thanmaxWidth- See Also:
-
geminate
-
escapeSymbolic
-
utf16
-