KickJava   Java API By Example, From Geeks To Geeks.

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


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.GlobalComplexType;
24 import org.netbeans.modules.xml.schema.model.GlobalComplexType.Block;
25 import org.netbeans.modules.xml.schema.model.GlobalComplexType.Final;
26 import org.netbeans.modules.xml.schema.model.SchemaComponent;
27 import org.netbeans.modules.xml.schema.model.SchemaModel;
28 import org.netbeans.modules.xml.schema.model.visitor.SchemaVisitor;
29 import org.w3c.dom.Element JavaDoc;
30
31
32 /**
33  *
34  * @author rico
35  */

36 public class GlobalComplexTypeImpl extends CommonComplexTypeImpl implements GlobalComplexType{
37     
38     /** Creates a new instance of GlobalComplexTypeImpl */
39     public GlobalComplexTypeImpl(SchemaModelImpl model) {
40         super(model,createNewComponent(SchemaElements.COMPLEX_TYPE, model));
41     }
42     
43     public GlobalComplexTypeImpl(SchemaModelImpl model, Element JavaDoc el){
44         super(model,el);
45     }
46
47     /**
48      *
49      *
50      */

51     public Class JavaDoc<? extends SchemaComponent> getComponentType()
52     {
53         return GlobalComplexType.class;
54     }
55     
56     public void setName(String JavaDoc name) {
57         setAttribute(NAME_PROPERTY, SchemaAttributes.NAME, name);
58     }
59     
60     public String JavaDoc getName() {
61         return getAttribute(SchemaAttributes.NAME);
62     }
63     
64     public void setFinal(Set JavaDoc<Final> finalValue) {
65         setAttribute(FINAL_PROPERTY, SchemaAttributes.FINAL,
66                 finalValue == null ? null :
67                     Util.convertEnumSet(Final.class, finalValue));
68     }
69     
70     public Set JavaDoc<Final> getFinal() {
71         String JavaDoc s = getAttribute(SchemaAttributes.FINAL);
72         return s == null ? null : Util.valuesOf(Final.class, s);
73     }
74     
75     public void setBlock(Set JavaDoc<Block> block) {
76         setAttribute(BLOCK_PROPERTY, SchemaAttributes.BLOCK,
77                 block == null ? null :
78                     Util.convertEnumSet(Block.class, block));
79     }
80     
81     public Set JavaDoc<Block> getBlock() {
82         String JavaDoc s = getAttribute(SchemaAttributes.BLOCK);
83         return s == null ? null : Util.valuesOf(Block.class, s);
84     }
85     
86     public Set JavaDoc<Final> getFinalEffective() {
87         Set JavaDoc<Final> v = getFinal();
88         return v == null ? getFinalDefault() : v;
89     }
90
91     public Set JavaDoc<Final> getFinalDefault() {
92         return Util.convertEnumSet(Final.class, getModel().getSchema().getFinalDefaultEffective());
93     }
94
95     public Set JavaDoc<Block> getBlockEffective() {
96         Set JavaDoc<Block> v = getBlock();
97         return v == null ? getBlockDefault() : v;
98     }
99
100     public Set JavaDoc<Block> getBlockDefault() {
101         return Util.convertEnumSet(Block.class, getModel().getSchema().getBlockDefaultEffective());
102     }
103
104     public void setAbstract(Boolean JavaDoc isAbstract) {
105         setAttribute(ABSTRACT_PROPERTY, SchemaAttributes.ABSTRACT, isAbstract);
106     }
107     
108     public Boolean JavaDoc isAbstract() {
109         String JavaDoc s = getAttribute(SchemaAttributes.ABSTRACT);
110         return s == null ? null : Boolean.valueOf(s);
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             case BLOCK:
122                 return Block.class;
123             default:
124                 return super.getAttributeMemberType(attr);
125         }
126     }
127
128     public boolean getEffectiveAbstract() {
129         Boolean JavaDoc v = isAbstract();
130         return v == null ? getAbstractDefault() : v;
131     }
132
133     public boolean getAbstractDefault() {
134         return false;
135     }
136
137     public boolean getAbstractEffective() {
138         Boolean JavaDoc v = isAbstract();
139         return v == null ? getAbstractDefault() : v;
140     }
141 }
142
Popular Tags