Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Adds private ctor and strips type prefixes from final constant.

  • Loading branch information...
commit d4431d26d8d400c68ce01fd2a948beead84d6d06 1 parent 5c58d6f
Jonathan Le authored
Showing with 17 additions and 2 deletions.
  1. BIN  bin/poppy.jar
  2. +17 −2 src/org/thete/Poppy.java
View
BIN  bin/poppy.jar
Binary file not shown
View
19 src/org/thete/Poppy.java
@@ -120,6 +120,9 @@ private void process() throws BuildException {
}
fos.write(String.format("public class %s {\n", classInfo.simpleName).getBytes());
+ // Write a private constructor
+ fos.write((TAB_SPACE + String.format("private %s() {}\n", classInfo.simpleName))
+ .getBytes());
processPropertySets(fos);
processPaths(fos);
fos.write("}\n".getBytes());
@@ -193,8 +196,7 @@ private void writeConstant(FileOutputStream fos, Properties props) throws IOExce
for (Map.Entry e : props.entrySet()) {
final String name = (String) e.getKey();
final String value = (String) e.getValue();
- fos.write(String.format(DataType.evaluateType(name, value).getFormat(),
- name.replace('.', '_').toUpperCase(), value).getBytes());
+ DataType.write(fos, name, value);
}
}
@@ -280,5 +282,18 @@ public static DataType evaluateType(String name, String value) {
return STRING;
}
}
+
+ public static void write(FileOutputStream fos, String name, String value)
+ throws IOException {
+ final DataType type = DataType.evaluateType(name, value);
+ if (!type.equals(DataType.STRING)) {
+ final int i = name.indexOf('.');
+ if (i < name.length() - 1) {
+ name = name.substring(i + 1);
+ }
+ }
+ fos.write(String.format(type.getFormat(),
+ name.replace('.', '_').toUpperCase(), value).getBytes());
+ }
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.