1 16 package org.apache.axis.wsdl.symbolTable; 17 18 import org.apache.axis.constants.Style; 19 import org.apache.axis.constants.Use; 20 21 import javax.wsdl.Binding; 22 import javax.wsdl.Operation; 23 import javax.wsdl.extensions.soap.SOAPFault; 24 import java.util.ArrayList ; 25 import java.util.HashMap ; 26 import java.util.Map ; 27 import java.util.Set ; 28 29 34 public class BindingEntry extends SymTabEntry { 35 36 38 39 public static final int TYPE_SOAP = 0; 40 41 42 public static final int TYPE_HTTP_GET = 1; 43 44 45 public static final int TYPE_HTTP_POST = 2; 46 47 48 public static final int TYPE_UNKNOWN = 3; 49 50 52 53 public static final int USE_ENCODED = 0; 54 55 56 public static final int USE_LITERAL = 1; 57 58 59 private Binding binding; 60 61 62 private int bindingType; 63 64 65 private Style bindingStyle; 66 67 68 private boolean hasLiteral; 69 70 71 private HashMap attributes; 72 73 75 76 private HashMap parameters = new HashMap (); 77 78 80 81 private HashMap faults = new HashMap (); 82 83 86 87 private Map mimeTypes; 88 89 93 94 private Map headerParts; 95 96 98 99 private ArrayList dimeOps = new ArrayList (); 100 101 114 public BindingEntry(Binding binding, int bindingType, Style bindingStyle, 115 boolean hasLiteral, HashMap attributes, Map mimeTypes, 116 Map headerParts) { 117 118 super(binding.getQName()); 119 120 this.binding = binding; 121 this.bindingType = bindingType; 122 this.bindingStyle = bindingStyle; 123 this.hasLiteral = hasLiteral; 124 125 if (attributes == null) { 126 this.attributes = new HashMap (); 127 } else { 128 this.attributes = attributes; 129 } 130 131 if (mimeTypes == null) { 132 this.mimeTypes = new HashMap (); 133 } else { 134 this.mimeTypes = mimeTypes; 135 } 136 137 if (headerParts == null) { 138 this.headerParts = new HashMap (); 139 } else { 140 this.headerParts = headerParts; 141 } 142 } 144 163 public BindingEntry(Binding binding) { 164 165 super(binding.getQName()); 166 167 this.binding = binding; 168 this.bindingType = TYPE_UNKNOWN; 169 this.bindingStyle = Style.DOCUMENT; 170 this.hasLiteral = false; 171 this.attributes = new HashMap (); 172 this.mimeTypes = new HashMap (); 173 this.headerParts = new HashMap (); 174 } 176 182 public Parameters getParameters(Operation operation) { 183 return (Parameters) parameters.get(operation); 184 } 186 191 public HashMap getParameters() { 192 return parameters; 193 } 195 200 public void setParameters(HashMap parameters) { 201 this.parameters = parameters; 202 } 203 204 212 public MimeInfo getMIMEInfo(String operationName, String parameterName) { 213 214 Map opMap = (Map ) mimeTypes.get(operationName); 215 216 if (opMap == null) { 217 return null; 218 } else { 219 return (MimeInfo) opMap.get(parameterName); 220 } 221 } 223 228 public Map getMIMETypes() { 229 return mimeTypes; 230 } 232 240 public void setMIMEInfo(String operationName, String parameterName, 241 String type, String dims) { 242 243 Map opMap = (Map ) mimeTypes.get(operationName); 244 245 if (opMap == null) { 246 opMap = new HashMap (); 247 248 mimeTypes.put(operationName, opMap); 249 } 250 251 opMap.put(parameterName, new MimeInfo(type, dims)); 252 } 254 259 public void setOperationDIME(String operationName) { 260 261 if (dimeOps.indexOf(operationName) == -1) { 262 dimeOps.add(operationName); 263 } 264 } 265 266 272 public boolean isOperationDIME(String operationName) { 273 return (dimeOps.indexOf(operationName) >= 0); 274 } 275 276 283 public boolean isInHeaderPart(String operationName, String partName) { 284 return (headerPart(operationName, partName) & IN_HEADER) > 0; 285 } 287 294 public boolean isOutHeaderPart(String operationName, String partName) { 295 return (headerPart(operationName, partName) & OUT_HEADER) > 0; 296 } 298 299 public static final int NO_HEADER = 0; 300 301 302 public static final int IN_HEADER = 1; 303 304 305 public static final int OUT_HEADER = 2; 306 307 315 private int headerPart(String operationName, String partName) { 316 317 Map opMap = (Map ) headerParts.get(operationName); 318 319 if (opMap == null) { 320 return NO_HEADER; 321 } else { 322 Integer I = (Integer ) opMap.get(partName); 323 324 return (I == null) 325 ? NO_HEADER 326 : I.intValue(); 327 } 328 } 330 335 public Map getHeaderParts() { 336 return headerParts; 337 } 339 346 public void setHeaderPart(String operationName, String partName, 347 int headerFlags) { 348 349 Map opMap = (Map ) headerParts.get(operationName); 350 351 if (opMap == null) { 352 opMap = new HashMap (); 353 354 headerParts.put(operationName, opMap); 355 } 356 357 Integer I = (Integer ) opMap.get(partName); 358 int i = (I == null) 359 ? headerFlags 360 : (I.intValue() | headerFlags); 361 362 opMap.put(partName, new Integer (i)); 363 } 365 370 public Binding getBinding() { 371 return binding; 372 } 374 380 public int getBindingType() { 381 return bindingType; 382 } 384 389 protected void setBindingType(int bindingType) { 390 391 if ((bindingType >= TYPE_SOAP) && (bindingType <= TYPE_UNKNOWN)) { 392 } 393 394 this.bindingType = bindingType; 395 } 397 402 public Style getBindingStyle() { 403 return bindingStyle; 404 } 406 411 protected void setBindingStyle(Style bindingStyle) { 412 this.bindingStyle = bindingStyle; 413 } 415 420 public boolean hasLiteral() { 421 return hasLiteral; 422 } 424 429 protected void setHasLiteral(boolean hasLiteral) { 430 this.hasLiteral = hasLiteral; 431 } 433 439 public Use getInputBodyType(Operation operation) { 440 441 OperationAttr attr = (OperationAttr) attributes.get(operation); 442 443 if (attr == null) { 444 return Use.ENCODED; } else { 446 return attr.getInputBodyType(); 447 } 448 } 450 456 protected void setInputBodyType(Operation operation, Use inputBodyType) { 457 458 OperationAttr attr = (OperationAttr) attributes.get(operation); 459 460 if (attr == null) { 461 attr = new OperationAttr(); 462 463 attributes.put(operation, attr); 464 } 465 466 attr.setInputBodyType(inputBodyType); 467 468 if (inputBodyType == Use.LITERAL) { 469 setHasLiteral(true); 470 } 471 } 473 479 public Use getOutputBodyType(Operation operation) { 480 481 OperationAttr attr = (OperationAttr) attributes.get(operation); 482 483 if (attr == null) { 484 return Use.ENCODED; } else { 486 return attr.getOutputBodyType(); 487 } 488 } 490 496 protected void setOutputBodyType(Operation operation, Use outputBodyType) { 497 498 OperationAttr attr = (OperationAttr) attributes.get(operation); 499 500 if (attr == null) { 501 attr = new OperationAttr(); 502 503 attributes.put(operation, attr); 504 } 505 506 attr.setOutputBodyType(outputBodyType); 507 508 if (outputBodyType == Use.LITERAL) { 509 setHasLiteral(true); 510 } 511 } 513 522 protected void setBodyType(Operation operation, Use bodyType, 523 boolean input) { 524 525 if (input) { 526 setInputBodyType(operation, bodyType); 527 } else { 528 setOutputBodyType(operation, bodyType); 529 } 530 } 532 539 public Use getFaultBodyType(Operation operation, String faultName) { 540 541 OperationAttr attr = (OperationAttr) attributes.get(operation); 542 543 if (attr == null) { 544 return Use.ENCODED; } else { 546 HashMap m = attr.getFaultBodyTypeMap(); 547 SOAPFault soapFault = (SOAPFault) m.get(faultName); 548 549 if (soapFault == null) { 551 return Use.ENCODED; 552 } 553 554 String use = soapFault.getUse(); 555 556 if ("literal".equals(use)) { 557 return Use.LITERAL; 558 } 559 560 return Use.ENCODED; 561 } 562 } 563 564 569 public HashMap getFaults() { 570 return faults; 571 } 572 573 578 public void setFaults(HashMap faults) { 579 this.faults = faults; 580 } 581 582 587 public Set getOperations() { 588 return attributes.keySet(); 589 } 590 591 597 protected void setFaultBodyTypeMap(Operation operation, 598 HashMap faultBodyTypeMap) { 599 600 OperationAttr attr = (OperationAttr) attributes.get(operation); 601 602 if (attr == null) { 603 attr = new OperationAttr(); 604 605 attributes.put(operation, attr); 606 } 607 608 attr.setFaultBodyTypeMap(faultBodyTypeMap); 609 } 611 615 protected static class OperationAttr { 616 617 618 private Use inputBodyType; 619 620 621 private Use outputBodyType; 622 623 624 private HashMap faultBodyTypeMap; 625 626 633 public OperationAttr(Use inputBodyType, Use outputBodyType, 634 HashMap faultBodyTypeMap) { 635 636 this.inputBodyType = inputBodyType; 637 this.outputBodyType = outputBodyType; 638 this.faultBodyTypeMap = faultBodyTypeMap; 639 } 640 641 644 public OperationAttr() { 645 646 this.inputBodyType = Use.ENCODED; 647 this.outputBodyType = Use.ENCODED; 648 this.faultBodyTypeMap = null; 649 } 650 651 656 public Use getInputBodyType() { 657 return inputBodyType; 658 } 659 660 665 protected void setInputBodyType(Use inputBodyType) { 666 this.inputBodyType = inputBodyType; 667 } 668 669 674 public Use getOutputBodyType() { 675 return outputBodyType; 676 } 677 678 683 protected void setOutputBodyType(Use outputBodyType) { 684 this.outputBodyType = outputBodyType; 685 } 686 687 692 public HashMap getFaultBodyTypeMap() { 693 return faultBodyTypeMap; 694 } 695 696 701 protected void setFaultBodyTypeMap(HashMap faultBodyTypeMap) { 702 this.faultBodyTypeMap = faultBodyTypeMap; 703 } 704 } } | Popular Tags |