List of usage examples for java.util StringTokenizer hasMoreElements
public boolean hasMoreElements()
From source file:org.eclipse.smarthome.io.rest.sse.internal.util.SseUtil.java
/** * Splits the given topicFilter at any commas (",") and for each token replaces any wildcards(*) with the regex * pattern (.*)//w w w. ja v a 2 s.co m * * @param topicFilter * @return */ public static List<String> convertToRegex(String topicFilter) { List<String> filters = new ArrayList<String>(); if (StringUtils.isEmpty(topicFilter)) { filters.add(".*"); } else { StringTokenizer tokenizer = new StringTokenizer(topicFilter, ","); while (tokenizer.hasMoreElements()) { String regex = tokenizer.nextToken().trim().replace("*", ".*") + ".*"; filters.add(regex); } } return filters; }
From source file:nl.nn.adapterframework.util.ProcessUtil.java
public static List splitUpCommandString(String command) { List list = new ArrayList(); StringTokenizer stringTokenizer = new StringTokenizer(command); while (stringTokenizer.hasMoreElements()) { list.add(stringTokenizer.nextToken()); }/*from w w w . j ava 2s . c o m*/ return list; }
From source file:com.yanzhenjie.andserver.util.HttpRequestParser.java
/** * Split http params./* w w w . j a va 2 s .c o m*/ * * @param content target content. * @param lowerCaseNames Whether to put all keys are converted to lowercase. * @return parameter key-value pairs. */ public static Map<String, String> splitHttpParams(String content, boolean lowerCaseNames) { Map<String, String> paramMap = new HashMap<String, String>(); StringTokenizer tokenizer = new StringTokenizer(content, "&"); while (tokenizer.hasMoreElements()) { String keyValue = tokenizer.nextToken(); int index = keyValue.indexOf("="); if (index > 0) { String key = keyValue.substring(0, index); if (lowerCaseNames) key = key.toLowerCase(Locale.ENGLISH); paramMap.put(key, keyValue.substring(index + 1)); } } return paramMap; }
From source file:Main.java
private static List<String> splitTokens(String sentenceTosearch) { StringTokenizer tokenizer = new StringTokenizer(sentenceTosearch, "'", true); List<String> tokens = new ArrayList<>(); while (tokenizer.hasMoreElements()) { tokens.add(tokenizer.nextToken()); }// w w w . j a v a 2 s. c o m return tokens; }
From source file:org.web4thejob.studio.support.CodeFormatter.java
public static String formatCSS(String css) { if (StringUtils.isBlank(css)) { return ""; }// w ww . j a v a2s .co m try { css = (String) invocable.invokeFunction("css_beautify", "<style>" + css + "</style>", options); StringBuffer sb = new StringBuffer(); StringTokenizer tokenizer = new StringTokenizer(css, "\n", true); while (tokenizer.hasMoreElements()) { String line = tokenizer.nextToken(); if (line.contains("<style>")) { line = line.replaceFirst("<style>", ""); line = line.trim(); } else if (line.contains("</style>")) { line = line.replaceFirst("</style>", ""); } sb.append(line); } return sb.toString(); } catch (Exception e) { e.printStackTrace(); throw new RuntimeException(e); } }
From source file:org.apache.manifoldcf.crawler.connectors.cmis.CmisRepositoryConnectorUtils.java
/** * Utility method to understand if a property must be indexed or not * @param cmisQuery/* w ww . j a v a 2s. co m*/ * @param propertyId * @return TRUE if the property is included in the select clause of the query, otherwise it will return FALSE */ public static boolean existsInSelectClause(String cmisQuery, String propertyId) { String selectClause = getSelectClause(cmisQuery); if (selectClause.startsWith(SELECT_STAR_CLAUSE)) { return true; } else { StringTokenizer cmisQueryTokenized = new StringTokenizer(cmisQuery.trim()); while (cmisQueryTokenized.hasMoreElements()) { String term = cmisQueryTokenized.nextToken(); if (!term.equalsIgnoreCase(FROM_TOKEN)) { if (term.equalsIgnoreCase(propertyId)) { return true; } else if (StringUtils.contains(term, SELECT_CLAUSE_TERM_SEP)) { //in this case means that we have: select cmis:objectId,cmis:name from ... StringTokenizer termsTokenized = new StringTokenizer(term, SELECT_CLAUSE_TERM_SEP); while (termsTokenized.hasMoreElements()) { String termTokenized = termsTokenized.nextToken().trim(); if (termTokenized.equalsIgnoreCase(propertyId)) { return true; } } } } else { break; } } return false; } }
From source file:ca.uhn.fhir.rest.method.QualifiedParamList.java
public static QualifiedParamList splitQueryStringByCommasIgnoreEscape(String theQualifier, String theParams) { QualifiedParamList retVal = new QualifiedParamList(); retVal.setQualifier(theQualifier);//from www .j a va 2 s. c o m StringTokenizer tok = new StringTokenizer(theParams, ",", true); String prev = null; while (tok.hasMoreElements()) { String str = tok.nextToken(); if (isBlank(str)) { prev = null; continue; } if (str.equals(",")) { if (countTrailingSlashes(prev) % 2 == 1) { int idx = retVal.size() - 1; String existing = retVal.get(idx); prev = existing.substring(0, existing.length() - 1) + ','; retVal.set(idx, prev); } else { prev = null; } continue; } if (prev != null && prev.length() > 0 && prev.charAt(prev.length() - 1) == ',') { int idx = retVal.size() - 1; String existing = retVal.get(idx); prev = existing + str; retVal.set(idx, prev); } else { retVal.add(str); prev = str; } } return retVal; }
From source file:com.intel.iotkitlib.utils.Utilities.java
public static Map.Entry<String, ?> getSensorMatch(String componentName) { Boolean found = false;//from w w w . j a v a 2 s . co m Map.Entry<String, ?> sensorMatch = null; Map<String, ?> preferencesAll = Utilities.sharedPreferences.getAll(); for (Map.Entry<String, ?> entry : preferencesAll.entrySet()) { Log.d(TAG, entry.getKey() + " :" + entry.getValue().toString()); if (entry.getKey().contains("sensor")) { StringTokenizer tokenizer = new StringTokenizer(entry.getKey(), "-"); while (tokenizer.hasMoreElements()) { if (tokenizer.nextToken().equals(componentName)) { Log.d(TAG, "sensor/component found in shared preferences"); found = true; sensorMatch = entry; break; } } if (found) { break; } } } return sensorMatch; }
From source file:org.sakaiproject.tool.assessment.ui.listener.evaluation.util.EvaluationListenerUtil.java
/** * Utility// w w w .ja v a2 s . c om * @param correctAnswerVar * @param answerVar * @return true if correct */ public static boolean answerRight(String correctAnswerVar, String answerVar) { StringTokenizer st = new StringTokenizer(correctAnswerVar, "|"); while (st.hasMoreElements()) { String correct = st.nextToken(); if (correct.equals(answerVar)) { return true; // match } } return false; }
From source file:org.apache.hadoop.io.compress.CompressionCodecFactory.java
/** * Get the list of codecs listed in the configuration * @param conf the configuration to look in * @return a list of the Configuration classes or null if the attribute * was not set/* w w w. j av a 2s. co m*/ */ public static List<Class<? extends CompressionCodec>> getCodecClasses(Configuration conf) { String codecsString = conf.get("io.compression.codecs"); if (codecsString != null) { List<Class<? extends CompressionCodec>> result = new ArrayList<Class<? extends CompressionCodec>>(); StringTokenizer codecSplit = new StringTokenizer(codecsString, ","); while (codecSplit.hasMoreElements()) { String codecSubstring = codecSplit.nextToken(); if (codecSubstring.length() != 0) { try { Class<?> cls = conf.getClassByName(codecSubstring); if (!CompressionCodec.class.isAssignableFrom(cls)) { throw new IllegalArgumentException( "Class " + codecSubstring + " is not a CompressionCodec"); } result.add(cls.asSubclass(CompressionCodec.class)); } catch (ClassNotFoundException ex) { throw new IllegalArgumentException("Compression codec " + codecSubstring + " not found.", ex); } } } return result; } else { return null; } }