List of usage examples for org.apache.commons.collections.map LRUMap get
public Object get(Object key)
From source file:org.lockss.plugin.AuSearchSet.java
public boolean isRecent404(String url) { LRUMap map = recent404s; if (map == null) { if (log.isDebug2()) log.debug2("isRecent404(" + url + "): false (no cache)"); return false; }/* www. j a va 2s .com*/ synchronized (map) { boolean res = (map.get(url) != null); if (log.isDebug2()) log.debug2("isRecent404(" + url + "): " + res); return res; } }
From source file:org.paxle.filter.webgraph.gui.PrefuseServlet.java
private Graph buildGraph() { // creating the result structure Graph graph = new Graph(true); graph.addColumn(VisualItem.LABEL, String.class); // getting the relations map LRUMap relations = this.getRelations(); // cloning the sourceDomain map HashMap<String, Node> domainMap = new HashMap<String, Node>(); @SuppressWarnings("unchecked") HashSet<String> sourceDomains = new HashSet<String>(relations.keySet()); for (String sourceDomain : sourceDomains) { // getting target domains @SuppressWarnings("unchecked") Set<String> targetDomains = (Set<String>) relations.get(sourceDomain); if (targetDomains == null || targetDomains.size() == 0) continue; // getting or creating source Node sourceNode = domainMap.get(sourceDomain); if (sourceNode == null) { sourceNode = graph.addNode(); sourceNode.setString(VisualItem.LABEL, sourceDomain); domainMap.put(sourceDomain, sourceNode); }// w w w . j av a2s . co m for (String targetDomain : targetDomains) { // getting or creating target Node targetNode = domainMap.get(targetDomain); if (targetNode == null) { targetNode = graph.addNode(); targetNode.setString(VisualItem.LABEL, targetDomain); domainMap.put(targetDomain, targetNode); } // adding link graph.addEdge(sourceNode, targetNode); } } return graph; }
From source file:org.paxle.filter.webgraph.gui.SourceServlet.java
@Override protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException { /*//from w ww . java2 s . c om * Okay, we have a lot of relations here. the filter stores up to 5000 domains with all relations, * if we graph this, the graph gets big and there is no overview. * What we do at the moment is this: * - limit the maximum Number of Nodes(Domains) to maxDomains(=100) * - limit the number of new domains introduced by a parent-domain to count(=5) * this keeps the graph small. */ LRUMap relations = ((GraphFilter) this.filter).getRelations(); StringBuffer result = new StringBuffer("digraph domains{\nedge [color=\"#80808080\"]\n"); Iterator it = (new HashSet(relations.keySet())).iterator(); int maxDomains = 1000; int maxChildDomains = 5; int numDomains = 0; int minReferences = 3; HashSet<String> domains = new HashSet<String>(); while (it.hasNext()) { String domain1 = (String) it.next(); //skip if the domain is new and we already know maxDomains if (!domains.contains(domain1)) { if (numDomains >= maxDomains) continue; domains.add(domain1); numDomains++; } //only nodes with at least minReferences ChildNodes (no lonely nodes) if (((Set) relations.get(domain1)).size() < minReferences) continue; Iterator<String> it2 = ((Set) relations.get(domain1)).iterator(); int count = 0; //new domains from this parent-node while (it2.hasNext()) { String domain2 = (String) it2.next(); if (!domains.contains(domain2)) { if (numDomains >= maxDomains) continue; if (count > maxChildDomains) continue; numDomains++; domains.add(domain2); count++; } result.append("\"").append(domain1).append("\"").append("->").append("\"").append(domain2) .append("\";\n"); } } result.append("}"); resp.setContentType("text/plain"); resp.setStatus(200); resp.getOutputStream().print(result.toString()); }
From source file:org.xenei.jena.security.SecuredItemImpl.java
private Boolean cacheGet(final CacheKey key) { final LRUMap cache = SecuredItemImpl.CACHE.get(); return (cache == null) ? null : (Boolean) cache.get(key); }