List of usage examples for java.util StringTokenizer StringTokenizer
public StringTokenizer(String str, String delim)
From source file:com.gistlabs.mechanize.impl.MechanizeInitializer.java
static List<String> getClassNames(final String forSystemProperty, final String orDefaultValue) { List<String> result = new ArrayList<String>(); String propertyValue = System.getProperty(forSystemProperty); if (propertyValue == null || "".equals(propertyValue)) propertyValue = orDefaultValue;/*w w w . j av a 2 s .c om*/ StringTokenizer tokenizer = new StringTokenizer(propertyValue, ","); while (tokenizer.hasMoreTokens()) result.add(tokenizer.nextToken().trim()); return result; }
From source file:com.ge.predix.sample.blobstore.connector.cloudfoundry.BlobstoreServiceInfoCreator.java
/** * Reads the VCAP_SERVICES and generates the Service Info Object * * @param serviceData injected by CloudFoundry with the metadata for the service * @return BlobstoreServiceInfo Service Info Object *//*from w ww. ja v a2 s.c o m*/ @Override public BlobstoreServiceInfo createServiceInfo(Map<String, Object> serviceData) { @SuppressWarnings("unchecked") Map<String, Object> credentials = (Map<String, Object>) serviceData.get("credentials"); String id = (String) serviceData.get("name"); String objectStoreAccessKey = (String) credentials.get("access_key_id"); String objectStoreSecretKey = (String) credentials.get("secret_access_key"); String endPointWithBucket = (String) credentials.get("url"); String host = (String) credentials.get("host"); String bucket = (String) credentials.get("bucket_name"); // Extract protocol for endpoint without bucket name StringTokenizer st = new StringTokenizer(endPointWithBucket, "://"); String protocol = ""; if (st.hasMoreTokens()) { protocol = st.nextToken(); } String url = ""; url = protocol + "://" + host; BlobstoreServiceInfo objectStoreInfo = new BlobstoreServiceInfo(id, objectStoreAccessKey, objectStoreSecretKey, bucket, url); log.info("createServiceInfo(): " + objectStoreInfo); return objectStoreInfo; }
From source file:com.glaf.base.district.web.springmvc.DistrictController.java
@ResponseBody @RequestMapping("/delete") public void delete(HttpServletRequest request, ModelMap modelMap) { LoginContext loginContext = RequestUtils.getLoginContext(request); Long id = RequestUtils.getLong(request, "id"); String ids = request.getParameter("ids"); if (StringUtils.isNotEmpty(ids)) { StringTokenizer token = new StringTokenizer(ids, ","); while (token.hasMoreTokens()) { String x = token.nextToken(); if (StringUtils.isNotEmpty(x)) { DistrictEntity district = districtService.getDistrict(Long.valueOf(x)); if (district != null && (StringUtils.equals(district.getCreateBy(), loginContext.getActorId()) || loginContext.isSystemAdministrator())) { districtService.deleteById(district.getId()); }/* w w w . j a va 2s .c om*/ } } } else if (id != null) { DistrictEntity district = districtService.getDistrict(Long.valueOf(id)); if (district != null && (StringUtils.equals(district.getCreateBy(), loginContext.getActorId()) || loginContext.isSystemAdministrator())) { districtService.deleteById(district.getId()); } } }
From source file:org.endeavour.mgmt.controller.servlet.CreateProjectPlan.java
public void doGet(HttpServletRequest aRequest, HttpServletResponse aResponse) throws IOException { try {/*from w w w. java 2s .co m*/ Document theDocument = new Document(PageSize.A4.rotate()); aResponse.setContentType("application/pdf"); PdfWriter.getInstance(theDocument, aResponse.getOutputStream()); theDocument.open(); String theProjectIdValue = aRequest.getParameter(ProjectPlanMaintenance.PROJECT_ID); StringTokenizer theId = new StringTokenizer(theProjectIdValue, ":"); Integer theProjectId = new Integer(theId.nextToken()); ProjectPlanMaintenance thePlanMaintenance = new ProjectPlanMaintenance(null); List<IPlanElement> thePlanElements = thePlanMaintenance.getProjectPlanReportingData(theProjectId); Task theTask = null; IPlanElement thePlanElement = null; TaskSeries theSeries = new TaskSeries(SCHEDULED); int theDataSetIndex = 0; Date theStartDate = null; Date theEndDate = null; String theDescription = null; for (int i = 0; i < thePlanElements.size(); i++) { thePlanElement = thePlanElements.get(i); theTask = new Task(thePlanElement.getElementType() + " : " + thePlanElement.getName(), thePlanElement.getStartDate(), thePlanElement.getEndDate()); theTask.setPercentComplete(thePlanElement.getProgress() * 0.01); theSeries.add(theTask); if (i == 0) { theStartDate = thePlanElement.getStartDate(); theEndDate = thePlanElement.getEndDate(); theDescription = thePlanElement.getElementType() + " : " + thePlanElement.getName(); } theDataSetIndex++; // Each page displays up to 25 tasks before creating a new one. if (theDataSetIndex == 25) { theDataSetIndex = 0; this.createReportPage(theDocument, theSeries, theStartDate, theEndDate, theDescription); theSeries = new TaskSeries(SCHEDULED); } } this.createReportPage(theDocument, theSeries, theStartDate, theEndDate, theDescription); theDocument.close(); } catch (Exception e) { e.printStackTrace(); } }
From source file:edu.ucsb.nceas.metacat.lsid.LSIDDataLookup.java
public String getDocType(LSID lsid) { // example/*from w ww.j a va 2 s .com*/ //http://metacat.nceas.ucsb.edu/knb/metacat?action=getrevisionanddoctype&docid=knb-lter-gce.109.6 // returns rev;doctype String _docType = null; String ns = lsid.getNamespace(); String id = lsid.getObject(); String ver = lsid.getRevision(); InputStream docStream = null; ResourceBundle rb = ResourceBundle.getBundle("metacat-lsid"); String theServer = rb.getString("metacatserver"); logger.debug("the server is " + theServer); String url = theServer + "?action=getrevisionanddoctype&docid="; url = url + ns + "." + id + "." + ver; try { URL theDoc = new URL(url); docStream = theDoc.openStream(); StringTokenizer _st = new StringTokenizer(LSIDAuthorityMetaData.getStringFromInputStream(docStream), ";"); _st.nextToken(); _docType = _st.nextToken(); docStream.close(); } catch (MalformedURLException mue) { logger.error("MalformedURLException in LSIDDataLookup: " + mue); mue.printStackTrace(); } catch (IOException ioe) { logger.error("IOException in LSIDDataLookup: " + ioe); ioe.printStackTrace(); } return _docType; }
From source file:net.sf.click.jquery.examples.util.StartupListener.java
private void loadCustomers() throws IOException { // Load customers data file loadFile("customers.txt", new LineProcessor() { public void processLine(String line) { StringTokenizer tokenizer = new StringTokenizer(line, ","); Customer customer = new Customer(); customer.setId(nextId());//w w w.j a v a2 s . c om customer.setName(next(tokenizer)); if (tokenizer.hasMoreTokens()) { customer.setEmail(next(tokenizer)); } if (tokenizer.hasMoreTokens()) { customer.setAge(Integer.valueOf(next(tokenizer))); } if (tokenizer.hasMoreTokens()) { customer.setInvestments(next(tokenizer)); } if (tokenizer.hasMoreTokens()) { customer.setHoldings(Double.valueOf(next(tokenizer))); } if (tokenizer.hasMoreTokens()) { customer.setDateJoined(createDate(next(tokenizer))); } if (tokenizer.hasMoreTokens()) { customer.setActive(Boolean.valueOf(next(tokenizer))); } CUSTOMERS.add(customer); } }); }
From source file:cn.com.qiqi.order.utils.Servlets.java
/** * ?? If-None-Match Header, Etag?./*from ww w. j av a 2 s. c o m*/ * * 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.glaf.core.web.springmvc.MxSchedulerLogController.java
@ResponseBody @RequestMapping("/delete") public byte[] delete(HttpServletRequest request, ModelMap modelMap) { LoginContext loginContext = RequestUtils.getLoginContext(request); logger.debug(RequestUtils.getParameterMap(request)); String id = RequestUtils.getString(request, "id"); String ids = request.getParameter("ids"); if (StringUtils.isNotEmpty(ids)) { StringTokenizer token = new StringTokenizer(ids, ","); while (token.hasMoreTokens()) { String x = token.nextToken(); if (StringUtils.isNotEmpty(x)) { SchedulerLog schedulerLog = schedulerLogService.getSchedulerLog(String.valueOf(x)); if (schedulerLog != null && (StringUtils.equals(schedulerLog.getCreateBy(), loginContext.getActorId()) || loginContext.isSystemAdministrator())) { schedulerLogService.deleteById(schedulerLog.getId()); }/*from w ww.j ava2 s . com*/ } } return ResponseUtils.responseResult(true); } else if (id != null) { SchedulerLog schedulerLog = schedulerLogService.getSchedulerLog(String.valueOf(id)); if (schedulerLog != null && (StringUtils.equals(schedulerLog.getCreateBy(), loginContext.getActorId()) || loginContext.isSystemAdministrator())) { schedulerLogService.deleteById(schedulerLog.getId()); return ResponseUtils.responseResult(true); } } return ResponseUtils.responseResult(false); }
From source file:com.microsoftopentechnologies.windowsazurestorage.service.UploadService.java
@Override public final int execute() throws WAStorageException { if (serviceData.getUploadType() == UploadType.INVALID) { // no files are uploaded println("Upload type is INVALID, nothing to do."); return 0; }/*from w ww . j a v a 2 s . c om*/ int filesUploaded = 0; // Counter to track no. of files that are uploaded try { final FilePath workspacePath = serviceData.getRemoteWorkspace(); println(Messages.WAStoragePublisher_uploading()); final StringBuilder archiveIncludes = new StringBuilder(); StringTokenizer strTokens = new StringTokenizer(serviceData.getFilePath(), fpSeparator); while (strTokens.hasMoreElements()) { String fileName = strTokens.nextToken(); String embeddedVP = null; if (fileName != null && fileName.contains("::")) { int embVPSepIndex = fileName.indexOf("::"); // Separate fileName and Virtual directory name if (fileName.length() > embVPSepIndex + 1) { embeddedVP = fileName.substring(embVPSepIndex + 2, fileName.length()); if (StringUtils.isBlank(embeddedVP)) { embeddedVP = null; } else if (!embeddedVP.endsWith(Constants.FWD_SLASH)) { embeddedVP = embeddedVP + Constants.FWD_SLASH; } } fileName = fileName.substring(0, embVPSepIndex); } // List all the paths without the zip archives. FilePath[] paths = workspacePath.list(fileName, excludedFilesAndZip()); archiveIncludes.append(",").append(fileName); filesUploaded += paths.length; if (paths.length != 0 && serviceData.getUploadType() != UploadType.ZIP) { // the uploadType is either INDIVIDUAL or BOTH, upload included individual files thus. uploadIndividuals(embeddedVP, paths); } } // if uploadType is BOTH or ZIP, create an archive.zip and upload if (filesUploaded != 0 && (serviceData.getUploadType() != UploadType.INDIVIDUAL)) { uploadArchive(archiveIncludes.toString()); } } catch (IOException | InterruptedException e) { throw new WAStorageException(e.getMessage(), e.getCause()); } return filesUploaded; }
From source file:com.abiquo.server.core.util.network.IPAddress.java
/** * IP Address constructor/*from w ww .java2 s . c om*/ * * @param ipAddress */ private IPAddress(String ipAddress) { // parse the string to delete all the 0's in the left of the . StringTokenizer tokenizer = new StringTokenizer(ipAddress, "."); // Thanks to the static method we can be sure we have 4 tokens // and they live between 0 and 256 int tokenOne = Integer.parseInt(tokenizer.nextToken()); int tokenTwo = Integer.parseInt(tokenizer.nextToken()); int tokenThree = Integer.parseInt(tokenizer.nextToken()); int tokenFour = Integer.parseInt(tokenizer.nextToken()); ip = tokenOne + "." + tokenTwo + "." + tokenThree + "." + tokenFour; }