public class NumberDictionary extends java.lang.Object implements Dictionary
Dictionary
that (virtually) contains every number and their
corresponding translations for some specific thousands and decimal separators.
The provided implementation is immutable and, therefore, instances can be freely shared.
DUMMY_DICTIONARY
Constructor and Description |
---|
NumberDictionary()
Constructs a new dictionary using the comma as the thousands separator and
the dot as the decimal separator for the entries in the target language.
|
NumberDictionary(java.lang.String thousandsSeparator,
java.lang.String decimalSeparator)
Creates a new dictionary with the specified thousands and decimal
separators for the entries in the target language.
|
Modifier and Type | Method and Description |
---|---|
boolean |
containsEntry(Entity src,
Entity trg)
Checks whether this bilingual dictionary contains the specified entry.
|
boolean |
equals(java.lang.Object obj) |
int |
hashCode() |
java.lang.String |
translate(Entity entity)
Translates the specified
Entity . |
public NumberDictionary()
NumberDictionary(",", ".")
,
which is appropriate for languages like English but not for languages
like Basque or Spanish.public NumberDictionary(java.lang.String thousandsSeparator, java.lang.String decimalSeparator)
thousandsSeparator
- the delimiter used in the target language to divide the digits before the decimal mark in groups of three (such as "," in "1,500,000").decimalSeparator
- the delimiter used in the target language to separate the integer part from the fractional part of a number (such as "." in "3.14159265").public java.lang.String translate(Entity entity)
Dictionary
Entity
.translate
in interface Dictionary
entity
- the Entity
to translate.Entity
, or null
if the dictionary doesn't contain any entry for it.public boolean containsEntry(Entity src, Entity trg)
Dictionary
containsEntry
in interface Dictionary
src
- the Entity
in the source language.trg
- the Entity
in the target language.trg
is a valid translation of src
according to this dictionary.public boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object