KickJava   Java API By Example, From Geeks To Geeks.

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


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 org.netbeans.modules.xml.schema.model.Form;
23 import org.netbeans.modules.xml.schema.model.GlobalElement;
24 import org.netbeans.modules.xml.schema.model.LocalElement;
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  *
32  * @author Vidhya Narayanan
33  */

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

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

50     public void setForm(Form f) {
51         setAttribute(LocalElement.FORM_PROPERTY, SchemaAttributes.FORM, f);
52     }
53     
54     /**
55      *
56      */

57     public void setRef(NamedComponentReference<GlobalElement> ref) {
58         setAttribute(LocalElement.REF_PROPERTY, SchemaAttributes.REF, ref);
59     }
60     
61     /**
62      *
63      */

64     public void setMinOccurs(Integer JavaDoc min) {
65         setAttribute(LocalElement.MIN_OCCURS_PROPERTY, SchemaAttributes.MIN_OCCURS, min);
66     }
67     
68     /**
69      *
70      */

71     public void setMaxOccurs(String JavaDoc max) {
72         setAttribute(LocalElement.MAX_OCCURS_PROPERTY, SchemaAttributes.MAX_OCCURS, max);
73     }
74     
75     /**
76      *
77      */

78     public NamedComponentReference<GlobalElement> getRef() {
79         return resolveGlobalReference(GlobalElement.class, SchemaAttributes.REF);
80     }
81     
82     /**
83      *
84      */

85     public Integer JavaDoc getMinOccurs() {
86         String JavaDoc s = getAttribute(SchemaAttributes.MIN_OCCURS);
87         return s == null ? null : Integer.valueOf(s);
88     }
89     
90     /**
91      *
92      */

93     public String JavaDoc getMaxOccurs() {
94         return getAttribute(SchemaAttributes.MAX_OCCURS);
95     }
96     
97     /**
98      *
99      */

100     public Form getForm() {
101         String JavaDoc s = super.getAttribute(SchemaAttributes.FORM);
102         return s == null ? null : Util.parse(Form.class, s);
103     }
104     
105     public int getMinOccursEffective() {
106         Integer JavaDoc v = getMinOccurs();
107         return v == null ? getMinOccursDefault() : v;
108     }
109
110     public int getMinOccursDefault() {
111         return 1;
112     }
113
114     public String JavaDoc getMaxOccursEffective() {
115         String JavaDoc v = getMaxOccurs();
116         return v == null ? getMaxOccursDefault() : v;
117     }
118
119     public String JavaDoc getMaxOccursDefault() {
120         return String.valueOf(1);
121     }
122
123     public Form getFormEffective() {
124         Form v = getForm();
125         return v == null ? getFormDefault() : v;
126     }
127
128     public Form getFormDefault() {
129         return getModel().getSchema().getElementFormDefaultEffective();
130     }
131 }
132
Popular Tags