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
Public Properties
| Name | Description |
---|
 | Boolean | Get a boolean value from the beginning of the buffer |
 | Buffer | Set the buffer for the parser |
 | Double | Read in the buffer until a double is read. This will read the entire buffer if fillFields is set. |
 | FillFields | Do we require a field to completely fill up the specified length (with optional leading and trailing white space. |
 | Float | Get a floating point value from the buffer. (see getDouble(int()) |
 | Int | Look for an integer at the beginning of the buffer |
 | NumberLength | Get the number of characters used to parse the previous number (or the length of the previous String returned). |
 | Offset | Get the current offset.Set the offset into the array. |
Top
Public Methods
| Name | Description |
---|
 | Equals | Determines whether the specified Object is equal to the current Object. (inherited from Object) |
 | GetBoolean | Get a boolean value from a specified region of the buffer |
 | GetDouble | Look for a double in the buffer. Leading spaces are ignored. |
 | GetFloat | Get a floating point value in a region of the buffer |
 | GetHashCode | Serves 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) |
 | GetInt | Convert a region of the buffer to an integer |
 | GetLong | Look for a long in a specified region of the buffer |
 | GetString | Get a string |
 | GetType | Gets the Type of the current instance. (inherited from Object) |
 | Skip | Skip bytes in the buffer |
 | SkipWhite | Skip 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' |
 | ToString | Returns a String that represents the current Object. (inherited from Object) |
Top
Protected Methods
| Name | Description |
---|
 | Finalize | Allows an Object to attempt to free resources and perform other cleanup operations before the Object is reclaimed by garbage collection. (inherited from Object) |
 | MemberwiseClone | Creates a shallow copy of the current Object. (inherited from Object) |
Top
See Also