Class Glob

java.lang.Object
ch.tocco.nice2.types.api.Glob
All Implemented Interfaces:
Cloneable

public final class Glob extends Object implements Cloneable
A glob implementation. Globs are simple patterns supporting the wildcards '?' (match any single character) and '*' (match any number of arbitrary characters). The two wildcards may actually be replaced by whatever you like.

See http://en.wikipedia.org/wiki/Glob_(programming)

  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static enum 
    Enum for wildcards.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Glob(CharSequence pattern)
    Create a case insensitive Glob from the given pattern using the default wildcard characters.
    Glob(CharSequence pattern, boolean caseSensitive)
    Create a Glob from the given pattern using the default wildcard characters.
    Glob(CharSequence pattern, boolean caseSensitive, char substring, char character)
    Create a Glob from the given pattern.
    Glob(CharSequence pattern, char substring, char character)
    Create a Glob from the given pattern using the specified wildcard characters.
  • Method Summary

    Modifier and Type
    Method
    Description
     
    boolean
    Check whether the string contains this Glob's pattern.
    boolean
     
    Get an array of this Glob's segments.
    int
     
    boolean
     
    boolean
    matches(String match)
    Check whether the string matches this Glob's pattern.
    Get a Glob surrounded by SUBSTRING wildcards.
    Convert the Glob back to a pattern string.
    toString(char substring, char character)
    Convert the Glob back to a pattern string using the specified wildcard characters.

    Methods inherited from class java.lang.Object

    finalize, getClass, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • Glob

      public Glob(CharSequence pattern)
      Create a case insensitive Glob from the given pattern using the default wildcard characters.
      Parameters:
      pattern - The pattern.
    • Glob

      public Glob(CharSequence pattern, boolean caseSensitive)
      Create a Glob from the given pattern using the default wildcard characters.
      Parameters:
      pattern - The pattern.
      caseSensitive - true for case sensitive mode.
    • Glob

      public Glob(CharSequence pattern, char substring, char character)
      Create a Glob from the given pattern using the specified wildcard characters.
      Parameters:
      pattern - The pattern.
      substring - The substring wildcard ('*').
      character - The single character wildcard ('?').
    • Glob

      public Glob(CharSequence pattern, boolean caseSensitive, char substring, char character)
      Create a Glob from the given pattern.
      Parameters:
      pattern - The pattern.
      caseSensitive - true for case sensitive mode.
      substring - The substring wildcard ('*').
      character - The single character wildcard ('?').
  • Method Details

    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Convert the Glob back to a pattern string.
      Overrides:
      toString in class Object
      Returns:
      The pattern string.
    • toString

      public String toString(char substring, char character)
      Convert the Glob back to a pattern string using the specified wildcard characters.
      Parameters:
      substring - The substring wildcard ('*').
      character - The single character wildcard ('?').
      Returns:
      The pattern string.
    • isCaseSensitive

      public boolean isCaseSensitive()
    • matches

      public boolean matches(String match)
      Check whether the string matches this Glob's pattern.
      Parameters:
      match - The string to match.
      Returns:
      true, if the string matches.
    • contains

      public boolean contains(String match)
      Check whether the string contains this Glob's pattern.
      Parameters:
      match - The string to match.
      Returns:
      true, if the string contains the pattern.
    • toContainsGlob

      public Glob toContainsGlob()
      Get a Glob surrounded by SUBSTRING wildcards.
      Returns:
      The new Glob.
    • getSegments

      public Object[] getSegments()
      Get an array of this Glob's segments. This is an Object[], where each element is either a string or a Glob.Wildcard value.
      Returns:
      The array of this Glob's segments.
    • clone

      public Glob clone()
      Overrides:
      clone in class Object