Class StringResource

    • Constructor Summary

      Constructors 
      Constructor Description
      StringResource​(java.lang.String name, java.lang.String content)  
      StringResource​(java.lang.String name, java.lang.String content, int lineNumber)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean exists()
      Checks wether this resource actually (still) exists
      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
      java.io.InputStream getInputStream()
      Returns an input stream to the content of the resource
      long getLength()
      Returns the length of the resource's content
      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
      java.net.URL getUrl()
      Returns an url to the resource if the repository of this resource is able to provide urls.
      boolean isAbsolute()
      Return true if this Trackable is in absolute mode.
      long lastModified()
      Returns the date the resource was last modified
      void setAbsolute​(boolean absolute)
      Set this Trackable to absolute mode.
      void setStripShebang​(boolean stripShebang)
      Switch shebang stripping on or off
      • Methods inherited from class java.lang.Object

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

      • StringResource

        public StringResource​(java.lang.String name,
                              java.lang.String content)
      • StringResource

        public StringResource​(java.lang.String name,
                              java.lang.String content,
                              int lineNumber)
    • Method Detail

      • 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
      • getLength

        public long getLength()
        Description copied from interface: Resource
        Returns the length of the resource's content
        Specified by:
        getLength in interface Resource
        Returns:
        content length
      • getInputStream

        public java.io.InputStream getInputStream()
                                           throws java.io.IOException
        Description copied from interface: Resource
        Returns an input stream to the content of the resource
        Specified by:
        getInputStream in interface Resource
        Returns:
        content input stream
        Throws:
        java.io.IOException - if a I/O related error occurs
      • 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()
        Description copied from interface: Resource
        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
      • 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
      • lastModified

        public long lastModified()
        Description copied from interface: Trackable
        Returns the date the resource was last modified
        Specified by:
        lastModified in interface Trackable
        Returns:
        last modified date
      • getChecksum

        public long getChecksum()
                         throws java.io.IOException
        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
        Throws:
        java.io.IOException
      • exists

        public boolean exists()
                       throws java.io.IOException
        Description copied from interface: Trackable
        Checks wether this resource actually (still) exists
        Specified by:
        exists in interface Trackable
        Returns:
        true if the resource exists
        Throws:
        java.io.IOException
      • 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
      • getUrl

        public java.net.URL getUrl()
                            throws java.lang.UnsupportedOperationException,
                                   java.net.MalformedURLException
        Description copied from interface: Trackable
        Returns an url to the resource if the repository of this resource is able to provide urls.
        Specified by:
        getUrl in interface Trackable
        Returns:
        url to the resource
        Throws:
        java.lang.UnsupportedOperationException
        java.net.MalformedURLException
      • 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
      • getModuleName

        public java.lang.String getModuleName()
        Description copied from interface: Trackable
        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
      • setAbsolute

        public void setAbsolute​(boolean absolute)
        Description copied from interface: Trackable
        Set this Trackable 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()
        Description copied from interface: Trackable
        Return true if this Trackable is in absolute mode.
        Specified by:
        isAbsolute in interface Trackable
        Returns:
        true if absolute mode is on