List of usage examples for java.util HashMap remove
public V remove(Object key)
From source file:com.fulcrum.mule.cluster.boot.ClusterExtension.java
private void disposeClusterSupport(String artifactName) { if (!initialized) { throw new MuleRuntimeException(new IllegalStateException("ClusterManager not initialized")); }//from w ww.j a va 2s. c o m HashMap<String, ClusterContext> clusterContexts = cluster.getClusterContexts(); synchronized (clusterContexts) { ClusterContext clusterContext = clusterContexts.remove(artifactName); if (clusterContext != null) { clusterContext.dispose(); } } }
From source file:fungus.FluctuationObserver.java
@SuppressWarnings("unchecked") public boolean execute() { if (CDState.getCycle() % period != 0) return false; updateStats();/* w w w .j av a2s.c o m*/ if (fluctuations.isEmpty()) return false; StringBuilder sb = new StringBuilder(); java.util.Formatter f = new java.util.Formatter(sb, Locale.US); Integer i = 0; HashMap<Integer, Integer> map = (HashMap<Integer, Integer>) fluctuations.clone(); while (!map.isEmpty()) { Integer val = map.remove(i); if (val == null) { f.format("%1d:%1d, ", i, 0); } else { f.format("%1d:%1d, ", i, val); } i++; } // ah: remove last commaspace and add a newline sb.delete(sb.length() - 2, sb.length()); sb.append("\n"); // ah: TODO: copy experiment writer to get this writing to // a file, too, so i can make a graph out of it. try { FileOutputStream out = new FileOutputStream(filename, true); PrintStream p = new PrintStream(out); p.print(sb.toString()); out.close(); } catch (IOException e) { log.severe("Error writing fluctuation data to file"); debug(e.getMessage()); } log.info("fluctuation counts " + sb.toString()); return false; }
From source file:test.googlecode.genericdao.BaseTest.java
protected void assertListEqual(Person[] expected, List<Person> actual) { Assert.assertEquals("The list did not have the expected length", expected.length, actual.size()); HashMap<Long, Object> unmatched = new HashMap<Long, Object>(); for (Person person : expected) { unmatched.put(person.getId(), ""); }//from www. jav a 2 s .c o m for (Person person : actual) { unmatched.remove(person.getId()); } if (unmatched.size() != 0) Assert.fail("The list did not match the expected results."); }
From source file:codetoanalyze.java.checkers.ContainerWrapper.java
void mapSubclassWriteBad(HashMap<String, String> m, String key) { m.remove(key); }
From source file:com.tongbanjie.tarzan.server.client.ClientManager.java
public void doChannelCloseEvent(final String remoteAddr, final Channel channel) { if (channel != null) { try {/*from ww w .j a v a 2s. c o m*/ if (this.groupChannelLock.tryLock(LOCK_TIMEOUT_MILLIS, TimeUnit.MILLISECONDS)) { try { for (final Entry<String, HashMap<Channel, ClientChannelInfo>> entry : this.groupChannelTable .entrySet()) { final String group = entry.getKey(); final HashMap<Channel, ClientChannelInfo> clientChannelInfoTable = entry.getValue(); final ClientChannelInfo clientChannelInfo = clientChannelInfoTable.remove(channel); if (clientChannelInfo != null) { LOGGER.info( "NETTY EVENT: remove channel[{}][{}] from ClientManager groupChannelTable, client group: {}", clientChannelInfo.toString(), remoteAddr, group); } } } finally { this.groupChannelLock.unlock(); } } else { LOGGER.warn("ClientManager doChannelCloseEvent lock timeout"); } } catch (InterruptedException e) { Thread.currentThread().interrupt(); LOGGER.error("", e); } } }
From source file:com.github.haixing_hu.bean.DefaultProperty.java
@Override public final Object removeMappedValue(final String key) { final HashMap<String, Object> map = getMappedValue(); return map.remove(key); }
From source file:com.wms.studio.cache.lock.SyncLockMapCache.java
@Override public V remove(K key) throws CacheException { // ??????/* w w w .j a va 2 s .c o m*/ try { lock.lock(); HashMap<K, V> attributes = memcachedClient.get(name); if (attributes == null) { return null; } V value = attributes.remove(key); memcachedClient.replace(name, 0, attributes); return value; } catch (Exception e) { log.fatal("MemCache,.", e); } finally { lock.unlock(); } return null; }
From source file:cr.ac.siua.tec.utils.impl.ProficiencyPDFGenerator.java
/** * Fills the PDF file (suficiencia.pdf) with the ticket values and returns base64 encoded string. *//*from ww w . j av a2 s .co m*/ @Override public String generate(HashMap<String, String> formValues) { String originalPdf = PDFGenerator.RESOURCES_PATH + "suficiencia.pdf"; try { PDDocument _pdfDocument = PDDocument.load(originalPdf); PDDocumentCatalog docCatalog = _pdfDocument.getDocumentCatalog(); PDAcroForm acroForm = docCatalog.getAcroForm(); formValues.remove("Queue"); //Iterates through all custom field values. for (Map.Entry<String, String> entry : formValues.entrySet()) { acroForm.getField(entry.getKey()).setValue(entry.getValue()); } return encodePDF(_pdfDocument); } catch (IOException e) { e.printStackTrace(); System.out.println("Excepcin al llenar el PDF."); return null; } }
From source file:org.duracloud.sync.config.SyncToolConfigParserTest.java
private void removeArgFailTest(HashMap<String, String> argsMap, String arg, String failMsg) { HashMap<String, String> cloneMap = (HashMap<String, String>) argsMap.clone(); cloneMap.remove(arg); try {//from w ww .ja v a2s . c o m syncConfigParser.processStandardOptions(mapToArray(cloneMap)); fail(failMsg); } catch (ParseException e) { assertNotNull(e); } }
From source file:org.apache.sysml.runtime.controlprogram.Program.java
public synchronized void removeFunctionProgramBlock(String namespace, String fname) { if (namespace == null) namespace = DMLProgram.DEFAULT_NAMESPACE; HashMap<String, FunctionProgramBlock> namespaceBlocks = null; if (_namespaceFunctions.containsKey(namespace)) { namespaceBlocks = _namespaceFunctions.get(namespace); if (namespaceBlocks.containsKey(fname)) namespaceBlocks.remove(fname); }//ww w . ja va 2 s. co m }