| java.lang.Object org.apache.struts.util.WildcardHelper
WildcardHelper | public class WildcardHelper (Code) | | This class is an utility class that perform wilcard-patterns matching and
isolation taken from Apache Cocoon.
version: $Rev: 471754 $ $Date: 2005-05-07 12:11:38 -0400 (Sat, 07 May 2005) version: $ since: Struts 1.2 |
Field Summary | |
final protected static int | MATCH_BEGIN The int representing begin in the pattern int [] . | final protected static int | MATCH_END The int value that terminates the pattern int [] . | final protected static int | MATCH_FILE The int representing '*' in the pattern int [] . | final protected static int | MATCH_PATH The int representing '**' in the pattern int [] . | final protected static int | MATCH_THEEND The int representing end in pattern int [] . |
Method Summary | |
public int[] | compilePattern(String data) Translate the given String into a int []
representing the pattern matchable by this class. | protected 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. | protected 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 ind. Parameters: rpos - The index of the first character in r to look for. Parameters: rend - The index of the last character in r to look for plus 1. Parameters: d - The array of char that should contain a part of r. Parameters: dpos - The starting offset in d for the matching. | public boolean | match(Map map, String data, int[] expr) Match a pattern agains a string and isolates wildcard replacement into
a Stack . | protected 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. |
MATCH_BEGIN | final protected static int MATCH_BEGIN(Code) | | The int representing begin in the pattern int [] .
|
MATCH_END | final protected static int MATCH_END(Code) | | The int value that terminates the pattern int [] .
|
MATCH_FILE | final protected static int MATCH_FILE(Code) | | The int representing '*' in the pattern int [] .
|
MATCH_PATH | final protected static int MATCH_PATH(Code) | | The int representing '**' in the pattern int [] .
|
MATCH_THEEND | final protected static int MATCH_THEEND(Code) | | The int representing end in pattern int [] .
|
compilePattern | public int[] compilePattern(String data)(Code) | | Translate the given String into a int []
representing the pattern matchable by this class. This function
translates a String into 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. The encoded string as an int array, terminated by the MATCH_ENDvalue (don't consider the array length). throws: NullPointerException - If data is null. |
indexOfArray | protected int indexOfArray(int[] r, int rpos, int rend, char[] d, int dpos)(Code) | | 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 ind. Parameters: rpos - The index of the first character in r to look for. Parameters: rend - The index of the last character in r to look for plus 1. Parameters: d - The array of char that should contain a part of r. Parameters: dpos - The starting offset in d for the matching. The offset in d of the part of r matched in d or -1 if that wasnot found. |
lastIndexOfArray | protected int lastIndexOfArray(int[] r, int rpos, int rend, char[] d, int dpos)(Code) | | 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 ind. Parameters: rpos - The index of the first character in r to look for. Parameters: rend - The index of the last character in r to look for plus 1. Parameters: d - The array of char that should contain a part of r. Parameters: dpos - The starting offset in d for the matching. The offset in d of the last part of r matched in d or -1 ifthat was not found. |
match | public boolean match(Map map, String data, int[] expr)(Code) | | Match a pattern agains a string and isolates wildcard replacement into
a Stack .
Parameters: map - The map to store matched values Parameters: data - The string to match Parameters: expr - The compiled wildcard expression True if a match throws: NullPointerException - If any parameters are null |
matchArray | protected boolean matchArray(int[] r, int rpos, int rend, char[] d, int dpos)(Code) | | 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 ind. Parameters: rpos - The index of the first character in r to look for. Parameters: rend - The index of the last character in r to look for. Parameters: d - The array of char that should start from a part of r. Parameters: dpos - The starting offset in d for the matching. true if array d starts from portion of array r. |
|
|