Class GlobusPathMatchingResourcePatternResolver


  • public class GlobusPathMatchingResourcePatternResolver
    extends java.lang.Object
    Provides methods to resolve locationPatterns and return GlobusResource objects which match those location patterns. Supports Ant-Style regular expressions, where: ** matches any number of directories ? matches one character * matches any number of characters Supports file:, classpath:, and relative paths. Provides similar functionality to spring framework's PathMatchingResourcePatternResolver 3/2/2012
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private java.util.regex.Pattern locationPattern  
      private java.lang.String mainClassPath
      Path from root directory to the directory at the beginning of a classpath.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      private java.lang.String antToRegexConverter​(java.lang.String antStyleLocationPattern)
      Converts an Ant-style pattern to a regex pattern by replacing (.
      private java.lang.String getPathUntilWildcard​(java.lang.String locationPatternString, boolean defaultToLocaldir)
      Returns a substring of the locationPattern from the beginning to the first occurrence of * or ? If this is unsuccessful, start at current directory ./
      GlobusResource getResource​(java.lang.String location)
      This method takes a location string and returns a GlobusResource of the corresponding location.
      GlobusResource[] getResources​(java.lang.String locationPattern)
      Finds all the resources that match the Ant-Style locationPattern
      private void parseDirectoryStructure​(java.io.File currentDirectory, java.util.Vector<GlobusResource> pathsMatchingLocationPattern)
      Recursive variant of parseFilesInDirectory.
      private void parseFilesInDirectory​(java.io.File currentDirectory, java.util.Vector<GlobusResource> pathsMatchingLocationPattern)
      Compares every file's Absolute Path against the locationPattern, if they match a GlobusResource is created with the file's Absolute Path and added to pathsMatchingLocationPattern.
      • Methods inherited from class java.lang.Object

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

      • locationPattern

        private java.util.regex.Pattern locationPattern
      • mainClassPath

        private java.lang.String mainClassPath
        Path from root directory to the directory at the beginning of a classpath. For example if a class was in a package org.globus.utils.MyClass.java, which had an absolute path of /user/userName/project/resources/org/globus/utils/MyClass.java the mainClassPath would be /user/userName/project/resources/
    • Constructor Detail

      • GlobusPathMatchingResourcePatternResolver

        public GlobusPathMatchingResourcePatternResolver()
    • Method Detail

      • getResource

        public GlobusResource getResource​(java.lang.String location)
        This method takes a location string and returns a GlobusResource of the corresponding location. This method does not accept any patterns for the location string.
        Parameters:
        location - An absolute or relative location in the style classpath:/folder/className.class, file:/folder/fileName.ext, or folder/folder/fileName.ext
        Returns:
        A GlobusResource type object of the corresponding location string.
      • getResources

        public GlobusResource[] getResources​(java.lang.String locationPattern)
        Finds all the resources that match the Ant-Style locationPattern
        Parameters:
        locationPattern - Ant-Style location pattern which may be prefixed with classpath:/, file:/, or describe a relative path.
        Returns:
        An array of GlobusResource containing all resources whose locaiton match the locationPattern
      • antToRegexConverter

        private java.lang.String antToRegexConverter​(java.lang.String antStyleLocationPattern)
        Converts an Ant-style pattern to a regex pattern by replacing (. with \\.), (? with .), (** with .*), and (* with [^/]*).
        Parameters:
        antStyleLocationPattern - An Ant-Stlye location pattern.
        Returns:
        A regex style location pattern representation of the antStyleLocationPattern
      • getPathUntilWildcard

        private java.lang.String getPathUntilWildcard​(java.lang.String locationPatternString,
                                                      boolean defaultToLocaldir)
        Returns a substring of the locationPattern from the beginning to the first occurrence of * or ? If this is unsuccessful, start at current directory ./
        Parameters:
        locationPatternString - The Ant-Style location pattern.
        Returns:
        A substring of the locationPatternString from the beginning to the first occurrence of a wildcard character
      • parseDirectoryStructure

        private void parseDirectoryStructure​(java.io.File currentDirectory,
                                             java.util.Vector<GlobusResource> pathsMatchingLocationPattern)
        Recursive variant of parseFilesInDirectory.
        Parameters:
        currentDirectory - The currentDirectory to explore.
        pathsMatchingLocationPattern - Holds GlobusResource instances of all the paths which matched the locationPattern
      • parseFilesInDirectory

        private void parseFilesInDirectory​(java.io.File currentDirectory,
                                           java.util.Vector<GlobusResource> pathsMatchingLocationPattern)
        Compares every file's Absolute Path against the locationPattern, if they match a GlobusResource is created with the file's Absolute Path and added to pathsMatchingLocationPattern.
        Parameters:
        currentDirectory - The directory whose files to parse.
        pathsMatchingLocationPattern - Holds GlobusResource instances of all the paths which matched the locationPattern