Class ConstantUtf8

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

    public final class ConstantUtf8
    extends Constant
    Extends the abstract Constant to represent a reference to a UTF-8 encoded string.

    The following system properties govern caching this class performs.

    Here is a sample Maven invocation with caching disabled:

     mvn test -Dbcel.statistics=true -Dbcel.maxcached.size=0 -Dbcel.maxcached=0
     

    Here is a sample Maven invocation with caching enabled:

     mvn test -Dbcel.statistics=true -Dbcel.maxcached.size=100000 -Dbcel.maxcached=5000000
     
    See Also:
    Constant
    • Field Detail

      • considered

        private static volatile int considered
      • created

        private static volatile int created
      • hits

        private static volatile int hits
      • skipped

        private static volatile int skipped
      • SYS_PROP_CACHE_MAX_ENTRIES

        private static final java.lang.String SYS_PROP_CACHE_MAX_ENTRIES
        See Also:
        Constant Field Values
      • SYS_PROP_CACHE_MAX_ENTRY_SIZE

        private static final java.lang.String SYS_PROP_CACHE_MAX_ENTRY_SIZE
        See Also:
        Constant Field Values
      • SYS_PROP_STATISTICS

        private static final java.lang.String SYS_PROP_STATISTICS
        See Also:
        Constant Field Values
      • value

        private final java.lang.String value
    • Constructor Detail

      • ConstantUtf8

        public ConstantUtf8​(ConstantUtf8 constantUtf8)
        Initializes from another object.
        Parameters:
        constantUtf8 - the value.
      • ConstantUtf8

        ConstantUtf8​(java.io.DataInput dataInput)
              throws java.io.IOException
        Initializes instance from file data.
        Parameters:
        dataInput - Input stream
        Throws:
        java.io.IOException - if an I/O error occurs.
      • ConstantUtf8

        public ConstantUtf8​(java.lang.String value)
        Parameters:
        value - Data
    • Method Detail

      • clearCache

        public static void clearCache()
        Clears the cache.
        Since:
        6.4.0
      • clearStats

        static void clearStats()
      • countCreated

        private static void countCreated()
      • getCachedInstance

        public static ConstantUtf8 getCachedInstance​(java.lang.String value)
        Gets a new or cached instance of the given value.

        See ConstantUtf8 class Javadoc for details.

        Parameters:
        value - the value.
        Returns:
        a new or cached instance of the given value.
        Since:
        6.0
      • getInstance

        public static ConstantUtf8 getInstance​(java.io.DataInput dataInput)
                                        throws java.io.IOException
        Gets a new or cached instance of the given value.

        See ConstantUtf8 class Javadoc for details.

        Parameters:
        dataInput - the value.
        Returns:
        a new or cached instance of the given value.
        Throws:
        java.io.IOException - if an I/O error occurs.
        Since:
        6.0
      • getInstance

        public static ConstantUtf8 getInstance​(java.lang.String value)
        Gets a new or cached instance of the given value.

        See ConstantUtf8 class Javadoc for details.

        Parameters:
        value - the value.
        Returns:
        a new or cached instance of the given value.
        Since:
        6.0
      • printStats

        static void printStats()
      • accept

        public void accept​(Visitor v)
        Called by objects that are traversing the nodes of the tree implicitly defined by the contents of a Java class. I.e., the hierarchy of methods, fields, attributes, etc. spawns a tree of objects.
        Specified by:
        accept in interface Node
        Specified by:
        accept in class Constant
        Parameters:
        v - Visitor object
      • dump

        public void dump​(java.io.DataOutputStream file)
                  throws java.io.IOException
        Dumps String in Utf8 format to file stream.
        Specified by:
        dump in class Constant
        Parameters:
        file - Output file stream
        Throws:
        java.io.IOException - if an I/O error occurs.
      • getBytes

        public java.lang.String getBytes()
        Returns:
        Data converted to string.
      • setBytes

        @Deprecated
        public void setBytes​(java.lang.String bytes)
        Deprecated.
        (since 6.0)
        Parameters:
        bytes - the raw bytes of this UTF-8
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class Constant
        Returns:
        String representation