List of usage examples for java.util Map remove
V remove(Object key);
From source file:net.sourceforge.vulcan.cvs.CvsPlugin.java
public void projectNameChanged(String oldName, String newName) { final Map<String, Long> counters = globalConfig.getWorkingCopyByteCounts(); synchronized (counters) { if (counters.containsKey(oldName)) { counters.put(newName, counters.remove(oldName)); }/* ww w .ja v a 2 s .c om*/ } }
From source file:com.fatwire.dta.sscrawler.util.SSUriHelper.java
public String toLink(final QueryString uri) { if (!uri.isOK()) { return null; }//from ww w .java 2 s. c o m try { final Map<String, String> map = new TreeMap<String, String>(uri.getParameters()); map.remove(HelperStrings.CACHECONTROL); map.remove(HelperStrings.RENDERMODE); final StringBuilder qs = new StringBuilder(); qs.append(path); // qs.append("ContentServer"); qs.append("?"); for (final Iterator<Map.Entry<String, String>> i = map.entrySet().iterator(); i.hasNext();) { final Map.Entry<String, String> entry = i.next(); if (log.isTraceEnabled()) log.trace(entry.toString()); qs.append(encode(entry.getKey())); qs.append("="); final String v = entry.getValue(); if (v != null && v.startsWith(HelperStrings.SSURI_START)) { final Link inner = createLink(v); qs.append(encode(toLink(inner))); } else if (v != null) { qs.append(encode(v)); } if (i.hasNext()) { qs.append("&"); } } return qs.toString(); } catch (final EncoderException e) { log.warn(e); return null; } catch (final RuntimeException e) { log.warn(e); return null; } }
From source file:com.xwtec.xwserver.util.json.util.JSONUtils.java
/** * Creates a new MorphDynaBean from a JSONObject. The MorphDynaBean will have * all the properties of the original JSONObject with the most accurate type. * Values of properties are not copied.// w ww . j av a 2 s. com */ public static DynaBean newDynaBean(JSONObject jsonObject, JsonConfig jsonConfig) { Map props = getProperties(jsonObject); for (Iterator entries = props.entrySet().iterator(); entries.hasNext();) { Map.Entry entry = (Map.Entry) entries.next(); String key = (String) entry.getKey(); if (!JSONUtils.isJavaIdentifier(key)) { String parsedKey = JSONUtils.convertToJavaIdentifier(key, jsonConfig); if (parsedKey.compareTo(key) != 0) { props.put(parsedKey, props.remove(key)); } } } MorphDynaClass dynaClass = new MorphDynaClass(props); MorphDynaBean dynaBean = null; try { dynaBean = (MorphDynaBean) dynaClass.newInstance(); dynaBean.setDynaBeanClass(dynaClass); } catch (Exception e) { throw new JSONException(e); } return dynaBean; }
From source file:org.carewebframework.api.property.mock.MockPropertyService.java
@Override public void saveValue(String propertyName, String instanceName, boolean asGlobal, String value) { Map<String, String> map = asGlobal ? global_map : local_map; String key = getKey(propertyName, instanceName); if (value == null) { map.remove(key); } else {//from w ww. java2 s. c om map.put(key, value); } }
From source file:net.sourceforge.vulcan.subversion.SubversionPlugin.java
public void projectNameChanged(String oldName, String newName) { final Map<String, Long> counters = config.getWorkingCopyByteCounts(); synchronized (counters) { if (counters.containsKey(oldName)) { counters.put(newName, counters.remove(oldName)); }//from ww w. j a v a 2s. c o m } }
From source file:de.otto.jsonhome.registry.controller.RegistriesControllerTest.java
@Test public void shouldCreateANewRegistryAndAddMissingAttributes() { // given://from ww w .ja v a2s .c om final Map<String, Object> registry = registryLiveWithSingleLinkTo("foo"); registry.remove("self"); registry.remove("container"); registry.remove("name"); // when: final MockHttpServletResponse response = new MockHttpServletResponse(); registriesController.putRegistry("live", registry, response); // then: assertEquals(response.getStatus(), SC_CREATED); assertEquals(registriesController.getRegistry("live", new MockHttpServletResponse()), registryLiveWithSingleLinkTo("foo")); }
From source file:be.neutrinet.ispng.mail.Renderer.java
public String renderInTemplate(String segmentName, Map<String, String> content, boolean plaintext) { fillInDefaults(content);/*from w w w . ja v a 2 s . c om*/ String rseg = render(segmentName, content, plaintext); HashMap<String, String> ct = new HashMap<>(); content.remove("body"); ct.putAll(content); ct.put("body", rseg); return render(BASE_TEMPLATE, ct, plaintext); }
From source file:com.facebook.presto.accumulo.iterators.AbstractBooleanFilter.java
@Override public void init(SortedKeyValueIterator<Key, Value> source, Map<String, String> options, IteratorEnvironment env) throws IOException { super.init(source, options, env); for (Entry<String, String> e : options.entrySet()) { try {/*from w w w . j a v a 2 s . c o m*/ Map<String, String> props = OBJECT_MAPPER.readValue(e.getValue(), new TypeReference<Map<String, String>>() { }); String clazz = props.remove(FILTER_JAVA_CLASS_NAME); RowFilter f = (RowFilter) Class.forName(clazz).newInstance(); f.init(this, props, env); filters.add(f); LOG.info("%s: Added Filter %s", super.toString(), f); } catch (Exception ex) { throw new IllegalArgumentException( "Failed to deserialize Filter information from JSON value " + e.getValue(), ex); } } }
From source file:org.openmhealth.reference.request.SchemaRequest.java
@Override public void service() throws OmhException { // First, short-circuit if this request has already been serviced. if (isServiced()) { return;/*from ww w . j av a2 s . c o m*/ } else { setServiced(); } // Get the schema. Schema schema = Registry.getInstance().getSchema(schemaId, schemaVersion); // Make sure the schema exists. if (schema == null) { throw new NoSuchSchemaException( "The schema with id '" + schemaId + "' and version '" + schemaVersion + "' does not exist."); } // Convert the result to a map. ObjectMapper mapper = new ObjectMapper(); // We need to suppress Java's type erasure. :( @SuppressWarnings("unchecked") Map<String, Object> metaData = mapper.convertValue(schema, Map.class); // Remove the schema from the meta-data. metaData.remove(Schema.JSON_KEY_SCHEMA); // Save the meta-data. setMetaData(metaData); // Set the schema itself as the data. setData(schema.getSchema()); }
From source file:com.redhat.rhn.common.util.manifestfactory.ManifestFactory.java
/** helper function for when Digesting an xml file. sadly, must * be public or Digester freaks out, otherwise it would be private. * @param m used by Digester to build template *//*from w ww . j a v a2 s . c o m*/ public void addFactoryTemplate(Map m) { String name = (String) m.get("name"); if (name == null) { throw new NullPointerException("factory/template must have name attribute"); } m.remove("name"); objects.put(name, builder.createObject(m)); }