Source Code Cross Referenced for CondicaoSQL.java in  » ERP-CRM-Financial » Personal-Finance-Manager » br » com » igor » db » 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 » ERP CRM Financial » Personal Finance Manager » br.com.igor.db 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Created on 12/12/2006
003:         * 
004:         * Swing Components - visit http://sf.net/projects/gfd
005:         * 
006:         * Copyright (C) 2006  Igor Regis da Silva Simões
007:         * 
008:         * This program is free software; you can redistribute it and/or
009:         * modify it under the terms of the GNU General Public License
010:         * as published by the Free Software Foundation; either version 2
011:         * of the License, or (at your option) any later version.
012:         *
013:         * This program is distributed in the hope that it will be useful,
014:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
015:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
016:         * GNU General Public License for more details.
017:         *
018:         * You should have received a copy of the GNU General Public License
019:         * along with this program; if not, write to the Free Software
020:         * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
021:         * 
022:         */
023:        package br.com.igor.db;
024:
025:        import static br.com.igor.db.CondicaoSQL.Condicao.BETWEEN;
026:        import static br.com.igor.db.CondicaoSQL.Condicao.IGUAL;
027:        import static br.com.igor.db.CondicaoSQL.Condicao.IS_NULL;
028:        import static br.com.igor.db.CondicaoSQL.Condicao.MAIOR;
029:        import static br.com.igor.db.CondicaoSQL.Condicao.MAIOR_IGUAL;
030:        import static br.com.igor.db.CondicaoSQL.Condicao.MENOR;
031:        import static br.com.igor.db.CondicaoSQL.Condicao.MENOR_IGUAL;
032:
033:        /**
034:         * Monta uma condição de clausula where sql com os parametros 
035:         * passados conforme descrito a seguir:
036:         * 
037:         * Condição <br>
038:         *      MAIOR:  coluna  <  valor <br>
039:         *      MAIOR_IGUAL: coluna <= valor <br>
040:         *      MENOR: coluna > valor <br>
041:         *      MENOR_IGUAL: coluna >= valor <br>
042:         *      IGUAL: coluna = valor <br>
043:         *      IS_NULL: coluna IS NULL <br>
044:         *      BETWEEN: coluna between valor and valor_2 <br>
045:         *
046:         * @author Igor Regis da Silva Simoes
047:         * @since 12/12/2006
048:         */
049:        public class CondicaoSQL<E extends Object> {
050:            public enum Condicao {
051:                IGUAL, MAIOR, MENOR, BETWEEN, MAIOR_IGUAL, MENOR_IGUAL, IS_NULL
052:            }
053:
054:            private String coluna = null;
055:
056:            private E valor = null;
057:
058:            private E valor_2 = null;
059:
060:            private Condicao condicao;
061:
062:            /**
063:             *  Condição <br> 
064:             *      MAIOR:  coluna > valor <br>
065:             *      MAIOR_IGUAL: coluna >= valor <br>
066:             *      MENOR: coluna < valor <br>
067:             *      MENOR_IGUAL: coluna <= valor <br>
068:             *      IGUAL: coluna = valor <br>
069:             *      IS_NULL: coluna IS NULL <br>
070:             *      BETWEEN: coluna between valor and valor_2 <br>
071:             *      
072:             * @param coluna
073:             * @param valor
074:             * @param condicao
075:             */
076:            public CondicaoSQL(String coluna, E valor, Condicao condicao) {
077:                setColuna(coluna);
078:                setValor(valor);
079:                setCondicao(condicao);
080:            }
081:
082:            /**
083:             *  Condição <br> 
084:             *      MAIOR:  coluna > valor <br>
085:             *      MAIOR_IGUAL: coluna >= valor <br>
086:             *      MENOR: coluna < valor <br>
087:             *      MENOR_IGUAL: coluna <= valor <br>
088:             *      IGUAL: coluna = valor <br>
089:             *      IS_NULL: coluna IS NULL <br>
090:             *      BETWEEN: coluna between valor and valor_2 <br>
091:             *      
092:             * @param coluna
093:             * @param condicao
094:             */
095:            @SuppressWarnings("unchecked")
096:            public CondicaoSQL(String coluna, Condicao condicao) {
097:                setColuna(coluna);
098:                setCondicao(condicao);
099:            }
100:
101:            /**
102:             *  Condição <br> 
103:             *      MAIOR:  coluna > valor <br>
104:             *      MAIOR_IGUAL: coluna >= valor <br>
105:             *      MENOR: coluna < valor <br>
106:             *      MENOR_IGUAL: coluna <= valor <br>
107:             *      IGUAL: coluna = valor <br>
108:             *      IS_NULL: coluna IS NULL <br>
109:             *      BETWEEN: coluna between valor and valor_2 <br>
110:             *      
111:             * @param coluna
112:             * @param valor
113:             * @param valor_2
114:             * @param condicao
115:             */
116:            public CondicaoSQL(String coluna, E valor, E valor_2,
117:                    Condicao condicao) {
118:                setColuna(coluna);
119:                setValor(valor);
120:                setValor_2(valor_2);
121:                setCondicao(condicao);
122:            }
123:
124:            public String getColuna() {
125:                return "\"" + coluna + "\"";
126:            }
127:
128:            public void setColuna(String coluna) {
129:                this .coluna = coluna;
130:            }
131:
132:            public E getValor() {
133:                return valor;
134:            }
135:
136:            public void setValor(E valor) {
137:                this .valor = valor;
138:            }
139:
140:            public E getValor_2() {
141:                return valor_2;
142:            }
143:
144:            public void setValor_2(E valor_2) {
145:                this .valor_2 = valor_2;
146:            }
147:
148:            public Condicao getCondicao() {
149:                return condicao;
150:            }
151:
152:            public void setCondicao(Condicao condicao) {
153:                this .condicao = condicao;
154:            }
155:
156:            @Override
157:            public String toString() {
158:                switch (condicao) {
159:                case MAIOR:
160:                    return " " + coluna + " > " + valor + " ";
161:                case MAIOR_IGUAL:
162:                    return " " + coluna + " >= " + valor + " ";
163:                case MENOR:
164:                    return " " + coluna + " < " + valor + " ";
165:                case MENOR_IGUAL:
166:                    return " " + coluna + " <= " + valor + " ";
167:                case IGUAL:
168:                    return " " + coluna + " = " + valor + " ";
169:                case IS_NULL:
170:                    return " " + coluna + " IS NULL ";
171:                case BETWEEN:
172:                    if (valor_2 == null)
173:                        throw new RuntimeException(
174:                                "Invalid value for value_2 property");
175:                    return " " + coluna + " between " + valor + " and "
176:                            + valor_2 + " ";
177:                default:
178:                    return "<empty condition>";
179:                }
180:            }
181:
182:            public String getParsedString() {
183:                switch (condicao) {
184:                case MAIOR:
185:                    return " " + getColuna() + " > ? ";
186:                case MAIOR_IGUAL:
187:                    return " " + getColuna() + " >= ? ";
188:                case MENOR:
189:                    return " " + getColuna() + " < ? ";
190:                case MENOR_IGUAL:
191:                    return " " + getColuna() + " <= ? ";
192:                case IGUAL:
193:                    return " " + getColuna() + " = ? ";
194:                case IS_NULL:
195:                    return " " + getColuna() + " IS NULL ";
196:                case BETWEEN:
197:                    if (valor_2 == null)
198:                        throw new RuntimeException(
199:                                "Invalid value for value_2 property");
200:                    return " " + getColuna() + " between ? and ? ";
201:                default:
202:                    return "<empty condition>";
203:                }
204:            }
205:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.