001: /*
002: * IzPack - Copyright 2001-2008 Julien Ponge, All Rights Reserved.
003: *
004: * http://izpack.org/
005: * http://izpack.codehaus.org/
006: *
007: * Copyright 2005 Klaus Bartz
008: *
009: * Licensed under the Apache License, Version 2.0 (the "License");
010: * you may not use this file except in compliance with the License.
011: * You may obtain a copy of the License at
012: *
013: * http://www.apache.org/licenses/LICENSE-2.0
014: *
015: * Unless required by applicable law or agreed to in writing, software
016: * distributed under the License is distributed on an "AS IS" BASIS,
017: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
018: * See the License for the specific language governing permissions and
019: * limitations under the License.
020: */
021:
022: package com.coi.tools.os.win;
023:
024: import java.io.Serializable;
025:
026: /**
027: * Data container for Windows registry logging. This container is used to hold old and new created
028: * registry data used at rewinding the registry changes.
029: *
030: * @author Klaus Bartz
031: *
032: */
033: public class RegistryLogItem implements Cloneable, Serializable {
034:
035: /**
036: *
037: */
038: private static final long serialVersionUID = 3618134559108444211L;
039:
040: /** Types of log items */
041:
042: /** Identifier for removed key */
043: public static final int REMOVED_KEY = 1;
044:
045: /** Identifier for created key */
046: public static final int CREATED_KEY = 2;
047:
048: /** Identifier for removed value */
049: public static final int REMOVED_VALUE = 3;
050:
051: /** Identifier for created value */
052: public static final int CREATED_VALUE = 4;
053:
054: /** Identifier for changed value */
055: public static final int CHANGED_VALUE = 5;
056:
057: private int type;
058:
059: private int root;
060:
061: private String key;
062:
063: private String valueName;
064:
065: private RegDataContainer newValue = null;
066:
067: private RegDataContainer oldValue = null;
068:
069: /**
070: * Default constructor.
071: */
072: private RegistryLogItem() {
073: super ();
074: }
075:
076: /**
077: * Constructor with settings.
078: *
079: * @param type type of loging item. Possible are REMOVED_KEY, CREATED_KEY, REMOVED_VALUE,
080: * CREATED_VALUE and CHANGED_VALUE
081: * @param root id for the registry root
082: * @param key key name of the item which should be logged
083: * @param valueName name of the value of the item which should be logged if it is a value type,
084: * else null
085: * @param newValue new value of the registry entry if it is a value type, else null
086: * @param oldValue old value of the registry entry if it is a value type, else null
087: */
088: public RegistryLogItem(int type, int root, String key,
089: String valueName, RegDataContainer newValue,
090: RegDataContainer oldValue) {
091: this .type = type;
092: this .root = root;
093: this .key = key;
094: this .valueName = valueName;
095: this .newValue = newValue;
096: this .oldValue = oldValue;
097: }
098:
099: /**
100: * Returns the key name of this logging item.
101: *
102: * @return the key name of this logging item
103: */
104: public String getKey() {
105: return key;
106: }
107:
108: /**
109: * Returns the new value of this logging item.
110: *
111: * @return the new value of this logging item
112: */
113: public RegDataContainer getNewValue() {
114: return newValue;
115: }
116:
117: /**
118: * Returns the old value of this logging item.
119: *
120: * @return the old value of this logging item
121: */
122: public RegDataContainer getOldValue() {
123: return oldValue;
124: }
125:
126: /**
127: * Returns the root id of this logging item.
128: *
129: * @return the root id of this logging item
130: */
131: public int getRoot() {
132: return root;
133: }
134:
135: /**
136: * Returns the type id of this logging item.
137: *
138: * @return the type id of this logging item
139: */
140: public int getType() {
141: return type;
142: }
143:
144: /**
145: * Returns the value name of this logging item.
146: *
147: * @return the value name of this logging item
148: */
149: public String getValueName() {
150: return valueName;
151: }
152:
153: /**
154: * Sets the key name to the given string
155: *
156: * @param string to be used as key name
157: */
158: public void setKey(String string) {
159: key = string;
160: }
161:
162: /**
163: * Sets the new value to the given RegDataContainer.
164: *
165: * @param container to be used as new value
166: */
167: public void setNewValue(RegDataContainer container) {
168: newValue = container;
169: }
170:
171: /**
172: * Sets the old value to the given RegDataContainer.
173: *
174: * @param container to be used as old value
175: */
176: public void setOldValue(RegDataContainer container) {
177: oldValue = container;
178: }
179:
180: /**
181: * Sets the root id for this logging item.
182: *
183: * @param i root id to be used for this logging item
184: */
185: public void setRoot(int i) {
186: root = i;
187: }
188:
189: /**
190: * Sets the type id for this logging item.
191: *
192: * @param i type id to be used for this logging item
193: */
194: public void setType(int i) {
195: type = i;
196: }
197:
198: /**
199: * Sets the value name to the given string
200: *
201: * @param string to be used as value name
202: */
203: public void setValueName(String string) {
204: valueName = string;
205: }
206:
207: public Object clone() throws CloneNotSupportedException {
208: RegistryLogItem retval = (RegistryLogItem) super .clone();
209: if (newValue != null)
210: retval.newValue = (RegDataContainer) newValue.clone();
211: if (oldValue != null)
212: retval.oldValue = (RegDataContainer) oldValue.clone();
213: return (retval);
214:
215: }
216: }
|