Source Code Cross Referenced for DSDataStoreDescriptor.java in  » J2EE » Sofia » com » salmonllc » sql » 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 » J2EE » Sofia » com.salmonllc.sql 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        //** Copyright Statement ***************************************************
002:        //The Salmon Open Framework for Internet Applications (SOFIA)
003:        // Copyright (C) 1999 - 2002, Salmon LLC
004:        //
005:        // This program is free software; you can redistribute it and/or
006:        // modify it under the terms of the GNU General Public License version 2
007:        // as published by the Free Software Foundation;
008:        //
009:        // This program is distributed in the hope that it will be useful,
010:        // but WITHOUT ANY WARRANTY; without even the implied warranty of
011:        // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
012:        // GNU General Public License for more details.
013:        //
014:        // You should have received a copy of the GNU General Public License
015:        // along with this program; if not, write to the Free Software
016:        // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
017:        //
018:        // For more information please visit http://www.salmonllc.com
019:        //** End Copyright Statement ***************************************************
020:        package com.salmonllc.sql;
021:
022:        /////////////////////////
023:        //$Archive: /SOFIA/SourceCode/com/salmonllc/sql/DSDataStoreDescriptor.java $
024:        //$Author: Dan $
025:        //$Revision: 27 $
026:        //$Modtime: 11/02/04 3:55p $
027:        /////////////////////////
028:
029:        import java.util.*;
030:
031:        /**
032:         * This class is public as an implementation detail. It should not be used outside the framework.
033:         */
034:        public class DSDataStoreDescriptor implements  java.io.Serializable {
035:            private Vector _columns = new Vector();
036:            private Vector _joins = new Vector(1, 1);
037:            private Vector _aliases = new Vector(1, 1);
038:            private String _defaultTable;
039:            private String _whereClause;
040:            private String _groupByClause;
041:            private String _havingClause;
042:            private String _orderByClause;
043:            private boolean _distinct = false;
044:            private boolean _trimStrings = true;
045:            private Hashtable _columnIndexes = new Hashtable();
046:            private Object[] _nullValues;
047:            private int _booleanDataType = DataStoreBuffer.DATATYPE_SHORT;
048:            private Object _booleanTrueValue = new Short((short) 1);
049:            private Object _booleanFalseValue = new Short((short) 0);
050:
051:            public DSDataStoreDescriptor() {
052:                super ();
053:            }
054:
055:            public void addAlias(String table, String alias) {
056:
057:                if (alias != null) {
058:                    for (int i = 0; i < _aliases.size(); i++) {
059:                        DSTableAliasDescriptor test = (DSTableAliasDescriptor) _aliases
060:                                .elementAt(i);
061:                        if (test.getAlias() != null
062:                                && test.getAlias().equalsIgnoreCase(alias))
063:                            return;
064:                    }
065:                } else {
066:                    for (int i = 0; i < _aliases.size(); i++) {
067:                        DSTableAliasDescriptor test = (DSTableAliasDescriptor) _aliases
068:                                .elementAt(i);
069:                        if (test.getTable().equalsIgnoreCase(table)) {
070:                            if (alias != null)
071:                                test.setAlias(alias);
072:                            return;
073:                        } else if (test.getAlias() != null) {
074:                            if (test.getAlias().equalsIgnoreCase(table)) {
075:                                return;
076:                            }
077:                        }
078:                    }
079:                }
080:
081:                DSTableAliasDescriptor d = new DSTableAliasDescriptor(table,
082:                        alias);
083:                _aliases.addElement(d);
084:            }
085:
086:            public synchronized void addColumn(DSColumnDescriptor col) {
087:                _columns.addElement(col);
088:
089:                String cName = null;
090:                String cName2 = null;
091:
092:                if (col.getInternalName() != null) {
093:                    cName = col.getInternalName();
094:                    if (col.getTable() == null)
095:                        if (getDefaultTable() == null)
096:                            cName2 = col.getColumn();
097:                        else
098:                            cName2 = getDefaultTable() + "." + col.getColumn();
099:                    else
100:                        cName2 = col.getTable() + "." + col.getColumn();
101:                } else {
102:                    if (col.getTable() == null)
103:                        if (getDefaultTable() == null)
104:                            cName = col.getColumn();
105:                        else
106:                            cName = getDefaultTable() + "." + col.getColumn();
107:                    else
108:                        cName = col.getTable() + "." + col.getColumn();
109:                }
110:
111:                Integer index = new Integer(_columns.size() - 1);
112:                String check = cName.toUpperCase();
113:                if (!_columnIndexes.containsKey(check))
114:                    _columnIndexes.put(check, index);
115:
116:                if (cName2 != null) {
117:                    check = cName2.toUpperCase();
118:                    if (!_columnIndexes.containsKey(check))
119:                        _columnIndexes.put(check, index);
120:                }
121:            }
122:
123:            public void addColumn(String table, String column, int type,
124:                    boolean primaryKey, boolean updateable, String internalName) {
125:                if (table != null)
126:                    addAlias(table, null);
127:
128:                DSColumnDescriptor d = new DSColumnDescriptor(table, column,
129:                        type, primaryKey, updateable);
130:                if (type == DataStoreBuffer.DATATYPE_BYTEARRAY) {
131:                    d.setUseBind(DataStoreBuffer.BIND_TRUE);
132:                    d.setConcurrency(false);
133:                }
134:                d.setInternalName(internalName);
135:                addColumn(d);
136:            }
137:
138:            public void addJoin(String left, String right, boolean outer) {
139:                DSJoinDescriptor d = new DSJoinDescriptor(left, right, outer);
140:                _joins.addElement(d);
141:            }
142:
143:            //fc 06/11/04: Added Method to specify the Relationship of the join. (Use for Master/Detail scenario)
144:            public void addJoin(String left, String right, boolean outer,
145:                    int reltype) {
146:                DSJoinDescriptor d = new DSJoinDescriptor(left, right, outer,
147:                        reltype);
148:                _joins.addElement(d);
149:            }
150:
151:            public DSTableAliasDescriptor getAlias(int index) {
152:                if (index < 0 || index >= _aliases.size())
153:                    return null;
154:                return (DSTableAliasDescriptor) _aliases.elementAt(index);
155:            }
156:
157:            public int getAliasCount() {
158:                return _aliases.size();
159:            }
160:
161:            public DSColumnDescriptor getColumn(int index) {
162:                if (index < 0 || index >= _columns.size())
163:                    return null;
164:                return (DSColumnDescriptor) _columns.elementAt(index);
165:            }
166:
167:            public int getColumnCount() {
168:                return _columns.size();
169:            }
170:
171:            public int getColumnIndex(String column) {
172:                Integer i = (Integer) _columnIndexes.get(column.toUpperCase());
173:                if (i == null) {
174:
175:                    /*
176:                    DAN Leave this it is useful for debugging problems
177:                    MessageLog.writeInfoMessage("getColumnIndex : *** COLUMN " + column + " NOT FOUND ***", Props.LOG_LEVEL_9, this);
178:                     */
179:                    return -1;
180:                } else {
181:                    return i.intValue();
182:                }
183:
184:            }
185:
186:            public String getDefaultTable() {
187:                return _defaultTable;
188:            }
189:
190:            public boolean getDistinct() {
191:                return _distinct;
192:            }
193:
194:            public String getGroupByClause() {
195:                return _groupByClause;
196:            }
197:
198:            public String getHavingClause() {
199:                return _havingClause;
200:            }
201:
202:            public DSJoinDescriptor getJoin(int index) {
203:                if (index < 0 || index >= _joins.size())
204:                    return null;
205:                return (DSJoinDescriptor) _joins.elementAt(index);
206:            }
207:
208:            public int getJoinCount() {
209:                return _joins.size();
210:            }
211:
212:            public String getOrderByClause() {
213:                return _orderByClause;
214:            }
215:
216:            public boolean getTrimStrings() {
217:                return _trimStrings;
218:            }
219:
220:            public String getWhereClause() {
221:                return _whereClause;
222:            }
223:
224:            public synchronized void removeColumn(String column) {
225:                int ndx = getColumnIndex(column);
226:                if (ndx > -1) {
227:                    _columns.removeElementAt(ndx);
228:                    Enumeration e = _columnIndexes.keys();
229:                    while (e.hasMoreElements()) {
230:                        String s = (String) e.nextElement();
231:                        int ndx1 = ((Integer) _columnIndexes.get(s)).intValue();
232:                        if (ndx1 == ndx)
233:                            _columnIndexes.remove(s);
234:                        else if (ndx1 > ndx)
235:                            _columnIndexes.put(s, new Integer(ndx1 - 1));
236:                    }
237:                }
238:            }
239:
240:            public void removeJoin(String left, String right) {
241:                DSJoinDescriptor des = null;
242:                String jNameLeft = "";
243:                String jNameRight = "";
244:                // look through the columns
245:                for (int i = 0; i < getJoinCount(); i++) {
246:                    des = getJoin(i);
247:                    jNameLeft = "";
248:                    jNameRight = "";
249:
250:                    // LEFT SIDE
251:                    for (int leftIndex = 0; leftIndex < des.getLeftCount(); leftIndex++) {
252:                        // go through append comma for all except for last
253:                        if (des.getLeftCount() - 1 != leftIndex) {
254:                            jNameLeft += des.getLeftColumn(leftIndex) + ",";
255:                        } else {
256:                            jNameLeft += des.getLeftColumn(leftIndex);
257:                        }
258:                    }
259:
260:                    // RIGHT SIDE
261:                    for (int rightIndex = 0; rightIndex < des.getRightCount(); rightIndex++) {
262:                        // go through append comma for all except for last
263:                        if (des.getRightCount() - 1 != rightIndex) {
264:                            jNameRight += des.getRightColumn(rightIndex) + ",";
265:                        } else {
266:                            jNameRight += des.getRightColumn(rightIndex);
267:                        }
268:                    }
269:
270:                    //
271:                    if (left.equalsIgnoreCase(jNameLeft)
272:                            && right.equalsIgnoreCase(jNameRight)) {
273:                        // if found removw from _column vector
274:                        _joins.removeElementAt(i);
275:                        break;
276:                    }
277:                    // if found removw from _join vector
278:
279:                }
280:            }
281:
282:            public void removeTableAlias(String table) {
283:                DSTableAliasDescriptor des = null;
284:                // look through the columns
285:                for (int i = 0; i < getAliasCount(); i++) {
286:                    des = getAlias(i);
287:                    String tableName = null;
288:                    tableName = des.getTable();
289:                    if (table.equalsIgnoreCase(tableName)) {
290:                        // if found removw from _column vector
291:                        _aliases.removeElementAt(i);
292:                        break;
293:                    }
294:                }
295:            }
296:
297:            public String resolveTable(String table) {
298:                if (table.equals(_defaultTable))
299:                    return _defaultTable;
300:                for (int i = 0; i < getAliasCount(); i++) {
301:                    DSTableAliasDescriptor d = getAlias(i);
302:                    if (table.equals(d.getTable()))
303:                        return table;
304:                    else if (table.equals(d.getAlias()))
305:                        return d.getTable();
306:                }
307:                return null;
308:            }
309:
310:            public void setDefaultTable(String table) {
311:                _defaultTable = table;
312:            }
313:
314:            public void setDistinct(boolean distinct) {
315:                _distinct = distinct;
316:            }
317:
318:            public void setGroupByClause(String groupByClause) {
319:                _groupByClause = groupByClause;
320:            }
321:
322:            public void setHavingClause(String havingClause) {
323:                _havingClause = havingClause;
324:            }
325:
326:            public void setOrderByClause(String orderByClause) {
327:                _orderByClause = orderByClause;
328:            }
329:
330:            public void setTrimStrings(boolean trim) {
331:                _trimStrings = trim;
332:            }
333:
334:            public void setWhereClause(String whereClause) {
335:                _whereClause = whereClause;
336:            }
337:
338:            public void setNullDefault(int type, Object value) {
339:                if (_nullValues == null)
340:                    _nullValues = new Object[10];
341:                _nullValues[type] = value;
342:            }
343:
344:            public Object getNullDefault(int type) {
345:                if (_nullValues == null)
346:                    return null;
347:                return _nullValues[type];
348:            }
349:
350:            public boolean areNullDefaultsDefined() {
351:                return (_nullValues != null);
352:            }
353:
354:            public int getBooleanDataType() {
355:                return _booleanDataType;
356:            }
357:
358:            public Object getBooleanFalseValue() {
359:                return _booleanFalseValue;
360:            }
361:
362:            public Object getBooleanTrueValue() {
363:                return _booleanTrueValue;
364:            }
365:
366:            public void setBooleanRepresentation(int dataType,
367:                    Object trueValue, Object falseValue) {
368:                _booleanDataType = dataType;
369:                _booleanTrueValue = trueValue;
370:                _booleanFalseValue = falseValue;
371:            }
372:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.