List of usage examples for java.util Map clear
void clear();
From source file:edu.umass.cs.gigapaxos.testing.TESTPaxosNode.java
protected void createNonDefaultGroupInstanes(int numGroups, int batchSize) { int j = 1;//w ww .ja v a 2s . c o m if (numGroups > Config.getGlobalInt(TC.PRE_CONFIGURED_GROUPS)) System.out.println("\nNode " + this.myID + " initiating creation of non-default groups" + (batchSize > 1 ? " in batches of " + batchSize : "") + ":"); // Creating groups beyond default configured groups (if numGroups > // MAX_CONFIG_GROUPS) int k = 0; String groupIDPrefix = Config.getGlobalString(TC.TEST_GUID_PREFIX); Map<String, String> nameStates = new HashMap<String, String>(); for (int i = Config.getGlobalInt(TC.PRE_CONFIGURED_GROUPS); i < numGroups; i += batchSize) { nameStates.clear(); for (k = i; k < Math.min(numGroups, i + batchSize); k++) nameStates.put(groupIDPrefix + k, "some_initial_value"); for (int id : TESTPaxosConfig.getDefaultGroup()) { try { if (id == myID) this.getPaxosManager().createPaxosInstance(nameStates, Util.arrayToIntSet(TESTPaxosConfig.getDefaultGroup())); } catch (Exception e) { // ignore } } int bcount = (i - Config.getGlobalInt(TC.PRE_CONFIGURED_GROUPS)) / batchSize; if (bcount % j == 0 && ((j *= 2) > 1) || (k == numGroups - 1)) { System.out.print((k - Config.getGlobalInt(TC.PRE_CONFIGURED_GROUPS)) + " "); } } }
From source file:com.taobao.datax.plugins.reader.oraclereader.OracleReader.java
private Map<String, SimpleDateFormat> genDateFormatMap() { Map<String, SimpleDateFormat> mapDateFormat; mapDateFormat = new HashMap<String, SimpleDateFormat>(); mapDateFormat.clear(); mapDateFormat.put("date", new SimpleDateFormat("yyyy-MM-dd HH:mm:ss")); mapDateFormat.put("timestamp", new SimpleDateFormat("yyyy-MM-dd HH:mm:ss")); return mapDateFormat; }
From source file:com.stratio.ingestion.sink.mongodb.MongoSinkDynamicTest.java
@Test public void basicTest() throws Exception { Transaction tx = channel.getTransaction(); tx.begin();/*from ww w .jav a 2 s . c o m*/ Map<String, String> headers = new HashMap<String, String>(); headers.put("myString", "test1"); Event event = EventBuilder.withBody(new byte[0], headers); channel.put(event); headers.clear(); headers.put("myString", "test2"); headers.put("collection", "test2coll"); event = EventBuilder.withBody(new byte[0], headers); channel.put(event); headers.clear(); headers.put("myString", "test3"); headers.put("db", "test3db"); headers.put("collection", "test3coll"); event = EventBuilder.withBody(new byte[0], headers); channel.put(event); tx.commit(); tx.close(); mongoSink.process(); DBObject result = fongo.getDB("test").getCollection("test").findOne(); assertThat(result.get("myString")).isEqualTo("test1"); result = fongo.getDB("test").getCollection("test2coll").findOne(); assertThat(result.get("myString")).isEqualTo("test2"); result = fongo.getDB("test3db").getCollection("test3coll").findOne(); assertThat(result.get("myString")).isEqualTo("test3"); }
From source file:com.adito.applications.forms.ApplicationShortcutForm.java
@SuppressWarnings("unchecked") public void applyToResource() throws Exception { ApplicationShortcut as = (ApplicationShortcut) getResource(); as.setAutoStart(isAutoStart());//www. j a va 2s . c o m Map<String, String> parameterMap = as.getParameters(); parameterMap.clear(); for (Iterator i = getParameterItems().iterator(); i.hasNext();) { ShortcutParameterItem pi = (ShortcutParameterItem) i.next(); parameterMap.put(pi.getName(), pi.getPropertyValue().toString()); } }
From source file:org.dbflute.utflute.spring.SpringTestCase.java
protected void xreleaseLocatorContextCache() { final Class<ContextSingletonBeanFactoryLocator> locatorType = ContextSingletonBeanFactoryLocator.class; final String cacheMapName = "instances"; final Field cacheMapField = DfReflectionUtil.getWholeField(locatorType, cacheMapName); final Map<?, ?> instances = (Map<?, ?>) DfReflectionUtil.getValueForcedly(cacheMapField, null); instances.clear(); }
From source file:de.l3s.boilerpipe.sax.HtmlArticleExtractor.java
private String removeNotAllowedTags(String htmlFragment, URI docUri) { Source source = new Source(htmlFragment); OutputDocument outputDocument = new OutputDocument(source); List<Element> elements = source.getAllElements(); for (Element element : elements) { Attributes attrs = element.getAttributes(); Map<String, String> attrsUpdate = outputDocument.replace(attrs, true); if (!element.getName().contains("a")) { attrsUpdate.clear(); } else {//from w w w . j av a2 s. c o m if (attrsUpdate.get("href") != null) { String link = attrsUpdate.get("href"); if (!link.contains("http")) { URI documentUri = docUri; URI anchorUri; try { anchorUri = new URI(link); URI result = documentUri.resolve(anchorUri); attrsUpdate.put("href", result.toString()); } catch (URISyntaxException e) { outputDocument.remove(element); } } } } if (NOT_ALLOWED_HTML_TAGS.contains(element.getName())) { Segment content = element.getContent(); if (element.getName() == "script" || element.getName() == "style" || element.getName() == "form") { outputDocument.remove(content); } outputDocument.remove(element.getStartTag()); if (!element.getStartTag().isSyntacticalEmptyElementTag()) { outputDocument.remove(element.getEndTag()); } } } String out = outputDocument.toString(); out = out.replaceAll("\\n", ""); out = out.replaceAll("\\t", ""); return out; }
From source file:nz.co.senanque.validationengine.Binder.java
public void unbindAll(final Map<ValidationObject, ProxyObject> boundMap) { for (ValidationObject validationObject : boundMap.keySet()) { validationObject.setValidationSession(null); }/*from ww w .jav a 2 s . c o m*/ boundMap.clear(); }
From source file:cc.kave.commons.pointsto.evaluation.TimeEvaluation.java
public void run(List<Context> contexts, List<PointsToAnalysisFactory> ptFactories) throws IOException { initializeStmtCountTimes(ptFactories, contexts); log("Using %d contexts for time measurement\n", contexts.size()); Map<Pair<String, ITypeName>, AnalysisTimeEntry> timesRegistry = new LinkedHashMap<>( contexts.size() * ptFactories.size()); for (int i = 0; i < WARM_UP_RUNS + MEASUREMENT_RUNS; ++i) { if (i == WARM_UP_RUNS) { timesRegistry.clear(); }/*from w w w .j av a 2 s . c o m*/ for (PointsToAnalysisFactory ptFactory : ptFactories) { analysisStatistics.put(ptFactory.getName(), measurePointerAnalysis(contexts, ptFactory, new MutableLong())); } updateTimesRegistry(timesRegistry); } analysisTimes = timesRegistry.values().stream().map(entry -> new AnalysisTimeEntry(entry.analysisName, entry.contextType, entry.numStmts, entry.time / MEASUREMENT_RUNS)).collect(Collectors.toList()); }
From source file:com.flexive.war.javascript.tree.StructureTreeWriter.java
/** * Render an assigned property./*from ww w . ja va 2 s .com*/ * * @param writer the tree node writer * @param nodeProperties an existing hashmap for storing additional JS properties (cleared on entry) * @param assignment the property to be rendered * @param isShowLabels true if labels should be shown, false if the Alias should be shown * @throws IOException if the tree could not be written */ private void writePropertyAssignment(TreeNodeWriter writer, Map<String, Object> nodeProperties, FxPropertyAssignment assignment, boolean isShowLabels) throws IOException { nodeProperties.clear(); nodeProperties.put("alias", assignment.getAlias()); nodeProperties.put("assignmentId", String.valueOf(assignment.getId())); nodeProperties.put("propertyId", String.valueOf(assignment.getProperty().getId())); nodeProperties.put("nodeType", assignment.isSystemInternal() ? NODE_TYPE_ASSIGNMENT_SYSTEMINTERNAL : NODE_TYPE_ASSIGNMENT); writer.writeNode(new Node(String.valueOf(assignment.getId()), isShowLabels ? assignment.getDisplayName() : (String) nodeProperties.get("alias"), assignment.isSystemInternal() ? DOC_TYPE_ASSIGNMENT_SYSTEMINTERNAL : DOC_TYPE_ASSIGNMENT, nodeProperties)); }
From source file:com.esd.ps.LoginRegController.java
/** * ??//from www . j av a2 s. c o m * * @param username * @return */ public Map<String, Object> regCheckLoginName(String username) { Map<String, Object> map = new HashMap<String, Object>(); if (!StringUtils.isEmpty(username)) { District district = districtService.getByUserName(username); if (district == null) { map.clear(); map.put(Constants.MESSAGE, MSG_USER_NOT_EXIST); map.put(Constants.REPLAY, Constants.ZERO); return map; } map.clear(); map.put(Constants.REPLAY, Constants.ONE); return map; } map.clear(); map.put(Constants.MESSAGE, MSG_USER_NOT_EMPTY); map.put(Constants.REPLAY, Constants.ZERO); return map; }