KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > axis > constants > Scope


1 /*
2  * Copyright 2001-2004 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * 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,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16
17 package org.apache.axis.constants;
18
19
20
21
22 /**
23  * @author rsitze
24  */

25 public class Scope extends Enum JavaDoc {
26     private static final Type type = new Type();
27     
28     public static final String JavaDoc REQUEST_STR = "Request";
29     public static final String JavaDoc APPLICATION_STR = "Application";
30     public static final String JavaDoc SESSION_STR = "Session";
31     public static final String JavaDoc FACTORY_STR = "Factory";
32
33     public static final Scope REQUEST = type.getScope(REQUEST_STR);
34     public static final Scope APPLICATION = type.getScope(APPLICATION_STR);
35     public static final Scope SESSION = type.getScope(SESSION_STR);
36     public static final Scope FACTORY = type.getScope(FACTORY_STR);
37
38     public static final Scope DEFAULT = REQUEST;
39
40     static { type.setDefault(DEFAULT); }
41     
42     // public int getValue();
43
// public String getName();
44
// public Type getType();
45

46     public static Scope getDefault() { return (Scope)type.getDefault(); }
47     
48     public static final Scope getScope(int scope) {
49         return type.getScope(scope);
50     }
51
52     public static final Scope getScope(String JavaDoc scope) {
53         return type.getScope(scope);
54     }
55     
56     public static final Scope getScope(String JavaDoc scope, Scope dephault) {
57         return type.getScope(scope, dephault);
58     }
59     
60     public static final boolean isValid(String JavaDoc scope) {
61         return type.isValid(scope);
62     }
63     
64     public static final int size() {
65         return type.size();
66     }
67     
68     public static final String JavaDoc[] getScopes() {
69         return type.getEnumNames();
70     }
71     
72     private Object JavaDoc readResolve() throws java.io.ObjectStreamException JavaDoc {
73         return type.getScope(value);
74     }
75     public static class Type extends Enum.Type JavaDoc {
76         private Type() {
77             super("scope", new Enum JavaDoc[] {
78                 new Scope(0, REQUEST_STR),
79                 new Scope(1, APPLICATION_STR),
80                 new Scope(2, SESSION_STR),
81                 new Scope(3, FACTORY_STR)
82             });
83         }
84
85         public final Scope getScope(int scope) {
86             return (Scope)this.getEnum(scope);
87         }
88
89         public final Scope getScope(String JavaDoc scope) {
90             return (Scope)this.getEnum(scope);
91         }
92
93         public final Scope getScope(String JavaDoc scope, Scope dephault) {
94             return (Scope)this.getEnum(scope, dephault);
95         }
96
97     }
98
99     private Scope(int value, String JavaDoc name) {
100         super(type, value, name);
101     }
102     
103     protected Scope() {
104         super(type, DEFAULT.getValue(), DEFAULT.getName());
105     }
106 }
107
Popular Tags