Class ObjectUtility


  • public final class ObjectUtility
    extends java.lang.Object
    General object related utilities.
    • Constructor Detail

      • ObjectUtility

        public ObjectUtility​(boolean isIndenting,
                             int initialLevel,
                             int increment)
    • Method Detail

      • useToString

        public ObjectUtility useToString​(java.lang.Class cls)
      • defaultObjectToString

        public static java.lang.String defaultObjectToString​(java.lang.Object object)
        A convenience method that gives the default behavior: use indenting to display the object's structure and do not use built-in toString methods.
        Parameters:
        object - Object to print.
        Returns:
        the String representation of obj.
      • compactObjectToString

        public static java.lang.String compactObjectToString​(java.lang.Object object)
        A convenience method that gives the default behavior: do not use indenting to display the object's structure.
        Parameters:
        object - Object to print.
        Returns:
        the String representation of obj.
      • objectToString

        public java.lang.String objectToString​(java.lang.Object obj)
        objectToString handles display of arbitrary objects. It correctly handles objects whose elements form an arbitrary graph. It uses reflection to display the contents of any kind of object. An object's toString() method may optionally be used, but the default is to ignore all toString() methods except for those defined for primitive types, primitive type wrappers, and strings.
      • objectToStringHelper

        private void objectToStringHelper​(java.util.IdentityHashMap printed,
                                          ObjectWriter result,
                                          java.lang.Object obj)
      • checkPackageAccess

        private void checkPackageAccess​(java.lang.Class cls)
      • getDeclaredFields

        private java.lang.reflect.Field[] getDeclaredFields​(java.lang.Class cls)
      • handleObject

        private void handleObject​(java.util.IdentityHashMap printed,
                                  ObjectWriter result,
                                  java.lang.Object obj)
      • handleArray

        private void handleArray​(java.util.IdentityHashMap printed,
                                 ObjectWriter result,
                                 java.lang.Object obj)