Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

Source code: com/flexstor/common/data/ejb/setting/ImportSettingData.java


1   /*
2    * ImportSettingData.java
3    *
4    * Copyright $Date: 2003/08/11 02:22:44 $ FLEXSTOR.net Inc.
5    *
6    * This work is licensed for use and distribution under license terms found at
7    * http://www.flexstor.org/license.html
8    *
9    */
10  
11  package com.flexstor.common.data.ejb.setting;
12  
13  import java.util.Enumeration;
14  import java.util.Hashtable;
15  
16  import com.flexstor.common.data.ejb.SettingData;
17  import com.flexstor.common.keys.ejb.ImportSettingKey;
18  import com.flexstor.common.keys.ejb.SettingKey;
19  
20  /**
21   * This class supports underlying state data for <code>ImportSetting</code>.  A Data class holds <br>
22   * all of the state information for a corresponding class and reference <br>
23   * pointers to other classes <br>
24   *
25   * @author  Perry Hoekstra
26   * @version 1.0, 6/22/99
27   *
28   * @since   FLEXSTOR.db 3.0
29   */
30   
31  public class ImportSettingData
32     extends SettingData
33  {
34    // MKS macro expander
35    public final static String IDENTIFIER = "$Id: ImportSettingData.java,v 1.3 2003/08/11 02:22:44 aleric Exp $";
36      static final long serialVersionUID = 7264446993022878127L;
37      
38    private Hashtable importSettingCollection = new Hashtable();
39    
40      /** 
41      * Constructor for the ImportSetting class
42      *
43      * @param com.flexstor.common.keys.ejb.ImportSettingKey  reference to user the import settings belong to
44      */
45       
46      public ImportSettingData() 
47      {
48      }
49  
50      /** 
51      * Constructor for the ImportSetting class
52      *
53      * @param com.flexstor.common.keys.ejb.ImportSettingKey  reference to user the import settings belong to
54      */
55       
56      public ImportSettingData(ImportSettingKey aImportSettingKey) 
57      {
58        setKey(aImportSettingKey);
59      }
60  
61      /** 
62      * Constructor for the ImportSetting class
63      *
64      * @param com.flexstor.common.keys.ejb.ImportSettingKey  reference to user the import settings belong to 
65      * @param java.util.Hashtable                           collection of import settings
66      */
67       
68      public ImportSettingData( String sName , ImportSettingKey anImportSettingKey, Hashtable anImportSettingCollection ) 
69      {
70       this(anImportSettingKey);
71        setName(sName);  
72       importSettingCollection = anImportSettingCollection;
73      }
74  
75  
76     /**
77      * Creates a ImportSettingData object based on an orginal ImportSettingData object.
78      * This constructor is intended to be used by the clone() method.
79      *
80      * @param orginal the object to be copied.
81      */
82     public ImportSettingData ( ImportSettingData original )
83     {
84        synchronize(original);
85        setKey(null);
86     }
87     
88     /**
89      * Clones this object.
90      */   
91     public SettingData cloneObject ( )
92     {
93        return new ImportSettingData ( this );
94     }
95  
96     /**
97      * Copies all members from the argument into the current object.
98      * This methods is used when the server returns an updated object
99      * to synchronize the client instance.
100     * @param AddressData
101     */
102    public void synchronize(ImportSettingData original )
103    {
104       super.synchronize(original);
105       importSettingCollection = (Hashtable)original.getSettings().clone();
106    }
107 
108     /**
109     * Determine if these two objects are equal, i.e. their attributes are equal.  This method <b>will not</b> test the
110     * equality of references to other objects
111     *
112     * @param   com.flexstor.common.data.ejb.setting.ImportSettingData  the data object to compare this <code>data object</code> against
113     *
114     * @return boolean                                                  - <code>true</code> if the objects are equal; <code>false</code> if they are not
115     */
116      
117     public boolean equals(ImportSettingData aDataObject) 
118     {
119       boolean objectsEqual = true;
120 
121       if (! ( getKey().toString().equals( aDataObject.getKey().toString())) ) 
122         return false;
123 
124       //get keys from one hashtable
125       Enumeration t_keys = importSettingCollection.keys();
126       String t_key = null;
127 
128       Object t_object = null;  
129       String t_value1 = null;
130       String t_value2 = null; 
131           
132       while (t_keys.hasMoreElements()) {
133         t_key = (String)t_keys.nextElement();
134 
135         t_object = importSettingCollection.get(t_key);
136 
137         if (t_object != null) {
138           t_value1 = (String)t_object;
139         }
140 
141         t_object = aDataObject.getSettings().get(t_key);
142 
143         if (t_object != null) {
144           t_value2 = (String)t_object;
145         }        
146 
147         if (t_value1.equals(t_value2)) {
148           //continue on
149         }
150         else {
151           objectsEqual = false;
152           break;
153         }
154       }
155         
156       return objectsEqual;
157     }
158 
159     /**
160     * Return the reference to this object
161     *
162     * @return com.flexstor.common.keys.ejb.ImportSettingKey - an object reference
163     * @deprecated see getKey()
164     */
165     public ImportSettingKey getReference() 
166     {
167       return (ImportSettingKey)key;
168     }
169 
170     /**
171     * Return the underlying collection of import settings
172     *
173     * @return java.util.Hashtable
174     */
175     public Hashtable getSettings() 
176     {
177       return importSettingCollection;
178     }
179 
180     /**
181     * Set the underlying collection of import settings
182     *
183     * @param java.util.Hashtable
184     */
185     public void setSettings( Hashtable settings ) 
186     {
187       importSettingCollection = settings;
188     }
189 
190     /**
191     * Assign the reference key for this object.
192     *
193     * @param com.flexstor.common.keys.ejb.ImportSettingKey  reference key for an import setting
194     * @deprecated see setKey()
195     */
196     public void setReference(ImportSettingKey aImportSettingKey) 
197     {
198       key = aImportSettingKey;
199     }
200 
201    /**
202     * Sets the oracle key. Enforce type safety.
203     * @param com.flexstor.common.keys.ejb.ImportSettingKey  reference key for an import setting
204     */
205     public void setKey(SettingKey aImportSettingKey) 
206     {
207       key = (ImportSettingKey)aImportSettingKey;
208     }
209     
210 }