1 package org.codehaus.xfire.annotations;
2
3
4 /***
5 * Represents a common representation of a web parameter annotation. Customizes the mapping of an individual parameter
6 * to a Web Service message part and XML element.
7 *
8 * @author Arjen Poutsma
9 */
10 public class WebParamAnnotation
11 {
12 private String name = "";
13 private String targetNamespace = "";
14 private boolean header = false;
15 private int mode = MODE_IN;
16
17 /***
18 * Constant used to specify that a parameter flows inwards. This is the default mode.
19 */
20 public final static int MODE_IN = 0;
21 /***
22 * Constant used to specify that a parameter flows both in and outwards.
23 */
24 public final static int MODE_INOUT = 1;
25 /***
26 * Constant used to specify that a parameter flows outwards.
27 */
28 public final static int MODE_OUT = 2;
29
30 /***
31 * Returns the name of the parameter as it appears in the WSDL. For RPC bindings, this is name of the wsdl:part
32 * representing the parameter. For document bindings, this is the local name of the XML element representing the
33 * parameter. Defaults to the name of the parameter as it appears in the argument list.
34 *
35 * @return the name of the parameter as it appears in the WSDL.
36 */
37 public String getName()
38 {
39 return name;
40 }
41
42 /***
43 * Sets the name of the parameter as it appears in the WSDL. For RPC bindings, this is name of the wsdl:part
44 * representing the parameter. For document bindings, this is the local name of the XML element representing the
45 * parameter. Defaults to the name of the parameter as it appears in the argument list.
46 *
47 * @param name the new name of the parameter as it appears in the WSDL.
48 */
49 public void setName(String name)
50 {
51 this.name = name;
52 }
53
54 /***
55 * Returns the XML namespace for the parameter. Only used with document bindings, where the parameter maps to an XML
56 * element. Defaults to the targetNamespace for the Web Service.
57 *
58 * @return the XML namespace for the parameter.
59 */
60 public String getTargetNamespace()
61 {
62 return targetNamespace;
63 }
64
65 /***
66 * Sets the XML namespace for the parameter. Only used with document bindings, where the parameter maps to an XML
67 * element. Defaults to the targetNamespace for the Web Service.
68 *
69 * @param targetNamespace the XML namespace for the parameter.
70 */
71 public void setTargetNamespace(String targetNamespace)
72 {
73 this.targetNamespace = targetNamespace;
74 }
75
76 /***
77 * Returns the direction in which the parameter is flowing. One of {@link #MODE_IN}, {@link #MODE_OUT}, or {@link
78 * #MODE_INOUT}.
79 *
80 * @return the parameter mode.
81 */
82 public int getMode()
83 {
84 return mode;
85 }
86
87 /***
88 * Sets the direction in which the parameter is flowing. The given parameter must be of {@link #MODE_IN}, {@link
89 * #MODE_OUT}, or {@link #MODE_INOUT}.
90 *
91 * @param mode the new parameter mode.
92 * @throws IllegalArgumentException if <code>mode</code> is not a valid mode.
93 */
94 public void setMode(int mode)
95 {
96 if (mode == WebParamAnnotation.MODE_IN || mode == WebParamAnnotation.MODE_INOUT ||
97 mode == WebParamAnnotation.MODE_OUT)
98 {
99 this.mode = mode;
100 }
101 else
102 {
103 throw new IllegalArgumentException("Invalid mode: " + mode);
104 }
105 }
106
107 /***
108 * If <code>true</code>, the parameter is pulled from a message header rather then the message body.
109 *
110 * @return <code>true</code> if a header; <code>false</code> otherwise.
111 */
112 public boolean isHeader()
113 {
114 return header;
115 }
116
117 /***
118 * Determines whether this parameter is a header.
119 *
120 * @param header <code>true</code> if a header; <code>false</code> otherwise.
121 */
122 public void setHeader(boolean header)
123 {
124 this.header = header;
125 }
126 }