KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jibx > binding > model > TemplateElement


1 /*
2 Copyright (c) 2004-2005, Dennis M. Sosnoski
3 All rights reserved.
4
5 Redistribution and use in source and binary forms, with or without modification,
6 are permitted provided that the following conditions are met:
7
8  * Redistributions of source code must retain the above copyright notice, this
9    list of conditions and the following disclaimer.
10  * Redistributions in binary form must reproduce the above copyright notice,
11    this list of conditions and the following disclaimer in the documentation
12    and/or other materials provided with the distribution.
13  * Neither the name of JiBX nor the names of its contributors may be used
14    to endorse or promote products derived from this software without specific
15    prior written permission.
16
17 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
18 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
21 ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
22 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
24 ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
26 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */

28
29 package org.jibx.binding.model;
30
31 /**
32  * Model component for <b>template</b> element of binding definition.
33  *
34  * @author Dennis M. Sosnoski
35  * @version 1.0
36  */

37  
38 public class TemplateElement extends TemplateElementBase
39 {
40     /** Template label. */
41     private String JavaDoc m_label;
42     
43     /** Default template for type flag. */
44     private boolean m_isDefault;
45     
46     /** Schema type name for xsi:type. */
47     private NameAttributes m_typeNameAttrs;
48     
49     /** Base schema type name for xsi:type. */
50     private NameAttributes m_baseNameAttrs;
51
52     /** Base template extended by this one. */
53     private TemplateElement m_extendsMapping;
54     
55     /**
56      * Default constructor.
57      */

58     public TemplateElement() {
59         super(TEMPLATE_ELEMENT);
60         m_typeNameAttrs = new NameAttributes();
61     }
62     
63     /**
64      * Get template label.
65      *
66      * @return template label (<code>null</code> if none)
67      */

68     public String JavaDoc getLabel() {
69         return m_label;
70     }
71     
72     /**
73      * Set template label.
74      *
75      * @param label template label (<code>null</code> if none)
76      */

77     public void setLabel(String JavaDoc label) {
78         m_label = label;
79     }
80     
81     /**
82      * Check if default template for type.
83      *
84      * @return <code>true</code> if default for type, <code>false</code> if not
85      */

86     public boolean isDefaultTemplate() {
87         return m_isDefault;
88     }
89     
90     /**
91      * Set default template for type flag.
92      *
93      * @param dflt <code>true</code> if default for type, <code>false</code> if
94      * not
95      */

96     public void setDefaultTemplate(boolean dflt) {
97         m_isDefault = dflt;
98     }
99     
100     //
101
// Type name attribute delegate methods
102

103     /**
104      * Get type name.
105      *
106      * @return type name text
107      */

108     public String JavaDoc getTypeName() {
109         return m_typeNameAttrs.getName();
110     }
111     
112     /**
113      * Set type name.
114      *
115      * @param name text for type name
116      */

117     public void setTypeName(String JavaDoc name) {
118         m_typeNameAttrs.setName(name);
119     }
120     
121     /**
122      * Get namespace URI specified for type.
123      *
124      * @return type namespace URI (<code>null</code> if not set)
125      */

126     public String JavaDoc getTypeUri() {
127         return m_typeNameAttrs.getUri();
128     }
129     
130     /**
131      * Set type namespace URI.
132      *
133      * @param uri type namespace URI (<code>null</code> if not set)
134      */

135     public void setTypeUri(String JavaDoc uri) {
136         m_typeNameAttrs.setUri(uri);
137     }
138     
139     /**
140      * Get namespace prefix specified for type.
141      *
142      * @return type namespace prefix (<code>null</code> if not set)
143      */

144     public String JavaDoc getTypePrefix() {
145         return m_typeNameAttrs.getPrefix();
146     }
147     
148     /**
149      * Set type namespace prefix.
150      *
151      * @param type prefix namespace prefix (<code>null</code> if not set)
152      */

153     public void setTypePrefix(String JavaDoc prefix) {
154         m_typeNameAttrs.setPrefix(prefix);
155     }
156     
157     /**
158      * Get effective namespace information for type. This call is only
159      * meaningful after validation.
160      *
161      * @return effective namespace information
162      */

163     public NamespaceElement getTypeNamespace() {
164         return m_typeNameAttrs.getNamespace();
165     }
166     
167     /**
168      * Get template extended by this one.
169      *
170      * @return template extended by this one
171      */

172     public TemplateElement getExtendsMapping() {
173         return m_extendsMapping;
174     }
175     
176     //
177
// Base type name attribute delegate methods
178

179     /**
180      * Get base type name.
181      *
182      * @return base type name text
183      */

184     public String JavaDoc getBaseName() {
185         return m_baseNameAttrs.getName();
186     }
187     
188     /**
189      * Set base type name.
190      *
191      * @param name text for base type name
192      */

193     public void setBaseName(String JavaDoc name) {
194         m_baseNameAttrs.setName(name);
195     }
196     
197     /**
198      * Get namespace URI specified for base type.
199      *
200      * @return base type namespace URI (<code>null</code> if not set)
201      */

202     public String JavaDoc getBaseUri() {
203         return m_baseNameAttrs.getUri();
204     }
205     
206     /**
207      * Set base type namespace URI.
208      *
209      * @param uri base type namespace URI (<code>null</code> if if not set)
210      */

211     public void setBaseUri(String JavaDoc uri) {
212         m_baseNameAttrs.setUri(uri);
213     }
214     
215     /**
216      * Get namespace URI specified for base type.
217      *
218      * @return base type namespace prefix (<code>null</code> if not set)
219      */

220     public String JavaDoc getBasePrefix() {
221         return m_baseNameAttrs.getPrefix();
222     }
223     
224     /**
225      * Set base type namespace prefix.
226      *
227      * @param type base type namespace prefix (<code>null</code> if not set)
228      */

229     public void setBasePrefix(String JavaDoc prefix) {
230         m_baseNameAttrs.setPrefix(prefix);
231     }
232     
233     /**
234      * Get effective namespace information for base type. This call is only
235      * meaningful after validation.
236      *
237      * @return effective namespace information
238      */

239     public NamespaceElement getBaseNamespace() {
240         return m_typeNameAttrs.getNamespace();
241     }
242     
243     //
244
// Validation methods
245

246     /**
247      * Prevalidate attributes of element in isolation.
248      *
249      * @param vctx validation context
250      */

251     public void prevalidate(ValidationContext vctx) {
252         m_typeNameAttrs.prevalidate(vctx);
253         super.prevalidate(vctx);
254     }
255 }
Popular Tags