Package org.apache.flink.types.parser
Class StringParser
- java.lang.Object
-
- org.apache.flink.types.parser.FieldParser<String>
-
- org.apache.flink.types.parser.StringParser
-
@PublicEvolving public class StringParser extends FieldParser<String>
Converts a variable length field of a byte array into aString
. The byte contents between delimiters is interpreted as an ASCII string. The string may be quoted in double quotes. For quoted strings, whitespaces (space and tab) leading and trailing before and after the quotes are removed.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.apache.flink.types.parser.FieldParser
FieldParser.ParseErrorState
-
-
Constructor Summary
Constructors Constructor Description StringParser()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description String
createValue()
Returns an instance of the parsed value type.void
enableQuotedStringParsing(byte quoteCharacter)
String
getLastResult()
Gets the parsed field.int
parseField(byte[] bytes, int startPos, int limit, byte[] delimiter, String reusable)
Each parser's logic should be implemented inside this method-
Methods inherited from class org.apache.flink.types.parser.FieldParser
delimiterNext, endsWithDelimiter, getCharset, getErrorState, getParserForType, nextStringEndPos, nextStringLength, resetErrorStateAndParse, resetParserState, setCharset, setErrorState
-
-
-
-
Method Detail
-
enableQuotedStringParsing
public void enableQuotedStringParsing(byte quoteCharacter)
-
parseField
public int parseField(byte[] bytes, int startPos, int limit, byte[] delimiter, String reusable)
Description copied from class:FieldParser
Each parser's logic should be implemented inside this method- Specified by:
parseField
in classFieldParser<String>
-
createValue
public String createValue()
Description copied from class:FieldParser
Returns an instance of the parsed value type.- Specified by:
createValue
in classFieldParser<String>
- Returns:
- An instance of the parsed value type.
-
getLastResult
public String getLastResult()
Description copied from class:FieldParser
Gets the parsed field. This method returns the value parsed by the last successful invocation ofFieldParser.parseField(byte[], int, int, byte[], Object)
. It objects are mutable and reused, it will return the object instance that was passed the parse function.- Specified by:
getLastResult
in classFieldParser<String>
- Returns:
- The latest parsed field.
-
-