1 package org.tigris.scarab.pipeline; 2 3 48 49 import java.io.IOException ; 50 51 import org.apache.turbine.RunData; 52 import org.apache.turbine.Turbine; 53 import org.apache.turbine.TurbineException; 54 import org.apache.turbine.ValveContext; 55 import org.apache.turbine.pipeline.AbstractValve; 56 import org.tigris.scarab.util.ComponentLocator; 57 58 64 public class DetermineCharsetValve 65 extends AbstractValve 66 { 67 68 private static String REQUIRED_CHARSET; 69 70 public void initialize() throws Exception { 71 super.initialize(); 72 REQUIRED_CHARSET = Turbine.getConfiguration(). 73 getString("locale.default.charset",null); 74 } 75 76 79 public void invoke(RunData data, ValveContext context) 80 throws IOException , TurbineException 81 { 82 String encoding = REQUIRED_CHARSET; 86 87 if (encoding == null) 88 { 89 encoding = ComponentLocator.getMimeTypeService().getCharSet(data.getLocale()); 91 } 92 93 if (encoding != null) 97 { 98 data.getRequest().setCharacterEncoding(encoding); 99 data.setCharSet(encoding); 100 } 101 102 context.invokeNext(data); 104 } 105 } 106 | Popular Tags |