List of usage examples for java.util Map remove
V remove(Object key);
From source file:com.joliciel.talismane.other.Extensions.java
/** * To be called initially, so that any parameters specific to the extensions can be removed * and/or replaced in the argument map./* ww w .j a va 2 s . c om*/ * @param args */ public void pluckParameters(Map<String, String> args) { if (args.containsKey("referenceStats")) { referenceStatsPath = args.get("referenceStats"); args.remove("referenceStats"); } if (args.containsKey("corpusRules")) { corpusRulesPath = args.get("corpusRules"); args.remove("corpusRules"); } if (args.containsKey("command")) { try { command = ExtendedCommand.valueOf(args.get("command")); args.remove("command"); args.put("command", "process"); args.put("module", "parse"); } catch (IllegalArgumentException iae) { // do nothing } } }
From source file:org.vaadin.spring.internal.UIStore.java
private void cleanEmptyMaps(UIID uuid) { Map<String, Object> uiSpace = objectMap.get(uuid); if (uiSpace != null && uiSpace.isEmpty()) { objectMap.remove(uuid);/*from w w w.j av a2s . c o m*/ } Map<String, Runnable> destructionCallbacks = destructionCallbackMap.get(uuid); if (destructionCallbacks != null && destructionCallbacks.isEmpty()) { destructionCallbacks.remove(uuid); } }
From source file:com.discover.cls.processors.cls.AttributesToTypedJSON.java
/** * Remove all of the CoreAttributes from the Attributes that will be written to the Flowfile. * * @param atsToWrite List of Attributes that have already been generated including the CoreAttributes * @return Difference of all attributes minus the CoreAttributes *///from ww w. ja v a 2 s . co m private Map<String, String> removeCoreAttributes(Map<String, String> atsToWrite) { for (CoreAttributes c : CoreAttributes.values()) { atsToWrite.remove(c.key()); } return atsToWrite; }
From source file:edu.utsa.sifter.FileInfo.java
public Document generateSlackDoc(final AbstractParser tika, final Analyzer analyzer) throws IOException { if (!hasSlack()) { return null; }//from ww w . j a va 2 s . co m Data.reset(); Data.skip(FileSize); final Map<String, Object> slackMD = new HashMap<String, Object>(); slackMD.putAll(Metadata); final Object metaObj = slackMD.get("meta"); if (metaObj != null) { try { final Map<String, Object> meta = (Map<String, Object>) metaObj; meta.remove("size"); meta.put("size", new Long(SlackSize)); } catch (ClassCastException e) { } } final Object nameObj = slackMD.get("name"); if (nameObj != null) { try { final Map<String, Object> name = (Map<String, Object>) nameObj; final Object oldNameField = name.remove("name"); final StringBuilder newName = new StringBuilder(); if (oldNameField instanceof String) { newName.append((String) oldNameField); } newName.append(":slack"); name.put("name", newName.toString()); } catch (ClassCastException e) { } } // assert: Data must have been advanced beyond contents return makeDoc(tika, analyzer, ID + 1, Data, slackMD, null, true); }
From source file:com.jivesoftware.sdk.service.filter.JiveSignedFetchValidator.java
public void authenticate(ContainerRequestContext request) { String authorization = request.getHeaderString(HttpHeaders.AUTHORIZATION); if (!authorization.startsWith(JIVE_EXTN) || !authorization.contains(QUERY_PARAM_SIGNATURE)) { logger.log(Level.INFO, "Jive authorization isn't properly formatted: " + authorization); throw BAD_REQUEST; } // end if/*from w w w . j a v a 2s .c om*/ Map<String, String> paramMap = getParamsFromAuthz(authorization); String signature = paramMap.remove(PARAM_SIGNATURE); String algorithm = paramMap.get(PARAM_ALGORITHM); String clientId = paramMap.get(PARAM_CLIENT_ID); String jiveUrl = paramMap.get(PARAM_JIVE_URL); String tenantId = paramMap.get(PARAM_TENANT_ID); String timeStampStr = paramMap.get(PARAM_TIMESTAMP); if (!JiveSDKUtils.isAllExist(algorithm, clientId, jiveUrl, tenantId, timeStampStr)) { //TODO: LOG System.err.println("Jive authorization is partial: " + paramMap); throw BAD_REQUEST; } // end if long timeStamp = Long.parseLong(timeStampStr); long millisPassed = System.currentTimeMillis() - timeStamp; if (millisPassed < 0 || millisPassed > TimeUnit.MINUTES.toMillis(5)) { //TODO: LOG System.err.println("Jive authorization is rejected since it's " + millisPassed + "ms old (max. allowed is 5 minutes): " + paramMap); throw UNAUTHORIZED; } // end if //JiveInstance jiveInstance = jiveInstanceProvider.getInstanceByTenantId(tenantId); JiveInstance jiveInstance = jiveAddOnApplication.getJiveInstanceProvider().getInstanceByTenantId(tenantId); if (jiveInstance == null) { //TODO: LOG System.err.println("Jive authorization failed due to invalid tenant ID: " + tenantId); throw UNAUTHORIZED; } // end if String expectedClientId = jiveInstance.getClientId(); if (!clientId.equals(expectedClientId)) { String msg = String.format( "Jive authorization failed due to missing Client ID: Actual [%s], Expected [%s]", clientId, expectedClientId); //TODO: LOG System.err.println(msg); throw UNAUTHORIZED; } // end if String clientSecret = jiveInstance.getClientSecret(); String paramStrWithoutSignature = authorization.substring(JIVE_EXTN.length(), authorization.indexOf(QUERY_PARAM_SIGNATURE)); try { String expectedSignature = sign(paramStrWithoutSignature, clientSecret, algorithm); if (expectedSignature.equals(signature)) { //SAVING jiveInstance INSTANCE TO REQUEST //TODO: request.setProperty(JIVE_INSTANCE, jiveInstance); } else { //TODO: LOG System.err.println( "Jive authorization failed due to tampered signature! Original authz: " + authorization); throw UNAUTHORIZED; } // end if } catch (Exception e) { //TODO: LOG System.err.println("Failed validating Jive auth. scheme" + e.getMessage()); throw UNAUTHORIZED; } // end try/catch }
From source file:ch.rasc.wampspring.session.WebSocketRegistryListener.java
private void afterWsConnectionClosed(WebSocketSession wsSession) { String httpSessionId = (String) wsSession.getAttributes().get(SessionSupport.SPRING_SESSION_ID_ATTR_NAME); if (httpSessionId == null) { return;/*from ww w . j av a 2 s . c o m*/ } Map<String, WebSocketSession> sessions = this.httpSessionIdToWsSessions.get(httpSessionId); if (sessions != null) { String wsSessionId = wsSession.getId(); boolean result = sessions.remove(wsSessionId) != null; if (logger.isDebugEnabled()) { logger.debug("Removal of " + wsSessionId + " was " + result); } if (sessions.isEmpty()) { this.httpSessionIdToWsSessions.remove(httpSessionId); if (logger.isDebugEnabled()) { logger.debug("Removed the corresponding HTTP Session for " + wsSessionId + " since it contained no WebSocket mappings"); } } } }
From source file:jfs.sync.meta.AbstractMetaStorageAccess.java
@Override public void flush(String rootPath, FileInfo info) { String[] pathAndName = new String[2]; pathAndName[0] = info.getPath();// w w w . ja v a2 s. c o m pathAndName[1] = info.getName(); Map<String, FileInfo> listing = getParentListing(rootPath, pathAndName); if (listing.containsKey(info.getName())) { listing.remove(info.getName()); } // if listing.put(info.getName(), info); if (LOG.isInfoEnabled()) { LOG.info("flush() flushing " + pathAndName[0] + "/" + pathAndName[1]); } // if flushMetaData(rootPath, pathAndName, listing); }
From source file:com.jostrobin.battleships.view.frames.GameFrame.java
public void initializeFields(int length, int width, SortedMap<Long, String> participants) { this.width = width; this.length = length; this.participants = participants; // first entry is the current player playerId = participants.firstKey();// w w w . j a v a2s . c o m // remove it from the map Map<Long, String> opponents = new HashMap<Long, String>(participants); opponents.remove(playerId); gamePanel.initUi(length, width, opponents); initializeFieldSize(length, width); }
From source file:org.jresponder.util.PropUtil.java
/** * Merge from the aFromMap to the aIntoMap (dst <- src) (assembly style). * Null value in from map causes corresponding entry in dst map to be * removed.//from w w w. ja v a2 s . c o m * @param aIntoMap * @param aFromMap * @return Map returns aIntoMap - in case it helps you chain calls together easier */ public Map<String, Object> propMerge(Map<String, Object> aIntoMap, Map<String, Object> aFromMap) { for (String myKey : aFromMap.keySet()) { Object myValue = aFromMap.get(myKey); if (myValue == null) { aIntoMap.remove(myKey); } else { aIntoMap.put(myKey, myValue); } } return aIntoMap; }
From source file:com.datos.vfs.cache.LRUFilesCache.java
@Override public void removeFile(final FileSystem filesystem, final FileName name) { final Map<?, ?> files = getOrCreateFilesystemCache(filesystem); writeLock.lock();/*from w w w .jav a 2 s . c om*/ try { files.remove(name); if (files.size() < 1) { filesystemCache.remove(filesystem); } } finally { writeLock.unlock(); } }