List of usage examples for java.util StringTokenizer hasMoreTokens
public boolean hasMoreTokens()
From source file:com.evolveum.liferay.usercreatehook.ws.WSConfig.java
public static List<String> getReservedScreennames() { List<String> result = new ArrayList<String>(); String value = PropsUtil.get(PROPERTY_SCREENNAME_RESERVED); if (!StringUtils.isBlank(value)) { StringTokenizer st = new StringTokenizer(value, ","); while (st.hasMoreTokens()) { String reservedScreenname = st.nextToken().trim().toLowerCase(); result.add(reservedScreenname); }/* w w w.j av a 2s .c om*/ } LOG.debug("Property '" + PROPERTY_SCREENNAME_RESERVED + "' value: '" + value + "'. Used reserved screennames from list: '" + result + "'"); return result; }
From source file:Main.java
/** * This is basically the inverse of {@link #addAndDeHump(String)}. It will remove the 'replaceThis' parameter and * uppercase the next character afterwards. * * <pre>//from ww w .j av a 2 s .c om * removeAndHump( "this-is-it", %quot;-" ); * </pre> * * will become 'ThisIsIt'. * * @param data * @param replaceThis * @return */ public static String removeAndHump(String data, String replaceThis) { String temp; StringBuilder out = new StringBuilder(); temp = data; StringTokenizer st = new StringTokenizer(temp, replaceThis); while (st.hasMoreTokens()) { String element = (String) st.nextElement(); out.append(capitalizeFirstLetter(element)); } return out.toString(); }
From source file:org.jberet.support.io.NoMappingJsonFactoryObjectFactory.java
static void configureJsonFactoryFeatures(final JsonFactory jsonFactory, final String jsonFactoryFeatures) { final StringTokenizer st = new StringTokenizer(jsonFactoryFeatures, ","); while (st.hasMoreTokens()) { final String[] pair = parseSingleFeatureValue(st.nextToken().trim()); final String key = pair[0]; final String value = pair[1]; final JsonFactory.Feature feature; try {//from w ww . j a va2 s.c o m feature = JsonFactory.Feature.valueOf(key); } catch (final Exception e1) { throw SupportMessages.MESSAGES.unrecognizedReaderWriterProperty(key, value); } if ("true".equals(value)) { if (!feature.enabledByDefault()) { jsonFactory.configure(feature, true); } } else if ("false".equals(value)) { if (feature.enabledByDefault()) { jsonFactory.configure(feature, false); } } else { throw SupportMessages.MESSAGES.invalidReaderWriterProperty(null, value, key); } } }
From source file:Main.java
/** * Replaces all contiguous sequences of #x9 (tab), #xA (line feed) and #xD * (carriage return) with a single #x20 (space) character, and removes any * leading and trailing whitespace characters, as specified for whiteSpace * facet <tt>collapse</tt>./*from w w w.java2 s. com*/ */ public static String collapseWhiteSpace(String s) { StringBuilder sb = new StringBuilder(s.length()); StringTokenizer st = new StringTokenizer(s, "\t\r\n "); if (st.hasMoreTokens()) { sb.append(st.nextToken()); } while (st.hasMoreTokens()) { sb.append(' ').append(st.nextToken()); } return sb.toString(); }
From source file:Main.java
/** * Input is "daddy[8880],sindhu[8880],camille[5555]. Return List of * InetSocketAddress/*from ww w. ja v a2 s .co m*/ */ public static List<InetSocketAddress> parseCommaDelimitedHosts2(String hosts, int port_range) { StringTokenizer tok = new StringTokenizer(hosts, ","); String t; InetSocketAddress addr; Set<InetSocketAddress> retval = new HashSet<InetSocketAddress>(); while (tok.hasMoreTokens()) { t = tok.nextToken().trim(); String host = t.substring(0, t.indexOf('[')); host = host.trim(); int port = Integer.parseInt(t.substring(t.indexOf('[') + 1, t.indexOf(']'))); for (int i = port; i < port + port_range; i++) { addr = new InetSocketAddress(host, i); retval.add(addr); } } return new LinkedList<InetSocketAddress>(retval); }
From source file:IPAddress.java
/** * Check if the specified address is a valid numeric TCP/IP address * /* w ww. jav a 2 s. c o m*/ * @param ipaddr String * @return boolean */ public final static boolean isNumericAddress(String ipaddr) { // Check if the string is valid if (ipaddr == null || ipaddr.length() < 7 || ipaddr.length() > 15) return false; // Check the address string, should be n.n.n.n format StringTokenizer token = new StringTokenizer(ipaddr, "."); if (token.countTokens() != 4) return false; while (token.hasMoreTokens()) { // Get the current token and convert to an integer value String ipNum = token.nextToken(); try { int ipVal = Integer.valueOf(ipNum).intValue(); if (ipVal < 0 || ipVal > 255) return false; } catch (NumberFormatException ex) { return false; } } // Looks like a valid IP address return true; }
From source file:Main.java
public static void initializeMap(InputStream is, boolean isPositive) { try {/*from www . j a v a 2 s .c om*/ BufferedReader reader = new BufferedReader(new InputStreamReader(is, "UTF-8")); String line = null; while ((line = reader.readLine()) != null) { StringTokenizer tokenizer = new StringTokenizer(line, "\t\n", false); String key = null; Vector<String> tokens = new Vector<String>(); if (tokenizer.hasMoreTokens()) key = tokenizer.nextToken(); while (tokenizer.hasMoreTokens()) { tokens.add(tokenizer.nextToken()); } if (key != null) { if (isPositive) posMap.put(key, tokens); else negMap.put(key, tokens); } } } catch (Exception e) { } }
From source file:com.stratuscom.harvester.Utils.java
public static String[] splitOnWhitespace(String input) { List<String> strings = new ArrayList<String>(); StringTokenizer tok = new StringTokenizer(Strings.WHITESPACE_SEPARATORS); while (tok.hasMoreTokens()) { strings.add(tok.nextToken());/*from w w w .jav a 2s. c o m*/ } return (String[]) strings.toArray(new String[0]); }
From source file:Main.java
/** * Tokenize the given String into a String array via a StringTokenizer. * <p>The given delimiters string is supposed to consist of any number of * delimiter characters. Each of those characters can be used to separate * tokens. A delimiter is always a single character; for multi-character * delimiters, consider using {@code delimitedListToStringArray} * @param str the String to tokenize/* www . j a v a 2 s .c o m*/ * @param delimiters the delimiter characters, assembled as String * (each of those characters is individually considered as delimiter) * @param trimTokens trim the tokens via String's {@code trim} * @param ignoreEmptyTokens omit empty tokens from the result array * (only applies to tokens that are empty after trimming; StringTokenizer * will not consider subsequent delimiters as token in the first place). * @return an array of the tokens ({@code null} if the input String * was {@code null}) * @see java.util.StringTokenizer * @see String#trim() * @see #delimitedListToStringArray */ public static String[] tokenizeToStringArray(String str, String delimiters, boolean trimTokens, boolean ignoreEmptyTokens) { if (str == null) { return null; } StringTokenizer st = new StringTokenizer(str, delimiters); List<String> tokens = new ArrayList<>(); while (st.hasMoreTokens()) { String token = st.nextToken(); if (trimTokens) { token = token.trim(); } if (!ignoreEmptyTokens || token.length() > 0) { tokens.add(token); } } return toStringArray(tokens); }
From source file:edu.stanford.muse.util.SloppyDates.java
public static List<DateRangeSpec> parseDateSpec(String dateSpec) { List<DateRangeSpec> result = new ArrayList<DateRangeSpec>(); StringTokenizer st = new StringTokenizer(dateSpec, ".,;"); while (st.hasMoreTokens()) { String token = st.nextToken(); result.add(new DateRangeSpec(token)); }//from w w w.j av a2s. c o m return result; }