List of usage examples for java.util HashMap values
public Collection<V> values()
From source file:edu.cornell.mannlib.vitro.webapp.web.jsptags.OptionsForPropertyTag.java
public int doStartTag() { try {// ww w . j a va 2s . c om VitroRequest vreq = new VitroRequest((HttpServletRequest) pageContext.getRequest()); WebappDaoFactory wdf = vreq.getWebappDaoFactory(); if (wdf == null) throw new Exception("could not get WebappDaoFactory from request."); Individual subject = wdf.getIndividualDao().getIndividualByURI(getSubjectUri()); if (subject == null) throw new Exception("could not get individual for subject uri " + getSubjectUri()); ObjectProperty objProp = wdf.getObjectPropertyDao().getObjectPropertyByURI(getPredicateUri()); if (objProp == null) throw new Exception("could not get object property for predicate " + getPredicateUri()); List<VClass> vclasses = new ArrayList<VClass>(); vclasses = wdf.getVClassDao().getVClassesForProperty(getPredicateUri(), true); HashMap<String, Individual> indMap = new HashMap<String, Individual>(); for (VClass vclass : vclasses) { for (Individual ind : wdf.getIndividualDao().getIndividualsByVClassURI(vclass.getURI(), -1, -1)) if (!indMap.containsKey(ind.getURI())) indMap.put(ind.getURI(), ind); } List<Individual> individuals = new ArrayList(indMap.values()); List<ObjectPropertyStatement> stmts = subject.getObjectPropertyStatements(); if (stmts == null) throw new Exception("object properties for subject were null"); individuals = removeIndividualsAlreadyInRange(individuals, stmts); Collections.sort(individuals, new compareEnts()); JspWriter out = pageContext.getOut(); int optionsCount = 0; for (Individual ind : individuals) { String uri = ind.getURI(); if (uri != null) { out.print("<option value=\"" + StringEscapeUtils.escapeHtml(uri) + '"'); if (uri.equals(getSelectedUri())) out.print(" selected=\"selected\""); out.print('>'); out.print(StringEscapeUtils.escapeHtml(ind.getName())); out.println("</option>"); ++optionsCount; } } log.trace("added " + optionsCount + " options for object property \"" + getPredicateUri() + "\" in OptionsForPropertyTag.doStartTag()"); } catch (Exception ex) { throw new Error("Error in doStartTag: " + ex.getMessage()); } return SKIP_BODY; }
From source file:org.apache.manifoldcf.authorities.authorities.amazons3.AmazonS3Authority.java
@Override public AuthorizationResponse getAuthorizationResponse(String userName) throws ManifoldCFException { HashMap<String, Set<Grant>> checkUserExists = checkUserExists(userName); if (isUserAvailable(userName, checkUserExists.values())) { return new AuthorizationResponse(new String[] { userName }, AuthorizationResponse.RESPONSE_OK); }/*w w w. j av a 2 s . c o m*/ return RESPONSE_USERNOTFOUND; }
From source file:com.dslr.dashboard.PtpService.java
public void searchForUsbCamera() { boolean deviceFound = false; try {/*from ww w .j a v a 2 s . com*/ if (mUsbDevice == null) { Log.d(TAG, "Ptp service usb device not initialized, search for one"); if (mUsbManager != null) { HashMap<String, UsbDevice> devices = mUsbManager.getDeviceList(); Log.d(TAG, "Found USB devices count: " + devices.size()); Iterator<UsbDevice> iterator = devices.values().iterator(); while (iterator.hasNext()) { UsbDevice usbDevice = iterator.next(); Log.d(TAG, "USB Device: " + usbDevice.getDeviceName() + " Product ID: " + usbDevice.getProductId() + " Vendor ID: " + usbDevice.getVendorId() + " Interface count: " + usbDevice.getInterfaceCount()); for (int i = 0; i < usbDevice.getInterfaceCount(); i++) { UsbInterface intf = usbDevice.getInterface(i); Log.d(TAG, "Interface class: " + intf.getInterfaceClass()); if (intf.getInterfaceClass() == android.hardware.usb.UsbConstants.USB_CLASS_STILL_IMAGE) { //mUsbDevice = usbDevice; Log.d(TAG, "Ptp Service imaging usb device found requesting permission"); mUsbManager.requestPermission(usbDevice, mPermissionIntent); deviceFound = true; break; } } if (deviceFound) break; } } else Log.d(TAG, "USB Manager is unavailable"); } else { Log.d(TAG, "Ptp service usb imaging device already present"); //_usbManager.requestPermission(_usbDevice, mPermissionIntent); } } catch (Exception e) { Log.d(TAG, "PtpService search for USB camrea exception: " + e.getMessage()); } }
From source file:com.nps.micro.MainActivity.java
private void initUsbDevices() { HashMap<String, UsbDevice> deviceList = usbManager.getDeviceList(); Iterator<UsbDevice> deviceIterator = deviceList.values().iterator(); while (deviceIterator.hasNext()) { UsbDevice dev = deviceIterator.next(); if (isExpectedDevice(dev)) { devices.add(dev);// w w w . ja va 2 s. c o m } } if (!devices.isEmpty()) { devicesWithoutPermisions = new ArrayList<UsbDevice>(devices); requestPermisionForDevice(); } else { Log.d(TAG, "Cannot find target USB device"); Dialogs.getUsbDeviceNotFoundDialog(this).show(); } }
From source file:com.espertech.esper.regression.epl.TestPerfNamedWindowSubquery.java
private void sendEvent(String e0, int e1, String e2) { HashMap<String, Object> theEvent = new LinkedHashMap<String, Object>(); theEvent.put("e0", e0); theEvent.put("e1", e1); theEvent.put("e2", e2); if (EventRepresentationEnum.getEngineDefault(epService).isObjectArrayEvent()) { epService.getEPRuntime().sendEvent(theEvent.values().toArray(), "EventSchema"); } else {//from ww w. j av a2 s . c o m epService.getEPRuntime().sendEvent(theEvent, "EventSchema"); } }
From source file:com.ibm.bi.dml.hops.globalopt.GDFEnumOptimizer.java
/** * //from w w w. j a va2 s . c o m * @param plans * @param maxCosts * @throws DMLRuntimeException * @throws DMLUnsupportedOperationException */ private static void pruneSuboptimalPlans(PlanSet plans, double maxCosts) throws DMLRuntimeException, DMLUnsupportedOperationException { //costing of all plans incl containment check for (Plan p : plans.getPlans()) { p.setCosts(costRuntimePlan(p)); } //build and probe for optimal plans (hash-groupby on IPC, min costs) HashMap<InterestingProperties, Plan> probeMap = new HashMap<InterestingProperties, Plan>(); for (Plan p : plans.getPlans()) { //max cost pruning filter (branch-and-bound) if (BRANCH_AND_BOUND_PRUNING && p.getCosts() > maxCosts) { continue; } //plan cost per IPS pruning filter (allow smaller or equal costs) Plan best = probeMap.get(p.getInterestingProperties()); if (best != null && p.getCosts() > best.getCosts()) { continue; } //non-preferred plan pruning filter (allow smaller cost or equal cost and preferred plan) if (PREFERRED_PLAN_SELECTION && best != null && p.getCosts() == best.getCosts() && !p.isPreferredPlan()) { continue; } //add plan as best per IPS probeMap.put(p.getInterestingProperties(), p); } //copy over plans per IPC into one plan set ArrayList<Plan> optimal = new ArrayList<Plan>(probeMap.values()); int sizeBefore = plans.size(); int sizeAfter = optimal.size(); _prunedSuboptimalPlans += (sizeBefore - sizeAfter); LOG.debug("Pruned suboptimal plans: " + sizeBefore + " --> " + sizeAfter); plans.setPlans(optimal); }
From source file:org.apache.hadoop.hive.ql.parse.spark.SparkCompiler.java
@Override protected void setInputFormat(Task<? extends Serializable> task) { if (task instanceof SparkTask) { SparkWork work = ((SparkTask) task).getWork(); List<BaseWork> all = work.getAllWork(); for (BaseWork w : all) { if (w instanceof MapWork) { MapWork mapWork = (MapWork) w; HashMap<String, Operator<? extends OperatorDesc>> opMap = mapWork.getAliasToWork(); if (!opMap.isEmpty()) { for (Operator<? extends OperatorDesc> op : opMap.values()) { setInputFormat(mapWork, op); }/*from w ww. jav a2s.c o m*/ } } } } else if (task instanceof ConditionalTask) { List<Task<? extends Serializable>> listTasks = ((ConditionalTask) task).getListTasks(); for (Task<? extends Serializable> tsk : listTasks) { setInputFormat(tsk); } } if (task.getChildTasks() != null) { for (Task<? extends Serializable> childTask : task.getChildTasks()) { setInputFormat(childTask); } } }
From source file:com.likya.myra.jef.controller.BaseSchedulerController.java
@SuppressWarnings("unchecked") public int getNumOfActiveJobs() { StateName.Enum filterStates[] = { StateName.RUNNING }; HashMap<String, AbstractJobType> abstractJobTypeList = JobQueueOperations.toAbstractJobTypeList(jobQueue); Collection<AbstractJobType> filteredList; int listSize = 0; try {//from www .jav a 2 s .co m filteredList = CollectionUtils.select(abstractJobTypeList.values(), new StateFilter(filterStates).anyPredicate()); listSize = filteredList.size(); } catch (NullPointerException n) { n.printStackTrace(); } // System.err.println("filteredList.size() : " + filteredList.size()); return listSize; }
From source file:de.tudarmstadt.tk.statistics.test.StatsProcessor.java
/** * Determine order of significant differences between models Cf. Eugster, M. * J. A., Hothorn, T., & Leisch, F. (2008). Exploratory and inferential * analysis of benchmark experiments. Retrieved from * http://epub.ub.uni-muenchen.de/4134/ Determine topological ordering of a * DAG of the significance model-pairs. In addition to Eugster et al., we * also check whether relations between topological groups are valid. * * //from w ww . ja v a 2 s. co m * @return a HashMap mapping from levels of the topological ordering to the * models on that level */ private HashMap<Integer, TreeSet<Integer>> calcOrderOfSignificantDifferences( ImprovedDirectedGraph<Integer, DefaultEdge> directedGraph) { // If nodes are on the same level of the graph, they are not // significantly different and form a group // One higher group is significantly different from all lower groups as // a whole (!), if there exists an edge from each element of the higher // group to each element of the lower groups HashMap<Integer, TreeSet<Integer>> ordering = directedGraph.getTopologicalOrder(); int nodesLeft = 0; for (TreeSet<Integer> s : ordering.values()) { nodesLeft += s.size(); } for (int level = 0; level < ordering.keySet().size() - 1; level++) { TreeSet<Integer> nodes = ordering.get(level); nodesLeft -= nodes.size(); for (Integer n : nodes) { if (directedGraph.outDegreeOf(n) != nodesLeft) { // Not a valid ordering return null; } } } return ordering; }
From source file:at.tugraz.ist.catroid.test.content.XMLValidatingTest.java
@SuppressWarnings("unchecked") public void testSerializeProjectWithAllBricks() throws IllegalArgumentException, IllegalAccessException, InvocationTargetException, IOException, JSONException { File projectDirectory = new File(Consts.DEFAULT_ROOT + "/" + testProjectName); if (projectDirectory.exists()) { UtilFile.deleteDirectory(projectDirectory); }//from w ww . j av a 2 s.c o m Project project = new Project(getContext(), testProjectName); Sprite sprite = new Sprite("testSprite"); Script startScript = new StartScript(sprite); Script whenScript = new WhenScript(sprite); Script broadcastScript = new BroadcastScript(sprite); sprite.addScript(startScript); sprite.addScript(whenScript); sprite.addScript(broadcastScript); project.addSprite(sprite); ProjectManager.getInstance().setProject(project); ProjectManager.getInstance().setCurrentSprite(sprite); ProjectManager.getInstance().setCurrentScript(startScript); Method[] methods = AddBrickDialog.class.getDeclaredMethods(); HashMap<String, List<Brick>> brickMap = null; if (PluginManager.getInstance() == null) { PluginManager.createPluginManager(getContext()); } for (Method method : methods) { if (method.getName().equalsIgnoreCase("setupBrickMap")) { method.setAccessible(true); brickMap = (HashMap<String, List<Brick>>) method.invoke(null, sprite, getContext()); break; } } for (List<Brick> brickList : brickMap.values()) { for (Brick brick : brickList) { startScript.addBrick(brick); } } assertTrue("no bricks added to the start script", startScript.getBrickList().size() > 0); StorageHandler.getInstance().saveProject(project); //TODO adapt for Drone Bricks XMLValidationUtil.sendProjectXMLToServerForValidating(project); }