List of usage examples for org.apache.commons.collections MultiHashMap MultiHashMap
public MultiHashMap()
From source file:com.cyclopsgroup.waterview.DummyTest.java
/** * Dummy test case/*from w w w . ja v a2 s . c om*/ */ public void testDummy() { MultiHashMap map = new MultiHashMap(); map.put("a", "a1"); map.put("a", "a2"); Properties p = new Properties(); p.putAll(map); System.out.println(p.getProperty("a")); }
From source file:de.costache.calendar.util.IndexedEventCollection.java
/** * Creates a new instance of {@link IndexedEventCollection} *///from w w w .j a v a 2 s .c o m public IndexedEventCollection(final JCalendar parent) { this.parent = parent; this.indexedEvents = new MultiHashMap(); this.collectionChangedListeners = new ArrayList<ModelChangedListener>(); this.selectionChangedListeners = new ArrayList<SelectionChangedListener>(); this.selectedEvents = new HashSet<CalendarEvent>(); }
From source file:com.cyclopsgroup.waterview.navigator.impl.DefaultNavigatorHome.java
/** * Overwrite or implement method in DefaultNavigatorHome * * @see org.apache.avalon.framework.activity.Initializable#initialize() *///from w w w .ja v a 2s. com public void initialize() throws Exception { pathIndex = new Hashtable(); parentPathIndex = new MultiHashMap(); pageIndex = new Hashtable(); rootNode = new DefaultNavigatorNode(this, "/", null); rootNode.getAttributes().set(DefaultNavigatorNode.PAGE_NAME, "/Index.jelly"); rootNode.getAttributes().set(DefaultNavigatorNode.TITLE_NAME, "Start"); addNode(rootNode); JellyContext jc = new JellyContext(); jc.setVariable(getClass().getName(), this); jc.registerTagLibrary("http://waterview.cyclopsgroup.com/navigator", new NavigatorTagLibrary()); for (Enumeration en = getClass().getClassLoader() .getResources("META-INF/cyclopsgroup/waterview-navigation.xml"); en.hasMoreElements();) { URL resource = (URL) en.nextElement(); getLogger().info("Reading navigation from " + resource); jc.runScript(resource, XMLOutput.createDummyXMLOutput()); } populateNode(rootNode); }
From source file:edu.cmu.tetrad.graph.LayeredDrawing.java
private List<List<Node>> placeInTiers(Graph graph) { List<List<Node>> connectedComponents = GraphUtils.connectedComponents(graph); List<List<Node>> tiers = new ArrayList<List<Node>>(); for (List<Node> component : connectedComponents) { // Recursively map each node to its tier inside the component, // starting with the first node. These tiers are relative and // can be negative. Node firstNode = component.get(0); Map<Node, Integer> componentTiers = new HashMap<Node, Integer>(); placeNodes(firstNode, componentTiers, graph); // Reverse the map. The domain of this map is now possibly negative // tiers. Map<Integer, Node> reversedMap = new MultiHashMap(); for (Node _node : component) { Integer _tier = componentTiers.get(_node); reversedMap.put(_tier, _node); }/*from ww w.ja v a2s . co m*/ List<Integer> indices = new ArrayList<Integer>(reversedMap.keySet()); Collections.sort(indices); // Add these tiers low to high to the list of all tiers. Note that // connected components are appended top to bottom in the list of // tiers. int start = tiers.size(); for (int i : indices) { Collection<Node> collection = (Collection<Node>) reversedMap.get(i); tiers.add(new ArrayList<Node>(collection)); } // Do some heuristic uncrossing of edges in successive tiers. for (int i = start; i < tiers.size() - 1; i++) { List<Node> tier1 = tiers.get(i); List<Node> tier2 = tiers.get(i + 1); List<Node> saveArray = new ArrayList<Node>(); int saveCrossings = Integer.MAX_VALUE; for (int j = 0; j < 4 * tier2.size(); j++) { Collections.shuffle(tier2); int numCrossings = numCrossings(tier1, tier2, graph); if (numCrossings < saveCrossings) { saveArray = new ArrayList<Node>(tier2); saveCrossings = numCrossings; } } tiers.set(i + 1, saveArray); } } return tiers; }
From source file:com.opensymphony.able.webwork.quickstart.Configuration.java
public void resolveDirs(String wd) { if (ideaConfig != null) { String[] parts = ideaConfig.split(","); for (int i = 0; i < parts.length; i++) { String full = resolveDir(parts[i], wd); try { DocumentBuilder db = DocumentBuilderFactory.newInstance().newDocumentBuilder(); Document doc = db.parse(full); NodeList components = doc.getElementsByTagName("root"); List jars = new ArrayList(); for (int j = 0; j < components.getLength(); j++) { Element e = (Element) components.item(j); String value = e.getAttribute("url"); if (value != null && value.startsWith("jar://") && value.endsWith(".jar!/")) { value = value.substring(6, value.length() - 2); if (value.startsWith("$MODULE_DIR$")) { value = value.substring(13); }// ww w .j a va 2 s .c o m jars.add(value); } } if (this.libs != null) { this.libs.addAll(jars); } else { this.libs = jars; } } catch (Exception e) { e.printStackTrace(); } } } resolve(this.libs, wd); resolve(this.classDirs, wd); resolve(this.sources, wd); // now resolve the web dirs for (Iterator iterator = webDirs.iterator(); iterator.hasNext();) { Mapping mapping = (Mapping) iterator.next(); String path = mapping.getPath(); String dir = mapping.getDir(); dir = resolveDir(dir, wd); if (this.mappings == null) { this.mappings = new MultiHashMap(); this.pathPriority = new ArrayList(); } if (!this.pathPriority.contains(path)) { this.pathPriority.add(path); } this.mappings.put(path, dir); } }
From source file:com.cyclopsgroup.waterview.navigator.impl.DefaultNavigatorService.java
/** * Overwrite or implement method in DefaultNavigatorHome * * @see org.apache.avalon.framework.activity.Initializable#initialize() *///w ww. ja va2 s. c o m public void initialize() throws Exception { pathIndex = new Hashtable(); parentPathIndex = new MultiHashMap(); pageIndex = new Hashtable(); rootNode = new DefaultNavigatorNode(this, "/", null); rootNode.getAttributes().set(DefaultNavigatorNode.PAGE_NAME, "/Index.jelly"); rootNode.getAttributes().set(DefaultNavigatorNode.TITLE_NAME, "%waterview.navigation.start"); addNode(rootNode); JellyContext jc = new JellyContext(); jc.setVariable(DefaultNavigatorService.class.getName(), this); jc.registerTagLibrary("http://waterview.cyclopsgroup.com/navigator", new NavigatorTagLibrary()); for (Enumeration en = getClass().getClassLoader().getResources(path); en.hasMoreElements();) { URL resource = (URL) en.nextElement(); getLogger().info("Reading navigation from " + resource); jc.runScript(resource, XMLOutput.createDummyXMLOutput()); } populateNode(rootNode); }
From source file:edu.uci.ics.jung.graph.impl.BipartiteGraph.java
/** * Creates a one-part graph from a bipartite graph by folding * Vertices from one class into a second class. This function * creates a new UndirectedGraph (with vertex set V') in which: <br> * <ul>//from w w w.j a v a 2 s.c o m * <li> each vertex in V' has an equivalent V in bpg.getAllVertices( class ) </li> * <li> an edge E' joins V'1 and V'2 iff there is a path of length 2 from * V1 to V2 (by way of some third vertex in the other class, VXs) </li> * <li> each edge E' is annotated with the set of vertices VXs </li> * </ul> * * In social network analysis and related fields, this operation transforms * an actor-by-event chart into an actor-by-actor chart. * * @param bpg The bipartite graph to be folded * @param vertexSet Chooses the set of vertices to be brought into * the new Graph. * @return an UndirectedSparseGraph. */ public static Graph fold(BipartiteGraph bpg, Choice vertexSet) { Graph newGraph = new UndirectedSparseGraph(); Set vertices = bpg.getAllVertices(vertexSet); for (Iterator iter = vertices.iterator(); iter.hasNext();) { BipartiteVertex v = (BipartiteVertex) iter.next(); v.copy(newGraph); } Set coveredNodes = new HashSet(); for (Iterator iter = vertices.iterator(); iter.hasNext();) { BipartiteVertex v = (BipartiteVertex) iter.next(); coveredNodes.add(v); // the set of all Bs that touch this A Set hyperEdges = v.getNeighbors(); // this will ultimately contain a mapping from // the next adjacent "A" to the list of "B"s that support that // connection (that is, all Bs that run between this A and its neighbor MultiMap mm = new MultiHashMap(); for (Iterator iterator = hyperEdges.iterator(); iterator.hasNext();) { Vertex hyperEdge = (Vertex) iterator.next(); addAll(mm, hyperEdge.getNeighbors(), hyperEdge); } for (Iterator iterator = mm.keySet().iterator(); iterator.hasNext();) { Vertex aVertex = (Vertex) iterator.next(); if (coveredNodes.contains(aVertex)) continue; Edge newEdge = GraphUtils.addEdge(newGraph, (Vertex) v.getEqualVertex(newGraph), (Vertex) aVertex.getEqualVertex(newGraph)); newEdge.addUserDatum(BIPARTITE_USER_TAG, mm.get(aVertex), UserData.SHARED); } } return newGraph; }
From source file:com.manydesigns.portofino.pageactions.AbstractPageAction.java
public MultiMap initEmbeddedPageActions() { if (embeddedPageActions == null) { MultiMap mm = new MultiHashMap(); Layout layout = pageInstance.getLayout(); for (ChildPage childPage : layout.getChildPages()) { String layoutContainerInParent = childPage.getContainer(); if (layoutContainerInParent != null) { String newPath = context.getActionPath() + "/" + childPage.getName(); File pageDir = new File(pageInstance.getChildrenDirectory(), childPage.getName()); try { Page page = DispatcherLogic.getPage(pageDir); EmbeddedPageAction embeddedPageAction = new EmbeddedPageAction(childPage.getName(), childPage.getActualOrder(), newPath, page); mm.put(layoutContainerInParent, embeddedPageAction); } catch (PageNotActiveException e) { logger.warn("Embedded page action is not active, skipping! " + pageDir, e); }/*from www . j a v a2 s . co m*/ } } for (Object entryObj : mm.entrySet()) { Map.Entry entry = (Map.Entry) entryObj; List pageActionContainer = (List) entry.getValue(); Collections.sort(pageActionContainer); } embeddedPageActions = mm; } return embeddedPageActions; }
From source file:edu.uci.ics.jung.algorithms.blockmodel.GraphCollapser.java
/** * INTERNAL METHOD./* w w w . j a v a 2s . co m*/ * For a set of vertices, finds all the edges connected to them, indexed (in a MultiMap) * to the vertices to which they connect. Thus, in the graph with edges (A-C, A-D, B-C), * with input (A, B), the result will be ( C {A-C, B-C}; D {A-D} ) * @param rootSet * @return */ protected MultiMap findEdgesAndVerticesConnectedToRootSet(Set rootSet) { // now, let's get a candidate set of edges MultiMap vertices_to_edges = new MultiHashMap(); for (Iterator iter = rootSet.iterator(); iter.hasNext();) { Vertex v = (Vertex) iter.next(); for (Iterator iterator = v.getIncidentEdges().iterator(); iterator.hasNext();) { Edge e = (Edge) iterator.next(); Vertex other = e.getOpposite(v); if (rootSet.contains(other)) continue; vertices_to_edges.put(other, e); } } return vertices_to_edges; }
From source file:com.krawler.workflow.bizservice.WorkflowServiceImpl.java
public String importWorkflow(String processid) throws ServiceException { String result = "{\"success\":false}"; try {/*from w w w . j a v a 2s . co m*/ DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance(); DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder(); String path = ConfigReader.getinstance().get("workflowpath") + processid; File fdir = new File(path); File file = new File(fdir + System.getProperty("file.separator") + "bpmn.xml"); Document doc = docBuilder.parse(file); int s; int a; String name = ""; ObjectInfo obj = new ObjectInfo(); HashMap<String, ObjectInfo> activityHm = new HashMap<String, ObjectInfo>(); NodeList nodeList = doc.getElementsByTagName("Activity"); for (s = 0; s < nodeList.getLength(); s++) { name = ""; Node node = nodeList.item(s); if (node.getNodeType() == Node.ELEMENT_NODE) { obj = new ObjectInfo(); obj.type = getNodeType(node); getNodeInfo(node, obj); if (obj.type.equals("activity")) { Node graphicsInfoNode = getActivityNode(node, 1); getGraphicsNodeInfo(graphicsInfoNode, obj); } activityHm.put(obj.objId, obj); } } NodeList transitionList = doc.getElementsByTagName("Transitions"); String fromId = ""; String toId = ""; ObjectInfo fromObj; ObjectInfo toObj; ObjectInfo tempObj; JSONObject jobj; JSONObject jtemp = new com.krawler.utils.json.base.JSONObject(); HashMap<String, String> fromConditionHm = new HashMap<String, String>(); MultiMap toConditionHm = new MultiHashMap(); for (int i = 0; i < transitionList.getLength(); i++) { Node node = transitionList.item(i); NodeList childrenList = node.getChildNodes(); for (int cnt = 0; cnt < childrenList.getLength(); cnt++) { node = childrenList.item(cnt); if (node.getNodeType() == Node.ELEMENT_NODE) { NamedNodeMap attr = node.getAttributes(); for (int b = 0; b < attr.getLength(); b++) { Node attribute = attr.item(b); name = attribute.getNodeName(); if (name.compareToIgnoreCase("From") == 0) { fromId = attribute.getNodeValue(); } else if (name.compareToIgnoreCase("To") == 0) { toId = attribute.getNodeValue(); } } fromObj = activityHm.get(fromId); toObj = activityHm.get(toId); if (fromObj.type.equals("start")) { tempObj = new ObjectInfo(); tempObj = activityHm.get(toId); tempObj.hasStart = "true"; activityHm.put(toId, tempObj); continue; } if (toObj.type.equals("end")) { tempObj = new ObjectInfo(); tempObj = activityHm.get(fromId); tempObj.hasEnd = "true"; activityHm.put(fromId, tempObj); continue; } if (fromObj.type.equals("activity") && toObj.type.equals("activity")) { jobj = new com.krawler.utils.json.base.JSONObject(); jobj.put("fromId", "flowPanel" + fromId); jobj.put("toId", "flowPanel" + toId); jtemp.append("Lines", jobj); tempObj = new ObjectInfo(); tempObj = activityHm.get(fromId); tempObj.derivationRule = "sequence"; activityHm.put(fromId, tempObj); continue; } if (fromObj.type.equals("activity") && toObj.type.equals("condition")) { fromConditionHm.put(toId, fromId); tempObj = new ObjectInfo(); tempObj = activityHm.get(fromId); tempObj.derivationRule = "evaluation"; activityHm.put(fromId, tempObj); continue; } if (fromObj.type.equals("condition") && toObj.type.equals("activity")) { toConditionHm.put(fromId, toId); continue; } } } } Set keys = activityHm.keySet(); Iterator ite = keys.iterator(); while (ite.hasNext()) { String key = (String) ite.next(); obj = new ObjectInfo(); obj = activityHm.get(key); if (obj.type.equals("activity")) { jobj = new com.krawler.utils.json.base.JSONObject(); jobj.put("Id", "flowPanel" + obj.objId); jobj.put("name", obj.name); jobj.put("xpos", obj.xpos); jobj.put("ypos", obj.ypos); jobj.put("height", obj.height); jobj.put("width", obj.width); jobj.put("parent", obj.parentId); jobj.put("refId", obj.refId); jobj.put("hasStart", obj.hasStart); jobj.put("hasEnd", obj.hasEnd); jobj.put("startRefId", obj.startRefId); jobj.put("endRefId", obj.endRefId); jobj.put("derivationRule", obj.derivationRule); jobj.put("domEl", obj.domEl); jtemp.append("data", jobj); } } keys = fromConditionHm.keySet(); ite = keys.iterator(); Iterator ite1 = null; String key = ""; while (ite.hasNext()) { key = (String) ite.next(); fromId = fromConditionHm.get(key); List toList = (List) toConditionHm.get(key); ite1 = toList.iterator(); while (ite1.hasNext()) { toId = (String) ite1.next(); jobj = new com.krawler.utils.json.base.JSONObject(); jobj.put("fromId", "flowPanel" + fromId); jobj.put("toId", "flowPanel" + toId); jtemp.append("Lines", jobj); } } return jtemp.toString(); } catch (ParserConfigurationException ex) { logger.warn(ex.getMessage(), ex); result = "{\"success\":false}"; throw ServiceException.FAILURE("workflow.reloadWorkflow", ex); } catch (SAXException ex) { logger.warn(ex.getMessage(), ex); result = "{\"success\":false}"; throw ServiceException.FAILURE("workflow.reloadWorkflow", ex); } catch (IOException ex) { logger.warn(ex.getMessage(), ex); result = "{\"success\":false}"; throw ServiceException.FAILURE("workflow.reloadWorkflow", ex); } catch (JSONException ex) { logger.warn(ex.getMessage(), ex); result = "{\"success\":false}"; throw ServiceException.FAILURE("workflow.reloadWorkflow", ex); } }