List of usage examples for java.util StringTokenizer nextToken
public String nextToken()
From source file:Main.java
public static QName getNamespace(Map<String, String> namespaces, String str, String defaultNamespace) { String prefix = null;//from w w w . j a v a 2s . c om String localName = null; StringTokenizer tokenizer = new StringTokenizer(str, ":"); if (tokenizer.countTokens() == 2) { prefix = tokenizer.nextToken(); localName = tokenizer.nextToken(); } else if (tokenizer.countTokens() == 1) { localName = tokenizer.nextToken(); } String namespceURI = defaultNamespace; if (prefix != null) { namespceURI = namespaces.get(prefix); } return new QName(namespceURI, localName); }
From source file:Main.java
/** * Parses a string of given stop:line entries into a list *//*from www .j a v a 2s. c o m*/ public static ArrayList<String> parseString(String list) { ArrayList<String> result = new ArrayList<String>(); StringTokenizer tokenizer = new StringTokenizer(list, ","); while (tokenizer.hasMoreTokens()) { result.add(tokenizer.nextToken()); } return result; }
From source file:Main.java
/** * Converts a path into a <code>List</code> of element names. * * @param childPath a path. e.g. "aaa:bbb/ccc:ddd/eee" * @return a <code>List</code> of element names. * e.g. "aaa:bbb", "ccc:ddd", "eee".//from w w w. j a va2 s .c om */ private static List getElementNames(final String childPath) { List<String> strArray = new ArrayList<>(); if (childPath != null) { StringTokenizer st = new StringTokenizer(childPath, elementDelim); while (st.hasMoreTokens()) { String token = st.nextToken(); if (token.length() > 0) { strArray.add(token); } } } return strArray; }
From source file:cc.recommenders.utils.parser.MavenVersionParser.java
private static void consumeDelimiter(final StringTokenizer st, final String... allowedDelimiters) { final String delimiter = st.nextToken(); for (final String allowedDelimiter : allowedDelimiters) { if (delimiter.equals(allowedDelimiter)) { return; }//from www . j a v a 2 s. c om } Throws.throwIllegalArgumentException("Unexpected delimiter '%s'; Expected delimiters '%s'", delimiter, StringUtils.join(allowedDelimiters, "','")); }
From source file:Main.java
/** * get the name of an XML element, with the namespace prefix stripped off * @param el/* ww w . j ava2s . c om*/ * @return */ public static String getLocalName(Node el) { String locName = ""; StringTokenizer st = new StringTokenizer(el.getNodeName(), ":"); while (st.hasMoreTokens()) locName = st.nextToken(); return locName; }
From source file:Main.java
/** * Converts a path into a <code>List</code> of element names. * * @param childPath a path. e.g. "aaa:bbb/ccc:ddd/eee" * * @return a <code>List</code> of element names. * e.g. "aaa:bbb", "ccc:ddd", "eee". *//*from w ww .ja v a2 s. c o m*/ private static List getElementNames(final String childPath) { List strArray = new ArrayList(); if (childPath != null) { StringTokenizer st = new StringTokenizer(childPath, elementDelim); while (st.hasMoreTokens()) { String token = st.nextToken(); if (token.length() > 0) { strArray.add(token); } } } return strArray; }
From source file:Main.java
/** * Loads the given expansion state of a JTree, making it expand in the given manner. * //from w ww . j a va2 s . com * @param tree * The JTree to be expended * @param enumeration * The expansion state for tree as Enumeration<TreePath> */ public static void loadTreeExpansionState(JTree tree, String expansionState, int row) { // if a tree is opened for the first time, its expansionState is null if (expansionState == null) { return; } StringTokenizer stok = new StringTokenizer(expansionState, ","); while (stok.hasMoreTokens()) { int token = row + Integer.parseInt(stok.nextToken()); tree.expandRow(token); } }
From source file:Main.java
public static int findProcessIdWithPS(String command) throws Exception { int procId = -1; Runtime r = Runtime.getRuntime(); Process procPs = null;/* w w w. ja v a 2 s.com*/ procPs = r.exec(SHELL_CMD_PS); BufferedReader reader = new BufferedReader(new InputStreamReader(procPs.getInputStream())); String line = null; while ((line = reader.readLine()) != null) { if (line.indexOf(' ' + command) != -1) { StringTokenizer st = new StringTokenizer(line, " "); st.nextToken(); // proc owner procId = Integer.parseInt(st.nextToken().trim()); break; } } return procId; }
From source file:Main.java
public static int findProcessIdWithPS(String command) throws Exception { int procId = -1; Runtime r = Runtime.getRuntime(); Process procPs = null;/*from w w w . j av a2 s . c o m*/ procPs = r.exec(SHELL_CMD_PS); BufferedReader reader = new BufferedReader(new InputStreamReader(procPs.getInputStream())); String line = null; while ((line = reader.readLine()) != null) { if (line.indexOf(' ' + command) != -1) { StringTokenizer st = new StringTokenizer(line, " "); st.nextToken(); //proc owner procId = Integer.parseInt(st.nextToken().trim()); break; } } return procId; }
From source file:Main.java
public static List parseTokenList(String tokenList) { List result = new ArrayList(); StringTokenizer tokenizer = new StringTokenizer(tokenList, " "); while (tokenizer.hasMoreTokens()) { result.add(tokenizer.nextToken()); }/* www. j av a2s . co m*/ return result; }