List of usage examples for java.util Map clear
void clear();
From source file:hoot.services.osm.OsmTestUtils.java
public static Set<Long> createTestWays(final long changesetId, final Set<Long> nodeIds) throws Exception { Set<Long> wayIds = new LinkedHashSet<Long>(); List<Long> wayNodeIds = new ArrayList<Long>(); final Long[] nodeIdsArr = nodeIds.toArray(new Long[] {}); Map<String, String> tags = new HashMap<String, String>(); tags.put("key 1", "val 1"); tags.put("key 2", "val 2"); wayNodeIds.add(nodeIdsArr[0]);/*from ww w. j ava2s . c o m*/ wayNodeIds.add(nodeIdsArr[1]); wayNodeIds.add(nodeIdsArr[4]); wayIds.add(Way.insertNew(changesetId, mapId, wayNodeIds, tags, conn)); tags.clear(); wayNodeIds.clear(); wayNodeIds.add(nodeIdsArr[2]); wayNodeIds.add(nodeIdsArr[1]); wayIds.add(Way.insertNew(changesetId, mapId, wayNodeIds, null, conn)); wayNodeIds.clear(); tags.put("key 3", "val 3"); wayNodeIds.add(nodeIdsArr[0]); wayNodeIds.add(nodeIdsArr[1]); wayIds.add(Way.insertNew(changesetId, mapId, wayNodeIds, tags, conn)); tags.clear(); wayNodeIds.clear(); return wayIds; }
From source file:com.fortify.processrunner.processor.AbstractProcessorGroupByExpressions.java
/** * If grouping is enabled, initialize the temporary cache that will hold grouped objects. *//*ww w .j av a 2s . co m*/ @SuppressWarnings("unchecked") @Override protected final boolean preProcess(Context context) { if (isGroupingEnabled(context)) { IContextGrouping ctx = context.as(IContextGrouping.class); DB db = DBMaker.tempFileDB().closeOnJvmShutdown().fileDeleteAfterClose().fileMmapEnableIfSupported() .make(); Map<String, List<Object>> groups = db.hashMap("groups", Serializer.STRING, Serializer.JAVA).create(); groups.clear(); // Make sure that we start with a clean cache ctx.setGroupByExpressionsMapDB(db); ctx.setGroupByExpressionsGroupsMap(groups); } return preProcessBeforeGrouping(context); }
From source file:io.servicecomb.loadbalance.filter.TestSimpleTransactionControlFilter.java
@Test public void testAllowVisit() { Map<String, String> filterOptions = new HashMap<>(); Assert.assertTrue(filter.allowVisit(server, filterOptions)); filterOptions.put("tag0", "value0"); Assert.assertTrue(filter.allowVisit(server, filterOptions)); filterOptions.put("tag2", "value2"); Assert.assertFalse(filter.allowVisit(server, filterOptions)); filterOptions.clear(); filterOptions.put("tag0", "value1"); Assert.assertFalse(filter.allowVisit(server, filterOptions)); }
From source file:com.inmobi.messaging.consumer.util.TestUtil.java
public static void assertBuffer(StreamFile file, int fileNum, int startIndex, int numMsgs, PartitionId pid, LinkedBlockingQueue<QueueEntry> buffer, boolean isDatabusData, Map<Integer, PartitionCheckpoint> expectedDeltaPck) throws InterruptedException, IOException { int fileIndex = (fileNum - 1) * 100; for (int i = startIndex; i < (startIndex + numMsgs); i++) { QueueEntry entry = buffer.take(); Assert.assertEquals(entry.getPartitionId(), pid); if (entry.getMessageChkpoint() instanceof DeltaPartitionCheckPoint) { int min = Integer.parseInt(new Path(file.toString()).getParent().getName()); Map<Integer, PartitionCheckpoint> actualDeltaPck = ((DeltaPartitionCheckPoint) entry .getMessageChkpoint()).getDeltaCheckpoint(); // get expected delta pck expectedDeltaPck = new DeltaPartitionCheckPoint(file, i + 1, min, expectedDeltaPck) .getDeltaCheckpoint(); // assert on expected and actual delta pck Assert.assertEquals(actualDeltaPck, expectedDeltaPck); expectedDeltaPck.clear(); } else {//from w w w. ja v a 2 s. c om Assert.assertEquals(entry.getMessageChkpoint(), new PartitionCheckpoint(file, i + 1)); } if (isDatabusData) { Assert.assertEquals(new String(((Message) entry.getMessage()).getData().array()), MessageUtil.constructMessage(fileIndex + i)); } else { Assert.assertEquals(MessageUtil.getTextMessage(((Message) entry.getMessage()).getData().array()), new Text(MessageUtil.constructMessage(fileIndex + i))); } } }
From source file:com.microsoft.projectoxford.emotion.EmotionServiceRestClient.java
@Override public List<RecognizeResult> recognizeImage(String url, FaceRectangle[] faceRectangles) throws EmotionServiceException { Map<String, Object> params = new HashMap<>(); String path = apiRoot + "/recognize"; if (faceRectangles != null && faceRectangles.length > 0) { params.put(FACE_RECTANGLES, getFaceRectangleStrings(faceRectangles)); }/*from w w w .j a va2 s.com*/ String uri = WebServiceRequest.getUrl(path, params); params.clear(); params.put("url", url); String json = (String) this.restCall.post(uri, params, null, false); RecognizeResult[] recognizeResult = this.gson.fromJson(json, RecognizeResult[].class); return Arrays.asList(recognizeResult); }
From source file:com.microsoft.projectoxford.emotion.EmotionServiceRestClient.java
@Override public List<RecognizeResult> recognizeImage(InputStream stream, FaceRectangle[] faceRectangles) throws EmotionServiceException, IOException { Map<String, Object> params = new HashMap<>(); String path = apiRoot + "/recognize"; if (faceRectangles != null && faceRectangles.length > 0) { params.put(FACE_RECTANGLES, getFaceRectangleStrings(faceRectangles)); }//from ww w .ja v a 2 s. c om String uri = WebServiceRequest.getUrl(path, params); params.clear(); byte[] data = IOUtils.toByteArray(stream); params.put("data", data); String json = (String) this.restCall.post(uri, params, "application/octet-stream", false); RecognizeResult[] recognizeResult = this.gson.fromJson(json, RecognizeResult[].class); return Arrays.asList(recognizeResult); }
From source file:com.microsoft.projectoxford.vision.VisionServiceRestClient.java
@Override public AnalysisInDomainResult analyzeImageInDomain(String url, String model) throws VisionServiceException { Map<String, Object> params = new HashMap<>(); String path = apiRoot + "/models/" + model + "/analyze"; String uri = WebServiceRequest.getUrl(path, params); params.clear(); params.put("url", url); String json = (String) this.restCall.request(uri, "POST", params, null, false); AnalysisInDomainResult visualFeature = this.gson.fromJson(json, AnalysisInDomainResult.class); return visualFeature; }
From source file:com.microsoft.projectoxford.vision.VisionServiceRestClient.java
@Override public AnalysisInDomainResult analyzeImageInDomain(InputStream stream, String model) throws VisionServiceException, IOException { Map<String, Object> params = new HashMap<>(); String path = apiRoot + "/models/" + model + "/analyze"; String uri = WebServiceRequest.getUrl(path, params); params.clear(); byte[] data = IOUtils.toByteArray(stream); params.put("data", data); String json = (String) this.restCall.request(uri, "POST", params, "application/octet-stream", false); AnalysisInDomainResult visualFeature = this.gson.fromJson(json, AnalysisInDomainResult.class); return visualFeature; }
From source file:com.netflix.spinnaker.halyard.deploy.spinnaker.v1.profile.deck.ApacheSpinnakerProfileFactory.java
@Override protected Map<String, String> getBindings(DeploymentConfiguration deploymentConfiguration, SpinnakerRuntimeSettings endpoints) { TemplatedResource resource = new StringResource(SSL_TEMPLATE); Map<String, String> bindings = new HashMap<>(); UiSecurity uiSecurity = deploymentConfiguration.getSecurity().getUiSecurity(); ApacheSsl apacheSsl = uiSecurity.getSsl(); bindings.put("cert-file", apacheSsl.getSslCertificateFile()); bindings.put("key-file", apacheSsl.getSslCertificateKeyFile()); String ssl = resource.setBindings(bindings).toString(); bindings.clear(); bindings.put("ssl", ssl); bindings.put("deck-host", endpoints.getServices().getDeck().getHost()); bindings.put("deck-port", endpoints.getServices().getDeck().getPort() + ""); return bindings; }
From source file:it.greenvulcano.gvesb.virtual.rest.RestCallOperation.java
private void fillMap(NodeList sourceNodeList, Map<String, String> destinationMap) { if (sourceNodeList.getLength() == 0) { destinationMap.clear(); } else {//from w ww .j av a 2 s . c o m IntStream.range(0, sourceNodeList.getLength()).mapToObj(sourceNodeList::item).forEach(node -> { try { destinationMap.put(XMLConfig.get(node, "@name"), XMLConfig.get(node, "@value")); } catch (Exception e) { logger.error("Fail to read configuration", e); } }); } }