public Map makeEmptyMap() { return new CaseInsensitiveMap(); }
throw new IllegalArgumentException("Empty list of mimeTypes provided"); this.mimeTypes = new CaseInsensitiveMap(new HashMap<String, String>(mimeTypes)); this.outputFormats = new ArrayList<String>(outputFormats); this.fileExtensions = new CaseInsensitiveMap(fileExtensions); this.geoserver = geoserver;
public void testCaseInsensitive() { Map map = new CaseInsensitiveMap(); map.put("One", "One"); map.put("Two", "Two"); assertEquals("One", (String) map.get("one")); assertEquals("One", (String) map.get("oNe")); map.put("two", "Three"); assertEquals("Three", (String) map.get("Two")); }
Map<String, String> env = Shell.WINDOWS ? new CaseInsensitiveMap(callerEnv) : callerEnv; String[] classPathEntries = inputClassPath.split(File.pathSeparator);
public void testNullHandling() { Map map = new CaseInsensitiveMap(); map.put("One", "One"); map.put("Two", "Two"); map.put(null, "Three"); assertEquals("Three", (String) map.get(null)); map.put(null, "Four"); assertEquals("Four", (String) map.get(null)); Set keys = map.keySet(); assertTrue(keys.contains("one")); assertTrue(keys.contains("two")); assertTrue(keys.contains(null)); assertTrue(keys.size() == 3); }
public void testPutAll() { Map map = new HashMap(); map.put("One", "One"); map.put("Two", "Two"); map.put("one", "Three"); map.put(null, "Four"); map.put(new Integer(20), "Five"); Map caseInsensitiveMap = new CaseInsensitiveMap(map); assertTrue(caseInsensitiveMap.size() == 4); // ones collapsed Set keys = caseInsensitiveMap.keySet(); assertTrue(keys.contains("one")); assertTrue(keys.contains("two")); assertTrue(keys.contains(null)); assertTrue(keys.contains(Integer.toString(20))); assertTrue(keys.size() == 4); assertTrue(!caseInsensitiveMap.containsValue("One") || !caseInsensitiveMap.containsValue("Three")); // ones collaped assertEquals(caseInsensitiveMap.get(null), "Four"); }
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 static Map<String, String> parseQueryString(final String queryString) { if (queryString == null || queryString.length() == 0) { return Collections.emptyMap(); } String[] params = queryString.split("&"); @SuppressWarnings("unchecked") Map<String, String> kvpMap = new CaseInsensitiveMap(); for (String kvp : params) { String[] split = kvp.split("="); if (split[0].length() > 0) { String key = split[0]; String value = split.length > 1 ? urlDecode(split[1]) : null; kvpMap.put(key, value); } } return kvpMap; } }
@SuppressWarnings("unchecked") @Override protected Map<String, List<Object>> createImmutableAttributeMap(int size) { return ListOrderedMap.decorate(new CaseInsensitiveMap(size > 0 ? size : 1)); } }
/** * Create a Map instance to be used as attribute map. * <br/> * By default, a linked case-insensitive Map will be created * * @param attributeCount the attribute count, to be used as initial capacity for the Map * @return the new Map instance */ @SuppressWarnings("unchecked") protected Map<String, Object> createAttributeMap(int attributeCount) { return ListOrderedMap.decorate(new CaseInsensitiveMap(attributeCount > 0 ? attributeCount : 1)); }
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")); }
@SuppressWarnings("unchecked") @Override protected Map<String, List<Object>> createImmutableAttributeMap(int size) { return ListOrderedMap.decorate(new CaseInsensitiveMap(size > 0 ? size : 1)); } }
/** * Create a Map instance to be used as column map. * <br/> * By default, a linked case-insensitive Map will be created * * @param columnCount the column count, to be used as initial capacity for the Map * @return the new Map instance */ @SuppressWarnings("unchecked") protected Map<String, Object> createColumnMap(int columnCount) { return ListOrderedMap.decorate(new CaseInsensitiveMap(columnCount > 0 ? columnCount : 1)); }
private static Map createListOrderedCaseInsensitiveMap(int initialCapacity) { // Commons Collections does not support initial capacity of 0. return ListOrderedMap.decorate(new CaseInsensitiveMap(initialCapacity == 0 ? 1 : initialCapacity)); }
/** * Case insensitive lookup for a couple of strings, drops everything else * * @param map * @param keys * @return map subset containing (URL decoded) values for {@code keys}, with keys normalized to * upper case */ @SuppressWarnings("unchecked") public static Map<String, String> selectedStringsFromMap( Map<String, ?> map, String encoding, String... keys) { map = new CaseInsensitiveMap(map); Map<String, String> selected = new CaseInsensitiveMap(); for (String key : keys) { Object value = map.get(key); if (value != null) { String sValue = value instanceof String[] ? ((String[]) value)[0] : String.valueOf(value); selected.put(key.toUpperCase(), URLDecode(sValue, encoding)); } } return selected; }
public static Map<String, String> parseQueryString(final String queryString) { if (queryString == null || queryString.length() == 0) { return Collections.emptyMap(); } String[] params = queryString.split("&"); @SuppressWarnings("unchecked") Map<String, String> kvpMap = new CaseInsensitiveMap(); for (String kvp : params) { String[] split = kvp.split("="); if (split[0].length() > 0) { String key = split[0]; String value = split.length > 1 ? urlDecode(split[1]) : null; kvpMap.put(key, value); } } return kvpMap; } }
public static Map<String,String> getHeaders(BasicProperties properties){ Preconditions.checkArgument(properties!=null, "properties cannot be null."); Map<String,String> headers = new CaseInsensitiveMap(); setTimestamp(headers, properties); Map<String, Object> rabbitmqHeaders = properties.getHeaders(); if(null!=rabbitmqHeaders){ for(Map.Entry<String, Object> kvp:rabbitmqHeaders.entrySet()){ if(!headers.containsKey(kvp.getKey())&&null!=kvp.getValue()){ if(log.isInfoEnabled())log.info("header=" + kvp.getKey() + " value=" + kvp.getValue()); headers.put(kvp.getKey(), kvp.getValue().toString()); } } } return headers; }
@SuppressWarnings("unchecked") public void init() { method2Mapping = new CaseInsensitiveMap(); if (!CollectionUtil.isEmpty(mappings)) { for (Mapping mapping : mappings) { addUrlMapping(mapping); } } }
@SuppressWarnings("unchecked") protected GetCoverageType parse(String url) throws Exception { Map<String, Object> rawKvp = new CaseInsensitiveMap(KvpUtils.parseQueryString(url)); Map<String, Object> kvp = new CaseInsensitiveMap(parseKvp(rawKvp)); WCS20GetCoverageRequestReader reader = new WCS20GetCoverageRequestReader(); GetCoverageType gc = (GetCoverageType) reader.createRequest(); return (GetCoverageType) reader.read(gc, kvp, rawKvp); }