/** * @return The special symbolic language code which is supposed to be a category for multiple languages. */ public final LanguageCode getMultilingualCode() { return getLanguages().get("mul"); }
/** * Constructs a new ISO639_3 and loads the list of languages from the .tab file in the classpath. * The list is cached for the lifetime of this ISO639_3 object, make sure not to keep the ISO639_3 object alive * if you only use a small part of all languages. * * @throws RuntimeException If the .tab file is not present in the classpath or if parsing fails. */ public ISO639_3() { allLanguagesCache = Collections.unmodifiableMap(loadFromTabFile()); }
/** * Gets a filtered list of languages. The list is cached for the lifetime of this ISO639_3 object. * * @param scope Must not be null. * @param type Must not be null. * @return Gets a {@link Hashtable} of language codes with the given scope and type. The key in the returned list is the ID * of the language code, which is the 3-letter code of ISO639-3. The given Hashtable is free for modification. */ public final Hashtable<String, LanguageCode> getLanguagesByScopeAndType(LanguageCode.Scope scope, LanguageCode.Type type) { final Map<String, LanguageCode> all = getLanguages(); final Hashtable<String, LanguageCode> result = new Hashtable<String, LanguageCode>(); for(final LanguageCode c : all.values()) { if(c.scope.equals(scope) && c.type.equals(type)) result.put(c.id, c); // We do not clone the code because all its fields are final. } return result; }
public static void main(String[] args) { for(LanguageCode c : loadFromTabFile().values()) { System.out.println(c); } }