public Map makeEmptyMap() { return new CaseInsensitiveMap(); }
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")); }
@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; }
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 CapabilitiesRequest(Document doc) throws ExceptionReport { super(doc); this.map = new CaseInsensitiveMap(); this.map.put(REQUEST_DOC, name); String[] serviceArray = {service}; this.map.put(PARAM_SERVICE, serviceArray); this.map.put(PARAM_VERSION, versionList.toArray(new String[versionList.size()]));
/** * 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); } }
private boolean requestNeedsWrapper(HttpServletRequest requestHTTP) { String pathInfo = requestHTTP.getPathInfo(); Map<String, String[]> parameterMap = requestHTTP.getParameterMap(); return pathInfo != null && parameterMap != null && "GET".equalsIgnoreCase(requestHTTP.getMethod()) && !(new CaseInsensitiveMap(parameterMap).containsKey("service")) && (pathInfo.endsWith("search") || pathInfo.endsWith("description")); }
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; }
/** * Read the map in using a custom routine. */ private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { in.defaultReadObject(); doReadObject(in); }
/** * Write the map out using a custom routine. */ private void writeObject(ObjectOutputStream out) throws IOException { out.defaultWriteObject(); doWriteObject(out); }
/** * Helper method to ensure unique output column names. If allowDupsWithRename is set to true, the original name * will be appended with a suffix number to ensure uniqueness. Otherwise, the original column would not be renamed even * even if it has been used * * @param origName the original input name of the column * @param result the data structure to keep track of the used names and decide what output name should be * to ensure uniqueness * @param allowDupsWithRename if the original name has been used, is renaming allowed to ensure output name unique */ private void addToResultMaps(final String origName, final ClassifierResult result, final boolean allowDupsWithRename) { String name = origName; if (allowDupsWithRename) { name = getUniqueName(origName, result); } if (!result.outputMap.containsKey(name)) { result.outputNames.add(name); result.outputMap.put(name, name); } else { result.outputNames.add(EMPTY_STRING); } }
public Object get(String name) { return map.get(name); }
public void set(String name, Object value) { map.put(name, value); }
/** * {@inheritDoc} */ public boolean isThemeRegistered(final String theme) { return themes.containsKey(theme); }
map = new CaseInsensitiveMap(); map.put(n.getLocalName(), new String[]{n.getNodeValue()}); }else if(n.getLocalName().equalsIgnoreCase("version")){ map.put(n.getLocalName(), new String[]{n.getNodeValue()}); map.put("identifier", new String[]{identifierList});
/** * 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); } }
/** * 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); }
/** * Read the map in using a custom routine. */ private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { in.defaultReadObject(); doReadObject(in); }
/** * Write the map out using a custom routine. */ private void writeObject(ObjectOutputStream out) throws IOException { out.defaultWriteObject(); doWriteObject(out); }