KickJava   Java API By Example, From Geeks To Geeks.

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


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.deployment.wsdd.WSDDConstants;
20
21 import javax.xml.namespace.QName JavaDoc;
22
23
24 /**
25  * Description of the different styles
26  * <br>
27  * <b>style=rpc, use=encoded</b><br>
28  * First element of the SOAP body is the
29  * operation. The operation contains
30  * elements describing the parameters, which
31  * are serialized as encoded (possibly multi-ref)
32  * <pre>
33  * &lt;soap:body&gt;
34  * &lt;operation&gt;
35  * &lt;arg1&gt;...&lt;/arg1&gt;
36  * &lt;arg2&gt;...&lt;/arg2&gt;
37  * &lt;/operation&gt;
38  * </pre>
39  * <br>
40  * <b>style=RPC, use=literal</b><br>
41  * First element of the SOAP body is the
42  * operation. The operation contains elements
43  * describing the parameters, which are serialized
44  * as encoded (no multi-ref)\
45  * <pre>
46  * &lt;soap:body&gt;
47  * &lt;operation&gt;
48  * &lt;arg1&gt;...&lt;/arg1&gt;
49  * &lt;arg2&gt;...&lt;/arg2&gt;
50  * &lt;/operation&gt;
51  * </pre>
52  * <br>
53  * <b>style=document, use=literal</b><br>
54  * Elements of the SOAP body are the names of the parameters
55  * (there is no wrapper operation...no multi-ref)
56  * <pre>
57  * &lt;soap:body&gt;
58  * &lt;arg1&gt;...&lt;/arg1&gt;
59  * &lt;arg2&gt;...&lt;/arg2&gt;
60  * </pre>
61  * <br>
62  * <b>style=wrapped</b><br>
63  * Special case of DOCLIT where there is only one parameter
64  * and it has the same qname as the operation. In
65  * such cases, there is no actual type with the name...the
66  * elements are treated as parameters to the operation
67  * <pre>
68  * &lt;soap:body&gt;
69  * &lt;one-arg-same-name-as-operation&gt;
70  * &lt;elemofarg1&gt;...&lt;/elemofarg1&gt;
71  * &lt;elemofarg2&gt;...&lt;/elemofarg2&gt;
72  * </pre>
73  * <br>
74  * <b>style=document, use=encoded</b><br>
75  * There is not an enclosing operation name element, but
76  * the parmeterss are encoded using SOAP encoding
77  * This mode is not (well?) supported by Axis.
78  *
79  * @author Richard Sitze
80  */

81 public class Style extends Enum JavaDoc {
82
83     private static final Type type = new Type();
84     
85     public static final String JavaDoc RPC_STR = "rpc";
86     public static final String JavaDoc DOCUMENT_STR = "document";
87     public static final String JavaDoc WRAPPED_STR = "wrapped";
88     public static final String JavaDoc MESSAGE_STR = "message";
89    
90  
91     public static final Style RPC = type.getStyle(RPC_STR);
92     public static final Style DOCUMENT = type.getStyle(DOCUMENT_STR);
93     public static final Style WRAPPED = type.getStyle(WRAPPED_STR);
94     public static final Style MESSAGE = type.getStyle(MESSAGE_STR);
95
96     public static final Style DEFAULT = RPC;
97     
98     static { type.setDefault(DEFAULT); }
99
100         
101     private QName JavaDoc provider;
102
103     public static Style getDefault() { return (Style)type.getDefault(); }
104     
105     public final QName JavaDoc getProvider() { return provider; }
106
107     public static final Style getStyle(int style) {
108         return type.getStyle(style);
109     }
110
111     public static final Style getStyle(String JavaDoc style) {
112         return type.getStyle(style);
113     }
114     
115     public static final Style getStyle(String JavaDoc style, Style dephault) {
116         return type.getStyle(style, dephault);
117     }
118     
119     public static final boolean isValid(String JavaDoc style) {
120         return type.isValid(style);
121     }
122     
123     public static final int size() {
124         return type.size();
125     }
126     
127     public static final String JavaDoc[] getStyles() {
128         return type.getEnumNames();
129     }
130     
131     private Object JavaDoc readResolve() throws java.io.ObjectStreamException JavaDoc {
132         return type.getStyle(value);
133     }
134
135     public static class Type extends Enum.Type JavaDoc {
136         private Type() {
137             super("style", new Enum JavaDoc[] {
138             new Style(0, RPC_STR,
139                       WSDDConstants.QNAME_JAVARPC_PROVIDER),
140             new Style(1, DOCUMENT_STR,
141                       WSDDConstants.QNAME_JAVARPC_PROVIDER),
142             new Style(2, WRAPPED_STR,
143                       WSDDConstants.QNAME_JAVARPC_PROVIDER),
144             new Style(3, MESSAGE_STR,
145                       WSDDConstants.QNAME_JAVAMSG_PROVIDER),
146             });
147         }
148
149         public final Style getStyle(int style) {
150             return (Style)this.getEnum(style);
151         }
152
153         public final Style getStyle(String JavaDoc style) {
154             return (Style)this.getEnum(style);
155         }
156
157         public final Style getStyle(String JavaDoc style, Style dephault) {
158             return (Style)this.getEnum(style, dephault);
159         }
160     }
161
162     private Style(int value, String JavaDoc name, QName JavaDoc provider) {
163         super(type, value, name);
164         this.provider = provider;
165     }
166
167     protected Style() {
168         super(type, DEFAULT.getValue(), DEFAULT.getName());
169         this.provider = DEFAULT.getProvider();
170     }
171 }
172
Popular Tags