2
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
4
* Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
6
* The contents of this file are subject to the terms of either the GNU
7
* General Public License Version 2 only ("GPL") or the Common
8
* Development and Distribution License("CDDL") (collectively, the
9
* "License"). You may not use this file except in compliance with the
10
* License. You can obtain a copy of the License at
11
* http://www.netbeans.org/cddl-gplv2.html
12
* or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
13
* specific language governing permissions and limitations under the
14
* License. When distributing the software, include this License Header
15
* Notice in each file and include the License file at
16
* nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
17
* particular file as subject to the "Classpath" exception as provided
18
* by Sun in the GPL Version 2 section of the License file that
19
* accompanied this code. If applicable, add the following below the
20
* License Header, with the fields enclosed by brackets [] replaced by
21
* your own identifying information:
22
* "Portions Copyrighted [year] [name of copyright owner]"
26
* The Original Software is NetBeans. The Initial Developer of the Original
27
* Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
28
* Microsystems, Inc. All Rights Reserved.
30
* If you wish your version of this file to be governed by only the CDDL
31
* or only the GPL Version 2, indicate your decision by adding
32
* "[Contributor] elects to include this software in this distribution
33
* under the [CDDL or GPL Version 2] license." If you do not indicate a
34
* single choice of license, a recipient has the option to distribute
35
* your version of this file under either the CDDL, the GPL Version 2 or
36
* to extend the choice of license to its licensees as provided above.
37
* However, if you add GPL Version 2 code and therefore, elected the GPL
38
* Version 2 license, then the option applies only if the new code is
39
* made subject to such option by the copyright holder.
42
package org.netbeans.modules.xslt.model.impl;
44
import org.netbeans.modules.xslt.model.ApplyTemplates;
45
import org.netbeans.modules.xslt.model.Attribute;
46
import org.netbeans.modules.xslt.model.AttributeSet;
47
import org.netbeans.modules.xslt.model.CallTemplate;
48
import org.netbeans.modules.xslt.model.Choose;
49
import org.netbeans.modules.xslt.model.Copy;
50
import org.netbeans.modules.xslt.model.CopyOf;
51
import org.netbeans.modules.xslt.model.Document;
52
import org.netbeans.modules.xslt.model.Element;
53
import org.netbeans.modules.xslt.model.ForEach;
54
import org.netbeans.modules.xslt.model.If;
55
import org.netbeans.modules.xslt.model.Import;
56
import org.netbeans.modules.xslt.model.Include;
57
import org.netbeans.modules.xslt.model.Key;
58
import org.netbeans.modules.xslt.model.LiteralResultElement;
59
import org.netbeans.modules.xslt.model.Namespace;
60
import org.netbeans.modules.xslt.model.Number;
61
import org.netbeans.modules.xslt.model.Otherwise;
62
import org.netbeans.modules.xslt.model.Output;
63
import org.netbeans.modules.xslt.model.Param;
64
import org.netbeans.modules.xslt.model.Sequence;
65
import org.netbeans.modules.xslt.model.Sort;
66
import org.netbeans.modules.xslt.model.Stylesheet;
67
import org.netbeans.modules.xslt.model.Template;
68
import org.netbeans.modules.xslt.model.Text;
69
import org.netbeans.modules.xslt.model.ValueOf;
70
import org.netbeans.modules.xslt.model.Variable;
71
import org.netbeans.modules.xslt.model.When;
72
import org.netbeans.modules.xslt.model.XslComponent;
73
import org.netbeans.modules.xslt.model.XslComponentFactory;
80
class XslComponentFactoryImpl implements XslComponentFactory {
82
XslComponentFactoryImpl( XslModelImpl model ) {
84
myBuilder = new ThreadLocal<XslComponentsBuildVisitor>();
88
* @see org.netbeans.modules.xslt.model.XslComponentFactory#createApplyTemplates()
90
public ApplyTemplates createApplyTemplates() {
91
return new ApplyTemplatesImpl( getModel() );
95
* @see org.netbeans.modules.xslt.model.XslComponentFactory#createAttribute()
97
public Attribute createAttribute() {
98
return new AttributeImpl( getModel() );
102
* @see org.netbeans.modules.xslt.model.XslComponentFactory#createAttributeSet()
104
public AttributeSet createAttributeSet() {
105
return new AttributeSetImpl( getModel() );
109
* @see org.netbeans.modules.xslt.model.XslComponentFactory#createCallTemplate()
111
public CallTemplate createCallTemplate() {
112
return new CallTemplateImpl( getModel() );
116
* @see org.netbeans.modules.xslt.model.XslComponentFactory#createChoose()
118
public Choose createChoose() {
119
return new ChooseImpl( getModel() );
123
* @see org.netbeans.modules.xslt.model.XslComponentFactory#createCopy()
125
public Copy createCopy() {
126
return new CopyImpl( getModel() );
130
* @see org.netbeans.modules.xslt.model.XslComponentFactory#createCopyOf()
132
public CopyOf createCopyOf() {
133
return new CopyOfImpl( getModel() );
137
* @see org.netbeans.modules.xslt.model.XslComponentFactory#createDocument()
139
public Document createDocument() {
140
return new DocumentImpl( getModel() );
144
* @see org.netbeans.modules.xslt.model.XslComponentFactory#createElement()
146
public Element createElement() {
147
return new ElementImpl( getModel() );
151
* @see org.netbeans.modules.xslt.model.XslComponentFactory#createForEach()
153
public ForEach createForEach() {
154
return new ForEachImpl( getModel() );
158
* @see org.netbeans.modules.xslt.model.XslComponentFactory#createIf()
160
public If createIf() {
161
return new IfImpl( getModel() );
165
* @see org.netbeans.modules.xslt.model.XslComponentFactory#createInclude()
167
public Include createInclude() {
168
return new IncludeImpl( getModel() );
172
* @see org.netbeans.modules.xslt.model.XslComponentFactory#createKey()
174
public Key createKey() {
175
return new KeyImpl( getModel() );
179
* @see org.netbeans.modules.xslt.model.XslComponentFactory#createLiteralResultElement()
181
public LiteralResultElement createLiteralResultElement( String name ,
182
String namespaceUri )
184
org.w3c.dom.Element element = getModel().getDocument().
185
createElementNS( namespaceUri, name );
186
return new LiteralResultElementImpl( getModel() , element );
190
* @see org.netbeans.modules.xslt.model.XslComponentFactory#createNamespace()
192
public Namespace createNamespace() {
193
return new NamespaceImpl( getModel() );
197
* @see org.netbeans.modules.xslt.model.XslComponentFactory#createNumber()
199
public Number createNumber() {
200
return new NumberImpl( getModel() );
204
* @see org.netbeans.modules.xslt.model.XslComponentFactory#createOtherwise()
206
public Otherwise createOtherwise() {
207
return new OtherwiseImpl( getModel() );
211
* @see org.netbeans.modules.xslt.model.XslComponentFactory#createOutput()
213
public Output createOutput() {
214
return new OutputImpl( getModel() );
218
* @see org.netbeans.modules.xslt.model.XslComponentFactory#createParam()
220
public Param createParam() {
221
return new ParamImpl( getModel() );
225
* @see org.netbeans.modules.xslt.model.XslComponentFactory#createSequence()
227
public Sequence createSequence() {
228
return new SequenceImpl( getModel() );
232
* @see org.netbeans.modules.xslt.model.XslComponentFactory#createSort()
234
public Sort createSort() {
235
return new SortImpl( getModel() );
239
* @see org.netbeans.modules.xslt.model.XslComponentFactory#createStylesheet()
241
public Stylesheet createStylesheet() {
242
return new StylesheetImpl( getModel() );
246
* @see org.netbeans.modules.xslt.model.XslComponentFactory#createTemplate()
248
public Template createTemplate() {
249
return new TemplateImpl( getModel() );
253
* @see org.netbeans.modules.xslt.model.XslComponentFactory#createText()
255
public Text createText() {
256
return new TextImpl( getModel() );
260
* @see org.netbeans.modules.xslt.model.XslComponentFactory#createValueOf()
262
public ValueOf createValueOf() {
263
return new ValueOfImpl( getModel() );
267
* @see org.netbeans.modules.xslt.model.XslComponentFactory#createVariable()
269
public Variable createVariable() {
270
return new VariableImpl( getModel() );
274
* @see org.netbeans.modules.xslt.model.XslComponentFactory#createWhen()
276
public When createWhen() {
277
return new WhenImpl( getModel() );
281
* @see org.netbeans.modules.xslt.model.XslComponentFactory#createImport()
283
public Import createImport() {
284
return new ImportImpl( getModel() );
288
* @see org.netbeans.modules.xml.xam.dom.ComponentFactory#create(org.w3c.dom.Element, org.netbeans.modules.xml.xam.dom.DocumentComponent)
290
public XslComponent create( org.w3c.dom.Element child, XslComponent parent )
292
XslComponentsBuildVisitor visitor = getBuilder( );
293
return visitor.createSubComponent( parent , child );
296
private XslComponentsBuildVisitor getBuilder() {
297
XslComponentsBuildVisitor visitor = myBuilder.get();
298
if ( visitor == null ) {
299
visitor = new XslComponentsBuildVisitor( getModel());
300
myBuilder.set( visitor );
306
private XslModelImpl getModel() {
310
private XslModelImpl myModel;
312
private ThreadLocal<XslComponentsBuildVisitor> myBuilder;