Class ClassFileSource


public class ClassFileSource extends Support
ClassFileSource provides a mechanism for associating a class with the source of that class. The source is currently either an ordinary .class file or a zip file 1 or more class files.
  • Constructor Details

    • ClassFileSource

      public ClassFileSource(String className, File classFile)
      Constructor
      Parameters:
      className - The expected name of the class
      classFile - The file containing the class. This file should exist and be readable.
    • ClassFileSource

      public ClassFileSource(String className, ZipFile zipFile)
      Constructor
      Parameters:
      className - The expected name of the class
      zipFile - The zip file containing the class. This file should exist and be readable.
    • ClassFileSource

      public ClassFileSource(String className, InputStream byteCodeStream)
      Constructor
      Parameters:
      className - The expected name of the class
      byteCodeStream - containing the class file.
  • Method Details

    • sameAs

      public boolean sameAs(ClassFileSource other)
      Does the other class file source refer to the same source location?
    • isZipped

      public boolean isZipped()
      Does this class originate in a zip file?
    • isStreamed

      public boolean isStreamed()
      Does this class originate in a zip file?
    • expectedClassName

      public String expectedClassName()
      The expected name of the class contained in the class file. Returns null if the class name can not be intuited from the file name.
    • setExpectedClassName

      public void setExpectedClassName(String name)
      Set the name of the class contained in the class file.
    • containingFilePath

      public String containingFilePath()
      Get the path of the File containing the class
    • nextSource

      public ClassFileSource nextSource(String className)
      Attempt to find the next possible source of the class
    • friendSource

      public ClassFileSource friendSource(String className)
      Build a "friend" source file specification for the class of the given name. That is, the new class file source should be in the same zip file if zipped or else the same directory. Restriction: containingFilePath() must be non-null.
    • classFileContents

      public DataInputStream classFileContents() throws IOException, FileNotFoundException
      Get a DataInputStream containing the class file. Restriction: containingFilePath() must be non-null.
      Throws:
      IOException
      FileNotFoundException
    • modificationDate

      public long modificationDate() throws FileNotFoundException
      Get the modification date of the class file. The date format is that used by java.util.Date. Restriction: containingFilePath() must be non-null.
      Throws:
      FileNotFoundException
    • setModificationDate

      public void setModificationDate(long date)
      Set the cached modification date of the class file. This doesn't actually update the file.
    • computeDestination

      public File computeDestination(File destDir) throws IOException, FileNotFoundException
      Compute the destination file for the class. If destDir is non-null, use that as a destination location Restriction: if containingFilePath() is null, null is returned.
      Throws:
      IOException
      FileNotFoundException
    • getOutputStream

      public DataOutputStream getOutputStream(File dest) throws IOException, FileNotFoundException
      Get a DataOutputStream to which a class file should be written. The caller must close the output stream when complete.
      Throws:
      IOException
      FileNotFoundException