1 19 package org.netbeans.modules.xml.wsdl.model.extensions.soap.impl; 20 21 import org.netbeans.modules.xml.wsdl.model.extensions.soap.SOAPAddress; 22 import org.netbeans.modules.xml.wsdl.model.extensions.soap.SOAPBinding; 23 import org.netbeans.modules.xml.wsdl.model.extensions.soap.SOAPBody; 24 import org.netbeans.modules.xml.wsdl.model.extensions.soap.SOAPComponent; 25 import org.netbeans.modules.xml.wsdl.model.extensions.soap.SOAPFault; 26 import org.netbeans.modules.xml.wsdl.model.extensions.soap.SOAPHeader; 27 import org.netbeans.modules.xml.wsdl.model.extensions.soap.SOAPHeaderFault; 28 import org.netbeans.modules.xml.wsdl.model.extensions.soap.SOAPOperation; 29 import org.netbeans.modules.xml.xam.Component; 30 import org.netbeans.modules.xml.xam.ComponentUpdater; 31 import org.netbeans.modules.xml.xam.ComponentUpdater.Operation; 32 import org.netbeans.modules.xml.xam.ComponentUpdater.Query; 33 34 38 public class SOAPComponentUpdater implements ComponentUpdater<SOAPComponent>, Query<SOAPComponent>, SOAPComponent.Visitor { 39 private SOAPComponent parent; 40 private Operation operation; 41 private boolean canAdd; 42 43 44 public SOAPComponentUpdater() { 45 } 46 47 public boolean canAdd(SOAPComponent target, Component child) { 48 if (!(child instanceof SOAPComponent)) return false; 49 update(target, (SOAPComponent) child, null); 50 return canAdd; 51 } 52 53 public void update(SOAPComponent target, SOAPComponent child, Operation operation) { 54 update(target, child, -1, operation); 55 } 56 57 58 public void update(SOAPComponent target, SOAPComponent child, int index, Operation operation) { 59 parent = target; 60 this.operation = operation; 61 child.accept(this); 62 } 63 64 public void visit(SOAPOperation child) { 65 if (operation == null) { 67 canAdd = false; 68 } 69 } 70 71 public void visit(SOAPBinding child) { 72 if (operation == null) { 74 canAdd = false; 75 } 76 } 77 78 public void visit(SOAPHeader child) { 79 if (operation == null) { 81 canAdd = false; 82 } 83 } 84 85 public void visit(SOAPBody child) { 86 if (operation == null) { 88 canAdd = false; 89 } 90 } 91 92 public void visit(SOAPFault child) { 93 if (operation == null) { 95 canAdd = false; 96 } 97 } 98 99 public void visit(SOAPHeaderFault child) { 100 SOAPHeader target = (SOAPHeader) parent; 101 if (operation == Operation.ADD) { 102 target.addSOAPHeaderFault(child); 103 } else if (operation == Operation.REMOVE) { 104 target.removeSOAPHeaderFault(child); 105 } else if (operation == null) { 106 canAdd = true; 107 } 108 } 109 110 public void visit(SOAPAddress child) { 111 if (operation == null) { 113 canAdd = false; 114 } 115 } 116 117 } 118 | Popular Tags |