List of usage examples for java.util Map clear
void clear();
From source file:org.grails.datastore.mapping.core.AbstractSession.java
private void clearMaps(Map<Class, Map<Serializable, Object>> mapOfMaps) { for (Map<Serializable, Object> cache : mapOfMaps.values()) { cache.clear(); }//from w ww . j ava 2s .c o m }
From source file:com.esd.ps.ManagerController.java
/** * ?/*from w w w .j av a 2 s .c o m*/ * * @param userId * @param request * @return */ @RequestMapping(value = "/workerDetail", method = RequestMethod.GET) public ModelAndView workerDetailGET(int userId, HttpServletRequest request) { Map<String, Object> model = new HashMap<>(); try { String username = new String(request.getParameter("username").getBytes("iso-8859-1"), "utf-8"); model.clear(); model.put(Constants.USER_ID, userId); model.put(Constants.CHOOSEUSERNAME, username); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } return new ModelAndView("manager/workerDetail", Constants.MODEL, model); }
From source file:com.lillicoder.newsblurry.net.PreferenceCookieStore.java
@Override public void clear() { Map<String, Cookie> cache = this.getCookieCache(); // Clear saved cookies fist, then empty in-memory cache. SharedPreferences.Editor editor = this.getPreferences().edit(); for (Cookie cookie : cache.values()) { String cookieId = this.getCookiePreferenceEntryId(cookie); editor.remove(cookieId);/*from w w w . j av a2 s .com*/ } editor.remove(PREFERENCE_COOKIE_IDS); editor.commit(); // Clear cache. cache.clear(); }
From source file:chaitanya.im.searchforreddit.LauncherActivity.java
private Map<String, String> getFinalQuery(String q) { Map<String, String> finalQuery = new HashMap<>(); finalQuery.clear(); finalQuery.put("t", timeValue); finalQuery.put("sort", sortValue); finalQuery.put("q", q); return finalQuery; }
From source file:org.apache.camel.component.olingo2.api.Olingo2AppIntegrationTest.java
@Test public void testReadUpdateProperties() throws Exception { // test simple property Manufacturer.Founded final TestOlingo2ResponseHandler<Map<String, Object>> propertyHandler = new TestOlingo2ResponseHandler<Map<String, Object>>(); olingoApp.read(edm, TEST_MANUFACTURER_FOUNDED_PROPERTY, null, propertyHandler); Calendar founded = (Calendar) propertyHandler.await().get(FOUNDED_PROPERTY); LOG.info("Founded property {}", founded.toString()); final TestOlingo2ResponseHandler<Calendar> valueHandler = new TestOlingo2ResponseHandler<Calendar>(); olingoApp.read(edm, TEST_MANUFACTURER_FOUNDED_VALUE, null, valueHandler); founded = valueHandler.await();/*from w w w . jav a 2 s .c o m*/ LOG.info("Founded property {}", founded.toString()); final TestOlingo2ResponseHandler<HttpStatusCodes> statusHandler = new TestOlingo2ResponseHandler<HttpStatusCodes>(); final HashMap<String, Object> properties = new HashMap<String, Object>(); properties.put(FOUNDED_PROPERTY, new Date()); // olingoApp.update(edm, TEST_MANUFACTURER_FOUNDED_PROPERTY, properties, statusHandler); // requires a plain Date for XML olingoApp.update(edm, TEST_MANUFACTURER_FOUNDED_PROPERTY, new Date(), statusHandler); LOG.info("Founded property updated with status {}", statusHandler.await().getStatusCode()); statusHandler.reset(); olingoApp.update(edm, TEST_MANUFACTURER_FOUNDED_VALUE, new Date(), statusHandler); LOG.info("Founded property updated with status {}", statusHandler.await().getStatusCode()); // test complex property Manufacturer.Address propertyHandler.reset(); olingoApp.read(edm, TEST_MANUFACTURER_ADDRESS_PROPERTY, null, propertyHandler); final Map<String, Object> address = propertyHandler.await(); LOG.info("Address property {}", prettyPrint(address, 0)); statusHandler.reset(); address.clear(); // Olingo2 sample server MERGE/PATCH behaves like PUT!!! // address.put("Street", "Main Street"); address.put("Street", "Star Street 137"); address.put("City", "Stuttgart"); address.put("ZipCode", "70173"); address.put("Country", "Germany"); // olingoApp.patch(edm, TEST_MANUFACTURER_ADDRESS_PROPERTY, address, statusHandler); olingoApp.merge(edm, TEST_MANUFACTURER_ADDRESS_PROPERTY, address, statusHandler); LOG.info("Address property updated with status {}", statusHandler.await().getStatusCode()); }
From source file:org.xmlactions.action.config.ExecContext.java
/** * @deprecated - use spring bean scope="session" or "request" *//*w w w. j av a2 s. c o m*/ public void copyTo(IExecContext dest) { dest.setApplicationContext(getApplicationContext()); // dest.setRootMap(getRootMap()); // why copy the root map dest.setActionMaps(getActionMaps()); Map<String, Object> map = dest.getActionMaps().get("request"); if (map != null) { map.clear(); } map = dest.getActionMaps().get(PERSISTENCE_MAP); if (map != null) { map.clear(); } dest.setNamedMaps(getNamedMaps()); Map<String, Map<String, Object>> maps = dest.getNamedMaps(); for (String key : maps.keySet()) { if (log.isDebugEnabled()) { log.debug("namedMaps key:" + key); } } Set<Entry<String, Object>> set = entrySet(); Iterator<Entry<String, Object>> iterator = set.iterator(); while (iterator.hasNext()) { Entry<String, Object> entry = iterator.next(); dest.put(entry.getKey(), entry.getValue()); if (log.isDebugEnabled()) { log.debug("key:" + entry.getKey()); } } set = rootMap.entrySet(); iterator = set.iterator(); while (iterator.hasNext()) { Entry<String, Object> entry = iterator.next(); dest.put(entry.getKey(), entry.getValue()); if (log.isDebugEnabled()) { log.debug("key:" + entry.getKey()); } } }
From source file:com.mgmtp.jfunk.common.util.Configuration.java
/** * If properties are present which start with {@link JFunkConstants#SYSTEM_PROPERTIES} the * corresponding values are taken as property files and loaded here. *///from www . j a v a 2 s . com private void loadExtraFiles(final String filterPrefix, final boolean preserveExisting) { Map<String, String> view = Maps.filterKeys(this, Predicates.startsWith(filterPrefix)); while (true) { if (view.isEmpty()) { break; } Queue<String> fileKeys = Queues.newArrayDeque(view.values()); // we need to keep them separately in order to be able to reload them (see put method) extraFileProperties.addAll(fileKeys); // Remove original keys in order to prevent a stack overflow view.clear(); for (String fileNameKey = null; (fileNameKey = fileKeys.poll()) != null;) { // Recursion String fileName = processPropertyValue(fileNameKey); if (PLACEHOLDER_PATTERN.matcher(fileName).find()) { // not all placeholders were resolved, so we enqueue it again to process another file first fileKeys.offer(fileName); } else { load(fileName, preserveExisting); } } } }
From source file:com.marsspiders.ukwa.controllers.CollectionController.java
private Map<String, String> buildCollectionBreadcrumbPath(CollectionDTO currentCollectionDto) { Map<String, String> path = new LinkedHashMap<>(); path.put(currentCollectionDto.getId(), currentCollectionDto.getName()); String parentCollectionId = currentCollectionDto.getParentId(); while (parentCollectionId != null) { CollectionInfo parentCollection = searchService.fetchCollectionById(parentCollectionId) .getResponseBody().getDocuments().get(0); //Create a new map to get reversed map in result Map<String, String> oldPath = new LinkedHashMap<>(path); path.clear();/*from www . j av a 2s .co m*/ path.put(parentCollection.getId(), parentCollection.getName()); path.putAll(oldPath); parentCollectionId = parentCollection.getParentId(); } return path; }
From source file:com.taobao.tddl.jdbc.group.config.ConfigManager.java
/** * AtomDataSourceDBSelector ---add by/*from w w w .j a v a 2 s. c om*/ * mazhidan.pt * * @param dswList */ private void resetByDataSourceWrapper(List<DataSourceWrapper> dswList) { // DataSourceWrapper Map<String, DataSourceWrapper> newDataSourceWrapperMap = new HashMap<String, DataSourceWrapper>( dswList.size()); for (DataSourceWrapper dsw : dswList) { newDataSourceWrapperMap.put(dsw.getDataSourceKey(), dsw); } Map<String, DataSourceWrapper> old = this.dataSourceWrapperMap; this.dataSourceWrapperMap = newDataSourceWrapperMap; old.clear(); old = null; DBSelector r_DBSelector = null; DBSelector w_DBSelector = null; // dbOneDBSelector if (dswList.size() == 1) { DataSourceWrapper dsw2 = dswList.get(0); r_DBSelector = new OneDBSelector(dsw2); r_DBSelector.setDbType(dsw2.getDBType()); w_DBSelector = r_DBSelector; } else { // Map Map<Integer/* */, List<DataSourceWrapper>/* keyDS */> rPriority2DswList = new HashMap<Integer, List<DataSourceWrapper>>(); Map<Integer, List<DataSourceWrapper>> wPriority2DswList = new HashMap<Integer, List<DataSourceWrapper>>(); for (DataSourceWrapper dsw1 : dswList) { add2LinkedListMap(rPriority2DswList, dsw1.getWeight().p, dsw1); add2LinkedListMap(wPriority2DswList, dsw1.getWeight().q, dsw1); } r_DBSelector = createDBSelector(rPriority2DswList, true); w_DBSelector = createDBSelector(wPriority2DswList, false); } r_DBSelector.setReadable(true); w_DBSelector.setReadable(false); this.readDBSelectorWrapper = r_DBSelector; this.writeDBSelectorWrapper = w_DBSelector; if (tGroupDataSource.getAutoSelectWriteDataSource()) runtimeWritableAtomDBSelectorWrapper = new RuntimeWritableAtomDBSelector(dataSourceWrapperMap, groupExtraConfig); // System.out.println("dataSourceWrapperMap=" + dataSourceWrapperMap); if (this.dataSourceChangeListener != null) { dataSourceChangeListener.onDataSourceChanged(null);// getDataSource() } }
From source file:com.alibaba.wasp.client.TestFromClientSide.java
@Test // (expected = PrimaryKeyAlreadyExistsException.class) public void testInsertWithSomePK() throws IOException { Map<String, String> sqlGroup = new HashMap<String, String>(); sqlGroup.put(INSERT, "Insert into " + TABLE_NAME + " (column1,column2,column3) values (7,234,'abc');"); sqlGroup.put(SELECT_FOR_INSERT, "select column1,column2,column3,column4,column5 from " + TABLE_NAME + " where column1=7 and column3='abc';"); testSqlGroupExecute(sqlGroup);//from w w w. ja va2 s . c o m sqlGroup.clear(); String insert = "Insert into " + TABLE_NAME + " (column1,column2,column3) values (7,234,'def');"; Pair<String, Pair<Boolean, List<ExecuteResult>>> insertRet = client.execute(insert); OperationStatus operationStatus = insertRet.getSecond().getSecond().get(0).getStatus(); assertTrue(operationStatus.getOperationStatusCode() == OperationStatusCode.FAILURE); assertTrue(operationStatus.getExceptionClassname() .equals("com.alibaba.wasp.PrimaryKeyAlreadyExistsException")); }