Package eu.bandm.tscore.base
Class TransletLib
java.lang.Object
eu.bandm.tscore.base.TransletLib
Library of universal
Translet
parsers, and of auxiliary functions
to be used in such parsers.-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
Filters the result of its sub-parser by an explicit Java-encoded boolean predicate. -
Field Summary
Modifier and TypeFieldDescriptionstatic final Translet.Parser<String>
Parser which accepts any text which is framed by doublequotes and does not contain doublequotes.static final Translet.Parser<String>
Parser which accepts any text which fulfills the rules for Java identifiers.static final Translet.Parser<String>
Parser accepting string values "0" or any positive integer, no leading zeros.static final Translet.Parser<String>
Parser accepting string values of any positive integer, no leading zeros.static final Translet.Parser<Double>
Parser for floating point numbers (but not in "E" notation or with "_")static final Translet.Parser<Integer>
Parser accepting string values "0" or any positive integer, no leading zeros, and converting it toInteger
value.static final Translet.Parser<Integer>
Parser accepting string values of any positive integer, no leading zeros, and converting it toInteger
value.static final Translet.Parser<Integer>
Parser accepting strings representing integer percent values (one or two digits, no leading zeros, or the special values "100" and "0"), and converting it toInteger
value.static final Translet.Parser<Rational>
Parser for rational numbers in slash notation.static final Translet.Parser<Rational>
Parser for rational numbers in slash notation.static final Translet.Parser<Rational>
Parser for rational numbers in slash notation.Map of latin characters to roman numeral valuesstatic final Function<String,
@Opt BigDecimal> String conversion function.static final Function<String,
@Opt BigInteger> String conversion function.String conversion function at base 10.static final BiFunction<String,
String, @Opt Rational> String conversion function. -
Method Summary
Modifier and TypeMethodDescriptionint2roman
(int num, boolean uppercase) Convert a positive integer into a roman number literal.static final <T> @Opt Translet.Parser<T>
makeOR1
(@Opt Translet.Parser<? extends T> p1, @Opt Translet.Parser<? extends T> p2) Combine parsers into a OR parser, if necessary.roman2integer
(MessageReceiver<SimpleMessage<?>> msg, boolean lowercasesupported, boolean uppercasesupported, boolean subtractiveformat_directNeighbour, boolean subtractiveformat_fartherNeighbour) Convert a string with a Roman number into anInteger
value.string2integer
(int radix) This method returns a conversionFunction
from a text string to integer in the given base.static <R> TransletLib._TEST<R>
TEST
(Predicate<R> test, Translet.Parser<R> sub) static <R> TransletLib._TEST<R>
TEST
(Predicate<R> test, String name, Translet.Parser<R> sub) static <T,
R> Translet.Parser<T> toConst
(Translet.Parser<R> condition, T result)
-
Field Details
-
string2bigInteger
String conversion function. -
strings2rational
String conversion function. -
string2bigDecimal
String conversion function. -
string2integer
String conversion function at base 10. -
parse_integer_nonNeg
Parser accepting string values "0" or any positive integer, no leading zeros. -
parse_integer_positive
Parser accepting string values of any positive integer, no leading zeros. -
parseAndPack_integer_nonNeg
Parser accepting string values "0" or any positive integer, no leading zeros, and converting it toInteger
value. -
parseAndPack_integer_positive
Parser accepting string values of any positive integer, no leading zeros, and converting it toInteger
value. -
parseAndPack_rational_withSlash_nonNeg
Parser for rational numbers in slash notation. Slash !/
" and two numbers must be present, only the first may be==0
. No sign+
or-
permitted. -
parseAndPack_rational_optionalSlash_nonNeg
Parser for rational numbers in slash notation. Either slash !/
" and two numbers must be present, only the first may be==0
, or only one non-negative integer. No sign+
or-
permitted. -
parseAndPack_rational_withSlash_positive
Parser for rational numbers in slash notation. Slash !/
" and two numbers must be present, none of which may be==0
. No sign+
or-
permitted. -
parseAndPack_double
Parser for floating point numbers (but not in "E" notation or with "_") -
parseAndPack_percent
Parser accepting strings representing integer percent values (one or two digits, no leading zeros, or the special values "100" and "0"), and converting it toInteger
value. -
romanLetterValues
Map of latin characters to roman numeral values -
doubleQuotedTextParser_noDoubleQuotesContained
Parser which accepts any text which is framed by doublequotes and does not contain doublequotes. -
identifier_javalike
Parser which accepts any text which fulfills the rules for Java identifiers.
-
-
Method Details
-
string2integer
This method returns a conversionFunction
from a text string to integer in the given base. -
roman2integer
public static final Function<String,Integer> roman2integer(MessageReceiver<SimpleMessage<?>> msg, boolean lowercasesupported, boolean uppercasesupported, boolean subtractiveformat_directNeighbour, boolean subtractiveformat_fartherNeighbour) Convert a string with a Roman number into anInteger
value. Returns null in case of an error, and sends messages. ATTENTION, if used in a tscore parser, a null value does not indicate failure. For this, an exception must be thrown, e.g. via aMessageThrower
.// FIXME wie verhält sich das zu "
/util/RomanNumbers" ?? (FIXME does not yet reject e.g. IIII
orXXXXXXXX
or evenIXII
.)- Parameters:
lowercasesupported
- whether lower case letters are decodeduppercasesupported
- whether upper case letters are decodedsubtractiveformat_directNeighbour
- whether "IX", "XC" etc. are allowedsubtractiveformat_fartherNeighbour
- whether "IL", "IC" are allowed
-
int2roman
Convert a positive integer into a roman number literal.- Parameters:
num
- the number to convert, must be in the range1 <= num < 4000
uppercase
- whether upper case letters shall be returned
-
makeOR1
@Opt public static final <T> @Opt Translet.Parser<T> makeOR1(@Opt @Opt Translet.Parser<? extends T> p1, @Opt @Opt Translet.Parser<? extends T> p2) Combine parsers into a OR parser, if necessary. I.e. if more than one is!= null
. -
TEST
-
TEST
-
toConst
-