Class TranslationRuntimeLimits
The defaults are deliberately generous enough for normal localized strings while bounding work that is proportional to
untrusted localized strings data or runtime values. Builders may customize a limit through the library's hard ceiling.
Localized strings loaders validate expressions against hard ceilings because an application's runtime policy is not yet
available; Strings construction then enforces its configured limits. A single instance is safe to share
between Strings instances and threads.
Caller-supplied CharSequence values are length-checked before Lokalized scans, copies, bidi-isolates, or
materializes them for phonetic resolution. The interpolated-output limit also bounds one phonetic input. For other
placeholder object types, Lokalized must invoke application-defined Object.toString() code before it can
measure the result; these limits bound Lokalized's subsequent work but cannot bound work performed inside that
application method. Use a pre-bounded String or CharSequence when runtime values originate from
untrusted input.
Expression source, token, and nesting limits apply equally to whole-message alternative predicates and
expression-fragment predicates. Generated-placeholder depth and
cumulative expansion limits are shared by language-form fragments
and expression-selected fragments, including dependencies that cross
between the two kinds.
- Since:
- 3.0.0
- Author:
- Mark Allen
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionDefault limit for the absolute value of a decimal scale: 1,024.Default limit for compact-decimal exponents: 64.Default limit for characters in one whole-message or generated-fragment expression: 2,048.Default limit for nested groups in one whole-message or generated-fragment expression: 32.Default limit for tokens in one whole-message or generated-fragment expression: 256.Default cumulative expansion limit across both generated-placeholder kinds: 1,048,576 UTF-16 code units per locale fallback attempt.Default limit for nested generated placeholders across both definition kinds: 32.Default limit for one interpolated message, generated fragment, or phonetic input: 262,144 UTF-16 code units.Default limit for decimal precision: 1,024.Default limit for explicitly visible decimal places: 1,024.Hard ceiling for the absolute value of a decimal scale: 4,096.Hard ceiling for compact-decimal exponents: 4,096.Hard ceiling for characters in one whole-message or generated-fragment expression: 4,096.Hard ceiling for nested groups in one whole-message or generated-fragment expression: 64.Hard ceiling for tokens in one whole-message or generated-fragment expression: 512.Hard ceiling for cumulative expansion across both generated-placeholder kinds: 8,388,608 UTF-16 code units per locale fallback attempt.Hard ceiling for nested generated placeholders across both definition kinds: 64.Hard ceiling for one interpolated message, generated fragment, or phonetic input: 1,048,576 UTF-16 code units.Hard ceiling for decimal precision: 4,096.Hard ceiling for explicitly visible decimal places: 4,096. -
Method Summary
Modifier and TypeMethodDescriptionbuilder()Creates a builder initialized to the library defaults.static @NonNull TranslationRuntimeLimitsdefaults()Gets the library-default limits.booleanGets the maximum absolute decimal scale.Gets the maximum compact-decimal exponent.Gets the maximum characters in one whole-message or generated-fragment expression.Gets the maximum nested groups in one whole-message or generated-fragment expression.Gets the maximum tokens in one whole-message or generated-fragment expression.Gets the maximum cumulative expansion across both generated-placeholder kinds per locale fallback attempt.Gets the maximum generated-placeholder nesting depth across both definition kinds.Gets the maximum UTF-16 code units in one interpolated message, generated fragment, or caller-supplied phonetic input.Gets the maximum decimal precision.Gets the maximum number of explicitly visible decimal places.inthashCode()Creates a builder initialized from this instance.toString()
-
Field Details
-
DEFAULT_MAXIMUM_NUMBER_PRECISION
Default limit for decimal precision: 1,024. -
DEFAULT_MAXIMUM_ABSOLUTE_NUMBER_SCALE
Default limit for the absolute value of a decimal scale: 1,024. -
DEFAULT_MAXIMUM_VISIBLE_DECIMAL_PLACES
Default limit for explicitly visible decimal places: 1,024. -
DEFAULT_MAXIMUM_COMPACT_EXPONENT
Default limit for compact-decimal exponents: 64. -
DEFAULT_MAXIMUM_EXPRESSION_CHARACTERS
Default limit for characters in one whole-message or generated-fragment expression: 2,048. -
DEFAULT_MAXIMUM_EXPRESSION_TOKENS
Default limit for tokens in one whole-message or generated-fragment expression: 256. -
DEFAULT_MAXIMUM_EXPRESSION_NESTING_DEPTH
Default limit for nested groups in one whole-message or generated-fragment expression: 32. -
DEFAULT_MAXIMUM_GENERATED_PLACEHOLDER_DEPTH
Default limit for nested generated placeholders across both definition kinds: 32. -
DEFAULT_MAXIMUM_INTERPOLATED_OUTPUT_CHARACTERS
Default limit for one interpolated message, generated fragment, or phonetic input: 262,144 UTF-16 code units. -
DEFAULT_MAXIMUM_GENERATED_EXPANSION_CHARACTERS
Default cumulative expansion limit across both generated-placeholder kinds: 1,048,576 UTF-16 code units per locale fallback attempt. -
MAXIMUM_NUMBER_PRECISION
Hard ceiling for decimal precision: 4,096. -
MAXIMUM_ABSOLUTE_NUMBER_SCALE
Hard ceiling for the absolute value of a decimal scale: 4,096. -
MAXIMUM_VISIBLE_DECIMAL_PLACES
Hard ceiling for explicitly visible decimal places: 4,096. -
MAXIMUM_COMPACT_EXPONENT
Hard ceiling for compact-decimal exponents: 4,096. -
MAXIMUM_EXPRESSION_CHARACTERS
Hard ceiling for characters in one whole-message or generated-fragment expression: 4,096. -
MAXIMUM_EXPRESSION_TOKENS
Hard ceiling for tokens in one whole-message or generated-fragment expression: 512. -
MAXIMUM_EXPRESSION_NESTING_DEPTH
Hard ceiling for nested groups in one whole-message or generated-fragment expression: 64. -
MAXIMUM_GENERATED_PLACEHOLDER_DEPTH
Hard ceiling for nested generated placeholders across both definition kinds: 64. -
MAXIMUM_INTERPOLATED_OUTPUT_CHARACTERS
Hard ceiling for one interpolated message, generated fragment, or phonetic input: 1,048,576 UTF-16 code units. -
MAXIMUM_GENERATED_EXPANSION_CHARACTERS
Hard ceiling for cumulative expansion across both generated-placeholder kinds: 8,388,608 UTF-16 code units per locale fallback attempt.
-
-
Method Details
-
defaults
Gets the library-default limits.- Returns:
- the library-default limits, not null
-
builder
Creates a builder initialized to the library defaults.- Returns:
- a builder initialized to the library defaults, not null
-
toBuilder
Creates a builder initialized from this instance.- Returns:
- a builder initialized from this instance, not null
-
getMaximumNumberPrecision
Gets the maximum decimal precision.- Returns:
- maximum decimal precision, not null
-
getMaximumAbsoluteNumberScale
Gets the maximum absolute decimal scale.- Returns:
- maximum absolute decimal scale, not null
-
getMaximumVisibleDecimalPlaces
Gets the maximum number of explicitly visible decimal places.- Returns:
- maximum explicitly visible decimal places, not null
-
getMaximumCompactExponent
Gets the maximum compact-decimal exponent.- Returns:
- maximum compact-decimal exponent, not null
-
getMaximumExpressionCharacters
Gets the maximum characters in one whole-message or generated-fragment expression.- Returns:
- maximum characters in one whole-message or generated-fragment expression, not null
-
getMaximumExpressionTokens
Gets the maximum tokens in one whole-message or generated-fragment expression.- Returns:
- maximum tokens in one whole-message or generated-fragment expression, not null
-
getMaximumExpressionNestingDepth
Gets the maximum nested groups in one whole-message or generated-fragment expression.- Returns:
- maximum nested groups in one whole-message or generated-fragment expression, not null
-
getMaximumGeneratedPlaceholderDepth
Gets the maximum generated-placeholder nesting depth across both definition kinds.- Returns:
- maximum generated-placeholder nesting depth across both definition kinds, not null
-
getMaximumInterpolatedOutputCharacters
Gets the maximum UTF-16 code units in one interpolated message, generated fragment, or caller-supplied phonetic input.- Returns:
- maximum UTF-16 code units in one interpolated message, generated fragment, or phonetic input, not null
-
getMaximumGeneratedExpansionCharacters
Gets the maximum cumulative expansion across both generated-placeholder kinds per locale fallback attempt.- Returns:
- maximum cumulative expansion across both generated-placeholder kinds in UTF-16 code units per locale fallback attempt, not null
-
equals
-
hashCode
-
toString
-