org.apache.logging.log4j.util

Class Unbox



  • public class Unbox
    extends Object
    Utility for preventing primitive parameter values from being auto-boxed. Auto-boxing creates temporary objects which contribute to pressure on the garbage collector. With this utility users can convert primitive values directly into text without allocating temporary objects.

    Example usage:

     import static org.apache.logging.log4j.util.Unbox.box;
     ...
     long longValue = 123456L;
     double doubleValue = 3.14;
     // prevent primitive values from being auto-boxed
     logger.debug("Long value={}, double value={}", box(longValue), box(doubleValue));
     
    • Constructor Summary

      Constructors 
      Constructor and Description
      Unbox() 
    • Method Summary

      Methods 
      Modifier and Type Method and Description
      static StringBuilder box(boolean value)
      Returns a StringBuilder containing the text representation of the specified primitive value.
      static StringBuilder box(byte value)
      Returns a StringBuilder containing the text representation of the specified primitive value.
      static StringBuilder box(char value)
      Returns a StringBuilder containing the text representation of the specified primitive value.
      static StringBuilder box(double value)
      Returns a StringBuilder containing the text representation of the specified primitive value.
      static StringBuilder box(float value)
      Returns a StringBuilder containing the text representation of the specified primitive value.
      static StringBuilder box(int value)
      Returns a StringBuilder containing the text representation of the specified primitive value.
      static StringBuilder box(long value)
      Returns a StringBuilder containing the text representation of the specified primitive value.
      static StringBuilder box(short value)
      Returns a StringBuilder containing the text representation of the specified primitive value.
    • Constructor Detail

      • Unbox

        public Unbox()
    • Method Detail

      • box

        public static StringBuilder box(float value)
        Returns a StringBuilder containing the text representation of the specified primitive value. This method will not allocate temporary objects.
        Parameters:
        value - the value whose text representation to return
        Returns:
        a StringBuilder containing the text representation of the specified primitive value
      • box

        public static StringBuilder box(double value)
        Returns a StringBuilder containing the text representation of the specified primitive value. This method will not allocate temporary objects.
        Parameters:
        value - the value whose text representation to return
        Returns:
        a StringBuilder containing the text representation of the specified primitive value
      • box

        public static StringBuilder box(short value)
        Returns a StringBuilder containing the text representation of the specified primitive value. This method will not allocate temporary objects.
        Parameters:
        value - the value whose text representation to return
        Returns:
        a StringBuilder containing the text representation of the specified primitive value
      • box

        public static StringBuilder box(int value)
        Returns a StringBuilder containing the text representation of the specified primitive value. This method will not allocate temporary objects.
        Parameters:
        value - the value whose text representation to return
        Returns:
        a StringBuilder containing the text representation of the specified primitive value
      • box

        public static StringBuilder box(char value)
        Returns a StringBuilder containing the text representation of the specified primitive value. This method will not allocate temporary objects.
        Parameters:
        value - the value whose text representation to return
        Returns:
        a StringBuilder containing the text representation of the specified primitive value
      • box

        public static StringBuilder box(long value)
        Returns a StringBuilder containing the text representation of the specified primitive value. This method will not allocate temporary objects.
        Parameters:
        value - the value whose text representation to return
        Returns:
        a StringBuilder containing the text representation of the specified primitive value
      • box

        public static StringBuilder box(byte value)
        Returns a StringBuilder containing the text representation of the specified primitive value. This method will not allocate temporary objects.
        Parameters:
        value - the value whose text representation to return
        Returns:
        a StringBuilder containing the text representation of the specified primitive value
      • box

        public static StringBuilder box(boolean value)
        Returns a StringBuilder containing the text representation of the specified primitive value. This method will not allocate temporary objects.
        Parameters:
        value - the value whose text representation to return
        Returns:
        a StringBuilder containing the text representation of the specified primitive value

Copyright © 1999-2016 Apache Software Foundation. All Rights Reserved.
Apache Logging, Apache Log4j, Log4j, Apache, the Apache feather logo, the Apache Logging project logo, and the Apache Log4j logo are trademarks of The Apache Software Foundation.