public class TranslatableWithContext extends Object
Provides a specification for a list of texts to translate.
This class is best suited for use cases where the input is
naturally segmented and contains some segments with dynamic content
(in other words, content that may change after it has been
submitted to a BrailleTranslator
or a BrailleFilter
).
This class has the following characteristics:
TranslatableWithContext
Translatable
Modifier and Type | Class and Description |
---|---|
static class |
TranslatableWithContext.Builder
Provides a builder for translatable objects
|
Modifier and Type | Method and Description |
---|---|
static <T extends ResolvableText> |
from(List<T> list,
int index)
Returns a new Translatable builder for this list.
|
static <T extends ResolvableText> |
from(List<T> list,
int fromIndex,
int toIndex)
Returns a new Translatable builder for this list.
|
Optional<AttributeWithContext> |
getAttributes()
Gets the attribute context.
|
List<FollowingText> |
getFollowingText()
Gets the text items in the context that follows
the current text.
|
List<PrecedingText> |
getPrecedingText()
Gets the text items in the context that preceded
the current text.
|
List<ResolvableText> |
getTextToTranslate()
Gets the text items to translate.
|
static TranslatableWithContext.Builder |
text(TextWithContext texts)
Creates a new Translatable.Builder with the specified text.
|
public static TranslatableWithContext.Builder text(TextWithContext texts)
texts
- the text to translatepublic static <T extends ResolvableText> TranslatableWithContext.Builder from(List<T> list, int index)
Returns a new Translatable builder for this list.
The current item is the specified index
.
T
- the type of itemslist
- the listindex
- the index of the current itemIndexOutOfBoundsException
- for an illegal endpoint index value
(fromIndex < 0 || toIndex > size ||
fromIndex > toIndex
)public static <T extends ResolvableText> TranslatableWithContext.Builder from(List<T> list, int fromIndex, int toIndex)
Returns a new Translatable builder for this list.
The current items are between the specified fromIndex
,
inclusive, and toIndex
, exclusive. (If
fromIndex
and toIndex
are equal, the current items list
is empty, however this isn't useful in practice.)
T
- the type of itemslist
- the listfromIndex
- low endpoint (inclusive) of the current subListtoIndex
- high endpoint (exclusive) of the current subListIndexOutOfBoundsException
- for an illegal endpoint index value
(fromIndex < 0 || toIndex > size ||
fromIndex > toIndex
)public List<PrecedingText> getPrecedingText()
public List<FollowingText> getFollowingText()
public List<ResolvableText> getTextToTranslate()
public Optional<AttributeWithContext> getAttributes()