Source Code Cross Referenced for DataStoreRow.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:        import java.sql.*;
023:
024:        /**
025:         * This class encapsulates one row in a DataStore Buffer.
026:         */
027:        public class DataStoreRow {
028:            DataStoreBuffer _ds;
029:            DSDataRow _row;
030:            DSDataStoreDescriptor _desc;
031:
032:            DataStoreRow(DataStoreBuffer ds, DSDataRow row,
033:                    DSDataStoreDescriptor desc) {
034:                super ();
035:                _ds = ds;
036:                _row = row;
037:                _desc = desc;
038:            }
039:
040:            private void checkColNo(int colNo) throws DataStoreException {
041:                if (colNo < 0 || colNo >= _desc.getColumnCount())
042:                    throw new DataStoreException("Specified column (" + colNo
043:                            + ") is out of range.");
044:            }
045:
046:            private int getColNo(String colName) throws DataStoreException {
047:                int colNo = _desc.getColumnIndex(colName);
048:
049:                if (colNo < 0 || colNo >= _desc.getColumnCount())
050:                    throw new DataStoreException("Specified column (" + colName
051:                            + ") is out of range.");
052:
053:                return colNo;
054:            }
055:
056:            /**
057:             * This method returns the index of the column with the specified name or -1 if not found.
058:             */
059:            public int getColumnIndex(String name) {
060:                return _ds.getColumnIndex(name);
061:            }
062:
063:            /**
064:             * This method returns the number of columns.
065:             */
066:            public int getColumnCount() {
067:                return _ds.getColumnCount();
068:            }
069:
070:            /**
071:             * This method returns a list with the names of all the columns in the data store.
072:             */
073:            public String[] getColumnList() {
074:                return _ds.getColumnList();
075:            }
076:
077:            /**
078:             * This method returns the name of the column at the specified index.
079:             */
080:            public String getColumnName(int colNo) throws DataStoreException {
081:                return _ds.getColumnName(colNo);
082:            }
083:
084:            /**
085:             * This method gets the data from a column in the datastore. 
086:             * @param colNo The number of the column in the data store.
087:             */
088:            public Object getData(int colNo) throws DataStoreException {
089:                checkColNo(colNo);
090:                return _row.getData(colNo);
091:            }
092:
093:            /**
094:             * This method gets the data from a column in the datastore. If the column doesn't exist it will return null.
095:             * @param colName The name of the column in the data store.
096:             */
097:            public Object getData(String colName) throws DataStoreException {
098:                return _row.getData(getColNo(colName));
099:            }
100:
101:            /**
102:             * This method returns the datatype of the column in the datastore. 
103:             * @param colNo The number of the column in the data store.
104:             */
105:            public int getDataType(int colNo) throws DataStoreException {
106:                checkColNo(colNo);
107:                return _desc.getColumn(colNo).getType();
108:            }
109:
110:            /**
111:             * This method returns the datatype of the column in the datastore. 
112:             * @param colName The name of the column in the data store.
113:             */
114:            public int getDataType(String colName) throws DataStoreException {
115:                return getDataType(getColNo(colName));
116:            }
117:
118:            /**
119:             * This method was created in VisualAge.
120:             * @return com.salmonllc.sql.DSDataRow
121:             */
122:            public DSDataRow getDSDataRow() {
123:                return _row;
124:            }
125:
126:            /**
127:             * This method gets the original data (before any modifications were made) from a column in the datastore. 
128:             * @param colNo the column in the data store.
129:             */
130:            public Object getOriginalData(int colNo) throws DataStoreException {
131:                if (colNo < 0 || colNo >= _desc.getColumnCount())
132:                    throw new DataStoreException("Specified column (" + colNo
133:                            + ") is out of range.");
134:
135:                return _row.getOrigData(colNo);
136:            }
137:
138:            /**
139:             * This method gets the original data (before any modifications were made) from a column in the datastore. 
140:             * @param colName the column in the data store.
141:             */
142:            public Object getOriginalData(String colName)
143:                    throws DataStoreException {
144:                return _row.getOrigData(getColNo(colName));
145:            }
146:
147:            /**
148:             * This method gets the status of the column in the row. Returns true if the column has been modified since the original retrieve.
149:             */
150:            public boolean isColumnModified(int colNo)
151:                    throws DataStoreException {
152:                checkColNo(colNo);
153:                return (_row.getColumnStatus(colNo) == DataStoreBuffer.STATUS_MODIFIED);
154:            }
155:
156:            /**
157:             * This method gets the status of the column in the row. Returns true if the column has been modified since the original retrieve.
158:             */
159:            public boolean isColumnModified(String colName)
160:                    throws DataStoreException {
161:                return isColumnModified(getColNo(colName));
162:            }
163:
164:            /**
165:             * Use this method to populate the row from a result set. The result set must be 100% compatible with the structure of the datastore or an exception will be thrown.
166:             */
167:            public void populateFromResultSet(ResultSet r) throws Exception {
168:                _row.populateFromResultSet(_desc, r);
169:            }
170:
171:            /**
172:             * This method sets the status of the row and all the columns in it to not modified.
173:             */
174:            public void resetStatus() {
175:                _row.resetStatus();
176:            }
177:
178:            /**
179:             * This method sets the value of the column colNo.
180:             * @param colNo int The column to set.
181:             * @param data Object The value to set the column to.
182:             */
183:            public void setData(int colNo, Object data)
184:                    throws DataStoreException {
185:                checkColNo(colNo);
186:
187:                int type = _desc.getColumn(colNo).getType();
188:
189:                boolean dataMatch = false;
190:
191:                switch (type) {
192:                case DataStoreBuffer.DATATYPE_BYTEARRAY:
193:                    dataMatch = data instanceof  byte[];
194:                    break;
195:                case DataStoreBuffer.DATATYPE_DATE:
196:                    dataMatch = data instanceof  java.sql.Date
197:                            || data instanceof  java.sql.Timestamp;
198:                    break;
199:                case DataStoreBuffer.DATATYPE_DATETIME:
200:                    dataMatch = data instanceof  java.sql.Date
201:                            || data instanceof  java.sql.Timestamp;
202:                    break;
203:                case DataStoreBuffer.DATATYPE_DOUBLE:
204:                    dataMatch = data instanceof  Double;
205:                    break;
206:                case DataStoreBuffer.DATATYPE_FLOAT:
207:                    dataMatch = data instanceof  Float;
208:                    break;
209:                case DataStoreBuffer.DATATYPE_INT:
210:                    dataMatch = data instanceof  Integer;
211:                    break;
212:                case DataStoreBuffer.DATATYPE_LONG:
213:                    dataMatch = data instanceof  Long;
214:                    break;
215:                case DataStoreBuffer.DATATYPE_SHORT:
216:                    dataMatch = data instanceof  Short;
217:                    break;
218:                case DataStoreBuffer.DATATYPE_STRING:
219:                    dataMatch = data instanceof  String;
220:                    break;
221:                case DataStoreBuffer.DATATYPE_TIME:
222:                    dataMatch = data instanceof  java.sql.Time;
223:                    break;
224:                }
225:
226:                if (!dataMatch && data != null)
227:                    throw new DataStoreException(
228:                            "Column type mismatch. Column: " + colNo
229:                                    + " must be type: " + type + ".");
230:
231:                _row.setValue(colNo, data, _desc);
232:            }
233:
234:            /**
235:             * This method sets the value of the column colName.
236:             * @param colName String The column to set.
237:             * @param data Object The value to set the column to.
238:             */
239:            public void setData(String colName, Object data)
240:                    throws DataStoreException {
241:                setData(getColNo(colName), data);
242:            }
243:
244:            /**
245:             * Sets a temp value in the row
246:             */
247:            public void setTempValue(int colNo, String data)
248:                    throws DataStoreException {
249:                _row.setTempValue(colNo, data, _desc);
250:            }
251:
252:            /**
253:             * Sets a temp value in the row
254:             */
255:            public void setTempValue(String colName, String data)
256:                    throws DataStoreException {
257:                _row.setTempValue(getColNo(colName), data, _desc);
258:            }
259:
260:            /**
261:             * Gets a temp value from the row
262:             */
263:            public String getTempValue(int colNo) throws DataStoreException {
264:                return _row.getTempValue(colNo);
265:            }
266:
267:            /**
268:             * Gets a temp value from the row
269:             */
270:            public String getTempValue(String colName)
271:                    throws DataStoreException {
272:                return _row.getTempValue(getColNo(colName));
273:            }
274:
275:            /**
276:             * returns the column status for the row
277:             */
278:            int getColumnStatus(int colNo) {
279:                return _row.getColumnStatus(colNo);
280:            }
281:
282:            void setDSDataRow(DSDataRow row) {
283:                _row = row;
284:            }
285:
286:            /**
287:             * Copies matching values from this DataStore row to the destination row
288:             */
289:            public void copyTo(DataStoreRow dest) {
290:                DSDataStoreDescriptor destDesc = dest.getDesc();
291:                DSDataRow sourceRow = getDSDataRow();
292:                DSDataRow destRow = dest.getDSDataRow();
293:                sourceRow.copyTo(destRow, _desc, destDesc);
294:            }
295:
296:            DSDataStoreDescriptor getDesc() {
297:                return _desc;
298:            }
299:
300:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.