Methods Summary |
---|
public java.lang.String | getName()get the associated name
return name;
|
public int | getScope()get the associated scope
return scope;
|
public java.lang.Object | getValue(javax.servlet.ServletContext context, javax.servlet.http.HttpServletRequest request)get the field value by looking up in the given scope
Object value = null;
switch (scope) {
case Constants.SCOPE_CONTEXT_ATTRIBUTE:
value = context.getAttribute(name);
break;
case Constants.SCOPE_REQUEST_HEADER:
value = request.getHeader(name);
break;
case Constants.SCOPE_REQUEST_PARAMETER:
value = request.getParameter(name);
break;
case Constants.SCOPE_REQUEST_COOKIE:
Cookie cookies[] = request.getCookies();
for (int i = 0; i < cookies.length; i++) {
if (name.equals(cookies[i].getName())) {
value = cookies[i].getValue();
break;
}
}
break;
case Constants.SCOPE_REQUEST_ATTRIBUTE:
value = request.getAttribute(name);
break;
case Constants.SCOPE_SESSION_ID:
{
HttpSession session = request.getSession(false);
if (session != null) {
value = session.getId();
}
}
break;
case Constants.SCOPE_SESSION_ATTRIBUTE:
{
HttpSession session = request.getSession(false);
if (session != null) {
value = session.getAttribute(name);
}
}
break;
}
return value;
|
private int | parseScope(java.lang.String value)set the associated scope
int scope;
if ("context.attribute".equals(value))
scope = Constants.SCOPE_CONTEXT_ATTRIBUTE;
else if ("request.header".equals(value))
scope = Constants.SCOPE_REQUEST_HEADER;
else if ("request.parameter".equals(value))
scope = Constants.SCOPE_REQUEST_PARAMETER;
else if ("request.cookie".equals(value))
scope = Constants.SCOPE_REQUEST_COOKIE;
else if ("request.attribute".equals(value))
scope = Constants.SCOPE_REQUEST_ATTRIBUTE;
else if ("session.attribute".equals(value))
scope = Constants.SCOPE_SESSION_ATTRIBUTE;
else if ("session.id".equals(value))
scope = Constants.SCOPE_SESSION_ID;
else {
String msg = _rb.getString("cache.mapping.incorrectScope");
Object[] params = { value, name };
msg = MessageFormat.format(msg, params);
throw new IllegalArgumentException(msg);
}
return scope;
|
public void | setName(java.lang.String name)set the associated name
this.name = name;
|
public void | setScope(int scope)set the associated scope
this.scope = scope;
|