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


001:        /*
002:         * ProfileKey.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.gui.profiles;
013:
014:        /**
015:         * A class to uniquely identify a {@link workbench.db.ConnectionProfile}
016:         * 
017:         * @author support@sql-workbench.net
018:         */
019:        public class ProfileKey {
020:            private String name; // the name of the profile
021:            private String group; // the profile group
022:
023:            /**
024:             * Create a new ProfileKey.
025:             * The passed name can consist of the profile group and the profile name
026:             * the group needs to be enclosed in curly brackets, e.g: 
027:             * <tt>{MainGroup}/HR Database</tt><br/>
028:             * The divividing slash is optional.
029:             * 
030:             * @param pname the name (can include the profile group) of the profile
031:             */
032:            public ProfileKey(String pname) {
033:                if (pname == null)
034:                    throw new NullPointerException("Name cannot be null!");
035:                setName(pname);
036:            }
037:
038:            /**
039:             * Create a new key based on a profile name and a group name.
040:             * 
041:             * @param pname the name of the profile
042:             * @param pgroup the group to which the profile belongs
043:             */
044:            public ProfileKey(String pname, String pgroup) {
045:                if (pgroup != null)
046:                    group = pgroup.trim();
047:                setName(pname);
048:            }
049:
050:            private void setName(String pname) {
051:                String tname = pname.trim();
052:                if (tname.charAt(0) == '{') {
053:                    int pos = tname.indexOf('}');
054:                    if (pos < 0)
055:                        throw new IllegalArgumentException(
056:                                "Missing closing } to define group name");
057:                    int slashPos = tname.indexOf("/", pos + 1);
058:                    if (slashPos < 0)
059:                        slashPos = pos;
060:                    this .name = tname.substring(slashPos + 1).trim();
061:                    this .group = tname.substring(1, pos).trim();
062:                } else {
063:                    name = tname;
064:                }
065:            }
066:
067:            public String getName() {
068:                return name;
069:            }
070:
071:            public String getGroup() {
072:                return group;
073:            }
074:
075:            public String toString() {
076:                if (group == null)
077:                    return name;
078:                return "{" + group + "}/" + name;
079:            }
080:
081:            @Override
082:            public int hashCode() {
083:                return toString().hashCode();
084:            }
085:
086:            @Override
087:            public boolean equals(Object other) {
088:                if (other == null)
089:                    return false;
090:                if (other instanceof  ProfileKey) {
091:                    ProfileKey key = (ProfileKey) other;
092:                    if (key.getName() == null)
093:                        return false;
094:                    if (this .name.equals(key.getName())) {
095:                        if (key.getGroup() == null || this .group == null)
096:                            return true;
097:                        return this .getGroup().equals(key.getGroup());
098:                    }
099:                }
100:                return false;
101:            }
102:
103:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.