Source Code Cross Referenced for AptEventField.java in  » Library » Apache-beehive-1.0.2-src » org » apache » beehive » controls » runtime » generator » 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 » Library » Apache beehive 1.0.2 src » org.apache.beehive.controls.runtime.generator 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Licensed to the Apache Software Foundation (ASF) under one or more
003:         * contributor license agreements.  See the NOTICE file distributed with
004:         * this work for additional information regarding copyright ownership.
005:         * The ASF licenses this file to You under the Apache License, Version 2.0
006:         * (the "License"); you may not use this file except in compliance with
007:         * the License.  You may obtain a copy of the License at
008:         * 
009:         *     http://www.apache.org/licenses/LICENSE-2.0
010:         * 
011:         * Unless required by applicable law or agreed to in writing, software
012:         * distributed under the License is distributed on an "AS IS" BASIS,
013:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014:         * See the License for the specific language governing permissions and
015:         * limitations under the License.
016:         *
017:         * $Header:$
018:         */
019:        package org.apache.beehive.controls.runtime.generator;
020:
021:        import java.util.Collection;
022:        import java.util.HashMap;
023:        import java.util.Iterator;
024:
025:        import com.sun.mirror.declaration.FieldDeclaration;
026:        import com.sun.mirror.declaration.TypeDeclaration;
027:        import com.sun.mirror.declaration.TypeParameterDeclaration;
028:        import com.sun.mirror.type.DeclaredType;
029:        import com.sun.mirror.type.ReferenceType;
030:        import com.sun.mirror.type.TypeMirror;
031:
032:        /**
033:         * The AptEventField class represents a field type that is also an event source
034:         */
035:        abstract public class AptEventField extends AptField {
036:            public AptEventField(FieldDeclaration fieldDecl) {
037:                super (fieldDecl);
038:            }
039:
040:            /**
041:             * Inits the ControlInterface associated with this event field. The public interface
042:             * for controls and contextual services, and their associated events can be modeled in the
043:             * same way.  Subclasses will override this to assign an appropriate interface.
044:             */
045:            abstract protected AptControlInterface initControlInterface();
046:
047:            /**
048:             * Computes the binding from any formal type parameters declared on the control interface
049:             * to bound types on the field declaration.
050:             */
051:            private void initTypeParameterBindings() {
052:                //
053:                // Get an iterator to both the declared type arguments and the original type
054:                // declaration on the associated control interface
055:                //
056:                DeclaredType fieldType = (DeclaredType) _fieldDecl.getType();
057:                Iterator<TypeMirror> paramBoundIter = fieldType
058:                        .getActualTypeArguments().iterator();
059:
060:                TypeDeclaration intfDecl = (TypeDeclaration) _controlIntf
061:                        .getTypeDeclaration();
062:                Iterator<TypeParameterDeclaration> paramDeclIter = intfDecl
063:                        .getFormalTypeParameters().iterator();
064:
065:                //
066:                // Iterate through them in parallel, creating a mapping from the original formal
067:                // type parameter name to the actual bound type.  In parallel, also build up a
068:                // representation of the bound type declaration.
069:                //
070:                // NOTE: If no type binding is done on the field declaration, then loop below
071:                // will not execute and no mappings/empty bound decl will be the result.
072:                //
073:                StringBuffer sb = new StringBuffer();
074:                boolean isFirst = true;
075:                while (paramBoundIter.hasNext()) {
076:                    TypeMirror paramBound = paramBoundIter.next();
077:                    TypeParameterDeclaration paramDecl = paramDeclIter.next();
078:
079:                    //
080:                    // Save a mapping from the formal type name to the bound mirror type
081:                    //
082:                    _typeBindingMap.put(paramDecl.getSimpleName(), paramBound);
083:
084:                    if (isFirst) {
085:                        sb.append("<");
086:                        isFirst = false;
087:                    } else
088:                        sb.append(", ");
089:                    sb.append(paramBound);
090:                }
091:                if (!isFirst)
092:                    sb.append(">");
093:
094:                _boundParameterDecl = sb.toString();
095:            }
096:
097:            /**
098:             * Returns the ControlInterface associated with this event field
099:             */
100:            public AptControlInterface getControlInterface() {
101:                if (_controlIntf == null) {
102:                    _controlIntf = initControlInterface();
103:                    if (_controlIntf != null)
104:                        initTypeParameterBindings();
105:                }
106:                return _controlIntf;
107:            }
108:
109:            /**
110:             * Gets the EventAdaptor for a particular EventSet
111:             */
112:            public EventAdaptor getEventAdaptor(AptEventSet eventSet) {
113:                return _eventAdaptors.get(eventSet);
114:            }
115:
116:            /**
117:             * Adds a EventAdaptor for a particular EventSet
118:             */
119:            public void addEventAdaptor(AptEventSet eventSet,
120:                    EventAdaptor eventAdaptor) {
121:                assert !_eventAdaptors.containsKey(eventSet);
122:                _eventAdaptors.put(eventSet, eventAdaptor);
123:            }
124:
125:            /**
126:             *  Returns all EventAdaptors for this EventField
127:             */
128:            public Collection<EventAdaptor> getEventAdaptors() {
129:                return _eventAdaptors.values();
130:            }
131:
132:            /**
133:             * Returns the bound parameter declaration for this event field
134:             */
135:            public String getBoundParameters() {
136:                return _boundParameterDecl;
137:            }
138:
139:            /**
140:             * Returns the formal type binding map (from name to bound type) for the event field
141:             */
142:            public HashMap<String, TypeMirror> getTypeBindingMap() {
143:                return _typeBindingMap;
144:            }
145:
146:            HashMap<AptEventSet, EventAdaptor> _eventAdaptors = new HashMap<AptEventSet, EventAdaptor>();
147:
148:            String _boundParameterDecl;
149:            HashMap<String, TypeMirror> _typeBindingMap = new HashMap<String, TypeMirror>();
150:            private AptControlInterface _controlIntf;
151:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.