]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.graph.compiler/src/org/simantics/graph/compiler/internal/resourceFiles/ResourceFile.java
Fixed all line endings of the repository
[simantics/platform.git] / bundles / org.simantics.graph.compiler / src / org / simantics / graph / compiler / internal / resourceFiles / ResourceFile.java
index 2b3fd2b71e74580bb36c0471c83648baa4041e8a..25758343d59751d3dd2a5d28d2aac8d950485ebe 100644 (file)
-package org.simantics.graph.compiler.internal.resourceFiles;\r
-\r
-import java.io.ByteArrayInputStream;\r
-import java.io.InputStream;\r
-import java.io.OutputStreamWriter;\r
-import java.io.StringWriter;\r
-import java.io.Writer;\r
-import java.net.URL;\r
-import java.util.Arrays;\r
-import java.util.Collection;\r
-import java.util.Collections;\r
-import java.util.List;\r
-\r
-import org.simantics.graph.IResourceFile;\r
-\r
-import freemarker.cache.URLTemplateLoader;\r
-import freemarker.template.Configuration;\r
-import freemarker.template.DefaultObjectWrapper;\r
-import freemarker.template.Template;\r
-\r
-public class ResourceFile implements IResourceFile {\r
-       String packageName;\r
-       String className;\r
-       List<ResourceRef> resources;\r
-       \r
-       public ResourceFile(String packageName, String className,\r
-                       List<ResourceRef> resources) {\r
-               this.packageName = packageName;\r
-               this.className = className;\r
-               this.resources = resources;\r
-       }\r
-\r
-       /* (non-Javadoc)\r
-        * @see org.simantics.graph.resourceFiles.IResourceFile#getPackageName()\r
-        */\r
-       @Override\r
-       public String getPackageName() {\r
-               return packageName;\r
-       }\r
-       \r
-       /* (non-Javadoc)\r
-        * @see org.simantics.graph.resourceFiles.IResourceFile#getClassName()\r
-        */\r
-       @Override\r
-       public String getClassName() {\r
-               return className;\r
-       }\r
-       \r
-       public Collection<ResourceRef> getResources() {\r
-               return resources;\r
-       }\r
-       \r
-       private static Configuration configuration = null;\r
-       private static Configuration getConfiguration() {\r
-               if(configuration == null) {\r
-                       configuration = new Configuration();\r
-                       configuration.setTemplateLoader(\r
-                                       new URLTemplateLoader() {                                               \r
-                                               @Override\r
-                                               protected URL getURL(String name) {\r
-                                                       return ResourceFile.class.getResource(name);\r
-                                               }\r
-                                       });\r
-                       configuration.setObjectWrapper(new DefaultObjectWrapper());\r
-               }\r
-               return configuration;\r
-       }\r
-       \r
-       /* (non-Javadoc)\r
-        * @see org.simantics.graph.resourceFiles.IResourceFile#write(java.io.Writer)\r
-        */\r
-       @Override\r
-       public void write(Writer writer) {\r
-               try {\r
-                       Template temp = \r
-                               getConfiguration().getTemplate("resourceFile.ftl");\r
-                        \r
-                       temp.process(this, writer);\r
-               } catch (Exception e) {\r
-                       // TODO Auto-generated catch block\r
-                       e.printStackTrace();\r
-               }  \r
-       }\r
-       \r
-       /* (non-Javadoc)\r
-        * @see org.simantics.graph.resourceFiles.IResourceFile#getContent()\r
-        */\r
-       @Override\r
-       public InputStream getContent() {\r
-               StringWriter writer = new StringWriter();\r
-               write(writer);\r
-               return new ByteArrayInputStream(writer.toString().getBytes());\r
-       }\r
-       \r
-       /* (non-Javadoc)\r
-        * @see org.simantics.graph.resourceFiles.IResourceFile#getFileName()\r
-        */\r
-       @Override\r
-       public String getFileName() {\r
-               return "src/" + packageName.replace('.', '/') + "/" + className + ".java";\r
-       }\r
-       \r
-       public void sort() {\r
-               Collections.sort(resources);\r
-       }\r
-       \r
-       public static void main(String[] args) {\r
-               ResourceRef Foo = new ResourceRef("Foo", "http://www.dsf.sdf/Foo");\r
-               ResourceRef Bar = new ResourceRef("Foo", "http://www.dsf.sdf/Bar");\r
-               Bar.deprecated = true;\r
-               new ResourceFile("org.simantics.graph", "Testi", Arrays.<ResourceRef>asList(\r
-                               Foo, Bar\r
-                       )).write(new OutputStreamWriter(System.out));\r
-       }\r
-}\r
+package org.simantics.graph.compiler.internal.resourceFiles;
+
+import java.io.ByteArrayInputStream;
+import java.io.InputStream;
+import java.io.OutputStreamWriter;
+import java.io.StringWriter;
+import java.io.Writer;
+import java.net.URL;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+
+import org.simantics.graph.IResourceFile;
+
+import freemarker.cache.URLTemplateLoader;
+import freemarker.template.Configuration;
+import freemarker.template.DefaultObjectWrapper;
+import freemarker.template.Template;
+
+public class ResourceFile implements IResourceFile {
+       String packageName;
+       String className;
+       List<ResourceRef> resources;
+       
+       public ResourceFile(String packageName, String className,
+                       List<ResourceRef> resources) {
+               this.packageName = packageName;
+               this.className = className;
+               this.resources = resources;
+       }
+
+       /* (non-Javadoc)
+        * @see org.simantics.graph.resourceFiles.IResourceFile#getPackageName()
+        */
+       @Override
+       public String getPackageName() {
+               return packageName;
+       }
+       
+       /* (non-Javadoc)
+        * @see org.simantics.graph.resourceFiles.IResourceFile#getClassName()
+        */
+       @Override
+       public String getClassName() {
+               return className;
+       }
+       
+       public Collection<ResourceRef> getResources() {
+               return resources;
+       }
+       
+       private static Configuration configuration = null;
+       private static Configuration getConfiguration() {
+               if(configuration == null) {
+                       configuration = new Configuration();
+                       configuration.setTemplateLoader(
+                                       new URLTemplateLoader() {                                               
+                                               @Override
+                                               protected URL getURL(String name) {
+                                                       return ResourceFile.class.getResource(name);
+                                               }
+                                       });
+                       configuration.setObjectWrapper(new DefaultObjectWrapper());
+               }
+               return configuration;
+       }
+       
+       /* (non-Javadoc)
+        * @see org.simantics.graph.resourceFiles.IResourceFile#write(java.io.Writer)
+        */
+       @Override
+       public void write(Writer writer) {
+               try {
+                       Template temp = 
+                               getConfiguration().getTemplate("resourceFile.ftl");
+                        
+                       temp.process(this, writer);
+               } catch (Exception e) {
+                       // TODO Auto-generated catch block
+                       e.printStackTrace();
+               }  
+       }
+       
+       /* (non-Javadoc)
+        * @see org.simantics.graph.resourceFiles.IResourceFile#getContent()
+        */
+       @Override
+       public InputStream getContent() {
+               StringWriter writer = new StringWriter();
+               write(writer);
+               return new ByteArrayInputStream(writer.toString().getBytes());
+       }
+       
+       /* (non-Javadoc)
+        * @see org.simantics.graph.resourceFiles.IResourceFile#getFileName()
+        */
+       @Override
+       public String getFileName() {
+               return "src/" + packageName.replace('.', '/') + "/" + className + ".java";
+       }
+       
+       public void sort() {
+               Collections.sort(resources);
+       }
+       
+       public static void main(String[] args) {
+               ResourceRef Foo = new ResourceRef("Foo", "http://www.dsf.sdf/Foo");
+               ResourceRef Bar = new ResourceRef("Foo", "http://www.dsf.sdf/Bar");
+               Bar.deprecated = true;
+               new ResourceFile("org.simantics.graph", "Testi", Arrays.<ResourceRef>asList(
+                               Foo, Bar
+                       )).write(new OutputStreamWriter(System.out));
+       }
+}