1 19 20 26 package org.netbeans.modules.xml.wsdl.ui.extensibility.model.impl; 27 28 import java.util.ArrayList ; 29 import java.util.Collection ; 30 import java.util.List ; 31 import java.util.logging.Logger ; 32 import org.netbeans.modules.xml.schema.model.Schema; 33 import org.netbeans.modules.xml.wsdl.ui.common.Constants; 34 35 import org.netbeans.modules.xml.wsdl.ui.extensibility.model.WSDLExtensibilityElementInfo; 36 import org.netbeans.modules.xml.wsdl.ui.extensibility.model.WSDLExtensibilityElementInfoContainer; 37 import org.netbeans.modules.xml.wsdl.ui.extensibility.model.XMLSchemaFileInfo; 38 import org.openide.loaders.DataFolder; 39 import org.openide.loaders.DataObject; 40 41 42 48 public class WSDLExtensibilityElementInfoContainerImpl implements WSDLExtensibilityElementInfoContainer { 49 50 private static final Logger mLogger = Logger.getLogger(WSDLExtensibilityElementInfoContainerImpl.class.getName()); 51 52 53 private DataObject mDataObject; 54 55 private List <WSDLExtensibilityElementInfo> mElementInfos = new ArrayList <WSDLExtensibilityElementInfo>(); 56 57 private WSDLExtensibilityElementsImpl mRootElement; 58 59 60 public WSDLExtensibilityElementInfoContainerImpl(DataObject dataObject, WSDLExtensibilityElementsImpl element) { 61 this.mDataObject = dataObject; 62 this.mRootElement = element; 63 } 64 65 public List <WSDLExtensibilityElementInfo> getAllWSDLExtensibilityElementInfo() { 66 if(mElementInfos.size() != 0) { 67 return mElementInfos; 68 } 69 70 if(this.mDataObject instanceof DataFolder) { 72 DataObject[] children = ((DataFolder)this.mDataObject).getChildren(); 73 for(int i = 0; i < children.length; i++ ) { 74 DataObject dObj = children[i]; 75 Object val = dObj.getPrimaryFile().getAttribute(Constants.XSD_FILE_NAME); 76 XMLSchemaFileInfo schemaFileInfo = null; 77 if(val instanceof String ) { 78 schemaFileInfo = this.mRootElement.getXMLSchemaFileInfoMatchingFileName((String ) val); 79 } 80 81 WSDLExtensibilityElementInfo elementInfo = new WSDLExtensibilityElementInfoImpl(dObj, schemaFileInfo); 82 mElementInfos.add(elementInfo); 83 84 } 85 } else { 86 } 90 91 return mElementInfos; 92 } 93 94 public List <WSDLExtensibilityElementInfo> getWSDLExtensibilityElementInfo(String namespace) { 95 List <WSDLExtensibilityElementInfo> allInfos = getAllWSDLExtensibilityElementInfo(); 96 List <WSDLExtensibilityElementInfo> result = new ArrayList <WSDLExtensibilityElementInfo>(); 97 for (WSDLExtensibilityElementInfo eInfo : allInfos) { 98 Schema schema = eInfo.getSchema(); 99 if(schema != null) { 100 if(namespace != null) { 101 if(namespace.equals(schema.getTargetNamespace())) { 102 result.add(eInfo); 103 } 104 } 105 } 106 } 107 108 return result; 109 } 110 111 public String getDisplayName() { 112 return mDataObject.getNodeDelegate().getDisplayName(); 113 } 114 115 public DataObject getDataObject() { 116 return mDataObject; 117 } 118 119 public String getName() { 120 return mDataObject.getName(); 121 } 122 123 } 124 | Popular Tags |