org.displaytag.util
public class: ParamEncoder [javadoc |
source]
java.lang.Object
org.displaytag.util.ParamEncoder
All Implemented Interfaces:
Serializable
Simple utility class for encoding parameter names.
- author:
Fabrizio - Giustina
- version:
$ - Revision: 1081 $ ($Author: fgiust $)
| Constructor: |
public ParamEncoder(String idAttribute) {
// use name and id to get the unique identifier
String stringIdentifier = "x-" + idAttribute; //$NON-NLS-1$
// get the array
char[] charArray = stringIdentifier.toCharArray();
// calculate a simple checksum-like value
int checkSum = 17;
for (int j = 0; j < charArray.length; j++)
{
checkSum = 3 * checkSum + charArray[j];
}
// keep it positive
checkSum &= 0x7fffff;
// this is the full identifier used for all the parameters
this.parameterIdentifier = "d-" + checkSum + "-"; //$NON-NLS-1$ //$NON-NLS-2$
}
Generates a new parameter encoder for the table with the given id. Parameters:
idAttribute - value of "id" attribute
|
| Method from org.displaytag.util.ParamEncoder Detail: |
public String encodeParameterName(String paramName) {
return this.parameterIdentifier + paramName;
}
encode a parameter name prepending calculated parameterIdentifier. |
public boolean isParameterEncoded(String paramName) {
return paramName != null && paramName.startsWith(this.parameterIdentifier);
}
Check if the given parameter has been encoded using paramEncoder. It actually check if the parameter name starts
with the calculated parameterIdentifier. Null safe (a null string returns false). |