Class Sources.FileSource

  • All Implemented Interfaces:
    Source
    Enclosing class:
    Sources

    private static class Sources.FileSource
    extends java.lang.Object
    implements Source
    Implementation of Source.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private java.io.File file  
      private java.net.URL url  
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      private FileSource​(java.io.File file)  
      private FileSource​(java.net.URL url)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      Source append​(Source child)
      Returns a source whose path concatenates this with a child.
      java.io.File file()  
      java.io.InputStream openStream()  
      java.lang.String path()  
      java.lang.String protocol()  
      java.io.Reader reader()  
      Source relative​(Source parent)
      Returns a relative source, if this source is a child of a given base.
      java.lang.String toString()  
      Source trim​(java.lang.String suffix)
      Looks for a suffix on a path and returns either the path with the suffix removed or the original path.
      Source trimOrNull​(java.lang.String suffix)
      Looks for a suffix on a path and returns either the path with the suffix removed or null.
      java.net.URL url()  
      private java.io.File urlToFile​(java.net.URL url)  
      • Methods inherited from class java.lang.Object

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

      • file

        private final java.io.File file
      • url

        private final java.net.URL url
    • Constructor Detail

      • FileSource

        private FileSource​(java.net.URL url)
      • FileSource

        private FileSource​(java.io.File file)
    • Method Detail

      • urlToFile

        private java.io.File urlToFile​(java.net.URL url)
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • url

        public java.net.URL url()
        Specified by:
        url in interface Source
      • file

        public java.io.File file()
        Specified by:
        file in interface Source
      • protocol

        public java.lang.String protocol()
        Specified by:
        protocol in interface Source
      • path

        public java.lang.String path()
        Specified by:
        path in interface Source
      • reader

        public java.io.Reader reader()
                              throws java.io.IOException
        Specified by:
        reader in interface Source
        Throws:
        java.io.IOException
      • openStream

        public java.io.InputStream openStream()
                                       throws java.io.IOException
        Specified by:
        openStream in interface Source
        Throws:
        java.io.IOException
      • trim

        public Source trim​(java.lang.String suffix)
        Description copied from interface: Source
        Looks for a suffix on a path and returns either the path with the suffix removed or the original path.
        Specified by:
        trim in interface Source
      • trimOrNull

        public Source trimOrNull​(java.lang.String suffix)
        Description copied from interface: Source
        Looks for a suffix on a path and returns either the path with the suffix removed or null.
        Specified by:
        trimOrNull in interface Source
      • append

        public Source append​(Source child)
        Description copied from interface: Source
        Returns a source whose path concatenates this with a child.

        For example,

        • source("/foo").append(source("bar")) returns source("/foo/bar")
        • source("/foo").append(source("/bar")) returns source("/bar") because "/bar" was already absolute
        Specified by:
        append in interface Source
      • relative

        public Source relative​(Source parent)
        Description copied from interface: Source
        Returns a relative source, if this source is a child of a given base.

        For example,

        • source("/foo/bar").relative(source("/foo")) returns source("bar")
        • source("/baz/bar").relative(source("/foo")) returns source("/baz/bar")
        Specified by:
        relative in interface Source