List of usage examples for java.util Hashtable get
@SuppressWarnings("unchecked") public synchronized V get(Object key)
From source file:edu.ku.brc.specify.utilapps.CreateTextSchema.java
/** * @param tables//w w w .j a v a 2s .co m */ @SuppressWarnings("unchecked") protected void makeTableIndexes(final Vector<DBTableInfo> tables) { po.write(" <tr>\n"); po.write(" <td class=\"hd\" colspan=\"1\">" + UIRegistry.getResourceString("IndexName") + "</td>\n"); po.write( " <td class=\"hd\" colspan=\"1\">" + UIRegistry.getResourceString("ColumnName") + "</td>\n"); po.write(" <td class=\"hd\" colspan=\"1\">" + UIRegistry.getResourceString("Table") + "</td>\n"); po.write(" </tr>\n"); for (DBTableInfo tn : tables) { System.out.println("Indexing " + tn.getName()); Hashtable<String, String> colToTitle = new Hashtable<String, String>(); for (DBFieldInfo fi : tn.getFields()) { colToTitle.put(fi.getColumn(), StringUtils.isNotEmpty(fi.getTitle()) ? fi.getTitle() : fi.getColumn()); } if (tn.getTableIndexMap() != null) { Vector<String> keys = new Vector<String>(tn.getTableIndexMap().keySet()); Collections.sort(keys); for (String key : keys) { String title = colToTitle.get(key); if (StringUtils.isNotEmpty(title)) { title = key; } po.write("<tr>\n"); po.write("<td align=\"center\">"); po.write(tn.getTableIndexMap().get(key)); po.write("</td>\n"); po.write("<td align=\"center\">"); po.write(key); po.write("</td>\n"); po.write("<td align=\"center\">"); //if (!tableName.equals(prevTbl)) //{ po.write(" <a href=\"#" + tn.getName() + "\">"); po.write(tn.getTitle()); po.write("</a>"); //prevTbl = tableName; //} else //{ // po.write(NBSP); //} po.write("</td>\n"); po.write("</tr>\n"); } } } }
From source file:it.okkam.exhibit.JSONSerializer.java
protected JSONObject objectifyResourceProper(Resource resource, boolean root, int depth, Collection visited) throws JSONException { // create the JSON object JSONObject jo = root ? this.createRootObject() : new JSONObject(); // put the id if (resource.isURIResource()) { jo.put(ID, resource.getURI());/*from w w w.j a va 2s . c o m*/ } else if (resource.isAnon()) { jo.put(ID, resource.getId().toString()); } if (!visited.contains(resource)) { visited.add(resource); // build a properties table for the resource Hashtable propsTable = this.buildPropsTable(resource, depth); // handle the properties Enumeration propNames = propsTable.keys(); while (propNames.hasMoreElements()) { String propName = (String) propNames.nextElement(); ArrayList vals = (ArrayList) propsTable.get(propName); if (vals.size() == 1) // handle single value props { RDFNode node = (RDFNode) vals.get(0); if (node.isLiteral()) // handle literal value { jo.put(this.abbrev(propName), this.objectifyLiteral((Literal) node, false)); } else // handle resource value { JSONObject nested = this.objectifyResource((Resource) node, false, depth + 1, visited); jo.put(this.abbrev(propName), nested); } } else if (vals.size() > 1) // handle multi value props { JSONArray array = new JSONArray(); for (int i = 0; i < vals.size(); i++) { RDFNode node = (RDFNode) vals.get(i); if (node.isLiteral()) // handle literal value { array.put(this.objectifyLiteral((Literal) node, false)); } else if (node.isResource()) // handle resource values { JSONObject nested = this.objectifyResource((Resource) node, false, depth + 1, visited); array.put(nested); } } JSONObject valsobj = (new JSONObject()).put(VALUES, array); jo.put(this.abbrev(propName), valsobj); } } } return jo; }
From source file:org.adempiere.webui.dashboard.CalendarWindow.java
private void syncModel() { Hashtable<String, BigDecimal> ht = new Hashtable<String, BigDecimal>(); List<?> list = calendars.getModel().get(calendars.getBeginDate(), calendars.getEndDate(), null); int size = list.size(); for (Iterator<?> it = list.iterator(); it.hasNext();) { String key = ((ADCalendarEvent) it.next()).getR_RequestType_ID() + ""; if (!ht.containsKey(key)) ht.put(key, BigDecimal.ONE); else {//from w w w . j a v a 2s .co m BigDecimal value = ht.get(key); ht.put(key, value.add(BigDecimal.ONE)); } } Hashtable<Object, String> htTypes = new Hashtable<Object, String>(); for (int i = 0; i < lbxRequestTypes.getItemCount(); i++) { Listitem li = lbxRequestTypes.getItemAtIndex(i); if (li != null && li.getValue() != null) htTypes.put(li.getValue(), li.getLabel()); } DefaultPieDataset pieDataset = new DefaultPieDataset(); Enumeration<?> keys = ht.keys(); while (keys.hasMoreElements()) { String key = (String) keys.nextElement(); BigDecimal value = ht.get(key); String name = (String) htTypes.get(key); pieDataset.setValue(name == null ? "" : name, new Double(size > 0 ? value.doubleValue() / size * 100 : 0)); } JFreeChart chart = ChartFactory.createPieChart3D(Msg.getMsg(Env.getCtx(), "EventsAnalysis"), pieDataset, true, true, true); PiePlot3D plot = (PiePlot3D) chart.getPlot(); plot.setForegroundAlpha(0.5f); BufferedImage bi = chart.createBufferedImage(600, 250); try { byte[] bytes = EncoderUtil.encode(bi, ImageFormat.PNG, true); AImage image = new AImage("Pie Chart", bytes); myChart.setContent(image); } catch (IOException e) { e.printStackTrace(); } htTypes = null; ht = null; }
From source file:imapi.IMAPIClass.java
void printSourceInfo(SourceDataHolder sourceInfo) { int counter = 0; Vector<String> fileInstances = new Vector<String>(sourceInfo.keySet()); Collections.sort(fileInstances); //System.out.println("Found " + fileInstances.size() + " instances in all \"\"SOURCE\"\" input files."); for (int i = 0; i < fileInstances.size(); i++) { String filename = fileInstances.get(i); Vector<String> uris = new Vector<String>(sourceInfo.get(filename).keySet()); Collections.sort(uris);// w ww.j a v a2 s. c o m for (int j = 0; j < uris.size(); j++) { counter++; String uri = uris.get(j); SequencesVector allSeqData = sourceInfo.get(filename).get(uri); System.out.println("\r\n" + counter + ". " + uri + "\t\tin source: " + filename); for (int k = 0; k < allSeqData.size(); k++) { SequenceData currentSeq = allSeqData.get(k); System.out .println("\tData found on sequence: " + (currentSeq.getSchemaInfo().getPositionID() + 1) + " mnemonic: " + currentSeq.getSchemaInfo().getMnemonic() + " with weight: " + currentSeq.getSchemaInfo().getWeight()); Hashtable<String, String> parameterTypes = currentSeq.getSchemaInfo() .getAllQueryStepParameters(); String[] parameterNames = currentSeq.getSchemaInfo().getSortedParameterNamesCopy(); for (int paramStep = 0; paramStep < parameterNames.length; paramStep++) { String paramName = parameterNames[paramStep]; String paramType = parameterTypes.get(paramName); //System.out.println(paramName); //String type //String stepName = currentSeq.getSchemaInfo().getQuerySteps().get(step).getParameterName(); //String type = currentSeq.getSchemaInfo().getQuerySteps().get(step).getParameterType(); Vector<DataRecord> vals = currentSeq.getValuesOfKey(paramName); for (int valIndex = 0; valIndex < vals.size(); valIndex++) { DataRecord rec = vals.get(valIndex); String printStr = "\t\t" + paramName + ": " + paramType + " -->\t" + rec.toString(); System.out.println(printStr); } } } } } }
From source file:edu.ku.brc.specify.rstools.SpAnalysis.java
public void checkCollectors(final TableWriter tblWriter) { Statement stmt = null;//from w w w .j a v a2 s . com try { tblWriter.append("<H3>Collectors</H3>"); tblWriter.startTable(); tblWriter.append( "<TR><TH>AddressID</TH><TH>Address</TH><TH>Address2</TH><TH>City</TH><TH>State</TH><TH>PostalCode</TH><TH>Ids</TH></TR>"); String sql = "SELECT c.CollectingEventID, a.AgentID FROM collector c INNER JOIN agent a ON c.AgentID = a.AgentID ORDER BY c.CollectingEventID ASC, c.OrderNumber ASC"; Hashtable<String, Triple<Integer, Integer, ArrayList<Integer>>> hash = new Hashtable<String, Triple<Integer, Integer, ArrayList<Integer>>>(); StringBuilder sb = new StringBuilder(); Integer ceId = null; Connection conn = DBConnection.getInstance().getConnection(); stmt = conn.createStatement(); ResultSet rs = stmt.executeQuery(sql + " ORDER BY AddressID"); while (rs.next()) { int id = rs.getInt(1); int agentId = rs.getInt(2); if (ceId == null || !ceId.equals(id)) { if (ceId != null) { Pair<Integer, Integer> count = hash.get(sb.toString()); if (count == null) { //hash.put(sb.toString(), new Pair<Integer, Integer>(ceId, 1)); } else { count.second++; } } sb.setLength(0); sb.append(agentId); sb.append(','); ceId = id; } } rs.close(); } catch (Exception ex) { ex.printStackTrace(); } finally { try { if (stmt != null) { stmt.close(); } } catch (Exception ex) { } } tblWriter.endTable(); }
From source file:DDTDate.java
/** * Replenish a single property in the variables map varsMap * @param key//www.j ava 2s .co m * @param value * @param varsMap */ private void maintainDateProperty(String key, Object value, Hashtable<String, Object> varsMap) { String tmp = key.toLowerCase(); // varsMap is maintained in lower case by convention Object oldValue = varsMap.get(tmp); if (oldValue != null) { // Change value in varsMap only if needed. if (oldValue.equals(value)) return; varsMap.remove(tmp); } varsMap.put(tmp, String.valueOf(value)); // Reporting ... @TODO comment out when done testing (thanks) (you are welcome) /* if (oldValue == null) System.out.println(" key " + Util.sq(key) + " set to " + Util.sq(value.toString()) + " in the variables map."); else System.out.println("Old version of key " + Util.sq(key) + " => " + Util.sq(oldValue.toString()) + " reset to " + Util.sq(value.toString()) + " in the variables map."); */ }
From source file:com.netspective.medigy.model.data.EntitySeedDataPopulator.java
protected void populateEntity(final Session session, final Class entityClass, final String[] propertyList, final Object[][] data) throws HibernateException { try {/*from ww w. ja v a2 s.c o m*/ final Hashtable pdsByName = new Hashtable(); final BeanInfo beanInfo = Introspector.getBeanInfo(entityClass); final PropertyDescriptor[] descriptors = beanInfo.getPropertyDescriptors(); for (int i = 0; i < descriptors.length; i++) { final PropertyDescriptor descriptor = descriptors[i]; if (descriptor.getWriteMethod() != null) pdsByName.put(descriptor.getName(), descriptor.getWriteMethod()); } for (int i = 0; i < data.length; i++) { final Object entityObject = entityClass.newInstance(); for (int j = 0; j < propertyList.length; j++) { final Method setter = (Method) pdsByName.get(propertyList[j]); if (setter != null) setter.invoke(entityObject, new Object[] { data[i][j] }); } session.save(entityObject); } } catch (Exception e) { log.error(e); throw new HibernateException(e); } }
From source file:com.alfaariss.oa.engine.user.provisioning.storage.internal.jdbc.JDBCInternalStorage.java
/** * Returns the user object specified by the supplied id. * @see IInternalStorage#getUser(java.lang.String, java.lang.String) *///from ww w . j a v a2 s . c o m public ProvisioningUser getUser(String sOrganization, String id) throws UserException { ProvisioningUser oProvisioningUser = null; try { Boolean boolEnabled = isAccountEnabled(id); if (boolEnabled == null) return null; oProvisioningUser = new ProvisioningUser(sOrganization, id, boolEnabled); Hashtable<String, Boolean> htRegistered = getRegistered(id); Enumeration enumAuthSPIDs = htRegistered.keys(); while (enumAuthSPIDs.hasMoreElements()) { String sID = (String) enumAuthSPIDs.nextElement(); oProvisioningUser.putRegistered(sID, htRegistered.get(sID)); } } catch (UserException e) { throw e; } catch (Exception e) { _logger.fatal("Could not get user with id: " + id, e); throw new UserException(SystemErrors.ERROR_INTERNAL); } return oProvisioningUser; }
From source file:ucar.unidata.idv.control.chart.MyScatterPlot.java
/** * Draws the fast scatter plot on a Java 2D graphics device (such as the * screen or a printer)./*www .ja v a 2 s. c o m*/ * a * @param g2 the graphics device. * @param dataArea the data area * @param index which data set * @param info collects chart drawing information (<code>null</code> * permitted). * @param crosshairState crosshairState * * @return did something */ public boolean render(Graphics2D g2, Rectangle2D dataArea, int index, PlotRenderingInfo info, CrosshairState crosshairState) { if (index >= series.size()) { return false; } XYDataset dataset = getDataset(index); g2.setStroke(new BasicStroke()); // getRendererForDataset(dataset).getSeriesStroke(0)); ScatterPlotChartWrapper.MyRenderer renderer = (ScatterPlotChartWrapper.MyRenderer) getRendererForDataset( dataset); g2.setPaint(renderer.getSeriesPaint(0)); int shape = renderer.shape; PlotOrientation orientation = getOrientation(); int seenCnt = 0; int xx = (int) dataArea.getMinX(); int ww = (int) dataArea.getWidth(); int yy = (int) dataArea.getMaxY(); int hh = (int) dataArea.getHeight(); ValueAxis rangeAxis = getRangeAxisForDataset(index); ValueAxis domainAxis = getDomainAxisForDataset(index); double domainMin = domainAxis.getLowerBound(); double domainLength = domainAxis.getUpperBound() - domainMin; double rangeMin = rangeAxis.getLowerBound(); double rangeLength = rangeAxis.getUpperBound() - rangeMin; int boxWidth = 6; double[][] data = (double[][]) series.get(index); double[] d1 = data[0]; double[] d2 = data[1]; int size = d1.length; Hashtable seen = new Hashtable(); int lastX = 0; int lastY = 0; //TODO: Check for clipping //TODO: Try to create a GeneralPath with the points //and cal g2.draw just once GeneralPath path = new GeneralPath(); long t1 = System.currentTimeMillis(); for (int i = 0; i < size; i++) { int transX = (int) (xx + ww * (d1[i] - domainMin) / domainLength); int transY = (int) (yy - hh * (d2[i] - rangeMin) / rangeLength); Object key = transX + "_" + transY; if (seen.get(key) != null) { seenCnt++; continue; } seen.put(key, key); if (crosshairState != null) { crosshairState.updateCrosshairPoint(d1[i], d2[i], transX, transY, orientation); } switch (shape) { case LineState.SHAPE_VLINE: if (i > 1) { g2.drawLine(lastX, lastY, transX, transY); } lastX = transX; lastY = transY; case LineState.SHAPE_POINT: path.append(new Rectangle((int) transX, (int) transY, 1, 1), false); break; case LineState.SHAPE_LARGEPOINT: path.append(new Rectangle((int) transX, (int) transY, 2, 2), false); break; case LineState.SHAPE_RECTANGLE: path.append( new Rectangle((int) transX - boxWidth / 2, (int) transY - boxWidth / 2, boxWidth, boxWidth), false); break; case LineState.SHAPE_X: g2.drawLine(transX - boxWidth / 2, transY - boxWidth / 2, transX + boxWidth - boxWidth / 2, transY + boxWidth - boxWidth / 2); g2.drawLine(transX + boxWidth - boxWidth / 2, transY - boxWidth / 2, transX - boxWidth / 2, transY + boxWidth - boxWidth / 2); break; case LineState.SHAPE_PLUS: g2.drawLine(transX + boxWidth / 2, transY, transX + boxWidth / 2, transY + boxWidth); g2.drawLine(transX, transY + boxWidth / 2, transX + boxWidth, transY + boxWidth / 2); break; } } g2.fill(path); long t2 = System.currentTimeMillis(); // System.out.println ("time:" + (t2-t1)); return true; }
From source file:com.modeln.build.ctrl.charts.CMnBuildListChart.java
/** * Generate a pie graph representing test counts for each product area. * * @param suites List of test suites * @param areas List of product areas * /* w ww .j a v a 2 s . c o m*/ * @return Pie graph representing build execution times across all builds */ public static final JFreeChart getAverageAreaTestCountChart(Vector<CMnDbBuildData> builds, Vector<CMnDbTestSuite> suites, Vector<CMnDbFeatureOwnerData> areas) { JFreeChart chart = null; // Collect the average of all test types Hashtable countAvg = new Hashtable(); DefaultPieDataset dataset = new DefaultPieDataset(); if ((suites != null) && (suites.size() > 0)) { // Collect test data for each of the suites in the list Enumeration suiteList = suites.elements(); while (suiteList.hasMoreElements()) { // Process the data for the current suite CMnDbTestSuite suite = (CMnDbTestSuite) suiteList.nextElement(); Integer testCount = new Integer(suite.getTestCount()); CMnDbFeatureOwnerData area = null; // Iterate through each product area to determine who owns this suite CMnDbFeatureOwnerData currentArea = null; Iterator iter = areas.iterator(); while (iter.hasNext()) { currentArea = (CMnDbFeatureOwnerData) iter.next(); if (currentArea.hasFeature(suite.getGroupName())) { Integer avgValue = null; String areaName = currentArea.getDisplayName(); if (countAvg.containsKey(areaName)) { Integer oldAvg = (Integer) countAvg.get(areaName); avgValue = oldAvg + testCount; } else { avgValue = testCount; } countAvg.put(areaName, avgValue); } } } // while list has elements // Populate the data set with the average values for each metric Enumeration keys = countAvg.keys(); while (keys.hasMoreElements()) { String key = (String) keys.nextElement(); Integer total = (Integer) countAvg.get(key); Integer avg = new Integer(total.intValue() / builds.size()); dataset.setValue(key, avg); } } // if list has elements // API: ChartFactory.createPieChart(title, data, legend, tooltips, urls) chart = ChartFactory.createPieChart("Avg Test Count by Area", dataset, true, true, false); // get a reference to the plot for further customization... PiePlot plot = (PiePlot) chart.getPlot(); chartFormatter.formatAreaChart(plot, "tests"); return chart; }