Package nzilbb.util
Class ISO639
- java.lang.Object
-
- nzilbb.util.ISO639
-
public class ISO639 extends Object
Manages various operations for validating and translating ISO 639 standard language codes and language names.- Author:
- Robert Fromont robert@fromont.net.nz
-
-
Constructor Summary
Constructors Constructor Description ISO639()
Default constructor
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Optional<String>
alpha2(String id)
Gets the alpha 2 code of a language, given some language identifier.Set<String>
alpha2Codes()
Provides a list of all known alpha-2 codes.Optional<String>
alpha2FromAlpha3(String code)
Gets the alpha 2 code of a language, given its alpha-3 code.Optional<String>
alpha2FromName(String name)
Gets the alpha 2 code of a language, given its name.Optional<String>
alpha3(String id)
Gets the alpha 3 code of a language, given some language identifier.Set<String>
alpha3Codes()
Provides a list of all known alpha-3 codes.Optional<String>
alpha3FromAlpha2(String code)
Gets the alpha 3 code of a language, given its alpha-2 code.Optional<String>
alpha3FromName(String name)
Gets the alpha 3 code of a language, given its name.boolean
isAlpha2(String s)
Determines whether the given string is a 2-letter ISO639 code.boolean
isAlpha3(String s)
Determines whether the given string is a 3-letter ISO639 code.boolean
isName(String s)
Determines whether the given string is a language name in English.Optional<String>
name(String id)
Gets the standard English name of a language, given some language identifier.Optional<String>
nameFromAlpha2(String code)
Gets the name of a language, given its alpha-2 code.Optional<String>
nameFromAlpha3(String code)
Gets the name of a language, given its alpha-3 code.Set<String>
names()
Provides a list of all known names.
-
-
-
Method Detail
-
isName
public boolean isName(String s)
Determines whether the given string is a language name in English.- Parameters:
s
-- Returns:
- true if the given string is a known language name (in English), false otherwise.
-
isAlpha2
public boolean isAlpha2(String s)
Determines whether the given string is a 2-letter ISO639 code.- Parameters:
s
-- Returns:
- true if the given string is a known 2-letter ISO639, false otherwise.
-
isAlpha3
public boolean isAlpha3(String s)
Determines whether the given string is a 3-letter ISO639 code.- Parameters:
s
-- Returns:
- true if the given string is a known 3-letter ISO639, false otherwise.
-
nameFromAlpha2
public Optional<String> nameFromAlpha2(String code)
Gets the name of a language, given its alpha-2 code. Case is ignored.- Parameters:
code
-- Returns:
- The name of a language with the given two-letter code, or an empty Optional if the code is unknown.
-
nameFromAlpha3
public Optional<String> nameFromAlpha3(String code)
Gets the name of a language, given its alpha-3 code. Case is ignored.- Parameters:
code
-- Returns:
- The name of a language with the given three-letter code, or an empty Optional if the code is unknown.
-
alpha2FromName
public Optional<String> alpha2FromName(String name)
Gets the alpha 2 code of a language, given its name. Case is ignored.- Parameters:
name
-- Returns:
- The two-letter code of a language with the given name, or an empty Optional if the name is unknown.
-
alpha3FromName
public Optional<String> alpha3FromName(String name)
Gets the alpha 3 code of a language, given its name. Case is ignored.- Parameters:
name
-- Returns:
- The two-letter code of a language with the given name, or an empty Optional if the name is unknown.
-
alpha2FromAlpha3
public Optional<String> alpha2FromAlpha3(String code)
Gets the alpha 2 code of a language, given its alpha-3 code. Case is ignored.- Parameters:
code
- An alpha-3 code.- Returns:
- The two-letter code of a language with the given three-letter code, or an empty Optional if the name is unknown.
-
alpha3FromAlpha2
public Optional<String> alpha3FromAlpha2(String code)
Gets the alpha 3 code of a language, given its alpha-2 code. Case is ignored.- Parameters:
code
- An alpha-2 code.- Returns:
- The three-letter code of a language with the given two-letter code, or an empty Optional if the name is unknown.
-
alpha3
public Optional<String> alpha3(String id)
Gets the alpha 3 code of a language, given some language identifier.- Parameters:
id
- A string identifying the language, which may be an alpha-3 code, an alpha-2 code, or a name.- Returns:
- The three-letter code of the language with the given ID, or an empty Optional if the identifier is unknown.
-
alpha2
public Optional<String> alpha2(String id)
Gets the alpha 2 code of a language, given some language identifier.- Parameters:
id
- A string identifying the language, which may be an alpha-3 code, an alpha-2 code, or a name.- Returns:
- The two-letter code of the language with the given ID, or an empty Optional if the identifier is unknown.
-
name
public Optional<String> name(String id)
Gets the standard English name of a language, given some language identifier.- Parameters:
id
- A string identifying the language, which may be an alpha-3 code, an alpha-2 code, or a name.- Returns:
- The English name of the language with the given ID, or an empty Optional if the identifier is unknown.
-
alpha2Codes
public Set<String> alpha2Codes()
Provides a list of all known alpha-2 codes.- Returns:
- An alphabetical list of two-letter codes.
-
alpha3Codes
public Set<String> alpha3Codes()
Provides a list of all known alpha-3 codes.- Returns:
- An alphabetical list of three-letter codes.
-
-