List of usage examples for java.util LinkedHashMap get
public V get(Object key)
From source file:dm_p2.DBSCAN.java
public static void normalize(LinkedHashMap<Integer, List<Double>> lhm) { Double[][] mydata = new Double[lhm.size()][lhm.get(1).size()]; Double[] min = new Double[lhm.get(1).size()]; Double[] max = new Double[lhm.get(1).size()]; for (int i = 1; i <= lhm.size(); i++) { List<Double> eachrow = lhm.get(i); for (int k = 0; k < eachrow.size(); k++) { mydata[i - 1][k] = eachrow.get(k); }/*from ww w . ja v a2 s . c om*/ } for (int i = 0; i < lhm.get(1).size(); i++) { min[i] = 1000.0; max[i] = -1000.0; for (int k = 0; k < lhm.size(); k++) { if (mydata[k][i] < min[i]) { min[i] = mydata[k][i]; } if (mydata[k][i] > max[i]) { max[i] = mydata[k][i]; } } } for (int i = 1; i <= lhm.size(); i++) { for (int k = 0; k < lhm.get(1).size(); k++) { mydata[i - 1][k] = (mydata[i - 1][k] - min[k]) / (max[k] - min[k]); } } for (int i = 1; i <= lhm.size(); i++) { gene g = new gene(); ArrayList<Double> expval = new ArrayList<Double>(); for (int k = 0; k < lhm.get(1).size(); k++) { expval.add(mydata[i - 1][k]); //mydata[i-1][k]=(mydata[i-1][k]-min[k])/(max[k]-min[k]); } g.add(i, expval); linkedHashMap.put(i, expval); genelist.add(g); } }
From source file:com.mycomm.dao.mydao.base.MyDaoSupport.java
/** * order by?/* www .j ava 2 s . c o m*/ * * @param orderby * @return */ protected static String buildOrderby(LinkedHashMap<String, String> orderby) { StringBuffer orderbyql = new StringBuffer(""); if (orderby != null && orderby.size() > 0) { orderbyql.append(" order by "); for (String key : orderby.keySet()) { orderbyql.append("o.").append(key).append(" ").append(orderby.get(key)).append(","); } orderbyql.deleteCharAt(orderbyql.length() - 1); } return orderbyql.toString(); }
From source file:com.streamsets.pipeline.stage.lib.hive.HiveMetastoreUtil.java
@SuppressWarnings("unchecked") private static <T> void extractInnerMapFromTheList(Record metadataRecord, String listFieldName, String innerPairFirstFieldName, String innerPairSecondFieldName, boolean isSecondFieldHiveType, LinkedHashMap<String, T> returnVal, StageException exception) throws StageException { boolean throwException = false; if (metadataRecord.has(SEP + listFieldName)) { Field columnField = metadataRecord.get(SEP + listFieldName); List<Field> columnList = columnField.getValueAsList(); if (columnList != null) { for (Field listElementField : columnList) { if (listElementField.getType() != Field.Type.MAP && listElementField.getType() != Field.Type.LIST_MAP) { throwException = true; break; }/*from w w w . jav a2 s. co m*/ LinkedHashMap<String, Field> innerPair = listElementField.getValueAsListMap(); String innerPairFirstField = innerPair.get(innerPairFirstFieldName).getValueAsString(); String innerPairSecondField = innerPair.get(innerPairSecondFieldName).getValueAsString(); returnVal.put(innerPairFirstField, isSecondFieldHiveType ? (T) HiveType.getHiveTypeFromString(innerPairSecondField) : (T) innerPairSecondField); } } } else { throwException = true; } if (throwException) { throw exception; } }
From source file:com.glaf.shiro.SecurityConfig.java
public static void reload() { InputStream inputStream = null; try {/*www .j a va 2 s . c o m*/ loading.set(true); String config_path = SystemProperties.getConfigRootPath() + "/conf/security/"; String defaultFileName = config_path + "system-security.properties"; File defaultFile = new File(defaultFileName); if (defaultFile.isFile()) { inputStream = new FileInputStream(defaultFile); LinkedHashMap<String, String> p = PropertiesUtils.load(inputStream); if (p != null) { Iterator<String> it = p.keySet().iterator(); while (it.hasNext()) { String key = it.next(); String value = p.get(key); /** * ????????? */ if (!filterChainDefinitionMap.containsKey(key)) { filterChainDefinitionMap.put(key, value); } } } IOUtils.closeQuietly(inputStream); inputStream = null; } File directory = new File(config_path); if (directory.isDirectory()) { String[] filelist = directory.list(); for (int i = 0; i < filelist.length; i++) { String filename = config_path + filelist[i]; if (StringUtils.equals(filename, "system-security.properties")) { continue; } File file = new File(filename); if (file.isFile() && file.getName().endsWith(".properties")) { inputStream = new FileInputStream(file); LinkedHashMap<String, String> p = PropertiesUtils.load(inputStream); if (p != null) { Iterator<String> it = p.keySet().iterator(); while (it.hasNext()) { String key = it.next(); String value = p.get(key); /** * ????????? */ if (!filterChainDefinitionMap.containsKey(key)) { filterChainDefinitionMap.put(key, value); } } } IOUtils.closeQuietly(inputStream); inputStream = null; } } } } catch (Exception ex) { throw new RuntimeException(ex); } finally { loading.set(false); IOUtils.closeQuietly(inputStream); } }
From source file:hd3gtv.mydmam.auth.AuthenticationBackend.java
public static void refreshConfiguration() throws Exception { if (Configuration.global.isElementExists("auth") == false) { throw new NullPointerException("Can't found \"auth\" element in configuration"); }//w ww. j av a 2 s .co m if (Configuration.global.isElementKeyExists("auth", "backend") == false) { throw new NullPointerException("Can't found \"auth/backend\" element in configuration"); } List<LinkedHashMap<String, ?>> elements = Configuration.global.getListMapValues("auth", "backend"); if (elements == null) { throw new NullPointerException("No items for \"auth/backend\" element in configuration"); } force_select_domain = Configuration.global.getValueBoolean("auth", "force_select_domain"); authenticators = new ArrayList<Authenticator>(elements.size()); authenticators_domains = new ArrayList<String>(elements.size()); LinkedHashMap<String, ?> configuration_element; File auth_file; for (int pos = 0; pos < elements.size(); pos++) { configuration_element = elements.get(pos); String element_source = (String) configuration_element.get("source"); if (element_source.equals("local")) { String path = (String) configuration_element.get("path"); auth_file = new File(path); if (auth_file.exists() == false) { if (auth_file.isAbsolute() == false) { if (auth_file.getParentFile().getName().equals("conf") & Configuration .getGlobalConfigurationDirectory().getParentFile().getName().equals("conf")) { /** * SQLite file is located in Play conf directory, and Play /app.d/ is also located in conf directory. * We consider that conf directory is the same. */ auth_file = new File(Configuration.getGlobalConfigurationDirectory().getParent() + File.separator + auth_file.getName()); } } } if (auth_file.exists() == false) { throw new FileNotFoundException(path); } String masterkey = (String) configuration_element.get("masterkey"); authenticators.add(new AuthenticatorLocalsqlite(auth_file, masterkey)); String label = (String) configuration_element.get("label"); authenticators_domains.add(label); } else if (element_source.equals("ad")) { String domain = (String) configuration_element.get("domain"); String server = (String) configuration_element.get("server"); int port = (Integer) configuration_element.get("port"); authenticators.add(new AuthenticatorActivedirectory(domain, server, port)); authenticators_domains.add(domain); } else { Log2.log.error("Can't import \"auth/backend\" " + (pos + 1) + " configuration item", null, new Log2Dump("item", configuration_element.toString())); } } if (authenticators.isEmpty()) { throw new NullPointerException("No authentication backend is correctly set"); } }
From source file:PerformanceGraph.java
/** * Plots the performance graph of the best fitness value so far versus the * number of function calls (NFC)./*from w ww .j a va 2 s .com*/ * * @param bestFitness A linked hashmap mapping the NFC to the best fitness value * found so far. * @param fitnessFunction The name of the fitness function, used for the title and the * name of the file that is saved, e.g. "De Jong". */ public static void plot(LinkedHashMap<Integer, Double> bestFitness, String fitnessFunction) { /* Create an XYSeries plot */ XYSeries series = new XYSeries("Best Fitness Value Vs. Number of Function Calls"); /* Add the NFC and best fitness value data to the series */ for (Integer NFC : bestFitness.keySet()) { /* Jfreechart crashes if double values are too large! */ if (bestFitness.get(NFC) <= 10E12) { series.add(NFC.doubleValue(), bestFitness.get(NFC).doubleValue()); } } /* Add the x,y series data to the dataset */ XYSeriesCollection dataset = new XYSeriesCollection(); dataset.addSeries(series); /* Plot the data as an X,Y line chart */ JFreeChart chart = ChartFactory.createXYLineChart("Best Fitness Value Vs. Number of Function Calls", "Number of Function Calls (NFC)", "Best Fitness Value", dataset, PlotOrientation.VERTICAL, false, true, false); /* Configure the chart settings such as anti-aliasing, background colour */ chart.setAntiAlias(true); XYPlot plot = chart.getXYPlot(); plot.setBackgroundPaint(Color.WHITE); plot.setDomainGridlinesVisible(true); plot.setRangeGridlinesVisible(true); plot.setRangeGridlinePaint(Color.black); plot.setDomainGridlinePaint(Color.black); /* Set the domain range from 0 to NFC */ NumberAxis domain = (NumberAxis) plot.getDomainAxis(); domain.setRange(0.0, ControlVariables.MAX_FUNCTION_CALLS.doubleValue()); /* Logarithmic range axis */ plot.setRangeAxis(new LogAxis()); /* Set the thickness and colour of the lines */ XYItemRenderer renderer = plot.getRenderer(); BasicStroke thickLine = new BasicStroke(3.0f); renderer.setSeriesStroke(0, thickLine); renderer.setPaint(Color.BLACK); /* Display the plot in a JFrame */ ChartFrame frame = new ChartFrame(fitnessFunction + " Best Fitness Value", chart); frame.setVisible(true); frame.setSize(1000, 600); /* Save the plot as an image named after fitness function try { ChartUtilities.saveChartAsJPEG(new File("plots/" + fitnessFunction + ".jpg"), chart, 1600, 900); } catch (IOException e) { e.printStackTrace(); }*/ }
From source file:com.streamsets.pipeline.lib.jdbc.JdbcMetastoreUtil.java
public static LinkedHashMap<String, JdbcTypeInfo> getDiff(LinkedHashMap<String, JdbcTypeInfo> oldState, LinkedHashMap<String, JdbcTypeInfo> newState) throws JdbcStageCheckedException { LinkedHashMap<String, JdbcTypeInfo> columnDiff = new LinkedHashMap<>(); for (Map.Entry<String, JdbcTypeInfo> entry : newState.entrySet()) { String columnName = entry.getKey(); JdbcTypeInfo columnTypeInfo = entry.getValue(); if (!oldState.containsKey(columnName)) { columnDiff.put(columnName, columnTypeInfo); } else if (!oldState.get(columnName).equals(columnTypeInfo)) { throw new JdbcStageCheckedException(JdbcErrors.JDBC_303, columnName, oldState.get(columnName).toString(), columnTypeInfo.toString()); }//from w w w .j a v a2s . c om } return columnDiff; }
From source file:com.geewhiz.pacify.utils.ArchiveUtils.java
public static void replaceFilesInArchives(List<PFile> replacePFiles) { // for performance, get all pfiles of the same archive Map<PArchive, List<PFile>> pFilesToReplace = getPFilesToReplace(replacePFiles); // replace the pfiles for (PArchive pArchive : pFilesToReplace.keySet()) { List<PFile> pFiles = pFilesToReplace.get(pArchive); replacePFilesInArchive(pArchive, pFiles); for (PFile toDelete : pFiles) { // delete the temporary extracted file toDelete.getFile().delete(); }/*from w w w . j a va2s . com*/ } // if we have an archive in archive, replace it. Order is relevant, so we use a LinkedHashMap pfile -> parchive3 -> parchive2 -> parchive1 LinkedHashMap<PArchive, List<PArchive>> parentArchives = getParentArchives(replacePFiles); // replace the archives within the parent archive for (PArchive parentArchive : parentArchives.keySet()) { List<PArchive> pArchives = parentArchives.get(parentArchive); replacePArchivesInArchive(parentArchive, pArchives); for (PArchive pArchive : pArchives) { // delete the temporary extracted file pArchive.getFile().delete(); } } }
From source file:com.projity.field.Select.java
public static String toConfigurationXMLOptions(LinkedHashMap map, String keyPrefix) { // MapIterator i = map.i(); Iterator i = map.keySet().iterator(); StringBuffer buf = new StringBuffer(); HashSet duplicateSet = new HashSet(); // don't allow duplicate keys while (i.hasNext()) { String key = (String) i.next(); // notion of key and value is switched String value = (String) map.get(key); int dupCount = 2; String newKey = key;//from w w w .ja va 2 s .c o m while (duplicateSet.contains(newKey)) { newKey = key + "-" + dupCount++; } key = newKey; duplicateSet.add(key); if (key == null || key.length() == 0) continue; if (value == null || value.length() == 0) continue; key = keyPrefix + key; // String key = "<html>" + keyPrefix + ": " + "<b>" + i.getValue() // +"</b></html>"; buf.append(SelectOption.toConfigurationXML(key, value)); } return buf.toString(); }
From source file:net.sf.maltcms.chromaui.project.spi.DBProjectFactory.java
private static void addNormalizationDescriptors(Map<String, Object> props, Map<File, File> importFileMap, LinkedHashMap<File, IChromatogramDescriptor> fileToDescriptor) { HashMap<File, INormalizationDescriptor> normalizationDescriptors = (HashMap<File, INormalizationDescriptor>) props .get(DBProjectVisualPanel3.PROP_FILE_TO_NORMALIZATION); for (File file : normalizationDescriptors.keySet()) { fileToDescriptor.get(importFileMap.get(file)) .setNormalizationDescriptor(normalizationDescriptors.get(file)); }//w w w . j a va2 s . c o m }