KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > web > wizards > FilterMappingData


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.wizards;
21
22
23 /**
24  * Filter Mapping representation
25
26  * @author ana.von.klopp@sun.com
27  */

28 class FilterMappingData {
29
30     private String JavaDoc name = null;
31     private Type type = null;
32     private String JavaDoc pattern = null;
33     private Dispatcher[] dispatch = new Dispatcher[0];
34
35     FilterMappingData() {}
36
37     FilterMappingData(String JavaDoc name) {
38     this.name = name;
39     this.type = FilterMappingData.Type.URL;
40     this.pattern = "/*"; //NOI18N
41
}
42
43     FilterMappingData(String JavaDoc name, Type type, String JavaDoc pattern, Dispatcher[] d) {
44     this.name = name;
45     this.type = type;
46     this.pattern = pattern;
47     this.dispatch = d;
48     }
49
50     public Object JavaDoc clone() {
51     return new FilterMappingData(name, type, pattern, dispatch);
52     }
53
54     /**
55      * Get the Name value.
56      * @return the Name value.
57      */

58     String JavaDoc getName() {
59     return name;
60     }
61
62     /**
63      * Set the Name value.
64      * @param newName The new Name value.
65      */

66     void setName(String JavaDoc newName) {
67     this.name = newName;
68     }
69
70     /**
71      * Get the Type value.
72      * @return the Type value.
73      */

74     Type getType() {
75     return type;
76     }
77
78     /**
79      * Set the Type value.
80      * @param newType The new Type value.
81      */

82     void setType(Type newType) {
83     this.type = newType;
84     }
85
86     /**
87      * Get the Pattern value.
88      * @return the Pattern value.
89      */

90     String JavaDoc getPattern() {
91     return pattern;
92     }
93
94     /**
95      * Set the Pattern value.
96      * @param newPattern The new Pattern value.
97      */

98     void setPattern(String JavaDoc newPattern) {
99     this.pattern = newPattern;
100     }
101
102     /**
103      * Get the DispatchConfig value.
104      * @return the DispatchConfig value.
105      */

106     Dispatcher[] getDispatcher() {
107     return dispatch;
108     }
109
110     /**
111      * Set the DispatchConfig value.
112      * @param new dc new DispatchConfig value.
113      */

114     void setDispatcher(Dispatcher[] d) {
115     this.dispatch = d;
116     }
117
118     public String JavaDoc toString() {
119     StringBuffer JavaDoc buf =
120         new StringBuffer JavaDoc("FilterMapping for filter: "); //NOI18N
121
buf.append(name);
122     buf.append("\nMapping type: ");
123     buf.append(type.toString());
124     buf.append(" for pattern: ");
125     buf.append(pattern);
126     buf.append("\nDispatch conditions: ");
127     if(dispatch.length == 0)
128         buf.append("REQUEST (not set)\n\n");
129     else {
130         for(int i=0; i<dispatch.length; ++i) {
131         buf.append(dispatch[i].toString());
132         buf.append(", ");
133         }
134         buf.append("\n\n");
135     }
136     return buf.toString();
137     }
138
139     static class Type {
140     private String JavaDoc name;
141     private Type(String JavaDoc name) { this.name = name; }
142     public String JavaDoc toString() { return name; }
143     public static final Type URL = new Type("URL pattern");
144     public static final Type SERVLET = new Type("Servlet");
145     }
146
147     static class Dispatcher {
148     private String JavaDoc name;
149     private Dispatcher(String JavaDoc name) { this.name = name; }
150     public String JavaDoc toString() { return name; }
151     public static final Dispatcher BLANK = new Dispatcher("");
152     public static final Dispatcher REQUEST = new Dispatcher("REQUEST");
153     public static final Dispatcher INCLUDE = new Dispatcher("INCLUDE");
154     public static final Dispatcher FORWARD = new Dispatcher("FORWARD");
155     public static final Dispatcher ERROR = new Dispatcher("ERROR");
156     public static final Dispatcher findDispatcher(String JavaDoc s) {
157         if(s.equals(REQUEST.toString())) return REQUEST;
158         else if(s.equals(INCLUDE.toString())) return INCLUDE;
159         else if(s.equals(FORWARD.toString())) return FORWARD;
160         else if(s.equals(ERROR.toString())) return ERROR;
161         else return BLANK;
162     }
163     public static final Dispatcher[] getAll() {
164         Dispatcher[] d = new Dispatcher[4];
165         d[0] = REQUEST;
166         d[1] = FORWARD;
167         d[2] = INCLUDE;
168         d[3] = ERROR;
169         return d;
170     }
171     }
172 }
Popular Tags