KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > xml > wsdl > ui > extensibility > model > impl > WSDLExtensibilityElementInfoContainerImpl


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20 /*
21  * Created on May 25, 2005
22  *
23  * To change the template for this generated file go to
24  * Window - Preferences - Java - Code Generation - Code and Comments
25  */

26 package org.netbeans.modules.xml.wsdl.ui.extensibility.model.impl;
27
28 import java.util.ArrayList JavaDoc;
29 import java.util.Collection JavaDoc;
30 import java.util.List JavaDoc;
31 import java.util.logging.Logger JavaDoc;
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 /**
43  * @author radval
44  *
45  * To change the template for this generated type comment go to
46  * Window - Preferences - Java - Code Generation - Code and Comments
47  */

48 public class WSDLExtensibilityElementInfoContainerImpl implements WSDLExtensibilityElementInfoContainer {
49     
50     private static final Logger JavaDoc mLogger = Logger.getLogger(WSDLExtensibilityElementInfoContainerImpl.class.getName());
51     
52     
53     private DataObject mDataObject;
54     
55     private List JavaDoc<WSDLExtensibilityElementInfo> mElementInfos = new ArrayList JavaDoc<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 JavaDoc<WSDLExtensibilityElementInfo> getAllWSDLExtensibilityElementInfo() {
66         if(mElementInfos.size() != 0) {
67             return mElementInfos;
68         }
69         
70         //if folder then look for files in the folder
71
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 JavaDoc val = dObj.getPrimaryFile().getAttribute(Constants.XSD_FILE_NAME);
76                 XMLSchemaFileInfo schemaFileInfo = null;
77                 if(val instanceof String JavaDoc) {
78                     schemaFileInfo = this.mRootElement.getXMLSchemaFileInfoMatchingFileName((String JavaDoc) val);
79                 }
80                 
81                 WSDLExtensibilityElementInfo elementInfo = new WSDLExtensibilityElementInfoImpl(dObj, schemaFileInfo);
82                 mElementInfos.add(elementInfo);
83                 
84             }
85         } else {
86 // //if file then use it
87
// WSDLExtensibilityElementInfo elementInfo = new WSDLExtensibilityElementInfoImpl(mDataObject);
88
// mElementInfos.add(elementInfo);
89
}
90         
91         return mElementInfos;
92     }
93     
94     public List JavaDoc<WSDLExtensibilityElementInfo> getWSDLExtensibilityElementInfo(String JavaDoc namespace) {
95         List JavaDoc<WSDLExtensibilityElementInfo> allInfos = getAllWSDLExtensibilityElementInfo();
96         List JavaDoc<WSDLExtensibilityElementInfo> result = new ArrayList JavaDoc<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 JavaDoc getDisplayName() {
112         return mDataObject.getNodeDelegate().getDisplayName();
113     }
114     
115     public DataObject getDataObject() {
116         return mDataObject;
117     }
118     
119     public String JavaDoc getName() {
120         return mDataObject.getName();
121     }
122     
123 }
124
Popular Tags