Source Code Cross Referenced for DatabaseEvent.java in  » Database-Client » iSQL-Viewer » org » isqlviewer » event » 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 » iSQL Viewer » org.isqlviewer.event 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * The contents of this file are subject to the Mozilla Public License
003:         * Version 1.1 (the "License"); you may not use this file except in
004:         * compliance with the License. You may obtain a copy of the License at
005:         * http://www.mozilla.org/MPL/
006:         *
007:         * Software distributed under the License is distributed on an "AS IS"
008:         * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
009:         * License for the specific language governing rights and limitations
010:         * under the License.
011:         * 
012:         * The Original Code is iSQL-Viewer, A Mutli-Platform Database Tool.
013:         *
014:         * The Initial Developer of the Original Code is iSQL-Viewer, A Mutli-Platform Database Tool.
015:         * Portions created by Mark A. Kobold are Copyright (C) 2000-2007. All Rights Reserved.
016:         *
017:         * Contributor(s): 
018:         *  Mark A. Kobold [mkobold <at> isqlviewer <dot> com].
019:         *  
020:         * If you didn't download this code from the following link, you should check
021:         * if you aren't using an obsolete version: http://www.isqlviewer.com
022:         */
023:        package org.isqlviewer.event;
024:
025:        import java.sql.Connection;
026:        import java.util.EventObject;
027:
028:        /**
029:         * Standard event object for notifying actions of the DatabaseConnection.
030:         * <p>
031:         * This event object more or less works much like the WindowEvent object where there is an ID that correlates to the
032:         * type of event is being propagated.
033:         * <p>
034:         * Most if not all the time the source of these events should be an instance of DatabaseConnection to help determine
035:         * which connection these events are coming from.
036:         * 
037:         * @see org.isqlviewer.event.DatabaseListener
038:         * @author Mark A. Kobold &lt;mkobold at isqlviewer dot com&gt;
039:         * @version 1.0
040:         */
041:        public class DatabaseEvent extends EventObject {
042:
043:            private static final long serialVersionUID = 6586214394143524988L;
044:            /**
045:             * Inidcates a disconnect from the database.
046:             */
047:            public final static int DISCONNECT = 0;
048:            /**
049:             * Indicates that a commit has succesfully occured.
050:             */
051:            public final static int COMMIT = 1;
052:            /**
053:             * Indicates a sucesful rollback has occured.
054:             */
055:            public final static int ROLLBACK = 2;
056:            /**
057:             * Indicates that the database connection has succesfuly initialized.
058:             */
059:            public final static int INITIALIZE = 3;
060:            /**
061:             * Indicates that the auto-commite state has changed.
062:             */
063:            public final static int AUTO_COMMIT_CHANGE = 4;
064:            /**
065:             * For when the catalog is manually updated.
066:             */
067:            public final static int CATALOG_CHANGE = 5;
068:
069:            private int eventCode = -1;
070:
071:            /**
072:             * Default event constructor.
073:             * <p>
074:             * Basic event constructor with the event code. the code will be checked for validity if not a
075:             * IllegalArgumentException will be thrown.
076:             * 
077:             * @throws IllegalArgumentException if code is invalid.
078:             * @param source of the event.
079:             * @param code for this event.
080:             */
081:            public DatabaseEvent(Object source, int code) {
082:
083:                super (source);
084:                if (!(source instanceof  Connection)) {
085:                    throw new IllegalArgumentException();
086:                }
087:                checkCode(code);
088:                eventCode = code;
089:            }
090:
091:            /**
092:             * Returns the code for this event.
093:             * <p>
094:             * This value will always be some constant value declared in this class.
095:             * 
096:             * @return int representing the event.
097:             */
098:            public int getID() {
099:
100:                return eventCode;
101:            }
102:
103:            public Connection getConnection() {
104:
105:                return (Connection) getSource();
106:            }
107:
108:            protected static void checkCode(int code)
109:                    throws IllegalArgumentException {
110:
111:                switch (code) {
112:                case DISCONNECT:
113:                case COMMIT:
114:                case ROLLBACK:
115:                case CATALOG_CHANGE:
116:                case INITIALIZE:
117:                case AUTO_COMMIT_CHANGE:
118:                    return;
119:                default:
120:                    throw new IllegalArgumentException(Integer.toString(code));
121:                }
122:            }
123:
124:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.