KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > web > monitor > data > CookieOut


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20 package org.netbeans.modules.web.monitor.data;
21
22 import org.w3c.dom.*;
23 import org.netbeans.modules.schema2beans.*;
24 import java.beans.*;
25 import java.util.*;
26 import javax.servlet.http.Cookie JavaDoc;
27
28 public class CookieOut extends BaseBean
29 {
30
31     static Vector comparators = new Vector();
32
33     public CookieOut()
34     {
35     this(Common.USE_DEFAULT_VALUES);
36     }
37
38     public CookieOut(Cookie JavaDoc cookie) {
39     super(CookieOut.comparators, new
40     org.netbeans.modules.schema2beans.Version(1, 0, 5));
41
42     // Note - the XML beans library does not treat NMTOKENS as
43
// special - they have to be set as strings!
44
setAttributeValue("name", cookie.getName()); //NOI18N
45
setAttributeValue("value", cookie.getValue()); //NOI18N
46
setAttributeValue("maxAge", //NOI18N
47
String.valueOf(cookie.getMaxAge()));
48     setAttributeValue("version", //NOI18N
49
String.valueOf(cookie.getVersion()));
50
51     String JavaDoc domain = ""; //NOI18N
52
try {
53         domain = cookie.getDomain();
54     }
55     catch(NullPointerException JavaDoc ne) {}
56     if(domain != null) {
57         if(domain.trim().equals("")) //NOI18N
58
setAttributeValue("domain", ""); //NOI18N
59
else
60         setAttributeValue("domain", domain); //NOI18N
61
}
62
63     String JavaDoc path = ""; //NOI18N
64
try {
65         path = cookie.getPath();
66     }
67     catch(NullPointerException JavaDoc ne) {}
68     if(path != null) {
69         if(path.trim().equals("")) //NOI18N
70
setAttributeValue("path", ""); //NOI18N
71
else
72         setAttributeValue("path", path); //NOI18N
73
}
74
75     String JavaDoc comment = ""; //NOI18N
76
try {
77         comment = cookie.getComment();
78     }
79     catch(NullPointerException JavaDoc ne) {}
80     if(comment != null) {
81         if(comment.trim().equals("")) //NOI18N
82
setAttributeValue("comment", ""); //NOI18N
83
else
84         setAttributeValue("comment", comment); //NOI18N
85
}
86     
87     int version = cookie.getVersion();
88     // XML Beans...
89
if(version != 0) setAttributeValue("version", //NOI18N
90
String.valueOf(version));
91       
92     try {
93         if(cookie.getSecure())
94         // XMLBeans library...
95
setAttributeValue("secure", //NOI18N
96
String.valueOf(cookie.getSecure()));
97         
98     }
99     catch(Exception JavaDoc exc) {}
100     }
101
102
103     public CookieOut(int options)
104     {
105     super(CookieOut.comparators, new org.netbeans.modules.schema2beans.Version(1, 0, 5));
106     // Properties (see root bean comments for the bean graph)
107
this.initialize(options);
108     }
109
110     // Setting the default values of the properties
111
void initialize(int options)
112     {
113
114     }
115
116     // This method verifies that the mandatory properties are set
117
public boolean verify()
118     {
119     return true;
120     }
121
122     //
123
static public void addComparator(BeanComparator c)
124     {
125     CookieOut.comparators.add(c);
126     }
127
128     //
129
static public void removeComparator(BeanComparator c)
130     {
131     CookieOut.comparators.remove(c);
132     }
133     //
134
public void addPropertyChangeListener(PropertyChangeListener l)
135     {
136     BeanProp p = this.beanProp();
137     if (p != null)
138         p.addPCListener(l);
139     }
140
141     //
142
public void removePropertyChangeListener(PropertyChangeListener l)
143     {
144     BeanProp p = this.beanProp();
145     if (p != null)
146         p.removePCListener(l);
147     }
148
149     //
150
public void addPropertyChangeListener(String JavaDoc n, PropertyChangeListener l)
151     {
152     BeanProp p = this.beanProp(n);
153     if (p != null)
154         p.addPCListener(l);
155     }
156
157     //
158
public void removePropertyChangeListener(String JavaDoc n, PropertyChangeListener l)
159     {
160     BeanProp p = this.beanProp(n);
161     if (p != null)
162         p.removePCListener(l);
163     }
164
165     // Dump the content of this bean returning it as a String
166
public void dump(StringBuffer JavaDoc str, String JavaDoc indent)
167     {
168     String JavaDoc s;
169     BaseBean n;
170     }
171
172     public String JavaDoc dumpBeanNode()
173     {
174     StringBuffer JavaDoc str = new StringBuffer JavaDoc();
175     str.append("CookieOut\n"); //NOI18N
176
this.dump(str, "\n "); //NOI18N
177
return str.toString();
178     }
179 }
180
181
Popular Tags