1 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 58 class XslComponentFactoryImpl implements XslComponentFactory { 59 60 XslComponentFactoryImpl( XslModelImpl model ) { 61 myModel = model; 62 myBuilder = new ThreadLocal <XslComponentsBuildVisitor>(); 63 } 64 65 68 public ApplyTemplates createApplyTemplates() { 69 return new ApplyTemplatesImpl( getModel() ); 70 } 71 72 75 public Attribute createAttribute() { 76 return new AttributeImpl( getModel() ); 77 } 78 79 82 public AttributeSet createAttributeSet() { 83 return new AttributeSetImpl( getModel() ); 84 } 85 86 89 public CallTemplate createCallTemplate() { 90 return new CallTemplateImpl( getModel() ); 91 } 92 93 96 public Choose createChoose() { 97 return new ChooseImpl( getModel() ); 98 } 99 100 103 public Copy createCopy() { 104 return new CopyImpl( getModel() ); 105 } 106 107 110 public CopyOf createCopyOf() { 111 return new CopyOfImpl( getModel() ); 112 } 113 114 117 public Document createDocument() { 118 return new DocumentImpl( getModel() ); 119 } 120 121 124 public Element createElement() { 125 return new ElementImpl( getModel() ); 126 } 127 128 131 public ForEach createForEach() { 132 return new ForEachImpl( getModel() ); 133 } 134 135 138 public If createIf() { 139 return new IfImpl( getModel() ); 140 } 141 142 145 public Include createInclude() { 146 return new IncludeImpl( getModel() ); 147 } 148 149 152 public Key createKey() { 153 return new KeyImpl( getModel() ); 154 } 155 156 159 public LiteralResultElement createLiteralResultElement( String name , 160 String namespaceUri ) 161 { 162 org.w3c.dom.Element element = getModel().getDocument(). 163 createElementNS( namespaceUri, name ); 164 return new LiteralResultElementImpl( getModel() , element ); 165 } 166 167 170 public Namespace createNamespace() { 171 return new NamespaceImpl( getModel() ); 172 } 173 174 177 public Number createNumber() { 178 return new NumberImpl( getModel() ); 179 } 180 181 184 public Otherwise createOtherwise() { 185 return new OtherwiseImpl( getModel() ); 186 } 187 188 191 public Output createOutput() { 192 return new OutputImpl( getModel() ); 193 } 194 195 198 public Param createParam() { 199 return new ParamImpl( getModel() ); 200 } 201 202 205 public Sequence createSequence() { 206 return new SequenceImpl( getModel() ); 207 } 208 209 212 public Sort createSort() { 213 return new SortImpl( getModel() ); 214 } 215 216 219 public Stylesheet createStylesheet() { 220 return new StylesheetImpl( getModel() ); 221 } 222 223 226 public Template createTemplate() { 227 return new TemplateImpl( getModel() ); 228 } 229 230 233 public Text createText() { 234 return new TextImpl( getModel() ); 235 } 236 237 240 public ValueOf createValueOf() { 241 return new ValueOfImpl( getModel() ); 242 } 243 244 247 public Variable createVariable() { 248 return new VariableImpl( getModel() ); 249 } 250 251 254 public When createWhen() { 255 return new WhenImpl( getModel() ); 256 } 257 258 261 public Import createImport() { 262 return new ImportImpl( getModel() ); 263 } 264 265 268 public XslComponent create( org.w3c.dom.Element 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 <XslComponentsBuildVisitor> myBuilder; 291 292 } 293 | Popular Tags |