Package org.apache.tiles.core.util
Class WildcardHelper
java.lang.Object
org.apache.tiles.core.util.WildcardHelper
This class is an utility class that perform wilcard-patterns matching and
 isolation taken from Apache Struts that is taken, in turn, from Apache
 Struts.
- Since:
- 2.1.0
- 
Field SummaryFieldsModifier and TypeFieldDescriptionprotected static final intThe int representing begin in the patternint [].protected static final intThe int value that terminates the patternint [].protected static final intThe int representing '*' in the patternint [].protected static final intThe int representing '**' in the patternint [].protected static final intThe int representing end in patternint [].
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionint[]compilePattern(String data) Translate the givenStringinto aint []representing the pattern matchable by this class.static StringconvertParam(String val, Map<Integer, String> vars) Inserts into a value wildcard-matched strings where specified.protected intindexOfArray(int[] r, int rpos, int rend, char[] d, int dpos) Get the offset of a part of an int array within a char array.protected intlastIndexOfArray(int[] r, int rpos, int rend, char[] d, int dpos) Get the offset of a last occurance of an int array within a char array.Match a pattern agains a string and isolates wildcard replacement into aStack.protected booleanmatchArray(int[] r, int rpos, int rend, char[] d, int dpos) Matches elements of array r from rpos to rend with array d, starting from dpos.
- 
Field Details- 
MATCH_FILEprotected static final int MATCH_FILEThe int representing '*' in the patternint [].- Since:
- 2.1.0
- See Also:
 
- 
MATCH_PATHprotected static final int MATCH_PATHThe int representing '**' in the patternint [].- Since:
- 2.1.0
- See Also:
 
- 
MATCH_BEGINprotected static final int MATCH_BEGINThe int representing begin in the patternint [].- Since:
- 2.1.0
- See Also:
 
- 
MATCH_THEENDprotected static final int MATCH_THEENDThe int representing end in patternint [].- Since:
- 2.1.0
- See Also:
 
- 
MATCH_ENDprotected static final int MATCH_ENDThe int value that terminates the patternint [].- Since:
- 2.1.0
- See Also:
 
 
- 
- 
Constructor Details- 
WildcardHelperpublic WildcardHelper()
 
- 
- 
Method Details- 
compilePatternTranslate the given Stringinto aint []representing the pattern matchable by this class.
 This function translates aStringinto an int array converting the special '*' and '\' characters.
 Here is how the conversion algorithm works:- The '*' character is converted to MATCH_FILE, meaning that zero or more characters (excluding the path separator '/') are to be matched.
- The '**' sequence is converted to MATCH_PATH, meaning that zero or more characters (including the path separator '/') are to be matched.
- The '\' character is used as an escape sequence ('\*' is translated in '*', not in MATCH_FILE). If an exact '\' character is to be matched the source string must contain a '\\'. sequence.
 When more than two '*' characters, not separated by another character, are found their value is considered as '**' (MATCH_PATH). 
 The array is always terminated by a special value (MATCH_END).
 All MATCH* values are less than zero, while normal characters are equal or greater.- Parameters:
- data- The string to translate.
- Returns:
- The encoded string as an int array, terminated by the MATCH_END value (don't consider the array length).
- Throws:
- NullPointerException- If data is null.
- Since:
- 2.1.0
 
- 
matchMatch a pattern agains a string and isolates wildcard replacement into aStack.- Parameters:
- data- The string to match
- expr- The compiled wildcard expression
- Returns:
- The list of matched variables, or nullif it does not match.
- Throws:
- NullPointerException- If any parameters are null
- Since:
- 2.2.0
 
- 
indexOfArrayprotected int indexOfArray(int[] r, int rpos, int rend, char[] d, int dpos) Get the offset of a part of an int array within a char array.
 This method return the index in d of the first occurrence after dpos of that part of array specified by r, starting at rpos and terminating at rend.- Parameters:
- r- The array containing the data that need to be matched in d.
- rpos- The index of the first character in r to look for.
- rend- The index of the last character in r to look for plus 1.
- d- The array of char that should contain a part of r.
- dpos- The starting offset in d for the matching.
- Returns:
- The offset in d of the part of r matched in d or -1 if that was not found.
- Since:
- 2.1.0
 
- 
lastIndexOfArrayprotected int lastIndexOfArray(int[] r, int rpos, int rend, char[] d, int dpos) Get the offset of a last occurance of an int array within a char array.
 This method return the index in d of the last occurrence after dpos of that part of array specified by r, starting at rpos and terminating at rend.- Parameters:
- r- The array containing the data that need to be matched in d.
- rpos- The index of the first character in r to look for.
- rend- The index of the last character in r to look for plus 1.
- d- The array of char that should contain a part of r.
- dpos- The starting offset in d for the matching.
- Returns:
- The offset in d of the last part of r matched in d or -1 if that was not found.
- Since:
- 2.1.0
 
- 
matchArrayprotected boolean matchArray(int[] r, int rpos, int rend, char[] d, int dpos) Matches elements of array r from rpos to rend with array d, starting from dpos.
 This method return true if elements of array r from rpos to rend equals elements of array d starting from dpos to dpos+(rend-rpos).- Parameters:
- r- The array containing the data that need to be matched in d.
- rpos- The index of the first character in r to look for.
- rend- The index of the last character in r to look for.
- d- The array of char that should start from a part of r.
- dpos- The starting offset in d for the matching.
- Returns:
- true if array d starts from portion of array r.
- Since:
- 2.1.0
 
- 
convertParamInserts into a value wildcard-matched strings where specified. - Parameters:
- val- The value to convert
- vars- A Map of wildcard-matched strings
- Returns:
- The new value
- Since:
- 2.1.0
 
 
-