Return-Path: Delivered-To: apmail-cxf-commits-archive@www.apache.org Received: (qmail 40946 invoked from network); 5 Mar 2010 06:29:17 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 5 Mar 2010 06:29:17 -0000 Received: (qmail 46815 invoked by uid 500); 5 Mar 2010 06:29:04 -0000 Delivered-To: apmail-cxf-commits-archive@cxf.apache.org Received: (qmail 46710 invoked by uid 500); 5 Mar 2010 06:29:02 -0000 Mailing-List: contact commits-help@cxf.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cxf.apache.org Delivered-To: mailing list commits@cxf.apache.org Received: (qmail 46698 invoked by uid 99); 5 Mar 2010 06:29:01 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 05 Mar 2010 06:29:01 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 05 Mar 2010 06:28:59 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 4CE28238897F; Fri, 5 Mar 2010 06:28:36 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r919310 - /cxf/sandbox/geronimo-jaxrs_1.0_spec/src/main/java/javax/ws/rs/core/CacheControl.java Date: Fri, 05 Mar 2010 06:28:36 -0000 To: commits@cxf.apache.org From: bluk@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20100305062836.4CE28238897F@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: bluk Date: Fri Mar 5 06:28:35 2010 New Revision: 919310 URL: http://svn.apache.org/viewvc?rev=919310&view=rev Log: Add JAX-RS CacheControl implementation Modified: cxf/sandbox/geronimo-jaxrs_1.0_spec/src/main/java/javax/ws/rs/core/CacheControl.java Modified: cxf/sandbox/geronimo-jaxrs_1.0_spec/src/main/java/javax/ws/rs/core/CacheControl.java URL: http://svn.apache.org/viewvc/cxf/sandbox/geronimo-jaxrs_1.0_spec/src/main/java/javax/ws/rs/core/CacheControl.java?rev=919310&r1=919309&r2=919310&view=diff ============================================================================== --- cxf/sandbox/geronimo-jaxrs_1.0_spec/src/main/java/javax/ws/rs/core/CacheControl.java (original) +++ cxf/sandbox/geronimo-jaxrs_1.0_spec/src/main/java/javax/ws/rs/core/CacheControl.java Fri Mar 5 06:28:35 2010 @@ -19,6 +19,208 @@ package javax.ws.rs.core; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import javax.ws.rs.ext.RuntimeDelegate; +import javax.ws.rs.ext.RuntimeDelegate.HeaderDelegate; + public class CacheControl { + private int maxAge = -1; + private int sMaxAge = -1; + private boolean isPrivate = false; + private boolean noCache = false; + private boolean noStore = false; + private boolean noTransform = true; + private boolean mustRevalidate = false; + private boolean proxyRevalidate = false; + private Map cacheExtensions = null; + private List noCacheFields = null; + private List privateFields = null; + + public CacheControl() { + /* do nothing */ + } + + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + + /* + * TODO: should the check be for instanceof or for getClass()? this + * class is not final so checking instanceof for now. + */ + if (!(obj instanceof CacheControl)) { + return false; + } + + CacheControl other = (CacheControl)obj; + + if (isPrivate != other.isPrivate()) { + return false; + } + + if (noCache != other.isNoCache()) { + return false; + } + + if (noStore != other.isNoStore()) { + return false; + } + + if (noTransform != other.isNoTransform()) { + return false; + } + + if (mustRevalidate != other.isMustRevalidate()) { + return false; + } + + if (proxyRevalidate != other.isProxyRevalidate()) { + return false; + } + + if (maxAge != other.getMaxAge()) { + return false; + } + + if (sMaxAge != other.getSMaxAge()) { + return false; + } + + if (!getCacheExtension().equals(other.getCacheExtension())) { + return false; + } + + if (!getPrivateFields().equals(other.getPrivateFields())) { + return false; + } + + if (!getNoCacheFields().equals(other.getNoCacheFields())) { + return false; + } + + return true; + } + + @Override + public int hashCode() { + int result = 17; + result = 31 * result + maxAge; + result = 31 * result + sMaxAge; + result = 31 * result + ((isPrivate) ? 1 : 0); + result = 31 * result + ((noCache) ? 1 : 0); + result = 31 * result + ((noStore) ? 1 : 0); + result = 31 * result + ((noTransform) ? 1 : 0); + result = 31 * result + ((mustRevalidate) ? 1 : 0); + result = 31 * result + ((proxyRevalidate) ? 1 : 0); + result = 31 * result + getCacheExtension().hashCode(); + result = 31 * result + getNoCacheFields().hashCode(); + result = 31 * result + getPrivateFields().hashCode(); + return result; + } + + public Map getCacheExtension() { + if (cacheExtensions == null) { + cacheExtensions = new HashMap(); + } + return cacheExtensions; + } + + public int getMaxAge() { + return maxAge; + } + + public List getNoCacheFields() { + if (noCacheFields == null) { + noCacheFields = new ArrayList(); + } + return noCacheFields; + } + + public List getPrivateFields() { + if (privateFields == null) { + privateFields = new ArrayList(); + } + return privateFields; + } + + public int getSMaxAge() { + return sMaxAge; + } + + public boolean isMustRevalidate() { + return mustRevalidate; + } + + public boolean isNoCache() { + return noCache; + } + + public boolean isNoStore() { + return noStore; + } + + public boolean isNoTransform() { + return noTransform; + } + + public boolean isPrivate() { + return isPrivate; + } + + public boolean isProxyRevalidate() { + return proxyRevalidate; + } + + public void setMaxAge(int maxAge) { + this.maxAge = maxAge; + } + + public void setMustRevalidate(boolean mustRevalidate) { + this.mustRevalidate = mustRevalidate; + } + + public void setNoCache(boolean noCache) { + this.noCache = noCache; + } + + public void setNoStore(boolean noStore) { + this.noStore = noStore; + } + + public void setNoTransform(boolean noTransform) { + this.noTransform = noTransform; + } + + public void setPrivate(boolean isPrivate) { + this.isPrivate = isPrivate; + } + + public void setProxyRevalidate(boolean proxyRevalidate) { + this.proxyRevalidate = proxyRevalidate; + } + + public void setSMaxAge(int sMaxAge) { + this.sMaxAge = sMaxAge; + } + + private final static HeaderDelegate headerDelegate = + RuntimeDelegate + .getInstance() + .createHeaderDelegate(CacheControl.class); + + @Override + public String toString() { + return headerDelegate.toString(this); + } + + public static CacheControl valueOf(String value) { + return headerDelegate.fromString(value); + } }