KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > xml > schema > model > impl > GlobalElementImpl


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-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20 package org.netbeans.modules.xml.schema.model.impl;
21
22 import java.util.Set JavaDoc;
23 import org.netbeans.modules.xml.schema.model.GlobalElement;
24 import org.netbeans.modules.xml.schema.model.GlobalElement.Final;
25 import org.netbeans.modules.xml.schema.model.SchemaComponent;
26 import org.netbeans.modules.xml.schema.model.visitor.SchemaVisitor;
27 import org.netbeans.modules.xml.xam.dom.NamedComponentReference;
28 import org.w3c.dom.Element JavaDoc;
29 /**
30  *
31  * @author Vidhya Narayanan
32  */

33 public class GlobalElementImpl extends ElementImpl implements GlobalElement {
34
35     public GlobalElementImpl(SchemaModelImpl model) {
36         this(model,createNewComponent(SchemaElements.ELEMENT,model));
37     }
38     
39     /**
40      * Creates a new instance of GlobalElementImpl
41      */

42     public GlobalElementImpl(SchemaModelImpl model, Element el) {
43         super(model, el);
44     }
45
46     /**
47      *
48      *
49      */

50     public Class JavaDoc<? extends SchemaComponent> getComponentType() {
51         return GlobalElement.class;
52     }
53     
54     /**
55      *
56      */

57     public void setSubstitutionGroup(NamedComponentReference<GlobalElement> element) {
58     setAttribute(SUBSTITUTION_GROUP_PROPERTY, SchemaAttributes.SUBSTITUTION_GROUP, element);
59     }
60     
61     /**
62      *
63      */

64     public NamedComponentReference<GlobalElement> getSubstitutionGroup() {
65         return resolveGlobalReference(GlobalElement.class, SchemaAttributes.SUBSTITUTION_GROUP);
66     }
67     
68     /**
69      *
70      */

71     public void setAbstract(Boolean JavaDoc abstr) {
72         setAttribute(ABSTRACT_PROPERTY, SchemaAttributes.ABSTRACT, abstr);
73     }
74     
75     /**
76      *
77      */

78     public Boolean JavaDoc isAbstract() {
79         String JavaDoc s = getAttribute(SchemaAttributes.ABSTRACT);
80         return s == null ? null : Boolean.valueOf(s);
81     }
82     
83
84     public boolean getAbstractEffective() {
85         Boolean JavaDoc v = isAbstract();
86         return v == null ? getAbstractDefault() : v;
87     }
88
89     public boolean getAbstractDefault() {
90         return false;
91     }
92     
93     public void setFinal(Set JavaDoc<Final> finalValue) {
94         setAttribute(FINAL_PROPERTY, SchemaAttributes.FINAL,
95                 finalValue == null ? null :
96                     Util.convertEnumSet(Final.class, finalValue));
97     }
98     
99     public Set JavaDoc<Final> getFinal() {
100         String JavaDoc s = getAttribute(SchemaAttributes.FINAL);
101         return s == null ? null : Util.valuesOf(Final.class, s);
102     }
103     
104     public Set JavaDoc<Final> getFinalEffective() {
105         Set JavaDoc<Final> v = getFinal();
106         return v == null ? getFinalDefault() : v;
107     }
108
109     public Set JavaDoc<Final> getFinalDefault() {
110         return Util.convertEnumSet(Final.class, getModel().getSchema().getFinalDefaultDefault());
111     }
112
113     public void accept(SchemaVisitor visitor) {
114         visitor.visit(this);
115     }
116  
117     protected Class JavaDoc getAttributeMemberType(SchemaAttributes attr) {
118         switch(attr) {
119             case FINAL:
120                 return Final.class;
121             default:
122                 return super.getAttributeMemberType(attr);
123         }
124     }
125 }
126
Popular Tags