List of utility methods to do AbstractMap Usage
Map.Entry | buildClause(String key, String... values) build Clause List<String> clauseValues = new ArrayList<String>(); if (values != null) { for (String value : values) { clauseValues.add(value); } else { clauseValues.add(null); return new AbstractMap.SimpleEntry<String, List<String>>(key, clauseValues); |
Map.Entry | countLinesColumns(String text, int initialLinesCnt, int initialColumnsCnt) Count lines and columns (in last line) in text. int lines = initialLinesCnt; int columns = initialColumnsCnt; boolean foundCr = false; for (char c : text.toCharArray()) { if (c == '\n') { foundCr = false; lines++; columns = 0; ... |
Map.Entry | decodeIconUrl(String path) Decodes an URL path to extract a name and a potential qualifier. if (path.startsWith("/")) path = path.substring(1); String name = null, qualifier = null; String[] parts = path.split("/"); switch (parts.length) { case 2: name = parts[0]; break; ... |
int | getClassType(Object obj) get Class Type Class<?> collection = java.util.AbstractCollection.class; Class<?> map = java.util.AbstractMap.class; if (collection.isInstance(obj)) { return 1; } else if (map.isInstance(obj)) { return 2; } else { return 0; ... |
Map | getSymmetricPropertyValueDifference( Properties propertyFileOne, Properties propertyFileTwo) get Symmetric Property Value Difference Map<String, SimpleEntry<String, String>> differences = new HashMap<String, SimpleEntry<String, String>>(); for (String key : propertyFileOne.stringPropertyNames()) { String propertyOneValue = propertyFileOne.getProperty(key); String propertyTwoValue = propertyFileTwo.getProperty(key); if (propertyOneValue != null && propertyTwoValue != null && !propertyOneValue.equals(propertyTwoValue)) { differences.put(key, new SimpleEntry(propertyOneValue, propertyTwoValue)); return differences; |
Map.Entry | parseEntityURI(final String uri) parse Entity URI final String relPath = uri.substring(uri.lastIndexOf("/")); final int branchIndex = relPath.indexOf('('); final String es = relPath.substring(0, branchIndex); final String eid = relPath.substring(branchIndex + 1, relPath.indexOf(')')); return new SimpleEntry<String, String>(es, eid); |
Map.Entry | parseExportedVariable(String exportedVariable) Parses an exported variable (<variableName> = <defaultValue>). int index = exportedVariable.indexOf('='); String varName = exportedVariable, defaultValue = null; if (index > 0) { varName = exportedVariable.substring(0, index).trim(); defaultValue = exportedVariable.substring(index + 1).trim(); return new AbstractMap.SimpleEntry<String, String>(varName, defaultValue); |
Map.Entry | parseSocketAddress(String address) parse Socket Address String hostName = null; Integer port = null; if (null != address) { if (-1 != address.indexOf(':')) { String[] split = address.split(":"); hostName = split[0]; port = Integer.valueOf(split[1]); } else { ... |
Map.Entry | parseVariableName(String variableName) Parses a variable name (<facetOrComponentName>.<simpleName>). String componentOrFacetName = "", simpleName = variableName; int index = variableName.indexOf('.'); if (index >= 0) { componentOrFacetName = variableName.substring(0, index).trim(); simpleName = variableName.substring(index + 1).trim(); return new AbstractMap.SimpleEntry<String, String>(componentOrFacetName, simpleName); |
Entry | splitByQualifier(String str) split By Qualifier int i = str.lastIndexOf(':'); String name = i == -1 ? str : str.substring(0, i).trim(); String qualifier = i == -1 ? "" : str.substring(i + 1).trim(); Entry<String, String> result = new AbstractMap.SimpleEntry<String, String>(name, qualifier); return result; |