KickJava   Java API By Example, From Geeks To Geeks.

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


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

33 public class GlobalSimpleTypeImpl extends CommonSimpleTypeImpl implements GlobalSimpleType{
34
35     /** Creates a new instance of GlobalSimpleTypeImpl */
36     public GlobalSimpleTypeImpl(SchemaModelImpl model) {
37         this(model,createNewComponent(SchemaElements.SIMPLE_TYPE,model));
38     }
39     
40     public GlobalSimpleTypeImpl(SchemaModelImpl model, Element JavaDoc e) {
41         super(model,e);
42     }
43
44     /**
45      *
46      *
47      */

48     public Class JavaDoc<? extends SchemaComponent> getComponentType() {
49         return GlobalSimpleType.class;
50     }
51     
52     protected Class JavaDoc getAttributeMemberType(SchemaAttributes attribute) {
53         switch(attribute) {
54             case FINAL:
55                 return Final.class;
56             default:
57                 return super.getAttributeType(attribute);
58         }
59     }
60     
61     //setters/getters of attributes
62
public void setName(String JavaDoc name) {
63         setAttribute(NAME_PROPERTY, SchemaAttributes.NAME, name);
64     }
65     
66     
67     public String JavaDoc getName() {
68         return getAttribute(SchemaAttributes.NAME);
69     }
70     
71     public void setFinal(Set JavaDoc<Final> finalValue) {
72         setAttribute(FINAL_PROPERTY, SchemaAttributes.FINAL,
73                 finalValue == null ? null :
74                     Util.convertEnumSet(Final.class, finalValue));
75     }
76     
77     public Set JavaDoc<Final> getFinal() {
78         String JavaDoc s = getAttribute(SchemaAttributes.FINAL);
79         return s == null ? null : Util.valuesOf(Final.class, s);
80     }
81  
82     public Set JavaDoc<Final> getFinalEffective() {
83         Set JavaDoc<Final> v = getFinal();
84         return v == null ? getFinalDefault() : v;
85     }
86
87     public Set JavaDoc<Final> getFinalDefault() {
88         return Util.convertEnumSet(Final.class, getModel().getSchema().getFinalDefaultEffective());
89     }
90
91     public void accept(SchemaVisitor visitor) {
92         visitor.visit(this);
93     }
94 }
95
Popular Tags