Source Code Cross Referenced for DatabaseRowModel.java in  » XML-UI » XUI » net » xoetrope » optional » data » 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 » XML UI » XUI » net.xoetrope.optional.data.sql 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package net.xoetrope.optional.data.sql;
002:
003:        import net.xoetrope.xui.data.XModel;
004:
005:        /**
006:         * <p>Provides a model for table rows. The attributes are equivalent to the row
007:         * fields. The row will have no children. As a Java object the fields and rows
008:         * indices are zero based in contrast to the JDBC indexing setup.</p>
009:         * <p>Copyright (c) Xoetrope Ltd. 2001-2003</p>
010:         * $Revision: 1.1 $
011:         */
012:        public class DatabaseRowModel extends XModel {
013:            protected int rowIdx;
014:            protected DatabaseTableModel xtable;
015:
016:            /**
017:             * Default constructor, no table or row is referenced
018:             */
019:            public DatabaseRowModel() {
020:            }
021:
022:            /**
023:             * Construct a model node for a table
024:             * @param table the table to reference
025:             * @param row the row to reference
026:             */
027:            public DatabaseRowModel(DatabaseTableModel table, int row) {
028:                xtable = table;
029:                rowIdx = row;
030:            }
031:
032:            /**
033:             * Get the referenced table
034:             * @return
035:             */
036:            public DatabaseTableModel getTable() {
037:                return xtable;
038:            }
039:
040:            /**
041:             * Set the row to reference
042:             * @param table the table to reference
043:             * @param row the row to reference
044:             */
045:            public void setRowReference(DatabaseTableModel table, int row) {
046:                xtable = table;
047:                rowIdx = row;
048:            }
049:
050:            /**
051:             * Get a field as a double value
052:             * @param elementName the field name
053:             * @return
054:             */
055:            public double getValueAsDouble(String elementName) {
056:                /**This method is inappropriate for this node type*/
057:                throw new java.lang.UnsupportedOperationException(
058:                        "Method getValueAsDouble() not yet implemented.");
059:            }
060:
061:            /**
062:             * Get a field value
063:             * @param attribName the field name
064:             * @return
065:             */
066:            public Object get(String attribName) {
067:                return new DatabaseFieldModel(xtable, rowIdx, xtable
068:                        .getAttribute(attribName));
069:            }
070:
071:            /**
072:             * Gets the model element tag name, e.g. 'Component' from the XML fragment
073:             * <Component ....
074:             * @return the model element name
075:             */
076:            public String getTagName() {
077:                return "";
078:            }
079:
080:            /**
081:             * Append a node
082:             * @param childNode the child node
083:             */
084:            public void append(XModel newObject) {
085:                /**@todo Implement this net.xoetrope.xui.data.XModel abstract method*/
086:            }
087:
088:            /**
089:             * Get a field value as an int
090:             * @param attribName the fieldName
091:             * @return the value
092:             */
093:            public int getInt(String attribName) {
094:                return new Integer(xtable.getFieldValue(rowIdx, xtable
095:                        .getAttribute(attribName))).intValue();
096:            }
097:
098:            /**
099:             * Get a field value as an double
100:             * @param attribName the fieldName
101:             * @return the value
102:             */
103:            public double getDouble(String attribName) {
104:                return new Double(xtable.getFieldValue(rowIdx, xtable
105:                        .getAttribute(attribName))).doubleValue();
106:            }
107:
108:            /**
109:             * Get a field value as an String
110:             * @param attribName the fieldName
111:             * @return the value
112:             */
113:            public String getString(String attribName) {
114:                return xtable.getFieldValue(rowIdx, xtable
115:                        .getAttribute(attribName));
116:            }
117:
118:            /**
119:             * Get the value of the first field in this row
120:             * @return
121:             */
122:            public String getValue() {
123:                return xtable.getFieldValue(rowIdx, 0);
124:            }
125:
126:            /**
127:             * Gets an individual field value
128:             * @param fieldIdx the field index
129:             * @return the value
130:             */
131:            public String getFieldValue(int fieldIdx) {
132:                return xtable.getFieldValue(rowIdx, fieldIdx);
133:            }
134:
135:            /**
136:             * Get the value of an attribute
137:             * @param i
138:             * @return
139:             */
140:            public Object getAttribValue(int i) {
141:                return xtable.getAttribValue(i);
142:            }
143:
144:            public String getAttribValueAsString(int i) {
145:                return xtable.getAttribValueAsString(i);
146:            }
147:
148:            /**
149:             * Gets the value attribute of the specified node as a string.
150:             * @param elementName
151:             * @return the value as a string
152:             */
153:            public String getValueAsString(String elementName) {
154:                return xtable.getAttribValueAsString(xtable
155:                        .getAttribute(elementName));
156:            }
157:
158:            /**
159:             * Get the ID of this row
160:             * @return
161:             */
162:            public String getId() {
163:                return new Integer(rowIdx).toString();
164:            }
165:
166:            public String getAttribName(int i) {
167:                return xtable.getAttribName(i);
168:            }
169:
170:            public int getAttribute(String attribName) {
171:                return xtable.getAttribute(attribName);
172:            }
173:
174:            public void set(String attribName, Object newObject) {
175:                /**@todo Implement this net.xoetrope.xui.data.XModel abstract method*/
176:            }
177:
178:            public void set(Object s) {
179:                /**@todo Implement this net.xoetrope.xui.data.XModel abstract method*/
180:                fireModelUpdated();
181:            }
182:
183:            public XModel get(int i) {
184:                return new DatabaseFieldModel(xtable, rowIdx, i);
185:            }
186:
187:            public Object get() {
188:                return new DatabaseFieldModel(xtable, rowIdx, 0);
189:            }
190:
191:            public Object append(String id) {
192:                return null;
193:            }
194:
195:            public int getValueAsInt(String elementName) {
196:                /**This method is inappropriate for this node type*/
197:                throw new java.lang.UnsupportedOperationException(
198:                        "Method getValueAsInt() not yet implemented.");
199:            }
200:
201:            /**
202:             * Get the value of a field as a model node
203:             * @param i the field index
204:             * @return the new field model node
205:             */
206:            public XModel getValue(int i) {
207:                return new DatabaseFieldModel(xtable, rowIdx, i);
208:            }
209:
210:            public void setAttribValue(int i, Object value) {
211:                xtable.setFieldValue(i, value.toString());
212:            }
213:
214:            public void setAttribValue(int i, String attribName, Object value) {
215:                xtable.setFieldValue(i, value.toString());
216:            }
217:
218:            /**
219:             * Set the value of a field
220:             * @param colIdx the field index
221:             * @param newValue the new field value
222:             */
223:            public void setFieldValue(int colIdx, String newValue) {
224:                xtable.setFieldValue(colIdx, newValue);
225:            }
226:
227:            /**
228:             * Get the hashcode for this row
229:             * @return the row id
230:             */
231:            public int hashCode() {
232:                return rowIdx;
233:            }
234:
235:            /**
236:             * Gets the number of fields for this row
237:             * @return the number of fields
238:             */
239:            public int getNumChildren() {
240:                return xtable.xtable.numFields;
241:            }
242:
243:            /**
244:             * @param i The index of the attributeValues array whose value we want
245:             * @return The double value of the attributeValues array at position i
246:             */
247:            public double getAttribValueAsDouble(int i) {
248:                return new Double(xtable.getAttribValueAsString(i))
249:                        .doubleValue();
250:            }
251:
252:            /**
253:             * @param i The index of the attributeValues array whose value we want
254:             * @return The int value of the attributeValues array at position i
255:             */
256:            public int getAttribValueAsInt(int i) {
257:                return new Integer(xtable.getAttribValueAsString(i)).intValue();
258:            }
259:
260:            /**
261:             * Remove a node
262:             * @param childnode node to be removed
263:             */
264:            public void remove(XModel node) {
265:                /**@todo Implement this abstract method*/
266:                throw new java.lang.UnsupportedOperationException(
267:                        "Method remove() not yet implemented.");
268:            }
269:
270:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.