List of usage examples for java.util PropertyResourceBundle containsKey
public boolean containsKey(String key)
key
is contained in this ResourceBundle
or its parent bundles. From source file:org.pentaho.platform.plugin.services.importer.LocaleImportHandler.java
/** * return locale specific properties from resource bundle * * @param locale//from ww w .j av a 2 s . com * @return */ private Properties buildLocaleProperties(RepositoryFileImportBundle locale, Properties localePropertiesFromIndex) { Properties localeProperties = new Properties(); PropertyResourceBundle rb = null; String comment = locale.getComment(); String fileTitle = locale.getName(); if (!localePropertiesFromIndex.isEmpty()) { // for old style index.xml as locale comment = localePropertiesFromIndex.getProperty(DESC_PROPERTY_NAME); fileTitle = localePropertiesFromIndex.getProperty(TITLE_PROPERTY_NAME); } else { try { byte[] bytes = IOUtils.toByteArray(locale.getInputStream()); java.io.InputStream bundleInputStream = new ByteArrayInputStream(bytes); rb = new PropertyResourceBundle(bundleInputStream); } catch (Exception returnEmptyIfError) { getLogger().error(returnEmptyIfError.getMessage()); return localeProperties; } if (rb != null) { // this is the 4.8 style - name and description // First try file desc. If no file desc, try for a directory desc, else try fallback comment = rb.containsKey(DESC_PROPERTY_NAME) ? rb.getString(DESC_PROPERTY_NAME) : rb.containsKey(FILE_DESCRIPTION) ? rb.getString(FILE_DESCRIPTION) : rb.containsKey(DIRECTORY_DESCRIPTION) ? rb.getString(DIRECTORY_DESCRIPTION) : comment; // First try name. If no name, try title. If no title, try for a directory name, else use filename. fileTitle = rb.containsKey(TITLE_PROPERTY_NAME) ? rb.getString(TITLE_PROPERTY_NAME) : rb.containsKey("title") ? rb.getString("title") : rb.containsKey(FILE_TITLE) ? rb.getString(FILE_TITLE) : rb.containsKey(DIRECTORY_NAME) ? rb.getString(DIRECTORY_NAME) : fileTitle; } } // this is the new .locale Jcr property names localeProperties.setProperty(FILE_DESCRIPTION, comment != null ? comment : StringUtils.EMPTY); localeProperties.setProperty(FILE_TITLE, fileTitle != null ? fileTitle : StringUtils.EMPTY); return localeProperties; }