Source Code Cross Referenced for ValueComputer.java in  » Web-Framework » makumba » org » makumba » list » engine » valuecomputer » 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 » Web Framework » makumba » org.makumba.list.engine.valuecomputer 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        ///////////////////////////////
002:        //  Makumba, Makumba tag library
003:        //  Copyright (C) 2000-2003  http://www.makumba.org
004:        //
005:        //  This library is free software; you can redistribute it and/or
006:        //  modify it under the terms of the GNU Lesser General Public
007:        //  License as published by the Free Software Foundation; either
008:        //  version 2.1 of the License, or (at your option) any later version.
009:        //
010:        //  This library is distributed in the hope that it will be useful,
011:        //  but WITHOUT ANY WARRANTY; without even the implied warranty of
012:        //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
013:        //  Lesser General Public License for more details.
014:        //
015:        //  You should have received a copy of the GNU Lesser General Public
016:        //  License along with this library; if not, write to the Free Software
017:        //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
018:        //
019:        //  -------------
020:        //  $Id: ValueComputer.java 1394 2007-07-20 11:37:36Z manuel_gay $
021:        //  $Name$
022:        /////////////////////////////////////
023:
024:        package org.makumba.list.engine.valuecomputer;
025:
026:        import javax.servlet.jsp.JspException;
027:
028:        import org.makumba.FieldDefinition;
029:        import org.makumba.LogicException;
030:        import org.makumba.analyser.AnalysableTag;
031:        import org.makumba.analyser.PageCache;
032:        import org.makumba.commons.MultipleKey;
033:        import org.makumba.commons.attributes.PageAttributes;
034:        import org.makumba.commons.formatters.RecordFormatter;
035:        import org.makumba.list.engine.ComposedQuery;
036:        import org.makumba.list.engine.QueryExecution;
037:        import org.makumba.list.html.RecordViewer;
038:        import org.makumba.list.tags.QueryTag;
039:        import org.makumba.list.tags.ValueTag;
040:
041:        /**
042:         * Every ValueTag will build a ValueComputer at page analysis, which it then retrieves and uses at page running
043:         * 
044:         * @author Cristian Bogdan
045:         * @version $Id
046:         */
047:        public class ValueComputer {
048:
049:            /**
050:             * Determines if 'analyzed' is a queryMak:value or a nonQueryMak:value
051:             * 
052:             * @param analyzed
053:             *            the analyzed tag
054:             * @param parentListKey
055:             *            the key of the parent list
056:             * @param expr
057:             *            the expression passed in the tag
058:             * @param pageCache
059:             *            the page cache of the page
060:             */
061:            public static ValueComputer getValueComputerAtAnalysis(
062:                    AnalysableTag analyzed, MultipleKey parentListKey,
063:                    String expr, PageCache pageCache) {
064:                expr = expr.trim();
065:                Object check = QueryTag.getQuery(pageCache, parentListKey)
066:                        .checkExprSetOrNullable(expr);
067:
068:                FieldDefinition set = null;
069:                String nullableExpr = null;
070:
071:                if (check instanceof  String)
072:                    nullableExpr = (String) check;
073:
074:                if (check instanceof  FieldDefinition)
075:                    set = (FieldDefinition) check;
076:
077:                if (nullableExpr == null && set == null)
078:                    return new ValueComputer(analyzed, parentListKey, expr,
079:                            pageCache);
080:
081:                if (set == null)
082:                    return new NullableValueComputer(analyzed, parentListKey,
083:                            nullableExpr, expr, pageCache);
084:                return new SetValueComputer(analyzed, parentListKey, set, expr,
085:                        pageCache);
086:            }
087:
088:            /** The key of the parentList */
089:            MultipleKey parentKey;
090:
091:            /** The queryProjection index in the currentListData */
092:            int projectionIndex;
093:
094:            /** The queryProjection expression */
095:            String expr;
096:
097:            /** The queryProjection type */
098:            protected FieldDefinition type;
099:
100:            ValueComputer() {
101:            }
102:
103:            /**
104:             * A special ValueComputer made by mak:lists who want to select extra expressions
105:             * 
106:             * @param listKey
107:             *            the key of the list
108:             * @param parentListKey
109:             *            the key of the parent list
110:             * @param expr
111:             *            the extra expression
112:             * @param pageCache
113:             *            the page cache
114:             */
115:            ValueComputer(MultipleKey listKey, String expr, PageCache pageCache) {
116:                parentKey = listKey;
117:                this .expr = expr;
118:                QueryTag.getQuery(pageCache, parentKey).checkProjectionInteger(
119:                        expr);
120:
121:            }
122:
123:            /**
124:             * A nonQueryMak:value value computer
125:             * 
126:             * @param analyzed
127:             *            the analyzed tag
128:             * @param expr
129:             *            the expression of the tag
130:             * @param pageCache
131:             *            the page cache
132:             */
133:            ValueComputer(AnalysableTag analyzed, MultipleKey parentListKey,
134:                    String expr, PageCache pageCache) {
135:                this (parentListKey, expr, pageCache);
136:            }
137:
138:            /**
139:             * The key of the query in which this value is a projection.
140:             * 
141:             * @return The key of the parent of the value
142:             */
143:            MultipleKey getQueryKey() {
144:                return parentKey;
145:            }
146:
147:            /**
148:             * Computes the queryProjection index in the currentListData, and the queryProjection type.
149:             * 
150:             * @param pageCache
151:             *            the page cache
152:             */
153:            public void doEndAnalyze(PageCache pageCache) {
154:                ComposedQuery q = QueryTag.getQuery(pageCache, getQueryKey());
155:                projectionIndex = q.checkProjectionInteger(expr).intValue();
156:
157:                if (type == null) // if type is not set in the constructor
158:                    type = q.getResultType()
159:                            .getFieldDefinition(projectionIndex);
160:            }
161:
162:            /**
163:             * Gets the value of from the QueryExecution based on the projectionIndex
164:             * 
165:             * @param pc
166:             *            the page context
167:             * @return the computed value
168:             * @throws LogicException
169:             */
170:            public Object getValue(javax.servlet.jsp.PageContext pc)
171:                    throws LogicException {
172:                return QueryExecution.getFor(getQueryKey(), pc, null, null)
173:                        .currentListData().data[projectionIndex];
174:            }
175:
176:            /**
177:             * Formats the value of the queryProjection from the currentListData of the enclosing query. Sets the var and the
178:             * printVar values.
179:             * 
180:             * @param running
181:             *            the tag that is currently running
182:             * @param pageCache
183:             *            the page cache of the current page
184:             * @throws JspException
185:             * @throws LogicException
186:             */
187:            public void print(ValueTag running, PageCache pageCache)
188:                    throws JspException, LogicException {
189:                Object o = getValue(running.getPageContext());
190:                String s = null;
191:                if (running.getPrintVar() != null || running.getVar() == null) {
192:                    s = ((RecordViewer) pageCache.retrieve(
193:                            RecordFormatter.FORMATTERS, getQueryKey())).format(
194:                            projectionIndex, o, running.getParams());
195:                }
196:
197:                if (running.getVar() != null)
198:                    PageAttributes.setAttribute(running.getPageContext(),
199:                            running.getVar(), o);
200:                if (running.getPrintVar() != null)
201:                    running.getPageContext().setAttribute(
202:                            running.getPrintVar(), s);
203:                if (running.getPrintVar() == null && running.getVar() == null) {
204:                    try {
205:                        running.getPageContext().getOut().print(s);
206:                    } catch (Exception e) {
207:                        throw new JspException(e.toString());
208:                    }
209:                }
210:            }
211:
212:            public FieldDefinition getType() {
213:                return type;
214:            }
215:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.