public class Language extends Object implements Comparable<Language>
The GNU Lesser General Public License for details.
Modifier and Type | Class and Description |
---|---|
private static class |
Language.CanonicalUtils
Converts substrings to the canonical representation for language code, script and country.
|
Modifier and Type | Field and Description |
---|---|
private String |
code
The lower case iso639 language code.
|
private String |
country
The UPPER case iso3166 country code.
|
static Language |
DEFAULT_LANG
The default language is English.
|
static String |
DEFAULT_LANG_CODE
The default language code is en for English.
|
private String |
found
The effective specification.
|
private String |
given
The original specification provided by the user.
|
private boolean |
knowsDirection |
private boolean |
ltor |
private String |
name
The name as defined by Languages.
|
private String |
script
The Title case iso15924 script code.
|
static String |
UNKNOWN_LANG_CODE
The language code for invalid language specifications is und for Undetermined.
|
private boolean |
valid
Flag to store whether the code is valid.
|
Constructor and Description |
---|
Language(String specification)
A single language defined by an ISO-639 code.
|
Modifier and Type | Method and Description |
---|---|
private boolean |
compareStrings(String a,
String b)
Equal if both a and b are the same.
|
int |
compareTo(Language o) |
boolean |
equals(Object obj) |
String |
getCode()
Get the iso639 language code.
|
String |
getCountry()
Get the iso3166 script for the language.
|
String |
getFoundSpecification()
The specification that was given might not be be the one that
ultimately gets the name.
|
String |
getGivenSpecification()
The specification that was given might not be be the one that
ultimately gets the name.
|
String |
getName()
Get the localized language name.
|
String |
getScript()
Get the iso15924 script for the language.
|
int |
hashCode() |
boolean |
isLeftToRight()
Determine whether this language is a Left-to-Right or a Right-to-Left
language.
|
boolean |
isValidLanguage()
Determine whether this language is valid.
|
private void |
parse(String spec)
Split the specification on '-' into 1 to 3 parts.
|
String |
toString() |
public static final String DEFAULT_LANG_CODE
public static final String UNKNOWN_LANG_CODE
public static final Language DEFAULT_LANG
private String given
private String found
private String code
private String script
private String country
private String name
private boolean valid
private boolean knowsDirection
private boolean ltor
public Language(String specification)
specification
- the specifier for the particular languagepublic String getGivenSpecification()
public String getFoundSpecification()
public boolean isValidLanguage()
public String getCode()
public String getScript()
public String getCountry()
public String getName()
public boolean isLeftToRight()
Note: This is problematic. Languages do not have direction. Scripts do. Further, there are over 7000 living languages, many of which are written in Right-to-Left scripts and are not listed here.
public int compareTo(Language o)
compareTo
in interface Comparable<Language>
private void parse(String spec)
spec
- the specification to parse