Package nom.tam.util

Class AsciiFuncs

java.lang.Object
nom.tam.util.AsciiFuncs

public final class AsciiFuncs extends Object
(for internal use) Various static functios to handle ASCII sequences
Author:
tmcglynn
  • Method Details

    • asciiString

      public static String asciiString(byte[] buf)
      Convert to ASCII or return null if not compatible.
      Parameters:
      buf - the bytes representing a string
      Returns:
      the String represented by the bytes
    • asciiString

      public static String asciiString(byte[] buf, int start, int len)
      Convert to ASCII or return null if not compatible.
      Parameters:
      buf - buffer to get the string bytes from
      start - the position where the string starts
      len - the length of the string
      Returns:
      the extracted string
    • getBytes

      public static byte[] getBytes(String in)
      Convert an ASCII string to bytes.
      Parameters:
      in - the string to convert
      Returns:
      the string converted to bytes
    • isWhitespace

      @Deprecated public static boolean isWhitespace(char c)
      Deprecated.
      Parameters:
      c - the character to check
      Returns:
      true if it is a white-space character, otherwise false.
    • 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 string
      pos - 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

      public static char extractChar(String s, ParsePosition pos) throws IndexOutOfBoundsException
      Returns a character from a string, incrementing the position argument.
      Parameters:
      s - a string
      pos - 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