KickJava   Java API By Example, From Geeks To Geeks.

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


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 import org.apache.axis.Constants;
20
21
22 /**
23  * Use enum description
24  * @author Richard Scheuerle
25  */

26 public class Use extends Enum JavaDoc {
27
28     /**
29      * See Style.java for a description of the combination
30      * of style and use.
31      */

32
33     private static final Type type = new Type();
34     
35     public static final String JavaDoc ENCODED_STR = "encoded";
36     public static final String JavaDoc LITERAL_STR = "literal";
37  
38     public static final Use ENCODED = type.getUse(ENCODED_STR);
39     public static final Use LITERAL = type.getUse(LITERAL_STR);
40
41     public static final Use DEFAULT = ENCODED;
42     
43     static { type.setDefault(DEFAULT); }
44     private String JavaDoc encoding;
45
46     public static Use getDefault() { return (Use)type.getDefault(); }
47     
48     public final String JavaDoc getEncoding() { return encoding; }
49
50     public static final Use getUse(int style) {
51         return type.getUse(style);
52     }
53
54     public static final Use getUse(String JavaDoc style) {
55         return type.getUse(style);
56     }
57     
58     public static final Use getUse(String JavaDoc style, Use dephault) {
59         return type.getUse(style, dephault);
60     }
61     
62     public static final boolean isValid(String JavaDoc style) {
63         return type.isValid(style);
64     }
65     
66     public static final int size() {
67         return type.size();
68     }
69     
70     public static final String JavaDoc[] getUses() {
71         return type.getEnumNames();
72     }
73     
74     private Object JavaDoc readResolve() throws java.io.ObjectStreamException JavaDoc {
75         return type.getUse(value);
76     }
77
78     public static class Type extends Enum.Type JavaDoc {
79         private Type() {
80             super("style", new Enum JavaDoc[] {
81             new Use(0, ENCODED_STR,
82                   Constants.URI_DEFAULT_SOAP_ENC),
83             new Use(1, LITERAL_STR,
84                   Constants.URI_LITERAL_ENC),
85             });
86         }
87
88         public final Use getUse(int style) {
89             return (Use)this.getEnum(style);
90         }
91
92         public final Use getUse(String JavaDoc style) {
93             return (Use)this.getEnum(style);
94         }
95
96         public final Use getUse(String JavaDoc style, Use dephault) {
97             return (Use)this.getEnum(style, dephault);
98         }
99
100     }
101
102     private Use(int value, String JavaDoc name, String JavaDoc encoding) {
103         super(type, value, name);
104         this.encoding = encoding;
105     }
106
107     protected Use() {
108         super(type, DEFAULT.getValue(), DEFAULT.getName());
109         this.encoding = DEFAULT.getEncoding();
110     }
111 }
112
Popular Tags