KickJava   Java API By Example, From Geeks To Geeks.

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


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.Collection JavaDoc;
29 import java.util.Iterator JavaDoc;
30 import java.util.logging.Logger JavaDoc;
31
32 import org.netbeans.modules.xml.schema.model.GlobalElement;
33 import org.netbeans.modules.xml.schema.model.Schema;
34 import org.netbeans.modules.xml.wsdl.ui.common.Constants;
35 import org.netbeans.modules.xml.wsdl.ui.extensibility.model.WSDLExtensibilityElementInfo;
36 import org.netbeans.modules.xml.wsdl.ui.extensibility.model.XMLSchemaFileInfo;
37 import org.openide.loaders.DataFolder;
38 import org.openide.loaders.DataObject;
39
40
41 /**
42  * @author radval
43  *
44  * To change the template for this generated type comment go to
45  * Window - Preferences - Java - Code Generation - Code and Comments
46  */

47 public class WSDLExtensibilityElementInfoImpl implements WSDLExtensibilityElementInfo {
48
49     private static final Logger JavaDoc mLogger = Logger.getLogger(WSDLExtensibilityElementInfoImpl.class.getName());
50     
51     private DataObject mDataObject;
52     
53     private Schema mSchema;
54     
55     private XMLSchemaFileInfo mSchemaFileInfo = null;
56     
57     public WSDLExtensibilityElementInfoImpl(DataObject dataObject, XMLSchemaFileInfo schemaFileInfo) {
58         this.mDataObject = dataObject;
59         if ((dataObject instanceof DataFolder) && dataObject.getPrimaryFile().hasExt(Constants.XSD_EXT)) {
60             this.mSchema = ExtensibilityUtils.readSchema(dataObject);
61         }
62         this.mSchemaFileInfo = schemaFileInfo;
63     }
64     
65     public String JavaDoc getElementName() {
66         Object JavaDoc val = mDataObject.getPrimaryFile().getAttribute(Constants.ELEMENT);
67         if(val instanceof String JavaDoc) {
68             return (String JavaDoc) val;
69         }
70         
71         return null;
72     }
73     
74     public GlobalElement getElement() {
75         String JavaDoc name = getElementName();
76         if(name != null && getSchema() != null) {
77             Collection JavaDoc elements = getSchema().getElements();
78             Iterator JavaDoc iter = elements.iterator();
79             while (iter.hasNext()) {
80                 GlobalElement elem = (GlobalElement) iter.next();
81                 if (elem.getName().equals(name)) {
82                     return elem;
83                 }
84             }
85         }
86         
87         return null;
88     }
89     
90     public DataObject getDataObject() {
91         return mDataObject;
92     }
93     
94     public Schema getSchema() {
95         if(mSchema != null) {
96             return mSchema;
97         } else if(mSchemaFileInfo != null) {
98             return mSchemaFileInfo.getSchema();
99         }
100         
101         return null;
102     }
103     
104     public String JavaDoc getPrefix() {
105         Object JavaDoc val = mDataObject.getPrimaryFile().getAttribute(Constants.PREFIX);
106         if(val instanceof String JavaDoc) {
107             return (String JavaDoc) val;
108         } else if(mSchemaFileInfo != null) {
109             return mSchemaFileInfo.getPrefix();
110         }
111         
112         return null;
113     }
114     
115 }
116
Popular Tags