com.nervousync.commons.beans.servlet.request.RequestAttribute Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of nervousync-utils Show documentation
Show all versions of nervousync-utils Show documentation
Java Utils collections, development by Nervousync Studio (NSYC)
/*
* Licensed to the Nervousync Studio (NSYC) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.nervousync.commons.beans.servlet.request;
import java.io.Serializable;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
/**
* Parse request attribute from HttpServletRequest
* @author Steven Wee [email protected]
* @version $Revision: 1.0 $ $Date: Jun 19, 2015 8:56:50 AM $
*/
public final class RequestAttribute implements Serializable {
/**
*
*/
private static final long serialVersionUID = 485757973915022360L;
/**
* Current session id
*/
private String sessionId;
/**
* Send attribute mapping for request
*/
private Map attributeMap;
private RequestAttribute(HttpServletRequest request) {
this.sessionId = request.getSession().getId();
this.attributeMap = new HashMap();
Enumeration e = request.getAttributeNames();
while (e.hasMoreElements()) {
String name = e.nextElement();
this.attributeMap.put(name, request.getAttribute(name));
}
}
/**
* Parse given request
* @param request HttpServletRequest will be parsed
* @return Object of RequestAttribute
*/
public static RequestAttribute newInstance(HttpServletRequest request) {
return new RequestAttribute(request);
}
/**
* @return the serialversionuid
*/
public static long getSerialversionuid() {
return serialVersionUID;
}
/**
* @return the sessionId
*/
public String getSessionId() {
return sessionId;
}
/**
* @return the attributeMap
*/
public Map getAttributeMap() {
return attributeMap;
}
}