This class provides routines for efficient parsing of data stored in a byte array. This routine is optimized (in theory at least!) for efficiency rather than accuracy. The values read in for doubles or floats may differ in the last bit or so from the standard input utilities, especially in the case where a float is specified as a very long string of digits (substantially longer than the precision of the type).

The get methods generally are available with or without a length parameter specified. When a length parameter is specified only the bytes with the specified range from the current offset will be search for the number. If no length is specified, the entire buffer from the current offset will be searched.

The getString method returns a string with leading and trailing white space left intact. For all other get calls, leading white space is ignored. If fillFields is set, then the get methods check that only white space follows valid data and a FormatException is thrown if that is not the case. If fillFields is not set and valid data is found, then the methods return having read as much as possible. E.g., for the sequence "T123.258E13", a getBoolean, getInteger and getFloat call would return true, 123, and 2.58e12 when called in succession.


The following tables list the members exposed by ByteParser.

Public Constructors

 NameDescription
Public methodByteParserConstruct a parser.
Top

Public Properties

 NameDescription
Public propertyBooleanGet a boolean value from the beginning of the buffer
Public propertyBufferSet the buffer for the parser
Public propertyDoubleRead in the buffer until a double is read. This will read the entire buffer if fillFields is set.
Public propertyFillFieldsDo we require a field to completely fill up the specified length (with optional leading and trailing white space.
Public propertyFloatGet a floating point value from the buffer. (see getDouble(int())
Public propertyIntLook for an integer at the beginning of the buffer
Public propertyNumberLengthGet the number of characters used to parse the previous number (or the length of the previous String returned).
Public propertyOffsetGet the current offset.Set the offset into the array.
Top

Public Methods

 NameDescription
Public methodEqualsDetermines whether the specified Object is equal to the current Object. (inherited from Object)
Public methodGetBooleanGet a boolean value from a specified region of the buffer
Public methodGetDoubleLook for a double in the buffer. Leading spaces are ignored.
Public methodGetFloatGet a floating point value in a region of the buffer
Public methodGetHashCodeServes as a hash function for a particular type. GetHashCode is suitable for use in hashing algorithms and data structures like a hash table. (inherited from Object)
Public methodGetIntConvert a region of the buffer to an integer
Public methodGetLongLook for a long in a specified region of the buffer
Public methodGetStringGet a string
Public methodGetTypeGets the Type of the current instance. (inherited from Object)
Public methodSkipSkip bytes in the buffer
Public methodSkipWhiteSkip white space. This routine skips with space in the input and returns the number of character skipped. White space is defined as ' ', '\t', '\n' or '\r'
Public methodToStringReturns a String that represents the current Object. (inherited from Object)
Top

Protected Methods

 NameDescription
Family methodFinalizeAllows an Object to attempt to free resources and perform other cleanup operations before the Object is reclaimed by garbage collection. (inherited from Object)
Family methodMemberwiseCloneCreates a shallow copy of the current Object. (inherited from Object)
Top

See Also