1 19 package org.netbeans.modules.xml.wsdl.model.spi; 20 21 import java.io.IOException ; 22 import java.util.ArrayList ; 23 import java.util.Collections ; 24 import java.util.List ; 25 import javax.xml.namespace.QName ; 26 import org.netbeans.modules.xml.wsdl.model.ExtensibilityElement; 27 import org.netbeans.modules.xml.wsdl.model.WSDLComponent; 28 import org.netbeans.modules.xml.wsdl.model.WSDLModel; 29 import org.netbeans.modules.xml.wsdl.model.visitor.WSDLVisitor; 30 import org.netbeans.modules.xml.xam.Component; 31 import org.netbeans.modules.xml.xam.dom.Attribute; 32 import org.w3c.dom.Element ; 33 34 38 public class GenericExtensibilityElement extends WSDLComponentBase implements ExtensibilityElement.ParentSelector { 39 40 41 public GenericExtensibilityElement(WSDLModel model, Element e) { 42 super(model, e); 43 } 44 45 public GenericExtensibilityElement(WSDLModel model, QName qname){ 46 this(model, createNewElement(qname, model)); 47 } 48 49 public void accept(WSDLVisitor visitor) { 50 visitor.visit(this); 51 } 52 53 public static class StringAttribute implements Attribute { 54 private String name; 55 public StringAttribute(String name) { this.name = name; } 56 public Class getType() { return String .class; } 57 public String getName() { return name; } 58 public Class getMemberType() { return null; } 59 } 60 61 public String getAttribute(String attribute) { 62 return getAttribute(new StringAttribute(attribute)); 63 } 64 public void setAttribute(String attribute, String value) { 65 setAttribute(attribute, new StringAttribute(attribute), value); 66 } 67 68 public String getContentFragment() { 69 return super.getXmlFragment(); 70 } 71 72 public void setContentFragment(String text) throws IOException { 73 super.setXmlFragment(CONTENT_FRAGMENT_PROPERTY, text); 74 } 75 76 public void addAnyElement(ExtensibilityElement anyElement, int index) { 77 List <WSDLComponent> all = getChildren(); 78 if (index > all.size() || index < 0) { 79 throw new ArrayIndexOutOfBoundsException (index); 80 } 81 insertAtIndex(EXTENSIBILITY_ELEMENT_PROPERTY, anyElement, index); 82 } 83 84 public void removeAnyElement(ExtensibilityElement any) { 85 super.removeExtensibilityElement(any); 86 } 87 88 public List <ExtensibilityElement> getAnyElements() { 89 List <ExtensibilityElement> result = new ArrayList <ExtensibilityElement>(); 90 List <ExtensibilityElement> allEEs = super.getExtensibilityElements(); 91 for (ExtensibilityElement ee : allEEs) { 92 if (! ee.getModel().getQNames().contains(ee.getQName())) { 93 result.add(ee); 94 } 95 } 96 return Collections.unmodifiableList(result); 97 } 98 99 102 public boolean canBeAddedTo(Component target) { 103 if (target instanceof WSDLComponent) { 104 return true; 105 } 106 return false; 107 } 108 } 109 | Popular Tags |