Source Code Cross Referenced for GenForwardModel.java in  » Library » Apache-beehive-1.0.2-src » org » apache » beehive » netui » compiler » genmodel » 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.netui.compiler.genmodel 
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.netui.compiler.genmodel;
020:
021:        import org.apache.beehive.netui.compiler.model.ForwardModel;
022:        import org.apache.beehive.netui.compiler.model.ForwardContainer;
023:        import org.apache.beehive.netui.compiler.CompilerUtils;
024:        import org.apache.beehive.netui.compiler.JpfLanguageConstants;
025:        import org.apache.beehive.netui.compiler.typesystem.declaration.AnnotationInstance;
026:        import org.apache.beehive.netui.compiler.typesystem.declaration.ClassDeclaration;
027:        import org.apache.beehive.netui.compiler.typesystem.declaration.FieldDeclaration;
028:        import org.apache.beehive.netui.compiler.typesystem.declaration.TypeDeclaration;
029:        import org.apache.beehive.netui.compiler.typesystem.type.DeclaredType;
030:
031:        import java.util.List;
032:        import java.util.Collection;
033:        import java.util.Iterator;
034:
035:        public class GenForwardModel extends ForwardModel implements 
036:                JpfLanguageConstants {
037:            public GenForwardModel(GenStrutsApp parent,
038:                    AnnotationInstance annotation, ClassDeclaration jclass,
039:                    String commentSuffix) {
040:                super (parent);
041:
042:                setName(CompilerUtils.getString(annotation, NAME_ATTR, true));
043:                setRedirect(CompilerUtils.getBoolean(annotation, REDIRECT_ATTR,
044:                        false).booleanValue());
045:                if (CompilerUtils.getBoolean(annotation,
046:                        EXTERNAL_REDIRECT_ATTR, false).booleanValue()) {
047:                    setExternalRedirect(true);
048:                }
049:
050:                //
051:                // outputFormBean/outputFormBeanType
052:                //
053:                DeclaredType outputFormType = CompilerUtils.getDeclaredType(
054:                        annotation, OUTPUT_FORM_BEAN_TYPE_ATTR, true);
055:                String outputFormMember = CompilerUtils.getString(annotation,
056:                        OUTPUT_FORM_BEAN_ATTR, true);
057:                if (outputFormMember != null) {
058:                    FieldDeclaration field = CompilerUtils.getClassField(
059:                            jclass, outputFormMember, null);
060:                    assert outputFormType == null; // checker should catch this
061:                    assert field != null; // checker should catch this
062:                    assert field.getType() instanceof  DeclaredType : field
063:                            .getType().getClass().getName(); // checker enforces
064:                    outputFormType = (DeclaredType) field.getType();
065:                }
066:                setOutputFormBeanMember(outputFormMember);
067:                setOutputFormBeanType(outputFormType != null ? CompilerUtils
068:                        .getLoadableName(outputFormType) : null);
069:
070:                //
071:                // path, tilesDefinition, navigateTo, returnAction (mutually exclusive)
072:                //
073:                String returnAction = CompilerUtils.getString(annotation,
074:                        RETURN_ACTION_ATTR, true);
075:                String navigateTo = CompilerUtils.getEnumFieldName(annotation,
076:                        NAVIGATE_TO_ATTR, true);
077:                String tilesDefinition = CompilerUtils.getString(annotation,
078:                        TILES_DEFINITION_ATTR, true);
079:                String path = CompilerUtils.getString(annotation, PATH_ATTR,
080:                        true);
081:                String action = CompilerUtils.getString(annotation,
082:                        ACTION_ATTR, true);
083:
084:                if (action != null) {
085:                    assert path == null; // checker should enforce this
086:                    path = action + ACTION_EXTENSION_DOT;
087:                }
088:
089:                if (returnAction != null) {
090:                    assert navigateTo == null;
091:                    assert tilesDefinition == null;
092:                    assert path == null;
093:                    setIsNestedReturn(true);
094:                    setPath(returnAction); // set the returnAction as the path -- the runtime expects it there
095:                } else if (navigateTo != null) {
096:                    assert tilesDefinition == null;
097:                    assert path == null;
098:
099:                    if (navigateTo.equals(NAVIGATE_TO_PAGE_LEGACY_STR)
100:                            || navigateTo.equals(NAVIGATE_TO_CURRENT_PAGE_STR)
101:                            || navigateTo.equals(NAVIGATE_TO_PREVIOUS_PAGE_STR)) {
102:                        setReturnToPage(true);
103:                    } else if (navigateTo
104:                            .equals(NAVIGATE_TO_PREVIOUS_ACTION_STR)) {
105:                        setReturnToAction(true);
106:                    } else {
107:                        assert false : "unknown value for navigateTo: \""
108:                                + navigateTo + '"';
109:                    }
110:
111:                    boolean restore = CompilerUtils.getBoolean(annotation,
112:                            RESTORE_QUERY_STRING_ATTR, false).booleanValue();
113:                    setRestoreQueryString(restore);
114:                    setPath(navigateTo); // set the actual navigateTo value as the path -- the runtime expects it there
115:                } else if (tilesDefinition != null) {
116:                    assert path == null;
117:                    setPath(tilesDefinition); // set the tilesDefinition as the path -- the runtime expects it there
118:                } else {
119:                    assert path != null; // checker should enforce this
120:
121:                    //
122:                    // Translate our relative-path convention (normal) to the Struts convention, which adds a '/'
123:                    // to any module-relative path.
124:                    //
125:                    boolean contextRelative = true;
126:                    if (!path.startsWith("/")) {
127:                        contextRelative = false;
128:
129:                        // If it's an absolute URL, then the path shouldn't have a slash inserted in front of it.
130:                        if (!CompilerUtils.isAbsoluteURL(path)) {
131:                            path = '/' + path;
132:
133:                            // See if we should be using the path for the struts module that this forward is relative to
134:                            TypeDeclaration typeDeclaration = annotation
135:                                    .getContainingType();
136:
137:                            if (!typeDeclaration.equals(jclass)
138:                                    && !path.endsWith(ACTION_EXTENSION_DOT)
139:                                    && parent.getFlowControllerInfo()
140:                                            .getMergedControllerAnnotation()
141:                                            .isInheritLocalPaths()) {
142:                                setRelativeTo(CompilerUtils
143:                                        .inferModulePathFromType(typeDeclaration));
144:                            }
145:                        }
146:                    }
147:
148:                    setPath(path);
149:                    setContextRelative(contextRelative);
150:                }
151:
152:                addActionOutputs(annotation, jclass);
153:
154:                if (commentSuffix != null) {
155:                    setComment("forward \"" + getName() + '"' + commentSuffix); // @TODO I18N the comment
156:                }
157:            }
158:
159:            static void addForwards(AnnotationInstance annotation,
160:                    ForwardContainer container, ClassDeclaration jclass,
161:                    GenStrutsApp strutsApp, String commentSuffix) {
162:                List forwards = CompilerUtils.getAnnotationArray(annotation,
163:                        FORWARDS_ATTR, true);
164:                addForwards(forwards, container, jclass, strutsApp,
165:                        commentSuffix);
166:            }
167:
168:            static void addForwards(Collection forwards,
169:                    ForwardContainer container, ClassDeclaration jclass,
170:                    GenStrutsApp strutsApp, String commentSuffix) {
171:                if (forwards != null) {
172:                    for (Iterator ii = forwards.iterator(); ii.hasNext();) {
173:                        AnnotationInstance ann = (AnnotationInstance) ii.next();
174:                        container.addForward(new GenForwardModel(strutsApp,
175:                                ann, jclass, commentSuffix));
176:                    }
177:                }
178:            }
179:
180:            protected void addActionOutputs(AnnotationInstance annotation,
181:                    ClassDeclaration jclass) {
182:                List actionOutputs = CompilerUtils.getAnnotationArray(
183:                        annotation, ACTION_OUTPUTS_ATTR, true);
184:
185:                if (actionOutputs != null) {
186:                    for (Iterator ii = actionOutputs.iterator(); ii.hasNext();) {
187:                        AnnotationInstance ann = (AnnotationInstance) ii.next();
188:                        addActionOutput(new GenActionOutputModel(ann, jclass));
189:                    }
190:                }
191:            }
192:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.