List of usage examples for java.util Hashtable get
@SuppressWarnings("unchecked") public synchronized V get(Object key)
From source file:br.gov.frameworkdemoiselle.behave.integration.alm.ALMIntegration.java
/** * Obteem o valor do hash ou retorna um valor padro * /* w w w . j a v a 2 s. co m*/ * @param result * @param key * @param defaultValue * @return */ private String getHash(Hashtable<String, Object> result, String key, String defaultValue) { if (result.containsKey(key)) { return (String) result.get(key); } else { return defaultValue; } }
From source file:org.mahasen.thread.MahasenDownloadWorker.java
public void run() { Hashtable<String, Vector<String>> iptable = mahasenResource.getSplittedPartsIpTable(); String fileName = mahasenResource.getProperty(MahasenConstants.FILE_NAME).toString(); String currentFilePartName = fileName + "." + partName; if (iptable.get(partName).contains(localIp)) { log.debug("Storing : " + fileName + "." + partName + " locally"); FileInputStream inputStream = null; FileOutputStream outputStream = null; try {/*w w w . j a v a2 s .com*/ inputStream = new FileInputStream(new File( MahasenConfiguration.getInstance().getRepositoryPath() + fileName + "." + partName)); outputStream = new FileOutputStream( new File(MahasenConfiguration.getInstance().getTempDownloadFolderPath() + "/" + fileName + "/" + fileName + "." + partName)); byte[] buffer = new byte[1024]; int numRead; while ((numRead = inputStream.read(buffer)) != -1) { outputStream.write(buffer, 0, numRead); } GetUtil.decrementStoredNoOfParts(); } catch (Exception e) { log.error("Error occurred in storing part : " + partName, e); } finally { try { if (outputStream != null) { outputStream.flush(); outputStream.close(); } } catch (IOException e) { e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates. } } } else { for (int i = 0; i < iptable.get(partName).size(); i++) { String nodeIp = iptable.get(partName).get(i); URI uri = null; try { ArrayList<NameValuePair> qparams = new ArrayList<NameValuePair>(); qparams.add(new BasicNameValuePair(MahasenConstants.FILE_NAME, currentFilePartName)); uri = URIUtils.createURI("https", nodeIp + ":" + MahasenConstants.SERVER_PORT, -1, "/mahasen/download_request_ajaxprocessor.jsp", URLEncodedUtils.format(qparams, "UTF-8"), null); } catch (URISyntaxException e) { log.info("URI not found"); return; } HttpPost httppost = new HttpPost(uri); HttpClient downloadHttpClient = new DefaultHttpClient(); downloadHttpClient = SSLWrapper.wrapClient(downloadHttpClient); try { System.out.println("Executing Download request " + httppost.getRequestLine()); HttpResponse response = downloadHttpClient.execute(httppost); HttpEntity httpEntity = response.getEntity(); if (httpEntity.getContentLength() > 0) { fileOutputStream = new FileOutputStream( MahasenConfiguration.getInstance().getTempDownloadFolderPath() + "/" + fileName + "/" + fileName + "." + partName); inputStream = httpEntity.getContent(); byte[] buffer = new byte[1024]; int numRead; while ((numRead = inputStream.read(buffer)) != -1) { fileOutputStream.write(buffer, 0, numRead); } GetUtil.decrementStoredNoOfParts(); System.out.println(response.getStatusLine()); if ((response.getStatusLine().getReasonPhrase().equals("OK")) && (response.getStatusLine().getStatusCode() == 200)) { break; } } if (httpEntity.getContentLength() <= 0) { System.out.println("no content available"); } } catch (Exception e) { log.error("Error occurred in downloading file : " + partName, e); } finally { try { if (inputStream != null) { inputStream.close(); } if (fileOutputStream != null) { fileOutputStream.flush(); fileOutputStream.close(); } } catch (IOException e) { e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates. } } } } }
From source file:com.nec.nsgui.taglib.nssorttab.ListSTModel.java
public void sort(String colName, boolean isAscend, String sideSortOrder, Hashtable comparators) { if (colName == null || colName.trim().equals("")) { return;//from w ww . j av a 2s . co m } if (comparators == null) { return; } if (dataList.size() <= 1) { return; } Vector sortData = new Vector(); sortData.add(colName); sortData.add((comparators.get(colName))); if (sideSortOrder != null) { String[] orders = sideSortOrder.split(" "); for (int i = 0; i < orders.length; i++) { String order = orders[i]; if (!(order.trim().equals(""))) { sortData.add(order); sortData.add((comparators.get(order))); } } } SortComparator comp = new SortComparator(isAscend, sortData); Collections.sort(dataList, comp); return; }
From source file:edu.ku.brc.specify.toycode.BugParse.java
/** * @param hash/*www. j ava 2s. c om*/ * @param year * @param mon */ @SuppressWarnings("unchecked") protected void process(final Hashtable<Integer, Hashtable<Integer, Integer>> hash, final int year, final int mon) { Hashtable<Integer, Integer> yearHash = hash.get(year); if (yearHash == null) { yearHash = new Hashtable<Integer, Integer>(); hash.put(year, yearHash); } Hashtable<Integer, Integer> yearHashDif = hashDif.get(year); if (yearHashDif == null) { yearHashDif = new Hashtable<Integer, Integer>(); hashDif.put(year, yearHashDif); } Integer monTotal = yearHash.get(mon); int tot = monTotal == null ? 0 : monTotal; tot++; yearHash.put(mon, tot); yearHashDif.put(mon, 0); }
From source file:org.hdiv.webflow.validator.EditableParameterValidator.java
/** * Obtains the errors from request detected by HDIV during the validation * process of the editable parameters./*from w w w . j av a 2s . c o m*/ * * @param formObject form object * @param errors errors detected by HDIV during the validation process of * the editable parameters. */ public void validateEditableParameters(Object formObject, Errors errors) { ExternalContext externalContext = ExternalContextHolder.getExternalContext(); Hashtable editableParameters = (Hashtable) externalContext.getRequestMap().get(EDITABLE_PARAMETER_ERROR); if ((editableParameters != null) && (editableParameters.size() > 0)) { for (Iterator it = editableParameters.keySet().iterator(); it.hasNext();) { String currentParameter = (String) it.next(); String[] currentUnauthorizedValues = (String[]) editableParameters.get(currentParameter); if ((currentUnauthorizedValues.length == 1) && (currentUnauthorizedValues[0].equals(HDIV_EDITABLE_PASSWORD_ERROR))) { errors.rejectValue(currentParameter, HDIV_EDITABLE_PASSWORD_ERROR); } else { String printedValue = this.createMessageError(currentUnauthorizedValues); errors.rejectValue(currentParameter, HDIV_EDITABLE_ERROR, new String[] { printedValue }, printedValue + " has not allowed characters"); } } } }
From source file:com.seer.datacruncher.profiler.spring.ProfilerInfoController.java
public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { @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"))); }/*from w w w.j av a 2 s . c om*/ String selectedValue = CommonUtil.notNullValue(request.getParameter("selectedValue")); request.setAttribute("selectedValue", selectedValue); String parentNodeValue = CommonUtil.notNullValue(request.getParameter("parent")); request.setAttribute("parentValue", parentNodeValue); ObjectMapper mapper = new ObjectMapper(); if (CommonUtil.notNullValue(request.getParameter("action")).equals("minMaxValues")) { InfoBL ibl = new InfoBL(); String data = mapper.writeValueAsString( ibl.generateMinMaxValueGrid(CommonUtil.notNullValue(dbParams.get("Database_DSN")), parentNodeValue, selectedValue.split(":")[0])); PrintWriter out = response.getWriter(); out.println(data); return null; } else if (CommonUtil.notNullValue(request.getParameter("tab")).equals("analysis")) { String queryString = CommonUtil.notNullValue(request.getParameter("queryString")); Vector vector = RdbmsConnection.getTable(); String s = parentNodeValue; int i = vector.indexOf(s); Vector avector[] = (Vector[]) null; avector = TableMetaInfo.populateTable(5, i, i + 1, avector); QueryDialog querydialog = new QueryDialog(1, s, avector); List<String> listPrimaryKeys = new ArrayList<String>(); try { RdbmsConnection.openConn(); DatabaseMetaData dbmd = RdbmsConnection.getMetaData(); ResultSet resultset = dbmd.getPrimaryKeys(null, null, s); while (resultset.next()) { listPrimaryKeys.add(resultset.getString("COLUMN_NAME")); } RdbmsConnection.closeConn(); } catch (Exception ex) { ex.printStackTrace(); } try { querydialog.executeAction(queryString); } catch (Exception e) { e.printStackTrace(); } request.setAttribute("rowCount", querydialog.getRowCount()); GridUtil gridUtil = new GridUtil(); gridUtil.generateGridData(querydialog.getTableGridDTO(), false, listPrimaryKeys); request.setAttribute("gridColumns", gridUtil.getColumnNames()); GridUtil gridUtilEdit = new GridUtil(); gridUtilEdit.generateGridData(querydialog.getTableGridDTO(), true, listPrimaryKeys); request.setAttribute("gridColumnsEdit", gridUtilEdit.getColumnNames()); request.setAttribute("gridFields", gridUtil.getFieldNames()); request.setAttribute("gridData", gridUtil.getData()); request.setAttribute("systemDate", new Date(System.currentTimeMillis()).toString()); return new ModelAndView("jsp/profiler/analysis.jsp"); } else if (CommonUtil.notNullValue(request.getParameter("isLeaf")).equals("true")) { String s = dbParams.get("Database_DSN"); String s1 = parentNodeValue; String s2 = selectedValue.split(":")[0]; QueryBuilder querybuilder = new QueryBuilder(s, s1, s2, RdbmsConnection.getDBType()); Double profileValues[] = FirstInformation.getProfileValues(querybuilder); Vector patternValues[] = FirstInformation.getPatternValues(querybuilder); Vector distValues[] = getDistributionValues(querybuilder, request); // showBar(ad); // showPatternChart(avector); String pieChartData = ChartUtil.getChartDataForPieChart(distValues); String barChartData = ChartUtil.getChartDataForBarChart(profileValues); String patternChartData = ChartUtil.getChartDataForPieChart(patternValues); request.setAttribute("pieChartData", pieChartData); request.setAttribute("barChartData", barChartData); request.setAttribute("patternChartData", patternChartData); return new ModelAndView("jsp/profiler/charts.jsp"); } else { Vector vector = RdbmsConnection.getTable(); String s = selectedValue; int i = vector.indexOf(s); Vector avector[] = (Vector[]) null; avector = TableMetaInfo.populateTable(5, i, i + 1, avector); QueryDialog querydialog = new QueryDialog(1, s, avector); try { querydialog.executeAction(""); } catch (Exception e) { e.printStackTrace(); } request.setAttribute("rowCount", querydialog.getRowCount()); GridUtil gridUtil = new GridUtil(); gridUtil.generateGridData(querydialog.getTableGridDTO(), false, null); request.setAttribute("gridColumns", gridUtil.getColumnNames()); request.setAttribute("colCount", querydialog.getTableGridDTO().getColumnNames().length); request.setAttribute("gridFields", gridUtil.getFieldNames()); request.setAttribute("gridData", gridUtil.getData()); return new ModelAndView("jsp/profiler/info.jsp"); } }
From source file:com.mobilefirst.fiberlink.WebServiceRequest.java
/** * initializeRequestHeadersAndParameters iterates through Hashtable of attributes and sets against correct level in object * @param objectList: hashtable of parameters *///w ww. j a v a 2 s . co m @SuppressWarnings("unchecked") public void initializeRequestHeadersAndParameters(Hashtable<String, Object> objectList) { try { if (null != objectList) { if (0 != objectList.size()) { if (null != objectList.get("parameters")) { parameters.clear(); parameters = (Hashtable<String, String>) objectList.get("parameters"); } if (null != objectList.get("headers")) { headers.clear(); headers = (Hashtable<String, String>) objectList.get("headers"); } if (null != objectList.get("parts")) { parts = (Part[]) objectList.get("parts"); } } } } catch (Exception e) { } }
From source file:edu.ku.brc.specify.tasks.BaseTask.java
@Override public PermissionIFace getDefaultPermissions(final String userType) { Hashtable<String, PermissionOptionPersist> hash = getAndSetDefPerms(); //System.err.println(name+" "+userType+" "+(defaultPermissionsHash != null ? defaultPermissionsHash.get(userType) : null)); if (hash != null) { PermissionOptionPersist permOpt = hash.get(userType); if (permOpt != null) { return permOpt.getDefaultPerms(); }// w w w . jav a2s.c om baseLog.error("No permissions from hash for user type[" + userType + "]"); } else { baseLog.error("No hashtable from getAndSetDefPerms!"); } return null; }
From source file:net.nosleep.superanalyzer.analysis.views.YearView.java
/** * Creates a sample dataset./*from w ww. j a va 2 s.co m*/ * * @return The dataset. */ private void refreshDataset() { // TimeSeries t1 = new TimeSeries("Songs you have", "Year", "Count"); // TimeSeries t2 = new TimeSeries("Songs you played", "Year", "Count"); XYSeries t1 = new XYSeries(Misc.getString("SONGS_YOU_HAVE")); XYSeries t2 = new XYSeries(Misc.getString("SONGS_YOU_PLAYED")); Stat itemStats = null; if (_comboBox == null) { itemStats = _analysis.getStats(Analysis.KIND_TRACK, null); } else { ComboItem item = (ComboItem) _comboBox.getSelectedItem(); itemStats = _analysis.getStats(item.getKind(), item.getValue()); } Vector yearCountListHave = new Vector(); Hashtable years = itemStats.getYears(); Enumeration e = years.keys(); while (e.hasMoreElements()) { Integer year = (Integer) e.nextElement(); Integer count = (Integer) years.get(year); // if (count.intValue() > 0) yearCountListHave.addElement(new YearCountItem(year.intValue(), count.intValue())); } Collections.sort(yearCountListHave, new YearCountComparator()); for (int i = 0; i < yearCountListHave.size(); i++) { YearCountItem item = (YearCountItem) yearCountListHave.elementAt(i); // _dataset.addValue(item.Count, "Songs you have", new // Integer(item.Year)); t1.add(item.Year, new Integer(item.Count)); } Vector yearCountListPlay = new Vector(); Hashtable yearPlays = itemStats.getPlayYears(); e = yearPlays.keys(); while (e.hasMoreElements()) { Integer year = (Integer) e.nextElement(); Integer count = (Integer) yearPlays.get(year); // if (count.intValue() > 0) yearCountListPlay.addElement(new YearCountItem(year.intValue(), count.intValue())); } Collections.sort(yearCountListPlay, new YearCountComparator()); for (int i = 0; i < yearCountListPlay.size(); i++) { YearCountItem item = (YearCountItem) yearCountListPlay.elementAt(i); // _dataset.addValue(item.Count, "Songs you've played", new // Integer(item.Year)); t2.add(item.Year, new Integer(item.Count)); } _dataset.removeAllSeries(); _dataset.addSeries(t1); _dataset.addSeries(t2); // TimeSeriesCollection tsc = new TimeSeriesCollection(t1); XYPlot plot = (XYPlot) _chart.getPlot(); NumberAxis axis = (NumberAxis) plot.getRangeAxis(); axis.setAutoRangeStickyZero(false); XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) plot.getRenderer(); renderer.setSeriesPaint(0, Theme.getColorSet()[0]); renderer.setSeriesPaint(1, Theme.getColorSet()[2]); }
From source file:org.jberet.support.io.NoMappingJsonFactoryObjectFactory.java
/** * Gets an instance of {@code com.fasterxml.jackson.core.JsonFactory} based on the resource configuration in the * application server. The parameter {@code environment} contains JsonFactory configuration properties, and accepts * the following properties:// w ww.ja v a 2 s. c om * <ul> * <li>jsonFactoryFeatures: JsonFactory features as defined in com.fasterxml.jackson.core.JsonFactory.Feature * <li>inputDecorator: fully-qualified name of a class that extends {@code com.fasterxml.jackson.core.io.InputDecorator} * <li>outputDecorator: fully-qualified name of a class that extends {@code com.fasterxml.jackson.core.io.OutputDecorator} * </ul> * * @param obj the JNDI name of {@code com.fasterxml.jackson.core.JsonFactory} resource * @param name always null * @param nameCtx always null * @param environment a {@code Hashtable} of configuration properties * @return an instance of {@code com.fasterxml.jackson.core.JsonFactory} * @throws Exception any exception occurred */ @Override public Object getObjectInstance(final Object obj, final Name name, final Context nameCtx, final Hashtable<?, ?> environment) throws Exception { JsonFactory jsonFactory = jsonFactoryCached; if (jsonFactory == null) { synchronized (this) { jsonFactory = jsonFactoryCached; if (jsonFactory == null) { jsonFactoryCached = jsonFactory = new JsonFactory(); } final Object jsonFactoryFeatures = environment.get("jsonFactoryFeatures"); if (jsonFactoryFeatures != null) { configureJsonFactoryFeatures(jsonFactory, (String) jsonFactoryFeatures); } configureInputDecoratorAndOutputDecorator(jsonFactory, environment); } } return jsonFactory; }