Source Code Cross Referenced for AdaptorVisitor.java in  » Development » jga-Generic-Algorithms » net » sf » jga » fn » 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 » Development » jga Generic Algorithms » net.sf.jga.fn 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        // ============================================================================
002:        // $Id: AdaptorVisitor.java,v 1.7 2006/05/08 02:30:32 davidahall Exp $
003:        // Copyright (c) 2005  David A. Hall
004:        // ============================================================================
005:        // The contents of this file are subject to the Common Development and
006:        // Distribution License (CDDL), Version 1.0 (the License); you may not use this 
007:        // file except in compliance with the License.  You should have received a copy
008:        // of the the License along with this file: if not, a copy of the License is 
009:        // available from Sun Microsystems, Inc.
010:        //
011:        // http://www.sun.com/cddl/cddl.html
012:        //
013:        // From time to time, the license steward (initially Sun Microsystems, Inc.) may
014:        // publish revised and/or new versions of the License.  You may not use,  
015:        // distribute, or otherwise make this file available under subsequent versions 
016:        // of the License.
017:        // 
018:        // Alternatively, the contents of this file may be used under the terms of the 
019:        // GNU Lesser General Public License Version 2.1 or later (the "LGPL"), in which
020:        // case the provisions of the LGPL are applicable instead of those above. If you 
021:        // wish to allow use of your version of this file only under the terms of the 
022:        // LGPL, and not to allow others to use your version of this file under the 
023:        // terms of the CDDL, indicate your decision by deleting the provisions above 
024:        // and replace them with the notice and other provisions required by the LGPL. 
025:        // If you do not delete the provisions above, a recipient may use your version 
026:        // of this file under the terms of either the CDDL or the LGPL.
027:        // 
028:        // This library is distributed in the hope that it will be useful,
029:        // but WITHOUT ANY WARRANTY; without even the implied warranty of
030:        // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 
031:        // ============================================================================
032:
033:        package net.sf.jga.fn;
034:
035:        import net.sf.jga.fn.adaptor.*;
036:        import net.sf.jga.fn.logical.All;
037:        import net.sf.jga.fn.logical.Any;
038:        import java.util.Iterator;
039:
040:        /**
041:         * Visitor that performs a walk of compound functor structures.  This visitor
042:         * implements the Visitor interface associated with all of the compounding
043:         * functors in the <a href="adaptor/package-summary.html">net.sf.jga.fn.adaptor</a>
044:         * package, as well as the two that are in the
045:         * <a href="logical/package-summary.html">net.sf.jga.fn.logical</a> package.
046:         * <p>
047:         * Basing visitors on this base class will allow most implementations to ignore
048:         * the tree structure, and implement visiting the leaf node functors that are
049:         * of interest.  When used in this way, the tree nodes will be ignored by the
050:         * visitor (exception that the visit walks through them).  If the tree nodes
051:         * are to be considered during the visit, then the implementation can override
052:         * methods contained in this class: depending on where in the overridden
053:         * implementation the call to super() occurs, either breadth-first, depth-first,
054:         * or in-line traversal can be supported.
055:         * <p>
056:         * Copyright &copy; 2005  David A. Hall
057:         * @author <a href="mailto:davidahall@users.sf.net">David A. Hall</a>
058:         */
059:
060:        public class AdaptorVisitor extends AbstractVisitor implements 
061:                All.Visitor, AndBinary.Visitor, AndGenerator.Visitor,
062:                AndUnary.Visitor, Any.Visitor, ApplyBinary.Visitor,
063:                ApplyGenerator.Visitor, ApplyUnary.Visitor, Bind.Visitor,
064:                Bind1st.Visitor, Bind2nd.Visitor, ChainBinary.Visitor,
065:                ChainUnary.Visitor, ComposeBinary.Visitor,
066:                ComposeUnary.Visitor, CompoundBinary.Visitor,
067:                CompoundGenerator.Visitor, CompoundUnary.Visitor,
068:                ConditionalBinary.Visitor, ConditionalGenerator.Visitor,
069:                ConditionalUnary.Visitor, Distribute.Visitor, Generate.Visitor,
070:                Generate1st.Visitor, Generate2nd.Visitor,
071:                GenerateBinary.Visitor, GenerateUnary.Visitor,
072:                OrBinary.Visitor, OrGenerator.Visitor, OrUnary.Visitor {
073:            public void visit(All host) {
074:                for (Iterator iter = host.branches(); iter.hasNext();) {
075:                    ((UnaryFunctor) iter.next()).accept(this );
076:                }
077:            }
078:
079:            public void visit(AndBinary host) {
080:                host.getFirstFunctor().accept(this );
081:                host.getSecondFunctor().accept(this );
082:            }
083:
084:            public void visit(AndGenerator host) {
085:                host.getFirstFunctor().accept(this );
086:                host.getSecondFunctor().accept(this );
087:            }
088:
089:            public void visit(AndUnary host) {
090:                host.getFirstFunctor().accept(this );
091:                host.getSecondFunctor().accept(this );
092:            }
093:
094:            public void visit(Any host) {
095:                for (Iterator iter = host.branches(); iter.hasNext();) {
096:                    ((UnaryFunctor) iter.next()).accept(this );
097:                }
098:            }
099:
100:            public void visit(ApplyBinary host) {
101:                BinaryFunctor[] fns = host.getFunctors();
102:                for (int i = 0; i < fns.length; ++i)
103:                    fns[i].accept(this );
104:            }
105:
106:            public void visit(ApplyGenerator host) {
107:                Generator[] fns = host.getGenerators();
108:                for (int i = 0; i < fns.length; ++i)
109:                    fns[i].accept(this );
110:            }
111:
112:            public void visit(ApplyUnary host) {
113:                UnaryFunctor[] fns = host.getFunctors();
114:                for (int i = 0; i < fns.length; ++i)
115:                    fns[i].accept(this );
116:            }
117:
118:            public void visit(Bind host) {
119:                host.getFunctor().accept(this );
120:            }
121:
122:            public void visit(Bind1st host) {
123:                host.getFunctor().accept(this );
124:            }
125:
126:            public void visit(Bind2nd host) {
127:                host.getFunctor().accept(this );
128:            }
129:
130:            public void visit(ChainBinary host) {
131:                host.getInnerFunctor().accept(this );
132:                host.getOuterFunctor().accept(this );
133:            }
134:
135:            public void visit(ChainUnary host) {
136:                host.getInnerFunctor().accept(this );
137:                host.getOuterFunctor().accept(this );
138:            }
139:
140:            public void visit(ComposeBinary host) {
141:                host.getFirstInnerFunctor().accept(this );
142:                host.getSecondInnerFunctor().accept(this );
143:                host.getOuterFunctor().accept(this );
144:            }
145:
146:            public void visit(ComposeUnary host) {
147:                host.getFirstInnerFunctor().accept(this );
148:                host.getSecondInnerFunctor().accept(this );
149:                host.getOuterFunctor().accept(this );
150:            }
151:
152:            public void visit(CompoundBinary host) {
153:                host.getFirstFunctor().accept(this );
154:                host.getSecondFunctor().accept(this );
155:            }
156:
157:            public void visit(CompoundGenerator host) {
158:                host.getFirstFunctor().accept(this );
159:                host.getSecondFunctor().accept(this );
160:            }
161:
162:            public void visit(CompoundUnary host) {
163:                host.getFirstFunctor().accept(this );
164:                host.getSecondFunctor().accept(this );
165:            }
166:
167:            public void visit(ConditionalBinary host) {
168:                host.getCondition().accept(this );
169:                host.getTrueFunctor().accept(this );
170:                host.getFalseFunctor().accept(this );
171:            }
172:
173:            public void visit(ConditionalGenerator host) {
174:                host.getCondition().accept(this );
175:                host.getTrueFunctor().accept(this );
176:                host.getFalseFunctor().accept(this );
177:            }
178:
179:            public void visit(ConditionalUnary host) {
180:                host.getCondition().accept(this );
181:                host.getTrueFunctor().accept(this );
182:                host.getFalseFunctor().accept(this );
183:            }
184:
185:            public void visit(Distribute host) {
186:                host.getFirstInnerFunctor().accept(this );
187:                host.getSecondInnerFunctor().accept(this );
188:                host.getOuterFunctor().accept(this );
189:            }
190:
191:            public void visit(Generate host) {
192:                host.getFunctor().accept(this );
193:                host.getGenerator().accept(this );
194:            }
195:
196:            public void visit(Generate1st host) {
197:                host.getFunctor().accept(this );
198:                host.getGenerator().accept(this );
199:            }
200:
201:            public void visit(Generate2nd host) {
202:                host.getFunctor().accept(this );
203:                host.getGenerator().accept(this );
204:            }
205:
206:            public void visit(GenerateUnary host) {
207:                host.getGenerator().accept(this );
208:            }
209:
210:            public void visit(GenerateBinary host) {
211:                host.getGenerator().accept(this );
212:            }
213:
214:            public void visit(OrBinary host) {
215:                host.getFirstFunctor().accept(this );
216:                host.getSecondFunctor().accept(this );
217:            }
218:
219:            public void visit(OrGenerator host) {
220:                host.getFirstFunctor().accept(this );
221:                host.getSecondFunctor().accept(this );
222:            }
223:
224:            public void visit(OrUnary host) {
225:                host.getFirstFunctor().accept(this);
226:                host.getSecondFunctor().accept(this);
227:            }
228:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.