List of usage examples for java.util Map clear
void clear();
From source file:com.flexive.rest.TypeService.java
private List<?> buildProperties(FxEnvironment env, FxType type) { final Set<FxProperty> properties = Sets.newHashSet( Lists.transform(type.getAllProperties(), new Function<FxPropertyAssignment, FxProperty>() { @Override/* w ww . j av a 2s . c om*/ public FxProperty apply(@Nullable FxPropertyAssignment input) { return input == null ? null : input.getProperty(); } })); final List<Map<String, Object>> result = Lists.newArrayListWithCapacity(properties.size()); final Map<String, Object> specificOptions = Maps.newHashMap(); for (FxProperty prop : properties) { specificOptions.clear(); if (prop.getReferencedList() != null) { specificOptions.put("referencedList", prop.getReferencedList().getName()); } if (prop.getReferencedType() != null) { specificOptions.put("referencedType", prop.getReferencedType() == null ? null : prop.getReferencedType().getName()); } result.add(FxRestApiUtils.responseMapBuilder().put("id", prop.getId()).put("name", prop.getName()) .put("dataType", prop.getDataType().name()).put("multiLang", prop.isMultiLang()) .put("emptyValue", ContentService.serializeMultiLangSimple(env, prop.getEmptyValue())) .put("defaultValue", ContentService.serializeMultiLangSimple(env, prop.getDefaultValue())) .put("uniqueMode", prop.getUniqueMode().name()).putAll(specificOptions).build()); } return result; }
From source file:org.atemsource.atem.impl.common.attribute.MapAttributeImpl.java
public void clearOrInitialize(Object entity) { Map<?, ?> map = getValue(entity); if (map == null) { setValue(entity, getEmptyMap()); } else {/*from ww w . j av a 2 s . co m*/ map.clear(); } }
From source file:com.taobao.datax.plugins.reader.mysqlreader.MysqlReader.java
private Map<String, SimpleDateFormat> genDateFormatMap() { Map<String, SimpleDateFormat> mapDateFormat = new HashMap<String, SimpleDateFormat>(); mapDateFormat.clear(); mapDateFormat.put("datetime", new SimpleDateFormat("yyyy-MM-dd HH:mm:ss")); mapDateFormat.put("timestamp", new SimpleDateFormat("yyyy-MM-dd HH:mm:ss")); mapDateFormat.put("time", new SimpleDateFormat("HH:mm:ss")); return mapDateFormat; }
From source file:edu.uci.ics.jung.algorithms.importance.BetweennessCentrality.java
protected void computeBetweenness(Graph<V, E> graph) { Map<V, BetweennessData> decorator = new HashMap<V, BetweennessData>(); Map<V, Number> bcVertexDecorator = vertexRankScores.get(getRankScoreKey()); bcVertexDecorator.clear(); Map<E, Number> bcEdgeDecorator = edgeRankScores.get(getRankScoreKey()); bcEdgeDecorator.clear();//from w ww . j a v a2s. c o m Collection<V> vertices = graph.getVertices(); for (V s : vertices) { initializeData(graph, decorator); decorator.get(s).numSPs = 1; decorator.get(s).distance = 0; Stack<V> stack = new Stack<V>(); Buffer<V> queue = new UnboundedFifoBuffer<V>(); queue.add(s); while (!queue.isEmpty()) { V v = queue.remove(); stack.push(v); for (V w : getGraph().getSuccessors(v)) { if (decorator.get(w).distance < 0) { queue.add(w); decorator.get(w).distance = decorator.get(v).distance + 1; } if (decorator.get(w).distance == decorator.get(v).distance + 1) { decorator.get(w).numSPs += decorator.get(v).numSPs; decorator.get(w).predecessors.add(v); } } } while (!stack.isEmpty()) { V w = stack.pop(); for (V v : decorator.get(w).predecessors) { double partialDependency = (decorator.get(v).numSPs / decorator.get(w).numSPs); partialDependency *= (1.0 + decorator.get(w).dependency); decorator.get(v).dependency += partialDependency; E currentEdge = getGraph().findEdge(v, w); double edgeValue = bcEdgeDecorator.get(currentEdge).doubleValue(); edgeValue += partialDependency; bcEdgeDecorator.put(currentEdge, edgeValue); } if (w != s) { double bcValue = bcVertexDecorator.get(w).doubleValue(); bcValue += decorator.get(w).dependency; bcVertexDecorator.put(w, bcValue); } } } if (graph instanceof UndirectedGraph) { for (V v : vertices) { double bcValue = bcVertexDecorator.get(v).doubleValue(); bcValue /= 2.0; bcVertexDecorator.put(v, bcValue); } for (E e : graph.getEdges()) { double bcValue = bcEdgeDecorator.get(e).doubleValue(); bcValue /= 2.0; bcEdgeDecorator.put(e, bcValue); } } for (V vertex : vertices) { decorator.remove(vertex); } }
From source file:com.alibaba.otter.shared.arbitrate.setl.BaseStageTest.java
@BeforeMethod public void setUp() { try {/*from w w w .j a v a2s. c o m*/ Map cache = (Map) TestUtils.getField(new ArbitrateFactory(), "cache"); cache.clear(); } catch (Exception e) { want.fail(); } }
From source file:fr.paris.lutece.portal.web.upload.UploadServletTest.java
public void testDoPost_NoFiles_Handler2() throws Exception { final String BEAN_NAME = "testAsyncUpMap"; MockHttpServletRequest request = new MockHttpServletRequest(); MockHttpServletResponse response = new MockHttpServletResponse(); Map<String, List<FileItem>> mapFiles = new HashMap<>(); Map<String, String[]> mapParameters = new HashMap<>(); mapParameters.put("handler", new String[] { BEAN_NAME }); MultipartHttpServletRequest multipartRequest = new MultipartHttpServletRequest(request, mapFiles, mapParameters);/* www .j a va 2 s. c o m*/ clearLuteceSpringCache(); ConfigurableListableBeanFactory beanFactory = ((ConfigurableApplicationContext) SpringContextService .getContext()).getBeanFactory(); beanFactory.registerSingleton(BEAN_NAME, new IAsynchronousUploadHandler2() { @Override public void process(HttpServletRequest request, HttpServletResponse response, Map<String, Object> mainObject, List<FileItem> fileItems) { mainObject.clear(); mainObject.put("testmap", "valuetestmap"); } @Override public boolean isInvoked(HttpServletRequest request) { return BEAN_NAME.equals(request.getParameter("handler")); } }); try { new UploadServlet().doPost(multipartRequest, response); } catch (Exception e) { throw new RuntimeException(e); } finally { ((DefaultListableBeanFactory) beanFactory).destroySingleton(BEAN_NAME); clearLuteceSpringCache(); } String strResponseJson = response.getContentAsString(); System.out.println(strResponseJson); String strRefJson = "{\"testmap\":\"valuetestmap\"}"; ObjectMapper objectMapper = new ObjectMapper(); JsonNode objectNodeRef = objectMapper.readTree(strRefJson); JsonNode objectNodeJson = objectMapper.readTree(strResponseJson); assertEquals(objectNodeRef, objectNodeJson); }
From source file:org.fcrepo.camel.indexing.solr.DeleteProcessorTest.java
@Test public void testDeleteProcessor() throws Exception { final String id = "/foo"; final String baseUrl = "http://localhost/rest"; resultEndpoint.expectedMessageCount(2); resultEndpoint.expectedHeaderReceived(FcrepoHeaders.FCREPO_IDENTIFIER, id); resultEndpoint.expectedHeaderReceived(FcrepoHeaders.FCREPO_BASE_URL, baseUrl); resultEndpoint.expectedHeaderReceived(Exchange.HTTP_METHOD, "POST"); resultEndpoint.expectedHeaderReceived(Exchange.CONTENT_TYPE, "application/json"); final Map<String, Object> headers = new HashMap<>(); headers.put(FcrepoHeaders.FCREPO_IDENTIFIER, id); headers.put(FcrepoHeaders.FCREPO_BASE_URL, baseUrl); template.sendBodyAndHeaders("", headers); headers.clear(); headers.put(JmsHeaders.IDENTIFIER, id); headers.put(JmsHeaders.BASE_URL, baseUrl); template.sendBodyAndHeaders("", headers); final ObjectMapper mapper = new ObjectMapper(); for (final Exchange e : resultEndpoint.getExchanges()) { final JsonNode root = mapper.readTree(e.getIn().getBody(String.class)); final JsonNode deleteNode = root.get("delete"); assertNotNull(deleteNode);//from ww w.ja v a 2 s .c o m assertNotNull(deleteNode.get("id")); assertEquals(deleteNode.get("id").asText(), baseUrl + id); } assertMockEndpointsSatisfied(); }
From source file:com.datos.vfs.cache.LRUFilesCache.java
@Override public void clear(final FileSystem filesystem) { final Map<FileName, FileObject> files = getOrCreateFilesystemCache(filesystem); writeLock.lock();// ww w . j a v a 2 s. c o m try { files.clear(); filesystemCache.remove(filesystem); } finally { writeLock.unlock(); } }
From source file:io.syndesis.dao.manager.DataManager.java
public <T extends WithId<T>> void deleteAll(Class<T> model) { Kind kind = Kind.from(model);//from www .java 2 s . c om Map<String, WithId<T>> cache = caches.getCache(kind.getModelName()); cache.clear(); doWithDataAccessObject(model, d -> { d.deleteAll(); return null; }); }
From source file:hoot.services.osm.OsmTestUtils.java
public static Set<Long> createTestNodes(final long changesetId, final BoundingBox bounds) throws Exception { Set<Long> nodeIds = new LinkedHashSet<Long>(); Map<String, String> tags = new HashMap<String, String>(); tags.put("key 1", "val 1"); tags.put("key 2", "val 2"); nodeIds.add(Node.insertNew(changesetId, mapId, bounds.getMinLat(), bounds.getMinLon(), tags, conn)); tags.clear(); nodeIds.add(Node.insertNew(changesetId, mapId, bounds.getMaxLat(), bounds.getMaxLon(), null, conn)); nodeIds.add(Node.insertNew(changesetId, mapId, bounds.getMinLat(), bounds.getMinLon(), null, conn)); tags.put("key 3", "val 3"); nodeIds.add(Node.insertNew(changesetId, mapId, bounds.getMinLat(), bounds.getMinLon(), tags, conn)); tags.clear();/*from ww w . j a v a 2 s . com*/ tags.put("key 4", "val 4"); nodeIds.add(Node.insertNew(changesetId, mapId, bounds.getMinLat(), bounds.getMinLon(), tags, conn)); tags.clear(); return nodeIds; }