Class CompilationUnit.Storage

  • Enclosing class:
    CompilationUnit

    public static class CompilationUnit.Storage
    extends java.lang.Object
    Information about where this compilation unit was loaded from. This class only stores the absolute location. For more flexibility use SourceRoot.
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      private Storage​(CompilationUnit compilationUnit, java.nio.file.Path path)  
      private Storage​(CompilationUnit compilationUnit, java.nio.file.Path path, java.nio.charset.Charset encoding)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      CompilationUnit getCompilationUnit()  
      java.nio.file.Path getDirectory()  
      java.nio.charset.Charset getEncoding()  
      java.lang.String getFileName()  
      java.nio.file.Path getPath()  
      java.nio.file.Path getSourceRoot()  
      ParseResult<CompilationUnit> reparse​(JavaParser javaParser)  
      void save()
      Saves the compilation unit to its original location
      void save​(java.util.function.Function<CompilationUnit,​java.lang.String> makeOutput)
      Saves a compilation unit to its original location with formatting according to the function passed as a parameter.
      void save​(java.util.function.Function<CompilationUnit,​java.lang.String> makeOutput, java.nio.charset.Charset encoding)
      Saves a compilation unit to its original location with formatting and encoding according to the function and encoding passed as a parameter.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • path

        private final java.nio.file.Path path
      • encoding

        private final java.nio.charset.Charset encoding
    • Constructor Detail

      • Storage

        private Storage​(CompilationUnit compilationUnit,
                        java.nio.file.Path path)
      • Storage

        private Storage​(CompilationUnit compilationUnit,
                        java.nio.file.Path path,
                        java.nio.charset.Charset encoding)
    • Method Detail

      • getPath

        public java.nio.file.Path getPath()
        Returns:
        the path to the source for this CompilationUnit
      • getCompilationUnit

        public CompilationUnit getCompilationUnit()
        Returns:
        the CompilationUnit this Storage is about.
      • getEncoding

        public java.nio.charset.Charset getEncoding()
        Returns:
        the encoding used to read the file.
      • getSourceRoot

        public java.nio.file.Path getSourceRoot()
        Returns:
        the source root directory, calculated from the path of this compiation unit, and the package declaration of this compilation unit. If the package declaration is invalid (when it does not match the end of the path) a RuntimeException is thrown.
      • getFileName

        public java.lang.String getFileName()
      • getDirectory

        public java.nio.file.Path getDirectory()
      • save

        public void save()
        Saves the compilation unit to its original location
      • save

        public void save​(java.util.function.Function<CompilationUnit,​java.lang.String> makeOutput)
        Saves a compilation unit to its original location with formatting according to the function passed as a parameter.
        Parameters:
        makeOutput - a function that formats the compilation unit
      • save

        public void save​(java.util.function.Function<CompilationUnit,​java.lang.String> makeOutput,
                         java.nio.charset.Charset encoding)
        Saves a compilation unit to its original location with formatting and encoding according to the function and encoding passed as a parameter.
        Parameters:
        makeOutput - a function that formats the compilation unit
        encoding - the encoding to use for the saved file