Source Code Cross Referenced for ComposedSubquery.java in  » Web-Framework » makumba » org » makumba » list » engine » 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 
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: ComposedSubquery.java 1678 2007-09-24 15:36:19Z manuel_gay $
021:        //  $Name$
022:        /////////////////////////////////////
023:
024:        package org.makumba.list.engine;
025:
026:        import java.util.Enumeration;
027:        import java.util.Vector;
028:
029:        /**
030:         * A subquery of a composed query
031:         * 
032:         * @author Cristian Bogdan
033:         * @version $Id: ComposedSubquery.java 1678 2007-09-24 15:36:19Z manuel_gay $
034:         */
035:        public class ComposedSubquery extends ComposedQuery {
036:
037:            /** The enclosing query */
038:            ComposedQuery super Query;
039:
040:            /**
041:             * Make a subquery of the indicated query, from the given sections.
042:             * 
043:             * @param usesHQL
044:             *            <code>true</code> if we use Hibernate to execute the query
045:             */
046:            public ComposedSubquery(String[] subsections, ComposedQuery cq,
047:                    String queryLanguage) {
048:                super (subsections, queryLanguage);
049:                super Query = cq;
050:                super Query.addSubquery(this );
051:                derivedSections = new String[5];
052:                deriveFrom(FROM);
053:                deriveFrom(VARFROM);
054:
055:                concat(derivedSections, super Query.derivedSections, sections,
056:                        WHERE, " AND ", true);
057:                // concat(derivedSections, superQuery.derivedSections, sections, GROUPBY, ",", false);
058:                String gpb = sections[GROUPBY];
059:                if (gpb != null)
060:                    derivedSections[GROUPBY] = gpb;
061:
062:                // concat(derivedSections, superQuery.derivedSections, sections, "ORDERBY", ",");
063:                String order = sections[ORDERBY];
064:                if (order != null)
065:                    derivedSections[ORDERBY] = order;
066:            }
067:
068:            /**
069:             * Derives the FROM section using the sections of the superQuery
070:             * 
071:             * @param n
072:             *            the index of the section
073:             */
074:            void deriveFrom(int n) {
075:                derivedSections[n] = super Query.derivedSections[n];
076:                if (sections[n] != null)
077:                    if (derivedSections[n] != null)
078:                        if (sections[n].trim().toLowerCase().startsWith("join"))
079:                            // FIXME: this seems to be a dirty fix...maybe the separator should be join in all cases?
080:                            derivedSections[n] += " " + sections[n];
081:                        else
082:                            derivedSections[n] += "," + sections[n];
083:                    else
084:                        derivedSections[n] = sections[n];
085:            }
086:
087:            /**
088:             * Concatenates sections on the given index, with the given separator
089:             * 
090:             * @param result
091:             *            the String array containing the result
092:             * @param h1
093:             *            first array of sections
094:             * @param h2
095:             *            second array of sections
096:             * @param what
097:             *            the index at which we should concatenate
098:             * @pram sep the separator used for concatenation
099:             * @param paran
100:             *            do we want parenthesis
101:             */
102:            static void concat(String[] result, String[] h1, String[] h2,
103:                    int what, String sep, boolean paran) {
104:                String lp = "";
105:                String rp = "";
106:                if (paran) {
107:                    lp = "(";
108:                    rp = ")";
109:                }
110:                String s1 = h1[what];
111:                String s2 = h2[what];
112:                if (s1 != null && s1.trim().length() == 0)
113:                    s1 = null;
114:
115:                if (s2 != null && s2.trim().length() == 0)
116:                    s2 = null;
117:
118:                if (s1 == null && s2 != null) {
119:                    result[what] = s2;
120:                    return;
121:                }
122:                if (s2 == null && s1 != null) {
123:                    result[what] = s1;
124:                    return;
125:                }
126:                if (s2 != null && s1 != null)
127:                    result[what] = lp + s1 + rp + sep + lp + s2 + rp;
128:            }
129:
130:            /**
131:             * Initializes the keysets by adding the superquery's previousKeyset to its keyset.
132:             */
133:            protected void initKeysets() {
134:                previousKeyset = (Vector) super Query.previousKeyset.clone();
135:                keyset = (Vector) super Query.keyset.clone();
136:                keysetLabels = (Vector) super Query.keysetLabels.clone();
137:
138:                for (Enumeration e = keysetLabels.elements(); e
139:                        .hasMoreElements();)
140:                    addProjection((String) e.nextElement());
141:                previousKeyset.addElement(superQuery.keyset);
142:            }
143:
144:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.