Source Code Cross Referenced for ProjectLevelImportedBeansModel.java in  » Swing-Library » abeille-forms-designer » com » jeta » swingbuilder » store » 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 » Swing Library » abeille forms designer » com.jeta.swingbuilder.store 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright (C) 2005 Jeff Tassin
003:         *
004:         * This library is free software; you can redistribute it and/or
005:         * modify it under the terms of the GNU Lesser General Public
006:         * License as published by the Free Software Foundation; either
007:         * version 2.1 of the License, or (at your option) any later version.
008:         *
009:         * This library is distributed in the hope that it will be useful,
010:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
011:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
012:         * Lesser General Public License for more details.
013:         *
014:         * You should have received a copy of the GNU Lesser General Public
015:         * License along with this library; if not, write to the Free Software
016:         * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
017:         */
018:
019:        package com.jeta.swingbuilder.store;
020:
021:        import java.io.Externalizable;
022:        import java.io.File;
023:        import java.io.IOException;
024:        import java.net.MalformedURLException;
025:        import java.util.Arrays;
026:        import java.util.Collection;
027:        import java.util.LinkedList;
028:        import java.util.ListIterator;
029:
030:        /**
031:         * This model contains the list of beans imported by the user for the
032:         * application. It also includes all classpaths where these beans are located.
033:         * 
034:         * @author Jeff Tassin
035:         */
036:        public class ProjectLevelImportedBeansModel implements  Externalizable {
037:            static final long serialVersionUID = 4699864132660581997L;
038:
039:            public static final int VERSION = 2;
040:
041:            public static final String COMPONENT_ID = "project.level.imported.beans.model";
042:
043:            private String m_env_var;
044:
045:            private transient File m_root_dir;
046:
047:            /**
048:             * A list of ImportedBeanInfo objects that describe each imported java bean
049:             */
050:            private LinkedList m_imported_beans = new LinkedList();
051:
052:            /**
053:             * A list of URLs for path and JAR files where the java beans are located.
054:             */
055:            private LinkedList m_relative_class_paths = new LinkedList();
056:
057:            /**
058:             * ctor
059:             */
060:            public ProjectLevelImportedBeansModel() {
061:            }
062:
063:            public ProjectLevelImportedBeansModel(String envVar) {
064:                this .m_env_var = envVar;
065:                this .m_root_dir = getRootDir(m_env_var);
066:            }
067:
068:            /**
069:             * @param envVar
070:             */
071:            private File getRootDir(String envVar) {
072:                if (envVar != null) {
073:                    String directory = System.getenv(envVar);
074:                    if ((directory != null) && (!"".equals(directory))) {
075:                        try {
076:                            File tempFile = new File(directory);
077:                            if (tempFile.exists() && tempFile.isDirectory()) {
078:                                return tempFile;
079:                            }
080:                        } catch (Exception e) {
081:                        }
082:                    }
083:                }
084:                return null;
085:            }
086:
087:            /**
088:             * Adds an imported bean definition to the model
089:             */
090:            public void addImportedBean(ImportedBeanInfo bi) {
091:                if (m_imported_beans == null) {
092:                    m_imported_beans = new LinkedList();
093:                }
094:                if (bi != null) {
095:                    m_imported_beans.add(bi);
096:                }
097:            }
098:
099:            /**
100:             * Adds a relative classpath to the list of classpaths where the java beans
101:             * can be found
102:             */
103:            public void addRelativeClasspath(String relativeClasspath) {
104:                if (m_relative_class_paths == null) {
105:                    m_relative_class_paths = new LinkedList();
106:                }
107:                if ((relativeClasspath != null)
108:                        && (!"".equals(relativeClasspath))) {
109:                    m_relative_class_paths.add(relativeClasspath);
110:                }
111:            }
112:
113:            /**
114:             * @return a collection of ImportedBeanInfo objects that define the list of
115:             *         imported Java beans defined by the user.
116:             */
117:            public Collection getImportedBeans() {
118:                return m_imported_beans;
119:            }
120:
121:            /**
122:             * @return the collection of relative classpaths (String objects) that
123:             *         define the classpath where the imported Java beans are found.
124:             */
125:            public Collection getRelativeClasspaths() {
126:                return m_relative_class_paths;
127:            }
128:
129:            /**
130:             * @return the collection of urls (URL objects) that define the classpath
131:             *         where the imported Java beans are found.
132:             */
133:            public Collection getUrls() {
134:                LinkedList urls = new LinkedList();
135:                for (ListIterator i = m_relative_class_paths.listIterator(); i
136:                        .hasNext();) {
137:                    String relClasspath = (String) i.next();
138:                    File file = new File(this .m_root_dir, relClasspath);
139:                    try {
140:                        urls.addLast(file.toURL());
141:                    } catch (MalformedURLException e) {
142:                        e.printStackTrace();
143:                    }
144:                }
145:                return urls;
146:            }
147:
148:            public String getEnvVar() {
149:                return this .m_env_var;
150:            }
151:
152:            public void setEnvVar(String envVar) {
153:                this .m_env_var = envVar;
154:                this .m_root_dir = getRootDir(this .m_env_var);
155:            }
156:
157:            public boolean equals(Object obj) {
158:                if (this  == obj)
159:                    return true;
160:
161:                if (null == obj)
162:                    return false;
163:
164:                if (!(obj instanceof  ProjectLevelImportedBeansModel))
165:                    return false;
166:
167:                ProjectLevelImportedBeansModel mObj = (ProjectLevelImportedBeansModel) obj;
168:
169:                if ((null == m_env_var && null != mObj.getEnvVar())
170:                        || (null != m_env_var && null == mObj.getEnvVar())
171:                        || (null != m_env_var && null != mObj.getEnvVar() && !mObj
172:                                .getEnvVar().equals(m_env_var))) {
173:                    return false;
174:                } else {
175:                    if ((null == m_relative_class_paths && null != mObj
176:                            .getRelativeClasspaths())
177:                            || (null != m_relative_class_paths && null == mObj
178:                                    .getRelativeClasspaths())
179:                            || (null != m_relative_class_paths
180:                                    && null != mObj.getRelativeClasspaths() && mObj
181:                                    .getRelativeClasspaths().size() != m_relative_class_paths
182:                                    .size())) {
183:                        return false;
184:                    } else {
185:                        Object[] a1 = m_relative_class_paths.toArray();
186:                        Arrays.sort(a1);
187:
188:                        Object[] a2 = mObj.getRelativeClasspaths().toArray();
189:                        Arrays.sort(a2);
190:
191:                        for (int i = 0; i < a1.length; i++) {
192:                            if (!a1[i].equals(a2[i]))
193:                                return false;
194:                        }
195:
196:                        if ((null == m_imported_beans && null != mObj
197:                                .getImportedBeans())
198:                                || (null != m_imported_beans && null == mObj
199:                                        .getImportedBeans())
200:                                || (null != m_imported_beans
201:                                        && null != mObj.getImportedBeans() && mObj
202:                                        .getImportedBeans().size() != m_imported_beans
203:                                        .size())) {
204:                            return false;
205:                        } else {
206:                            Object[] beans1 = m_imported_beans.toArray();
207:                            Arrays.sort(beans1);
208:
209:                            Object[] beans2 = mObj.getImportedBeans().toArray();
210:                            Arrays.sort(beans2);
211:
212:                            for (int i = 0; i < beans1.length; i++) {
213:                                if (!beans1[i].equals(beans2[i]))
214:                                    return false;
215:                            }
216:                        }
217:                    }
218:                }
219:
220:                return true;
221:            }
222:
223:            /**
224:             * Externalizable Implementation
225:             */
226:            public void readExternal(java.io.ObjectInput in)
227:                    throws ClassNotFoundException, IOException {
228:                int version = in.readInt();
229:                m_imported_beans = (LinkedList) in.readObject();
230:                m_relative_class_paths = (LinkedList) in.readObject();
231:                if (version >= 2) {
232:                    m_env_var = (String) in.readObject();
233:                    m_root_dir = getRootDir(m_env_var);
234:                }
235:            }
236:
237:            /**
238:             * Externalizable Implementation
239:             */
240:            public void writeExternal(java.io.ObjectOutput out)
241:                    throws IOException {
242:                out.writeInt(VERSION);
243:                out.writeObject(m_imported_beans);
244:                out.writeObject(m_relative_class_paths);
245:                out.writeObject(m_env_var);
246:            }
247:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.