org.apache.cocoon.environment
public final class: ObjectModelHelper [javadoc |
source]
java.lang.Object
org.apache.cocoon.environment.ObjectModelHelper
A set of constants and methods to access the content of the object model.
The object model is a Map used to pass information about the
calling environment to the sitemap and its components (matchers, actions,
transformers, etc).
This class provides accessors only for the objects in the object model that are
common to every environment and which can thus be used safely. Some environments
provide additional objects, but they are not described here and accessing them
should be done in due cause since this ties the application to that particular
environment.
- author:
< - a href="mailto:sylvain@apache.org">Sylvain Wallez
- version:
CVS - $Id: ObjectModelHelper.java 433543 2006-08-22 06:22:54Z crossley $
| Field Summary |
|---|
| public static final String | REQUEST_OBJECT | Key for the environment Request in the object model. |
| public static final String | RESPONSE_OBJECT | Key for the environment Response in the object model. |
| public static final String | CONTEXT_OBJECT | Key for the environment Context in the object model. |
| public static final String | EXPIRES_OBJECT | Key for the expiration value (Long) in the object model. |
| public static final String | THROWABLE_OBJECT | Key for the throwable object, only available within a <map:handle-errors>. |
| public static final String | PARENT_CONTEXT | Key for a Map containing information from
a parent request provided to a sub-request (internal processing) |
| Method from org.apache.cocoon.environment.ObjectModelHelper Detail: |
public static final Context getContext(Map objectModel) {
return (Context)objectModel.get(CONTEXT_OBJECT);
}
|
public static Cookie getCookie(Map objectModel,
String cookieName,
int cookieIndex) {
Deprecation.logger.error("ObjectModelHelper.getCookie() should not be used, and will be removed in the next release");
boolean retrieveByName = false;
boolean retrieveByIndex = false;
boolean matchFound = false;
int count = 0;
Request request = ObjectModelHelper.getRequest(objectModel);
Cookie currentCookie = null;
if (cookieName != null) {
retrieveByName = true;
} else if (cookieIndex >=0) {
retrieveByIndex = true;
}
Cookie[] cookies = request.getCookies();
if (cookies != null && retrieveByName) {
for(count = 0; count < cookies.length; count++) {
currentCookie = cookies[count];
if (currentCookie.getName().equals(cookieName)) {
matchFound = true;
break;
}
}
} else if(cookies != null && retrieveByIndex) {
if(cookies.length > cookieIndex) {
currentCookie = cookies[cookieIndex];
matchFound = true;
}
}
if (matchFound) {
return currentCookie;
}
return null;
} Deprecated! Don - 't use this method which should never have been there
|
public static final Long getExpires(Map objectModel) {
return (Long)objectModel.get(EXPIRES_OBJECT);
}
|
public static final Request getRequest(Map objectModel) {
return (Request)objectModel.get(REQUEST_OBJECT);
}
|
public static final Response getResponse(Map objectModel) {
return (Response)objectModel.get(RESPONSE_OBJECT);
}
|
public static final Throwable getThrowable(Map objectModel) {
return (Throwable)objectModel.get(THROWABLE_OBJECT);
}
|