001    /**
002     * Copyright (c) 2000-2011 Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.util.servlet.filters;
016    
017    import com.liferay.portal.kernel.servlet.ByteBufferServletResponse;
018    import com.liferay.portal.kernel.servlet.Header;
019    
020    import java.io.Serializable;
021    
022    import java.nio.ByteBuffer;
023    
024    import java.util.HashMap;
025    import java.util.List;
026    import java.util.Map;
027    
028    /**
029     * @author Michael Young
030     * @author Shuyang Zhou
031     */
032    public class CacheResponseData implements Serializable {
033    
034            public CacheResponseData(ByteBufferServletResponse byteBufferResponse) {
035                    _byteBuffer = byteBufferResponse.getByteBuffer();
036                    _contentType = byteBufferResponse.getContentType();
037                    _headers = byteBufferResponse.getHeaders();
038            }
039    
040            public Object getAttribute(String name) {
041                    return _attributes.get(name);
042            }
043    
044            public ByteBuffer getByteBuffer() {
045                    return _byteBuffer;
046            }
047    
048            public String getContentType() {
049                    return _contentType;
050            }
051    
052            public Map<String, List<Header>> getHeaders() {
053                    return _headers;
054            }
055    
056            public void setAttribute(String name, Object value) {
057                    _attributes.put(name, value);
058            }
059    
060            private Map<String, Object> _attributes = new HashMap<String, Object>();
061            private ByteBuffer _byteBuffer;
062            private String _contentType;
063            private Map<String, List<Header>> _headers;
064    
065    }