Class TypeUtil


  • public class TypeUtil
    extends java.lang.Object
    TYPE Utilities. Provides various static utiltiy methods for manipulating types and their string representations.
    Since:
    Jetty 4.1
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private static java.util.HashMap<java.lang.Class<?>,​java.lang.String> class2Name  
      private static java.util.HashMap<java.lang.Class<?>,​java.lang.reflect.Method> class2Value  
      private static java.util.HashMap<java.lang.String,​java.lang.Class<?>> name2Class  
    • Constructor Summary

      Constructors 
      Constructor Description
      TypeUtil()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static int convertHexDigit​(char c)  
      static int convertHexDigit​(int c)  
      static int parseInt​(java.lang.String s, int offset, int length, int base)
      Parse an int from a substring.
      static java.lang.String toHexString​(byte b)  
      static java.lang.String toHexString​(byte[] b, int offset, int length)  
      static java.lang.String toString​(byte[] bytes, int base)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • name2Class

        private static final java.util.HashMap<java.lang.String,​java.lang.Class<?>> name2Class
      • class2Name

        private static final java.util.HashMap<java.lang.Class<?>,​java.lang.String> class2Name
      • class2Value

        private static final java.util.HashMap<java.lang.Class<?>,​java.lang.reflect.Method> class2Value
    • Constructor Detail

      • TypeUtil

        public TypeUtil()
    • Method Detail

      • parseInt

        public static int parseInt​(java.lang.String s,
                                   int offset,
                                   int length,
                                   int base)
                            throws java.lang.NumberFormatException
        Parse an int from a substring. Negative numbers are not handled.
        Parameters:
        s - String
        offset - Offset within string
        length - Length of integer or -1 for remainder of string
        base - base of the integer
        Returns:
        the parsed integer
        Throws:
        java.lang.NumberFormatException - if the string cannot be parsed
      • toString

        public static java.lang.String toString​(byte[] bytes,
                                                int base)
      • convertHexDigit

        public static int convertHexDigit​(char c)
        Parameters:
        c - An ASCII encoded character 0-9 a-f A-F
        Returns:
        The byte value of the character 0-16.
      • convertHexDigit

        public static int convertHexDigit​(int c)
        Parameters:
        c - An ASCII encoded character 0-9 a-f A-F
        Returns:
        The byte value of the character 0-16.
      • toHexString

        public static java.lang.String toHexString​(byte b)
      • toHexString

        public static java.lang.String toHexString​(byte[] b,
                                                   int offset,
                                                   int length)