List of usage examples for java.util Hashtable get
@SuppressWarnings("unchecked") public synchronized V get(Object key)
From source file:hk.hku.cecid.edi.as2.admin.listener.PartnershipPageletAdaptor.java
protected Source getCenterSource(HttpServletRequest request) { PropertyTree dom = new PropertyTree(); dom.setProperty("/partnerships", ""); dom.setProperty("add_partnership/", ""); try {/*w ww .j a va2s .c o m*/ boolean isMultipart = FileUpload.isMultipartContent(request); if (isMultipart) { Hashtable ht = getHashtable(request); String selectedPartnershipId = null; if (((String) ht.get("request_action")).equalsIgnoreCase("change")) { selectedPartnershipId = (String) ht.get("selected_partnership_id"); } else { selectedPartnershipId = (String) ht.get("partnership_id"); updatePartnership(ht, request, dom); } getSelectedPartnership(selectedPartnershipId, dom); } getAllPartnerships(dom); } catch (Exception e) { AS2PlusProcessor.getInstance().getLogger().debug("Unable to process the partnership page request", e); throw new RuntimeException("Unable to process the partnership page request", e); } return dom.getSource(); }
From source file:eionet.gdem.utils.InputFile.java
/** * Get Host credentials from database. There could be restriction for accessing files in different servers. Username and * password are saved in the T_HOST table for these cases. * * @param host URL./*from www .ja va2s. c o m*/ */ private void getHostCredentials(String host) { try { Vector v = hostDao.getHosts(host); if (v == null) { return; } if (v.size() > 0) { Hashtable h = (Hashtable) v.get(0); String user = (String) h.get("user_name"); String pwd = (String) h.get("pwd"); this.ticket = Utils.getEncodedAuthentication(user, pwd); } } catch (Exception e) { LOGGER.error("Error getting host data from the DB " + e.toString()); LOGGER.error("Conversion proceeded"); } }
From source file:com.hybris.mobile.adapter.FormAdapter.java
private boolean isLastEditText(int position) { for (int i = position + 1; i < objects.size(); i++) { @SuppressWarnings("unchecked") Hashtable<String, Object> map = (Hashtable<String, Object>) objects.get(i); String cellId = map.get("cellIdentifier").toString(); if (HYFormTextEntryCell.class.getName().endsWith(cellId) || HYFormSecureTextEntryCell.class.getName().endsWith(cellId)) { return false; }//from ww w . j a va 2 s . co m } return true; }
From source file:eionet.gdem.conversion.odf.OdsReader.java
@Override public String getXMLSchema() { String ret = null;/*from w ww. j a v a 2 s. co m*/ Hashtable usermetadata = metadata.getUserDefined(); if (usermetadata.containsKey(SCHEMA_ATTR_NAME)) { ret = (String) usermetadata.get(SCHEMA_ATTR_NAME); } return ret; }
From source file:com.modeln.build.ctrl.charts.CMnChartFormatter.java
private void formatChart(CategoryPlot plot, CategoryDataset dataset, Hashtable colormap) { BarRenderer renderer = (BarRenderer) plot.getRenderer(); Enumeration keys = colormap.keys(); while (keys.hasMoreElements()) { // Map the metric name to a series number String name = (String) keys.nextElement(); int series = dataset.getRowIndex(name); // Select the color that corresponds to the current name Color color = (Color) colormap.get(name); if (color == null) { color = DEFAULT_COLOR;/*from w w w . j av a 2s .co m*/ } // Set the color for the current series as long as it is a valid series if (series >= 0) { renderer.setSeriesPaint(series, color); } } }
From source file:com.adito.agent.client.tunneling.TunnelInactivityMonitor.java
public void run() { // #ifdef DEBUG log.info("Starting tunnel inactivity monitor (tunnels " + new Integer(vpnClient.getConfiguration().getTunnelInactivity()) + "ms, web forwards " + new Integer(vpnClient.getConfiguration().getWebForwardInactivity()) + "ms)"); // #endif// w ww . j a v a 2s . co m while (true) { try { Thread.sleep(30000); if (vpnClient.getState() == Agent.STATE_DISCONNECTED) { break; } // #ifdef DEBUG log.info("Checking for tunnel inactivity"); //$NON-NLS-1$ // #endif // Hack to allow MSJVM access to the protected member Hashtable activeListeners = vpnClient.getTunnelManager().getActiveLocalTunnels(); synchronized (activeListeners) { long now = System.currentTimeMillis(); for (Enumeration e = activeListeners.keys(); e.hasMoreElements();) { Integer id = (Integer) e.nextElement(); LocalTunnelServer l = (LocalTunnelServer) activeListeners.get(id); try { if (l.isListening()) { // Temporary single connect tunnels and // permanent tunnels if (vpnClient.getConfiguration().getTunnelInactivity() != 0 && l.getTunnel().isPermanent()) { if (now > (l.getDataLastTransferredTime() + vpnClient.getConfiguration().getTunnelInactivity())) { // #ifdef DEBUG log.info("Permanent tunnel " + id + " is out of date, closing."); //$NON-NLS-1$ // #endif vpnClient.getTunnelManager().stopLocalTunnel(l.getId()); } } // Temporary tunnels that allow multiple // connections (i.e. // web forwards) else if (vpnClient.getConfiguration().getWebForwardInactivity() != 0 && !l.getTunnel().isPermanent()) { if (now > (l.getDataLastTransferredTime() + vpnClient.getConfiguration().getWebForwardInactivity())) { // #ifdef DEBUG log.info("Temporary tunnel " + id + " is out of date, closing."); //$NON-NLS-1$ // #endif vpnClient.getTunnelManager().stopLocalTunnel(l.getId()); } } } } catch (Throwable t) { // #ifdef DEBUG log.error("Failed to check state of tunnel " + id, t); //$NON-NLS-1$ // #endif } } } } catch (Throwable t) { // #ifdef DEBUG log.error("Failed to check state of tunnels", t); //$NON-NLS-1$ // #endif } } // #ifdef DEBUG log.error("Disconnected, so stopping tunnel inactivity monitor."); //$NON-NLS-1$ // #endif }
From source file:com.hybris.mobile.activity.AbstractProductDetailActivity.java
/** * Show an image in a new activity//from www.j a v a 2 s .c o m * * @param position * the index of the image */ private void viewImage(int position) { Intent viewImage = new Intent(this, ImageZoomActivity.class); Hashtable<String, String> urls = mProduct.getGalleryImageURLs().get(position); viewImage.putExtra("url", urls.get("zoom")); startActivity(viewImage); }
From source file:com.seer.datacruncher.profiler.spring.ProfilerInfoUpdateController.java
public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { ServletOutputStream out = null;/*from www . j a v a 2 s .c o m*/ response.setContentType("application/json"); out = response.getOutputStream(); @SuppressWarnings("unchecked") Hashtable<String, String> dbParams = (Hashtable<String, String>) request.getSession(true) .getAttribute("dbConnectionData"); if (dbParams != null) { request.setAttribute("serverName", CommonUtil.notNullValue(dbParams.get("Database_DSN"))); } String selectedValue = CommonUtil.notNullValue(request.getParameter("selectedValue")); request.setAttribute("selectedValue", selectedValue); String tableName = CommonUtil.notNullValue(request.getParameter("parent")); request.setAttribute("parentValue", tableName); ObjectMapper mapper = new ObjectMapper(); Vector vector = RdbmsConnection.getTable(); int i = vector.indexOf(tableName); Vector avector[] = (Vector[]) null; avector = TableMetaInfo.populateTable(5, i, i + 1, avector); QueryDialog querydialog = new QueryDialog(1, tableName, avector); try { querydialog.executeAction(""); } catch (Exception e) { e.printStackTrace(); } String strColumnName = ""; List<String> listPrimaryKeys = new ArrayList<String>(); Map<String, Integer> mapColumnNames = new HashMap<String, Integer>(); try { RdbmsConnection.openConn(); DatabaseMetaData dbmd = RdbmsConnection.getMetaData(); ResultSet resultset = dbmd.getPrimaryKeys(null, null, tableName); while (resultset.next()) { listPrimaryKeys.add(resultset.getString("COLUMN_NAME")); } resultset = dbmd.getColumns(null, null, tableName, null); while (resultset.next()) { strColumnName = resultset.getString(4); mapColumnNames.put(strColumnName, resultset.getInt(5)); } RdbmsConnection.closeConn(); } catch (Exception ex) { ex.printStackTrace(); } Map<String, Integer> mapPrimaryKeys = new HashMap<String, Integer>(); if (strColumnName.trim().length() > 0) { try { JSONArray array = new JSONArray(request.getParameter("data")); for (int count = 0; count < array.length(); count++) { JSONObject jsonObject = new JSONObject(array.get(count).toString()); StringBuilder queryString = new StringBuilder(); Iterator<String> keyIterator = jsonObject.keys(); while (keyIterator.hasNext()) { String strKey = keyIterator.next(); if (listPrimaryKeys.contains(strKey)) { mapPrimaryKeys.put(strKey, ((int) Double.parseDouble(jsonObject.get(strKey).toString()))); continue; } if (jsonObject.get(strKey) != null) { if (mapColumnNames.get(strKey) == 4 || mapColumnNames.get(strKey) == 5 || mapColumnNames.get(strKey) == -6) { queryString.append( strKey + "=" + Integer.parseInt(jsonObject.get(strKey).toString()) + ","); } else if (mapColumnNames.get(strKey) == 2 || mapColumnNames.get(strKey) == 3 || mapColumnNames.get(strKey) == 7 || mapColumnNames.get(strKey) == 6 || mapColumnNames.get(strKey) == -5) { queryString.append(strKey + "=" + jsonObject.get(strKey) + ","); } else if (mapColumnNames.get(strKey) == 91 || mapColumnNames.get(strKey) == 92 || mapColumnNames.get(strKey) == 93) { queryString.append(strKey + "=" + jsonObject.get(strKey) + ","); } else if (mapColumnNames.get(strKey) == -7 || mapColumnNames.get(strKey) == 16 || mapColumnNames.get(strKey) == -3 || mapColumnNames.get(strKey) == -4) { queryString.append(strKey + "=" + jsonObject.get(strKey) + ","); } else if (mapColumnNames.get(strKey) == -1 || mapColumnNames.get(strKey) == 1 || mapColumnNames.get(strKey) == 12) { queryString.append(strKey + "=\"" + jsonObject.get(strKey) + "\","); } } } StringBuilder whereClause = new StringBuilder(" where "); for (String primaryKey : listPrimaryKeys) { whereClause.append(primaryKey + "=" + mapPrimaryKeys.get(primaryKey).intValue()); whereClause.append(" and "); } String strWhereClause = whereClause.toString(); strWhereClause = strWhereClause.substring(0, strWhereClause.lastIndexOf("and")); queryString = new StringBuilder("UPDATE " + tableName + " SET ") .append(queryString.toString().substring(0, queryString.toString().length() - 1)); queryString.append(strWhereClause); RdbmsConnection.openConn(); RdbmsConnection.executeUpdate(queryString.toString()); RdbmsConnection.closeConn(); } } catch (Exception ex) { ex.printStackTrace(); } } Update update = new Update(); update.setSuccess(true); GridUtil gridUtil = new GridUtil(); gridUtil.generateGridData(querydialog.getTableGridDTO(), false, null); update.setResults(gridUtil.getData()); out.write(mapper.writeValueAsBytes(update)); out.flush(); out.close(); return null; }
From source file:net.sourceforge.floggy.persistence.fr2422928.FR2422928MigrationTest.java
/** * DOCUMENT ME!/*from w w w. j av a2 s. c o m*/ * * @throws Exception DOCUMENT ME! */ public void testNewField() throws Exception { MigrationManager um = MigrationManager.getInstance(); Enumeration enumeration = um.start(FR2422928.class, null); try { while (enumeration.hasMoreElements()) { Hashtable data = (Hashtable) enumeration.nextElement(); assertFalse("Should not be empty!", data.isEmpty()); assertNull(data.get("node")); } } finally { um.finish(FR2422928.class); } }
From source file:edu.stanford.cfuller.imageanalysistools.filter.WatershedFilter.java
/** * Applies the WatershedFilter to the specified Image, segmenting it. * @param im The Image to be segmented. *//*from w w w . ja v a 2s . co m*/ @Override public void apply(WritableImage im) { WritableImage imCopy = ImageFactory.createWritable(im); InversionFilter invf = new InversionFilter(); invf.apply(imCopy); Histogram h = new Histogram(imCopy); java.util.Hashtable<Double, java.util.Vector<Vector3D>> greylevelLookup = new Hashtable<Double, java.util.Vector<Vector3D>>(); for (ImageCoordinate ic : imCopy) { double value = imCopy.getValue(ic); if (greylevelLookup.get(value) == null) { greylevelLookup.put(value, new java.util.Vector<Vector3D>()); } greylevelLookup.get(value).add( new Vector3D(ic.get(ImageCoordinate.X), ic.get(ImageCoordinate.Y), ic.get(ImageCoordinate.Z))); } WritableImage processing = getSeedImage(greylevelLookup, imCopy, h); Histogram hSeed = new Histogram(processing); int nextLabel = hSeed.getMaxValue() + 1; ImageCoordinate ic = ImageCoordinate.createCoordXYZCT(0, 0, 0, 0, 0); for (int i = h.getMinValue() + 1; i < h.getMaxValue(); i++) { //java.util.logging.Logger.getLogger("edu.stanford.cfuller.imageanalysistools").info("processing greylevel: " + i); if (h.getCounts(i) == 0) continue; for (Vector3D v : greylevelLookup.get((double) i)) { int x = (int) v.getX(); int y = (int) v.getY(); int z = (int) v.getZ(); ic.set(ImageCoordinate.X, x); ic.set(ImageCoordinate.Y, y); ic.set(ImageCoordinate.Z, z); int label = getCorrectLabel(ic, processing, nextLabel); processing.setValue(ic, label); if (label == nextLabel) nextLabel++; } } ic.recycle(); MaskFilter mf = new MaskFilter(); mf.setReferenceImage(processing); mf.apply(im); LabelFilter lf = new LabelFilter(); lf.apply(im); }