Class AbstractRepository

    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      protected abstract AbstractRepository createChildRepository​(java.lang.String name)
      Create a new child reposiotory with the given name.
      AbstractRepository getChildRepository​(java.lang.String subpath)
      Get a child repository with the given name
      java.lang.String getModuleName()
      Utility method to get the name for the module defined by this resource.
      java.lang.String getName()
      Get the local name that identifies this repository locally within its parent repository
      AbstractRepository getParentRepository()
      Get this repository's parent repository.
      java.lang.String getPath()
      Get the full name that identifies this repository globally
      java.lang.String getRelativePath()
      Get the path of this repository relative to its root repository.
      Resource getResource​(java.lang.String subpath)
      Get a resource contained in this repository identified by the given local name.
      Resource[] getResources()
      Get a list of resources contained in this repository identified by the given local name.
      Resource[] getResources​(boolean recursive)
      Get a list of resources contained in this repository identified by the given local name.
      Resource[] getResources​(java.lang.String resourcePath, boolean recursive)
      Get a list of resources contained in this repository identified by the given local name.
      protected abstract void getResources​(java.util.List<Resource> list, boolean recursive)
      Add the repository's resources into the list, optionally descending into nested repositories.
      Repository getRootRepository()
      Get the repository's root repository
      boolean isAbsolute()
      Return true if this Repository is in absolute mode.
      protected AbstractRepository lookupRepository​(java.lang.String name)  
      protected abstract Resource lookupResource​(java.lang.String name)
      Called to create a child resource for this repository if it exists.
      protected java.lang.String[] resolve​(java.lang.String path, boolean absolute)
      Resolve path relative to this repository.
      void setAbsolute​(boolean absolute)
      Set this Repository to absolute mode.
      void setRoot()
      Mark this repository as root repository.
      java.lang.String toString()
      Returns the repositories full path as string representation.
      • Methods inherited from class java.lang.Object

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

      • AbstractRepository

        public AbstractRepository()
    • Method Detail

      • lookupResource

        protected abstract Resource lookupResource​(java.lang.String name)
                                            throws java.io.IOException
        Called to create a child resource for this repository if it exists.
        Parameters:
        name - the name of the child resource
        Returns:
        the child resource, or null if no resource with the given name exists
        Throws:
        java.io.IOException - an I/O error occurred
      • createChildRepository

        protected abstract AbstractRepository createChildRepository​(java.lang.String name)
                                                             throws java.io.IOException
        Create a new child reposiotory with the given name.
        Parameters:
        name - the name
        Returns:
        the new child repository
        Throws:
        java.io.IOException - an I/O error occurred
      • getResources

        protected abstract void getResources​(java.util.List<Resource> list,
                                             boolean recursive)
                                      throws java.io.IOException
        Add the repository's resources into the list, optionally descending into nested repositories.
        Parameters:
        list - the list to add the resources to
        recursive - whether to descend into nested repositories
        Throws:
        java.io.IOException - an I/O related error occurred
      • getPath

        public java.lang.String getPath()
        Get the full name that identifies this repository globally
        Specified by:
        getPath in interface Trackable
        Returns:
        path of the resource
      • getName

        public java.lang.String getName()
        Get the local name that identifies this repository locally within its parent repository
        Specified by:
        getName in interface Trackable
        Returns:
        short name of the resource
      • setRoot

        public void setRoot()
        Mark this repository as root repository.
        Specified by:
        setRoot in interface Repository
      • setAbsolute

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

        public java.lang.String getRelativePath()
        Get the path of this repository relative to its root repository.
        Specified by:
        getRelativePath in interface Repository
        Specified by:
        getRelativePath in interface Trackable
        Returns:
        the repository 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
      • resolve

        protected java.lang.String[] resolve​(java.lang.String path,
                                             boolean absolute)
        Resolve path relative to this repository.
        Parameters:
        path - a path string
        absolute - whether to return an absolute path that can be used without this repository
        Returns:
        a List containing the path elements resolved relative to this repository
      • getResource

        public Resource getResource​(java.lang.String subpath)
                             throws java.io.IOException
        Get a resource contained in this repository identified by the given local name. If the name can't be resolved to a resource, a resource object is returned for which exists() returns false.
        Specified by:
        getResource in interface Repository
        Parameters:
        subpath - name of the child resource to return
        Returns:
        specified child resource
        Throws:
        java.io.IOException
      • getChildRepository

        public AbstractRepository getChildRepository​(java.lang.String subpath)
                                              throws java.io.IOException
        Get a child repository with the given name
        Specified by:
        getChildRepository in interface Repository
        Parameters:
        subpath - the name of the repository
        Returns:
        the child repository
        Throws:
        java.io.IOException - an IOException occurred
      • lookupRepository

        protected AbstractRepository lookupRepository​(java.lang.String name)
                                               throws java.io.IOException
        Throws:
        java.io.IOException
      • getResources

        public Resource[] getResources()
                                throws java.io.IOException
        Description copied from interface: Repository
        Get a list of resources contained in this repository identified by the given local name.
        Specified by:
        getResources in interface Repository
        Returns:
        a list of all direct child resources
        Throws:
        java.io.IOException
      • getResources

        public Resource[] getResources​(boolean recursive)
                                throws java.io.IOException
        Description copied from interface: Repository
        Get a list of resources contained in this repository identified by the given local name.
        Specified by:
        getResources in interface Repository
        Parameters:
        recursive - whether to include nested resources
        Returns:
        a list of all nested child resources
        Throws:
        java.io.IOException
      • getResources

        public Resource[] getResources​(java.lang.String resourcePath,
                                       boolean recursive)
                                throws java.io.IOException
        Description copied from interface: Repository
        Get a list of resources contained in this repository identified by the given local name.
        Specified by:
        getResources in interface Repository
        Parameters:
        resourcePath - the repository path
        recursive - whether to include nested resources
        Returns:
        a list of all nested child resources
        Throws:
        java.io.IOException
      • toString

        public java.lang.String toString()
        Returns the repositories full path as string representation.
        Overrides:
        toString in class java.lang.Object
        See Also:
        getPath()