/** * <p> * Returns a definition, given its name and the customization key. * </p> * <strong>WARNING!</strong> This method is slow! It loads all the * definitions and then selects the needed one. * * @param name The name of the definition. * @param customizationKey The customization key. * @return The requested definition, if found, otherwise <code>null</code>. * The inheritance of the definition must not be resolved. * @since 2.1.0 */ public Definition getDefinition(String name, Locale customizationKey) { Map<String, Definition> defsMap = getDefinitions(customizationKey); return defsMap != null ? defsMap.get(name) : null; }
/** {@inheritDoc} */ public Map<String, Definition> getDefinitions(Locale customizationKey) { ArrayList<Locale> postfixes = computeLocales(customizationKey); Map<String, Definition> localeDefsMap = new HashMap<String, Definition>(); // process the postfixes from the root to the most specific for (Locale postfix : postfixes) { // For each postfix, all the sources must be loaded. for (ApplicationResource resource : sources) { ApplicationResource newResource = applicationContext.getResource(resource, postfix); if (newResource != null) { Map<String, Definition> defsMap = loadDefinitionsFromResource(newResource); if (defsMap != null) { localeDefsMap.putAll(defsMap); } } } } return localeDefsMap; }
/** {@inheritDoc} */ public Map<String, Definition> getDefinitions(Locale customizationKey) { List<String> postfixes = LocaleUtil.calculatePostfixes(customizationKey); Map<String, Definition> localeDefsMap = new HashMap<String, Definition>(); for (Object postfix : postfixes) { // For each postfix, all the sources must be loaded. for (URL url : sourceURLs) { String path = url.toExternalForm(); String newPath = LocaleUtil.concatPostfix(path, (String) postfix); try { URL newUrl = new URL(newPath); Map<String, Definition> defsMap = loadDefinitionsFromURL(newUrl); if (defsMap != null) { localeDefsMap.putAll(defsMap); } } catch (MalformedURLException e) { throw new DefinitionsFactoryException("Error parsing URL " + newPath, e); } } } return localeDefsMap; } }
/** * <p> * Returns a definition, given its name and the customization key. * </p> * <strong>WARNING!</strong> This method is slow! It loads all the * definitions and then selects the needed one. * * @param name The name of the definition. * @param customizationKey The customization key. * @return The requested definition, if found, otherwise <code>null</code>. * The inheritance of the definition must not be resolved. * @since 2.1.0 */ public Definition getDefinition(String name, Locale customizationKey) { Map<String, Definition> defsMap = getDefinitions(customizationKey); return defsMap.get(name); }