This repository has been archived by the owner. It is now read-only.
Permalink
Browse files

Adds private ctor and strips type prefixes from final constant.

  • Loading branch information...
Jonathan Le
Jonathan Le committed Apr 19, 2012
1 parent 5c58d6f commit d4431d26d8d400c68ce01fd2a948beead84d6d06
Showing with 17 additions and 2 deletions.
  1. BIN bin/poppy.jar
  2. +17 −2 src/org/thete/Poppy.java
View
Binary file not shown.
View
@@ -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());
+ }
}
}

0 comments on commit d4431d2

Please sign in to comment.