List of usage examples for java.util HashMap clone
@SuppressWarnings("unchecked") @Override public Object clone()
From source file:MainClass.java
public static void main(String[] a) { HashMap map = new HashMap(); map.put("key1", "value1"); map.put("key2", "value2"); map.put("key3", "value3"); HashMap map2 = (HashMap) map.clone(); System.out.println(map2);/*from w w w .j a v a2 s . c o m*/ }
From source file:Main.java
public static void main(String[] a) { HashMap<String, String> map = new HashMap<String, String>(); map.put("key1", "value1"); map.put("key2", "value2"); map.put("key3", "value3"); HashMap map2 = (HashMap) map.clone(); System.out.println(map2);/*from ww w . jav a 2 s.co m*/ }
From source file:Main.java
public static void main(String a[]) { HashMap hashMap = new HashMap(); HashMap hashMap1 = new HashMap(); hashMap.put(1, "One"); hashMap.put(2, "Two"); hashMap.put(3, "Three"); System.out.println("Original HashMap : " + hashMap); hashMap1 = (HashMap) hashMap.clone(); System.out.println("Copied HashMap : " + hashMap1); }
From source file:Main.java
public static void main(String args[]) { // create two hash maps HashMap<Integer, String> newmap1 = new HashMap<Integer, String>(); HashMap<Integer, String> newmap2 = new HashMap<Integer, String>(); // populate hash map newmap1.put(1, "tutorials"); newmap1.put(2, "from"); newmap1.put(3, "java2s.com"); // clone 1st map newmap2 = (HashMap) newmap1.clone(); System.out.println("1st Map: " + newmap1); System.out.println("Cloned 2nd Map: " + newmap2); }
From source file:org.apache.axis.transport.jms.JMSConnectorFactory.java
private static JMSConnector createConnector(HashMap connectorConfig, HashMap cfConfig, boolean allowReceive, String username, String password, JMSVendorAdapter adapter) throws Exception { if (connectorConfig != null) connectorConfig = (HashMap) connectorConfig.clone(); int numRetries = MapUtils.removeIntProperty(connectorConfig, JMSConstants.NUM_RETRIES, JMSConstants.DEFAULT_NUM_RETRIES); int numSessions = MapUtils.removeIntProperty(connectorConfig, JMSConstants.NUM_SESSIONS, JMSConstants.DEFAULT_NUM_SESSIONS); long connectRetryInterval = MapUtils.removeLongProperty(connectorConfig, JMSConstants.CONNECT_RETRY_INTERVAL, JMSConstants.DEFAULT_CONNECT_RETRY_INTERVAL); long interactRetryInterval = MapUtils.removeLongProperty(connectorConfig, JMSConstants.INTERACT_RETRY_INTERVAL, JMSConstants.DEFAULT_INTERACT_RETRY_INTERVAL); long timeoutTime = MapUtils.removeLongProperty(connectorConfig, JMSConstants.TIMEOUT_TIME, JMSConstants.DEFAULT_TIMEOUT_TIME); String clientID = MapUtils.removeStringProperty(connectorConfig, JMSConstants.CLIENT_ID, null); String domain = MapUtils.removeStringProperty(connectorConfig, JMSConstants.DOMAIN, JMSConstants.DOMAIN_DEFAULT); // this will be set if the target endpoint address was set on the Axis call JMSURLHelper jmsurl = (JMSURLHelper) connectorConfig.get(JMSConstants.JMS_URL); if (cfConfig == null) throw new IllegalArgumentException("noCfConfig"); if (domain.equals(JMSConstants.DOMAIN_QUEUE)) { return new QueueConnector(adapter.getQueueConnectionFactory(cfConfig), numRetries, numSessions, connectRetryInterval, interactRetryInterval, timeoutTime, allowReceive, clientID, username, password, adapter, jmsurl); } else // domain is Topic {//ww w . j a v a2s . c om return new TopicConnector(adapter.getTopicConnectionFactory(cfConfig), numRetries, numSessions, connectRetryInterval, interactRetryInterval, timeoutTime, allowReceive, clientID, username, password, adapter, jmsurl); } }
From source file:com.app.server.util.ClassLoaderUtil.java
public static boolean cleanupJarFileFactory(CopyOnWriteArrayList setJarFileNames2Close) { boolean res = false; Class classJarURLConnection = null; try {//ww w. j a va 2s. co m classJarURLConnection = Class.forName("sun.net.www.protocol.jar.JarURLConnection"); } catch (ClassNotFoundException e) { e.printStackTrace(); } if (classJarURLConnection == null) { return res; } Field f = null; try { f = classJarURLConnection.getDeclaredField("factory"); } catch (NoSuchFieldException e) { e.printStackTrace(); } if (f == null) { return res; } f.setAccessible(true); Object obj = null; try { obj = f.get(null); } catch (IllegalAccessException e) { // ignore } if (obj == null) { return res; } Class classJarFileFactory = obj.getClass(); // HashMap fileCache = null; try { f = classJarFileFactory.getDeclaredField("fileCache"); f.setAccessible(true); obj = f.get(null); if (obj instanceof HashMap) { fileCache = (HashMap) obj; } } catch (NoSuchFieldException e) { e.printStackTrace(); } catch (IllegalAccessException e) { e.printStackTrace(); } HashMap urlCache = null; try { f = classJarFileFactory.getDeclaredField("urlCache"); f.setAccessible(true); obj = f.get(null); if (obj instanceof HashMap) { urlCache = (HashMap) obj; } } catch (NoSuchFieldException e) { e.printStackTrace(); } catch (IllegalAccessException e) { e.printStackTrace(); } if (urlCache != null) { HashMap urlCacheTmp = (HashMap) urlCache.clone(); Iterator it = urlCacheTmp.keySet().iterator(); while (it.hasNext()) { obj = it.next(); if (!(obj instanceof JarFile)) { continue; } JarFile jarFile = (JarFile) obj; if (setJarFileNames2Close.contains(jarFile.getName().trim().toUpperCase())) { try { jarFile.close(); } catch (IOException e) { e.printStackTrace(); } if (fileCache != null) { fileCache.remove(jarFile); } urlCache.remove(jarFile); } } res = true; } else if (fileCache != null) { // urlCache := null HashMap fileCacheTmp = (HashMap) fileCache.clone(); Iterator it = fileCacheTmp.keySet().iterator(); while (it.hasNext()) { Object key = it.next(); obj = fileCache.get(key); if (!(obj instanceof JarFile)) { continue; } JarFile jarFile = (JarFile) obj; try { jarFile.close(); } catch (IOException e) { // ignore } fileCache.remove(key); } res = true; } setJarFileNames2Close.clear(); return res; }
From source file:com.hangum.tadpole.rdb.core.editors.objects.table.TextViewerEditingSupport.java
@Override protected void setValue(Object element, Object value) { HashMap<Integer, String> data = (HashMap<Integer, String>) element; HashMap<Integer, String> oldDataMap = (HashMap<Integer, String>) data.clone(); String oldData = data.get(columnIndex) == null ? "" : data.get(columnIndex); if (logger.isDebugEnabled()) { logger.debug("original data :" + oldData + ":" + value.toString() + ":" + StringEscapeUtils.escapeXml(oldData)); }/*from w ww . java 2 s . c om*/ String compareValue = StringEscapeUtils.escapeXml(value.toString()); if (oldData.equals(compareValue)) return; // ? . String colType = tableDataTypeList.get(columnIndex - 1); if (!DataTypeValidate.isValid(editPart.getUserDB(), colType, value.toString())) { MessageDialog.openWarning(null, Messages.get().Warning, Messages.get().InputValue + " '" + value + "'. " + Messages.get().TextViewerEditingSupport_2 + " is " + colType + ".");// + " " + Messages.get().TextViewerEditingSupport_3); return; } // insert ? if (!TbUtils.isInsert(data.get(0))) { data.put(0, TbUtils.getColumnText(TbUtils.COLUMN_MOD_TYPE.UPDATE)); } // ? ?? data.put(columnIndex, TbUtils.getModifyData(value.toString())); editPart.setModifyButtonControl(); viewer.refresh(); }
From source file:org.duracloud.syncoptimize.config.SyncOptimizeConfigParserTest.java
private void removeArgFailTest(SyncOptimizeConfigParser retConfigParser, HashMap<String, String> argsMap, String arg, String failMsg) { HashMap<String, String> cloneMap = (HashMap<String, String>) argsMap.clone(); cloneMap.remove(arg);// ww w. j a v a 2 s .c o m try { retConfigParser.processOptions(mapToArray(cloneMap)); fail(failMsg); } catch (ParseException e) { assertNotNull(e); } }
From source file:org.duracloud.syncoptimize.config.SyncOptimizeConfigParserTest.java
private void addArgFailTest(SyncOptimizeConfigParser retConfigParser, HashMap<String, String> argsMap, String arg, String value, String failMsg) { HashMap<String, String> cloneMap = (HashMap<String, String>) argsMap.clone(); cloneMap.put(arg, value);// ww w . j a v a 2s. c om try { retConfigParser.processOptions(mapToArray(cloneMap)); fail(failMsg); } catch (ParseException e) { assertNotNull(e); } }
From source file:org.jboss.dashboard.ui.resources.ResourceGallery.java
public void setZipFile(byte[] zfile) throws Exception { boolean performReindexing = !"general".equals(getId()) && !"icons".equals(getId()) && this.getTmpZipFile() != null; if (!performReindexing) { super.setZipFile(zfile); } else {//from w ww. ja v a 2s .c o m Map resourcesBackup = new HashMap(); for (Iterator it = resources.keySet().iterator(); it.hasNext();) { String resourceName = (String) it.next(); HashMap resourceValue = (HashMap) resources.get(resourceName); resourcesBackup.put(resourceName, resourceValue.clone()); } super.setZipFile(zfile); } }