Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  package org.uberfire.debug;

Utility methods that help with debugging.
  
  public class Debug {

    
The code requires this list to have 16 entries
  
      private static final String[] CONSONANTS = { "b""d""f""h",
                                                  "j""k""l""m",
                                                  "n""p""r""s",
                                                  "t""v""w""z" };

    
The code requires this list to have 8 entries
 
     private static final String[] VOWELS = { "a""e""ee""i",
                                              "o""oo""u""y" };

    
Makes a reasonably easy-to-pronounce gibberish word from the given number. On average, the word will have about as many characters as the number would have when printed as a decimal, but (especially for large numbers) it will be easier to remember as a single word.

Parameters:
num The number to convert.
Returns:
The memorable string, unique to the given number. Never null.
 
     public static String toMemorableStringlong num ) {
         StringBuilder memorable = new StringBuilder();
         for ( ;; ) {
             int chunk = (int) (num & 0xf);
             memorable.append[chunk] );
             num >>= 4;
             if ( num == 0 )
                 break;
 
             chunk = (int) (num & 7);
             memorable.append[chunk] );
             num >>= 3;
             if ( num == 0 )
                 break;
         }
         return memorable.toString();
     }

    
Composes a compact, memorable unique string for the given object instance. The name starts with the abbreviated fully-qualified class name (see abbreviatedName(java.lang.Class)), an '@' character, then a gibberish word representing the object's identity hash code (see toMemorableString(long)).

Parameters:
o
Returns:
 
     public static String objectIdObject o ) {
         if ( o == null ) {
             return null;
         }
         return abbreviatedNameo.getClass() ) + "@" + toMemorableString( System.identityHashCodeo ) );
     }

    
Returns a compact representation of the fully-qualified name of the given class. The string is built with the following components:
  1. the first letter of each component of the package name
  2. a dot
  3. the class name. If the class is an inner class, the name is of the form Outer$Inner

      For classes in the default package, items 1 and 2 are omitted.

      Parameters:
      c the class whose name to abbreviate. Can be null, but will result in a null return value.
      Returns:
      the abbreviated FQCN as described, or null if the input is null.
 
     public static String abbreviatedNameClass<?> c ) {
         if ( c == null ) {
             return null;
         }
         StringBuilder result = new StringBuilder();
         String fqcn = c.getName();
         int lastDot = -1;
         int thisDot = -1;
         while ( (thisDot = fqcn.indexOf'.'thisDot + 1 ) ) != -1 ) {
             result.appendfqcn.charAtlastDot + 1 ) );
             lastDot = thisDot;
         }
         if ( lastDot != -1 ) {
             result.append'.' );
         }
         result.appendfqcn.substringlastDot + 1 ) );
         return result.toString();
     }

    
Returns the short name of the given class (no package name). This is the same as java.lang.Class.shortName(), which is not implemented in the GWT version of java.lang.Class.

Parameters:
c the class whose name to abbreviate. Can be null, but will result in a null return value.
Returns:
the abbreviated FQCN as described, or null if the input is null.
 
    public static String shortNameClass<?> c ) {
        if ( c == null ) {
            return null;
        }
        return c.getName().substringc.getName().lastIndexOf'.' ) + 1 );
    }
New to GrepCode? Check out our FAQ X