Source Code Cross Referenced for DatabaseTableModelAdapter.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:        import net.xoetrope.xui.data.XModelAdapter;
005:
006:        /**
007:         * <p>Adapts an XModel to provide access to child nodes as a list.</p>
008:         * <p>Copyright: Copyright (c) Xoetrope Ltd., 1998-2003<br>
009:         * License:      see license.txt
010:         * $Revision: 1.2 $
011:         */
012:        public class DatabaseTableModelAdapter implements  XModelAdapter {
013:            private DatabaseTableModel model;
014:            private int outputFieldIdx = 0;
015:
016:            /**
017:             * Create a new adapter for a model node
018:             * @param src the node to adapt
019:             */
020:            public DatabaseTableModelAdapter(XModel src) {
021:                model = (DatabaseTableModel) src;
022:            }
023:
024:            /**
025:             * Create a new adapter for a model node
026:             */
027:            public DatabaseTableModelAdapter() {
028:            }
029:
030:            /**
031:             * Get the number of children that the model node has
032:             * @return the number of children
033:             */
034:            public int getNumChildren() {
035:                return model.getNumChildren();
036:            }
037:
038:            /**
039:             * Gets the individual list item value
040:             * @param i The index of the listitem
041:             * @return The value of the listitem
042:             */
043:            public Object get(int i) {
044:                DatabaseRowModel row = (DatabaseRowModel) model.get(i);
045:                return row.getFieldValue(outputFieldIdx);
046:            }
047:
048:            /**
049:             * Gets the individual list item value
050:             * @param i The index of the listitem
051:             * @param fieldIdx the field index
052:             * @return The value of the listitem
053:             */
054:            public Object get(int i, int fieldIdx) {
055:                DatabaseRowModel row = (DatabaseRowModel) model.get(i);
056:                return row.getFieldValue(fieldIdx);
057:            }
058:
059:            /**
060:             * Set the value of the listitem
061:             * @param o The new value
062:             */
063:            public void set(Object o) {
064:                model.set(o);
065:            }
066:
067:            /**
068:             * Gets the value of the selected item from the list.
069:             * @return
070:             */
071:            public Object getSelected() {
072:                return model.get();
073:            }
074:
075:            /**
076:             * Gets the value of the selected item from the list.
077:             * @return
078:             */
079:            public Object getSelected(int fieldIdx) {
080:                return model.getFieldValue(fieldIdx);
081:            }
082:
083:            /**
084:             * Set the field to return for lists;
085:             * @param fieldIdx
086:             */
087:            public void setOutputField(int fieldIdx) {
088:                outputFieldIdx = fieldIdx;
089:            }
090:
091:            /**
092:             * Set the adapter source
093:             */
094:            public XModel getModel() {
095:                return model;
096:            }
097:
098:            /**
099:             * Set the adapter source
100:             * @param src the model
101:             */
102:            public void setModel(XModel src) {
103:                model = (DatabaseTableModel) src;
104:            }
105:
106:            /**
107:             * Locate a key value in the underlying data source
108:             * @param key the key to locate
109:             * @param keyColumnIdx the index of the key column
110:             * @return the row/record index taht contains the first instance of the key,
111:             * or -1 if the key is not found
112:             */
113:            public int find(String key, int keyColumnIdx) {
114:                model.sync();
115:                int numChildren = model.getNumChildren();
116:                for (int i = 0; i < numChildren; i++) {
117:                    String s = model.get(i).get(keyColumnIdx).toString();
118:                    if (s.equals(key))
119:                        return i;
120:                }
121:                return -1;
122:            }
123:
124:            /**
125:             * Force a sync/update of the table
126:             */
127:            public void sync() {
128:                model.sync();
129:            }
130:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.