KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > coi > tools > os > win > RegistryLogItem


1 /*
2  * IzPack - Copyright 2001-2007 Julien Ponge, All Rights Reserved.
3  *
4  * http://www.izforge.com/izpack/
5  * http://developer.berlios.de/projects/izpack/
6  *
7  * Copyright 2005 Klaus Bartz
8  *
9  * Licensed under the Apache License, Version 2.0 (the "License");
10  * you may not use this file except in compliance with the License.
11  * You may obtain a copy of the License at
12  *
13  * http://www.apache.org/licenses/LICENSE-2.0
14  *
15  * Unless required by applicable law or agreed to in writing, software
16  * distributed under the License is distributed on an "AS IS" BASIS,
17  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18  * See the License for the specific language governing permissions and
19  * limitations under the License.
20  */

21
22 package com.coi.tools.os.win;
23
24 import java.io.Serializable JavaDoc;
25
26 /**
27  * Data container for Windows registry logging. This container is used to hold old and new created
28  * registry data used at rewinding the registry changes.
29  *
30  * @author Klaus Bartz
31  *
32  */

33 public class RegistryLogItem implements Cloneable JavaDoc, Serializable JavaDoc
34 {
35
36     /**
37      *
38      */

39     private static final long serialVersionUID = 3618134559108444211L;
40
41     /** Types of log items */
42     
43     /** Identifier for removed key */
44     public static final int REMOVED_KEY = 1;
45
46     /** Identifier for created key */
47     public static final int CREATED_KEY = 2;
48
49     /** Identifier for removed value */
50     public static final int REMOVED_VALUE = 3;
51
52     /** Identifier for created value */
53     public static final int CREATED_VALUE = 4;
54
55     /** Identifier for changed value */
56     public static final int CHANGED_VALUE = 5;
57
58     private int type;
59
60     private int root;
61
62     private String JavaDoc key;
63
64     private String JavaDoc valueName;
65
66     private RegDataContainer newValue = null;
67
68     private RegDataContainer oldValue = null;
69
70     /**
71      * Default constructor.
72      */

73     private RegistryLogItem()
74     {
75         super();
76     }
77
78     /**
79      * Constructor with settings.
80      *
81      * @param type type of loging item. Possible are REMOVED_KEY, CREATED_KEY, REMOVED_VALUE,
82      * CREATED_VALUE and CHANGED_VALUE
83      * @param root id for the registry root
84      * @param key key name of the item which should be logged
85      * @param valueName name of the value of the item which should be logged if it is a value type,
86      * else null
87      * @param newValue new value of the registry entry if it is a value type, else null
88      * @param oldValue old value of the registry entry if it is a value type, else null
89      */

90     public RegistryLogItem(int type, int root, String JavaDoc key, String JavaDoc valueName,
91             RegDataContainer newValue, RegDataContainer oldValue)
92     {
93         this.type = type;
94         this.root = root;
95         this.key = key;
96         this.valueName = valueName;
97         this.newValue = newValue;
98         this.oldValue = oldValue;
99     }
100
101     /**
102      * Returns the key name of this logging item.
103      *
104      * @return the key name of this logging item
105      */

106     public String JavaDoc getKey()
107     {
108         return key;
109     }
110
111     /**
112      * Returns the new value of this logging item.
113      *
114      * @return the new value of this logging item
115      */

116     public RegDataContainer getNewValue()
117     {
118         return newValue;
119     }
120
121     /**
122      * Returns the old value of this logging item.
123      *
124      * @return the old value of this logging item
125      */

126     public RegDataContainer getOldValue()
127     {
128         return oldValue;
129     }
130
131     /**
132      * Returns the root id of this logging item.
133      *
134      * @return the root id of this logging item
135      */

136     public int getRoot()
137     {
138         return root;
139     }
140
141     /**
142      * Returns the type id of this logging item.
143      *
144      * @return the type id of this logging item
145      */

146     public int getType()
147     {
148         return type;
149     }
150
151     /**
152      * Returns the value name of this logging item.
153      *
154      * @return the value name of this logging item
155      */

156     public String JavaDoc getValueName()
157     {
158         return valueName;
159     }
160
161     /**
162      * Sets the key name to the given string
163      *
164      * @param string to be used as key name
165      */

166     public void setKey(String JavaDoc string)
167     {
168         key = string;
169     }
170
171     /**
172      * Sets the new value to the given RegDataContainer.
173      *
174      * @param container to be used as new value
175      */

176     public void setNewValue(RegDataContainer container)
177     {
178         newValue = container;
179     }
180
181     /**
182      * Sets the old value to the given RegDataContainer.
183      *
184      * @param container to be used as old value
185      */

186     public void setOldValue(RegDataContainer container)
187     {
188         oldValue = container;
189     }
190
191     /**
192      * Sets the root id for this logging item.
193      *
194      * @param i root id to be used for this logging item
195      */

196     public void setRoot(int i)
197     {
198         root = i;
199     }
200
201     /**
202      * Sets the type id for this logging item.
203      *
204      * @param i type id to be used for this logging item
205      */

206     public void setType(int i)
207     {
208         type = i;
209     }
210
211     /**
212      * Sets the value name to the given string
213      *
214      * @param string to be used as value name
215      */

216     public void setValueName(String JavaDoc string)
217     {
218         valueName = string;
219     }
220
221     public Object JavaDoc clone() throws CloneNotSupportedException JavaDoc
222     {
223         RegistryLogItem retval = (RegistryLogItem) super.clone();
224         if (newValue != null) retval.newValue = (RegDataContainer) newValue.clone();
225         if (oldValue != null) retval.oldValue = (RegDataContainer) oldValue.clone();
226         return (retval);
227
228     }
229 }
230
Popular Tags