Example usage for java.util Map remove

List of usage examples for java.util Map remove

Introduction

In this page you can find the example usage for java.util Map remove.

Prototype

V remove(Object key);

Source Link

Document

Removes the mapping for a key from this map if it is present (optional operation).

Usage

From source file:net.datacrow.onlinesearch.amazon.SignedRequestsHelper.java

public synchronized String sign(URL url) {
    String server = url.getHost();
    String query = url.getQuery();

    Map<String, String> params = createParameterMap(query);

    // remove old signature information
    params.remove("AWSAccessKeyId");
    params.remove("Timestamp");
    params.remove("Signature");

    return sign(server, params);
}

From source file:com.solace.labs.spring.cloud.cloudfoundry.SolaceMessagingServiceInfoCreatorTest.java

@Test
public void missingKeyValueTest() {
    // Should simply result in those values still being null.
    Map<String, Object> exVcapServices = createVcapMap();

    @SuppressWarnings("unchecked")
    Map<String, Object> exCred = (Map<String, Object>) exVcapServices.get("credentials");
    exCred.remove("smfHosts");

    SolaceMessagingInfoCreator smic = new SolaceMessagingInfoCreator();

    // Should still accept it.
    assertTrue(smic.accept(exVcapServices));

    SolaceMessagingInfo smi = smic.createServiceInfo(exVcapServices);

    // Validate smf is null. Others are not
    assertNull(smi.getSmfHost());/*  www.  ja  va 2s . c o m*/
    assertEquals("tcps://192.168.1.50:7003,tcps://192.168.1.51:7003", smi.getSmfTlsHost());
}

From source file:com.ge.apm.service.wechat.WorkOrderWeChatService.java

@Transactional
public String finishWo(HttpServletRequest request, Map map) throws Exception {
    WorkOrder workOrder = woDetail(Integer.parseInt((String) map.get("id")));
    String type = (String) map.remove("type");
    String serverId = (String) map.remove("closeReason");
    String comments = (String) map.remove("comments");
    Object stepDetails = map.remove("stepDetails");
    String assetStatus = "" + map.remove("assetStatus");
    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    Date conDownTime = sdf.parse(map.remove("confirmedDownTime") + "");
    Date conUpTime = sdf.parse(map.remove("confirmedUpTime") + "");
    workOrder.setConfirmedDownTime(conDownTime);
    workOrder.setConfirmedUpTime(conUpTime);

    BeanUtils.populate(workOrder, map);/*w  w w . ja va 2  s.c om*/
    List<WorkOrderStep> currentWoSteps = woStepDao.getByWorkOrderIdAndStepId(workOrder.getId(),
            workOrder.getCurrentStepId());
    if (currentWoSteps == null || currentWoSteps.isEmpty())
        return "error";
    WorkOrderStep currentWoStep = currentWoSteps.get(0);
    currentWoStep.setDescription(comments);

    JSONArray array = JSONArray.fromObject(stepDetails);
    List<WorkOrderStepDetail> list = JSONArray.toList(array, new WorkOrderStepDetail(), new JsonConfig());
    for (WorkOrderStepDetail sd : list) {
        sd.setWorkOrderStepId(currentWoStep.getId());
        currentWoStep.addStepDetail(sd);
    }

    if (null != type)
        switch (type) {
        case "save":
            woService.finishWorkOrderStep(workOrder, currentWoStep);
            break;
        case "transfer":
            woService.transferWorkOrder(workOrder, currentWoStep);
            break;
        default:
            woService.closeWorkOrder(workOrder, currentWoStep);
            break;
        }

    //change asset status
    AssetInfo ai = assetDao.findById(workOrder.getAssetId());
    ai.setStatus(Integer.parseInt(assetStatus));
    assetDao.save(ai);

    //?????
    if (serverId != null && !"".equals(serverId))
        upload(currentWoStep, serverId);
    return "success";
}

From source file:com.mgmtp.jfunk.data.source.BaseDataSource.java

/**
 * Resets (= removes) a specific fixed value from the specified {@link DataSet}.
 * /*from   w  ww  .j a  v a  2  s. c om*/
 * @param dataSetKey
 *            The {@link DataSet} key.
 * @param entryKey
 *            The entry key.
 */
@Override
public void resetFixedValue(final String dataSetKey, final String entryKey) {
    Map<String, String> map = fixedValues.get(dataSetKey);
    if (map != null) {
        if (map.remove(entryKey) == null) {
            log.warn("Entry " + dataSetKey + "." + entryKey + " could not be found in map of fixed values");
        }
        if (map.isEmpty()) {
            fixedValues.remove(dataSetKey);
        }
    }
    DataSet dataSet = getCurrentDataSets().get(dataSetKey);
    if (dataSet != null) {
        dataSet.resetFixedValue(entryKey);
    }
}

From source file:org.trustedanalytics.servicebroker.hdfs.plans.HdfsPlanGetUserDirectory.java

@Override
public Map<String, Object> bind(ServiceInstance serviceInstance) throws ServiceBrokerException {
    UUID instanceId = UUID.fromString(serviceInstance.getServiceInstanceId());
    UUID orgId = UUID.fromString(serviceInstance.getOrganizationGuid());
    Map<String, Object> configurationMap = bindingOperations.createCredentialsMap(instanceId, orgId);
    Map<String, Object> storedCredentials = credentialsStore.get(instanceId);

    if (getParameterUri(storedCredentials, URI_KEY).isPresent()) {
        configurationMap.remove(URI_KEY);
    }/*from   www.  jav  a2  s  .c o m*/

    Map<String, Object> credentials = new HashMap<>();
    credentials.putAll(configurationMap);
    credentials.putAll(storedCredentials);
    return credentials;
}

From source file:org.apache.geode.geospatial.index.BasicQuadTreeImpl.java

@Override
public void remove(Object key) {
    if (key != null) {
        writeLock.lock();//w  ww.j a v a  2s . c  om
        try {
            Map<Object, Geometry> container = quickRemove.remove(key);
            if (container != null) {
                container.remove(key);
            }
        } finally {
            writeLock.unlock();
        }
    }
}

From source file:jp.go.nict.langrid.testresource.loader.NodeLoader_1_2.java

/**
 * ?//from   ww  w . ja  va  2  s .  c o  m
 * @param resource ?
 * @return 
 * @throws IOException ???
 */
protected Attribute[] loadAttributes(Nodes_1_2 resource, Class<Attribute> clazz) throws IOException {
    Map<String, String> props = new PropertyFileReader(CharsetUtil.newUTF8Decoder())
            .read(resource.loadProperties());
    for (String name : getProfileProperties()) {
        props.remove(name);
    }
    for (String name : getProfileTupleProperties()) {
        props.remove(name);
    }
    props.remove("nodeId");
    List<Attribute> attrs = new ArrayList<Attribute>();
    try {
        for (Map.Entry<String, String> entry : props.entrySet()) {
            attrs.add(clazz.getConstructor(String.class, String.class).newInstance(entry.getKey(),
                    entry.getValue()));
        }
    } catch (IllegalAccessException e) {
        throw new RuntimeException(e);
    } catch (InstantiationException e) {
        throw new RuntimeException(e);
    } catch (InvocationTargetException e) {
        throw new RuntimeException(e);
    } catch (NoSuchMethodException e) {
        throw new RuntimeException(e);
    }
    return attrs.toArray((Attribute[]) Array.newInstance(clazz, 0));
}

From source file:com.nabla.project.application.core.spring.ExtractionScope.java

/**
 * DOCUMENT ME!//from  w w w.  j  ava 2  s  .co  m
 * 
 * @param beanName DOCUMENT ME!
 * @return DOCUMENT ME!
 */
public Object remove(String beanName) {

    RequestId requestId = (RequestId) extractionId.get();

    if (logger.isDebugEnabled()) {
        logger.debug("remove(" + beanName + ") extractionId=" + requestId);
    }

    Object bean = null;

    Map<String, Object> beansMap = scopeMaps.get(requestId);

    if (beansMap != null) {

        beansMap.remove(beanName);

    }

    try {

        ObjectName name = new ObjectName(getJmxObjectName(beanName, requestId));

        mbs.unregisterMBean(name);

        if (logger.isDebugEnabled()) {
            logger.debug("JMX registration done for " + name);
        }

    } catch (Exception ex) {

        logger.warn(ex);

    }

    return bean;

}

From source file:com.yahoo.glimmer.indexing.generator.Index.java

public void open() throws IOException {
    String basename = new Path(outputDir, name).toString();

    Path termsPath = new Path(outputDir, name + DiskBasedIndex.TERMS_EXTENSION);
    terms = new PrintWriter(new BufferedWriter(new OutputStreamWriter(fs.create(termsPath, false), "UTF-8")));

    Path propertiesPath = new Path(outputDir, name + DiskBasedIndex.PROPERTIES_EXTENSION);
    properties = fs.create(propertiesPath, false);

    Map<Component, Coding> defaultStandardIndexFlags = new Object2ObjectOpenHashMap<Component, Coding>(
            CompressionFlags.DEFAULT_STANDARD_INDEX);
    if (!positions) {
        defaultStandardIndexFlags.remove(CompressionFlags.Component.POSITIONS);
        defaultStandardIndexFlags.remove(CompressionFlags.Component.COUNTS); // Quasi Succinct Indexes can't not have counts.
    }//w ww.  j a v  a 2s . co m

    IOFactory ioFactory = new HadoopFileSystemIOFactory(fs);
    //   indexWriter = new QuasiSuccinctIndexWriter(ioFactory, basename, numDocs, Fast.mostSignificantBit(QuasiSuccinctIndex.DEFAULT_QUANTUM), indexWriterCacheSize, defaultStandardIndexFlags, ByteOrder.nativeOrder());
    indexWriter = new BitStreamIndexWriter(ioFactory, basename, numDocs, true, defaultStandardIndexFlags);
}

From source file:com.moai.app.prox.resources.ProxResource.java

private <K, V> void removeMapEntriesUsingList(final Map<K, V> pMap, final List<K> pList) {
    for (K key : pList) {
        if (pMap.containsKey(key)) {
            pMap.remove(key);
        }/*from  w  w  w .ja v a 2  s  . co  m*/
    }
}