commandbox.system.modules.globber.models

Class Globber

lucee.Component
    extended by commandbox.system.modules.globber.models.Globber

Copyright Since 2014 by Ortus Solutions, Corp www.coldbox.org | www.ortussolutions.com I represent a single globbing pattern and provide a fluent API to access the matching files Unlike the PathPatternMatcher, which only handles comparisons of patterns, this model actually interacts with the file system to resolve a pattern to a list of real file system resources.

Class Attributes:
  • synchronized : false
  •  
  • accessors : true
  •  
  • persistent : false
  •  
  • author : Brad Wood
  •  
    Property Summary
    type property default serializable required
    any baseDir
          Directory the list was pulled from.

    • access = public
    • returntype = any
    true false
    any excludePattern
          The file globbing pattern NOT to match.

    • access = public
    • returntype = any
    true false
    any format
          Return matches as a query instead of an array.

    • access = public
    • returntype = any
    array true false
    any matchQuery
          query of real file system resources that match the pattern.

    • access = public
    • returntype = any
    true false
    any pathPatternMatcher


    • access = public
    • returntype = any
    • inject = pathPatternMatcher@globber
    true false
    any pattern
          The file globbing pattern to match.

    • access = public
    • returntype = any
    true false
    any sort
          Sort to use.

    • access = public
    • returntype = any
    type, name true false
    Constructor Summary
    init()
    Method Summary
    any addExcludePattern(string excludePattern)
         Add addiional excludePattern to process.
    any addPattern(string pattern)
         Add addiional pattern to process.
    any apply([any udf])
         Pass a closure to this function to have it.
    any asArray()
         Return results as array.
    any asQuery()
         Return results as query.
    any count()
         Get count of matched files.
    private any ensureMatches()
         Make sure the MatchQuery has been loaded.
    string getBaseDir()
    any getCleanSort()
         The sort function in CFDirectory will simply ignore invalid sort columns so I'm mimicing that here, as much as I dislike it.
    any getExcludePattern()
         Always returns a string which is a list of excludePatterns.
    any getExcludePatternArray()
    string getFormat()
    string getMatchQuery()
    string getPathPatternMatcher()
    any getPattern()
         Always returns a string which is a list of patterns.
    any getPatternArray()
    string getSort()
    any matches()
         Get array of matched file system paths.
    private any process()
         Load matching file from the file system.
    private any processPattern([string pattern])
    any setBaseDir(any baseDir)
    any setExcludePattern(any excludePattern)
         Can be list of excludePatterns or array of excludePatterns.
    any setFormat(any format)
    any setMatchQuery(any matchQuery)
    any setPathPatternMatcher(any pathPatternMatcher)
    any setPattern(any pattern)
         Override setter to ensure consistent slashe in pattern.
    any setSort(any sort)
    any withSort([any thisSort])
         Return results as array.
     
    Methods inherited from class lucee.Component
    None

    Constructor Detail

    init

    public init()


    Property Detail

    baseDir

    property any baseDir

    Directory the list was pulled from

    Attributes:
    access - public
    required - false
    returntype - any
    serializable - true

    excludePattern

    property any excludePattern

    The file globbing pattern NOT to match.

    Attributes:
    access - public
    required - false
    returntype - any
    serializable - true

    format

    property any format = [array]

    Return matches as a query instead of an array

    Attributes:
    access - public
    required - false
    returntype - any
    serializable - true

    matchQuery

    property any matchQuery

    query of real file system resources that match the pattern

    Attributes:
    access - public
    required - false
    returntype - any
    serializable - true

    pathPatternMatcher

    property any pathPatternMatcher

    Attributes:
    access - public
    required - false
    returntype - any
    inject - pathPatternMatcher@globber
    serializable - true

    pattern

    property any pattern

    The file globbing pattern to match.

    Attributes:
    access - public
    required - false
    returntype - any
    serializable - true

    sort

    property any sort = [type, name]

    Sort to use

    Attributes:
    access - public
    required - false
    returntype - any
    serializable - true

    Method Detail

    addExcludePattern

    public any addExcludePattern(string excludePattern)

    Add addiional excludePattern to process

    Parameters:
    excludePattern

    addPattern

    public any addPattern(string pattern)

    Add addiional pattern to process

    Parameters:
    pattern

    apply

    public any apply([any udf])

    Pass a closure to this function to have it applied to each paths matched by the pattern.

    Parameters:
    udf

    asArray

    public any asArray()

    Return results as array


    asQuery

    public any asQuery()

    Return results as query


    count

    public any count()

    Get count of matched files


    ensureMatches

    private any ensureMatches()

    Make sure the MatchQuery has been loaded.


    getBaseDir

    public string getBaseDir()


    getCleanSort

    public any getCleanSort()

    The sort function in CFDirectory will simply ignore invalid sort columns so I'm mimicing that here, as much as I dislike it. The sort should be in the format of "col asc, col2 desc, col3, col4" like a SQL order by If any of the coluns or sort directions don't look right, just bail and return the default sort.


    getExcludePattern

    public any getExcludePattern()

    Always returns a string which is a list of excludePatterns


    getExcludePatternArray

    public any getExcludePatternArray()


    getFormat

    public string getFormat()


    getMatchQuery

    public string getMatchQuery()


    getPathPatternMatcher

    public string getPathPatternMatcher()


    getPattern

    public any getPattern()

    Always returns a string which is a list of patterns


    getPatternArray

    public any getPatternArray()


    getSort

    public string getSort()


    matches

    public any matches()

    Get array of matched file system paths


    process

    private any process()

    Load matching file from the file system


    processPattern

    private any processPattern([string pattern])

    Parameters:
    pattern

    setBaseDir

    public any setBaseDir(any baseDir)

    Parameters:
    baseDir

    setExcludePattern

    public any setExcludePattern(any excludePattern)

    Can be list of excludePatterns or array of excludePatterns. Empty excludePatterns will be ignored

    Parameters:
    excludePattern

    setFormat

    public any setFormat(any format)

    Parameters:
    format

    setMatchQuery

    public any setMatchQuery(any matchQuery)

    Parameters:
    matchQuery

    setPathPatternMatcher

    public any setPathPatternMatcher(any pathPatternMatcher)

    Parameters:
    pathPatternMatcher

    setPattern

    public any setPattern(any pattern)

    Override setter to ensure consistent slashe in pattern Can be list of patterns or array of patterns. Empty patterns will be ignored

    Parameters:
    pattern

    setSort

    public any setSort(any sort)

    Parameters:
    sort

    withSort

    public any withSort([any thisSort])

    Return results as array

    Parameters:
    thisSort