List of usage examples for org.apache.commons.collections.bidimap DualHashBidiMap getKey
public Object getKey(Object value)
From source file:com.github.lucapino.jira.helpers.IssuesReportHelper.java
/** * Get a list of id:s for the columns that are to be included in the report. * This method also handles deprecated column names, which will still work. * If deprecated column names are used they generate a warning, indicating * the replacement column name./*w w w . j a v a 2 s . c o m*/ * * @param columnNames The names of the columns * @param allColumns A mapping from column name to column id * @param deprecatedColumns A mapping from deprecated column name to column * id * @param log A log * @return A List of column id:s */ public static List<Integer> getColumnIds(String columnNames, Map<String, Integer> allColumns, Map<String, Integer> deprecatedColumns, Log log) { DualHashBidiMap bidiColumns = null; List<Integer> columnIds = new ArrayList<>(); String[] columnNamesArray = columnNames.split(","); if (deprecatedColumns != null) { bidiColumns = new DualHashBidiMap(allColumns); } // Loop through the names of the columns, to validate each of them and add their id to the list for (String columnNamesNotTrimmed : columnNamesArray) { String columnName = columnNamesNotTrimmed.trim(); if (allColumns.containsKey(columnName)) { columnIds.add(allColumns.get(columnName)); } else if (deprecatedColumns != null && deprecatedColumns.containsKey(columnName)) { Integer columnId = deprecatedColumns.get(columnName); columnIds.add(columnId); if (log != null && bidiColumns != null) { log.warn("The columnName '" + columnName + "' has been deprecated." + " Please use " + "the columnName '" + bidiColumns.getKey(columnId) + "' instead."); } } } return columnIds; }
From source file:eu.scape_project.archiventory.identifiers.UnixFileIdentification.java
@Override public HashMap<String, List<String>> identifyFileList(DualHashBidiMap fileRecidBidiMap) throws IOException { HashMap<String, List<String>> resultMap = new HashMap<String, List<String>>(); String ufidRes = this.identify(fileRecidBidiMap.values()); Scanner s = new Scanner(ufidRes); // one file identification result per line s.useDelimiter("\n"); while (s.hasNext()) { // output syntax of the unix-tool 'file' is ${fileName} : ${mimeType} StringTokenizer st = new StringTokenizer(s.next(), ":"); String fileName = st.nextToken().trim(); // output key String key = (String) fileRecidBidiMap.getKey(fileName); if (key != null) { String containerFileName = key.substring(0, key.indexOf("/")); String containerIdentifier = key.substring(key.indexOf("/") + 1); String outputKey = String.format(outputKeyFormat, containerFileName, containerIdentifier); // output value String property = "mime"; String value = st.nextToken().trim(); String outputValue = String.format(outputValueFormat, tool, property, value); List<String> valueLineList = new ArrayList<String>(); valueLineList.add(outputValue); resultMap.put(outputKey, valueLineList); } else {// w w w .j ava 2s .c om } } return resultMap; }
From source file:org.apache.maven.plugin.issues.IssuesReportHelper.java
/** * Get a list of id:s for the columns that are to be included in the report. * This method also handles deprecated column names, which will still work. * If deprecated column names are used they generate a warning, indicating * the replacement column name./*from w w w . jav a2 s. c o m*/ * * @param columnNames The names of the columns * @param allColumns A mapping from column name to column id * @param deprecatedColumns A mapping from deprecated column name to column id * @param log A log * @return A List of column id:s */ public static List<Integer> getColumnIds(String columnNames, Map<String, Integer> allColumns, Map<String, Integer> deprecatedColumns, Log log) { DualHashBidiMap bidiColumns = null; List<Integer> columnIds = new ArrayList<Integer>(); String[] columnNamesArray = columnNames.split(","); if (deprecatedColumns != null) { bidiColumns = new DualHashBidiMap(allColumns); } // Loop through the names of the columns, to validate each of them and add their id to the list for (String aColumnNamesArray : columnNamesArray) { String columnName = aColumnNamesArray.trim(); if (allColumns.containsKey(columnName)) { columnIds.add(allColumns.get(columnName)); } else if (deprecatedColumns != null && deprecatedColumns.containsKey(columnName)) { Integer columnId = deprecatedColumns.get(columnName); columnIds.add(columnId); if (log != null) { log.warn("The columnName '" + columnName + "' has been deprecated." + " Please use " + "the columnName '" + bidiColumns.getKey(columnId) + "' instead."); } } } return columnIds; }