01: /*
02: * PropertiesCopier.java
03: *
04: * This file is part of SQL Workbench/J, http://www.sql-workbench.net
05: *
06: * Copyright 2002-2008, Thomas Kellerer
07: * No part of this code maybe reused without the permission of the author
08: *
09: * To contact the author please send an email to: support@sql-workbench.net
10: *
11: */
12: package workbench.util;
13:
14: import java.util.Enumeration;
15: import java.util.Properties;
16:
17: /**
18: *
19: * @author support@sql-workbench.net
20: */
21: public class PropertiesCopier {
22:
23: public PropertiesCopier() {
24: }
25:
26: public void copyToSystem(Properties source) {
27: copy(source, System.getProperties());
28: }
29:
30: public void copy(Properties source, Properties target) {
31: if (source == null || target == null)
32: return;
33: Enumeration keys = source.propertyNames();
34: while (keys.hasMoreElements()) {
35: String key = (String) keys.nextElement();
36: String value = source.getProperty(key);
37: target.setProperty(key, value);
38: }
39: }
40:
41: public void removeFromSystem(Properties source) {
42: remove(source, System.getProperties());
43: }
44:
45: public void remove(Properties source, Properties target) {
46: if (source == null || target == null)
47: return;
48: Enumeration keys = source.propertyNames();
49: while (keys.hasMoreElements()) {
50: String key = (String) keys.nextElement();
51: target.remove(key);
52: }
53: }
54:
55: }
|