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 66 public class DetermineCharsetValve22 67 extends AbstractValve 68 { 69 70 private static String REQUIRED_CHARSET; 71 72 public void initialize() throws Exception { 73 super.initialize(); 74 REQUIRED_CHARSET = Turbine.getConfiguration(). 75 getString("locale.default.charset",null); 76 } 77 78 81 public void invoke(RunData data, ValveContext context) 82 throws IOException , TurbineException 83 { 84 String encoding = REQUIRED_CHARSET; 88 89 if (encoding == null) 90 { 91 encoding = ComponentLocator.getMimeTypeService().getCharSet(data.getLocale()); 93 } 94 95 if (encoding != null) 99 { 100 data.setCharSet(encoding); 102 } 103 104 context.invokeNext(data); 106 } 107 } 108 | Popular Tags |