1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.common.util.property.processor;
17
18 import java.util.List;
19 import java.util.Properties;
20
21 import org.kuali.common.util.Mode;
22 import org.kuali.common.util.PropertyUtils;
23 import org.kuali.common.util.property.Constants;
24
25 public class OverrideProcessor implements PropertyProcessor {
26
27 Mode propertyOverwriteMode;
28 Properties overrideProperties;
29 List<String> includes;
30 List<String> excludes;
31 int indent;
32
33 public OverrideProcessor() {
34 this(Constants.DEFAULT_PROPERTY_OVERWRITE_MODE);
35 }
36
37 public OverrideProcessor(Mode propertyOverwriteMode) {
38 this(Constants.DEFAULT_PROPERTY_OVERWRITE_MODE, null, 0);
39 }
40
41 public OverrideProcessor(Mode propertyOverwriteMode, Properties overrideProperties) {
42 this(Constants.DEFAULT_PROPERTY_OVERWRITE_MODE, overrideProperties, 0);
43 }
44
45 public OverrideProcessor(Mode propertyOverwriteMode, Properties overrideProperties, int indent) {
46 super();
47 this.propertyOverwriteMode = propertyOverwriteMode;
48 this.overrideProperties = overrideProperties;
49 this.indent = indent;
50 }
51
52 @Override
53 public void process(Properties properties) {
54 List<String> keys = PropertyUtils.getSortedKeys(overrideProperties, includes, excludes);
55 for (String key : keys) {
56 String newValue = overrideProperties.getProperty(key);
57 PropertyUtils.addOrOverrideProperty(properties, key, newValue, propertyOverwriteMode, indent);
58 }
59 }
60
61 public Mode getPropertyOverwriteMode() {
62 return propertyOverwriteMode;
63 }
64
65 public void setPropertyOverwriteMode(Mode propertyOverwriteMode) {
66 this.propertyOverwriteMode = propertyOverwriteMode;
67 }
68
69 public Properties getOverrideProperties() {
70 return overrideProperties;
71 }
72
73 public void setOverrideProperties(Properties overrideProperties) {
74 this.overrideProperties = overrideProperties;
75 }
76
77 public List<String> getIncludes() {
78 return includes;
79 }
80
81 public void setIncludes(List<String> includes) {
82 this.includes = includes;
83 }
84
85 public List<String> getExcludes() {
86 return excludes;
87 }
88
89 public void setExcludes(List<String> excludes) {
90 this.excludes = excludes;
91 }
92
93 }