Java Code Examples for com.codename1.util.StringUtil#tokenizeString()
The following examples show how to use
com.codename1.util.StringUtil#tokenizeString() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AbstractEvaluator.java From CodenameOne with GNU General Public License v2.0 | 5 votes |
/** * Utility method for subclasses to convert a string to an array, delimited * by comma, optionally enclosed in brackets, and elements optionally * enclosed in quotes. * * @param text value to transform * @return the value as an array. */ protected String[] explode(String arrayAsString) { arrayAsString = arrayAsString.trim(); if (arrayAsString.startsWith("(") && arrayAsString.endsWith(")")) { arrayAsString = arrayAsString.substring(1, arrayAsString.length() - 1); } List v = StringUtil.tokenizeString(arrayAsString, ','); String a[] = new String[v.size()]; for (int i = 0; i < v.size(); i++) { a[i] = stripQuotes(v.get(i).toString().trim()); } return a; }
Example 2
Source File: UIManager.java From CodenameOne with GNU General Public License v2.0 | 5 votes |
private Hashtable parseTextFieldInputMode(String s) { Vector tokens = StringUtil.tokenizeString(s, '|'); Hashtable response = new Hashtable(); int count = tokens.size(); for(int iter = 0 ; iter < count ; iter++) { String t = (String)tokens.elementAt(iter); int pos = t.indexOf('='); String key = t.substring(0, pos); String val = t.substring(pos + 1); response.put(Integer.valueOf(key), val); } return response; }
Example 3
Source File: UIManager.java From CodenameOne with GNU General Public License v2.0 | 5 votes |
private String[][] tokenizeMultiArray(String s, char separator, char lineBreak) { Vector lines = StringUtil.tokenizeString(s, lineBreak); int lineCount = lines.size(); String[][] result = new String[lineCount][]; for(int iter = 0 ; iter < lineCount ; iter++) { String currentString = (String)lines.elementAt(iter); result[iter] = toStringArray(StringUtil.tokenizeString(currentString, separator)); } return result; }
Example 4
Source File: GameCanvasImplementation.java From CodenameOne with GNU General Public License v2.0 | 4 votes |
/** * @inheritDoc */ public String[] getHeaderFields(String name, Object connection) throws IOException { HttpConnection c = (HttpConnection)connection; Vector r = new Vector(); int i = 0; while (c.getHeaderFieldKey(i) != null) { if (c.getHeaderFieldKey(i).equalsIgnoreCase(name)) { String val = c.getHeaderField(i); //some J2ME devices such as Nokia send all the cookies in one //header spereated by commas if(name.equalsIgnoreCase("Set-Cookie")){ //it is not possible to simply tokenize on comma, because //the expiration date of each cookie contains a comma, therefore //we temporary remove this comma tokenize all the cookies and then //fixing the comma in the expiration date String cookies = ""; Vector v = StringUtil.tokenizeString(val, ';'); for (int j = 0; j < v.size(); j++) { String keyval = (String) v.elementAt(j); if(keyval.indexOf("expires") > -1){ keyval = StringUtil.replaceAll(keyval, ",", "@__@"); } cookies += keyval + ";"; } cookies = cookies.substring(0, cookies.length() - 1); if(cookies.indexOf(",") > -1){ Vector v2 = StringUtil.tokenizeString(cookies, ','); for (int j = 0; j < v2.size(); j++) { String value = (String) v2.elementAt(j); value = StringUtil.replaceAll(value, "@__@", ","); r.addElement(value); } } }else{ r.addElement(val); } } i++; } if(r.size() == 0) { return null; } String[] response = new String[r.size()]; for(int iter = 0 ; iter < response.length ; iter++) { response[iter] = (String)r.elementAt(iter); } return response; }