1 16 package org.apache.axis.description; 17 18 import org.apache.axis.utils.Messages; 19 import org.apache.axis.wsdl.symbolTable.TypeEntry; 20 21 import javax.xml.namespace.QName ; 22 import java.io.IOException ; 23 import java.io.ObjectInputStream ; 24 import java.io.ObjectOutputStream ; 25 import java.io.Serializable ; 26 27 35 public class ParameterDesc implements Serializable { 36 37 public static final byte IN = 1; 39 public static final byte OUT = 2; 40 public static final byte INOUT = 3; 41 42 43 private transient QName name; 44 45 public TypeEntry typeEntry; 46 47 private byte mode = IN; 48 49 private QName typeQName; 50 51 private Class javaType = null; 52 53 private int order = -1; 54 55 private boolean isReturn = false; 56 57 private String mimeType = null; 58 61 private QName itemQName; 62 private QName itemType; 63 64 65 private boolean inHeader = false; 66 private boolean outHeader = false; 67 68 69 private String documentation = null; 70 71 public ParameterDesc() { 72 } 73 74 79 public ParameterDesc(ParameterDesc copy) { 80 name = copy.name; 81 typeEntry = copy.typeEntry; 82 mode = copy.mode; 83 typeQName = copy.typeQName; 84 javaType = copy.javaType; 85 order = copy.order; 86 isReturn = copy.isReturn; 87 mimeType = copy.mimeType; 88 inHeader = copy.inHeader; 89 outHeader = copy.outHeader; 90 } 91 92 99 public ParameterDesc(QName name, byte mode, QName typeQName) { 100 this.name = name; 101 this.mode = mode; 102 this.typeQName = typeQName; 103 } 104 105 115 public ParameterDesc(QName name, byte mode, QName typeQName, 116 Class javaType, boolean inHeader, boolean outHeader) { 117 this(name,mode,typeQName); 118 this.javaType = javaType; 119 this.inHeader = inHeader; 120 this.outHeader = outHeader; 121 } 122 123 130 public ParameterDesc(QName name, byte mode, QName typeQName, Class javaType) { 131 this(name,mode,typeQName,javaType,false,false); 132 } 133 134 public String toString() { 135 return toString(""); 136 } 137 public String toString(String indent) { 138 String text=""; 139 text+=indent + "name: " + name + "\n"; 140 text+=indent + "typeEntry: " + typeEntry + "\n"; 141 text+=indent + "mode: " + (mode == IN ? 142 "IN" : mode == INOUT ? 143 "INOUT" : "OUT") + "\n"; 144 text+=indent + "position: " + order + "\n"; 145 text+=indent + "isReturn: " + isReturn + "\n"; 146 text+=indent + "typeQName: " + typeQName + "\n"; 147 text+=indent + "javaType: " + javaType + "\n"; 148 text+=indent + "inHeader: " + inHeader + "\n"; 149 text+=indent + "outHeader: " + outHeader+ "\n"; 150 return text; 151 } 153 157 public static byte modeFromString(String modeStr) 158 { 159 byte ret = IN; 160 if (modeStr == null) { 161 return IN; 162 } else if (modeStr.equalsIgnoreCase("out")) { 163 ret = OUT; 164 } else if (modeStr.equalsIgnoreCase("inout")) { 165 ret = INOUT; 166 } 167 return ret; 168 } 169 170 public static String getModeAsString(byte mode) 171 { 172 if (mode == INOUT) { 173 return "inout"; 174 } else if (mode == OUT) { 175 return "out"; 176 } else if (mode == IN) { 177 return "in"; 178 } 179 180 throw new IllegalArgumentException ( 181 Messages.getMessage("badParameterMode", Byte.toString(mode))); 182 } 183 184 public QName getQName() { 185 return name; 186 } 187 188 public String getName() { 189 if (name == null) { 190 return null; 191 } 192 else { 193 return name.getLocalPart(); 194 } 195 } 196 197 public void setName(String name) { 198 this.name = new QName ("", name); 199 } 200 201 public void setQName(QName name) { 202 this.name = name; 203 } 204 205 public QName getTypeQName() { 206 return typeQName; 207 } 208 209 public void setTypeQName(QName typeQName) { 210 this.typeQName = typeQName; 211 } 212 213 217 public Class getJavaType() { 218 return javaType; 219 } 220 221 224 public void setJavaType(Class javaType) { 225 if (javaType != null) { 228 if ((mode == IN || isReturn) && 229 javax.xml.rpc.holders.Holder .class.isAssignableFrom(javaType) || 230 mode != IN && !isReturn && 231 !javax.xml.rpc.holders.Holder .class.isAssignableFrom(javaType)) { 232 throw new IllegalArgumentException ( 233 Messages.getMessage("setJavaTypeErr00", 234 javaType.getName(), 235 getModeAsString(mode))); 236 } 237 } 238 239 this.javaType = javaType; 240 } 241 242 public byte getMode() { 243 return mode; 244 } 245 246 public void setMode(byte mode) { 247 this.mode = mode; 248 } 249 250 public int getOrder() { 251 return order; 252 } 253 254 public void setOrder(int order) { 255 this.order = order; 256 } 257 258 public void setInHeader(boolean value) { 259 this.inHeader = value; 260 } 261 262 public boolean isInHeader() { 263 return this.inHeader; 264 } 265 266 public void setOutHeader(boolean value) { 267 this.outHeader = value; 268 } 269 270 public boolean isOutHeader() { 271 return this.outHeader; 272 } 273 274 278 public boolean getIsReturn() { 279 return isReturn; 280 } 281 285 public void setIsReturn(boolean value) { 286 isReturn = value; 287 } 288 289 292 public String getDocumentation() { 293 return documentation; 294 } 295 296 299 public void setDocumentation(String documentation) { 300 this.documentation = documentation; 301 } 302 303 private void writeObject(ObjectOutputStream out) 304 throws IOException { 305 if (name == null) { 306 out.writeBoolean(false); 307 } else { 308 out.writeBoolean(true); 309 out.writeObject(name.getNamespaceURI()); 310 out.writeObject(name.getLocalPart()); 311 } 312 if (typeQName == null) { 313 out.writeBoolean(false); 314 } else { 315 out.writeBoolean(true); 316 out.writeObject(typeQName.getNamespaceURI()); 317 out.writeObject(typeQName.getLocalPart()); 318 } 319 out.defaultWriteObject(); 320 } 321 322 private void readObject(ObjectInputStream in) 323 throws IOException , ClassNotFoundException { 324 if (in.readBoolean()) { 325 name = new QName ((String )in.readObject(), 326 (String )in.readObject()); 327 } else { 328 name = null; 329 } 330 if (in.readBoolean()) { 331 typeQName = new QName ((String )in.readObject(), 332 (String )in.readObject()); 333 } else { 334 typeQName = null; 335 } 336 in.defaultReadObject(); 337 } 338 339 public QName getItemQName() { 340 return itemQName; 341 } 342 343 public void setItemQName(QName itemQName) { 344 this.itemQName = itemQName; 345 } 346 347 public QName getItemType() { 348 return itemType; 349 } 350 351 public void setItemType(QName itemType) { 352 this.itemType = itemType; 353 } 354 } 355 | Popular Tags |