Class Ascii


  • public final class Ascii
    extends Object
    This class implements some basic ASCII character handling functions.
    Author:
    dac@eng.sun.com, James Todd [gonzo@eng.sun.com]
    • Constructor Summary

      Constructors 
      Constructor Description
      Ascii()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static void intToHexString​(org.glassfish.grizzly.Buffer buffer, int i)  
      static void intToUnsignedString​(org.glassfish.grizzly.Buffer buffer, int value, int shift)
      Convert the integer to an unsigned number.
      static boolean isAlpha​(int c)
      Returns true if the specified ASCII character is upper or lower case.
      static boolean isDigit​(int c)
      Returns true if the specified ASCII character is a digit.
      static boolean isLower​(int c)
      Returns true if the specified ASCII character is lower case.
      static boolean isUpper​(int c)
      Returns true if the specified ASCII character is upper case.
      static boolean isWhite​(int c)
      Returns true if the specified ASCII character is white space.
      static int parseInt​(byte[] b, int off, int len)
      Parses an unsigned integer from the specified sub-array of bytes.
      static int parseInt​(char[] b, int off, int len)  
      static int parseInt​(String s, int off, int len)  
      static int parseInt​(org.glassfish.grizzly.Buffer b, int off, int len)
      Parses an unsigned int from the specified sub-array of bytes.
      static int parseInt​(DataChunk dataChunk)
      Parses an unsigned integer from the specified DataChunk.
      static int parseInt​(DataChunk dataChunk, int offset, int length)
      Parses an unsigned integer from the specified part of DataChunk.
      static long parseLong​(byte[] b, int off, int len)
      Parses an unsigned long from the specified sub-array of bytes.
      static long parseLong​(char[] b, int off, int len)  
      static long parseLong​(String s, int off, int len)  
      static long parseLong​(org.glassfish.grizzly.Buffer b, int off, int len)
      Parses an unsigned long from the specified sub-array of bytes.
      static long parseLong​(DataChunk dataChunk)  
      static long parseLong​(DataChunk dataChunk, int offset, int length)  
      static void toLower​(byte[] bytes)
      Converts passed bytes (representing ASCII characters) to the lower case equivalent.
      static int toLower​(int c)
      Returns the lower case equivalent of the specified ASCII character.
      static void toUpper​(byte[] bytes)
      Converts passed bytes (representing ASCII characters) to the upper case equivalent.
      static int toUpper​(int c)
      Returns the upper case equivalent of the specified ASCII character.
    • Constructor Detail

      • Ascii

        public Ascii()
    • Method Detail

      • toUpper

        public static int toUpper​(int c)
        Returns the upper case equivalent of the specified ASCII character.
      • toUpper

        public static void toUpper​(byte[] bytes)
        Converts passed bytes (representing ASCII characters) to the upper case equivalent.
      • toLower

        public static int toLower​(int c)
        Returns the lower case equivalent of the specified ASCII character.
      • toLower

        public static void toLower​(byte[] bytes)
        Converts passed bytes (representing ASCII characters) to the lower case equivalent.
      • isAlpha

        public static boolean isAlpha​(int c)
        Returns true if the specified ASCII character is upper or lower case.
      • isUpper

        public static boolean isUpper​(int c)
        Returns true if the specified ASCII character is upper case.
      • isLower

        public static boolean isLower​(int c)
        Returns true if the specified ASCII character is lower case.
      • isWhite

        public static boolean isWhite​(int c)
        Returns true if the specified ASCII character is white space.
      • isDigit

        public static boolean isDigit​(int c)
        Returns true if the specified ASCII character is a digit.
      • parseInt

        public static int parseInt​(DataChunk dataChunk,
                                   int offset,
                                   int length)
        Parses an unsigned integer from the specified part of DataChunk.
        Parameters:
        dataChunk - the DataChunk
        offset - the start offset
        length - the length
        Throws:
        NumberFormatException - if the integer format was invalid
      • parseInt

        public static int parseInt​(byte[] b,
                                   int off,
                                   int len)
                            throws NumberFormatException
        Parses an unsigned integer from the specified sub-array of bytes.
        Parameters:
        b - the bytes to parse
        off - the start offset of the bytes
        len - the length of the bytes
        Throws:
        NumberFormatException - if the integer format was invalid
      • parseInt

        public static int parseInt​(org.glassfish.grizzly.Buffer b,
                                   int off,
                                   int len)
                            throws NumberFormatException
        Parses an unsigned int from the specified sub-array of bytes.
        Parameters:
        b - the Buffer to parse
        off - the start offset of the bytes
        len - the length of the bytes
        Throws:
        NumberFormatException - if the long format was invalid
      • parseLong

        public static long parseLong​(byte[] b,
                                     int off,
                                     int len)
                              throws NumberFormatException
        Parses an unsigned long from the specified sub-array of bytes.
        Parameters:
        b - the bytes to parse
        off - the start offset of the bytes
        len - the length of the bytes
        Throws:
        NumberFormatException - if the long format was invalid
      • parseLong

        public static long parseLong​(org.glassfish.grizzly.Buffer b,
                                     int off,
                                     int len)
                              throws NumberFormatException
        Parses an unsigned long from the specified sub-array of bytes.
        Parameters:
        b - the Buffer to parse
        off - the start offset of the bytes
        len - the length of the bytes
        Throws:
        NumberFormatException - if the long format was invalid
      • parseLong

        public static long parseLong​(DataChunk dataChunk)
      • parseLong

        public static long parseLong​(DataChunk dataChunk,
                                     int offset,
                                     int length)
      • intToHexString

        public static void intToHexString​(org.glassfish.grizzly.Buffer buffer,
                                          int i)
      • intToUnsignedString

        public static void intToUnsignedString​(org.glassfish.grizzly.Buffer buffer,
                                               int value,
                                               int shift)
        Convert the integer to an unsigned number.