1 19 package org.netbeans.modules.xml.wsdl.model.extensions.soap.impl; 20 21 import org.netbeans.modules.xml.wsdl.model.BindingInput; 22 import org.netbeans.modules.xml.wsdl.model.BindingOutput; 23 import org.netbeans.modules.xml.wsdl.model.Input; 24 import org.netbeans.modules.xml.wsdl.model.Message; 25 import org.netbeans.modules.xml.wsdl.model.Output; 26 import org.netbeans.modules.xml.wsdl.model.Part; 27 import org.netbeans.modules.xml.wsdl.model.extensions.soap.SOAPBody; 28 import org.netbeans.modules.xml.wsdl.model.extensions.soap.SOAPHeaderBase; 29 import org.netbeans.modules.xml.xam.dom.AbstractDocumentComponent; 30 import org.netbeans.modules.xml.xam.AbstractReference; 31 import org.netbeans.modules.xml.xam.Reference; 32 33 37 public class PartReference extends AbstractReference<Part> implements Reference<Part> { 38 39 public PartReference(Part referenced, AbstractDocumentComponent parent) { 40 super(referenced, Part.class, parent); 41 } 42 43 public PartReference(AbstractDocumentComponent parent, String ref){ 45 super(Part.class, parent, ref); 46 } 47 48 public String getRefString() { 49 if (refString == null) { 50 refString = getReferenced().getName(); 51 } 52 return refString; 53 } 54 55 public SOAPBodyImpl getBodyParent() { 56 if (getParent() instanceof SOAPBodyImpl) { 57 return (SOAPBodyImpl) getParent(); 58 } else { 59 return null; 60 } 61 } 62 63 public SOAPHeaderBaseImpl getHeaderParent() { 64 if (getParent() instanceof SOAPHeaderBaseImpl) { 65 return (SOAPHeaderBaseImpl) getParent(); 66 } else { 67 return null; 68 } 69 } 70 71 public Part get() { 72 if (getReferenced() == null) { 73 Message m = null; 74 if (getBodyParent() != null) { 75 SOAPBody p = getBodyParent(); 76 if (p.getParent() instanceof BindingInput) { 77 BindingInput bi = (BindingInput)p.getParent(); 78 if (bi.getInput() != null) { 79 Input in = bi.getInput().get(); 80 if (in != null) { 81 m = in.getMessage().get(); 82 } 83 } 84 } else if (p.getParent() instanceof BindingOutput) { 85 BindingOutput bo = (BindingOutput)p.getParent(); 86 if (bo.getOutput() != null) { 87 Output out = bo.getOutput().get(); 88 if (out != null) { 89 m = out.getMessage().get(); 90 } 91 } 92 } 93 94 } else if (getHeaderParent() != null) { 95 SOAPHeaderBase header = getHeaderParent(); 96 if (header.getMessage() != null) { 97 m = header.getMessage().get(); 98 } 99 } 100 if (m != null) { 101 for (Part part : m.getParts()) { 102 if (part.getName().equals(getRefString())) { 103 setReferenced(part); 104 break; 105 } 106 } 107 } 108 } 109 return getReferenced(); 110 } 111 } 112 | Popular Tags |