KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > xslt > model > impl > XslComponentFactoryImpl


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

19
20 package org.netbeans.modules.xslt.model.impl;
21
22 import org.netbeans.modules.xslt.model.ApplyTemplates;
23 import org.netbeans.modules.xslt.model.Attribute;
24 import org.netbeans.modules.xslt.model.AttributeSet;
25 import org.netbeans.modules.xslt.model.CallTemplate;
26 import org.netbeans.modules.xslt.model.Choose;
27 import org.netbeans.modules.xslt.model.Copy;
28 import org.netbeans.modules.xslt.model.CopyOf;
29 import org.netbeans.modules.xslt.model.Document;
30 import org.netbeans.modules.xslt.model.Element;
31 import org.netbeans.modules.xslt.model.ForEach;
32 import org.netbeans.modules.xslt.model.If;
33 import org.netbeans.modules.xslt.model.Import;
34 import org.netbeans.modules.xslt.model.Include;
35 import org.netbeans.modules.xslt.model.Key;
36 import org.netbeans.modules.xslt.model.LiteralResultElement;
37 import org.netbeans.modules.xslt.model.Namespace;
38 import org.netbeans.modules.xslt.model.Number;
39 import org.netbeans.modules.xslt.model.Otherwise;
40 import org.netbeans.modules.xslt.model.Output;
41 import org.netbeans.modules.xslt.model.Param;
42 import org.netbeans.modules.xslt.model.Sequence;
43 import org.netbeans.modules.xslt.model.Sort;
44 import org.netbeans.modules.xslt.model.Stylesheet;
45 import org.netbeans.modules.xslt.model.Template;
46 import org.netbeans.modules.xslt.model.Text;
47 import org.netbeans.modules.xslt.model.ValueOf;
48 import org.netbeans.modules.xslt.model.Variable;
49 import org.netbeans.modules.xslt.model.When;
50 import org.netbeans.modules.xslt.model.XslComponent;
51 import org.netbeans.modules.xslt.model.XslComponentFactory;
52
53
54 /**
55  * @author ads
56  *
57  */

58 class XslComponentFactoryImpl implements XslComponentFactory {
59
60     XslComponentFactoryImpl( XslModelImpl model ) {
61         myModel = model;
62         myBuilder = new ThreadLocal JavaDoc<XslComponentsBuildVisitor>();
63     }
64
65     /* (non-Javadoc)
66      * @see org.netbeans.modules.xslt.model.XslComponentFactory#createApplyTemplates()
67      */

68     public ApplyTemplates createApplyTemplates() {
69         return new ApplyTemplatesImpl( getModel() );
70     }
71
72     /* (non-Javadoc)
73      * @see org.netbeans.modules.xslt.model.XslComponentFactory#createAttribute()
74      */

75     public Attribute createAttribute() {
76         return new AttributeImpl( getModel() );
77     }
78
79     /* (non-Javadoc)
80      * @see org.netbeans.modules.xslt.model.XslComponentFactory#createAttributeSet()
81      */

82     public AttributeSet createAttributeSet() {
83         return new AttributeSetImpl( getModel() );
84     }
85
86     /* (non-Javadoc)
87      * @see org.netbeans.modules.xslt.model.XslComponentFactory#createCallTemplate()
88      */

89     public CallTemplate createCallTemplate() {
90         return new CallTemplateImpl( getModel() );
91     }
92
93     /* (non-Javadoc)
94      * @see org.netbeans.modules.xslt.model.XslComponentFactory#createChoose()
95      */

96     public Choose createChoose() {
97         return new ChooseImpl( getModel() );
98     }
99
100     /* (non-Javadoc)
101      * @see org.netbeans.modules.xslt.model.XslComponentFactory#createCopy()
102      */

103     public Copy createCopy() {
104         return new CopyImpl( getModel() );
105     }
106
107     /* (non-Javadoc)
108      * @see org.netbeans.modules.xslt.model.XslComponentFactory#createCopyOf()
109      */

110     public CopyOf createCopyOf() {
111         return new CopyOfImpl( getModel() );
112     }
113
114     /* (non-Javadoc)
115      * @see org.netbeans.modules.xslt.model.XslComponentFactory#createDocument()
116      */

117     public Document createDocument() {
118         return new DocumentImpl( getModel() );
119     }
120
121     /* (non-Javadoc)
122      * @see org.netbeans.modules.xslt.model.XslComponentFactory#createElement()
123      */

124     public Element createElement() {
125         return new ElementImpl( getModel() );
126     }
127
128     /* (non-Javadoc)
129      * @see org.netbeans.modules.xslt.model.XslComponentFactory#createForEach()
130      */

131     public ForEach createForEach() {
132         return new ForEachImpl( getModel() );
133     }
134
135     /* (non-Javadoc)
136      * @see org.netbeans.modules.xslt.model.XslComponentFactory#createIf()
137      */

138     public If createIf() {
139         return new IfImpl( getModel() );
140     }
141
142     /* (non-Javadoc)
143      * @see org.netbeans.modules.xslt.model.XslComponentFactory#createInclude()
144      */

145     public Include createInclude() {
146         return new IncludeImpl( getModel() );
147     }
148
149     /* (non-Javadoc)
150      * @see org.netbeans.modules.xslt.model.XslComponentFactory#createKey()
151      */

152     public Key createKey() {
153         return new KeyImpl( getModel() );
154     }
155
156     /* (non-Javadoc)
157      * @see org.netbeans.modules.xslt.model.XslComponentFactory#createLiteralResultElement()
158      */

159     public LiteralResultElement createLiteralResultElement( String JavaDoc name ,
160             String JavaDoc namespaceUri )
161     {
162         org.w3c.dom.Element JavaDoc element = getModel().getDocument().
163             createElementNS( namespaceUri, name );
164         return new LiteralResultElementImpl( getModel() , element );
165     }
166
167     /* (non-Javadoc)
168      * @see org.netbeans.modules.xslt.model.XslComponentFactory#createNamespace()
169      */

170     public Namespace createNamespace() {
171         return new NamespaceImpl( getModel() );
172     }
173
174     /* (non-Javadoc)
175      * @see org.netbeans.modules.xslt.model.XslComponentFactory#createNumber()
176      */

177     public Number JavaDoc createNumber() {
178         return new NumberImpl( getModel() );
179     }
180
181     /* (non-Javadoc)
182      * @see org.netbeans.modules.xslt.model.XslComponentFactory#createOtherwise()
183      */

184     public Otherwise createOtherwise() {
185         return new OtherwiseImpl( getModel() );
186     }
187
188     /* (non-Javadoc)
189      * @see org.netbeans.modules.xslt.model.XslComponentFactory#createOutput()
190      */

191     public Output createOutput() {
192         return new OutputImpl( getModel() );
193     }
194
195     /* (non-Javadoc)
196      * @see org.netbeans.modules.xslt.model.XslComponentFactory#createParam()
197      */

198     public Param createParam() {
199         return new ParamImpl( getModel() );
200     }
201
202     /* (non-Javadoc)
203      * @see org.netbeans.modules.xslt.model.XslComponentFactory#createSequence()
204      */

205     public Sequence createSequence() {
206         return new SequenceImpl( getModel() );
207     }
208
209     /* (non-Javadoc)
210      * @see org.netbeans.modules.xslt.model.XslComponentFactory#createSort()
211      */

212     public Sort createSort() {
213         return new SortImpl( getModel() );
214     }
215
216     /* (non-Javadoc)
217      * @see org.netbeans.modules.xslt.model.XslComponentFactory#createStylesheet()
218      */

219     public Stylesheet createStylesheet() {
220         return new StylesheetImpl( getModel() );
221     }
222
223     /* (non-Javadoc)
224      * @see org.netbeans.modules.xslt.model.XslComponentFactory#createTemplate()
225      */

226     public Template createTemplate() {
227         return new TemplateImpl( getModel() );
228     }
229
230     /* (non-Javadoc)
231      * @see org.netbeans.modules.xslt.model.XslComponentFactory#createText()
232      */

233     public Text createText() {
234         return new TextImpl( getModel() );
235     }
236
237     /* (non-Javadoc)
238      * @see org.netbeans.modules.xslt.model.XslComponentFactory#createValueOf()
239      */

240     public ValueOf createValueOf() {
241         return new ValueOfImpl( getModel() );
242     }
243
244     /* (non-Javadoc)
245      * @see org.netbeans.modules.xslt.model.XslComponentFactory#createVariable()
246      */

247     public Variable createVariable() {
248         return new VariableImpl( getModel() );
249     }
250
251     /* (non-Javadoc)
252      * @see org.netbeans.modules.xslt.model.XslComponentFactory#createWhen()
253      */

254     public When createWhen() {
255         return new WhenImpl( getModel() );
256     }
257
258     /* (non-Javadoc)
259      * @see org.netbeans.modules.xslt.model.XslComponentFactory#createImport()
260      */

261     public Import createImport() {
262         return new ImportImpl( getModel() );
263     }
264     
265     /* (non-Javadoc)
266      * @see org.netbeans.modules.xml.xam.dom.ComponentFactory#create(org.w3c.dom.Element, org.netbeans.modules.xml.xam.dom.DocumentComponent)
267      */

268     public XslComponent create( org.w3c.dom.Element JavaDoc child, XslComponent parent )
269     {
270         XslComponentsBuildVisitor visitor = getBuilder( );
271         return visitor.createSubComponent( parent , child );
272     }
273     
274     private XslComponentsBuildVisitor getBuilder() {
275         XslComponentsBuildVisitor visitor = myBuilder.get();
276         if ( visitor == null ) {
277             visitor = new XslComponentsBuildVisitor( getModel());
278             myBuilder.set( visitor );
279         }
280         visitor.init();
281         return visitor;
282     }
283     
284     private XslModelImpl getModel() {
285         return myModel;
286     }
287     
288     private XslModelImpl myModel;
289     
290     private ThreadLocal JavaDoc<XslComponentsBuildVisitor> myBuilder;
291
292 }
293
Popular Tags