View Javadoc
1   /*
2    * Copyright 2012 The Netty Project
3    *
4    * The Netty Project licenses this file to you under the Apache License,
5    * version 2.0 (the "License"); you may not use this file except in compliance
6    * with the License. You may obtain a copy of the License at:
7    *
8    *   http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12   * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13   * License for the specific language governing permissions and limitations
14   * under the License.
15   */
16  package org.jboss.netty.handler.codec.http;
17  
18  import java.util.Collections;
19  import java.util.Set;
20  import java.util.TreeSet;
21  
22  /**
23   * The default {@link Cookie} implementation.
24   *
25   * @deprecated Use {@link io.netty.handler.codec.http.cookie.DefaultCookie} instead.
26   */
27  @Deprecated
28  public class DefaultCookie extends org.jboss.netty.handler.codec.http.cookie.DefaultCookie implements Cookie {
29  
30      private String comment;
31      private String commentUrl;
32      private boolean discard;
33      private Set<Integer> ports = Collections.emptySet();
34      private Set<Integer> unmodifiablePorts = ports;
35      private int version;
36  
37      /**
38       * Creates a new cookie with the specified name and value.
39       */
40      public DefaultCookie(String name, String value) {
41          super(name, value);
42      }
43  
44      @Deprecated
45      public String getName() {
46          return name();
47      }
48  
49      @Deprecated
50      public String getValue() {
51          return value();
52      }
53  
54      @Deprecated
55      public String getDomain() {
56          return domain();
57      }
58  
59      @Deprecated
60      public String getPath() {
61          return path();
62      }
63  
64      @Deprecated
65      public String getComment() {
66          return comment();
67      }
68  
69      @Deprecated
70      public String comment() {
71          return comment;
72      }
73  
74      @Deprecated
75      public void setComment(String comment) {
76          this.comment = validateValue("comment", comment);
77      }
78  
79      @Deprecated
80      public String getCommentUrl() {
81          return commentUrl();
82      }
83  
84      @Deprecated
85      public String commentUrl() {
86          return commentUrl;
87      }
88  
89      @Deprecated
90      public void setCommentUrl(String commentUrl) {
91          this.commentUrl = validateValue("commentUrl", commentUrl);
92      }
93  
94      @Deprecated
95      public boolean isDiscard() {
96          return discard;
97      }
98  
99      @Deprecated
100     public void setDiscard(boolean discard) {
101         this.discard = discard;
102     }
103 
104     @Deprecated
105     public Set<Integer> getPorts() {
106         return ports();
107     }
108 
109     @Deprecated
110     public Set<Integer> ports() {
111         if (unmodifiablePorts == null) {
112             unmodifiablePorts = Collections.unmodifiableSet(ports);
113         }
114         return unmodifiablePorts;
115     }
116 
117     @Deprecated
118     public void setPorts(int... ports) {
119         if (ports == null) {
120             throw new NullPointerException("ports");
121         }
122 
123         int[] portsCopy = ports.clone();
124         if (portsCopy.length == 0) {
125             unmodifiablePorts = this.ports = Collections.emptySet();
126         } else {
127             Set<Integer> newPorts = new TreeSet<Integer>();
128             for (int p: portsCopy) {
129                 if (p <= 0 || p > 65535) {
130                     throw new IllegalArgumentException("port out of range: " + p);
131                 }
132                 newPorts.add(Integer.valueOf(p));
133             }
134             this.ports = newPorts;
135             unmodifiablePorts = null;
136         }
137     }
138 
139     @Deprecated
140     public void setPorts(Iterable<Integer> ports) {
141         Set<Integer> newPorts = new TreeSet<Integer>();
142         for (int p: ports) {
143             if (p <= 0 || p > 65535) {
144                 throw new IllegalArgumentException("port out of range: " + p);
145             }
146             newPorts.add(Integer.valueOf(p));
147         }
148         if (newPorts.isEmpty()) {
149             unmodifiablePorts = this.ports = Collections.emptySet();
150         } else {
151             this.ports = newPorts;
152             unmodifiablePorts = null;
153         }
154     }
155 
156     @Deprecated
157     public int getMaxAge() {
158         return maxAge();
159     }
160 
161     @Deprecated
162     public int getVersion() {
163         return version();
164     }
165 
166     @Deprecated
167     public int version() {
168         return version;
169     }
170 
171     @Deprecated
172     public void setVersion(int version) {
173         this.version = version;
174     }
175 }