Class AbstractResource

    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.String getBaseName()
      Returns the short name of the resource with the file extension (everything following the last dot character) cut off.
      long getChecksum()
      Checksum of the resource content.
      java.lang.String getContent()
      Returns the content of the resource
      java.lang.String getContent​(java.lang.String encoding)
      Returns the content of the resource in a given encoding
      int getLineNumber()
      Return the current line number of this resource.
      java.lang.String getModuleName()
      Utility method to get the name for the module defined by this resource.
      java.lang.String getName()
      Returns the short name of the resource.
      Repository getParentRepository()
      Returns the parent repository containing this resource
      java.lang.String getPath()
      Returns the path of the resource.
      java.io.Reader getReader()
      Returns a reader for the resource
      java.io.Reader getReader​(java.lang.String encoding)
      Returns a reader for the resource using the given character encoding
      java.lang.String getRelativePath()
      Get the path of this resource relative to its root repository.
      Repository getRootRepository()
      Returns the root repository of this resource
      boolean getStripShebang()
      Returns true if the input stream for this resource will look for a first line starting with the characters #! and suppress it if found
      boolean isAbsolute()
      Return true if this Resource is in absolute mode.
      void setAbsolute​(boolean absolute)
      Set this Resource to absolute mode.
      protected void setBaseNameFromName​(java.lang.String name)  
      void setStripShebang​(boolean stripShebang)
      Switch shebang stripping on or off
      protected java.io.InputStream stripShebang​(java.io.InputStream stream)  
      • Methods inherited from class java.lang.Object

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

      • path

        protected java.lang.String path
      • name

        protected java.lang.String name
      • baseName

        protected java.lang.String baseName
    • Constructor Detail

      • AbstractResource

        public AbstractResource()
    • Method Detail

      • setBaseNameFromName

        protected void setBaseNameFromName​(java.lang.String name)
      • getPath

        public java.lang.String getPath()
        Description copied from interface: Trackable
        Returns the path of the resource. The returned string must be in a form so that appending a child name produces a valid resource or repository name. Usually this means that it should end with a file separator character.
        Specified by:
        getPath in interface Trackable
        Returns:
        path of the resource
      • getName

        public java.lang.String getName()
        Description copied from interface: Trackable
        Returns the short name of the resource.
        Specified by:
        getName in interface Trackable
        Returns:
        short name of the resource
      • getBaseName

        public java.lang.String getBaseName()
        Description copied from interface: Resource
        Returns the short name of the resource with the file extension (everything following the last dot character) cut off.
        Specified by:
        getBaseName in interface Resource
        Returns:
        the file name without the file extension
      • getParentRepository

        public Repository getParentRepository()
        Description copied from interface: Trackable
        Returns the parent repository containing this resource
        Specified by:
        getParentRepository in interface Trackable
        Returns:
        parent repository
      • getRootRepository

        public Repository getRootRepository()
        Description copied from interface: Trackable
        Returns the root repository of this resource
        Specified by:
        getRootRepository in interface Trackable
        Returns:
        root repository
      • stripShebang

        protected java.io.InputStream stripShebang​(java.io.InputStream stream)
                                            throws java.io.IOException
        Throws:
        java.io.IOException
      • getReader

        public java.io.Reader getReader​(java.lang.String encoding)
                                 throws java.io.IOException
        Description copied from interface: Resource
        Returns a reader for the resource using the given character encoding
        Specified by:
        getReader in interface Resource
        Parameters:
        encoding - the character encoding
        Returns:
        the reader
        Throws:
        java.io.IOException - if a I/O related error occurs
      • getReader

        public java.io.Reader getReader()
                                 throws java.io.IOException
        Description copied from interface: Resource
        Returns a reader for the resource
        Specified by:
        getReader in interface Resource
        Returns:
        the reader
        Throws:
        java.io.IOException - if a I/O related error occurs
      • getContent

        public java.lang.String getContent​(java.lang.String encoding)
                                    throws java.io.IOException
        Description copied from interface: Resource
        Returns the content of the resource in a given encoding
        Specified by:
        getContent in interface Resource
        Parameters:
        encoding - the character encoding
        Returns:
        the content
        Throws:
        java.io.IOException - if a I/O related error occurs
      • getContent

        public java.lang.String getContent()
                                    throws java.io.IOException
        Description copied from interface: Resource
        Returns the content of the resource
        Specified by:
        getContent in interface Resource
        Returns:
        the content
        Throws:
        java.io.IOException - if a I/O related error occurs
      • getRelativePath

        public java.lang.String getRelativePath()
        Get the path of this resource relative to its root repository.
        Specified by:
        getRelativePath in interface Resource
        Specified by:
        getRelativePath in interface Trackable
        Returns:
        the relative resource path
      • getModuleName

        public java.lang.String getModuleName()
        Utility method to get the name for the module defined by this resource.
        Specified by:
        getModuleName in interface Trackable
        Returns:
        the module name according to the securable module spec
      • getChecksum

        public long getChecksum()
        Description copied from interface: Trackable
        Checksum of the resource content. Implementations should make sure to return a different checksum if the resource's content has changed.
        Specified by:
        getChecksum in interface Trackable
        Returns:
        checksum
      • getStripShebang

        public boolean getStripShebang()
        Description copied from interface: Resource
        Returns true if the input stream for this resource will look for a first line starting with the characters #! and suppress it if found
        Specified by:
        getStripShebang in interface Resource
        Returns:
        true if shebang stripping is enabled
      • setStripShebang

        public void setStripShebang​(boolean stripShebang)
        Description copied from interface: Resource
        Switch shebang stripping on or off
        Specified by:
        setStripShebang in interface Resource
        Parameters:
        stripShebang - true to enable shebang stripping
      • getLineNumber

        public int getLineNumber()
        Description copied from interface: Resource
        Return the current line number of this resource. Useful in combination with things like shebang stripping and shell input.
        Specified by:
        getLineNumber in interface Resource
        Returns:
        the current line number of this resource
      • setAbsolute

        public void setAbsolute​(boolean absolute)
        Set this Resource to absolute mode. This will cause all its relative path operations to use absolute paths instead.
        Specified by:
        setAbsolute in interface Trackable
        Parameters:
        absolute - true to operate in absolute mode
      • isAbsolute

        public boolean isAbsolute()
        Return true if this Resource is in absolute mode.
        Specified by:
        isAbsolute in interface Trackable
        Returns:
        true if absolute mode is on