1 12 package org.displaytag.util; 13 14 import java.io.Serializable ; 15 16 17 22 public class ParamEncoder implements Serializable 23 { 24 25 28 private static final long serialVersionUID = 899149338534L; 29 30 33 private String parameterIdentifier; 34 35 39 public ParamEncoder(String idAttribute) 40 { 41 String stringIdentifier = "x-" + idAttribute; 44 char[] charArray = stringIdentifier.toCharArray(); 46 47 int checkSum = 17; 49 50 for (int j = 0; j < charArray.length; j++) 51 { 52 checkSum = 3 * checkSum + charArray[j]; 53 } 54 55 checkSum &= 0x7fffff; 57 58 this.parameterIdentifier = "d-" + checkSum + "-"; } 61 62 67 public String encodeParameterName(String paramName) 68 { 69 return this.parameterIdentifier + paramName; 70 } 71 72 78 public boolean isParameterEncoded(String paramName) 79 { 80 return paramName != null && paramName.startsWith(this.parameterIdentifier); 81 } 82 83 } | Popular Tags |