List of usage examples for java.util StringTokenizer StringTokenizer
public StringTokenizer(String str, String delim)
From source file:edu.stanford.muse.index.NEROld.java
public static void readLocationsFreebase() throws IOException { InputStream is = new GZIPInputStream(NER.class.getClassLoader().getResourceAsStream("locations.gz")); LineNumberReader lnr = new LineNumberReader(new InputStreamReader(is, "UTF-8")); while (true) { String line = lnr.readLine(); if (line == null) break; StringTokenizer st = new StringTokenizer(line, "\t"); if (st.countTokens() == 3) { String locationName = st.nextToken(); String canonicalName = locationName.toLowerCase(); String lat = st.nextToken(); String longi = st.nextToken(); locations.put(canonicalName, new LocationInfo(locationName, lat, longi)); }/*from w w w.j av a2 s. c om*/ } }
From source file:org.projecthdata.social.api.connect.HDataServiceProvider.java
private static StringBuilder getBaseUrl(String ehrUrl) { URI uri = URIBuilder.fromUri(ehrUrl).build(); StringBuilder builder = new StringBuilder(); builder.append(uri.getScheme()).append("://"); builder.append(uri.getHost());// w w w .j av a2 s .c o m if (uri.getPort() >= 0) { builder.append(":").append(uri.getPort()); } if (uri.getPath() != null) { StringTokenizer tokenizer = new StringTokenizer(uri.getPath(), "/"); // if there is more than one path element, then the first one should // be the webapp name if (tokenizer.countTokens() > 1) { builder.append("/").append(tokenizer.nextToken()); } } return builder; }
From source file:com.cnksi.core.web.utils.Servlets.java
/** * ?? If-None-Match Header, Etag?.// www. j a va 2 s . com * * Etag, checkIfNoneMatchfalse, 304 not modify status. * * @param etag ETag. */ public static boolean checkIfNoneMatchEtag(HttpServletRequest request, HttpServletResponse response, String etag) { String headerValue = request.getHeader(HttpHeaders.IF_NONE_MATCH); if (headerValue != null) { boolean conditionSatisfied = false; if (!"*".equals(headerValue)) { StringTokenizer commaTokenizer = new StringTokenizer(headerValue, ","); while (!conditionSatisfied && commaTokenizer.hasMoreTokens()) { String currentToken = commaTokenizer.nextToken(); if (currentToken.trim().equals(etag)) { conditionSatisfied = true; } } } else { conditionSatisfied = true; } if (conditionSatisfied) { response.setStatus(HttpServletResponse.SC_NOT_MODIFIED); response.setHeader(HttpHeaders.ETAG, etag); return false; } } return true; }
From source file:com.adito.navigation.forms.ConfirmForm.java
public void setMessage(String message) { this.message = message; messages.clear();// w ww. j av a 2s . c om StringTokenizer t = new StringTokenizer(message == null ? "<null>" : message, "\n"); while (t.hasMoreTokens()) { messages.add(t.nextToken()); } }
From source file:net.java.sen.tools.DictionaryMaker.java
public void build() { int size = 0; // iterate variation for (Iterator i = ruleSet.iterator(); i.hasNext();) { ruleList.setSize(size + 1);// w ww. j a v a 2 s.c o m String str = (String) i.next(); rule2IdHash.put(str, new Integer(size)); // tokenList: split valiation information. StringTokenizer st = new StringTokenizer(str, ","); int len = st.countTokens(); String tokenList[] = new String[len]; for (int j = 0; j < len; j++) { tokenList[j] = st.nextToken(); } ruleList.set(size, tokenList); // System.out.println("tokenList="+tokenList[len-1]); if (tokenList[len - 1].charAt(0) != '*') isLexcalized.put(tokenList[len - 1], "1"); size++; } // System.out.println("size="+size); // System.out.println("ruleList size="+ruleList.size()); // System.out.println("test"); ruleSet.clear(); idList.setSize(ruleList.size()); for (int i = 0; i < ruleList.size(); i++) { Vector v = new Vector(); idList.set(i, v); getIdList((String[]) ruleList.get(i), (Vector) idList.get(i), 0); } }
From source file:net.sf.excelutils.tags.CallTag.java
public int[] parseTag(Object context, Workbook wb, Sheet sheet, Row curRow, Cell curCell) throws ExcelException { String cellstr = curCell.getStringCellValue(); LOG.debug("CallTag:" + cellstr); if (null == cellstr || "".equals(cellstr)) { return new int[] { 0, 0, 0 }; }/*w w w .j a va 2 s .c o m*/ cellstr = cellstr.substring(KEY_CALL.length()).trim(); String serviceName = cellstr.substring(0, cellstr.indexOf('.')); String methodName = cellstr.substring(cellstr.indexOf('.') + 1, cellstr.indexOf('(')); String paramStr = cellstr.substring(cellstr.indexOf('(') + 1, cellstr.lastIndexOf(')')); String propertyName = cellstr.substring(cellstr.lastIndexOf(')') + 1); Object[] params = new Object[0]; Class[] types = new Class[0]; // prepare params if (!"".equals(paramStr) && null != paramStr) { StringTokenizer st = new StringTokenizer(paramStr, ","); params = new Object[st.countTokens()]; types = new Class[st.countTokens()]; int index = 0; while (st.hasMoreTokens()) { String param = st.nextToken().trim(); // get param type & value types[index] = getParamType(param); if ("java.lang.Object".equals(types[index].getName())) { params[index] = ExcelParser.parseStr(context, param); types[index] = params[index].getClass(); } else if ("boolean".equals(types[index].getName())) { params[index] = Boolean.valueOf(param); } else if ("int".equals(types[index].getName())) { params[index] = Integer.valueOf(param); } else if ("double".equals(types[index].getName())) { params[index] = Double.valueOf(param); } else if ("java.lang.String".equals(types[index].getName())) { params[index] = param.substring(1, param.length() - 1); } index++; } } // get the service Object service = ExcelParser.getValue(context, serviceName); if (null == service) { return new int[] { 0, 0, 0 }; } // get the method Method method = findMethod(service, methodName, types); if (null == method) { return new int[] { 0, 0, 0 }; } // invoke method try { Object result = method.invoke(service, params); // put the result to context ExcelUtils.addValue(context, serviceName + methodName, result); // curCell.setEncoding(HSSFWorkbook.ENCODING_UTF_16); curCell.setCellValue("${" + serviceName + methodName + propertyName + "}"); ExcelParser.parseCell(context, sheet, curRow, curCell); } catch (Exception e) { } return new int[] { 0, 0, 0 }; }
From source file:com.glaf.oa.optional.web.springmvc.OptionalController.java
@ResponseBody @RequestMapping("/delete") public void delete(HttpServletRequest request, ModelMap modelMap) { LoginContext loginContext = RequestUtils.getLoginContext(request); Integer optionalId = RequestUtils.getInteger(request, "optionalId"); String optionalIds = request.getParameter("optionalIds"); if (StringUtils.isNotEmpty(optionalIds)) { StringTokenizer token = new StringTokenizer(optionalIds, ","); while (token.hasMoreTokens()) { String x = token.nextToken(); if (StringUtils.isNotEmpty(x)) { Optional optional = optionalService.getOptional(Integer.valueOf(x)); /**//w ww. ja v a2 s. c o m * */ optionalService.deleteById(Integer.valueOf(x)); if (optional != null && (StringUtils.equals(optional.getCreateBy(), loginContext.getActorId()) || loginContext.isSystemAdministrator())) { optionalService.save(optional); } } } } else if (optionalId != null) { Optional optional = optionalService.getOptional(Integer.valueOf(optionalId)); /** * */ optionalService.deleteById(Integer.valueOf(optionalId)); if (optional != null && (StringUtils.equals(optional.getCreateBy(), loginContext.getActorId()) || loginContext.isSystemAdministrator())) { optionalService.save(optional); } } }
From source file:net.codjo.dataprocess.common.codec.ListCodec.java
public List<String> decode(String listAsString) { List<String> parameters = new ArrayList<String>(); if (StringUtils.isEmpty(listAsString)) { return parameters; }//from www . j a v a 2 s . c om StringBuilder partToken = new StringBuilder(); StringTokenizer listTokenizer = new StringTokenizer(listAsString, separator); while (listTokenizer.hasMoreTokens()) { String token = listTokenizer.nextToken(); if (proceedPartTok(parameters, partToken.toString())) { partToken = new StringBuilder(); } if (token.trim().startsWith(openQuote) && token.trim().endsWith(closeQuote)) { token = removeQuote(token.trim()); if (trim) { token = token.trim(); } parameters.add(token); } else { partToken.append(token); if (!partToken.toString().trim().endsWith(closeQuote)) { partToken.append(separator); } } } proceedPartTok(parameters, partToken.toString()); return parameters; }
From source file:com.glaf.core.web.springmvc.MxSystemParamController.java
@RequestMapping("/delete") public ModelAndView delete(HttpServletRequest request, ModelMap modelMap) { Map<String, Object> params = RequestUtils.getParameterMap(request); String systemParamId = ParamUtils.getString(params, "systemParamId"); String systemParamIds = request.getParameter("systemParamIds"); if (StringUtils.isNotEmpty(systemParamIds)) { StringTokenizer token = new StringTokenizer(systemParamIds, ","); while (token.hasMoreTokens()) { String x = token.nextToken(); if (StringUtils.isNotEmpty(x)) { SystemParam systemParam = systemParamService.getSystemParam(x); if (systemParam != null) { // systemParam.setDeleteFlag(1); systemParamService.save(systemParam); }/*from ww w. j av a2 s . com*/ } } } else if (StringUtils.isNotEmpty(systemParamId)) { SystemParam systemParam = systemParamService.getSystemParam(systemParamId); if (systemParam != null) { // systemParam.setDeleteFlag(1); systemParamService.save(systemParam); } } return this.list(request, modelMap); }
From source file:com.karki.spring.dao.impl.FacilitatorDaoImpl.java
@Override public void loadData(String path) throws IOException, ClassNotFoundException, SQLException { Facilitator fac = new Facilitator(); String line = ""; BufferedReader reader = new BufferedReader(new FileReader(new File(path))); while ((line = reader.readLine()) != null) { StringTokenizer tokenizer = new StringTokenizer(line, ","); fac.setId(Integer.parseInt(tokenizer.nextToken())); fac.setName(tokenizer.nextToken()); fac.setSalary(Double.parseDouble(tokenizer.nextToken())); insert(fac);/*from w ww . j a va 2 s .co m*/ } reader.close(); }