List of usage examples for java.util Map clear
void clear();
From source file:com.blockwithme.longdb.bdb.BDBBackend.java
@Override protected void openInternal(final Map<String, BDBDatabase> theDatabase) { theDatabase.clear(); try {// www . j a v a2 s. c o m final File dataRoot = new File(config.filePath()); if (!dataRoot.exists()) FileUtils.forceMkdir(dataRoot); final String[] dataDirectories = dataRoot.list(DirectoryFileFilter.INSTANCE); for (final String dir : dataDirectories) { final BDBDatabase bdb = new BDBDatabase(this, this.connect(dir), dir); theDatabase.put(dir.toLowerCase(), bdb); } } catch (final Exception e) { LOG.error("Exception Occurred in - " + "openInternal(Map<String,BDBDatabase> databases=" + theDatabase + ")", e); throw new DBException("Error creating connection.", e); } }
From source file:org.atemsource.atem.impl.common.attribute.MapAttributeImpl.java
@Override public void clear(Object entity) { Map map = getValue(entity); if (map != null) { map.clear(); } }
From source file:com.espertech.esper.filter.FilterSpecCompiler.java
private static void consolidate(FilterParamExprMap filterParamExprMap, String statementName) { // consolidate or place in a boolean expression (by removing filter spec param from the map) // any filter parameter that feature the same property name and filter operator, // i.e. we are looking for "a!=5 and a!=6" to transform to "a not in (5,6)" which can match faster // considering that "a not in (5,6) and a not in (7,8)" is "a not in (5, 6, 7, 8)" therefore // we need to consolidate until there is no more work to do Map<Pair<FilterSpecLookupable, FilterOperator>, List<FilterSpecParam>> mapOfParams = new HashMap<Pair<FilterSpecLookupable, FilterOperator>, List<FilterSpecParam>>(); boolean haveConsolidated; do {//from w ww .jav a 2 s . c o m haveConsolidated = false; mapOfParams.clear(); // sort into buckets of propertyName + filterOperator combination for (FilterSpecParam currentParam : filterParamExprMap.getFilterParams()) { FilterSpecLookupable lookupable = currentParam.getLookupable(); FilterOperator op = currentParam.getFilterOperator(); Pair<FilterSpecLookupable, FilterOperator> key = new Pair<FilterSpecLookupable, FilterOperator>( lookupable, op); List<FilterSpecParam> existingParam = mapOfParams.get(key); if (existingParam == null) { existingParam = new ArrayList<FilterSpecParam>(); mapOfParams.put(key, existingParam); } existingParam.add(currentParam); } for (List<FilterSpecParam> entry : mapOfParams.values()) { if (entry.size() > 1) { haveConsolidated = true; consolidate(entry, filterParamExprMap, statementName); } } } while (haveConsolidated); }
From source file:net.nicoll.boot.metadata.CsvMetadataFormatter.java
@Override public String formatMetadata(ConfigurationMetadataRepository repository) throws IOException { StringWriter out = new StringWriter(); CsvMapWriter writer = new CsvMapWriter(out, CsvPreference.STANDARD_PREFERENCE); try {// w w w . j a v a2 s. c om List<ConfigurationMetadataGroup> groups = sortGroups(repository.getAllGroups().values()); Map<String, Object> content = new HashMap<String, Object>(); for (ConfigurationMetadataGroup group : groups) { content.clear(); StringBuilder groupSb = new StringBuilder(group.getId()).append(" - "); for (ConfigurationMetadataSource source : group.getSources().values()) { groupSb.append(source.getType()).append(" "); } content.put("id", groupSb.toString()); writer.write(content, header, processors); List<ConfigurationMetadataProperty> properties = sortProperties(group.getProperties().values()); for (ConfigurationMetadataProperty property : properties) { content.clear(); content.put("id", property.getId()); content.put("description", extractTagLine(property, null)); content.put("defaultValue", property.getDefaultValue()); content.put("type", property.getType()); writer.write(content, header, processors); } } } finally { writer.close(); } return out.toString(); }
From source file:edu.uci.ics.hyracks.algebricks.rewriter.rules.FactorRedundantGroupAndDecorVarsRule.java
private boolean factorRedundantRhsVars(List<Pair<LogicalVariable, Mutable<ILogicalExpression>>> veList, Mutable<ILogicalOperator> opRef, Map<LogicalVariable, LogicalVariable> varRhsToLhs, IOptimizationContext context) throws AlgebricksException { varRhsToLhs.clear(); ListIterator<Pair<LogicalVariable, Mutable<ILogicalExpression>>> iter = veList.listIterator(); boolean changed = false; while (iter.hasNext()) { Pair<LogicalVariable, Mutable<ILogicalExpression>> p = iter.next(); if (p.second.getValue().getExpressionTag() != LogicalExpressionTag.VARIABLE) { continue; }//from w w w .j a va 2s. c om LogicalVariable v = GroupByOperator.getDecorVariable(p); LogicalVariable lhs = varRhsToLhs.get(v); if (lhs != null) { if (p.first != null) { AssignOperator assign = new AssignOperator(p.first, new MutableObject<ILogicalExpression>(new VariableReferenceExpression(lhs))); ILogicalOperator op = opRef.getValue(); assign.getInputs().add(new MutableObject<ILogicalOperator>(op)); opRef.setValue(assign); context.computeAndSetTypeEnvironmentForOperator(assign); } iter.remove(); changed = true; } else { varRhsToLhs.put(v, p.first); } } return changed; }
From source file:com.fengduo.bee.commons.core.lang.BeanUtils.java
/** * ???/*from w w w . ja va 2 s. c o m*/ * * @param f * @return */ public static List<Map<String, String>> fieldEditableList(List<?> oldlineDOs, List<?> newlineDOs) { List<Map<String, String>> lst = new ArrayList<Map<String, String>>(); for (int i = 0; i < oldlineDOs.size(); i++) { Map<String, String> oldMap = getFieldValueMap(oldlineDOs.get(i)); Map<String, String> newMap = getFieldValueMap(newlineDOs.get(i)); Map<String, String> oldChangeMap = new HashMap<String, String>(); Map<String, String> newChangeMap = new HashMap<String, String>(); for (Entry<String, String> entry : oldMap.entrySet()) { String fieldKey = entry.getKey(); if (StringUtils.equalsIgnoreCase(fieldKey, "gmtModified") || StringUtils.equalsIgnoreCase(fieldKey, "gmtCreate")) { continue; } String oldValue = entry.getValue(); String newValue = newMap.get(fieldKey); if (!StringUtils.equalsIgnoreCase(oldValue, newValue)) { oldChangeMap.put(fieldKey, oldValue); newChangeMap.put(fieldKey, newValue); } } newMap.clear(); newMap.put("oldString", new Gson().toJson(oldChangeMap)); newMap.put("newString", new Gson().toJson(newChangeMap)); lst.add(newMap); } return lst; }
From source file:com.codekul.simpleboot.controller.ControllerRestServices.java
@RequestMapping(value = "/login", method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<Map<String, Object>> loginUser(@RequestBody User user) { ResponseEntity<Map<String, Object>> entity = null; Map<String, Object> mapBody = new HashMap<>(); HttpHeaders headers = new HttpHeaders(); try {/*from w w w . j a v a 2 s. co m*/ serviceUser.login(user); mapBody.clear(); mapBody.put("status", "success"); mapBody.put("msg", "Logged Successfully .."); entity = new ResponseEntity<>(mapBody, headers, HttpStatus.OK); } catch (Exception ex) { Logger.getLogger(ControllerRestServices.class.getName()).log(Level.SEVERE, null, ex); mapBody.clear(); mapBody.put("status", "fail"); mapBody.put("msg", "Bad Crediantials ..."); entity = new ResponseEntity<>(mapBody, headers, HttpStatus.BAD_REQUEST); } return entity; }
From source file:com.intuit.tank.project.ProjectVariableEditor.java
/** * persists the workload in the database *//*w w w.ja v a 2 s . co m*/ public void save() { Map<String, String> map = projectBean.getWorkload().getJobConfiguration().getVariables(); map.clear(); for (VariableEntry entry : variables) { map.put(entry.getKey(), entry.getValue()); } }
From source file:com.screenslicer.common.CommonUtil.java
public static String strip(String str, boolean removePipes) { if (str == null) { return ""; }//w ww.j a v a2 s . c o m int hash = Crypto.fastHashInt(str); Map<Integer, String> cache = removePipes ? stripCache : stripCacheWithPipes; if (cache.containsKey(hash)) { return cache.get(hash); } Pattern pattern = removePipes ? CommonUtil.whitespace : CommonUtil.whitespaceWithPipes; String oldStr = str; String newStr = pattern.matcher(oldStr).replaceAll(" "); while (!newStr.equals(oldStr)) { oldStr = newStr; newStr = pattern.matcher(oldStr).replaceAll(" "); } newStr = newStr.trim(); if (cache.size() == MAX_STRIP_CACHE) { cache.clear(); } cache.put(hash, newStr); return newStr; }
From source file:org.camunda.bpm.ext.sdk.impl.workers.PollTasksRunnable.java
protected void acquire() { final List<WorkerRegistrationImpl> registrations = workerManager.getRegistrations(); final MultiPollRequestDto request = new MultiPollRequestDto(); final Map<String, Worker> workerMap = new HashMap<String, Worker>(); request.clear();/* w ww .j a v a2 s . c o m*/ workerMap.clear(); synchronized (registrations) { int numOfRegistrations = registrations.size(); if (numOfRegistrations == 0) { try { registrations.wait(); } catch (InterruptedException e) { e.printStackTrace(); // TODO } } for (WorkerRegistrationImpl registration : registrations) { request.topics.add(new PollInstructionDto(registration.getTopicName(), registration.getLockTime(), registration.getVariableNames())); workerMap.put(registration.getTopicName(), registration.getWorker()); } } int tasksAcquired = 0; try { tasksAcquired = poll(request, workerMap); } catch (Exception e) { LOG.exceptionDuringPoll(e); } if (tasksAcquired == 0) { try { // back-off backoffStrategy.run(); } catch (InterruptedException e) { e.printStackTrace(); } } else { backoffStrategy.reset(); } }