Package org.apache.flink.types.parser
Class BigDecParser
- java.lang.Object
-
- org.apache.flink.types.parser.FieldParser<BigDecimal>
-
- org.apache.flink.types.parser.BigDecParser
-
@PublicEvolving public class BigDecParser extends FieldParser<BigDecimal>
Parses a text field into aBigDecimal
.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.apache.flink.types.parser.FieldParser
FieldParser.ParseErrorState
-
-
Constructor Summary
Constructors Constructor Description BigDecParser()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description BigDecimal
createValue()
Returns an instance of the parsed value type.BigDecimal
getLastResult()
Gets the parsed field.static BigDecimal
parseField(byte[] bytes, int startPos, int length)
Static utility to parse a field of type BigDecimal from a byte sequence that represents text characters (such as when read from a file stream).int
parseField(byte[] bytes, int startPos, int limit, byte[] delimiter, BigDecimal reusable)
Each parser's logic should be implemented inside this methodstatic BigDecimal
parseField(byte[] bytes, int startPos, int length, char delimiter)
Static utility to parse a field of type BigDecimal from a byte sequence that represents text characters (such as when read from a file stream).-
Methods inherited from class org.apache.flink.types.parser.FieldParser
delimiterNext, endsWithDelimiter, getCharset, getErrorState, getParserForType, nextStringEndPos, nextStringLength, resetErrorStateAndParse, resetParserState, setCharset, setErrorState
-
-
-
-
Method Detail
-
parseField
public int parseField(byte[] bytes, int startPos, int limit, byte[] delimiter, BigDecimal reusable)
Description copied from class:FieldParser
Each parser's logic should be implemented inside this method- Specified by:
parseField
in classFieldParser<BigDecimal>
-
createValue
public BigDecimal createValue()
Description copied from class:FieldParser
Returns an instance of the parsed value type.- Specified by:
createValue
in classFieldParser<BigDecimal>
- Returns:
- An instance of the parsed value type.
-
getLastResult
public BigDecimal 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<BigDecimal>
- Returns:
- The latest parsed field.
-
parseField
public static final BigDecimal parseField(byte[] bytes, int startPos, int length)
Static utility to parse a field of type BigDecimal from a byte sequence that represents text characters (such as when read from a file stream).- Parameters:
bytes
- The bytes containing the text data that should be parsed.startPos
- The offset to start the parsing.length
- The length of the byte sequence (counting from the offset).- Returns:
- The parsed value.
- Throws:
IllegalArgumentException
- Thrown when the value cannot be parsed because the text represents not a correct number.
-
parseField
public static final BigDecimal parseField(byte[] bytes, int startPos, int length, char delimiter)
Static utility to parse a field of type BigDecimal from a byte sequence that represents text characters (such as when read from a file stream).- Parameters:
bytes
- The bytes containing the text data that should be parsed.startPos
- The offset to start the parsing.length
- The length of the byte sequence (counting from the offset).delimiter
- The delimiter that terminates the field.- Returns:
- The parsed value.
- Throws:
IllegalArgumentException
- Thrown when the value cannot be parsed because the text represents not a correct number.
-
-