List of usage examples for java.util Hashtable get
@SuppressWarnings("unchecked") public synchronized V get(Object key)
From source file:gov.nih.nci.ncicb.cadsr.contexttree.CDEBrowserTree.java
public DefaultMutableTreeNode getTree(Hashtable params) throws Exception { treeType = StringEscapeUtils.escapeHtml((String) params.get("treeType")); functionName = StringEscapeUtils.escapeHtml((String) params.get("functionName")); contextExcludeListStr = StringEscapeUtils .escapeHtml((String) params.get(TreeConstants.BR_CONTEXT_EXCLUDE_LIST_STR)); return buildTree(params); }
From source file:eionet.gdem.dcm.business.ConvTypeManager.java
/** * Get conversion type mappings/* www . j a v a 2 s . c o m*/ * * @param convTypeId * (HTML, XML, ...) * @return * @throws DCMException */ public ConvType getConvType(String convTypeId) throws DCMException { ConvType convType = null; try { Hashtable type = convTypeDao.getConvType(convTypeId); if (type == null) { return null; } convType = new ConvType(); convType.setContType(type.get("content_type") == null ? null : (String) type.get("content_type")); convType.setConvType(type.get("conv_type") == null ? null : (String) type.get("conv_type")); convType.setDescription(type.get("description") == null ? null : (String) type.get("description")); convType.setFileExt(type.get("file_ext") == null ? null : (String) type.get("file_ext")); } catch (Exception e) { e.printStackTrace(); LOGGER.error("Error getting conv types", e); throw new DCMException(BusinessConstants.EXCEPTION_GENERAL); } return convType; }
From source file:javanews.gui.internalframe.LinkChart.java
/** * Updates the data set for both charts with the contents of the supplied * Hashtable. The Hashtable is expected to contain the following items: * <ul>/*from w ww . ja v a 2 s.c o m*/ * <li>down - The number of links currently in a down state</li> * <li>up - The number of links currently in an up state</li> * <li>unknown - The number of links currently in an unknown state</li> * </ul> * @param linkStats The hashtable containing the entries indicating current * link statistics. */ public void updateData(Hashtable<String, Integer> linkStats) { dpdCurrentData.insertValue(0, "Link Down", linkStats.get("down")); dpdCurrentData.insertValue(1, "Link Up", linkStats.get("up")); dpdCurrentData.insertValue(2, "Link State Unknown", linkStats.get("unknown")); dcdPreviousData.addValue(linkStats.get("down"), "Link Down", Calendar.getInstance().getTime().toString()); dcdPreviousData.addValue(linkStats.get("up"), "Link Up", Calendar.getInstance().getTime().toString()); dcdPreviousData.addValue(linkStats.get("unknown"), "Link State Unknown", Calendar.getInstance().getTime().toString()); }
From source file:gov.nih.nci.ncicb.cadsr.contexttree.CDEBrowserTreeCache.java
public void init(BaseTreeNode baseTree, Hashtable treeParams) throws Exception { log.info("Init start" + TimeUtils.getEasternTime()); String contextExcludeListStr = (String) treeParams.get(TreeConstants.BR_CONTEXT_EXCLUDE_LIST_STR); allContextHolders = appServiceLocator.findTreeService().getContextNodeHolders(baseTree, idGen, contextExcludeListStr);/*from w ww. j av a2 s. c o m*/ allTemplatesByContext = appServiceLocator.findTreeService().getAllContextTemplateNodes(baseTree, idGen); List protocolNodes = appServiceLocator.findTreeService().getAllContextProtocolNodes(baseTree, idGen); allFormsWithNoProtocol = (Map) protocolNodes.get(0); allFormsWithProtocol = (Map) protocolNodes.get(1); //create classification nodes allClassificationNodes = appServiceLocator.findTreeService().getAllClassificationNodes(baseTree, idGen); CDEBrowserParams params = CDEBrowserParams.getInstance(); boolean showFormsAlphebetically = new Boolean(params.getShowFormsAlphebetical()).booleanValue(); //creating publishing nodes allPublishingNode = appServiceLocator.findTreeService().getAllPublishingNode(baseTree, idGen, showFormsAlphebetically); //setCtepTemplateCtepNodes(conn,baseTree); log.info("Init end" + TimeUtils.getEasternTime()); }
From source file:eionet.rpcserver.servlets.XmlRpcRouter.java
/** * Standard doPost implementation./*www . ja v a 2s . c om*/ * */ public void doPost(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException { /* System.out.println("============================="); System.out.println("============POST ============"); System.out.println("============================="); */ byte[] result = null; //authorization here! String encoding = null; try { Hashtable<Object, Object> props = UITServiceRoster.loadProperties(); encoding = (String) props.get(UITServiceRoster.PROP_XMLRPC_ENCODING); } catch (Exception e) { } if (encoding != null) { req.setCharacterEncoding(encoding); XmlRpc.setEncoding(encoding); } //get authorization header from request String auth = req.getHeader("Authorization"); if (auth != null) { if (!auth.toUpperCase().startsWith("BASIC")) { throw new ServletException("wrong kind of authorization!"); } //get encoded username and password String userPassEncoded = auth.substring(6); String userPassDecoded = new String(Base64.decodeBase64(userPassEncoded)); //split decoded username and password StringTokenizer userAndPass = new StringTokenizer(userPassDecoded, ":"); String username = userAndPass.nextToken(); String password = userAndPass.nextToken(); result = xmlrpc.execute(req.getInputStream(), username, password); } else { //log("================ 2 "); result = xmlrpc.execute(req.getInputStream()); } res.setContentType("text/xml"); res.setContentLength(result.length); OutputStream output = res.getOutputStream(); output.write(result); output.flush(); //req.getSession().invalidate(); //??????????????? }
From source file:com.apatar.flickr.function.UploadPhotoFlickrTable.java
public List<KeyInsensitiveMap> execute(FlickrNode node, Hashtable<String, Object> values, String strApi, String strSecret) throws IOException, XmlRpcException { byte[] photo = (byte[]) values.get("photo"); int size = values.size() + 2; values.remove("photo"); File newFile = ApplicationData.createFile("flicr", photo); PostMethod post = new PostMethod("http://api.flickr.com/services/upload"); Part[] parts = new Part[size]; parts[0] = new FilePart("photo", newFile); parts[1] = new StringPart("api_key", strApi); int i = 2;//from w w w. ja v a2 s .c o m for (String key : values.keySet()) parts[i++] = new StringPart(key, values.get(key).toString()); values.put("api_key", strApi); parts[i] = new StringPart("api_sig", FlickrUtils.Sign(values, strApi, strSecret)); post.setRequestEntity(new MultipartRequestEntity(parts, post.getParams())); HttpClient client = new HttpClient(); client.getHttpConnectionManager().getParams().setConnectionTimeout(5000); int status = client.executeMethod(post); if (status != HttpStatus.SC_OK) { JOptionPane.showMessageDialog(ApatarUiMain.MAIN_FRAME, "Upload failed, response=" + HttpStatus.getStatusText(status)); return null; } else { InputStream is = post.getResponseBodyAsStream(); try { return createKeyInsensitiveMapFromElement(FlickrUtils.getRootElementFromInputStream(is)); } catch (Exception e) { e.printStackTrace(); } } return null; }
From source file:net.sourceforge.floggy.persistence.fr2422928.FR2422928AbstractVersionTest.java
/** * DOCUMENT ME!/*from w ww.ja va 2 s . co m*/ * * @throws Exception DOCUMENT ME! */ public void testFreezedClassIteration() throws Exception { Hashtable properties = new Hashtable(); properties.put(MigrationManager.MIGRATE_FROM_PREVIOUS_1_3_0_VERSION, Boolean.TRUE); properties.put(MigrationManager.ITERATION_MODE, Boolean.TRUE); Enumeration enumeration = MigrationManager.getInstance().start(Freezed.class, properties); assertEquals(2, enumeration.getSize()); if (enumeration.hasMoreElements()) { Hashtable data = enumeration.nextElement(); assertNull(data.get("uuid")); assertNull(data.get("deadline")); assertNull(data.get("description")); assertNull(data.get("nested")); assertEquals(0, ((Short) data.get("code")).shortValue()); } if (enumeration.hasMoreElements()) { Hashtable data = enumeration.nextElement(); assertEquals(Freezed.UUID, data.get("uuid")); assertEquals(Freezed.DEADLINE, data.get("deadline")); assertEquals(Freezed.DESCRIPTION, data.get("description")); FieldPersistableInfo freezedInfo = (FieldPersistableInfo) data.get("nested"); Freezed nested = new Freezed(); manager.load(nested, freezedInfo.getId()); assertEquals(Freezed.NESTED, nested); assertEquals(Freezed.CODE, ((Short) data.get("code")).shortValue()); } }
From source file:io.pivotal.poc.gemfire.gtx.jndi.SimpleNamingContextBuilder.java
/** * Simple InitialContextFactoryBuilder implementation, * creating a new SimpleNamingContext instance. * @see SimpleNamingContext/*from w ww . jav a 2 s . c o m*/ */ @Override public InitialContextFactory createInitialContextFactory(Hashtable<?, ?> environment) { if (activated == null && environment != null) { Object icf = environment.get(Context.INITIAL_CONTEXT_FACTORY); if (icf != null) { Class<?> icfClass; if (icf instanceof Class) { icfClass = (Class<?>) icf; } else if (icf instanceof String) { icfClass = ClassUtils.resolveClassName((String) icf, getClass().getClassLoader()); } else { throw new IllegalArgumentException("Invalid value type for environment key [" + Context.INITIAL_CONTEXT_FACTORY + "]: " + icf.getClass().getName()); } if (!InitialContextFactory.class.isAssignableFrom(icfClass)) { throw new IllegalArgumentException("Specified class does not implement [" + InitialContextFactory.class.getName() + "]: " + icf); } try { return (InitialContextFactory) icfClass.newInstance(); } catch (Throwable ex) { throw new IllegalStateException("Cannot instantiate specified InitialContextFactory: " + icf, ex); } } } // Default case... return new InitialContextFactory() { @Override @SuppressWarnings("unchecked") public Context getInitialContext(Hashtable<?, ?> environment) { return new SimpleNamingContext("", boundObjects, (Hashtable<String, Object>) environment); } }; }
From source file:com.innate.cresterp.explorer.services.LocationService.java
public List<Company> queryLocalCompanies(final String latitude, final String longitude, final String user, final String radius) { NetworkManager networkManager = NetworkManager.getInstance(); networkManager.start();/*from w w w .jav a 2 s . c om*/ networkManager.addErrorListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { NetworkEvent n = (NetworkEvent) evt; n.getError().printStackTrace(); System.out.println(n.getError()); } }); ConnectionRequest request; request = new ConnectionRequest() { int chr; StringBuffer sb = new StringBuffer(); String response = ""; @Override protected void readResponse(InputStream input) throws IOException { Vector vector = new Vector(); JSONParser parser = new JSONParser(); Hashtable hm = parser.parse(new InputStreamReader(input)); vector = (Vector) hm.get("companies"); if (vector == null) { Company company = new Company(); company.setDescription("Searching within 1KM radius..."); company.setName("Nothing found yet"); company.setAddress("..."); company.setCategory("..."); company.setEmail("..."); company.setWebsite("..."); company.setMobile("...."); if (!companies.contains(company)) { companies.add(company); } } else { for (int i = 0; i < vector.size(); i++) { Hashtable h = (Hashtable) vector.get(i); Company company = new Company(); company.setAddress(h.get("address").toString()); company.setCategory(h.get("category").toString()); company.setDescription(h.get("description").toString()); company.setEmail(h.get("email").toString()); company.setId(h.get("id").toString()); company.setLatitude(h.get("latitude").toString()); company.setLongitude(h.get("longitude").toString()); company.setMobile(h.get("mobile").toString()); company.setName(h.get("name").toString()); company.setWebsite(h.get("website").toString()); if (!companies.contains(company)) { companies.add(company); } } } } @Override protected void handleException(Exception err) { /* Display.getInstance().callSerially(new Runnable() { public void run() { Dialog.show("Oops", "Please make sure you still have data", "Ok", "Cancel"); } });*/ } }; String url = new UrlManager().getGetLocalCompanies() + "action=2&userlat=" + latitude + "&userlong=" + longitude + "&distance=" + radius; url = new Utility(null, null).replaceAll(url, " ", "%20"); request.setUrl(url); request.setPost(false); networkManager.addToQueueAndWait(request); return companies; }
From source file:de.kaiserpfalzEdv.commons.jee.jndi.SimpleContextFactory.java
@Override public Context getInitialContext(Hashtable<?, ?> environment) throws NamingException { Hashtable<Object, Object> env = new Hashtable<>(environment.size()); for (Object key : environment.keySet()) { env.put(key, environment.get(key)); }/*from w w w.j av a2s .co m*/ String configPath = System.getProperty(CONFIG_FILE_NAME_PROPERTY); if (isNotBlank(configPath)) { env.remove(org.osjava.sj.SimpleContext.SIMPLE_ROOT); env.put(org.osjava.sj.SimpleContext.SIMPLE_ROOT, configPath); } else { configPath = (String) env.get(org.osjava.sj.SimpleContext.SIMPLE_ROOT); } LOG.trace("***** Loading configuration from: {}", configPath); return new SimpleContext(env); }