List of usage examples for java.util StringTokenizer countTokens
public int countTokens()
From source file:com.sun.faces.generate.HtmlTaglibGenerator.java
/** * Main routine.//w w w . j a va 2 s . co m */ public static void main(String args[]) throws Exception { try { // Perform setup operations if (log.isDebugEnabled()) { log.debug("Processing command line options"); } Map options = options(args); String dtd = (String) options.get("--dtd"); if (log.isDebugEnabled()) { log.debug("Configuring digester instance with public identifiers and DTD '" + dtd + "'"); } StringTokenizer st = new StringTokenizer(dtd, "|"); int arrayLen = st.countTokens(); if (arrayLen == 0) { // PENDING I18n throw new Exception("No DTDs specified"); } String[] dtds = new String[arrayLen]; int i = 0; while (st.hasMoreTokens()) { dtds[i] = st.nextToken(); i++; } copyright((String) options.get("--copyright")); directories((String) options.get("--tlddir"), false); Digester digester = digester(dtds, false, true, false); String config = (String) options.get("--config"); loadOptionalTags((String) options.get("--tagdef")); if (log.isDebugEnabled()) { log.debug("Parsing configuration file '" + config + "'"); } digester.push(new FacesConfigBean()); fcb = parse(digester, config); if (log.isInfoEnabled()) { log.info("Generating Tag Library Descriptor file"); } // Generate TLD File generateTld(); // Generate Tag Handler Classes directories((String) options.get("--dir"), true); generateTagClasses(); } catch (Exception e) { e.printStackTrace(); System.exit(1); } System.exit(0); }
From source file:Main.java
private static String[] tokenize(String str) { StringTokenizer tokenizer = new StringTokenizer(str); String[] arr = new String[tokenizer.countTokens()]; int i = 0;//from w ww . j a v a2s. co m while (tokenizer.hasMoreTokens()) { arr[i++] = tokenizer.nextToken(); } return arr; }
From source file:Main.java
public static long[] strToArrayOfLong(String str) { StringTokenizer tmpst = new StringTokenizer(str, "|", false); int len = tmpst.countTokens(); long[] retl = new long[len]; for (int i = 0; i < len; i++) { retl[i] = Long.parseLong(tmpst.nextToken()); }/*w ww.j ava2 s .co m*/ return retl; }
From source file:Main.java
private static String getElementInPathAtPosixFromEnd(String path, int posix) { StringTokenizer st = new StringTokenizer(path, "."); int cpt = st.countTokens(); // if (cpt==1) // return root; int i = cpt - posix; for (int j = 0; j < i; j++) { st.nextToken();//from w w w .j a v a 2 s . c o m } return (String) st.nextToken(); }
From source file:Main.java
public static String[] strToArrayOfString(String str) { if (str == null) { return new String[0]; }// ww w .ja v a2 s. c om StringTokenizer tmpst = new StringTokenizer(str, "|", false); int len = tmpst.countTokens(); String[] retl = new String[len]; for (int i = 0; i < len; i++) { retl[i] = tmpst.nextToken(); } return retl; }
From source file:Main.java
public static String[] parseExtensions(String extensions) { StringTokenizer st = new StringTokenizer(extensions, ","); String[] ext = new String[st.countTokens()]; int i = 0;/*from w ww. j a v a2 s . com*/ while (st.hasMoreTokens()) { ext[i++] = st.nextToken(); } return ext; }
From source file:Main.java
public static String[] toStringArray(String s) { StringTokenizer st = new StringTokenizer(s); String[] array = new String[st.countTokens()]; for (int i = 0; st.hasMoreTokens(); i++) array[i] = st.nextToken();/*from w ww. ja v a2s. com*/ return array; }
From source file:Util.java
/** Parse comma-separated list of ints and return as array. */ public static int[] splitInts(String str) throws IllegalArgumentException { StringTokenizer tokenizer = new StringTokenizer(str, ","); int n = tokenizer.countTokens(); int[] list = new int[n]; for (int i = 0; i < n; i++) { String token = tokenizer.nextToken(); list[i] = Integer.parseInt(token); }/*from w w w. j a v a 2 s . c o m*/ return list; }
From source file:Main.java
private static String[] parseCommandStr(String str) { StringTokenizer st = new StringTokenizer(str, "|"); String[] command_arr = new String[st.countTokens()]; int i = 0;//from w w w. ja va 2 s. co m while (st.hasMoreElements()) { command_arr[i] = (String) st.nextElement(); i++; } return command_arr; }
From source file:Util.java
/** Parse comma-separated list of longs and return as array. */ public static long[] splitLongs(String str) throws IllegalArgumentException { StringTokenizer tokenizer = new StringTokenizer(str, ","); int n = tokenizer.countTokens(); long[] list = new long[n]; for (int i = 0; i < n; i++) { String token = tokenizer.nextToken(); list[i] = Long.parseLong(token); }//from www . j ava 2 s . co m return list; }