Class Utility


  • public final class Utility
    extends java.lang.Object
    • Constructor Summary

      Constructors 
      Constructor Description
      Utility()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.lang.StringBuffer appendNumber​(java.lang.StringBuffer result, int n)
      Append a number to the given StringBuffer in the radix 10 generating at least one digit.
      static java.lang.StringBuffer appendNumber​(java.lang.StringBuffer result, int n, int radix, int minDigits)
      Append a number to the given StringBuffer in the given radix.
      static java.lang.String hex​(char ch)
      Convert a char to 4 hex uppercase digits.
      static java.lang.StringBuffer hex​(char ch, java.lang.StringBuffer output)
      Convert a char to 4 hex uppercase digits.
      static java.lang.String hex​(int ch, int width)
      Convert a integer to size width (minimum) hex uppercase digits.
      static java.lang.StringBuffer hex​(int ch, int width, java.lang.StringBuffer output)
      Convert a integer to size width hex uppercase digits.
      static java.lang.String hex​(long ch)  
      static java.lang.String hex​(long i, int places)
      Supplies a zero-padded hex representation of an integer (without 0x)
      static java.lang.String hex​(java.lang.String s)
      Convert a string to comma-separated groups of 4 hex uppercase digits.
      static java.lang.String hex​(java.lang.StringBuffer s)
      Convert a string to comma-separated groups of 4 hex uppercase digits.
      static java.lang.StringBuffer hex​(java.lang.String s, java.lang.StringBuffer result)
      Convert a string to comma-separated groups of 4 hex uppercase digits.
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • Utility

        public Utility()
    • Method Detail

      • hex

        public static java.lang.String hex​(char ch)
        Convert a char to 4 hex uppercase digits. E.g., hex('a') => "0041".
      • hex

        public static java.lang.String hex​(java.lang.String s)
        Convert a string to comma-separated groups of 4 hex uppercase digits. E.g., hex('ab') => "0041,0042".
      • hex

        public static java.lang.String hex​(java.lang.StringBuffer s)
        Convert a string to comma-separated groups of 4 hex uppercase digits. E.g., hex('ab') => "0041,0042".
      • hex

        public static java.lang.StringBuffer hex​(char ch,
                                                 java.lang.StringBuffer output)
        Convert a char to 4 hex uppercase digits. E.g., hex('a') => "0041". Append the output to the given StringBuffer.
      • hex

        public static java.lang.StringBuffer hex​(int ch,
                                                 int width,
                                                 java.lang.StringBuffer output)
        Convert a integer to size width hex uppercase digits. E.g., hex('a', 4, str) => "0041". Append the output to the given StringBuffer. If width is too small to fit, nothing will be appended to output.
      • hex

        public static java.lang.String hex​(int ch,
                                           int width)
        Convert a integer to size width (minimum) hex uppercase digits. E.g., hex('a', 4, str) => "0041". If the integer requires more than width digits, more will be used.
      • appendNumber

        public static java.lang.StringBuffer appendNumber​(java.lang.StringBuffer result,
                                                          int n)
        Append a number to the given StringBuffer in the radix 10 generating at least one digit.
      • appendNumber

        public static java.lang.StringBuffer appendNumber​(java.lang.StringBuffer result,
                                                          int n,
                                                          int radix,
                                                          int minDigits)
                                                   throws java.lang.IllegalArgumentException
        Append a number to the given StringBuffer in the given radix. Standard digits '0'-'9' are used and letters 'A'-'Z' for radices 11 through 36.
        Parameters:
        result - the digits of the number are appended here
        n - the number to be converted to digits; may be negative. If negative, a '-' is prepended to the digits.
        radix - a radix from 2 to 36 inclusive.
        minDigits - the minimum number of digits, not including any '-', to produce. Values less than 2 have no effect. One digit is always emitted regardless of this parameter.
        Returns:
        a reference to result
        Throws:
        java.lang.IllegalArgumentException
      • hex

        public static java.lang.String hex​(long i,
                                           int places)
        Supplies a zero-padded hex representation of an integer (without 0x)
      • hex

        public static java.lang.String hex​(long ch)
      • hex

        public static java.lang.StringBuffer hex​(java.lang.String s,
                                                 java.lang.StringBuffer result)
        Convert a string to comma-separated groups of 4 hex uppercase digits. E.g., hex('ab') => "0041,0042". Append the output to the given StringBuffer.