List of usage examples for java.util StringTokenizer nextElement
public Object nextElement()
From source file:com.frameworkset.orm.engine.model.JavaNameGenerator.java
/** * Converts a database schema name to java object name. Operates * same as underscoreMethod but does not convert anything to * lowercase./*from w w w . j a va2 s . c o m*/ * * @param schemaName name to be converted. * @return converted name. * @see com.frameworkset.orm.engine.model.NameGenerator * @see #underscoreMethod(String) */ protected String javanameField(String schemaName, boolean IGNORE_FIRST_TOKEN) { StringBuffer name = new StringBuffer(); StringTokenizer tok = new StringTokenizer(schemaName, String.valueOf(STD_SEPARATOR_CHAR)); boolean first = true; while (tok.hasMoreTokens()) { String namePart = (String) tok.nextElement(); if (!first) { name.append(StringUtils.capitalize(namePart)); } else { first = false; name.append(namePart); } } // remove the SCHEMA_SEPARATOR_CHARs and capitalize // the tokens schemaName = name.toString(); name = new StringBuffer(); tok = new StringTokenizer(schemaName, String.valueOf(SCHEMA_SEPARATOR_CHAR)); first = true; while (tok.hasMoreTokens()) { String namePart = (String) tok.nextElement(); if (!first) { name.append(StringUtils.capitalize(namePart)); } else { first = false; name.append(namePart); } } return name.toString(); }
From source file:org.kuali.ole.select.service.OLEInvoiceSearchService.java
public Map<String, List<String>> getSearchCriteria(Map<String, String> itemFields) throws Exception { Map<String, List<String>> searchCriteriaMap = new HashMap<String, List<String>>(); for (Map.Entry<String, String> entry : itemFields.entrySet()) { List<String> list = new ArrayList<String>(); if (entry.getKey().equalsIgnoreCase(OleSelectConstant.InvoiceSearch.PURAP_ID)) { StringTokenizer stringTokenizer = new StringTokenizer(entry.getValue(), ","); while (stringTokenizer.hasMoreElements()) { list.add(stringTokenizer.nextElement().toString()); }/* w w w . j a va2 s .c om*/ searchCriteriaMap.put(entry.getKey().toString(), list); } else { searchCriteriaMap.put(entry.getKey().toString(), new ArrayList<String>(Arrays.asList(entry.getValue().toString()))); } } return searchCriteriaMap; }
From source file:org.kchine.rpf.db.DBLayer.java
public static String[] getPrefixes(String prefixes) { StringTokenizer st = new StringTokenizer(prefixes, ","); Vector<String> pv = new Vector<String>(); while (st.hasMoreElements()) pv.add((String) st.nextElement()); return pv.toArray(new String[0]); }
From source file:org.eclipse.californium.proxy.HttpTranslator.java
public static void getHttpDiscovery(HttpRequest httpRequest, Response coapResponse, HttpResponse httpResponse) { // TODO Auto-generated method stub String response = coapResponse.getPayloadString(); int start_index = response.indexOf("rt=\"", 0); String substring = response.substring(start_index + 4); int end_index = substring.indexOf('"', 0); String rt = substring.substring(0, end_index); StringTokenizer tokenizer = new StringTokenizer(rt, " "); String resources = ""; while (tokenizer.hasMoreElements()) { String resource = "<" + (String) tokenizer.nextElement() + ">; rel=\"type\", "; resources = resources + resource; }/*from ww w . java 2 s . c om*/ resources = resources.substring(0, resources.length() - 2); Header link = new BasicHeader("Link", resources); httpResponse.addHeader(link); }
From source file:org.wso2.carbon.andes.authorization.andes.AndesAuthorizationHandler.java
/** * Admin user and user who had add topic permission create the hierarchy topic get permission to all level by default * * @param userRealm User's Realm/* w ww . j av a2 s.co m*/ * @param topicId topic id * @param role admin role * @throws UserStoreException */ private static void grantPermissionToHierarchyLevel(UserRealm userRealm, String topicId, String role) throws UserStoreException { //tokenize resource path StringTokenizer tokenizer = new StringTokenizer(topicId, "/"); StringBuilder resourcePathBuilder = new StringBuilder(); //get token count int tokenCount = tokenizer.countTokens(); int count = 0; Pattern pattern = Pattern.compile(PARENT_RESOURCE_PATH); while (tokenizer.hasMoreElements()) { //get each element in topicId resource path String resource = tokenizer.nextElement().toString(); //build resource path again resourcePathBuilder.append(resource); //we want to give permission to any resource after event/topics/ in build resource path Matcher matcher = pattern.matcher(resourcePathBuilder.toString()); if (matcher.find()) { userRealm.getAuthorizationManager().authorizeRole(role, resourcePathBuilder.toString(), TreeNode.Permission.SUBSCRIBE.toString().toLowerCase()); userRealm.getAuthorizationManager().authorizeRole(role, resourcePathBuilder.toString(), TreeNode.Permission.PUBLISH.toString().toLowerCase()); userRealm.getAuthorizationManager().authorizeRole(role, resourcePathBuilder.toString(), PERMISSION_CHANGE_PERMISSION); } count++; if (count < tokenCount) { resourcePathBuilder.append("/"); } } }
From source file:io.hops.leaderElection.experiments.ExperimentDriver.java
private void runCommands(String file) throws FileNotFoundException, IOException, InterruptedException { if (!new File(file).exists()) { LOG.error("File Does not exists"); return;/*from www . j a v a 2s .co m*/ } BufferedReader br = new BufferedReader(new FileReader(file)); String line; while ((line = br.readLine()) != null) { if (line.startsWith("#") || line.trim().isEmpty()) { continue; } StringTokenizer st = new StringTokenizer(line, " "); int numProcesses = -1; String timeToRep = st.nextToken(); int timesToRepeat = Integer.parseInt(timeToRep); line = line.substring(timeToRep.length(), line.length()); String outputFileName = null; while (st.hasMoreElements()) { if (st.nextElement().equals("-max_processes")) { numProcesses = Integer.parseInt(st.nextToken()); outputFileName = numProcesses + ".log"; break; } } LOG.info("Going to repeat the experiment of " + timesToRepeat + " times"); for (int i = 0; i < timesToRepeat; i++) { // run command 10 times String command = line + " -output_file_path " + outputFileName; LOG.info("Driver going to run command " + command); runCommand(command); } LOG.info("Going to calculate points from file " + outputFileName); calculateNumbers(numProcesses, outputFileName); } br.close(); }
From source file:eu.europa.esig.dss.DSSUtils.java
/** * This method return the unique message id which can be used for translation purpose. * * @param message// ww w . j a v a2s . c o m * the {@code String} message on which the unique id is calculated. * @return the unique id */ public static String getMessageId(final String message) { final String message_ = message./*replace('\'', '_').*/toLowerCase().replaceAll("[^a-z_]", " "); StringBuilder nameId = new StringBuilder(); final StringTokenizer stringTokenizer = new StringTokenizer(message_); while (stringTokenizer.hasMoreElements()) { final String word = (String) stringTokenizer.nextElement(); nameId.append(word.charAt(0)); } final String nameIdString = nameId.toString(); return nameIdString.toUpperCase(); }
From source file:us.mn.state.health.lims.result.action.ResultsEntryReflexTestPopupAction.java
protected ActionForward performAction(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { // The first job is to determine if we are coming to this action with an // ID parameter in the request. If there is no parameter, we are // creating a new Result. // If there is a parameter present, we should bring up an existing // Result to edit. String id = request.getParameter(ID); String analysisId = (String) request.getParameter("analysisId"); String listOfSelectedIds = (String) request.getParameter("listOfSelectedIds"); //bugzilla 1684 String listOfSelectedIdAnalytes = (String) request.getParameter("listOfSelectedIdAnalytes"); //bugzilla 1882 String listOfSelectedIdAnalyses = (String) request.getParameter("listOfSelectedIdAnalyses"); String idSeparator = SystemConfiguration.getInstance().getDefaultIdSeparator(); StringTokenizer st = new StringTokenizer(listOfSelectedIds, idSeparator); List selectedTestResultIds = new ArrayList(); while (st.hasMoreElements()) { String trId = (String) st.nextElement(); selectedTestResultIds.add(trId); }/* w w w .ja v a2 s.com*/ //bugzilla 1684 StringTokenizer st3 = new StringTokenizer(listOfSelectedIdAnalytes, idSeparator); List selectedTestAnalyteIds = new ArrayList(); while (st3.hasMoreElements()) { String taId = (String) st3.nextElement(); selectedTestAnalyteIds.add(taId); } //bugzilla 1882 StringTokenizer st4 = new StringTokenizer(listOfSelectedIdAnalyses, idSeparator); List selectedAnalysisIds = new ArrayList(); while (st4.hasMoreElements()) { String aId = (String) st4.nextElement(); selectedAnalysisIds.add(aId); } String forward = FWD_SUCCESS; request.setAttribute(ALLOW_EDITS_KEY, "true"); request.setAttribute(PREVIOUS_DISABLED, "true"); request.setAttribute(NEXT_DISABLED, "true"); ResultsEntryReflexTestPopupActionForm dynaForm = (ResultsEntryReflexTestPopupActionForm) form; List listOfReflexTests = new ArrayList(); List listOfReflexTestIds = new ArrayList(); List listOfReflexTestsDisabledFlags = new ArrayList(); List listOfParentResults = new ArrayList(); // preload checkbox selection List preSelectedAddedTests = new ArrayList(); List listOfParentAnalytes = new ArrayList(); //bugzilla 1882 List listOfParentAnalyses = new ArrayList(); TestReflexDAO testReflexDAO = new TestReflexDAOImpl(); TestResultDAO testResultDAO = new TestResultDAOImpl(); TestAnalyteDAO testAnalyteDAO = new TestAnalyteDAOImpl(); AnalysisDAO analysisDAO = new AnalysisDAOImpl(); for (int i = 0; i < selectedTestResultIds.size(); i++) { TestResult testResult = new TestResult(); String testResultId = (String) selectedTestResultIds.get(i); testResult.setId(testResultId); testResultDAO.getData(testResult); //bugzilla 1684 TestAnalyte testAnalyte = new TestAnalyte(); String testAnalyteId = (String) selectedTestAnalyteIds.get(i); testAnalyte.setId(testAnalyteId); testAnalyteDAO.getData(testAnalyte); //bugzilla 1882 Analysis parentAnalysis = new Analysis(); String aId = (String) selectedAnalysisIds.get(i); parentAnalysis.setId(aId); analysisDAO.getData(parentAnalysis); //bugzilla 1684: added testAnalyte to criteria List reflexes = testReflexDAO.getTestReflexesByTestResultAndTestAnalyte(testResult, testAnalyte); if (reflexes != null) { for (int j = 0; j < reflexes.size(); j++) { TestReflex testReflex = (TestReflex) reflexes.get(j); String testReflexId = testReflex.getId(); testReflex.setId(testReflexId); testReflexDAO.getData(testReflex); if (testReflex != null && testReflex.getAddedTest() != null) { Test addedTest = (Test) testReflex.getAddedTest(); if (addedTest.getId() != null) { listOfReflexTestsDisabledFlags.add(NO); preSelectedAddedTests.add(addedTest.getId()); } //bugzilla 1684 - check to see if a different result //already generated this reflex test //only add it if not //bugzilla 1802 - display all reflex tests even if //already generated by diff. result //if (!listOfReflexTestIds.contains(addedTest.getId())) { listOfReflexTests.add(addedTest); listOfReflexTestIds.add(addedTest.getId()); //} listOfParentResults.add(testResult); listOfParentAnalytes.add(testAnalyte); //bugzilla 1882 listOfParentAnalyses.add(parentAnalysis); } } } } // initialize the form dynaForm.initialize(mapping); PropertyUtils.setProperty(dynaForm, "listOfReflexTests", listOfReflexTests); PropertyUtils.setProperty(dynaForm, "listOfReflexTestsDisabledFlags", listOfReflexTestsDisabledFlags); PropertyUtils.setProperty(dynaForm, "listOfParentResults", listOfParentResults); PropertyUtils.setProperty(dynaForm, "listOfParentAnalytes", listOfParentAnalytes); //bugzilla 1882 PropertyUtils.setProperty(dynaForm, "listOfParentAnalyses", listOfParentAnalyses); int numberOfPreselectedItems = preSelectedAddedTests.size(); String[] selectedAddedTests = new String[numberOfPreselectedItems]; for (int i = 0; i < preSelectedAddedTests.size(); i++) { String testId = (String) preSelectedAddedTests.get(i); selectedAddedTests[i] = testId; } PropertyUtils.setProperty(dynaForm, "selectedAddedTests", selectedAddedTests); return mapping.findForward(forward); }
From source file:org.eclipse.californium.proxy.HttpTranslator.java
public static Request createCoapRequestDiscovery(String proxyUri) throws TranslationException { // create the request -- since HTTP is reliable use CON Request coapRequest = new Request(Code.valueOf(1), Type.CON); String uri = ""; if (proxyUri.contains("?")) { int index = proxyUri.indexOf("?"); uri = proxyUri.substring(0, index); } else {/*from ww w .j a v a 2 s . c o m*/ uri = proxyUri; } String uriNoSchema = uri.substring(7); int index = uriNoSchema.indexOf('/', 0); String host = uriNoSchema.substring(0, index); String resource = uriNoSchema.substring(index + 1); StringTokenizer tokenizer = new StringTokenizer(resource, "/"); String resources = ""; while (tokenizer.hasMoreElements()) { resources = (String) tokenizer.nextElement(); } coapRequest.getOptions().setProxyUri("coap://" + host + "/.well-known/core?title=" + resources); // set the proxy as the sender to receive the response correctly try { // TODO check with multihomed hosts InetAddress localHostAddress = InetAddress.getLocalHost(); coapRequest.setDestination(localHostAddress); // TODO: setDestinationPort??? } catch (UnknownHostException e) { LOGGER.warning("Cannot get the localhost address: " + e.getMessage()); throw new TranslationException("Cannot get the localhost address: " + e.getMessage()); } return coapRequest; }
From source file:org.apache.torque.map.DatabaseMap.java
/** * Converts a database schema name to java object name. Operates * same as underscoreMethod but does not convert anything to * lowercase. This must match the javaNameMethod in the * JavaNameGenerator class in Generator code. * * @param schemaName name to be converted. * * @return converted name./* w ww . j a v a 2 s. c o m*/ */ protected String javanameMethod(String schemaName) { StringBuffer result = new StringBuffer(); StringTokenizer tok = new StringTokenizer(schemaName, String.valueOf(STD_SEPARATOR_CHAR)); while (tok.hasMoreTokens()) { String namePart = (String) tok.nextElement(); result.append(StringUtils.capitalize(namePart)); } // remove the SCHEMA_SEPARATOR_CHARs and capitalize // the tokens schemaName = result.toString(); result = new StringBuffer(); tok = new StringTokenizer(schemaName, String.valueOf(SCHEMA_SEPARATOR_CHAR)); while (tok.hasMoreTokens()) { String namePart = (String) tok.nextElement(); result.append(StringUtils.capitalize(namePart)); } return result.toString(); }