Class ClassConverter

  • All Implemented Interfaces:
    java.lang.instrument.ClassFileTransformer, Converter

    public class ClassConverter
    extends java.lang.Object
    implements Converter, java.lang.instrument.ClassFileTransformer
    Class converter and transformer.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected EESpecProfile profile
      The configured spec profile.
    • Constructor Summary

      Constructors 
      Constructor Description
      ClassConverter()
      Create a class converter with the default TOMCAT profile.
      ClassConverter​(EESpecProfile profile)
      Create a class converter with the specified spec profile.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean accepts​(java.lang.String filename)
      Check if the file can be processed by this converter.
      boolean convert​(java.lang.String path, java.io.InputStream src, java.io.OutputStream dest, EESpecProfile profile)
      Copies the source to the destination, converting it if necessary, according to the requirements of the given profile.
      protected boolean convertInternal​(java.lang.String path, java.io.InputStream src, java.io.OutputStream dest, EESpecProfile profile, java.lang.ClassLoader loader)
      Convert specified class bytecode.
      java.lang.String toString()  
      byte[] transform​(java.lang.ClassLoader loader, java.lang.String className, java.lang.Class<?> classBeingRedefined, java.security.ProtectionDomain protectionDomain, byte[] classfileBuffer)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
      • Methods inherited from interface java.lang.instrument.ClassFileTransformer

        transform
    • Field Detail

      • profile

        protected final EESpecProfile profile
        The configured spec profile.
    • Constructor Detail

      • ClassConverter

        public ClassConverter()
        Create a class converter with the default TOMCAT profile.
      • ClassConverter

        public ClassConverter​(EESpecProfile profile)
        Create a class converter with the specified spec profile.
        Parameters:
        profile - the specification profile to use for conversion
    • Method Detail

      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • accepts

        public boolean accepts​(java.lang.String filename)
        Description copied from interface: Converter
        Check if the file can be processed by this converter.
        Specified by:
        accepts in interface Converter
        Parameters:
        filename - the file name
        Returns:
        true if the converter will process this file
      • convert

        public boolean convert​(java.lang.String path,
                               java.io.InputStream src,
                               java.io.OutputStream dest,
                               EESpecProfile profile)
                        throws java.io.IOException
        Description copied from interface: Converter
        Copies the source to the destination, converting it if necessary, according to the requirements of the given profile.
        Specified by:
        convert in interface Converter
        Parameters:
        path - The path to the data being converted
        src - The source data to convert
        dest - The destination to write the converted data
        profile - The profile that defines the conversion required
        Returns:
        true if the converter made a conversion to the file
        Throws:
        java.io.IOException - If the conversion fails
      • transform

        public byte[] transform​(java.lang.ClassLoader loader,
                                java.lang.String className,
                                java.lang.Class<?> classBeingRedefined,
                                java.security.ProtectionDomain protectionDomain,
                                byte[] classfileBuffer)
                         throws java.lang.instrument.IllegalClassFormatException
        Specified by:
        transform in interface java.lang.instrument.ClassFileTransformer
        Throws:
        java.lang.instrument.IllegalClassFormatException
      • convertInternal

        protected boolean convertInternal​(java.lang.String path,
                                          java.io.InputStream src,
                                          java.io.OutputStream dest,
                                          EESpecProfile profile,
                                          java.lang.ClassLoader loader)
                                   throws java.io.IOException
        Convert specified class bytecode.
        Parameters:
        path - the path
        src - the source byte stream
        dest - the output byte stream
        profile - the specification profile to use
        loader - the class loader
        Returns:
        true if conversion occurred
        Throws:
        java.io.IOException - rethrow on byte read or write