Interface BrailleTranslatorResult
-
public interface BrailleTranslatorResultProvides a braille translator result.
-
-
Field Summary
Fields Modifier and Type Field Description static StringMETRIC_FORCED_BREAKMetric identifier representing the total number of forced breaks applied on the instance up to this point.static StringMETRIC_HYPHEN_COUNTMetric identifier representing the total number of breaks applied at break points inside words on the instance up to this point.
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description BrailleTranslatorResultcopy()Returns a copy of this result in the current state.intcountRemaining()Returns the number of characters remaining in the result.doublegetMetric(String metric)Gets the value of a given metric.StringgetTranslatedRemainder()Gets the translated remainder, in other words the characters not yet extracted withnextTranslatedRow.booleanhasNext()Returns true if there are characters remaining in the result, in other words of there are characters not yet extracted withnextTranslatedRow.default StringnextTranslatedRow(int limit, boolean force)Gets the translated string preceding the row break, including a translated hyphen at the end, if needed.StringnextTranslatedRow(int limit, boolean force, boolean wholeWordsOnly)Gets the translated string preceding the row break, including a translated hyphen at the end, if needed.booleansupportsMetric(String metric)Returns true if this result supports the given metric, false otherwise.
-
-
-
Field Detail
-
METRIC_FORCED_BREAK
static final String METRIC_FORCED_BREAK
Metric identifier representing the total number of forced breaks applied on the instance up to this point. Note that this only counts actually forced breaks, not breaks where forced was allowed but not used .- See Also:
- Constant Field Values
-
METRIC_HYPHEN_COUNT
static final String METRIC_HYPHEN_COUNT
Metric identifier representing the total number of breaks applied at break points inside words on the instance up to this point.- See Also:
- Constant Field Values
-
-
Method Detail
-
nextTranslatedRow
default String nextTranslatedRow(int limit, boolean force)
Gets the translated string preceding the row break, including a translated hyphen at the end, if needed. The length of the translated text must not exceed the specifiedlimit. Ifforceis not used, the result could be empty and no characters removed from the buffer. A caller would typically setforceto true whenlimitis equal to the maximum number of available characters on a row.- Parameters:
limit- specifies the maximum number of characters allowed in the resultforce- specifies if the translator should force a break at the limit if no natural break point is found- Returns:
- returns the translated string
-
nextTranslatedRow
String nextTranslatedRow(int limit, boolean force, boolean wholeWordsOnly)
Gets the translated string preceding the row break, including a translated hyphen at the end, if needed. The length of the translated text must not exceed the specified
limit. Ifforceis not used, the result could be empty and no characters removed from the buffer. A caller would typically setforceto true whenlimitis equal to the maximum number of available characters on a row.When
wholeWordsOnlyis set to true, the row may not end on a break point inside a word. However, when combined withforce, a row may end on such a break point if the distance to the first word boundary is longer than the row and there is a suitable break point inside the word.- Parameters:
limit- specifies the maximum number of characters allowed in the resultforce- specifies if the translator should force a break at the limit if no natural break point is foundwholeWordsOnly- specifies that the row may not end on a break point inside a word.- Returns:
- returns the translated string
-
getTranslatedRemainder
String getTranslatedRemainder()
Gets the translated remainder, in other words the characters not yet extracted withnextTranslatedRow.- Returns:
- returns the translated remainder
-
countRemaining
int countRemaining()
Returns the number of characters remaining in the result. This number equals the number of characters ingetTranslatedRemainder.- Returns:
- returns the number of characters remaining
-
hasNext
boolean hasNext()
Returns true if there are characters remaining in the result, in other words of there are characters not yet extracted withnextTranslatedRow.- Returns:
- returns true if there are characters remaining, false otherwise
-
supportsMetric
boolean supportsMetric(String metric)
Returns true if this result supports the given metric, false otherwise.
Metrics specified by the API are included as static strings in this class, but additional ones may be offered by an implementation.
- Parameters:
metric- the metric identifier- Returns:
- returns true if the given metric is supported, false otherwise
-
getMetric
double getMetric(String metric)
Gets the value of a given metric.
Metrics specified by the API are included as static strings in this interface, but additional ones may be offered by an implementation. Note that an implementation is not required to support any metrics. Metric support can be tested with
supportsMetric.- Parameters:
metric- the metric identifier- Returns:
- the metric value
- Throws:
UnsupportedMetricException- if the metric is not supported
-
copy
BrailleTranslatorResult copy()
Returns a copy of this result in the current state.- Returns:
- returns a copy of the result
- Throws:
UnsupportedOperationException- if the operation is not supported
-
-