Starting March 27, 2025, we recommend using android-latest-release
instead of aosp-main
to build and contribute to AOSP. For more information, see Changes to AOSP.
Stay organized with collections
Save and categorize content based on your preferences.
QuotationAwareTokenizer
public
class
QuotationAwareTokenizer
extends Object
java.lang.Object
|
↳ |
com.android.tradefed.util.QuotationAwareTokenizer
|
Summary
Public methods |
static
String
|
combineTokens(String... tokens)
Perform the reverse of tokenizeLine(String) .
|
static
String[]
|
tokenizeLine(String line, String delim)
|
static
String[]
|
tokenizeLine(String line)
Tokenizes the string, splitting on spaces.
|
static
String[]
|
tokenizeLine(String line, String delim, boolean logging)
Tokenizes the string, splitting on specified delimiter.
|
static
String[]
|
tokenizeLine(String line, boolean logging)
Tokenizes the string, splitting on spaces.
|
Public constructors
QuotationAwareTokenizer
public QuotationAwareTokenizer ()
Public methods
combineTokens
public static String combineTokens (String... tokens)
Perform the reverse of tokenizeLine(String)
.
Given array of tokens, combine them into a single line.
Returns |
String |
A String created from all the tokens.
|
tokenizeLine
public static String[] tokenizeLine (String line,
String delim)
Parameters |
line |
String |
delim |
String |
tokenizeLine
public static String[] tokenizeLine (String line)
Tokenizes the string, splitting on spaces. Does not split between consecutive, unquoted
double-quote marks.
See also tokenizeLine(String, String)
tokenizeLine
public static String[] tokenizeLine (String line,
String delim,
boolean logging)
Tokenizes the string, splitting on specified delimiter. Does not split between consecutive,
unquoted double-quote marks.
How the tokenizer works:
- Split the string into "characters" where each "character" is either an escaped
character like \" (that is, "\\\"") or a single real character like f (just "f").
- For each "character"
- If it's a space, finish a token unless we're being quoted
- If it's a quotation mark, flip the "we're being quoted" bit
- Otherwise, add it to the token being built
- At EOL, we typically haven't added the final token to the (tokens)
ERROR(/ArrayList)
- If the last "character" is an escape character, throw an exception; that's not
valid
- If we're in the middle of a quotation, throw an exception; that's not valid
- Otherwise, add the final token to (tokens)
- Return a String[] version of (tokens)
Parameters |
line |
String : A String to be tokenized |
delim |
String : the delimiter to split on |
logging |
boolean : whether or not to log operations |
Returns |
String[] |
A tokenized version of the string |
Throws |
IllegalArgumentException |
if the line cannot be parsed
|
tokenizeLine
public static String[] tokenizeLine (String line,
boolean logging)
Tokenizes the string, splitting on spaces. Does not split between consecutive, unquoted
double-quote marks.
See also tokenizeLine(String, String)
Parameters |
line |
String |
logging |
boolean |
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2022-08-03 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2022-08-03 UTC."],[],[]]