List of usage examples for java.util Hashtable get
@SuppressWarnings("unchecked") public synchronized V get(Object key)
From source file:net.sourceforge.jwbf.actions.mw.util.PostModifyContent.java
/** * /*from w w w. j a v a2 s . c om*/ * @param a the * @param tab internal value set * @param login a */ public PostModifyContent(final ContentAccessable a, final Hashtable<String, String> tab, LoginData login) { String uS = ""; try { uS = "/index.php?title=" + URLEncoder.encode(a.getLabel(), MediaWikiBot.CHARSET) + "&action=submit"; } catch (UnsupportedEncodingException e) { e.printStackTrace(); } NameValuePair action = new NameValuePair("wpSave", "Save"); NameValuePair wpStarttime = new NameValuePair("wpStarttime", tab.get("wpStarttime")); NameValuePair wpEditToken = new NameValuePair("wpEditToken", tab.get("wpEditToken")); NameValuePair wpEdittime = new NameValuePair("wpEdittime", tab.get("wpEdittime")); NameValuePair wpTextbox = new NameValuePair("wpTextbox1", a.getText()); String editSummaryText = a.getEditSummary(); if (editSummaryText != null && editSummaryText.length() > 200) { editSummaryText = editSummaryText.substring(0, 200); } NameValuePair wpSummary = new NameValuePair("wpSummary", editSummaryText); NameValuePair wpMinoredit = new NameValuePair(); if (a.isMinorEdit()) { wpMinoredit.setValue("1"); wpMinoredit.setName("wpMinoredit"); } LOG.info("WRITE: " + a.getLabel()); PostMethod pm = new PostMethod(uS); pm.getParams().setContentCharset(MediaWikiBot.CHARSET); pm.setRequestBody(new NameValuePair[] { action, wpStarttime, wpEditToken, wpEdittime, wpTextbox, wpSummary, wpMinoredit }); msgs.add(pm); }
From source file:StringNode.java
public String toJSONObject(String prependId, Hashtable htLinks, boolean level1) { StringBuffer stb = new StringBuffer(); if (htLinks != null) { if (!name.startsWith("class ") && !name.startsWith("interface ") && !name.equals("Classes") && !name.equals("Interfaces") && htLinks.containsKey(name) && !level1) { stb.append("{title:'link::"); stb.append(htLinks.get(name)); stb.append("',widgetId:'"); stb.append(prependId);/* w ww . ja v a2 s . c om*/ stb.append("'}"); return stb.toString(); } else { htLinks.put(name, prependId); } } stb.append("{title:'"); if (name != null) stb.append(name); stb.append("',widgetId:'"); stb.append(prependId); if (childs == null || childs.size() == 0) { stb.append("',children:[]}"); } else { stb.append("',children:["); Collections.sort(childs); for (int i = 0; i < childs.size(); i++) { Object obj = childs.get(i); if (i != 0) stb.append(","); if (obj instanceof StringNode) stb.append(((StringNode) obj).toJSONObject(prependId + "." + i, htLinks)); else { stb.append("{title:'"); stb.append((String) obj); stb.append("',widgetId:'"); stb.append(prependId + "." + i); stb.append("'}"); } } stb.append("]}"); } return stb.toString(); }
From source file:com.bt.aloha.fitnesse.InboundMediaCallFixture.java
private String waitForCallEndedEvent(Hashtable<String, AbstractCallEndedEvent> callEndedEvents, CallTerminationCause callTerminationCause, CallLegCausingTermination callLegCausingTermination, boolean zeroDuration, String targetId) { AbstractCallEndedEvent callEndedEvent = callEndedEvents.get(targetId); if (callEndedEvent != null && !callEndedEvent.getCallTerminationCause().equals(callTerminationCause)) { if ((zeroDuration && callEndedEvent.getDuration() == 0) || (!zeroDuration && callEndedEvent.getDuration() > 0)) return callEndedEvent.getCallTerminationCause().toString(); return String.format("Call duration: %d seconds", callEndedEvent.getDuration()); } else if (callEndedEvent != null && !callEndedEvent.getCallLegCausingTermination().equals(callLegCausingTermination)) return callEndedEvent.getCallLegCausingTermination().toString(); else if (callEndedEvent != null) return "OK"; else/*from w w w. jav a2s . c o m*/ return callEndedEvents.keySet().toString(); }
From source file:com.hybris.mobile.adapter.FormAdapter.java
@SuppressWarnings("unchecked") @Override/*from w w w .j a va 2 s .c om*/ public void submit() { if (this.actionGo != null) { actionGo.submit(); } else { ArrayList<String> bun = new ArrayList<String>(); for (Object obj : objects) { Hashtable<String, Object> values = (Hashtable<String, Object>) obj; if (StringUtils.isNotBlank((String) values.get("value"))) { bun.add(values.get("value").toString()); } else if (!(objects.get(objects.size() - 1) == obj)) { bun.add(""); } } ((SubmitListener) context).onSubmit(bun); } }
From source file:eionet.gdem.qa.XQueryService.java
/** * *//*from w w w. j ava 2s . c o m*/ public Vector analyzeXMLFiles(String schema, String origFile, Vector result) throws GDEMException { LOGGER.info("XML/RPC call for analyze xml: " + origFile); if (result == null) { result = new Vector(); } Vector outputTypes = null; // get all possible xqueries from db String newId = "-1"; // should not be returned with value -1; String file = origFile; Vector queries = listQueries(schema); try { outputTypes = convTypeDao.getConvTypes(); } catch (SQLException sqe) { throw new GDEMException("DB operation failed: " + sqe.toString()); } try { // get the trusted URL from source file adapter file = SourceFileManager.getSourceFileAdapterURL(getTicket(), file, isTrustedMode()); } catch (Exception e) { String err_mess = "File URL is incorrect"; LOGGER.error(err_mess + "; " + e.toString()); throw new GDEMException(err_mess, e); } if (!Utils.isNullVector(queries)) { for (int j = 0; j < queries.size(); j++) { Hashtable query = (Hashtable) queries.get(j); String query_id = String.valueOf(query.get("query_id")); String queryFile = (String) query.get("query"); String contentType = (String) query.get("content_type_id"); String fileExtension = getExtension(outputTypes, contentType); String resultFile = Properties.tmpFolder + File.separatorChar + "gdem_q" + query_id + "_" + System.currentTimeMillis() + "." + fileExtension; try { int queryId = 0; try { queryId = Integer.parseInt(query_id); } catch (NumberFormatException n) { queryId = 0; } // if it is a XQuery script, then append the system folder if (queryId != Constants.JOB_VALIDATION && queryFile.startsWith(Properties.gdemURL + "/" + Constants.QUERIES_FOLDER)) { queryFile = Utils.Replace(queryFile, Properties.gdemURL + "/" + Constants.QUERIES_FOLDER, Properties.queriesFolder + File.separator); } newId = xqJobDao.startXQJob(file, queryFile, resultFile, queryId); } catch (SQLException sqe) { throw new GDEMException("DB operation failed: " + sqe.toString()); } Vector queryResult = new Vector(); queryResult.add(newId); queryResult.add(origFile); result.add(queryResult); } } LOGGER.info("Analyze xml result: " + result.toString()); return result; }
From source file:net.sf.joost.plugins.httppostfilter.THResolver.java
/** * actual business logic related to POST. Used by both resolve methods. *//*from w w w . j a v a2 s.co m*/ private TransformerHandler resolve(String method, String href, String base, XMLReader reader, Hashtable params) throws SAXException { if (Constants.DEBUG) log.debug("hppt-post-filter : resolve '" + method + "'"); if (!available(method)) throw new SAXException("Not supported filter-method!"); if ((reader != null) || (href != null)) throw new SAXException("Attribute 'filter-src' not allowed for method '" + method + "'"); String v = String.valueOf(params.get("target")); if (v == null) throw new SAXException("Missing parameter 'target' for filter " + "method '" + method + "'"); return new HttpPostHandler(v); }
From source file:com.scoredev.scores.HighScore.java
/** * get the high score. return -1 if it hasn't been set. * */// w w w. j ava 2 s .com public int getHighScore() throws IOException, ClassNotFoundException { //check permission first SecurityManager sm = System.getSecurityManager(); if (sm != null) { sm.checkPermission(new HighScorePermission(gameName)); } Integer score = null; // need a doPrivileged block to manipulate the file try { score = (Integer) AccessController.doPrivileged(new PrivilegedExceptionAction() { public Object run() throws IOException, ClassNotFoundException { Hashtable scores = null; // try to open the existing file. Should have a locking // protocol (could use File.createNewFile). FileInputStream fis = new FileInputStream(highScoreFile); ObjectInputStream ois = new ObjectInputStream(fis); scores = (Hashtable) ois.readObject(); // get the high score out return scores.get(gameName); } }); } catch (PrivilegedActionException pae) { Exception e = pae.getException(); if (e instanceof IOException) throw (IOException) e; else throw (ClassNotFoundException) e; } if (score == null) return -1; else return score.intValue(); }
From source file:hk.hku.cecid.ebms.admin.listener.PartnershipPageletAdaptor.java
protected Source getCenterSource(HttpServletRequest request) { PropertyTree dom = new PropertyTree(); dom.setProperty("/partnerships", ""); dom.setProperty("add_partnership/", ""); try {// ww w . j a v a 2s . com boolean isMultipart = FileUpload.isMultipartContent(request); if (isMultipart) { Hashtable ht = getHashtable(request); String partnershipId = null; if (((String) ht.get("request_action")).equalsIgnoreCase("change")) { partnershipId = (String) ht.get("selected_partnership_id"); } else { partnershipId = (String) ht.get("partnership_id"); updatePartnership(ht, request, dom); } getSelectedPartnership(partnershipId, dom); } getAllPartnerships(dom); } catch (Exception e) { EbmsProcessor.core.log.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:examples.javarpc.CustomMapping.java
public Map parseToMap(Object obj) { try {/*from w w w. j a va 2 s. com*/ if (Hashtable.class.isInstance(obj)) { Hashtable table = (Hashtable) obj; mLogger.debug("Is Table"); Map m = new HashMap(); for (Iterator iter = table.keySet().iterator(); iter.hasNext();) { Object key = iter.next(); m.put(key, table.get(key)); } return m; } else { mLogger.debug("Is No Table: " + obj); } } catch (Exception err) { mLogger.error("[parseToMap]", err); } return null; }
From source file:de.berlios.statcvs.xml.chart.AbstractTimeSeriesChart.java
protected Map createTimeSeries(Grouper grouper, Iterator it, RevisionVisitorFactory factory) { Hashtable timeSeriesByGroup = new Hashtable(); Hashtable visitorByGroup = new Hashtable(); ReportSettings.Predicate predicate = getSettings().getOutputPredicate(); while (it.hasNext()) { CvsRevision rev = (CvsRevision) it.next(); Object group = grouper.getGroup(rev); DateTimeSeries series = (DateTimeSeries) timeSeriesByGroup.get(group); RevisionVisitor visitor = (RevisionVisitor) visitorByGroup.get(group); if (series == null) { series = new DateTimeSeries(grouper.getName(group)); timeSeriesByGroup.put(group, series); visitor = factory.create(group); visitorByGroup.put(group, visitor); }/*from w ww.j av a 2 s . c o m*/ int value = visitor.visit(rev); if (predicate == null || predicate.matches(rev)) { // TODO: Maybe introduce CvsFile.isBinary() again. series.add(rev.getDate(), value); } } for (Iterator it2 = timeSeriesByGroup.values().iterator(); it2.hasNext();) { ((DateTimeSeries) it2.next()).addLast(); } return timeSeriesByGroup; }