org.exoplatform.services.rest
Class URIPattern

java.lang.Object
  extended by org.exoplatform.services.rest.URIPattern

public class URIPattern
extends Object

An utility class for manipulating "parametrized" strings. A parametrized is a string constructed by substituting placeholders in the pattern string where pattern string is any string containing placeholders in the form of "{placeholderName}".

Author:
Alexander Tereshkin

Constructor Summary
URIPattern(String patternString)
          Creates a new instance of ParametrizedStringParser.
 
Method Summary
 Set<String> getParamNames()
          Returns a Set of names of parameters (placeholders) participating in the underlying pattern string.
 String getString()
          Returns the underlying pattern string.
 int getTotalTokensLength()
          Get total tokens length.
 boolean matches(String string)
          Checks if the given string matches the underlying pattern.
 boolean matches(URIPattern another)
          check is two URIPattern matches.
 Map<String,String> parse(String string)
          Parses the given string against the underlying pattern and returns a Map of parameter names to values.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

URIPattern

public URIPattern(String patternString)
Creates a new instance of ParametrizedStringParser.

Parameters:
patternString - pattern.
Method Detail

getParamNames

public Set<String> getParamNames()
Returns a Set of names of parameters (placeholders) participating in the underlying pattern string.

Returns:
Set of string parameters.

parse

public Map<String,String> parse(String string)
Parses the given string against the underlying pattern and returns a Map of parameter names to values.

Parameters:
string - string to parse.
Returns:
Map of parameter names to values.

matches

public boolean matches(String string)
Checks if the given string matches the underlying pattern.

Parameters:
string - string to test.
Returns:
true if the string matches the pattern false otherwise.

matches

public boolean matches(URIPattern another)
check is two URIPattern matches.

Parameters:
another - the another URIPattern.
Returns:
the result of comparison.

getString

public String getString()
Returns the underlying pattern string.

Returns:
the underlying pattern string.

getTotalTokensLength

public int getTotalTokensLength()
Get total tokens length.

Returns:
the total tokens length.


Copyright © 2009 eXo Platform SAS. All Rights Reserved.