@Override public String getFileExtension(String outputFormat) { if (fileExtensions.containsKey(outputFormat)) { return (String) fileExtensions.get(outputFormat); } if (mimeTypes.values().contains(outputFormat)) { return (String) fileExtensions.values().iterator().next(); } return null; }
@Override public String getMimeType(String outputFormat) { Utilities.ensureNonNull("outputFormat", outputFormat); if (mimeTypes.containsKey(outputFormat)) { return (String) mimeTypes.get(outputFormat); } if (mimeTypes.values().contains(outputFormat)) { return outputFormat; } return null; }
public void testLocaleIndependence() { Locale orig = Locale.getDefault(); Locale[] locales = { Locale.ENGLISH, new Locale("tr"), Locale.getDefault() }; String[][] data = { { "i", "I" }, { "\u03C2", "\u03C3" }, { "\u03A3", "\u03C2" }, { "\u03A3", "\u03C3" }, }; try { for (int i = 0; i < locales.length; i++) { Locale.setDefault(locales[i]); for (int j = 0; j < data.length; j++) { assertTrue("Test data corrupt: " + j, data[j][0].equalsIgnoreCase(data[j][1])); CaseInsensitiveMap map = new CaseInsensitiveMap(); map.put(data[j][0], "value"); assertEquals(Locale.getDefault() + ": " + j, "value", map.get(data[j][1])); } } } finally { Locale.setDefault(orig); } }
public void testClone() { CaseInsensitiveMap map = new CaseInsensitiveMap(10); map.put("1", "1"); Map cloned = (Map) map.clone(); assertEquals(map.size(), cloned.size()); assertSame(map.get("1"), cloned.get("1")); }
public Object get(String name) { return map.get(name); }
if (additionalOptions.get("fontAntiAliasing") instanceof String) { String aaVal = (String) additionalOptions.get("fontAntiAliasing"); if (aaVal.equalsIgnoreCase("on") || aaVal.equalsIgnoreCase("true") if (additionalOptions.get("dx") instanceof String) { columnMarginPercentage = Double.parseDouble((String) additionalOptions.get("dx")); if (additionalOptions.get("absoluteMargins") instanceof String) { absoluteMargins = Boolean.parseBoolean((String) additionalOptions.get("absoluteMargins")); if (additionalOptions.get("bandInfo") instanceof String) { bandInformation = Boolean.parseBoolean((String) additionalOptions.get("bandInfo")); if (additionalOptions.get("dy") instanceof String) { rowMarginPercentage = Double.parseDouble((String) additionalOptions.get("dy")); if (additionalOptions.get("mx") instanceof String) { hMarginPercentage = Double.parseDouble((String) additionalOptions.get("mx")); if (additionalOptions.get("my") instanceof String) { vMarginPercentage = Double.parseDouble((String) additionalOptions.get("my")); if (additionalOptions.get("borderColor") instanceof String) { borderColor = LegendUtils.color((String) additionalOptions.get("borderColor")); if (additionalOptions.get("border") instanceof String) { border = Boolean.valueOf((String) additionalOptions.get("border"));
/** * {@inheritDoc} */ public String getWebResourceForTheme(final String name) throws Exception { Theme theme = (Theme) themes.get(name); if (theme == null) { throw new UnknownThemeException(name); } return theme.getWebResource(); }
/** * {@inheritDoc} */ public Map<String, String> getThemeLookAndFeel(String name) throws Exception { Theme theme = (Theme) themes.get(name); if (theme == null) { throw new UnknownThemeException(name); } return theme.getDefaultLayout(); }
/** * Retrieve a value from an input-map with a lookup-key * @param key The lookup-key * @param map The input-map to look in * @param required If the key-value pair must be in the map. * @return The value of the key-value pair */ public static String getMapValue(String key, CaseInsensitiveMap map, boolean required) throws ExceptionReport{ if(map.containsKey(key)){ return ((String[]) map.get(key))[0]; }else if(!required){ LOGGER.warn("Parameter <" + key + "> not found."); return null; }else{ //Fix for Bug 904 https://bugzilla.52north.org/show_bug.cgi?id=904 throw new ExceptionReport("Parameter <" + key + "> not specified.", ExceptionReport.MISSING_PARAMETER_VALUE, key); } }
/** * Retrieve an array of values from an input-map with a lookup-key * @param key The lookup-key * @param map The input-map to look in * @param required If the key-value pair must be in the map. * @return The array of values of the key-value pair */ public static String[] getMapArray(String key, CaseInsensitiveMap map, boolean required) throws ExceptionReport{ if(map.containsKey(key)){ return (String[]) map.get(key); }else if(!required){ LOGGER.warn("Parameter <" + key + "> not found."); return null; }else{ //Fix for Bug 904 https://bugzilla.52north.org/show_bug.cgi?id=904 throw new ExceptionReport("Parameter <" + key + "> not specified.", ExceptionReport.MISSING_PARAMETER_VALUE, key); } }
w = new BufferedWriter(new OutputStreamWriter(os)); for (Object key : map.keySet()) { Object value = map.get(key); String valueString = ""; if(value instanceof String[]){
/** * Retrieve a value from an input-map with a lookup-key * @param key The lookup-key * @param map The input-map to look in * @param required If the key-value pair must be in the map. * @return The value of the key-value pair */ public static String getMapValue(String key, CaseInsensitiveMap map, boolean required, String[] supportedValues) throws ExceptionReport{ if(map.containsKey(key)){ String value = ((String[]) map.get(key))[0]; for (String string : supportedValues) { if(string.equalsIgnoreCase(value)){ return value; } } throw new ExceptionReport("Invalid value for parameter <" + key + ">.", ExceptionReport.INVALID_PARAMETER_VALUE, key); }else if(!required){ LOGGER.warn("Parameter <" + key + "> not found."); return null; }else{ //Fix for Bug 904 https://bugzilla.52north.org/show_bug.cgi?id=904 throw new ExceptionReport("Parameter <" + key + "> not specified.", ExceptionReport.MISSING_PARAMETER_VALUE, key); } }
private String getUniqueName(final String name, final ClassifierResult result) { final Integer currentSeq = (Integer) result.sequenceMap.get(name); if (currentSeq == null) { // name is unique, so return the original name final Integer n = -1; result.sequenceMap.put(name, n); return name; } // create a new name final Integer newSeq = currentSeq + 1; final String newName = name + newSeq; result.sequenceMap.put(name, newSeq); result.sequenceMap.put(newName, -1); return newName; }
/** * Register a theme with the registry. * * @param theme The theme to register. * @throws DuplicateThemeException In case of a duplicate theme */ void registerTheme(final Theme theme) throws Exception { if (themes.get(theme.getName()) != null) { throw new DuplicateThemeException("newcode.theme.register.duplicate.name", theme.getName()); } themes.put(theme.getName(), theme); }