Enum CompressorFactory

  • All Implemented Interfaces:
    java.io.Serializable, java.lang.Comparable<CompressorFactory>

    public enum CompressorFactory
    extends java.lang.Enum<CompressorFactory>
    Compressor factory supports programmatic selection and creation of Compressor instances. For example, it can return a compressor that is suited to a particular file type.
    Since:
    3.0
    Author:
    Chris Jennings
    • Enum Constant Summary

      Enum Constants 
      Enum Constant Description
      BZIP2
      The BZip2 compressor factory.
      DEFLATE
      The deflate (GZIP with no header or footer) compressor factory.
      GZIP
      The GZIP compressor factory.
      LZMA
      The LZMA compressor factory.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      static CompressorFactory choose​(boolean small, boolean fast, boolean standard)
      Chooses a compressor for a specific application.
      static CompressorFactory forExtension​(java.lang.String name)
      Returns a factory that matches a name, or null if no factory matches.
      java.lang.String[] getAllExtensions()
      Returns an array of all known extensions for this algorithm.
      Compressor getCompressor()
      Returns a Compressor for this algorithm.
      java.lang.String getExtension()
      Returns the most common file extension for this algorithm.
      boolean matchesExtension​(java.lang.String name)
      Returns true if one of this algorithm's extensions matches the given name.
      static CompressorFactory valueOf​(java.lang.String name)
      Returns the enum constant of this type with the specified name.
      static CompressorFactory[] values()
      Returns an array containing the constants of this enum type, in the order they are declared.
      • Methods inherited from class java.lang.Enum

        clone, compareTo, equals, finalize, getDeclaringClass, hashCode, name, ordinal, toString, valueOf
      • Methods inherited from class java.lang.Object

        getClass, notify, notifyAll, wait, wait, wait
    • Enum Constant Detail

      • DEFLATE

        public static final CompressorFactory DEFLATE
        The deflate (GZIP with no header or footer) compressor factory.
    • Method Detail

      • values

        public static CompressorFactory[] values()
        Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:
        for (CompressorFactory c : CompressorFactory.values())
            System.out.println(c);
        
        Returns:
        an array containing the constants of this enum type, in the order they are declared
      • valueOf

        public static CompressorFactory valueOf​(java.lang.String name)
        Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)
        Parameters:
        name - the name of the enum constant to be returned.
        Returns:
        the enum constant with the specified name
        Throws:
        java.lang.IllegalArgumentException - if this enum type has no constant with the specified name
        java.lang.NullPointerException - if the argument is null
      • getCompressor

        public Compressor getCompressor()
        Returns a Compressor for this algorithm.
        Returns:
        a compressor instance
      • getExtension

        public java.lang.String getExtension()
        Returns the most common file extension for this algorithm.
        Returns:
        the suggested file extension for compressed files
      • getAllExtensions

        public java.lang.String[] getAllExtensions()
        Returns an array of all known extensions for this algorithm.
        Returns:
        an array of suitable file extensions
      • matchesExtension

        public boolean matchesExtension​(java.lang.String name)
        Returns true if one of this algorithm's extensions matches the given name. If name contains a dot, then only the text after the final dot is considered when matching extensions.
        Parameters:
        name - a name with an extension to match against this algorithm's extensions
        Returns:
        true if the name's extension is a known extension for this algorithm
        Throws:
        java.lang.NullPointerException - if the name is null
      • choose

        public static CompressorFactory choose​(boolean small,
                                               boolean fast,
                                               boolean standard)
        Chooses a compressor for a specific application. The parameters allow you to specify which performance aspects of the resulting compressor are most important you, and returns a factory to suit your that satisfies
        Parameters:
        small - if true, small compressed output (high compression ratios) is important
        fast - if true, fast decompression is important
        standard - if true, being able to decompress data with common command line tools is important
        Returns:
        a factory that will create a compressor that satisfies as many of your needs as possible
      • forExtension

        public static CompressorFactory forExtension​(java.lang.String name)
        Returns a factory that matches a name, or null if no factory matches. If name contains a dot, then only the text after the final dot is considered when matching extensions.
        Parameters:
        name - the file name or extension to match
        Returns:
        a compressor factory that creates compressors for the matched file type, or null if no match was found
        Throws:
        java.lang.NullPointerException - if the name is null
        See Also:
        matchesExtension(java.lang.String)