Source Code Cross Referenced for XslComponentsBuildVisitor.java in  » IDE-Netbeans » xml » org » netbeans » modules » xslt » model » impl » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » IDE Netbeans » xml » org.netbeans.modules.xslt.model.impl 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * The contents of this file are subject to the terms of the Common Development
003:         * and Distribution License (the License). You may not use this file except in
004:         * compliance with the License.
005:         * 
006:         * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
007:         * or http://www.netbeans.org/cddl.txt.
008:         * 
009:         * When distributing Covered Code, include this CDDL Header Notice in each file
010:         * and include the License file at http://www.netbeans.org/cddl.txt.
011:         * If applicable, add the following below the CDDL Header, with the fields
012:         * enclosed by brackets [] replaced by your own identifying information:
013:         * "Portions Copyrighted [year] [name of copyright owner]"
014:         * 
015:         * The Original Software is NetBeans. The Initial Developer of the Original
016:         * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
017:         * Microsystems, Inc. All Rights Reserved.
018:         */
019:        package org.netbeans.modules.xslt.model.impl;
020:
021:        import org.netbeans.modules.xslt.model.Attribute;
022:        import org.netbeans.modules.xslt.model.Choose;
023:        import org.netbeans.modules.xslt.model.Document;
024:        import org.netbeans.modules.xslt.model.ForEach;
025:        import org.netbeans.modules.xslt.model.If;
026:        import org.netbeans.modules.xslt.model.Key;
027:        import org.netbeans.modules.xslt.model.LiteralResultElement;
028:        import org.netbeans.modules.xslt.model.Namespace;
029:        import org.netbeans.modules.xslt.model.Otherwise;
030:        import org.netbeans.modules.xslt.model.Param;
031:        import org.netbeans.modules.xslt.model.Sequence;
032:        import org.netbeans.modules.xslt.model.SequenceConstructor;
033:        import org.netbeans.modules.xslt.model.Sort;
034:        import org.netbeans.modules.xslt.model.Stylesheet;
035:        import org.netbeans.modules.xslt.model.Template;
036:        import org.netbeans.modules.xslt.model.ValueOf;
037:        import org.netbeans.modules.xslt.model.Variable;
038:        import org.netbeans.modules.xslt.model.When;
039:        import org.netbeans.modules.xslt.model.XslComponent;
040:        import org.netbeans.modules.xslt.model.XslVisitorAdapter;
041:        import org.w3c.dom.Element;
042:
043:        /**
044:         * @author ads
045:         *
046:         */
047:        class XslComponentsBuildVisitor extends XslVisitorAdapter {
048:
049:            XslComponentsBuildVisitor(XslModelImpl model) {
050:                assert model != null;
051:                myModel = model;
052:            }
053:
054:            XslComponent createSubComponent(XslComponent parent, Element element) {
055:                myElement = element;
056:                String namespace = element.getNamespaceURI();
057:                if (namespace == null && parent instanceof  XslComponentImpl) {
058:                    namespace = ((XslComponentImpl) parent)
059:                            .lookupNamespaceURI(element.getPrefix());
060:                }
061:
062:                if (XslComponent.XSL_NAMESPACE.equals(namespace)) {
063:                    if (parent == null) {
064:                        if (XslElements.STYLESHEET.getName().equals(
065:                                getElement().getLocalName())
066:                                || XslElements.TRANSFORM.getName().equals(
067:                                        getElement().getLocalName())) {
068:                            setResult(new StylesheetImpl(getModel(), element));
069:                        }
070:                    } else {
071:                        parent.accept(this );
072:                    }
073:                } else {
074:                    createNonXslComponentChild(parent);
075:                }
076:                return myResult;
077:            }
078:
079:            /* (non-Javadoc)
080:             * @see org.netbeans.modules.xslt.model.XslVisitorAdapter#visit(org.netbeans.modules.xslt.model.Stylesheet)
081:             */
082:            @Override
083:            public void visit(Stylesheet stylesheet) {
084:                if (isAcceptable(XslElements.IMPORT)) {
085:                    setResult(new ImportImpl(getModel(), getElement()));
086:                } else if (isAcceptable(XslElements.VARIABLE)) {
087:                    setResult(new VariableImpl(getModel(), getElement()));
088:                } else if (isAcceptable(XslElements.PARAM)) {
089:                    setResult(new ParamImpl(getModel(), getElement()));
090:                } else {
091:                    createDeclaration(stylesheet);
092:                }
093:
094:            }
095:
096:            @Override
097:            public void visit(Variable variable) {
098:                visitSequenceConstructor(variable);
099:            }
100:
101:            @Override
102:            public void visit(Document document) {
103:                visitSequenceConstructor(document);
104:            }
105:
106:            @Override
107:            public void visit(org.netbeans.modules.xslt.model.Element element) {
108:                visitSequenceConstructor(element);
109:            }
110:
111:            @Override
112:            public void visit(Attribute attribute) {
113:                visitSequenceConstructor(attribute);
114:            }
115:
116:            @Override
117:            public void visit(ForEach forEach) {
118:                if (visitSequenceConstructor(forEach)) {
119:                    return;
120:                }
121:                if (isAcceptable(XslElements.SORT)) {
122:                    setResult(new SortImpl(getModel(), getElement()));
123:                }
124:            }
125:
126:            @Override
127:            public void visit(If iff) {
128:                visitSequenceConstructor(iff);
129:            }
130:
131:            @Override
132:            public void visit(Key key) {
133:                visitSequenceConstructor(key);
134:            }
135:
136:            @Override
137:            public void visit(Namespace namespace) {
138:                visitSequenceConstructor(namespace);
139:            }
140:
141:            @Override
142:            public void visit(Otherwise otherwise) {
143:                visitSequenceConstructor(otherwise);
144:            }
145:
146:            @Override
147:            public void visit(Param param) {
148:                visitSequenceConstructor(param);
149:            }
150:
151:            @Override
152:            public void visit(Sequence sequence) {
153:                visitSequenceConstructor(sequence);
154:            }
155:
156:            @Override
157:            public void visit(Sort sort) {
158:                visitSequenceConstructor(sort);
159:            }
160:
161:            @Override
162:            public void visit(Template template) {
163:                if (visitSequenceConstructor(template)) {
164:                    return;
165:                }
166:                if (isAcceptable(XslElements.PARAM)) {
167:                    setResult(new ParamImpl(getModel(), getElement()));
168:                }
169:            }
170:
171:            @Override
172:            public void visit(ValueOf valueOf) {
173:                visitSequenceConstructor(valueOf);
174:            }
175:
176:            @Override
177:            public void visit(When when) {
178:                visitSequenceConstructor(when);
179:            }
180:
181:            public void visit(Choose choose) {
182:                if (isAcceptable(XslElements.WHEN)) {
183:                    setResult(new WhenImpl(getModel(), getElement()));
184:                } else if (isAcceptable(XslElements.OTHERWISE)) {
185:                    setResult(new OtherwiseImpl(getModel(), getElement()));
186:                }
187:            }
188:
189:            /* (non-Javadoc)
190:             * @see org.netbeans.modules.xslt.model.XslVisitorAdapter#visit(org.netbeans.modules.xslt.model.LiteralResultElement)
191:             */
192:            @Override
193:            public void visit(LiteralResultElement element) {
194:                visitSequenceConstructor(element);
195:            }
196:
197:            private boolean visitSequenceConstructor(
198:                    SequenceConstructor constructor) {
199:                if (isAcceptable(XslElements.APPLY_TEMPLATES)) {
200:                    setResult(new ApplyTemplatesImpl(getModel(), getElement()));
201:                } else if (isAcceptable(XslElements.ATTRIBUTE)) {
202:                    setResult(new AttributeImpl(getModel(), getElement()));
203:                } else if (isAcceptable(XslElements.CALL_TEMPLATE)) {
204:                    setResult(new CallTemplateImpl(getModel(), getElement()));
205:                } else if (isAcceptable(XslElements.CHOOSE)) {
206:                    setResult(new ChooseImpl(getModel(), getElement()));
207:                } else if (isAcceptable(XslElements.COPY)) {
208:                    setResult(new CopyImpl(getModel(), getElement()));
209:                } else if (isAcceptable(XslElements.COPY_OF)) {
210:                    setResult(new CopyOfImpl(getModel(), getElement()));
211:                } else if (isAcceptable(XslElements.DOCUMENT)) {
212:                    setResult(new DocumentImpl(getModel(), getElement()));
213:                } else if (isAcceptable(XslElements.ELEMENT)) {
214:                    setResult(new ElementImpl(getModel(), getElement()));
215:                } else if (isAcceptable(XslElements.FOR_EACH)) {
216:                    setResult(new ForEachImpl(getModel(), getElement()));
217:                } else if (isAcceptable(XslElements.IF)) {
218:                    setResult(new IfImpl(getModel(), getElement()));
219:                } else if (isAcceptable(XslElements.NAMESPACE)) {
220:                    setResult(new NamespaceImpl(getModel(), getElement()));
221:                } else if (isAcceptable(XslElements.NUMBER)) {
222:                    setResult(new NumberImpl(getModel(), getElement()));
223:                } else if (isAcceptable(XslElements.SEQUENCE)) {
224:                    setResult(new SequenceImpl(getModel(), getElement()));
225:                } else if (isAcceptable(XslElements.TEXT)) {
226:                    setResult(new TextImpl(getModel(), getElement()));
227:                } else if (isAcceptable(XslElements.VALUE_OF)) {
228:                    setResult(new ValueOfImpl(getModel(), getElement()));
229:                }
230:                return myResult != null;
231:            }
232:
233:            private void createDeclaration(Stylesheet stylesheet) {
234:                if (isAcceptable(XslElements.ATTRIBUTE_SET)) {
235:                    setResult(new AttributeSetImpl(getModel(), getElement()));
236:                } else if (isAcceptable(XslElements.INCLUDE)) {
237:                    setResult(new IncludeImpl(getModel(), getElement()));
238:                } else if (isAcceptable(XslElements.KEY)) {
239:                    setResult(new KeyImpl(getModel(), getElement()));
240:                } else if (isAcceptable(XslElements.TEMPLATE)) {
241:                    setResult(new TemplateImpl(getModel(), getElement()));
242:                } else if (isAcceptable(XslElements.OUTPUT)) {
243:                    setResult(new OutputImpl(getModel(), getElement()));
244:                }
245:            }
246:
247:            private void createNonXslComponentChild(XslComponent parent) {
248:                if (parent instanceof  SequenceConstructor) {
249:                    setResult(new LiteralResultElementImpl(getModel(),
250:                            getElement()));
251:                }
252:            }
253:
254:            private void setResult(XslComponent component) {
255:                myResult = component;
256:            }
257:
258:            private boolean isAcceptable(XslElements element) {
259:                return element.getName().equals(getLocalName());
260:            }
261:
262:            private String getLocalName() {
263:                return getElement().getLocalName();
264:            }
265:
266:            void init() {
267:                myResult = null;
268:                myElement = null;
269:            }
270:
271:            private XslModelImpl getModel() {
272:                return myModel;
273:            }
274:
275:            private Element getElement() {
276:                return myElement;
277:            }
278:
279:            private Element myElement;
280:
281:            private XslModelImpl myModel;
282:
283:            private XslComponent myResult;
284:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.