List of usage examples for java.util StringTokenizer countTokens
public int countTokens()
From source file:com.sun.faban.harness.webclient.CLIServlet.java
String[] getPathComponents(HttpServletRequest request) { String pathInfo = request.getPathInfo(); StringTokenizer pathTokens = null; int tokenCount = 0; if (pathInfo != null) { pathTokens = new StringTokenizer(pathInfo, "/"); tokenCount = pathTokens.countTokens(); }/* ww w. j av a 2s . co m*/ String[] comps = new String[tokenCount + 1]; comps[0] = request.getServletPath(); int i = 1; while (pathTokens != null && pathTokens.hasMoreTokens()) { comps[i] = pathTokens.nextToken(); if (comps[i] != null && comps[i].length() > 0) ++i; } if (i != comps.length) { String[] comps0 = new String[i]; System.arraycopy(comps, 0, comps0, 0, i); comps = comps0; } return comps; }
From source file:org.alfresco.web.bean.workflow.StartWorkflowWizard.java
/** * Get the Names of globally excluded workflow-names. * //from w w w. j av a 2s .co m * @return The names of the workflows to exclude. */ protected List<String> getExcludedWorkflows() { if ((excludedWorkflows == null) || (Application.isDynamicConfig(FacesContext.getCurrentInstance()))) { FacesContext fc = FacesContext.getCurrentInstance(); ConfigElement config = Application.getConfigService(fc).getGlobalConfig() .getConfigElement("excluded-workflows"); if (config != null) { StringTokenizer t = new StringTokenizer(config.getValue().trim(), ", "); excludedWorkflows = new ArrayList<String>(t.countTokens()); while (t.hasMoreTokens()) { String wfName = t.nextToken(); excludedWorkflows.add(wfName); } } else { excludedWorkflows = Collections.emptyList(); } } return excludedWorkflows; }
From source file:com.ecofactor.qa.automation.drapi.DRAPI_Test.java
/** * Fetch the Event Id after creation of DR Event. * @param response the response./*from w w w.j ava 2 s . c om*/ * @return Integer. */ public int getDrEventId(final String response) { StringTokenizer st = new StringTokenizer(response, ","); String eventID = ""; while (st.hasMoreElements()) { String[] values = new String[(st.countTokens())]; for (int i = 0; i < 5; i++) { values[i] = st.nextToken(); } eventID = values[1]; } String[] eventValues = eventID.split(":"); String value = eventValues[1]; String str = value.substring(1, value.length() - 1); final int eventId = Integer.parseInt(str); return eventId; }
From source file:com.wallabystreet.kinjo.common.transport.ws.ServiceDescriptor.java
/** * Loads the transports for the described service, using the values in the * <code>properties</code> field. * <p />/*w w w .java 2s .c o m*/ * The methods expects to find the supported transports in the * <code>transport</code> property of the aforementioned field, delimited * by a colon (":"). Then, for every token found, it reads the * <code>transport.</code><i>token</i> property. Finally, the value * – which is expected to be a package name – is passed to the * {@link #loadTransportSpecificConfiguration(String)} method. * * @throws MalformedServiceException, * IIF * <ol> * <li>the "transport" property is missing, empty or invalid</li> * <li>none of the found transports could be configured * properly</li> * </ol> * * @see #loadTransportSpecificConfiguration(String) */ private void loadTransports() throws MalformedServiceException { // constant for the "transport" property token delimiter final String TRANSPORT_PROPERTY = "transport"; final String TRANSPORT_DELIMITER = ":"; /* get the "transport" property */ String supportedTransports = null; supportedTransports = this.properties.getProperty(TRANSPORT_PROPERTY); if (supportedTransports == null) { String msg = "property not found: \"" + this.properties.getProperty(TRANSPORT_PROPERTY) + "\""; if (log.isErrorEnabled()) { log.error(msg); } throw new MalformedServiceException(msg); } /* tokenize it using the delimiter constant defined above */ StringTokenizer t = new StringTokenizer(supportedTransports, TRANSPORT_DELIMITER); int transportCount = t.countTokens(); /* * check if we have at least one transport name (however, this doesn't * check whether the property is valid) */ if (transportCount < 1) { String msg = "no transports specified: " + this.pkg; if (log.isErrorEnabled()) { log.error(msg); } throw new MalformedServiceException(msg); } /* put the transport(s) into an array */ String[] transports = new String[t.countTokens()]; for (int i = 0; i < transports.length; i++) { transports[i] = t.nextToken(); } int validTransports = 0; for (String transport : transports) { String transportPackage = this.properties.getProperty(TRANSPORT_PROPERTY + "." + transport); if (transportPackage != null) { try { this.loadTransportSpecificConfiguration(transportPackage); validTransports++; } catch (MalformedTransportException e) { if (log.isWarnEnabled()) { String msg = "could not load transport-specific configuration for " + transportPackage; log.warn(msg, e); } } } else { if (log.isWarnEnabled()) { String msg = "no package specified for transport \"" + transport + "\""; log.warn(msg); } } } if (validTransports == 0) { String msg = "no transports available: " + this.pkg; if (log.isErrorEnabled()) { log.error(msg); } throw new MalformedServiceException(msg); } }
From source file:edu.ucla.stat.SOCR.chart.SuperHistogramChart.java
public void setDataTable(String input) { StringTokenizer lnTkns = new StringTokenizer(input, "#"); String line;/* w w w . j ava 2 s . c o m*/ int lineCt = lnTkns.countTokens(); resetTableRows(lineCt); int r = 0; while (lnTkns.hasMoreTokens()) { line = lnTkns.nextToken(); // String tb[] =line.split("\t"); StringTokenizer cellTkns = new StringTokenizer(line, " \t\f,");// IE use "space" Mac use tab as cell separator int cellCnt = cellTkns.countTokens(); String tb[] = new String[cellCnt]; int r1 = 0; while (cellTkns.hasMoreTokens()) { tb[r1] = cellTkns.nextToken(); r1++; } //System.out.println("tb.length="+tb.length); int colCt = tb.length; resetTableColumns(colCt); for (int i = 0; i < tb.length; i++) { //System.out.println(tb[i]); if (tb[i].length() == 0) tb[i] = "0"; dataTable.setValueAt(tb[i], r, i); } r++; } // this will update the mapping panel resetTableColumns(dataTable.getColumnCount()); // comment out, let setXLabel and setYLabel take care of this /* resetTableColumns(dataTable.getColumnCount()); TableColumnModel columnModel= dataTable.getColumnModel(); dataTable.setTableHeader(new EditableHeader(columnModel)); System.out.println(dataTable.getColumnCount() +" "+dataTable.getRowCount()); int seriesCount = dataTable.getColumnCount()/2; for (int i=0; i<seriesCount; i++){ addButtonIndependent(); addButtonDependent(); }*/ }
From source file:eu.planets_project.tb.impl.model.BasicPropertiesImpl.java
public void setExperimentedObjectType(String mimeType) throws InvalidInputException { //parse input string if it is in the format String/String StringTokenizer tokenizer = new StringTokenizer(mimeType, "/", true); if (tokenizer.countTokens() == 3) { this.vExpObjectTypes = new Vector<String>(); this.vExpObjectTypes.add(mimeType); } else {/* w ww . j av a 2 s .c o m*/ throw new InvalidInputException("ExperimentedObject MIME Type " + mimeType + " is not supported"); } }
From source file:eu.planets_project.tb.impl.model.BasicPropertiesImpl.java
public void addExperimentedObjectType(String mimeType) throws InvalidInputException { //parse input string if it is in the format String/String StringTokenizer tokenizer = new StringTokenizer(mimeType, "/", true); if (tokenizer.countTokens() == 3) { if (!this.vExpObjectTypes.contains(mimeType)) this.vExpObjectTypes.add(mimeType); } else {/*w w w . j a va 2 s . com*/ throw new InvalidInputException("ExperimentedObject MIME Type " + mimeType + " is not supported"); } }
From source file:eu.planets_project.tb.impl.model.BasicPropertiesImpl.java
public void removeExperimentedObjectType(String mimeType) throws InvalidInputException { //parse input string if it is in the format String/String StringTokenizer tokenizer = new StringTokenizer(mimeType, "/", true); if (tokenizer.countTokens() == 3) { if (!this.vExpObjectTypes.contains(mimeType)) this.vExpObjectTypes.remove(mimeType); } else {/*w w w. j a v a 2 s . c o m*/ throw new InvalidInputException("ExperimentedObject MIME Type " + mimeType + " is not supported"); } }
From source file:com.sun.identity.security.cert.AMCRLStore.java
private byte[] getCRLByHttpURI(String url) { String argString = ""; //default StringBuffer params = null;//from w w w . j a v a2 s .co m HttpURLConnection con = null; byte[] crl = null; String uriParamsCRL = storeParam.getURIParams(); try { if (uriParamsCRL != null) { params = new StringBuffer(); StringTokenizer st1 = new StringTokenizer(uriParamsCRL, ","); while (st1.hasMoreTokens()) { String token = st1.nextToken(); StringTokenizer st2 = new StringTokenizer(token, "="); if (st2.countTokens() == 2) { String param = st2.nextToken(); String value = st2.nextToken(); params.append(URLEncDec.encode(param) + "=" + URLEncDec.encode(value)); } else { continue; } if (st1.hasMoreTokens()) { params.append("&"); } } } URL uri = new URL(url); con = HttpURLConnectionManager.getConnection(uri); // Prepare for both input and output con.setDoInput(true); // Turn off Caching con.setUseCaches(false); if (params != null) { byte[] paramsBytes = params.toString().trim().getBytes("UTF-8"); if (paramsBytes.length > 0) { con.setDoOutput(true); con.setRequestProperty("Content-Length", Integer.toString(paramsBytes.length)); // Write the arguments as post data BufferedOutputStream out = new BufferedOutputStream(con.getOutputStream()); out.write(paramsBytes, 0, paramsBytes.length); out.flush(); out.close(); } } // Input ... InputStream in = con.getInputStream(); ByteArrayOutputStream bos = new ByteArrayOutputStream(); int len; byte[] buf = new byte[1024]; while ((len = in.read(buf, 0, buf.length)) != -1) { bos.write(buf, 0, len); } crl = bos.toByteArray(); if (debug.messageEnabled()) { debug.message("AMCRLStore.getCRLByHttpURI: crl.length = " + crl.length); } } catch (Exception e) { debug.error("getCRLByHttpURI : Error in getting CRL", e); } return crl; }
From source file:de.kapsi.net.daap.DaapRequest.java
/** * Sets and parses the URI. Note: if URIException is * thrown then is this Request in an inconsistent state! * * @param uri/*from w w w .j ava 2 s .co m*/ * @throws URIException */ private void setURI(URI uri) throws URIException { this.uri = uri; if (uri != null) { String path = uri.getPath(); this.queryMap = DaapUtil.parseQuery(uri.getQuery()); if (path.equals("/server-info")) { requestType = SERVER_INFO; } else if (path.equals("/content-codes")) { requestType = CONTENT_CODES; } else if (path.equals("/login")) { requestType = LOGIN; } else if (path.equals("/logout")) { requestType = LOGOUT; } else if (path.equals("/update")) { requestType = UPDATE; } else if (path.equals("/resolve")) { requestType = RESOLVE; } if (queryMap.containsKey("session-id")) { sessionId = Integer.parseInt((String) queryMap.get("session-id")); } if (sessionId != DaapUtil.NULL) { if (queryMap.containsKey("revision-number")) { revisionNumber = Integer.parseInt((String) queryMap.get("revision-number")); } if (queryMap.containsKey("delta")) { delta = Integer.parseInt((String) queryMap.get("delta")); } if (queryMap.containsKey("meta")) { metaString = (String) queryMap.get("meta"); } isUpdateType = (delta != DaapUtil.NULL) && (delta < revisionNumber); // "/databases/id/items" 3 tokens // "/databases/id/containers" 3 tokens // "/databases/id/items/id.format" 4 tokens // "/databases/id/containers/id/items" 5 tokens if (path.equals("/databases")) { requestType = DATABASES; } else if (path.startsWith("/databases")) { StringTokenizer tok = new StringTokenizer(path, "/"); int count = tok.countTokens(); if (count >= 3) { String token = tok.nextToken(); if (token.equals("databases") == false) { throw new URIException("Unknown token in path: " + path + " [" + token + "]@1"); } databaseId = Integer.parseInt((String) tok.nextToken()); token = tok.nextToken(); if (token.equals("items")) { requestType = DATABASE_SONGS; } else if (token.equals("containers")) { requestType = DATABASE_PLAYLISTS; } else { throw new URIException("Unknown token in path: " + path + " [" + token + "]@2"); } if (count == 3) { // do nothing... } else if (count == 4) { token = (String) tok.nextToken(); StringTokenizer fileTokenizer = new StringTokenizer(token, "."); if (fileTokenizer.countTokens() == 2) { itemId = Integer.parseInt(fileTokenizer.nextToken()); requestType = SONG; } else { throw new URIException("Unknown token in path: " + path + " [" + token + "]@3"); } } else if (count == 5) { containerId = Integer.parseInt((String) tok.nextToken()); token = (String) tok.nextToken(); if (token.equals("items")) { requestType = PLAYLIST_SONGS; } else { throw new URIException("Unknown token in path: " + path + " [" + token + "@4"); } } else { throw new URIException("Unknown token in path: " + path + " [" + token + "]@5"); } } else { throw new URIException("Unknown token in path: " + path); } } } } else { queryMap = null; metaString = null; isUpdateType = false; requestType = DaapUtil.NULL; databaseId = DaapUtil.NULL; containerId = DaapUtil.NULL; itemId = DaapUtil.NULL; sessionId = DaapUtil.NULL; revisionNumber = DaapUtil.NULL; delta = DaapUtil.NULL; } }