01: /*
02: * $Id: UniqueProperties.java,v 1.3 2007/09/18 08:45:08 agoubard Exp $
03: *
04: * Copyright 2003-2007 Orange Nederland Breedband B.V.
05: * See the COPYRIGHT file for redistribution and use restrictions.
06: */
07: package org.xins.common.collections;
08:
09: import java.util.Properties;
10: import org.xins.common.Log;
11:
12: /**
13: * Class that indicates whether a property value is overwritten.
14: * It also logs which property has been overwritten.
15: *
16: * @version $Revision: 1.3 $ $Date: 2007/09/18 08:45:08 $
17: * @author <a href="mailto:anthony.goubard@japplis.com">Anthony Goubard</a>
18: *
19: * @since XINS 2.0.
20: */
21: public class UniqueProperties extends Properties {
22:
23: /**
24: * Flag that indicates that a identical key has been put more than once in
25: * this properties object.
26: */
27: private boolean _unique = true;
28:
29: public Object put(Object key, Object value) {
30: Object oldValue = super .put(key, value);
31: if (oldValue != null && key instanceof String
32: && value instanceof String
33: && oldValue instanceof String) {
34: _unique = false;
35: Log.log_1351((String) key, (String) oldValue,
36: (String) value);
37: }
38: return oldValue;
39: }
40:
41: /**
42: * Indicates whether a property has been changed in this collection.
43: *
44: * @return
45: * <code>true</code> if none of the properties were changed, <code>false</code> otherwise.
46: */
47: public boolean isUnique() {
48: return _unique;
49: }
50: }
|