List of usage examples for java.util Map remove
V remove(Object key);
From source file:iudex.da.DataSourceFactory.java
public DataSource create(Map<String, String> params) { String className = params.remove("dsf.driver.class"); if (className != null) { try {/*from w w w . ja v a2 s . c o m*/ Class<?> driverClass = Class.forName(className); assert (driverClass != null); } catch (ClassNotFoundException x) { throw new RuntimeException(x); } } setLogWriter(); String uri = params.remove("dsf.uri"); Properties props = new Properties(); for (Map.Entry<String, String> e : params.entrySet()) { props.setProperty(e.getKey(), e.getValue()); } DriverManagerConnectionFactory conFactory = new DriverManagerConnectionFactory(uri, props); ObjectPool conPool = new GenericObjectPool(null); //min, max, etc. connections // Sets self on conPool new PoolableConnectionFactory(conFactory, conPool, null, //stmtPoolFactory null, false, true); return new PoolingDataSource(conPool); }
From source file:com.alibaba.cobar.manager.web.screen.MCobarListScreen.java
@SuppressWarnings({ "unchecked" }) @Override//from w w w.java 2 s . co m protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) throws Exception { UserDO user = (UserDO) request.getSession().getAttribute("user"); long clusterId = Long.parseLong(request.getParameter("clusterId")); ClusterDO cluster = xmlAccesser.getClusterDAO().getClusterById(clusterId); List<CobarDO> cobarList = xmlAccesser.getCobarDAO().getCobarList(clusterId); List<Map<String, Object>> cobarViewList = null; if (null != cobarList) { ListSortUtil.sortCobarByName(cobarList); cobarViewList = new ArrayList<Map<String, Object>>(); PropertyUtilsBean util = new PropertyUtilsBean(); for (CobarDO c : cobarList) { Map<String, Object> map = util.describe(c); map.remove("class"); map.remove("name"); map.put("name", CobarStringUtil.htmlEscapedString(c.getName())); cobarViewList.add(map); } } Map<String, Object> clusterView = new HashMap<String, Object>(); clusterView.put("id", cluster.getId()); clusterView.put("name", CobarStringUtil.htmlEscapedString(cluster.getName())); return new ModelAndView("m_cobarList", new FluenceHashMap<String, Object>().putKeyValue("cobarList", cobarViewList) .putKeyValue("user", user).putKeyValue("cluster", clusterView)); }
From source file:com.bstek.dorado.idesupport.parse.ClientEventParser.java
@Override protected Object doParse(Node node, ParseContext context) throws Exception { Element element = (Element) node; ClientEvent event = new ClientEvent(); Map<String, Object> properties = this.parseProperties(element, context); String clientTypesText = (String) properties.remove("clientTypes"); int clientTypes = ClientType.parseClientTypes(clientTypesText); if (clientTypes > 0) { event.setClientTypes(clientTypes); }/*from w w w. j a v a 2s. co m*/ BeanUtils.copyProperties(event, properties); return event; }
From source file:com.alibaba.cobar.manager.web.screen.EditClusterPage.java
@SuppressWarnings("unchecked") @Override/*www. ja v a 2s .co m*/ protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) throws Exception { long clusterId = 0; try { clusterId = Long.parseLong(request.getParameter("clusterId").trim()); } catch (Exception e) { throw new IllegalArgumentException( "parameter 'clusterId' is invalid:" + request.getParameter("clusterId")); } ClusterDO cluster = xmlAccesser.getClusterDAO().getClusterById(clusterId); Map<String, Object> clusterMap = new PropertyUtilsBean().describe(cluster); clusterMap.remove("class"); clusterMap.remove("name"); clusterMap.remove("deployDesc"); clusterMap.put("name", CobarStringUtil.htmlEscapedString(cluster.getName())); clusterMap.put("deployDesc", CobarStringUtil.htmlEscapedString(cluster.getDeployDesc())); return new ModelAndView("m_editCluster", new FluenceHashMap<String, Object>().putKeyValue("cluster", clusterMap)); }
From source file:com.pkrete.locationservice.admin.util.CustomJacksonMappingView.java
@SuppressWarnings("unchecked") @Override//from w w w .j a va 2 s. c o m protected Object filterModel(Map<String, Object> model) { Object result = super.filterModel(model); if (!(result instanceof Map)) { return result; } Map map = (Map) result; if (map.size() == 1) { if (map.get("data") == null) { map.remove("data"); return map; } return map.values().toArray()[0]; } return map; }
From source file:net.minecraftforge.registries.GameData.java
@SuppressWarnings({ "unchecked", "rawtypes" }) public static Multimap<ResourceLocation, ResourceLocation> injectSnapshot( Map<ResourceLocation, ForgeRegistry.Snapshot> snapshot, boolean injectFrozenData, boolean isLocalWorld) { FMLLog.log.info("Injecting existing registry data into this {} instance", FMLCommonHandler.instance().getEffectiveSide().isServer() ? "server" : "client"); RegistryManager.ACTIVE.registries.forEach((name, reg) -> reg.validateContent(name)); RegistryManager.ACTIVE.registries.forEach((name, reg) -> reg.dump(name)); RegistryManager.ACTIVE.registries.forEach((name, reg) -> reg.resetDelegates()); List<ResourceLocation> missingRegs = snapshot.keySet().stream() .filter(name -> !RegistryManager.ACTIVE.registries.containsKey(name)).collect(Collectors.toList()); if (missingRegs.size() > 0) { String text = "Forge Mod Loader detected missing/unknown registrie(s).\n\n" + "There are " + missingRegs.size() + " missing registries in this save.\n" + "If you continue the missing registries will get removed.\n" + "This may cause issues, it is advised that you create a world backup before continuing.\n\n" + "Missing Registries:\n"; for (ResourceLocation s : missingRegs) text += s.toString() + "\n"; if (!StartupQuery.confirm(text)) StartupQuery.abort();/*from www . j a v a2s .com*/ } RegistryManager STAGING = new RegistryManager("STAGING"); final Map<ResourceLocation, Map<ResourceLocation, Integer[]>> remaps = Maps.newHashMap(); final LinkedHashMap<ResourceLocation, Map<ResourceLocation, Integer>> missing = Maps.newLinkedHashMap(); // Load the snapshot into the "STAGING" registry snapshot.forEach((key, value) -> { final Class<? extends IForgeRegistryEntry> clazz = RegistryManager.ACTIVE.getSuperType(key); remaps.put(key, Maps.newLinkedHashMap()); missing.put(key, Maps.newHashMap()); loadPersistentDataToStagingRegistry(RegistryManager.ACTIVE, STAGING, remaps.get(key), missing.get(key), key, value, clazz); }); snapshot.forEach((key, value) -> { value.dummied.forEach(dummy -> { Map<ResourceLocation, Integer> m = missing.get(key); ForgeRegistry<?> reg = STAGING.getRegistry(key); // Currently missing locally, we just inject and carry on if (m.containsKey(dummy)) { if (reg.markDummy(dummy, m.get(dummy))) m.remove(dummy); } else if (isLocalWorld) { if (ForgeRegistry.DEBUG) FMLLog.log.debug("Registry {}: Resuscitating dummy entry {}", key, dummy); } else { // The server believes this is a dummy block identity, but we seem to have one locally. This is likely a conflict // in mod setup - Mark this entry as a dummy int id = reg.getID(dummy); FMLLog.log.warn( "Registry {}: The ID {} is currently locally mapped - it will be replaced with a dummy for this session", key, id); reg.markDummy(dummy, id); } }); }); int count = missing.values().stream().mapToInt(Map::size).sum(); if (count > 0) { FMLLog.log.debug("There are {} mappings missing - attempting a mod remap", count); Multimap<ResourceLocation, ResourceLocation> defaulted = ArrayListMultimap.create(); Multimap<ResourceLocation, ResourceLocation> failed = ArrayListMultimap.create(); missing.entrySet().stream().filter(e -> e.getValue().size() > 0).forEach(m -> { ResourceLocation name = m.getKey(); ForgeRegistry<?> reg = STAGING.getRegistry(name); RegistryEvent.MissingMappings<?> event = reg.getMissingEvent(name, m.getValue()); MinecraftForge.EVENT_BUS.post(event); List<MissingMappings.Mapping<?>> lst = event.getAllMappings().stream() .filter(e -> e.getAction() == MissingMappings.Action.DEFAULT).collect(Collectors.toList()); if (!lst.isEmpty()) { FMLLog.log.error("Unidentified mapping from registry {}", name); lst.forEach(map -> { FMLLog.log.error(" {}: {}", map.key, map.id); if (!isLocalWorld) defaulted.put(name, map.key); }); } event.getAllMappings().stream().filter(e -> e.getAction() == MissingMappings.Action.FAIL) .forEach(fail -> failed.put(name, fail.key)); final Class<? extends IForgeRegistryEntry> clazz = RegistryManager.ACTIVE.getSuperType(name); processMissing(clazz, name, STAGING, event, m.getValue(), remaps.get(name), defaulted.get(name), failed.get(name)); }); if (!defaulted.isEmpty() && !isLocalWorld) return defaulted; if (!defaulted.isEmpty()) { StringBuilder buf = new StringBuilder(); buf.append("Forge Mod Loader detected missing registry entries.\n\n").append("There are ") .append(defaulted.size()).append(" missing entries in this save.\n") .append("If you continue the missing entries will get removed.\n") .append("A world backup will be automatically created in your saves directory.\n\n"); defaulted.asMap().forEach((name, entries) -> { buf.append("Missing ").append(name).append(":\n"); entries.forEach(rl -> buf.append(" ").append(rl).append("\n")); }); boolean confirmed = StartupQuery.confirm(buf.toString()); if (!confirmed) StartupQuery.abort(); try { String skip = System.getProperty("fml.doNotBackup"); if (skip == null || !"true".equals(skip)) { ZipperUtil.backupWorld(); } else { for (int x = 0; x < 10; x++) FMLLog.log.error("!!!!!!!!!! UPDATING WORLD WITHOUT DOING BACKUP !!!!!!!!!!!!!!!!"); } } catch (IOException e) { StartupQuery.notify("The world backup couldn't be created.\n\n" + e); StartupQuery.abort(); } } if (!defaulted.isEmpty()) { if (isLocalWorld) FMLLog.log.error( "There are unidentified mappings in this world - we are going to attempt to process anyway"); } } if (injectFrozenData) { // If we're loading from disk, we can actually substitute air in the block map for anything that is otherwise "missing". This keeps the reference in the map, in case // the block comes back later missing.forEach((name, m) -> { ForgeRegistry<?> reg = STAGING.getRegistry(name); m.forEach((rl, id) -> reg.markDummy(rl, id)); }); // If we're loading up the world from disk, we want to add in the new data that might have been provisioned by mods // So we load it from the frozen persistent registry RegistryManager.ACTIVE.registries.forEach((name, reg) -> { final Class<? extends IForgeRegistryEntry> clazz = RegistryManager.ACTIVE.getSuperType(name); loadFrozenDataToStagingRegistry(STAGING, name, remaps.get(name), clazz); }); } // Validate that all the STAGING data is good STAGING.registries.forEach((name, reg) -> reg.validateContent(name)); // Load the STAGING registry into the ACTIVE registry for (Map.Entry<ResourceLocation, ForgeRegistry<? extends IForgeRegistryEntry<?>>> r : RegistryManager.ACTIVE.registries .entrySet()) { final Class<? extends IForgeRegistryEntry> registrySuperType = RegistryManager.ACTIVE .getSuperType(r.getKey()); loadRegistry(r.getKey(), STAGING, RegistryManager.ACTIVE, registrySuperType, true); } // Dump the active registry RegistryManager.ACTIVE.registries.forEach((name, reg) -> reg.dump(name)); // Tell mods that the ids have changed Loader.instance().fireRemapEvent(remaps, false); // The id map changed, ensure we apply object holders ObjectHolderRegistry.INSTANCE.applyObjectHolders(); // Return an empty list, because we're good return ArrayListMultimap.create(); }
From source file:org.arrow.runtime.scope.ProcessScope.java
/** * {@inheritDoc}//from www.ja v a 2s . c o m */ @Override public Object remove(String key) { Map<String, Object> map = EngineSynchronizationManager.getProcessScope(); return map.remove(key); }
From source file:org.cybercat.automation.core.WeakReferenceThreadScope.java
public Object remove(String name) { Map<String, WeakReference<Object>> scope = threadScope.get(); WeakReference<Object> wRef = scope.remove(name); if (wRef == null || wRef.get() == null) { return null; }/*from w w w. j a v a 2 s. co m*/ return wRef.get(); }
From source file:org.osiam.security.controller.AccessConfirmationController.java
@RequestMapping("/confirm_access") public ModelAndView getAccessConfirmation(Map<String, Object> model) { AuthorizationRequest clientAuth = (AuthorizationRequest) model.remove("authorizationRequest"); if (clientAuth == null) { return new ModelAndView("redirect:/oauth/error"); }// w ww . j a v a 2s.co m ClientDetails client = clientDetailsService.loadClientByClientId(clientAuth.getClientId()); // NOSONAR // Sonar message: clientDetailsService is initialized via setter injection if (client == null) { return new ModelAndView("redirect:/oauth/error"); } model.put("auth_request", clientAuth); model.put("client", client); model.put("loginError", false); return new ModelAndView("access_confirmation", model); }
From source file:com.playonlinux.core.config.CompatibleConfigFileFormat.java
@Override public synchronized void deleteValue(String key) throws IOException { final Map<String, String> values = this.getMap(); values.remove(key); mapper.writeValue(configFile, values); }