Class JBossObject

  • All Implemented Interfaces:
    java.lang.Cloneable, JBossInterface

    public class JBossObject
    extends java.lang.Object
    implements JBossInterface
    Utility Class Utility Class that provides a Logger instance (log) and caching of toString() and hashCode() values. You most probably want to override the method that comes from JBossInterface: public void toShortString(StringBuffer buffer) to append to the buffer the key class properties, and also override the following methods to provide the hashCode and the class properties that should be cached: protected void toString(StringBuffer buffer) protected int getHashCode() Cached values can be flushed using flushJBossObjectCache() Caching can be disabled by simply overriding toString() and hashCode(), or returning false from methods: protected boolean cacheToString() protected boolean cacheGetHashCode()
    Version:
    $Revision$
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected int hashCode
      Cached hashCode
      protected org.jboss.logging.Logger log
      The log
      private static java.util.Map<java.lang.Class<?>,​org.jboss.logging.Logger> loggers
      The loggers
      protected java.lang.ref.SoftReference toString
      Cached toString
    • Constructor Summary

      Constructors 
      Constructor Description
      JBossObject()
      Create a new object
      JBossObject​(org.jboss.logging.Logger log)
      Create a new object using the specified Logger instace
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected boolean cacheGetHashCode()
      Whether we should cache the result hashCode()
      protected boolean cacheToString()
      Whether we should cache the result toString()
      java.lang.Object clone()
      Clone the object
      private org.jboss.logging.Logger createLog()
      Create logger.
      static boolean equals​(java.lang.Object one, java.lang.Object two)
      Safe equality check
      protected void flushJBossObjectCache()
      Flush the JBossObject cached values
      java.lang.String getClassShortName()
      Get the class short name
      protected int getHashCode()
      Calculate the hashcode
      int hashCode()
      Override hashCode to cache the value
      static void list​(JBossStringBuilder buffer, java.util.Collection objects)
      List the set of JBossObjects
      static boolean notEqual​(java.lang.Object one, java.lang.Object two)
      Safe inequality check
      java.lang.String toShortString()
      Print a short version of the object
      void toShortString​(JBossStringBuilder buffer)
      Append the key class properties to the buffer
      java.lang.String toString()
      Override toString to cache the value
      protected void toString​(JBossStringBuilder buffer)
      Append the class properties to the buffer
      protected java.lang.String toStringImplementation()
      Implementation of String
      • Methods inherited from class java.lang.Object

        equals, finalize, getClass, notify, notifyAll, wait, wait, wait
    • Field Detail

      • loggers

        private static final java.util.Map<java.lang.Class<?>,​org.jboss.logging.Logger> loggers
        The loggers
      • log

        protected org.jboss.logging.Logger log
        The log
      • toString

        protected transient java.lang.ref.SoftReference toString
        Cached toString
      • hashCode

        protected transient int hashCode
        Cached hashCode
    • Constructor Detail

      • JBossObject

        public JBossObject()
        Create a new object
      • JBossObject

        public JBossObject​(org.jboss.logging.Logger log)
        Create a new object using the specified Logger instace
        Parameters:
        log - the Logger instance to use
    • Method Detail

      • createLog

        private org.jboss.logging.Logger createLog()
        Create logger.
        Returns:
        the logger
      • equals

        public static boolean equals​(java.lang.Object one,
                                     java.lang.Object two)
        Safe equality check
        Parameters:
        one - an object
        two - another object
        Returns:
        true when they are equal
      • notEqual

        public static boolean notEqual​(java.lang.Object one,
                                       java.lang.Object two)
        Safe inequality check
        Parameters:
        one - an object
        two - another object
        Returns:
        true when they are not equal
      • list

        public static void list​(JBossStringBuilder buffer,
                                java.util.Collection objects)
        List the set of JBossObjects
        Parameters:
        buffer - the buffer
        objects - the collection of objects
      • toString

        public java.lang.String toString()
        Override toString to cache the value
        Overrides:
        toString in class java.lang.Object
        Returns:
        the String
      • hashCode

        public int hashCode()
        Override hashCode to cache the value
        Overrides:
        hashCode in class java.lang.Object
        Returns:
        the hashCode
      • clone

        public java.lang.Object clone()
        Description copied from interface: JBossInterface
        Clone the object
        Specified by:
        clone in interface JBossInterface
        Overrides:
        clone in class java.lang.Object
        Returns:
        a clone of the object
      • toShortString

        public java.lang.String toShortString()
        Description copied from interface: JBossInterface
        Print a short version of the object
        Specified by:
        toShortString in interface JBossInterface
        Returns:
        the short string
      • getClassShortName

        public java.lang.String getClassShortName()
        Get the class short name
        Returns:
        the short name of the class
      • toStringImplementation

        protected java.lang.String toStringImplementation()
        Implementation of String
        Returns:
        the string
      • flushJBossObjectCache

        protected void flushJBossObjectCache()
        Flush the JBossObject cached values
      • toString

        protected void toString​(JBossStringBuilder buffer)
        Append the class properties to the buffer
        Parameters:
        buffer - the buffer
      • getHashCode

        protected int getHashCode()
        Calculate the hashcode
        Returns:
        the hash code
      • cacheToString

        protected boolean cacheToString()
        Whether we should cache the result toString()
        Returns:
        true by default
      • cacheGetHashCode

        protected boolean cacheGetHashCode()
        Whether we should cache the result hashCode()
        Returns:
        true by default