List of usage examples for java.util StringTokenizer hasMoreElements
public boolean hasMoreElements()
From source file:org.wso2.carbon.apimgt.keymgt.token.APIMJWTGenerator.java
public String buildBody(JwtTokenInfoDTO jwtTokenInfoDTO) throws APIManagementException { Map<String, Object> standardClaims = populateStandardClaims(jwtTokenInfoDTO); //get tenantId int tenantId = APIUtil.getTenantId(jwtTokenInfoDTO.getEndUserName()); String claimSeparator = getMultiAttributeSeparator(tenantId); if (StringUtils.isNotBlank(claimSeparator)) { userAttributeSeparator = claimSeparator; }/*from ww w . j a va 2 s . com*/ if (standardClaims != null) { JWTClaimsSet.Builder jwtClaimsSetBuilder = new JWTClaimsSet.Builder(); Iterator<String> it = new TreeSet(standardClaims.keySet()).iterator(); while (it.hasNext()) { String claimURI = it.next(); Object claimValObj = standardClaims.get(claimURI); if (claimValObj instanceof String) { String claimVal = (String) claimValObj; List<String> claimList = new ArrayList<String>(); if (userAttributeSeparator != null && claimVal.contains(userAttributeSeparator)) { StringTokenizer st = new StringTokenizer(claimVal, userAttributeSeparator); while (st.hasMoreElements()) { String attValue = st.nextElement().toString(); if (StringUtils.isNotBlank(attValue)) { claimList.add(attValue); } } jwtClaimsSetBuilder.claim(claimURI, claimList.toArray(new String[claimList.size()])); } else if (APIConstants.EXP.equals(claimURI)) { jwtClaimsSetBuilder.claim(APIConstants.EXP, new Date(Long.valueOf((String) standardClaims.get(claimURI)))); } else { jwtClaimsSetBuilder.claim(claimURI, claimVal); } } else { if (claimValObj != null) { jwtClaimsSetBuilder.claim(claimURI, claimValObj); } } } return jwtClaimsSetBuilder.build().toJSONObject().toJSONString(); } return null; }
From source file:com.esri.gpt.control.rest.search.DistributedSearchServlet.java
/** * Gets the RIDs specified within the request. * /* www. jav a2 s . co m*/ * @param request * the HTTP request * @return the RIDs */ @SuppressWarnings("unchecked") private StringSet getRids(HttpServletRequest request) { StringSet rids = new StringSet(); Map<String, String[]> requestParameterMap = request.getParameterMap(); for (Map.Entry<String, String[]> e : requestParameterMap.entrySet()) { if (e.getKey().equalsIgnoreCase("rids")) { String[] values = e.getValue(); if (values != null) { for (String tokens : values) { StringTokenizer st = new StringTokenizer(tokens, ","); while (st.hasMoreElements()) { String value = Val.chkStr((String) st.nextElement()); if (value.length() > 0) { try { rids.add(URLDecoder.decode(value, "UTF-8")); } catch (UnsupportedEncodingException e1) { // Should never happen LOG.log(Level.WARNING, "Could not decde uuid", e1); } } } } } } } String arrRids[] = request.getParameterValues("rid"); for (int i = 0; arrRids != null && i < arrRids.length; i++) { rids.add(arrRids[i]); } return rids; }
From source file:com.headstrong.npi.raas.Utils.java
public static String removeBlankSpaces(String name) { StringTokenizer st = new StringTokenizer(name, " ", false); StringBuffer completelyFormattedValue = new StringBuffer(); while (st.hasMoreElements()) completelyFormattedValue.append(st.nextElement()); return completelyFormattedValue.toString(); }
From source file:org.rhq.enterprise.gui.legacy.action.resource.common.events.EventDetailsAction.java
private String ridBadChars(String source) { int sourceLen = source.length(); if (sourceLen == 0) { return source; }/*from w w w . jav a2 s. c o m*/ StringTokenizer st = new StringTokenizer(source); StringBuffer buffer = new StringBuffer(); while (st.hasMoreElements()) { String tok = st.nextToken(); tok = tok.replaceAll("['\"]", " "); if (tok.indexOf('<') > -1) { tok = StringUtil.replace(tok, "<", "<"); } buffer.append(tok).append(" "); } return buffer.toString(); }
From source file:com.egeniuss.appmarket.controller.AppManagerController.java
@RequestMapping("/uploadApp.html") public @ResponseBody Map<String, Object> uploadApp(@RequestParam(required = false) MultipartFile app, HttpServletRequest request) {/*from www.j a v a 2 s . co m*/ Date now = new Date(); long time = now.getTime(); String appFileName = app.getOriginalFilename(); String realFileName = time + appFileName.substring(appFileName.lastIndexOf(".")); Map<String, Object> msg = new HashMap<String, Object>(); try { FileUtils.copyInputStreamToFile(app.getInputStream(), new File(appStore.concat(realFileName))); } catch (IOException e) { LOGGER.error("?", e); msg.put("errcode", -1); msg.put("errmsg", "<br/>" + e.getMessage()); return msg; } SimpleDateFormat formator = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); StringTokenizer linemsg = new StringTokenizer(request.getParameter("releaseNote"), "\n"); StringBuilder releaseNoteSb = new StringBuilder(); while (linemsg.hasMoreElements()) { releaseNoteSb.append(linemsg.nextElement()).append("\\n"); } Object[] args = new Object[] { time, request.getParameter("appKey"), request.getParameter("appPlatform"), request.getParameter("appEnv"), request.getParameter("versionNum"), app.getSize(), releaseNoteSb.toString(), realFileName, formator.format(now) }; int[] argTypes = new int[] { Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.DECIMAL, Types.VARCHAR, Types.VARCHAR, Types.VARCHAR }; jdbcTemplate.update( "insert into APP_MARKET (APP_ID, APP_KEY, APP_PLATFORM, APP_ENV, VERSION_NUM, APP_SIZE, RELEASE_NOTE, FILE_NAME, CREATE_TIME) values (?, ?, ?, ?, ?, ?, ?, ?, ?)", args, argTypes); msg.put("errcode", 0); msg.put("errmsg", "ok"); return msg; }
From source file:org.finra.dm.dao.helper.DmStringHelper.java
/** * Splits the input String based on the default delimiter * * @param inputString to be split/*from w ww. j a v a2 s. c om*/ * * @return the list of String literals that are split with the delimiter */ public List<String> splitStringWithDefaultDelimiter(String inputString) { List<String> splitString = new ArrayList<>(); if (inputString != null) { StringTokenizer stringTokenizer = new StringTokenizer(inputString, configurationHelper.getProperty(ConfigurationValue.FIELD_DATA_DELIMITER)); while (stringTokenizer.hasMoreElements()) { splitString.add(stringTokenizer.nextToken()); } } return splitString; }
From source file:org.squale.welcom.outils.jdbc.WConnectionString.java
/** * Initialise un objet connectionString a partir d'une string * //from w w w.j a v a 2s . c o m * @param connectionString la chaine */ public void setConnectionString(final String connectionString) { final StringTokenizer st = new StringTokenizer(connectionString, ";"); while (st.hasMoreElements()) { final String element = (String) st.nextElement(); final int posEqual = element.indexOf("="); String key = ""; String value = ""; if (posEqual != -1) { key = element.substring(0, posEqual); value = element.substring(element.indexOf("=") + 1, element.length()); } else { key = element; } // Set les valeurs dans le bean setAttribute(key, value); } }
From source file:org.apache.cocoon.portal.coplet.CopletData.java
/** * Return the list of roles that are allowed to access this coplet * @return A list of roles or null if everyone is allowed. *///from w w w . ja v a 2 s .c o m public List getAllowedRolesList() { if (StringUtils.isBlank(this.allowedRoles)) { return null; } if (this.allowedRolesList == null) { this.allowedRolesList = new ArrayList(); final StringTokenizer tokenizer = new StringTokenizer(this.allowedRoles, ","); while (tokenizer.hasMoreElements()) { String token = (String) tokenizer.nextElement(); this.allowedRolesList.add(token); } if (this.allowedRolesList.size() == 0) { this.allowedRoles = null; this.allowedRolesList = null; } } return this.allowedRolesList; }
From source file:com.moviejukebox.tools.FileTools.java
public static void initUnsafeChars() { if (!UNSAFE_CHARS.isEmpty()) { return;/*ww w .j a v a 2 s . c om*/ } // What to do if the user specifies a blank encodeEscapeChar? I guess disable encoding. String encodeEscapeCharString = PropertiesUtil.getProperty("mjb.charset.filenameEncodingEscapeChar", "$"); if (encodeEscapeCharString.length() > 0) { // What to do if the user specifies a >1 character long string? I guess just use the first char. final Character ENCODE_ESCAPE_CHAR = encodeEscapeCharString.charAt(0); String repChars = PropertiesUtil.getProperty("mjb.charset.unsafeFilenameChars", "<>:\"/\\|?*"); for (String repChar : repChars.split("")) { if (repChar.length() > 0) { char ch = repChar.charAt(0); // Don't encode characters that are hex digits // Also, don't encode the escape char -- it is safe by definition! if (!Character.isDigit(ch) && -1 == "AaBbCcDdEeFf".indexOf(ch) && !ENCODE_ESCAPE_CHAR.equals(ch)) { String hex = Integer.toHexString(ch).toUpperCase(); UNSAFE_CHARS.add(new ReplaceEntry(repChar, ENCODE_ESCAPE_CHAR + hex)); } } } } // Parse transliteration map: (source_character [-] transliteration_sequence [,])+ StringTokenizer st = new StringTokenizer(PropertiesUtil.getProperty("mjb.charset.filename.translate", ""), ","); while (st.hasMoreElements()) { final String token = st.nextToken(); String beforeStr = substringBefore(token, "-"); final String character = beforeStr.length() == 1 && ("\t".equals(beforeStr) || " ".equals(beforeStr)) ? beforeStr : trimToNull(beforeStr); if (character == null) { // TODO Error message? continue; } String afterStr = substringAfter(token, "-"); final String translation = afterStr.length() == 1 && ("\t".equals(afterStr) || " ".equals(afterStr)) ? afterStr : trimToNull(afterStr); if (translation == null) { // TODO Error message? // TODO Allow empty transliteration? continue; } UNSAFE_CHARS.add(new ReplaceEntry(character.toUpperCase(), translation.toUpperCase())); UNSAFE_CHARS.add(new ReplaceEntry(character.toLowerCase(), translation.toLowerCase())); } }
From source file:net.java.javamoney.examples.tradingapp.web.PortfolioController.java
public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response) { Map<String, Object> model = new HashMap<String, Object>(); String m = null;/* w ww . j a va 2 s. com*/ Object o; Enumeration e = request.getParameterNames(); while (e.hasMoreElements()) { o = e.nextElement(); //logger.info("Param: " + o); if (String.valueOf(o).equals(MODEL)) { o = request.getParameter(MODEL); if (o instanceof Map) { //logger.info("It's a Map"); model = (Map) o; } } else if (String.valueOf(o).equals(MARKET)) { m = request.getParameter(MARKET); } } if (m != null && m.length() > 0) { String mDetails = this.market.getKnownMarkets().get(m); logger.info("Market: " + m + "=" + mDetails); market.setSymbol(m); //model.put(MARKET, m); String cSymbol = null; String mName = null; StringTokenizer st = new StringTokenizer(mDetails, ";"); while (st.hasMoreElements()) { if (mName == null) { mName = st.nextToken(); } else { if (cSymbol == null) { cSymbol = st.nextToken(); } } } if (mName != null) { market.setName(mName); } if (cSymbol != null) { Currency curr = new Currency(cSymbol); // TODO retrieve this from Yahoo Service similar to quotes, or 354 style ExchangeRateProvider Object oRate = market.getCurrencyExchangeRates().get(cSymbol); if (oRate != null) { Number exchangeRate; if (oRate instanceof Number) { exchangeRate = (Number) oRate; } else { try { exchangeRate = Double.parseDouble(String.valueOf(oRate)); } catch (NumberFormatException nfe) { logger.warn("Error during currency conversion", nfe); exchangeRate = 0; } } logger.info(exchangeRate); curr.setExchangeRate(exchangeRate.doubleValue()); } else { logger.warn("Could not find exchange rate for " + curr); curr.setExchangeRate(0); // TODO kind of dodgy, should throw exception or something? } //curr.setExchangeRate(1.4); labelCurrency(cSymbol, curr); //Currency.setReferenceCurrency(curr); portfolio.setCurrency(curr); // TODO portfolio should directly store market! market.setCurrency(curr); } } List<PortfolioItemBean> portfolioItems = getPortfolioItems(); model.put(MARKET, market); model.put("currency", portfolio.getCurrency()); model.put("cash", portfolio.getCash() + ""); model.put("amount", portfolio.getAmount()); model.put("amountLocal", portfolio.getAmount().to(portfolio.getCurrency())); model.put("portfolioItems", portfolioItems); return new ModelAndView(PORTFOLIO, MODEL, model); }