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.IOException;
023: import java.net.URL;
024: import java.util.Collection;
025: import java.util.LinkedList;
026:
027: /**
028: * This model contains the list of beans imported by the user for the
029: * application. It also includes all classpaths where these beans are located.
030: *
031: * @author Jeff Tassin
032: */
033: public class ImportedBeansModel implements Externalizable {
034: static final long serialVersionUID = 8638852111334242137L;
035:
036: public static final int VERSION = 1;
037:
038: public static final String COMPONENT_ID = "imported.beans.model";
039:
040: /**
041: * A list of ImportedBeanInfo objects that describe each imported java bean
042: */
043: private LinkedList m_imported_beans = new LinkedList();
044:
045: /**
046: * A list of URLs for path and JAR files where the java beans are located.
047: */
048: private LinkedList m_class_paths = new LinkedList();
049:
050: /**
051: * ctor
052: */
053: public ImportedBeansModel() {
054:
055: }
056:
057: /**
058: * Adds an imported bean definition to the model
059: */
060: public void addImportedBean(ImportedBeanInfo bi) {
061: m_imported_beans.add(bi);
062: }
063:
064: /**
065: * Adds a URL to the list of URLs where the java beans can be found
066: */
067: public void addUrl(URL url) {
068: m_class_paths.add(url);
069: }
070:
071: /**
072: * @return a collection of ImportedBeanInfo objects that define the list of
073: * imported Java beans defined by the user.
074: */
075: public Collection getImportedBeans() {
076: return m_imported_beans;
077: }
078:
079: /**
080: * @return the collection of urls (URL objects) that define the classpath
081: * where the imported Java beans are found.
082: */
083: public Collection getUrls() {
084: return m_class_paths;
085: }
086:
087: /**
088: * Externalizable Implementation
089: */
090: public void readExternal(java.io.ObjectInput in)
091: throws ClassNotFoundException, IOException {
092: int version = in.readInt();
093: m_imported_beans = (LinkedList) in.readObject();
094: m_class_paths = (LinkedList) in.readObject();
095: }
096:
097: /**
098: * Externalizable Implementation
099: */
100: public void writeExternal(java.io.ObjectOutput out)
101: throws IOException {
102: out.writeInt(VERSION);
103: out.writeObject(m_imported_beans);
104: out.writeObject(m_class_paths);
105: }
106:
107: }
|