1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.common.util.execute;
17
18 import java.io.File;
19 import java.util.List;
20 import java.util.Properties;
21
22 import org.kuali.common.util.PropertyUtils;
23 import org.springframework.util.Assert;
24
25 public class StorePropertiesExecutable implements Executable {
26
27 String encoding = "UTF-8";
28 boolean skip;
29 Properties properties;
30 File outputFile;
31 List<String> includes;
32 List<String> excludes;
33
34 @Override
35 public void execute() {
36 if (skip) {
37 return;
38 }
39 Assert.notNull(properties, "properties is null");
40 Assert.notNull(outputFile, "outputFile is null");
41 List<String> keys = PropertyUtils.getSortedKeys(properties, includes, excludes);
42 Properties outputProperties = new Properties();
43 for (String key : keys) {
44 String value = properties.getProperty(key);
45 outputProperties.setProperty(key, value);
46 }
47 PropertyUtils.store(outputProperties, outputFile, encoding);
48 }
49
50 public Properties getProperties() {
51 return properties;
52 }
53
54 public void setProperties(Properties properties) {
55 this.properties = properties;
56 }
57
58 public File getOutputFile() {
59 return outputFile;
60 }
61
62 public void setOutputFile(File outputFile) {
63 this.outputFile = outputFile;
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 String getEncoding() {
83 return encoding;
84 }
85
86 public void setEncoding(String encoding) {
87 this.encoding = encoding;
88 }
89
90 public boolean isSkip() {
91 return skip;
92 }
93
94 public void setSkip(boolean skip) {
95 this.skip = skip;
96 }
97
98 }