use of java.util.StringTokenizer in project android_frameworks_base by ParanoidAndroid.
the class UrlQuerySanitizer method parseQuery.
/**
* Parse a query. A query string is any number of parameter-value clauses
* separated by any non-zero number of ampersands. A parameter-value clause
* is a parameter followed by an equal sign, followed by a value. If the
* equal sign is missing, the value is assumed to be the empty string.
* @param query the query to parse.
*/
public void parseQuery(String query) {
clear();
// Split by '&'
StringTokenizer tokenizer = new StringTokenizer(query, "&");
while (tokenizer.hasMoreElements()) {
String attributeValuePair = tokenizer.nextToken();
if (attributeValuePair.length() > 0) {
int assignmentIndex = attributeValuePair.indexOf('=');
if (assignmentIndex < 0) {
// No assignment found, treat as if empty value
parseEntry(attributeValuePair, "");
} else {
parseEntry(attributeValuePair.substring(0, assignmentIndex), attributeValuePair.substring(assignmentIndex + 1));
}
}
}
}
use of java.util.StringTokenizer in project generator by mybatis.
the class Ibatis2FormattingUtilities method escapeStringForIbatis2.
/**
* Escape string for ibatis2.
*
* @param s
* the s
* @return the string
*/
public static String escapeStringForIbatis2(String s) {
//$NON-NLS-1$
StringTokenizer st = new StringTokenizer(s, "$#", true);
StringBuilder sb = new StringBuilder();
while (st.hasMoreTokens()) {
String token = st.nextToken();
if ("$".equals(token)) {
//$NON-NLS-1$
//$NON-NLS-1$
sb.append("$$");
} else if ("#".equals(token)) {
//$NON-NLS-1$
//$NON-NLS-1$
sb.append("##");
} else {
sb.append(token);
}
}
return sb.toString();
}
use of java.util.StringTokenizer in project mybatis-3 by mybatis.
the class BaseJdbcLogger method removeBreakingWhitespace.
protected String removeBreakingWhitespace(String original) {
StringTokenizer whitespaceStripper = new StringTokenizer(original);
StringBuilder builder = new StringBuilder();
while (whitespaceStripper.hasMoreTokens()) {
builder.append(whitespaceStripper.nextToken());
builder.append(" ");
}
return builder.toString();
}
use of java.util.StringTokenizer in project neo4j by neo4j.
the class TextUtil method tokenizeStringWithQuotes.
/**
* Tokenizes a string, regarding quotes. Examples:
*
* o '"One two"' ==> [ "One two" ]
* o 'One two' ==> [ "One", "two" ]
* o 'One "two three" four' ==> [ "One", "two three", "four" ]
*
* @param string the string to tokenize.
* @param trim whether or not to trim each token.
* @return the tokens from the line.
*/
public static String[] tokenizeStringWithQuotes(String string, boolean trim) {
if (trim) {
string = string.trim();
}
ArrayList<String> result = new ArrayList<String>();
string = string.trim();
boolean inside = string.startsWith("\"");
StringTokenizer quoteTokenizer = new StringTokenizer(string, "\"");
while (quoteTokenizer.hasMoreTokens()) {
String token = quoteTokenizer.nextToken();
if (trim) {
token = token.trim();
}
if (token.length() == 0) {
// Skip it
} else if (inside) {
// Don't split
result.add(token);
} else {
Collections.addAll(result, TextUtil.splitAndKeepEscapedSpaces(token, false));
}
inside = !inside;
}
return result.toArray(new String[result.size()]);
}
use of java.util.StringTokenizer in project generator by mybatis.
the class StringUtility method escapeStringForXml.
public static String escapeStringForXml(String s) {
//$NON-NLS-1$
StringTokenizer st = new StringTokenizer(s, "\"", true);
StringBuilder sb = new StringBuilder();
while (st.hasMoreTokens()) {
String token = st.nextToken();
if ("\"".equals(token)) {
//$NON-NLS-1$
//$NON-NLS-1$
sb.append(""");
} else {
sb.append(token);
}
}
return sb.toString();
}
Aggregations