KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > axis > enums > Scope


1 /*
2  * The Apache Software License, Version 1.1
3  *
4  *
5  * Copyright (c) 2001-2003 The Apache Software Foundation. All rights
6  * reserved.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions
10  * are met:
11  *
12  * 1. Redistributions of source code must retain the above copyright
13  * notice, this list of conditions and the following disclaimer.
14  *
15  * 2. Redistributions in binary form must reproduce the above copyright
16  * notice, this list of conditions and the following disclaimer in
17  * the documentation and/or other materials provided with the
18  * distribution.
19  *
20  * 3. The end-user documentation included with the redistribution,
21  * if any, must include the following acknowledgment:
22  * "This product includes software developed by the
23  * Apache Software Foundation (http://www.apache.org/)."
24  * Alternately, this acknowledgment may appear in the software itself,
25  * if and wherever such third-party acknowledgments normally appear.
26  *
27  * 4. The names "Axis" and "Apache Software Foundation" must
28  * not be used to endorse or promote products derived from this
29  * software without prior written permission. For written
30  * permission, please contact apache@apache.org.
31  *
32  * 5. Products derived from this software may not be called "Apache",
33  * nor may "Apache" appear in their name, without prior written
34  * permission of the Apache Software Foundation.
35  *
36  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
37  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
38  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
39  * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
40  * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
41  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
42  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
43  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
44  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
45  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
46  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
47  * SUCH DAMAGE.
48  * ====================================================================
49  *
50  * This software consists of voluntary contributions made by many
51  * individuals on behalf of the Apache Software Foundation. For more
52  * information on the Apache Software Foundation, please see
53  * <http://www.apache.org/>.
54  */

55
56 package org.jboss.axis.enums;
57
58
59 /**
60  * @author rsitze
61  */

62 public class Scope extends Enum JavaDoc
63 {
64    private static final Type type = new Type();
65
66    public static final String JavaDoc REQUEST_STR = "Request";
67    public static final String JavaDoc APPLICATION_STR = "Application";
68    public static final String JavaDoc SESSION_STR = "Session";
69
70    public static final Scope REQUEST = type.getScope(REQUEST_STR);
71    public static final Scope APPLICATION = type.getScope(APPLICATION_STR);
72    public static final Scope SESSION = type.getScope(SESSION_STR);
73
74    public static final Scope DEFAULT = REQUEST;
75
76
77    static
78    {
79       type.setDefault(DEFAULT);
80    }
81
82
83    // public int getValue();
84
// public String getName();
85
// public Type getType();
86

87    public static Scope getDefault()
88    {
89       return (Scope)type.getDefault();
90    }
91
92    public static final Scope getScope(int scope)
93    {
94       return type.getScope(scope);
95    }
96
97    public static final Scope getScope(String JavaDoc scope)
98    {
99       return type.getScope(scope);
100    }
101
102    public static final Scope getScope(String JavaDoc scope, Scope dephault)
103    {
104       return type.getScope(scope, dephault);
105    }
106
107    public static final boolean isValid(String JavaDoc scope)
108    {
109       return type.isValid(scope);
110    }
111
112    public static final int size()
113    {
114       return type.size();
115    }
116
117    public static final String JavaDoc[] getScopes()
118    {
119       return type.getEnumNames();
120    }
121
122    public static class Type extends Enum.Type JavaDoc
123    {
124       private Type()
125       {
126          super("scope", new Enum JavaDoc[]{
127             new Scope(0, REQUEST_STR),
128             new Scope(1, APPLICATION_STR),
129             new Scope(2, SESSION_STR)
130          });
131       }
132
133       public final Scope getScope(int scope)
134       {
135          return (Scope)this.getEnum(scope);
136       }
137
138       public final Scope getScope(String JavaDoc scope)
139       {
140          return (Scope)this.getEnum(scope);
141       }
142
143       public final Scope getScope(String JavaDoc scope, Scope dephault)
144       {
145          return (Scope)this.getEnum(scope, dephault);
146       }
147
148       // public final String getName();
149
// public boolean isValid(String enumName);
150
// public final int size();
151
// public final String[] getEnumNames();
152
// public final Enum getEnum(int enums);
153
// public final Enum getEnum(String enumName);
154
// public final Enum getEnum(String enumName, Enum dephault);
155
}
156
157    private Scope(int value, String JavaDoc name)
158    {
159       super(type, value, name);
160    }
161 }
162
163 ;
164
Popular Tags