Source Code Cross Referenced for ClobDescriptor.java in  » Database-Client » squirrel-sql-2.6.5a » net » sourceforge » squirrel_sql » fw » datasetviewer » cellcomponent » 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 » Database Client » squirrel sql 2.6.5a » net.sourceforge.squirrel_sql.fw.datasetviewer.cellcomponent 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package net.sourceforge.squirrel_sql.fw.datasetviewer.cellcomponent;
002:
003:        /*
004:         * Copyright (C) 2001-2004 Colin Bell
005:         * colbell@users.sourceforge.net
006:         *
007:         * This library is free software; you can redistribute it and/or
008:         * modify it under the terms of the GNU Lesser General Public
009:         * License as published by the Free Software Foundation; either
010:         * version 2.1 of the License, or (at your option) any later version.
011:         *
012:         * This library is distributed in the hope that it will be useful,
013:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
014:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
015:         * Lesser General Public License for more details.
016:         *
017:         * You should have received a copy of the GNU Lesser General Public
018:         * License along with this library; if not, write to the Free Software
019:         * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
020:         */
021:        import java.sql.Clob;
022:
023:        import net.sourceforge.squirrel_sql.fw.util.StringManager;
024:        import net.sourceforge.squirrel_sql.fw.util.StringManagerFactory;
025:
026:        /**
027:         * @author gwg
028:         *
029:         * This is the object that is actually stored in the ContentsTab table
030:         * for a CLOB field.
031:         * The data in a CLOB is handled differently than other data types.
032:         * When the row in the DB is read, what is returned is actually a
033:         * java.sql.Clob object that points to the data rather than the data itself.
034:         * Since CLOBs can be very large (and thus take a long time to read), we
035:         * provide the user the flexibility to read only part of the CLOB data, or
036:         * to not read any of it.  We use the user selected options in various operations
037:         * such as deciding if the field is editable or not.
038:         * These options are set in the Session Parameters,
039:         * and since those parameters can be changed after the data has been read, we
040:         * make a copy of the appropriate information here.
041:         */
042:        public class ClobDescriptor {
043:
044:            /**
045:             * The java.sql.Clob object that was read.
046:             */
047:            Clob _clob;
048:
049:            /**
050:             * The data read from the Clob.
051:             */
052:            String _data = null;
053:
054:            /**
055:             * If <TT>_clobRead</TT> is <TT>true</TT> then at least some
056:             * of the data in the CLOB should have been read.  If <TT>false</TT>,
057:             * then we have not even tried to read the data.
058:             */
059:            private boolean _clobRead = false;
060:
061:            /**
062:             * If <TT>_wholeClobRead</TT> is <TT>true</TT> then all of the
063:             * data in this CLOB has been read into _data..
064:             */
065:            private boolean _wholeClobRead = false;
066:
067:            /**
068:             * If <TT>_wholeClobRead</TT> is false, this is the size limit
069:             * set by the user for how much to read.
070:             */
071:            private int _userSetClobLimit;
072:
073:            /** Internationalized strings for this class. */
074:            private static final StringManager s_stringMgr = StringManagerFactory
075:                    .getStringManager(ClobDescriptor.class);
076:
077:            public static interface i18n {
078:                String CLOB_LABEL = s_stringMgr
079:                        .getString("ClobDescriptor.clob");
080:            }
081:
082:            /**
083:             * Ctor
084:             */
085:            public ClobDescriptor(Clob clob, String data, boolean clobRead,
086:                    boolean wholeClobRead, int userSetClobLimit) {
087:                _clob = clob;
088:                _data = data;
089:                _clobRead = clobRead;
090:                _wholeClobRead = wholeClobRead;
091:                _userSetClobLimit = userSetClobLimit;
092:            }
093:
094:            /**
095:             * Equals for Clobs means that the internal strings are identical,
096:             * including their length.
097:             * We need to account for the fact that one or both of them may not
098:             * have actually had their data read.  If both have not had their data read,
099:             * then they are "equal", in a wierd kind of way.
100:             */
101:            public boolean equals(ClobDescriptor c) {
102:                if (c == null) {
103:                    // the other obj is null, so see if this non-null obj contains
104:                    // a null value, which is equivilent.
105:                    // Assume that if we have read some of the data and we still have
106:                    // _data == null, then the value in the DB is actually null.
107:                    if (_clobRead == true && _data == null)
108:                        return true;
109:                    else
110:                        return false;
111:                }
112:
113:                if (c.getClobRead() == false) {
114:                    // the other obj has not read the data yet.
115:                    if (_clobRead == true)
116:                        return false; // we have read data, so that is not the same state
117:                    else
118:                        return true; //  odd-ball case: assume if neither has read data that they are equal
119:                }
120:
121:                // the other object has real data
122:                if (_clobRead == false)
123:                    return false; // this one does not, so they are not equal
124:
125:                // both have actual data, so compare the strings
126:                // Note that if one has read all of the data and the other has read only part
127:                // of the data that we will say that they are NOT equal.
128:                return c.getData().equals(_data);
129:            }
130:
131:            /**
132:             * toString means print the data string, unless the data has not been
133:             * read at all.
134:             */
135:            public String toString() {
136:                if (_clobRead) {
137:                    if (_data == null) {
138:                        return s_stringMgr.getString("ClobDescriptor.null");
139:                    }
140:                    if (_wholeClobRead || _userSetClobLimit > _data.length()) {
141:                        return _data; // we have the whole contents of the CLOB
142:                    }
143:                    return _data + "..."; // tell user the data is truncated
144:                }
145:                return i18n.CLOB_LABEL;
146:            }
147:
148:            /*
149:             * Getters and Setters
150:             */
151:
152:            public Clob getClob() {
153:                return _clob;
154:            }
155:
156:            public void setClob(Clob clob) {
157:                _clob = clob;
158:            }
159:
160:            public String getData() {
161:                return _data;
162:            }
163:
164:            public void setData(String data) {
165:                _data = data;
166:            }
167:
168:            public boolean getClobRead() {
169:                return _clobRead;
170:            }
171:
172:            public void setClobRead(boolean clobRead) {
173:                _clobRead = clobRead;
174:            }
175:
176:            public boolean getWholeClobRead() {
177:                return _wholeClobRead;
178:            }
179:
180:            public void setWholeClobRead(boolean wholeClobRead) {
181:                _wholeClobRead = wholeClobRead;
182:            }
183:
184:            public int getUserSetClobLimit() {
185:                return _userSetClobLimit;
186:            }
187:
188:            public void setUserSetClobLimit(int userSetClobLimit) {
189:                _userSetClobLimit = userSetClobLimit;
190:            }
191:
192:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.