From 4ebb2f9d7a869aa10f0842fbdd3a12635a0e81b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Bispo?= Date: Thu, 2 Jan 2025 15:35:43 +0000 Subject: [PATCH] [JavaGenerator] Adds Utils.ln(), IGenerate now uses that method --- .../org/specs/generators/java/IGenerate.java | 15 +++--- .../specs/generators/java/utils/Utils.java | 51 +++++++++---------- 2 files changed, 31 insertions(+), 35 deletions(-) diff --git a/JavaGenerator/src/org/specs/generators/java/IGenerate.java b/JavaGenerator/src/org/specs/generators/java/IGenerate.java index d6dce657..57311e26 100644 --- a/JavaGenerator/src/org/specs/generators/java/IGenerate.java +++ b/JavaGenerator/src/org/specs/generators/java/IGenerate.java @@ -1,30 +1,31 @@ /* * Copyright 2013 SPeCS. - * + * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. under the License. */ /** - * + * */ package org.specs.generators.java; -import pt.up.fe.specs.util.SpecsIo; +import org.specs.generators.java.utils.Utils; /** * @author Tiago - * + * */ public interface IGenerate { public StringBuilder generateCode(int indentation); default String ln() { - return SpecsIo.getNewline(); + return Utils.ln(); + //return SpecsIo.getNewline(); } } diff --git a/JavaGenerator/src/org/specs/generators/java/utils/Utils.java b/JavaGenerator/src/org/specs/generators/java/utils/Utils.java index 87d2a50c..a8c5567b 100644 --- a/JavaGenerator/src/org/specs/generators/java/utils/Utils.java +++ b/JavaGenerator/src/org/specs/generators/java/utils/Utils.java @@ -1,24 +1,23 @@ /* * Copyright 2013 SPeCS. - * + * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. under the License. */ package org.specs.generators.java.utils; -import java.io.File; - import org.specs.generators.java.IGenerate; import org.specs.generators.java.classtypes.ClassType; - import pt.up.fe.specs.util.SpecsIo; +import java.io.File; + public class Utils { private static final String INDENTER = " "; @@ -27,9 +26,8 @@ public class Utils { /** * Returns a {@link StringBuilder} containing the desired indentation - * - * @param indentation - * the level of indentation + * + * @param indentation the level of indentation * @return {@link StringBuilder} with indentation */ public static StringBuilder indent(int indentation) { @@ -42,12 +40,10 @@ public static StringBuilder indent(int indentation) { /** * Generates the java class/enum/interface into the requested folder, according to the class' package - * + * * @param outputDir - * @param java - * the class to generate and write in the output folder - * @param replace - * replace existing file? + * @param java the class to generate and write in the output folder + * @param replace replace existing file? */ public static boolean generateToFile(File outputDir, ClassType java, boolean replace) { @@ -59,13 +55,10 @@ public static boolean generateToFile(File outputDir, ClassType java, boolean rep /** * Create the file path according to the package of the class/interface - * - * @param outputDir - * the output directory - * @param pack - * the class/interface package - * @param name - * the class/interface name + * + * @param outputDir the output directory + * @param pack the class/interface package + * @param name the class/interface name * @return {@link File} containing the new file path */ private static File getFilePath(File outputDir, String pack, String name) { @@ -83,13 +76,10 @@ private static File getFilePath(File outputDir, String pack, String name) { /** * Write the java code in an output file - * - * @param outputFile - * the file destiny of the code - * @param java - * the code to generate and write; - * @param replace - * replace existing file? + * + * @param outputFile the file destiny of the code + * @param java the code to generate and write; + * @param replace replace existing file? */ private static boolean writeToFile(File outputFile, IGenerate java, boolean replace) { final StringBuilder generatedJava = java.generateCode(0); @@ -110,4 +100,9 @@ public static String firstCharToUpper(String string) { return string.substring(0, 1).toUpperCase() + string.substring(1); } + public static String ln() { + return "\n"; + //return SpecsIo.getNewline(); + } + }