List of usage examples for java.util LinkedHashMap clone
@HotSpotIntrinsicCandidate protected native Object clone() throws CloneNotSupportedException;
From source file:gtu._work.ui.SqlCreaterUI.java
private void firstRowMakeInsertSqlBtn(ActionEvent evt) { try {//from w ww . j a v a2 s . c o m String tableName = Validate.notBlank(tableNameText.getText(), "??"); File srcFile = JCommonUtil.filePathCheck(excelFilePathText2.getText(), "?", "xlsx"); File saveFile = JCommonUtil._jFileChooser_selectFileOnly_saveFile(); if (saveFile == null) { JCommonUtil._jOptionPane_showMessageDialog_error("?"); return; } BufferedWriter writer = new BufferedWriter( new OutputStreamWriter(new FileOutputStream(saveFile), "utf8")); BufferedInputStream bis = new BufferedInputStream(new FileInputStream(srcFile)); XSSFWorkbook xssfWorkbook = new XSSFWorkbook(bis); Sheet sheet = xssfWorkbook.getSheetAt(0); LinkedHashMap<String, String> valueMap = new LinkedHashMap<String, String>(); for (int ii = 0; ii < sheet.getRow(0).getLastCellNum(); ii++) { valueMap.put(formatCellType(sheet.getRow(0).getCell(ii)), ""); } for (int j = 0; j < sheet.getPhysicalNumberOfRows(); j++) { Row row = sheet.getRow(j); LinkedHashMap<String, String> valueMap2 = (LinkedHashMap<String, String>) valueMap.clone(); int ii = 0; for (String key : valueMap2.keySet()) { valueMap2.put(key, formatCellType(row.getCell(ii))); ii++; } appendLog("" + valueMap2); String insertSql = this.fetchInsertSQL(tableName, valueMap2); appendLog("" + insertSql); writer.write(insertSql); writer.newLine(); } bis.close(); writer.flush(); writer.close(); JCommonUtil._jOptionPane_showMessageDialog_info("? : \n" + saveFile); } catch (Exception ex) { JCommonUtil.handleException(ex); } }
From source file:com.google.gwt.emultest.java.util.LinkedHashMapTest.java
@SuppressWarnings("unchecked") public void testClone() { LinkedHashMap<String, String> srcMap = new LinkedHashMap<String, String>(); checkEmptyLinkedHashMapAssumptions(srcMap); // Check empty clone behavior LinkedHashMap<String, String> dstMap = (LinkedHashMap<String, String>) srcMap.clone(); assertNotNull(dstMap);/* w w w.j a va 2s . c o m*/ assertEquals(dstMap.size(), srcMap.size()); assertEquals(dstMap.keySet().toArray(), srcMap.keySet().toArray()); assertEquals(dstMap.entrySet().toArray(), srcMap.entrySet().toArray()); // Check non-empty clone behavior srcMap.put(KEY_1, VALUE_1); srcMap.put(KEY_2, VALUE_2); srcMap.put(KEY_3, VALUE_3); srcMap.put(KEY_4, VALUE_4); dstMap = (LinkedHashMap<String, String>) srcMap.clone(); assertNotNull(dstMap); assertEquals(dstMap.size(), srcMap.size()); assertEquals(dstMap.keySet().toArray(), srcMap.keySet().toArray()); assertEquals(dstMap.entrySet().toArray(), srcMap.entrySet().toArray()); }
From source file:com.vmware.bdd.cli.commands.ClusterCommands.java
private void prettyOutputDetailNodegroups(TopologyType topology, LinkedHashMap<String, List<String>> ngColumnNamesWithGetMethodNames, List<NodeGroupRead> nodegroups) throws Exception { LinkedHashMap<String, List<String>> nColumnNamesWithGetMethodNames = new LinkedHashMap<String, List<String>>(); nColumnNamesWithGetMethodNames.put(Constants.FORMAT_TABLE_COLUMN_NODE_NAME, Arrays.asList("getName")); nColumnNamesWithGetMethodNames.put(Constants.FORMAT_TABLE_COLUMN_NODE_VERSION, Arrays.asList("getVersion")); nColumnNamesWithGetMethodNames.put(Constants.FORMAT_TABLE_COLUMN_HOST, Arrays.asList("getHostName")); if (topology == TopologyType.RACK_AS_RACK || topology == TopologyType.HVE) { nColumnNamesWithGetMethodNames.put(Constants.FORMAT_TABLE_COLUMN_RACK, Arrays.asList("getRack")); }/*from www .jav a2 s .c o m*/ nColumnNamesWithGetMethodNames.put(Constants.FORMAT_TABLE_COLUMN_IP, Arrays.asList("fetchMgtIp")); nColumnNamesWithGetMethodNames.put(Constants.FORMAT_TABLE_COLUMN_HDFS_IP, Arrays.asList("fetchHdfsIp")); nColumnNamesWithGetMethodNames.put(Constants.FORMAT_TABLE_COLUMN_MAPRED_IP, Arrays.asList("fetchMapredIp")); nColumnNamesWithGetMethodNames.put(Constants.FORMAT_TABLE_COLUMN_STATUS, Arrays.asList("getStatus")); nColumnNamesWithGetMethodNames.put(Constants.FORMAT_TABLE_COLUMN_TASK, Arrays.asList("getAction")); for (NodeGroupRead nodegroup : nodegroups) { CommandsUtils.printInTableFormat(ngColumnNamesWithGetMethodNames, new NodeGroupRead[] { nodegroup }, Constants.OUTPUT_INDENT); List<NodeRead> nodes = nodegroup.getInstances(); if (nodes != null) { LinkedHashMap<String, List<String>> nColumnNamesWithGetMethodNamesClone = (LinkedHashMap<String, List<String>>) nColumnNamesWithGetMethodNames .clone(); if (!nodes.isEmpty() && (nodes.get(0).getIpConfigs() == null || (!nodes.get(0).getIpConfigs().containsKey(NetTrafficType.HDFS_NETWORK) && !nodes.get(0).getIpConfigs().containsKey(NetTrafficType.MAPRED_NETWORK)))) { nColumnNamesWithGetMethodNamesClone.remove(Constants.FORMAT_TABLE_COLUMN_HDFS_IP); nColumnNamesWithGetMethodNamesClone.remove(Constants.FORMAT_TABLE_COLUMN_MAPRED_IP); } System.out.println(); CommandsUtils.printInTableFormat(nColumnNamesWithGetMethodNamesClone, nodes.toArray(), new StringBuilder().append(Constants.OUTPUT_INDENT).append(Constants.OUTPUT_INDENT) .toString()); } System.out.println(); } CommandsUtils.prettyOutputErrorNode(nodegroups); }