1 55 56 package org.jboss.axis.wsdl.symbolTable; 57 58 import org.jboss.axis.enums.Style; 59 import org.jboss.axis.enums.Use; 60 import org.jboss.axis.utils.LinkedHashMap; 61 62 import javax.wsdl.Binding; 63 import javax.wsdl.Operation; 64 import javax.wsdl.extensions.soap.SOAPFault; 65 import javax.wsdl.extensions.soap.SOAPHeader; 66 import javax.xml.namespace.QName ; 67 import java.util.ArrayList ; 68 import java.util.HashMap ; 69 import java.util.Map ; 70 import java.util.Set ; 71 72 77 public class BindingEntry extends SymTabEntry 78 { 79 80 public static final int TYPE_SOAP = 0; 82 public static final int TYPE_HTTP_GET = 1; 83 public static final int TYPE_HTTP_POST = 2; 84 public static final int TYPE_UNKNOWN = 3; 85 86 public static final int USE_ENCODED = 0; 88 public static final int USE_LITERAL = 1; 89 90 93 public static final int NO_HEADER = 0; 94 public static final int IN_HEADER = 1; 95 public static final int OUT_HEADER = 2; 96 97 private Binding binding; 98 private int bindingType; 99 private Style bindingStyle; 100 private boolean hasLiteral; 101 private Map attributes; 102 private LinkedHashMap parameters = new LinkedHashMap(); 104 105 private Map faults = new LinkedHashMap(); 107 108 private Map mimeTypes; 111 112 private Map headerParts; 116 117 private ArrayList dimeOps = new ArrayList (); 119 120 125 public BindingEntry(Binding binding, int bindingType, Style bindingStyle, 126 boolean hasLiteral, HashMap attributes, Map mimeTypes, 127 Map headerParts) 128 { 129 super(binding.getQName()); 130 this.binding = binding; 131 this.bindingType = bindingType; 132 this.bindingStyle = bindingStyle; 133 this.hasLiteral = hasLiteral; 134 if (attributes == null) 135 { 136 this.attributes = new LinkedHashMap(); 137 } 138 else 139 { 140 this.attributes = attributes; 141 } 142 if (mimeTypes == null) 143 { 144 this.mimeTypes = new LinkedHashMap(); 145 } 146 else 147 { 148 this.mimeTypes = mimeTypes; 149 } 150 if (headerParts == null) 151 { 152 this.headerParts = new LinkedHashMap(); 153 } 154 else 155 { 156 this.headerParts = headerParts; 157 } 158 } 160 177 public BindingEntry(Binding binding) 178 { 179 super(binding.getQName()); 180 this.binding = binding; 181 this.bindingType = TYPE_UNKNOWN; 182 this.bindingStyle = Style.DOCUMENT; 183 this.hasLiteral = false; 184 this.attributes = new LinkedHashMap(); 185 this.mimeTypes = new LinkedHashMap(); 186 this.headerParts = new LinkedHashMap(); 187 } 189 192 public Parameters getParameters(Operation operation) 193 { 194 return (Parameters)parameters.get(operation); 195 } 197 200 public Map getParameters() 201 { 202 return parameters; 203 } 205 208 public void setParameters(LinkedHashMap parameters) 209 { 210 this.parameters = parameters; 211 } 212 213 217 public MimeInfo getMIMEInfo(String operationName, String parameterName) 218 { 219 Map opMap = (Map)mimeTypes.get(operationName); 220 if (opMap == null) 221 { 222 return null; 223 } 224 else 225 { 226 return (MimeInfo)opMap.get(parameterName); 227 } 228 } 230 233 public Map getMIMETypes() 234 { 235 return mimeTypes; 236 } 238 241 public void setMIMEInfo(String operationName, String parameterName, String type, String dims) 242 { 243 Map opMap = (Map)mimeTypes.get(operationName); 244 if (opMap == null) 245 { 246 opMap = new LinkedHashMap(); 247 mimeTypes.put(operationName, opMap); 248 } 249 opMap.put(parameterName, new MimeInfo(type, dims)); 250 } 252 257 public void setOperationDIME(String operationName) 258 { 259 if (dimeOps.indexOf(operationName) == -1) 260 { 261 dimeOps.add(operationName); 262 } 263 } 264 265 271 public boolean isOperationDIME(String operationName) 272 { 273 return (dimeOps.indexOf(operationName) >= 0); 274 } 275 276 279 public boolean isInHeaderPart(String operationName, 280 String partName) 281 { 282 return (headerPart(operationName, partName) & IN_HEADER) > 0; 283 } 285 288 public boolean isOutHeaderPart(String operationName, 289 String partName) 290 { 291 return (headerPart(operationName, partName) & OUT_HEADER) > 0; 292 } 294 302 private int headerPart(String operationName, 303 String partName) 304 { 305 Map opMap = (Map)headerParts.get(operationName); 306 if (opMap == null) 307 { 308 return NO_HEADER; 309 } 310 else 311 { 312 HeaderPart headerPart = (HeaderPart)opMap.get(partName); 313 return headerPart == null ? NO_HEADER : headerPart.getFlags(); 314 } 315 } 317 320 public Map getHeaderParts() 321 { 322 return headerParts; 323 } 325 328 public void setHeaderPart(String operationName, String partName, SOAPHeader soapHeader, int headerFlags) 329 { 330 Map opMap = (Map)headerParts.get(operationName); 331 if (opMap == null) 332 { 333 opMap = new LinkedHashMap(); 334 headerParts.put(operationName, opMap); 335 } 336 337 QName message = (soapHeader != null ? soapHeader.getMessage() : null); 339 340 HeaderPart headerPart = (HeaderPart)opMap.get(partName); 341 if (headerPart == null) 342 headerPart = new HeaderPart(partName, message, headerFlags); 343 else 344 headerPart = new HeaderPart(partName, message, headerFlags | headerPart.getFlags()); 345 346 opMap.put(partName, headerPart); 347 } 349 352 public Binding getBinding() 353 { 354 return binding; 355 } 357 361 public int getBindingType() 362 { 363 return bindingType; 364 } 366 369 protected void setBindingType(int bindingType) 370 { 371 if (bindingType >= TYPE_SOAP && bindingType <= TYPE_UNKNOWN) 372 { 373 } 374 this.bindingType = bindingType; 375 } 377 380 public Style getBindingStyle() 381 { 382 return bindingStyle; 383 } 385 388 protected void setBindingStyle(Style bindingStyle) 389 { 390 this.bindingStyle = bindingStyle; 391 } 393 396 public boolean hasLiteral() 397 { 398 return hasLiteral; 399 } 401 404 protected void setHasLiteral(boolean hasLiteral) 405 { 406 this.hasLiteral = hasLiteral; 407 } 409 412 public Use getInputBodyType(Operation operation) 413 { 414 OperationAttr attr = (OperationAttr)attributes.get(operation); 415 if (attr == null) 416 { 417 return Use.ENCODED; } 419 else 420 { 421 return attr.getInputBodyType(); 422 } 423 } 425 428 protected void setInputBodyType(Operation operation, Use inputBodyType) 429 { 430 OperationAttr attr = (OperationAttr)attributes.get(operation); 431 if (attr == null) 432 { 433 attr = new OperationAttr(); 434 attributes.put(operation, attr); 435 } 436 attr.setInputBodyType(inputBodyType); 437 if (inputBodyType == Use.LITERAL) 438 { 439 setHasLiteral(true); 440 } 441 } 443 446 public Use getOutputBodyType(Operation operation) 447 { 448 OperationAttr attr = (OperationAttr)attributes.get(operation); 449 if (attr == null) 450 { 451 return Use.ENCODED; } 453 else 454 { 455 return attr.getOutputBodyType(); 456 } 457 } 459 462 protected void setOutputBodyType(Operation operation, Use outputBodyType) 463 { 464 OperationAttr attr = (OperationAttr)attributes.get(operation); 465 if (attr == null) 466 { 467 attr = new OperationAttr(); 468 attributes.put(operation, attr); 469 } 470 attr.setOutputBodyType(outputBodyType); 471 if (outputBodyType == Use.LITERAL) 472 { 473 setHasLiteral(true); 474 } 475 } 477 482 protected void setBodyType(Operation operation, Use bodyType, boolean input) 483 { 484 if (input) 485 { 486 setInputBodyType(operation, bodyType); 487 } 488 else 489 { 490 setOutputBodyType(operation, bodyType); 491 } 492 } 494 499 public Use getFaultBodyType(Operation operation, String faultName) 500 { 501 OperationAttr attr = (OperationAttr)attributes.get(operation); 502 if (attr == null) 503 { 504 return Use.ENCODED; } 506 else 507 { 508 Map m = attr.getFaultBodyTypeMap(); 509 SOAPFault soapFault = (SOAPFault)m.get(faultName); 510 511 if (soapFault == null) 513 { 514 return Use.ENCODED; 515 } 516 String use = soapFault.getUse(); 517 if ("literal".equals(use)) 518 { 519 return Use.LITERAL; 520 } 521 522 return Use.ENCODED; 523 } 524 } 525 526 529 public Map getFaults() 530 { 531 return faults; 532 } 533 534 public void setFaults(Map faults) 535 { 536 this.faults = faults; 537 } 538 539 542 public Set getOperations() 543 { 544 return attributes.keySet(); 545 } 546 547 550 protected void setFaultBodyTypeMap(Operation operation, Map faultBodyTypeMap) 551 { 552 OperationAttr attr = (OperationAttr)attributes.get(operation); 553 if (attr == null) 554 { 555 attr = new OperationAttr(); 556 attributes.put(operation, attr); 557 } 558 attr.setFaultBodyTypeMap(faultBodyTypeMap); 559 } 561 565 protected static class OperationAttr 566 { 567 private Use inputBodyType; 568 private Use outputBodyType; 569 private Map faultBodyTypeMap; 570 571 public OperationAttr(Use inputBodyType, Use outputBodyType, Map faultBodyTypeMap) 572 { 573 this.inputBodyType = inputBodyType; 574 this.outputBodyType = outputBodyType; 575 this.faultBodyTypeMap = faultBodyTypeMap; 576 } 577 578 public OperationAttr() 579 { 580 this.inputBodyType = Use.ENCODED; 581 this.outputBodyType = Use.ENCODED; 582 this.faultBodyTypeMap = null; 583 } 584 585 public Use getInputBodyType() 586 { 587 return inputBodyType; 588 } 589 590 protected void setInputBodyType(Use inputBodyType) 591 { 592 this.inputBodyType = inputBodyType; 593 } 594 595 public Use getOutputBodyType() 596 { 597 return outputBodyType; 598 } 599 600 protected void setOutputBodyType(Use outputBodyType) 601 { 602 this.outputBodyType = outputBodyType; 603 } 604 605 public Map getFaultBodyTypeMap() 606 { 607 return faultBodyTypeMap; 608 } 609 610 protected void setFaultBodyTypeMap(Map faultBodyTypeMap) 611 { 612 this.faultBodyTypeMap = faultBodyTypeMap; 613 } 614 } 616 617 protected static class HeaderPart 618 { 619 private String part; 620 private QName message; 621 private int flags; 622 623 public HeaderPart(String part, QName message, int type) 624 { 625 this.part = part; 626 this.message = message; 627 this.flags = type; 628 } 629 630 public String getPartName() 631 { 632 return part; 633 } 634 635 public QName getMessageQName() 636 { 637 return message; 638 } 639 640 public int getFlags() 641 { 642 return flags; 643 } 644 645 public String toString() 646 { 647 return "[part=" + part + ",message=" + message + ",flags=" + flags + "]"; 648 } 649 } 651 } | Popular Tags |