proguard.classfile.visitor

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 » proguard » proguard.classfile.visitor 
proguard.classfile.visitor
This package contains interfaces and classes for processing class files from the {@link proguard.classfile proguard.classfile} package using the visitor pattern. Cfr., for instance, "Design Patterns, Elements of Reusable OO Software", by Gamma, Helm, Johnson, and Vlissider.

Why the visitor pattern? Class files frequently contain lists of elements of various mixed types: class items, constant pool entries, attributes,... These lists and types are largely fixed; they won't change much in future releases of the Java class file specifications. On the other hand, the kinds of operations that we may wish to perform on the class files may change and expand. We want to separate the objects and the operations performed upon them. This is a good place to use the visitor pattern.

Visitor interfaces avoid having to do series of instanceof tests on the elements of a list, followed by type casts and the proper operations. Every list element is a visitor accepter. When its accept method is called by a visitor, it calls its corresponding visitX method in the visitor, passing itself as an argument. This technique is called double-dispatch.

As already mentioned, the main advantage is avoiding lots of instanceof tests and type casts. Also, implementing a visitor interface ensures you're handling all possible visitor accepter types. Each type has its own method, which you simply have to implement.

A disadvantage is that the visitor methods always get the same names, specified by the visitor interface. These names aren't descriptive at all, making code harder to read. It's the visitor classes that describe the operations now.

Also, the visitor methods always have the same parameters and return values, as specified by the visitor interfaces. Passing additional parameters is done by means of extra fields in the visitor, which is somewhat of a kludge.

Because objects (the visitor accepters) and the operations performed upon them (the visitors) are now separated, it becomes harder to associate some state with the objects. For convenience, we always provide an extra visitor info field in visitor accepters, in which visitors can put any temporary information they want.

Java Source File NameTypeComment
AllClassVisitor.javaClass This ClassPoolVisitor lets a given ClassVisitor visit all Clazz objects of the class pools it visits.
AllFieldVisitor.javaClass This ClassVisitor lets a given MemberVisitor visit all FieldMember objects of the classes it visits.
AllMemberVisitor.javaClass This ClassVisitor lets a given MemberVisitor visit all Member objects of the classes it visits.
AllMethodVisitor.javaClass This ClassVisitor lets a given MemberVisitor visit all MethodMember objects of the classes it visits.
BottomClassFilter.javaClass This ClassVisitor delegates its visits to another given ClassVisitor, but only when visiting classes that don't have any subclasses.
ClassAccessFilter.javaClass This ClassVisitor delegates its visits to another given ClassVisitor, but only when the visited class has the proper access flags.
ClassCleaner.javaClass This ClassVisitor removes all visitor information of the classes it visits.
ClassCollector.javaClass This ClassVisitor collects the classes that it visits in the given collection.
ClassCounter.javaClass This ClassVisitor counts the number of classes that has been visited.
ClassForNameClassVisitor.javaClass This ConstantVisitor lets a given ClassVisitor visit all constant classes involved in any Class.forName constructs that it visits.
ClassHierarchyTraveler.javaClass This ClassVisitor lets a given ClassVisitor optionally travel to the visited class, its superclass, its interfaces, and its subclasses.
ClassMemberVisitor.javaClass This MemberVisitor delegates all visits to a given ClassVisitor.
ClassNameFilter.javaClass This ClassVisitor delegates its visits to another given ClassVisitor, but only when the visited class has a name that matches a given regular expression.
ClassPoolFiller.javaClass This ClassVisitor collects all the classes it visits in a given class pool.
ClassPoolVisitor.javaInterface This interface specifies the methods for a visitor of ClassPool objects.
ClassPresenceFilter.javaClass This ClassVisitor delegates its visits to one of two ClassVisitor instances, depending on whether the name of the visited class file is present in a given ClassPool or not.
ClassPrinter.javaClass This ClassVisitor prints out the complete internal structure of the classes it visits.
ClassVersionFilter.javaClass This ClassVisitor delegates its visits to program classes to another given ClassVisitor, but only when the class version number of the visited program class lies in a given range.
ClassVersionSetter.javaClass This ClassVisitor sets the version number of the program classes that it visits.
ClassVisitor.javaInterface This interface specifies the methods for a visitor of Clazz objects.
ConcreteClassDownTraveler.javaClass This ClassVisitor lets a given ClassVisitor travel to the first concrete subclasses down in its hierarchy of abstract classes and concrete classes.
DotClassClassVisitor.javaClass This InstructionVisitor lets a given ClassVisitor visit all classes involved in any .class constructs that it visits.
ExceptionCounter.javaClass This ExceptionInfoVisitor counts the number of exceptions that has been visited.
ExceptionExcludedOffsetFilter.javaClass This ExceptionInfoVisitor delegates its visits to another given ExceptionInfoVisitor, but only when the visited exception does not cover the instruction at the given offset.
ExceptionOffsetFilter.javaClass This ExceptionInfoVisitor delegates its visits to another given ExceptionInfoVisitor, but only when the visited exception covers the instruction at the given offset.
ExceptionRangeFilter.javaClass This ExceptionInfoVisitor delegates its visits to another given ExceptionInfoVisitor, but only when the visited exception overlaps with the given instruction range.
LibraryClassFilter.javaClass This ClassVisitor delegates its visits to another given ClassVisitor, but only when visiting library classes.
LibraryMemberFilter.javaClass This MemberVisitor delegates its visits to another given MemberVisitor, but only when visiting members of library classes.
MemberAccessFilter.javaClass This MemberVisitor delegates its visits to another given MemberVisitor, but only when the visited member has the proper access flags.
MemberClassAccessFilter.javaClass This MemberVisitor delegates its visits to another given MemberVisitor, but only when the visited member is accessible from the given referencing class.
MemberCounter.javaClass This MemberVisitor counts the number of class members that has been visited.
MemberDescriptorFilter.javaClass This MemberVisitor delegates its visits to another given MemberVisitor, but only when the visited member has a descriptor that matches a given regular expression.
MemberNameFilter.javaClass This MemberVisitor delegates its visits to another given MemberVisitor, but only when the visited member has a name that matches a given regular expression.
MemberToClassVisitor.javaClass This MemberVisitor delegates all visits to a given ClassVisitor.
MemberVisitor.javaInterface This interface specifies the methods for a visitor of ProgramMember objects and LibraryMember objects.
MethodImplementationFilter.javaClass This MemberVisitor delegates its visits to methods to another given MemberVisitor, but only when the visited method may have implementations.
MethodImplementationTraveler.javaClass This MemberVisitor lets a given MemberVisitor travel to all concrete implementations of the visited methods in their class hierarchies.
MultiClassPoolVisitor.javaClass This ClassPoolVisitor delegates all visits to each ClassPoolVisitor in a given list.
MultiClassVisitor.javaClass This ClassVisitor delegates all visits to each ClassVisitor in a given list.
MultiMemberVisitor.javaClass This MemberVisitor delegates all visits to each MemberVisitor in a given list.
NamedClassVisitor.javaClass This class visits Clazz objects with the given name.
NamedFieldVisitor.javaClass This class visits ProgramMember objects referring to fields, identified by a name and descriptor pair.
NamedMethodVisitor.javaClass This class visits ProgramMember objects referring to methods, identified by a name and descriptor pair.
ProgramClassFilter.javaClass This ClassVisitor delegates its visits to another given ClassVisitor, but only when visiting program classes.
ProgramMemberFilter.javaClass This MemberVisitor delegates its visits to another given MemberVisitor, but only when visiting members of program classes.
ReferencedClassVisitor.javaClass This ClassVisitor, MemberVisitor, ConstantVisitor, AttributeVisitor, etc.
ReferencedMemberVisitor.javaClass This ConstantVisitor and ElementValueVisitor lets a given MemberVisitor visit all the referenced class members of the elements that it visits.
SimpleClassPrinter.javaClass This ClassVisitor and MemberVisitor prints out the class names of the classes it visits, and the full class member descriptions of the class members it visits.
VariableClassVisitor.javaClass This ClassVisitor delegates all method calls to a ClassVisitor that can be changed at any time.
VariableMemberVisitor.javaClass This MemberVisitor delegates all method calls to a MemberVisitor that can be changed at any time.
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.