1 20 package org.enhydra.barracuda.core.view; 21 22 import java.util.*; 23 import javax.servlet.*; 24 import javax.servlet.http.*; 25 26 import org.enhydra.barracuda.plankton.l10n.*; 27 28 56 public class ViewCapabilities { 57 58 protected HttpServletRequest req = null; 59 protected HttpServletResponse resp = null; 60 61 protected FormatType formatType = null; 62 protected ScriptingType scriptingType = null; 63 protected ClientType clientType = null; 64 protected Locale clientLocale = null; 65 66 71 public ViewCapabilities() { 72 this(null, null, null, null); 73 } 74 75 82 public ViewCapabilities(HttpServletRequest req, HttpServletResponse resp) { 83 setSource(req, resp); 84 } 85 86 95 public ViewCapabilities(FormatType formatType, ClientType clientType, ScriptingType scriptingType, Locale clientLocale) { 96 setFormatType(formatType); 97 setClientType(clientType); 98 setScriptingType(scriptingType); 99 setClientLocale(clientLocale); 100 } 101 102 109 public void setSource(HttpServletRequest ireq, HttpServletResponse iresp) { 110 req = ireq; 111 resp = iresp; 112 } 113 114 119 public void setFormatType(FormatType iformatType) { 120 formatType = iformatType; 121 } 122 123 128 public FormatType getFormatType() { 129 if (formatType==null) { 130 formatType = ViewUtil.getFormatType(req); 131 } 132 return formatType; 133 } 134 135 140 public void setClientType(ClientType iclientType) { 141 clientType = iclientType; 142 } 143 144 149 public ClientType getClientType() { 150 if (clientType==null) { 151 clientType = ViewUtil.getClientType(req); 152 } 153 return clientType; 154 } 155 156 161 public void setScriptingType(ScriptingType iscriptingType) { 162 scriptingType = iscriptingType; 163 } 164 165 170 public ScriptingType getScriptingType() { 171 if (scriptingType==null) { 172 scriptingType = ViewUtil.getScriptingType(req); 173 } 174 return scriptingType; 175 } 176 177 182 public void setClientLocale(Locale iclientLocale) { 183 clientLocale = iclientLocale; 184 } 185 186 191 public Locale getClientLocale() { 192 if (clientLocale==null) { 193 clientLocale = Locales.getClientLocale(req, resp); 194 } 195 return clientLocale; 196 } 197 198 203 public String toString() { 204 return super.toString()+" {"+ 205 "ft="+getFormatType()+", "+ 206 "ct="+getClientType()+", "+ 207 "st="+getScriptingType()+", "+ 208 "loc="+(clientLocale==null ? "default" : getClientLocale().toString())+"}"; 209 } 210 } | Popular Tags |