@ -1294,20 +1294,11 @@ public final class TextFormat {
return consumeByteString ( ) . toStringUtf8 ( ) ;
}
/** If the next token is a string, consume it and return true. Otherwise, return false. */
boolean tryConsumeString ( ) {
try {
consumeString ( ) ;
return true ;
} catch ( ParseException e ) {
return false ;
}
}
/ * *
* If the next token is a string , consume it , unescape it as a { @link ByteString } , and return
* it . Otherwise , throw a { @link ParseException } .
* /
@CanIgnoreReturnValue
ByteString consumeByteString ( ) throws ParseException {
List < ByteString > list = new ArrayList < ByteString > ( ) ;
consumeByteString ( list ) ;
@ -1317,6 +1308,16 @@ public final class TextFormat {
return ByteString . copyFrom ( list ) ;
}
/** If the next token is a string, consume it and return true. Otherwise, return false. */
boolean tryConsumeByteString ( ) {
try {
consumeByteString ( ) ;
return true ;
} catch ( ParseException e ) {
return false ;
}
}
/ * *
* Like { @link # consumeByteString ( ) } but adds each token of the string to the given list . String
* literals ( whether bytes or text ) may come in multiple adjacent tokens which are automatically
@ -2282,11 +2283,8 @@ public final class TextFormat {
/** Skips a field value. */
private void skipFieldValue ( Tokenizer tokenizer ) throws ParseException {
if ( tokenizer . tryConsumeString ( ) ) {
while ( tokenizer . tryConsumeString ( ) ) { }
return ;
}
if ( ! tokenizer . tryConsumeIdentifier ( ) // includes enum & boolean
if ( ! tokenizer . tryConsumeByteString ( )
& & ! tokenizer . tryConsumeIdentifier ( ) // includes enum & boolean
& & ! tokenizer . tryConsumeInt64 ( ) // includes int32
& & ! tokenizer . tryConsumeUInt64 ( ) // includes uint32
& & ! tokenizer . tryConsumeDouble ( )