/** Returns a readonly collection of all device types. * @see #getByDeviceType */ public static final Collection<String> getDeviceTypes() { init(); return _ldefsByClient.keySet(); }
/** Returns whether the specified language exists. */ public static boolean exists(String name) { init(); synchronized (_ldefByName) { return _ldefByName.containsKey(name); } }
/** Returns a readonly list of all language definitions * regardless of the device type. * * @see #getByDeviceType * @since 2.4.1 */ public static final List<LanguageDefinition> getAll() { init(); final List<LanguageDefinition> list = new LinkedList<LanguageDefinition>(); synchronized (_ldefsByClient) { for (List<LanguageDefinition> langs : _ldefsByClient.values()) { list.addAll(langs); } } return list; }
/** Returns a readonly list of language definitions belong to * the specified device type. * * <p>A device type identifies the type of a client. For example, "ajax" * represents all Web browsers with Ajax support, * while "mil" represents clients that supports * <i>Mobile User interface markup Language</i> (on Limited Connected Device, * such as mobile phones). * * @param deviceType the device type, e.g., "ajax". * @see #getDeviceType * @see #getAll */ public static final List<LanguageDefinition> getByDeviceType(String deviceType) { init(); final List<LanguageDefinition> ldefs; synchronized (_ldefsByClient) { ldefs = _ldefsByClient.get(deviceType); } if (ldefs != null) return ldefs; return Collections.emptyList(); }
/** Associates an extension to a language. * * @param lang the language name. It cannot be null. * @param ext the extension, e.g., "svg". It cannot be null. * @since 3.0.0 */ public static final void addExtension(String ext, String lang) { if (lang == null || ext == null) throw new IllegalArgumentException(); init(); final LanguageDefinition langdef = lookup(lang); //ensure it exists synchronized (_ldefsByExt) { _ldefsByExt.put(ext, langdef); } }
/** Returns the language definition by specifying an extension. * * @param ext the extension, e.g., "zul". * If null, "zul" is assumed. * @exception DefinitionNotFoundException is thrown if the definition * is not found */ public static final LanguageDefinition getByExtension(String ext) { init(); if (ext == null) ext = "zul"; final LanguageDefinition langdef; synchronized (_ldefsByExt) { langdef = _ldefsByExt.get(ext); } if (langdef == null) throw new DefinitionNotFoundException("Language not found for extension " + ext); return langdef; }