Added support for customizing the character encoding used in generated java source.
diff --git a/tools/org.eclipse.persistence.tools.gen.db/.classpath b/tools/org.eclipse.persistence.tools.gen.db/.classpath
index 32c7e58..bd7a4b0 100644
--- a/tools/org.eclipse.persistence.tools.gen.db/.classpath
+++ b/tools/org.eclipse.persistence.tools.gen.db/.classpath
@@ -2,7 +2,6 @@
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="src" path="resource/templates/xml_entities"/>
- <classpathentry kind="src" path="resource/property_files"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6">
<attributes>
<attribute name="owner.project.facets" value="java"/>
diff --git a/tools/org.eclipse.persistence.tools.gen.nosql/src/org/eclipse/persistence/tools/gen/nosql/mongo/MongoEntityGenerator.java b/tools/org.eclipse.persistence.tools.gen.nosql/src/org/eclipse/persistence/tools/gen/nosql/mongo/MongoEntityGenerator.java
index d42d9f0..175c99e 100644
--- a/tools/org.eclipse.persistence.tools.gen.nosql/src/org/eclipse/persistence/tools/gen/nosql/mongo/MongoEntityGenerator.java
+++ b/tools/org.eclipse.persistence.tools.gen.nosql/src/org/eclipse/persistence/tools/gen/nosql/mongo/MongoEntityGenerator.java
@@ -152,11 +152,13 @@
* @param packageName java package to use for the generated code.
* @param baseDirectory the base directory to use for the generated code.
* @param type the access type to use (method versus field annotations).
+ * @param characterEncoding the type of character encoding to use (e.g. "UTF-8").
*
* @throws Exception
*/
public void generateSource(Collection<String> collectionNames, String packageName,
- File baseDirectory, AccessType type) throws Exception {
+ File baseDirectory, AccessType type,
+ String characterEncoding) throws Exception {
// Create metadata descriptors for the specified collections.
List<CollectionDescriptor> collectionDescriptors = buildCollectionDescriptors(collectionNames);
ExternalORMConfiguration config = generate(collectionDescriptors);
@@ -175,12 +177,12 @@
// Generate source for entities
for (ExternalEntity entity : config.entities()) {
- generateSource(entity, type, "entity.java.vm", packageName, packageDirectory, ve);
+ generateSource(entity, type, "entity.java.vm", packageName, packageDirectory, ve, characterEncoding);
}
// Generate source for embeddables
for (ExternalEmbeddableEntity entity : config.embeddableEntities()) {
- generateSource(entity, type, "embeddable.java.vm", packageName, packageDirectory, ve);
+ generateSource(entity, type, "embeddable.java.vm", packageName, packageDirectory, ve, characterEncoding);
}
}
@@ -193,12 +195,14 @@
* @param packageName the package name to use.
* @param packageDirectory the directory to generate the source file in.
* @param ve the velocity engine to use.
+ * @param characterEncoding the type of character encoding to use.
*
* @throws Exception
*/
private void generateSource(ExternalEmbeddableEntity entity, AccessType accessType,
String templateName, String packageName,
- File packageDirectory, VelocityEngine ve) throws Exception {
+ File packageDirectory, VelocityEngine ve,
+ String characterEncoding) throws Exception {
VelocityContext context = new VelocityContext();
context.put("entity", entity);
context.put("mappings", ListTools.list(entity.mappings()));
@@ -211,7 +215,7 @@
File javaFile = new File(packageDirectory, entity.getClassName() + ".java");
- byte[] content = fileContent.getBytes("UTF-8");
+ byte[] content = fileContent.getBytes(characterEncoding);
javaFile.createNewFile();
FileOutputStream writer = new FileOutputStream(javaFile);
writer.write(content);