Source Code Cross Referenced for StatementRunnerResult.java in  » Database-Client » SQL-Workbench » workbench » 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 » Database Client » SQL Workbench » workbench.sql 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * StatementRunnerResult.java
003:         *
004:         * This file is part of SQL Workbench/J, http://www.sql-workbench.net
005:         *
006:         * Copyright 2002-2008, Thomas Kellerer
007:         * No part of this code maybe reused without the permission of the author
008:         *
009:         * To contact the author please send an email to: support@sql-workbench.net
010:         *
011:         */
012:        package workbench.sql;
013:
014:        import java.sql.ResultSet;
015:        import java.text.DecimalFormat;
016:        import java.util.ArrayList;
017:        import java.util.LinkedList;
018:        import java.util.List;
019:        import workbench.gui.sql.DwStatusBar;
020:        import workbench.resource.ResourceMgr;
021:
022:        import workbench.storage.DataStore;
023:        import workbench.util.MessageBuffer;
024:
025:        /**
026:         *
027:         * @author  support@sql-workbench.net
028:         */
029:        public class StatementRunnerResult {
030:            private List<ResultSet> results;
031:            private long totalUpdateCount;
032:            private MessageBuffer messages;
033:            private List<DataStore> datastores;
034:            private String sourceCommand;
035:
036:            private boolean success = true;
037:            private boolean hasWarning = false;
038:            private boolean wasCancelled = false;
039:            private boolean stopScriptExecution = false;
040:
041:            private long executionTime = -1;
042:            private DecimalFormat timingFormatter;
043:
044:            public StatementRunnerResult() {
045:                this .timingFormatter = DwStatusBar.createTimingFormatter();
046:                this .messages = new MessageBuffer();
047:            }
048:
049:            public StatementRunnerResult(String aCmd) {
050:                this ();
051:                this .sourceCommand = aCmd;
052:            }
053:
054:            public boolean stopScript() {
055:                return stopScriptExecution;
056:            }
057:
058:            public void setStopScript(boolean flag) {
059:                this .stopScriptExecution = flag;
060:            }
061:
062:            public boolean promptingWasCancelled() {
063:                return wasCancelled;
064:            }
065:
066:            public void setPromptingWasCancelled() {
067:                this .wasCancelled = true;
068:            }
069:
070:            public void setExecutionTime(long t) {
071:                this .executionTime = t;
072:            }
073:
074:            public long getExecutionTime() {
075:                return this .executionTime;
076:            }
077:
078:            public String getTimingMessage() {
079:                if (executionTime == -1)
080:                    return null;
081:                StringBuilder msg = new StringBuilder(100);
082:                msg.append(ResourceMgr.getString("MsgExecTime"));
083:                msg.append(' ');
084:                double time = ((double) executionTime) / 1000.0;
085:                msg.append(timingFormatter.format(time));
086:                return msg.toString();
087:            }
088:
089:            public void setSuccess() {
090:                this .success = true;
091:            }
092:
093:            public void setFailure() {
094:                this .success = false;
095:            }
096:
097:            public void setWarning(boolean flag) {
098:                this .hasWarning = flag;
099:            }
100:
101:            public boolean hasWarning() {
102:                return this .hasWarning;
103:            }
104:
105:            public boolean isSuccess() {
106:                return this .success;
107:            }
108:
109:            public String getSourceCommand() {
110:                return this .sourceCommand;
111:            }
112:
113:            public int addDataStore(DataStore ds) {
114:                if (this .datastores == null)
115:                    this .datastores = new ArrayList<DataStore>(5);
116:                ds.resetCancelStatus();
117:                this .datastores.add(ds);
118:                return this .datastores.size();
119:            }
120:
121:            public int addResultSet(ResultSet rs) {
122:                if (this .results == null)
123:                    this .results = new LinkedList<ResultSet>();
124:                this .results.add(rs);
125:                return this .results.size();
126:            }
127:
128:            public void addUpdateCountMsg(int count) {
129:                this .totalUpdateCount += count;
130:                addMessage(count + " "
131:                        + ResourceMgr.getString("MsgRowsAffected"));
132:            }
133:
134:            public void addMessage(MessageBuffer buffer) {
135:                if (buffer == null)
136:                    return;
137:                this .messages.append(buffer);
138:            }
139:
140:            public void addMessageNewLine() {
141:                this .messages.appendNewLine();
142:            }
143:
144:            public void addMessage(CharSequence msgBuffer) {
145:                if (msgBuffer == null)
146:                    return;
147:                if (messages.getLength() > 0)
148:                    messages.appendNewLine();
149:                messages.append(msgBuffer);
150:            }
151:
152:            public boolean hasData() {
153:                return (this .hasResultSets() || this .hasDataStores());
154:            }
155:
156:            public boolean hasMessages() {
157:                if (this .messages == null)
158:                    return false;
159:                return (messages.getLength() > 0);
160:            }
161:
162:            public boolean hasResultSets() {
163:                return (this .results != null && this .results.size() > 0);
164:            }
165:
166:            public boolean hasDataStores() {
167:                return (this .datastores != null && this .datastores.size() > 0);
168:            }
169:
170:            public List<DataStore> getDataStores() {
171:                return this .datastores;
172:            }
173:
174:            public List<ResultSet> getResultSets() {
175:                return this .results;
176:            }
177:
178:            /**
179:             * Return the messages that have been collected for this result.
180:             * This will clear the internal buffer used to store the messages.
181:             *
182:             * @see workbench.util.MessageBuffer#getBuffer()
183:             */
184:            public CharSequence getMessageBuffer() {
185:                if (this .messages == null)
186:                    return null;
187:                return messages.getBuffer();
188:            }
189:
190:            public long getTotalUpdateCount() {
191:                return totalUpdateCount;
192:            }
193:
194:            /**
195:             * Clears stored ResultSets and DataStores. The content of 
196:             * the datastores will be removed!
197:             * @see #clearResultSets()
198:             */
199:            public void clearResultData() {
200:                if (this .datastores != null) {
201:                    //for (int i = 0; i < datastores.size(); i++)
202:                    for (DataStore ds : datastores) {
203:                        if (ds != null)
204:                            ds.reset();
205:                    }
206:                    this .datastores.clear();
207:                }
208:                this .clearResultSets();
209:            }
210:
211:            /**
212:             * Closes all "stored" ResultSets
213:             */
214:            public void clearResultSets() {
215:                if (this .results != null) {
216:                    for (ResultSet rs : results) {
217:                        if (rs != null) {
218:                            try {
219:                                rs.clearWarnings();
220:                            } catch (Exception th) {
221:                            }
222:                            try {
223:                                rs.close();
224:                            } catch (Exception th) {
225:                            }
226:                        }
227:                    }
228:                    this .results.clear();
229:                }
230:            }
231:
232:            public void clearMessageBuffer() {
233:                this .messages.clear();
234:            }
235:
236:            public void clear() {
237:                // Do not call clearResultData() !!!
238:                // otherwise the content of the retrieved DataStores will also 
239:                // be removed and as they are re-used by DwPanel or TableDataPanel
240:                // they might still be in use.
241:
242:                // We only want to free the list itself.
243:                if (this .datastores != null) {
244:                    this .datastores.clear();
245:                }
246:                clearResultSets();
247:                clearMessageBuffer();
248:                this .totalUpdateCount = 0;
249:                this .sourceCommand = null;
250:                this .hasWarning = false;
251:                this .executionTime = -1;
252:            }
253:
254:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.