Package nom.tam.util
Class AsciiFuncs
java.lang.Object
nom.tam.util.AsciiFuncs
(for internal use) Various static functios to handle ASCII sequences
- Author:
- tmcglynn
-
Method Summary
Modifier and TypeMethodDescriptionstatic String
asciiString
(byte[] buf) Convert to ASCII or return null if not compatible.static String
asciiString
(byte[] buf, int start, int len) Convert to ASCII or return null if not compatible.static char
extractChar
(String s, ParsePosition pos) Returns a character from a string, incrementing the position argument.static byte[]
Convert an ASCII string to bytes.static boolean
isWhitespace
(char c) Deprecated.static int
parseInteger
(String s, ParsePosition pos) Returns an integer value contained in a string the specified position.
-
Method Details
-
asciiString
Convert to ASCII or return null if not compatible.- Parameters:
buf
- the bytes representing a string- Returns:
- the String represented by the bytes
-
asciiString
Convert to ASCII or return null if not compatible.- Parameters:
buf
- buffer to get the string bytes fromstart
- the position where the string startslen
- the length of the string- Returns:
- the extracted string
-
getBytes
Convert an ASCII string to bytes.- Parameters:
in
- the string to convert- Returns:
- the string converted to bytes
-
isWhitespace
Deprecated.UseCharacter.isWhitespace(char)
instead.- Parameters:
c
- the character to check- Returns:
true
if it is a white-space character, otherwisefalse
.
-
parseInteger
public static int parseInteger(String s, ParsePosition pos) throws IndexOutOfBoundsException, NumberFormatException Returns an integer value contained in a string the specified position. Leading spaces will be skipped and the parsing will stop at the first non-digit character after. *- Parameters:
s
- A stringpos
- the position in the string to parse an integer. The position is updated to point to after the white spaces and integer component (if any).- Returns:
- the integer value parsed.
- Throws:
NumberFormatException
- if there is no integer value present at the position.IndexOutOfBoundsException
- if the parse position is outside of the string bounds- Since:
- 1.18
-
extractChar
Returns a character from a string, incrementing the position argument.- Parameters:
s
- a stringpos
- the position of the character to return. It is incremented.- Returns:
- the character at the requested position
- Throws:
IndexOutOfBoundsException
- if the parse position is outside of the string bounds- Since:
- 1.18
-
Character.isWhitespace(char)
instead.