Package org.gjt.cuspy

Class JarX.Build

  • Enclosing class:
    JarX

    public static class JarX.Build
    extends JarX
    Subclass of JarX containing the code needed to build jars. This class is not needed for extracting and this class file does not need to be included in a self-extracting jar.
    • Constructor Detail

      • Build

        public Build()
    • Method Detail

      • main

        public static void main​(String[] args)
                         throws Exception
        Entry point for building a jar. Names of all files to be put in the jar (except the manifest itself) are taken from the manifest.
        Parameters:
        args - two command line arguments: 1) the name of the jar file to create; 2) the name of the manifest file.
        Throws:
        Exception - if anything goes wrong, punt
      • build

        public void build​(String jarFile,
                          String manif)
                   throws Exception
        Method to be used by an application using this class to build a jar.
        Parameters:
        jarFile - name of jar file to be created
        manif - name of an existing manifest file containing the names of files to include in the jar. File names in the manifest obey zip conventions with the forward slash / as the path operator, which may differ from the local platform convention.
        Throws:
        Exception - if anything doesn't work, punt
      • shovelLines

        public void shovelLines​(InputStream is,
                                OutputStream os)
                         throws IOException
        Overridden to apply the archive encoding to the output stream (jar entry), the unpacked encoding to the input stream (local file), and use the RFC2046-required CRLF line separator on the output.
        Overrides:
        shovelLines in class JarX
        Parameters:
        is - source of input (local file)
        os - destination of output (jar entry)
        Throws:
        IOException - for any problem involving I/O
      • shovelChars

        public void shovelChars​(InputStream is,
                                OutputStream os)
                         throws IOException
        Overridden to apply the archive encoding to the output stream (jar entry) and the unpacked encoding to the input stream (local file).
        Overrides:
        shovelChars in class JarX
        Parameters:
        is - source of input (local file)
        os - destination of output (jar entry)
        Throws:
        IOException - for any problem involving I/O
      • manifest

        public void manifest​(InputStream is)
                      throws IOException
        Read the manifest and build lists of file names and Attributes objects. This was originally here because JarX wanted to support Java 1.1, which lacked java.util.jar. The reason it is still here (in Build only) is that the java.util.jar.Manifest implementation doesn't preserve the order of manifest sections, while it is nice to build the jar in the specified order.
        Parameters:
        is - an input stream already open on the manifest
        Throws:
        IOException - if unable to read the manifest
      • section

        public boolean section​(BufferedReader r)
                        throws IOException
        Process one manifest section, adding a dictionary entry if the section contains both a Name: and a Content-Type attribute.
        Parameters:
        r - BufferedReader already open on the manifest
        Returns:
        true if there is another section to read, false if the end of the manifest has been reached
        Throws:
        IOException - if the manifest can't be read
      • header

        public String header​(BufferedReader r)
                      throws IOException
        Return one header line (complete after RFC822 continuation unfolding). Note: The Jar specification says it is "inspired by" RFC822, but the folding rule differs. RFC822 allows "linear whitespace" (i.e. space or tab) to start the continuation line, and the LWSP remains in the line (RFC822 lines are only supposed to be folded at places LWSP can appear). A jar manifest line continuation can only begin with a space, and the space is eaten; Java's manifest writer can arbitrarily fold in the middle of anything.
        Parameters:
        r - BufferedReader to read from
        Returns:
        the line read, or null at end of input
        Throws:
        IOException - if the input cannot be read