info.magnolia.cms.util
Class SimpleUrlPattern

java.lang.Object
  extended by info.magnolia.cms.util.SimpleUrlPattern
All Implemented Interfaces:
UrlPattern, Serializable

public final class SimpleUrlPattern
extends Object
implements UrlPattern

An implementation of URLPattern which matches strings using simple * or ? wildcards. TODO rewrite this class using ant-style path comparison and avoiding regexp. See org.springframework.util.AntPathMatcher in spring 1.2 for a nice implementation.

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from interface info.magnolia.cms.util.UrlPattern
UrlPattern.MatchAllPattern
 
Field Summary
static String MULTIPLE_CHAR_PATTERN
          Regexp pattern used for the simple keyword *.
static String SINGLE_CHAR_PATTERN
          Regexp pattern used for the simple keyword ?.
static String URL_CHAR_PATTERN
          Any char, newline included.
 
Fields inherited from interface info.magnolia.cms.util.UrlPattern
MATCH_ALL
 
Constructor Summary
SimpleUrlPattern()
          Default constructor used by ContentToBean.
SimpleUrlPattern(String string)
          Compile a regexp pattern handling * and ? chars.
 
Method Summary
static String getEncodedString(String str)
          Replace all "*" with RegexWildcardPattern.MULTIPLE_CHAR_PATTERN.
 int getLength()
          Returns the pattern length.
 String getPatternString()
          Returns the pattern string.
 boolean match(String str)
          Does the patter match the given url?
 void setPatternString(String patternString)
          Mainly used by ContentToBean.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

URL_CHAR_PATTERN

public static final String URL_CHAR_PATTERN
Any char, newline included.

See Also:
Constant Field Values

MULTIPLE_CHAR_PATTERN

public static final String MULTIPLE_CHAR_PATTERN
Regexp pattern used for the simple keyword *. Matches 0 or more characters.

See Also:
Constant Field Values

SINGLE_CHAR_PATTERN

public static final String SINGLE_CHAR_PATTERN
Regexp pattern used for the simple keyword ?. Matches 0 or 1 character.

See Also:
Constant Field Values
Constructor Detail

SimpleUrlPattern

public SimpleUrlPattern()
Default constructor used by ContentToBean.


SimpleUrlPattern

public SimpleUrlPattern(String string)
Compile a regexp pattern handling * and ? chars.

Parameters:
string - input string
Method Detail

getEncodedString

public static String getEncodedString(String str)
Replace all "*" with RegexWildcardPattern.MULTIPLE_CHAR_PATTERN.

Parameters:
str - input string
Returns:
string where all the occurrences of * and ? are replaced with a regexp pattern.

match

public boolean match(String str)
Description copied from interface: UrlPattern
Does the patter match the given url?

Specified by:
match in interface UrlPattern
Parameters:
str - url to match
Returns:
true if the given URL matches the pattern
See Also:
UrlPattern.match(java.lang.String)

getLength

public int getLength()
Description copied from interface: UrlPattern
Returns the pattern length. Longer patterns have higher priority.

Specified by:
getLength in interface UrlPattern
Returns:
pattern length
See Also:
UrlPattern.getLength()

getPatternString

public String getPatternString()
Description copied from interface: UrlPattern
Returns the pattern string.

Specified by:
getPatternString in interface UrlPattern
Returns:
pattern string
See Also:
info.magnolia.cms.util.UrlPattern#getString()

setPatternString

public void setPatternString(String patternString)
Mainly used by ContentToBean.


toString

public String toString()
Overrides:
toString in class Object


Copyright © 2003-2014 Magnolia International Ltd.. All Rights Reserved.