[ONOS-4799],[ONOS-4351] Augment inter file linker and Generated Code refactored.
Change-Id: Id1f3ac9c90a632373f51cc75d499c3110216be17
diff --git a/plugin/src/main/java/org/onosproject/yangutils/utils/io/impl/FileSystemUtil.java b/plugin/src/main/java/org/onosproject/yangutils/utils/io/impl/FileSystemUtil.java
index d3e7b09..fae08ed 100644
--- a/plugin/src/main/java/org/onosproject/yangutils/utils/io/impl/FileSystemUtil.java
+++ b/plugin/src/main/java/org/onosproject/yangutils/utils/io/impl/FileSystemUtil.java
@@ -123,4 +123,22 @@
}
}
}
+
+ /**
+ * Closes the file handle for temporary file.
+ *
+ * @param file file to be closed
+ * @param toBeDeleted flag to indicate if file needs to be deleted
+ * @throws IOException when failed to close the file handle
+ */
+ public static void closeFile(File file, boolean toBeDeleted)
+ throws IOException {
+
+ if (file != null) {
+ updateFileHandle(file, null, true);
+ if (toBeDeleted) {
+ file.delete();
+ }
+ }
+ }
}
diff --git a/plugin/src/main/java/org/onosproject/yangutils/utils/io/impl/JavaDocGen.java b/plugin/src/main/java/org/onosproject/yangutils/utils/io/impl/JavaDocGen.java
index 19660b1..1610536 100644
--- a/plugin/src/main/java/org/onosproject/yangutils/utils/io/impl/JavaDocGen.java
+++ b/plugin/src/main/java/org/onosproject/yangutils/utils/io/impl/JavaDocGen.java
@@ -590,7 +590,7 @@
* @param attribute attribute string
* @return javaDocs for type constructor
*/
- private static String generateForTypeConstructor(String attribute) {
+ public static String generateForTypeConstructor(String attribute) {
return NEW_LINE + FOUR_SPACE_INDENTATION + JAVA_DOC_FIRST_LINE + FOUR_SPACE_INDENTATION + JAVA_DOC_CONSTRUCTOR
+ attribute + PERIOD + NEW_LINE + FOUR_SPACE_INDENTATION + NEW_LINE_ASTERISK + FOUR_SPACE_INDENTATION
+ JAVA_DOC_PARAM + VALUE + SPACE + VALUE + SPACE + OF + SPACE + attribute + NEW_LINE
diff --git a/plugin/src/main/java/org/onosproject/yangutils/utils/io/impl/YangIoUtils.java b/plugin/src/main/java/org/onosproject/yangutils/utils/io/impl/YangIoUtils.java
index baea6ea..a32d927 100644
--- a/plugin/src/main/java/org/onosproject/yangutils/utils/io/impl/YangIoUtils.java
+++ b/plugin/src/main/java/org/onosproject/yangutils/utils/io/impl/YangIoUtils.java
@@ -28,11 +28,11 @@
import java.util.List;
import java.util.Stack;
import java.util.regex.Pattern;
+
import org.apache.commons.io.FileUtils;
import org.onosproject.yangutils.translator.exception.TranslatorException;
import static org.onosproject.yangutils.utils.UtilConstants.COLAN;
-import static org.onosproject.yangutils.utils.UtilConstants.COMMA;
import static org.onosproject.yangutils.utils.UtilConstants.EMPTY_STRING;
import static org.onosproject.yangutils.utils.UtilConstants.HASH;
import static org.onosproject.yangutils.utils.UtilConstants.HYPHEN;
@@ -212,35 +212,17 @@
/**
* Removes extra char from the string.
*
- * @param valueString string to be trimmed
- * @param removealStirng extra chars
+ * @param valueString string to be trimmed
+ * @param removalStirng extra chars
* @return new string
*/
- public static String trimAtLast(String valueString, String removealStirng) {
+ public static String trimAtLast(String valueString, String removalStirng) {
StringBuilder stringBuilder = new StringBuilder(valueString);
- int index = valueString.lastIndexOf(removealStirng);
- stringBuilder.deleteCharAt(index);
- return stringBuilder.toString();
- }
-
- /**
- * Returns new parted string.
- *
- * @param partString string to be parted
- * @return parted string
- */
- public static String partString(String partString) {
- String[] strArray = partString.split(COMMA);
- String newString = EMPTY_STRING;
- for (int i = 0; i < strArray.length; i++) {
- if (i % 4 != 0 || i == 0) {
- newString = newString + strArray[i] + COMMA;
- } else {
- newString = newString + NEW_LINE + TWELVE_SPACE_INDENTATION
- + strArray[i] + COMMA;
- }
+ int index = valueString.lastIndexOf(removalStirng);
+ if (index != -1) {
+ stringBuilder.deleteCharAt(index);
}
- return trimAtLast(newString, COMMA);
+ return stringBuilder.toString();
}
/**
diff --git a/plugin/src/main/java/org/onosproject/yangutils/utils/io/impl/YangPluginConfig.java b/plugin/src/main/java/org/onosproject/yangutils/utils/io/impl/YangPluginConfig.java
index 21314ef..d7ef5a2 100644
--- a/plugin/src/main/java/org/onosproject/yangutils/utils/io/impl/YangPluginConfig.java
+++ b/plugin/src/main/java/org/onosproject/yangutils/utils/io/impl/YangPluginConfig.java
@@ -27,6 +27,11 @@
private String codeGenDir;
/**
+ * Contains the code generation directory.
+ */
+ private String managerCodeGenDir;
+
+ /**
* Contains information of naming conflicts that can be resolved.
*/
private YangToJavaNamingConflictUtil conflictResolver;
@@ -72,4 +77,22 @@
public YangToJavaNamingConflictUtil getConflictResolver() {
return conflictResolver;
}
+
+ /**
+ * Returns manager's code generation directory.
+ *
+ * @return manager's code generation directory
+ */
+ public String getManagerCodeGenDir() {
+ return managerCodeGenDir;
+ }
+
+ /**
+ * Sets manager's code generation directory.
+ *
+ * @param moduleCodeGenDir manager's code generation directory
+ */
+ public void setManagerCodeGenDir(String moduleCodeGenDir) {
+ this.managerCodeGenDir = moduleCodeGenDir;
+ }
}