List of usage examples for org.apache.commons.collections.map MultiValueMap getCollection
public Collection getCollection(Object key)
From source file:gda.hrpd.data.ExcelReader.java
/** * @param args/* w w w. ja v a 2 s .c om*/ */ public static void main(String[] args) { System.out.println("testing Excel file reading...."); ExcelReader er; try { er = new ExcelReader(); MultiValueMap sampleData = er.getMvm(); for (int i = 0; i < sampleData.size(); i++) { Collection<?> list = sampleData.getCollection(i); for (Object o : list) { System.out.print(o + "\t"); } System.out.println(); } // for (Object o : sampleData.keySet()) { // System.out.println(sampleData.size(o)); // Collection sample = sampleData.getCollection(o); // System.out.println(sample.size()); // for (Iterator it=sample.iterator(); it.hasNext();) { // Object element = it.next(); // System.out.print(element.toString() + "\t"); // } // System.out.println(); // } } catch (InstantiationException e) { // TODO Auto-generated catch block e.printStackTrace(); } }
From source file:gda.function.lookup.LookupTable.java
/** * Tests this class/*from w ww . ja v a2s .c o m*/ * * @param args * @throws DeviceException */ public static void main(String[] args) throws DeviceException { System.out.println("testing LookupTable file reading ...."); LookupTable lut = new LookupTable(); // lut.configure("C:\\workspace\\config\\i11-EpicsSimulation\\lookupTables\\Automated_energy_setup.txt"); lut.configure("/scratch/i12workspace/i12-config/lookupTables/tomo/module_lookup_table.txt"); MultiValueMap lum = lut.getLookupMap(); for (Object key : lut.getKeys()) { Collection<?> list = lum.getCollection(key); for (Object o : list) { System.out.print(o + "\t"); } System.out.println(); } lut.getLookupKeys(); }
From source file:com.nextep.designer.dbgm.ui.layout.DiagramLayoutService.java
@SuppressWarnings("unchecked") private static DependencyTree<IDiagramItem> buildTree(IDiagramItem currentItem, List<IDiagramItem> items, List<IDiagramItem> processed, Map<IReference, IDiagramItem> refMap, MultiValueMap invRefMap) { processed.add(currentItem);/*ww w . ja va2 s. com*/ // Our item node DependencyTree<IDiagramItem> tree = new DependencyTree<IDiagramItem>(currentItem); // Assuming table items final IBasicTable table = (IBasicTable) currentItem.getItemModel(); Collection<IReferencer> dependencies = invRefMap.getCollection(table.getReference()); if (dependencies == null) { dependencies = Collections.emptyList(); } for (IReferencer r : dependencies) { if (r instanceof IBasicTable) { final IDiagramItem depItem = refMap.get(((IBasicTable) r).getReference()); // If our dependency is in our set and is not processed we build the sub Tree if (items.contains(depItem) && !processed.contains(depItem)) { // Recursively processing sub item tree.addChild(buildTree(depItem, items, processed, refMap, invRefMap)); } } } // Child dependencies Collection<IReference> refDependencies = VersionHelper.getVersionable(table).getReferenceDependencies(); for (IReference r : refDependencies) { IReferenceable item = VersionHelper.getReferencedItem(r); if (item instanceof IBasicTable) { final IDiagramItem depItem = refMap.get(((IBasicTable) item).getReference()); // If our dependency is in our set and is not processed we build the sub Tree if (items.contains(depItem) && !processed.contains(depItem)) { // Recursively processing sub item tree.addChild(buildTree(depItem, items, processed, refMap, invRefMap)); } } } // Returning return tree; }
From source file:net.landora.video.infopanel.VideoInfoPanel.java
@Override public boolean supportsContext(MultiValueMap context) { Collection col = context.getCollection(VideoMetadata.class); return col != null && col.size() == 1; }
From source file:com.nextep.designer.vcs.ui.jface.DependenciesContentProvider.java
@SuppressWarnings("unchecked") @Override//from w w w .j a v a 2 s . co m public Object[] getChildren(Object parentElement) { if (request == null) { return null; } if (parentElement instanceof IDependencySearchRequest) { return new Object[] { ((IDependencySearchRequest) parentElement).getElement() }; } else if (parentElement instanceof ITypedNode) { return ((ITypedNode) parentElement).getChildren().toArray(); } else { if (request.getRequestType() == DependencyMode.OBJECTS_DEPENDENT_OF && parentElement instanceof IReferenceable) { MultiValueMap invRefMap = request.getReverseDependenciesMap(); Collection<?> dependencies = invRefMap .getCollection(((IReferenceable) parentElement).getReference()); if (dependencies != null) { return TypedNode.buildNodesFromCollection((ITypedObject) parentElement, (Collection<ITypedObject>) dependencies, null).toArray(); } } else if (request.getRequestType() == DependencyMode.DIRECT_DEPENDENCIES && parentElement instanceof IReferencer) { final IReferencer referencer = (IReferencer) parentElement; final Collection<IReference> references = referencer.getReferenceDependencies(); final Collection<ITypedObject> referencedElts = new LinkedList<ITypedObject>(); for (IReference r : references) { try { final IReferenceable referenced = VersionHelper.getReferencedItem(r); if (referenced instanceof ITypedObject) { referencedElts.add((ITypedObject) referenced); } } catch (UnresolvedItemException e) { LOGGER.error("Unresolved dependencies found on reference " + r.toString(), e); } } return TypedNode.buildNodesFromCollection((ITypedObject) parentElement, (Collection<ITypedObject>) referencedElts, null).toArray(); } } return null; }
From source file:net.landora.video.infopanel.VideoInfoPanel.java
@Override public void loadContext(MultiValueMap context) { Collection col = context.getCollection(VideoMetadata.class); VideoMetadata md = (VideoMetadata) UIUtils.select(col); byte[] data = md.getPosterImage(); if (data == null) { lblPicture.setIcon(null);/*from w w w .j a v a 2 s . c o m*/ } else { try { Image img = ImageIO.read(new ByteArrayInputStream(data)); lblPicture.setIcon(new ImageIcon(img)); } catch (IOException ex) { lblPicture.setIcon(null); LoggerFactory.getLogger(getClass()).warn("Error loading image.", ex); } } Map<String, String> values = md.getAllInformation(false); StringBuilder buffer = new StringBuilder(); buffer.append("<html>"); Font font = lblPicture.getFont(); buffer.append("<head>"); buffer.append("<style type=\"text/css\">"); buffer.append(" { margin-top: 0px; margin-bottom: 0px; margin-right: 0px; margin-left: 0px; }"); buffer.append("table { border-collapse:collapse; }"); buffer.append(" td { "); buffer.append(" font-family: \""); buffer.append(font.getFamily()); buffer.append("\"; font-size: "); buffer.append(font.getSize() - 2); buffer.append("px; "); buffer.append(" }\n"); buffer.append(" td.label { "); buffer.append("text-align: right; "); buffer.append("font-weight:bold; "); buffer.append("white-space:nowrap; "); buffer.append(" font-family: \""); buffer.append(font.getFamily()); buffer.append("\"; font-size: "); buffer.append(font.getSize() - 2); buffer.append("px; "); buffer.append("} "); buffer.append("</style>"); buffer.append("</head>"); buffer.append("<body>"); buffer.append("<table>"); boolean first = true; for (Map.Entry<String, String> entry : values.entrySet()) { buffer.append("<tr><td class=\"label\">"); buffer.append(StringEscapeUtils.escapeHtml(entry.getKey())); buffer.append("</td><td>"); buffer.append(StringEscapeUtils.escapeHtml(entry.getValue())); buffer.append("</td></tr>"); } buffer.append("</table>"); buffer.append("</body>"); buffer.append("</html>"); txtInfo.setContentType("text/html"); txtInfo.setText(buffer.toString()); }
From source file:com.nextep.designer.dbgm.ui.handlers.DependencyDiagramHandler.java
private void fillDiagramReverseDependencyItems(IDiagram diagram, MultiValueMap invRefMap, IReferenceable element, Set<IReference> addedReferences) { addDiagramItem(diagram, element);/*from ww w. j ava2 s . c om*/ addedReferences.add(element.getReference()); Collection<IReferenceable> dependencies = invRefMap.getCollection(element.getReference()); if (dependencies != null) { for (IReferenceable r : dependencies) { if (!addedReferences.contains(r.getReference())) { fillDiagramReverseDependencyItems(diagram, invRefMap, r, addedReferences); } } } }
From source file:net.firejack.platform.core.store.registry.resource.CollectionStore.java
private void checkCycle(MultiValueMap map, Long currentId, Long srcId) { if (map.containsKey(currentId)) { List collections = (List) map.getCollection(currentId); if (collections.contains(srcId)) { throw new BusinessFunctionException("Exist cycle collections"); } else {// ww w . j a v a 2 s .c o m for (Object collection : collections) { checkCycle(map, (Long) collection, srcId); } } } }
From source file:net.landora.video.ui.UIAddon.java
public JPopupMenu createPopupMenu(Collection<?> context) { MultiValueMap valuesByClass = UIUtils.createCompleteContextByClass(context); List<UIAction<?>> actionsToUse = new ArrayList(); for (UIAction<?> action : actions) { Class<?> clazz = action.getRequiredClass(); Collection<?> col = valuesByClass.getCollection(clazz); if (col == null || col.isEmpty()) { continue; }//from w w w. j a v a 2s.com if (action.isMultipuleObjectSupport() || col.size() == 1) { actionsToUse.add(action); } } if (actionsToUse.isEmpty()) { return null; } JPopupMenu menu = new JPopupMenu(); for (UIAction<?> action : actionsToUse) { JMenuItem item = new JMenuItem(action.getName()); item.addActionListener( new UIActionAction(action, valuesByClass.getCollection(action.getRequiredClass()))); menu.add(item); } return menu; }
From source file:com.nextep.designer.synch.ui.jface.ComparisonItemContentProvider.java
@SuppressWarnings("unchecked") private Collection<ICategorizedType> getHashedItemTypes(Collection<IComparisonItem> items) { List<ICategorizedType> categories = new ArrayList<ICategorizedType>(); MultiValueMap itemsTypeMap = new MultiValueMap(); for (IComparisonItem item : items) { itemsTypeMap.put(item.getType(), item); }//from w ww. j a va2s .c om for (Object o : itemsTypeMap.keySet()) { final IElementType t = (IElementType) o; final Collection<IComparisonItem> typedItems = itemsTypeMap.getCollection(t); final ICategorizedType category = new CategorizedType(t, typedItems); categories.add(category); } return categories; }