Return-Path: Delivered-To: apmail-cxf-commits-archive@www.apache.org Received: (qmail 50938 invoked from network); 23 Feb 2010 13:52:28 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 23 Feb 2010 13:52:28 -0000 Received: (qmail 59220 invoked by uid 500); 23 Feb 2010 13:52:27 -0000 Delivered-To: apmail-cxf-commits-archive@cxf.apache.org Received: (qmail 59136 invoked by uid 500); 23 Feb 2010 13:52:27 -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 59126 invoked by uid 99); 23 Feb 2010 13:52:26 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 23 Feb 2010 13:52:26 +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; Tue, 23 Feb 2010 13:52:23 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 38A8B23889DE; Tue, 23 Feb 2010 13:52:02 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r915344 - in /cxf/sandbox/geronimo-jaxrs_1.0_spec/src/main/java/javax/ws/rs: core/Cookie.java core/NewCookie.java ext/RuntimeDelegate.java Date: Tue, 23 Feb 2010 13:52:02 -0000 To: commits@cxf.apache.org From: bluk@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20100223135202.38A8B23889DE@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: bluk Date: Tue Feb 23 13:52:01 2010 New Revision: 915344 URL: http://svn.apache.org/viewvc?rev=915344&view=rev Log: Add JAX-RS Cookie and NewCookie Added: cxf/sandbox/geronimo-jaxrs_1.0_spec/src/main/java/javax/ws/rs/core/Cookie.java (with props) cxf/sandbox/geronimo-jaxrs_1.0_spec/src/main/java/javax/ws/rs/core/NewCookie.java (with props) Modified: cxf/sandbox/geronimo-jaxrs_1.0_spec/src/main/java/javax/ws/rs/ext/RuntimeDelegate.java Added: cxf/sandbox/geronimo-jaxrs_1.0_spec/src/main/java/javax/ws/rs/core/Cookie.java URL: http://svn.apache.org/viewvc/cxf/sandbox/geronimo-jaxrs_1.0_spec/src/main/java/javax/ws/rs/core/Cookie.java?rev=915344&view=auto ============================================================================== --- cxf/sandbox/geronimo-jaxrs_1.0_spec/src/main/java/javax/ws/rs/core/Cookie.java (added) +++ cxf/sandbox/geronimo-jaxrs_1.0_spec/src/main/java/javax/ws/rs/core/Cookie.java Tue Feb 23 13:52:01 2010 @@ -0,0 +1,155 @@ +/* + * Licensed to the Apache Software Foundation (ASF) 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 javax.ws.rs.core; + +import javax.ws.rs.ext.RuntimeDelegate; +import javax.ws.rs.ext.RuntimeDelegate.HeaderDelegate; + +public class Cookie { + + public static final int DEFAULT_VERSION = 1; + + private final String name; + private final String value; + private final String path; + private final String domain; + private final int version; + + public Cookie(String name, String value) { + this(name, value, null, null); + } + + public Cookie(String name, String value, String path, String domain) { + this(name, value, path, domain, DEFAULT_VERSION); + } + + public Cookie(String name, String value, String path, String domain, int version) { + if (name == null) { + throw new IllegalArgumentException(); + } + this.name = name; + this.value = value; + this.path = path; + this.domain = domain; + this.version = version; + } + + @Override + public boolean equals(java.lang.Object obj) { + if (this == obj) { + return true; + } + + if (obj == null) { + return false; + } + + // note that this must be a Cookie exactly + if (getClass() != obj.getClass()) { + return false; + } + + Cookie other = (Cookie)obj; + if (!name.equals(other.name)) { + return false; + } + + if (version != other.version) { + return false; + } + + if (value == null) { + if (other.value != null) { + return false; + } + } else { + if (!value.equals(other.value)) { + return false; + } + } + + if (path == null) { + if (other.path != null) { + return false; + } + } else { + if (!path.equals(other.path)) { + return false; + } + } + + if (domain == null) { + if (other.domain != null) { + return false; + } + } else { + if (!domain.equals(other.domain)) { + return false; + } + } + + return true; + } + + @Override + public int hashCode() { + int result = 17; + result = 31 * result + name.hashCode(); + result = 31 * result + ((value == null) ? 0 : value.hashCode()); + result = 31 * result + ((path == null) ? 0 : path.hashCode()); + result = 31 * result + ((domain == null) ? 0 : domain.hashCode()); + result = 31 * result + version; + return result; + } + + public String getDomain() { + return domain; + } + + public String getName() { + return name; + } + + public String getPath() { + return path; + } + + public String getValue() { + return value; + } + + public int getVersion() { + return version; + } + + private static final HeaderDelegate headerDelegate = + RuntimeDelegate + .getInstance() + .createHeaderDelegate(Cookie.class); + + @Override + public String toString() { + return headerDelegate.toString(this); + } + + public static Cookie valueOf(String value) { + return headerDelegate.fromString(value); + } +} Propchange: cxf/sandbox/geronimo-jaxrs_1.0_spec/src/main/java/javax/ws/rs/core/Cookie.java ------------------------------------------------------------------------------ svn:eol-style = native Added: cxf/sandbox/geronimo-jaxrs_1.0_spec/src/main/java/javax/ws/rs/core/NewCookie.java URL: http://svn.apache.org/viewvc/cxf/sandbox/geronimo-jaxrs_1.0_spec/src/main/java/javax/ws/rs/core/NewCookie.java?rev=915344&view=auto ============================================================================== --- cxf/sandbox/geronimo-jaxrs_1.0_spec/src/main/java/javax/ws/rs/core/NewCookie.java (added) +++ cxf/sandbox/geronimo-jaxrs_1.0_spec/src/main/java/javax/ws/rs/core/NewCookie.java Tue Feb 23 13:52:01 2010 @@ -0,0 +1,188 @@ +/* + * Licensed to the Apache Software Foundation (ASF) 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 javax.ws.rs.core; + +import javax.ws.rs.ext.RuntimeDelegate; +import javax.ws.rs.ext.RuntimeDelegate.HeaderDelegate; + +public class NewCookie extends Cookie { + public static final int DEFAULT_MAX_AGE = -1; + + private final String comment; + private final int maxAge; + private final boolean isSecure; + + public NewCookie(String name, String value) { + this(name, value, null, null, null, DEFAULT_MAX_AGE, false); + } + + public NewCookie(String name, + String value, + String path, + String domain, + String comment, + int maxAge, + boolean isSecure) { + this(name, value, path, domain, DEFAULT_VERSION, comment, maxAge, isSecure); + } + + public NewCookie(String name, + String value, + String path, + String domain, + int version, + String comment, + int maxAge, + boolean isSecure) { + super(name, value, path, domain, version); + this.comment = comment; + this.maxAge = maxAge; + this.isSecure = isSecure; + } + + public NewCookie(Cookie cookie) { + this(cookie, null, DEFAULT_MAX_AGE, false); + } + + public NewCookie(Cookie cookie, String comment, int maxAge, boolean isSecure) { + super(cookie.getName(), cookie.getValue(), cookie.getPath(), cookie.getDomain(), cookie + .getVersion()); + this.comment = comment; + this.maxAge = maxAge; + this.isSecure = isSecure; + } + + @Override + public boolean equals(java.lang.Object obj) { + if (this == obj) { + return true; + } + + if (obj == null) { + return false; + } + + // note that this must be a NewCookie exactly + if (getClass() != obj.getClass()) { + return false; + } + + NewCookie other = (NewCookie)obj; + if (!getName().equals(other.getName())) { + return false; + } + + if (getVersion() != other.getVersion()) { + return false; + } + + if (isSecure != other.isSecure) { + return false; + } + + if (maxAge != other.maxAge) { + return false; + } + + String value = getValue(); + if (value == null) { + if (other.getValue() != null) { + return false; + } + } else { + if (!value.equals(other.getValue())) { + return false; + } + } + + String path = getPath(); + if (path == null) { + if (other.getPath() != null) { + return false; + } + } else { + if (!path.equals(other.getPath())) { + return false; + } + } + + String domain = getDomain(); + if (domain == null) { + if (other.getDomain() != null) { + return false; + } + } else { + if (!domain.equals(other.getDomain())) { + return false; + } + } + + if (comment == null) { + if (other.comment != null) { + return false; + } + } else { + if (!comment.equals(other.comment)) { + return false; + } + } + + return true; + } + + @Override + public int hashCode() { + int result = super.hashCode(); + result = 31 * result + ((comment == null) ? 0 : comment.hashCode()); + result = 31 * result + maxAge; + result = 31 * result + ((isSecure) ? 1 : 0); + return result; + } + + public String getComment() { + return comment; + } + + public int getMaxAge() { + return maxAge; + } + + public boolean isSecure() { + return isSecure; + } + + public Cookie toCookie() { + return new Cookie(getName(), getValue(), getPath(), getDomain(), getVersion()); + } + + private static final HeaderDelegate headerDelegate = + RuntimeDelegate + .getInstance() + .createHeaderDelegate(NewCookie.class); + + @Override + public String toString() { + return headerDelegate.toString(this); + } + + public static NewCookie valueOf(String value) { + return headerDelegate.fromString(value); + } +} Propchange: cxf/sandbox/geronimo-jaxrs_1.0_spec/src/main/java/javax/ws/rs/core/NewCookie.java ------------------------------------------------------------------------------ svn:eol-style = native Modified: cxf/sandbox/geronimo-jaxrs_1.0_spec/src/main/java/javax/ws/rs/ext/RuntimeDelegate.java URL: http://svn.apache.org/viewvc/cxf/sandbox/geronimo-jaxrs_1.0_spec/src/main/java/javax/ws/rs/ext/RuntimeDelegate.java?rev=915344&r1=915343&r2=915344&view=diff ============================================================================== --- cxf/sandbox/geronimo-jaxrs_1.0_spec/src/main/java/javax/ws/rs/ext/RuntimeDelegate.java (original) +++ cxf/sandbox/geronimo-jaxrs_1.0_spec/src/main/java/javax/ws/rs/ext/RuntimeDelegate.java Tue Feb 23 13:52:01 2010 @@ -24,12 +24,20 @@ public abstract class RuntimeDelegate { - public abstract UriBuilder createUriBuilder(); + public static interface HeaderDelegate { + public T fromString(String str); + + public String toString(T obj); + } public static RuntimeDelegate getInstance() { return null; } + public abstract UriBuilder createUriBuilder(); + public abstract Variant.VariantListBuilder createVariantListBuilder(); + public abstract RuntimeDelegate.HeaderDelegate createHeaderDelegate(Class headerType); + }