Class ZipSourceLocation

  • All Implemented Interfaces:
    SourceLocation

    public class ZipSourceLocation
    extends java.lang.Object
    implements SourceLocation
    Represents source inside a zip or jar file. The source can be either in a "src/" subfolder, or at the root level of the archive. This class is useful for the JDK or other libraries that come with a src.zip file (src.jar on OS X).
    Version:
    1.0
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private java.io.File archive  
    • Constructor Summary

      Constructors 
      Constructor Description
      ZipSourceLocation​(java.io.File archive)
      Constructor.
      ZipSourceLocation​(java.lang.String archive)
      Constructor.
    • Field Detail

      • archive

        private java.io.File archive
    • Constructor Detail

      • ZipSourceLocation

        public ZipSourceLocation​(java.lang.String archive)
        Constructor.
        Parameters:
        archive - The archive containing the source. This should be an absolute path to ensure correctness.
      • ZipSourceLocation

        public ZipSourceLocation​(java.io.File archive)
        Constructor.
        Parameters:
        archive - The archive containing the source.
    • Method Detail

      • getCompilationUnit

        public CompilationUnit getCompilationUnit​(ClassFile cf)
                                           throws java.io.IOException
        Returns an AST for the specified class file.
        Specified by:
        getCompilationUnit in interface SourceLocation
        Parameters:
        cf - The class file to grab the AST for.
        Returns:
        The AST, or null if it cannot be found.
        Throws:
        java.io.IOException - If an IO error occurs.
      • getLocationAsString

        public java.lang.String getLocationAsString()
        Returns a string representation of this source location. For locations on disk such as zip files or directories, this should be the full path to the resource.
        Specified by:
        getLocationAsString in interface SourceLocation
        Returns:
        The location of this source as a string, or null if it is not an accessible location.