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.Collections;
19 import java.util.List;
20 import java.util.Properties;
21
22 import org.kuali.common.util.Mode;
23 import org.kuali.common.util.PropertyUtils;
24 import org.kuali.common.util.Str;
25 import org.kuali.common.util.property.Constants;
26
27 public class PathProcessor implements PropertyProcessor {
28
29 Mode propertyOverwriteMode = Constants.DEFAULT_PROPERTY_OVERWRITE_MODE;
30 String suffix = Constants.DEFAULT_PATH_SUFFIX;
31 List<String> includes;
32 List<String> excludes;
33
34 public PathProcessor() {
35 this(Collections.<String> emptyList());
36 }
37
38 public PathProcessor(String include) {
39 this(Collections.singletonList(include));
40 }
41
42 public PathProcessor(List<String> includes) {
43 super();
44 this.includes = includes;
45 }
46
47 @Override
48 public void process(Properties properties) {
49 List<String> keys = PropertyUtils.getSortedKeys(properties, includes, excludes);
50 for (String key : keys) {
51 String oldValue = properties.getProperty(key);
52 String newValue = Str.getPath(oldValue);
53 String newKey = key + "." + suffix;
54 PropertyUtils.addOrOverrideProperty(properties, newKey, newValue, propertyOverwriteMode);
55 }
56 }
57
58 public String getSuffix() {
59 return suffix;
60 }
61
62 public void setSuffix(String suffix) {
63 this.suffix = suffix;
64 }
65
66 public List<String> getIncludes() {
67 return includes;
68 }
69
70 public void setIncludes(List<String> includes) {
71 this.includes = includes;
72 }
73
74 public List<String> getExcludes() {
75 return excludes;
76 }
77
78 public void setExcludes(List<String> excludes) {
79 this.excludes = excludes;
80 }
81
82 public Mode getPropertyOverwriteMode() {
83 return propertyOverwriteMode;
84 }
85
86 public void setPropertyOverwriteMode(Mode propertyOverwriteMode) {
87 this.propertyOverwriteMode = propertyOverwriteMode;
88 }
89
90 }