1 package org.apache.webapp.balancer.rules; 2 3 import javax.servlet.http.HttpServletRequest ; 4 5 6 12 public class CharacterEncodingRule extends BaseRule { 13 16 private String encoding; 17 18 23 public void setEncoding(String theEncoding) { 24 if (theEncoding == null) { 25 throw new IllegalArgumentException ("The encoding cannot be null."); 26 } else { 27 encoding = theEncoding; 28 } 29 } 30 31 36 protected String getEncoding() { 37 return encoding; 38 } 39 40 43 public boolean matches(HttpServletRequest request) { 44 String actualEncoding = request.getCharacterEncoding(); 45 46 return (getEncoding().compareTo(actualEncoding) == 0); 47 } 48 49 54 public String toString() { 55 StringBuffer buffer = new StringBuffer (); 56 57 buffer.append("["); 58 buffer.append(getClass().getName()); 59 buffer.append(": "); 60 61 buffer.append("Target encoding: "); 62 buffer.append(getEncoding()); 63 buffer.append(" / "); 64 65 buffer.append("Redirect URL: "); 66 buffer.append(getRedirectUrl()); 67 68 buffer.append("]"); 69 70 return buffer.toString(); 71 } 72 } 73 74 75 | Popular Tags |