Class GlobPattern

java.lang.Object
com.day.cq.wcm.commons.GlobPattern

public class GlobPattern extends Object
The GlobPattern implements matching operations that do a pattern globbing.
This class is copied from day-commons-text and should not be used anymore. switch to regexp patterns if possible.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Class constructor that create a GlobPattern with the given pattern.
    GlobPattern(String pattern, boolean isHandle)
    Class constructor that create a GlobPattern with the given pattern.
  • Method Summary

    Modifier and Type
    Method
    Description
    static boolean
    Returns true if the string contains wildcards.
    boolean
    Returns true if this GlobPattern is equal to object obj.
    int
    Returns the hashCode for this GlobPattern.
    static int
    Returns the index of the first wildcard character in the string or -1 if the string does not contain a wild card character.
    final boolean
    Returns a flag indicating whether a string matches this pattern.
    static boolean
    matches(String pattern, String s)
    Returns a flag indicating whether a string matches a pattern.
    static boolean
    matches(String pattern, String s, boolean isHandle)
    Returns a flag indicating whether a string matches a pattern.
    boolean
    Returns a flag indicating whether a string matches a pattern.
    boolean
    shellMatches(String s, char c)
    Returns a flag indicating whether a string matches a pattern.
    Returns the pattern of this GlobPattern

    Methods inherited from class java.lang.Object

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

    • GlobPattern

      public GlobPattern(String pattern, boolean isHandle)
      Class constructor that create a GlobPattern with the given pattern. If the isHandle flag is true this will construct a hierarchy matcher.
      Parameters:
      pattern - pattern string
      isHandle - if true and the pattern contains no wildcards, the matches(String) returns true, if the compared string is equal or starts with the pattern+"/" (i.e. is a child page)
    • GlobPattern

      public GlobPattern(String pattern)
      Class constructor that create a GlobPattern with the given pattern.
      Parameters:
      pattern - pattern string
  • Method Details

    • matches

      public final boolean matches(String s)
      Returns a flag indicating whether a string matches this pattern.
      Parameters:
      s - string to be checked
      Returns:
      true if s matches this pattern, else false.
    • matches

      public static boolean matches(String pattern, String s)
      Returns a flag indicating whether a string matches a pattern.
      Parameters:
      pattern - pattern used for comparison
      s - string to be checked
      Returns:
      true if s matches pattern, else false.
    • matches

      public static boolean matches(String pattern, String s, boolean isHandle)
      Returns a flag indicating whether a string matches a pattern. if the ishHandle is true and the pattern contains no wildcards, the method returns true, if the pattern is a hierarchical father of the string.
      Parameters:
      pattern - pattern used for comparison
      s - string to be checked
      isHandle - flag, indicating, if a handle comparison has to be performed
      Returns:
      true if s matches pattern, else false.
    • shellMatches

      public boolean shellMatches(String s)
      Returns a flag indicating whether a string matches a pattern. unlike the matches methods, this matching is done shell-like.
      Parameters:
      s - string to be checked
      Returns:
      true if the string matches shell-like; false otherwise.
    • shellMatches

      public boolean shellMatches(String s, char c)
      Returns a flag indicating whether a string matches a pattern. unlike the matches methods, this matching is done shell-like.
      Parameters:
      s - string to be checked
      c - character to be used as path delimiter
      Returns:
      true if the string matches shell-like; false otherwise.
    • containsWildcards

      public static boolean containsWildcards(String s)
      Returns true if the string contains wildcards.
      Parameters:
      s - string to be checked
      Returns:
      true if s contains wildcards, else false.
    • indexOfWildcard

      public static int indexOfWildcard(String s)
      Returns the index of the first wildcard character in the string or -1 if the string does not contain a wild card character.
      Parameters:
      s - string to be checked
      Returns:
      the index of the first wildcard.
    • toString

      public String toString()
      Returns the pattern of this GlobPattern
      Overrides:
      toString in class Object
      Returns:
      the pattern.
    • equals

      public boolean equals(Object obj)
      Returns true if this GlobPattern is equal to object obj.
      Overrides:
      equals in class Object
      Parameters:
      obj - the object to compare for equality.
      Returns:
      true if this GlobPattern is equal to object obj.
    • hashCode

      public int hashCode()
      Returns the hashCode for this GlobPattern.
      Overrides:
      hashCode in class Object
      Returns:
      the hashCode for this GlobPattern.