List of usage examples for java.util Hashtable containsKey
public synchronized boolean containsKey(Object key)
From source file:org.dcm4che3.conf.core.storage.SingleJsonFileConfigurationStorage.java
public void configure(Hashtable<?, ?> props) { String fileName = ConfigurationSettingsLoader.getPropertyWithNotice(props, CONF_FILENAME_SYSPROP, "${jboss.server.config.dir}/dcm4chee-arc/sample-config.json"); this.fileName = StringUtils.replaceSystemProperties(fileName); if (props.containsKey(USE_GIT_SYSPROP)) makeGitCommitOnPersist = true;/* w w w. j a v a2 s . c o m*/ }
From source file:eionet.gdem.conversion.odf.OdsReader.java
@Override public String getXMLSchema() { String ret = null;/* w ww . j a v a 2s . co m*/ Hashtable usermetadata = metadata.getUserDefined(); if (usermetadata.containsKey(SCHEMA_ATTR_NAME)) { ret = (String) usermetadata.get(SCHEMA_ATTR_NAME); } return ret; }
From source file:org.springframework.security.ldap.DefaultSpringSecurityContextSource.java
/** * Create and initialize an instance which will connect to the supplied LDAP URL. If * you want to use more than one server for fail-over, rather use the * {@link #DefaultSpringSecurityContextSource(List, String)} constructor. * * @param providerUrl an LDAP URL of the form * <code>ldap://localhost:389/base_dn</code> *//*from w w w.j a v a2 s. com*/ public DefaultSpringSecurityContextSource(String providerUrl) { Assert.hasLength(providerUrl, "An LDAP connection URL must be supplied."); StringTokenizer st = new StringTokenizer(providerUrl); ArrayList<String> urls = new ArrayList<>(); // Work out rootDn from the first URL and check that the other URLs (if any) match while (st.hasMoreTokens()) { String url = st.nextToken(); String urlRootDn = LdapUtils.parseRootDnFromUrl(url); urls.add(url.substring(0, url.lastIndexOf(urlRootDn))); this.logger.info(" URL '" + url + "', root DN is '" + urlRootDn + "'"); if (this.rootDn == null) { this.rootDn = urlRootDn; } else if (!this.rootDn.equals(urlRootDn)) { throw new IllegalArgumentException("Root DNs must be the same when using multiple URLs"); } } setUrls(urls.toArray(new String[urls.size()])); setBase(this.rootDn); setPooled(true); setAuthenticationStrategy(new SimpleDirContextAuthenticationStrategy() { @Override @SuppressWarnings("rawtypes") public void setupEnvironment(Hashtable env, String dn, String password) { super.setupEnvironment(env, dn, password); // Remove the pooling flag unless we are authenticating as the 'manager' // user. if (!DefaultSpringSecurityContextSource.this.userDn.equals(dn) && env.containsKey(SUN_LDAP_POOLING_FLAG)) { DefaultSpringSecurityContextSource.this.logger.debug("Removing pooling flag for user " + dn); env.remove(SUN_LDAP_POOLING_FLAG); } } }); }
From source file:org.dspace.app.xmlui.cocoon.servlet.multipart.DSpaceMultipartParser.java
/** * Parse a single part/* ww w. j a v a 2 s.co m*/ * * @param ts * * @throws java.io.IOException * @throws org.apache.cocoon.servlet.multipart.MultipartException */ private void parsePart(DSpaceTokenStream ts) throws IOException, MultipartException { Hashtable headers = new Hashtable(); headers = readHeaders(ts); try { if (headers.containsKey("filename")) { if (!"".equals(headers.get("filename"))) { parseFilePart(ts, headers); } else { // IE6 sends an empty part with filename="" for // empty upload fields. Just parse away the part byte[] buf = new byte[32]; while (ts.getState() == DSpaceTokenStream.STATE_READING) ts.read(buf); } } else if (((String) headers.get("content-disposition")).toLowerCase().equals("form-data")) { parseInlinePart(ts, headers); } // FIXME: multipart/mixed parts are untested. else if (((String) headers.get("content-disposition")).toLowerCase().indexOf("multipart") > -1) { parseMultiPart(new DSpaceTokenStream(ts, MAX_BOUNDARY_SIZE), "--" + (String) headers.get("boundary")); ts.read(); // read past boundary } else { throw new MultipartException("Unknown part type"); } } catch (IOException e) { throw new MultipartException("Malformed stream: " + e.getMessage()); } catch (NullPointerException e) { e.printStackTrace(); throw new MultipartException("Malformed header"); } }
From source file:com.hybris.mobile.adapter.FormAdapter.java
@SuppressWarnings("unchecked") private Boolean fieldIsValid(int index) { Boolean isRequired = false;/*from w w w . j av a 2 s. co m*/ Boolean hasValidation = false; Hashtable<String, Object> obj = (Hashtable<String, Object>) objects.get(index); hasValidation = obj.containsKey("validation"); if (obj.containsKey("required")) { isRequired = Boolean.parseBoolean(obj.get("required").toString()); } String value = ""; if (obj.containsKey("value")) { value = obj.get("value").toString(); } if ((obj.get("cellIdentifier").toString().equalsIgnoreCase("HYFormTextEntryCell")) || (obj.get("cellIdentifier").toString().equalsIgnoreCase("HYFormSecureTextEntryCell"))) { if ((value.length() > 0) && hasValidation) { Pattern pattern = Pattern.compile(obj.get("validation").toString()); Matcher matcher = pattern.matcher(value); Boolean show = matcher.matches(); obj.put("showerror", !show); return show; } else { obj.put("showerror", isRequired); return !isRequired; } } else if ((obj.get("cellIdentifier").toString().equalsIgnoreCase("HYFormTextSelectionCell"))) { if (value.length() > 0) { return true; } else return false; } return true; }
From source file:eionet.gdem.conversion.odf.OdsReader.java
@Override public Map<String, String> getSheetSchemas() { Map<String, String> resultMap = new LinkedHashMap<String, String>(); Hashtable userMetadata = metadata.getUserDefined(); if (userMetadata.containsKey(TBL_SCHEMAS_ATTR_NAME)) { String ret = (String) userMetadata.get(TBL_SCHEMAS_ATTR_NAME); if (Utils.isNullStr(ret)) { return resultMap; }/*from w w w .j av a 2 s. com*/ StringTokenizer stTbl = new StringTokenizer(ret, TBL_SEPARATOR); if (stTbl.countTokens() == 0) { return resultMap; } resultMap = new HashMap<String, String>(); while (stTbl.hasMoreTokens()) { String tbl = stTbl.nextToken(); StringTokenizer stTblProps = new StringTokenizer(tbl, TBL_PROPERTIES_SEPARATOR); if (stTblProps.countTokens() < 2) { continue; } String tblName = null; String tblSchema = null; while (stTblProps.hasMoreTokens()) { String token = stTblProps.nextToken(); if (token.startsWith(TABLE_NAME)) { tblName = token.substring(TABLE_NAME.length()); } if (token.startsWith(TABLE_SCHEMA_URL)) { tblSchema = token.substring(TABLE_SCHEMA_URL.length()); } } if (Utils.isNullStr(tblName) || Utils.isNullStr(tblSchema)) { continue; } // check if table exists if (spreadsheet != null && !spreadsheet.tableExists(tblName)) { continue; } if (!resultMap.containsKey(tblName)) { resultMap.put(tblName, tblSchema); } } } return resultMap; }
From source file:eionet.gdem.qa.XQueryService.java
private String getExtension(Vector outputTypes, String content_type) { String ret = "html"; if (outputTypes == null) { return ret; }/*from w ww . ja v a2 s . c o m*/ if (content_type == null) { return ret; } for (int i = 0; i < outputTypes.size(); i++) { Hashtable outType = (Hashtable) outputTypes.get(i); if (outType == null) { continue; } if (!outType.containsKey("conv_type") || !outType.containsKey("file_ext") || outType.get("conv_type") == null || outType.get("file_ext") == null) { continue; } String typeId = (String) outType.get("conv_type"); if (!content_type.equalsIgnoreCase(typeId)) { continue; } ret = (String) outType.get("file_ext"); } return ret; }
From source file:opennlp.tools.textsimilarity.TextProcessor.java
public static String generateFingerPrintForHistogram(String s) throws Exception { Hashtable tokenHash = new Hashtable(); // ArrayList tokens = TextProcessor.tokenizeWithPunctuation(s); ArrayList tokens = TextProcessor.fastTokenize(s, true); for (Object t : tokens) { String tokenLower = ((String) (t)).toLowerCase(); if (tokenLower == "<punc>") { continue; }/*from w w w . j a va2 s.c om*/ if (tokenLower == "close_a") { continue; } if (tokenLower == "open_a") { continue; } String stemmedToken = TextProcessor.stemTerm(tokenLower); if (tokenHash.containsKey(stemmedToken)) { int freq = ((Integer) tokenHash.get(stemmedToken)).intValue(); freq++; tokenHash.put(stemmedToken, new Integer(freq)); } else { tokenHash.put(stemmedToken, new Integer(1)); } } // now we have histogram, lets write it out String hashString = ""; Enumeration en = tokenHash.keys(); while (en.hasMoreElements()) { String t = (String) en.nextElement(); int freq = (Integer) tokenHash.get(t); hashString += t + freq; } // log.info(hashString); String hash = ""; if (hashString.length() > 0) { MessageDigest md = null; try { md = MessageDigest.getInstance("SHA"); // step 2 } catch (NoSuchAlgorithmException e) { LOG.severe("NoSuchAlgorithmException " + e); throw new Exception(e.getMessage()); } try { md.update(hashString.getBytes("UTF-8")); // step 3 } catch (UnsupportedEncodingException e) { LOG.severe("UnsupportedEncodingException " + e); throw new Exception(e.getMessage()); } byte raw[] = md.digest(); hash = null; // (new BASE64Encoder()).encode(raw); } return hash; }
From source file:org.apache.usergrid.apm.service.charts.service.CommonStrategy.java
public List<NetworkMetricsChartDTO> compileChartDataWithGrouping( List<? extends CompactNetworkMetrics> cachedMetrics, List<? extends CompactNetworkMetrics> freshMetrics, MetricsChartCriteria cq) {/*from w ww . j ava2s . co m*/ Hashtable<String, Integer> groupIndex = getChartGroups(cachedMetrics, cq); //We need to do this because there could be new group such as Sprint network while cached ones only has ATT and Verizon Hashtable<String, Integer> groupIndexFresh = getChartGroups(freshMetrics, cq); Enumeration<String> keys = groupIndexFresh.keys(); while (keys.hasMoreElements()) { String temp = keys.nextElement(); if (!groupIndex.containsKey(temp)) groupIndex.put(temp, groupIndex.size()); } log.info("Total number of chart groups " + groupIndex.size()); //TODO: There probably is a better way List<NetworkMetricsChartDTO> charts = new ArrayList<NetworkMetricsChartDTO>(groupIndex.size()); for (int i = 0; i < groupIndex.size(); i++) { charts.add(new NetworkMetricsChartDTO()); } keys = groupIndex.keys(); String key; NetworkMetricsChartDTO dto; while (keys.hasMoreElements()) { key = keys.nextElement(); dto = charts.get(groupIndex.get(key)); dto.setChartGroupName(key); } populateUIChartDataWithGroup(charts, cachedMetrics, groupIndex, cq); populateUIChartDataWithGroup(charts, freshMetrics, groupIndex, cq); return charts; }
From source file:org.agnitas.web.MailingStatAction.java
/** * Loads mailing statistics./* w ww. j a va2 s. c om*/ */ protected void loadMailingStat(MailingStatForm aForm, HttpServletRequest req) { //set variables from form: MailingStat aMailStat = (MailingStat) getBean("MailingStat"); aMailStat.setCompanyID(getCompanyID(req)); int tid = aForm.getTargetID(); aMailStat.setTargetID(tid); int mid = aForm.getMailingID(); aMailStat.setMailingID(mid); if (aForm.getTargetIDs() != null) { LinkedList targets = aForm.getTargetIDs(); int atid = aForm.getNextTargetID(); if (targets.contains(new Integer(atid)) == false) { targets.add(new Integer(atid)); } if (req.getParameter("delTargetID") != null) { if (targets.contains(new Integer(req.getParameter("delTargetID"))) && targets.size() > 1) { targets.remove(new Integer(req.getParameter("delTargetID"))); } } aMailStat.setTargetIDs(targets); } else { LinkedList targets = new LinkedList(); targets.add(new Integer(0)); aMailStat.setTargetIDs(targets); } // if we come from the mailstat page itself, pass statValues data: if (req.getParameter("add.x") != null) { aMailStat.setStatValues(aForm.getStatValues()); } else if (req.getParameter("delTargetID") != null) { // delete MailingStatEntry for targetID to be deleted: Hashtable tmpStatVal = aForm.getStatValues(); if (tmpStatVal.containsKey(new Integer(req.getParameter("delTargetID")))) { tmpStatVal.remove(new Integer(req.getParameter("delTargetID"))); } // and put the statValues in the MailingStat class: aMailStat.setStatValues(tmpStatVal); } else { // delete all stat info: LinkedList targets = new LinkedList(); targets.add(new Integer(0)); aMailStat.setTargetIDs(targets); Hashtable tmpStatVal = new Hashtable(); aMailStat.setStatValues(tmpStatVal); } if (aMailStat.getMailingStatFromDB(this.getWebApplicationContext(), (Locale) req.getSession().getAttribute(org.apache.struts.Globals.LOCALE_KEY)) == true) { // write results back to form: aForm.setCsvfile(aMailStat.getCsvfile()); aForm.setClickSubscribers(aMailStat.getClickSubscribers()); aForm.setClicks(aMailStat.getClicks()); aForm.setOpenedMails(aMailStat.getOpenedMails()); aForm.setOptOuts(aMailStat.getOptOuts()); aForm.setBounces(aMailStat.getBounces()); aForm.setTotalSubscribers(aMailStat.getTotalSubscribers()); aForm.setValues(aMailStat.getValues()); aForm.setMailingShortname(aMailStat.getMailingShortname()); aForm.setMailingID(mid); aForm.setStatValues(aMailStat.getStatValues()); aForm.setTargetIDs(aMailStat.getTargetIDs()); aForm.setUrlNames(aMailStat.getUrls()); aForm.setUrlShortnames(aMailStat.getUrlShortnames()); aForm.setMaxblue(aMailStat.getMaxblue()); aForm.setMaxNRblue(aMailStat.getMaxNRblue()); aForm.setMaxSubscribers(aMailStat.getMaxSubscribers()); aForm.setClickedUrls(aMailStat.getClickedUrls()); aForm.setNotRelevantUrls(aMailStat.getNotRelevantUrls()); } else { AgnUtils.logger().error("loadMailingStat: could not load mailing stats."); } }