Committed by
Thomas Vachuska
[ONOS-4711] Removed cyclic dependencies
Change-Id: I9ffea9a1a1b72f6ed3a23c0edb04cfc37bd8e48e
Showing
69 changed files
with
1278 additions
and
1533 deletions
... | @@ -31,11 +31,11 @@ import org.onosproject.yangutils.datamodel.YangRpc; | ... | @@ -31,11 +31,11 @@ import org.onosproject.yangutils.datamodel.YangRpc; |
31 | import org.onosproject.yangutils.datamodel.YangType; | 31 | import org.onosproject.yangutils.datamodel.YangType; |
32 | import org.onosproject.yangutils.datamodel.exceptions.DataModelException; | 32 | import org.onosproject.yangutils.datamodel.exceptions.DataModelException; |
33 | 33 | ||
34 | + | ||
34 | /** | 35 | /** |
35 | * Represents utilities for data model tree. | 36 | * Represents utilities for data model tree. |
36 | */ | 37 | */ |
37 | public final class DataModelUtils { | 38 | public final class DataModelUtils { |
38 | - | ||
39 | /** | 39 | /** |
40 | * Creates a new data model tree utility. | 40 | * Creates a new data model tree utility. |
41 | */ | 41 | */ | ... | ... |
... | @@ -17,7 +17,7 @@ | ... | @@ -17,7 +17,7 @@ |
17 | package org.onosproject.yangutils.linker; | 17 | package org.onosproject.yangutils.linker; |
18 | 18 | ||
19 | import java.util.Set; | 19 | import java.util.Set; |
20 | -import org.onosproject.yangutils.plugin.manager.YangFileInfo; | 20 | +import org.onosproject.yangutils.datamodel.YangNode; |
21 | 21 | ||
22 | /** | 22 | /** |
23 | * Abstraction of entity which provides linking service of YANG files. | 23 | * Abstraction of entity which provides linking service of YANG files. |
... | @@ -28,7 +28,7 @@ public interface YangLinker { | ... | @@ -28,7 +28,7 @@ public interface YangLinker { |
28 | * Resolve the import and include dependencies for a given resolution | 28 | * Resolve the import and include dependencies for a given resolution |
29 | * information. | 29 | * information. |
30 | * | 30 | * |
31 | - * @param yangFileInfoSet set of all dependent YANG files | 31 | + * @param yangNodeSet set of all dependent YANG nodes |
32 | */ | 32 | */ |
33 | - void resolveDependencies(Set<YangFileInfo> yangFileInfoSet); | 33 | + void resolveDependencies(Set<YangNode> yangNodeSet); |
34 | } | 34 | } | ... | ... |
... | @@ -25,7 +25,6 @@ import org.onosproject.yangutils.datamodel.YangSubModule; | ... | @@ -25,7 +25,6 @@ import org.onosproject.yangutils.datamodel.YangSubModule; |
25 | import org.onosproject.yangutils.datamodel.exceptions.DataModelException; | 25 | import org.onosproject.yangutils.datamodel.exceptions.DataModelException; |
26 | import org.onosproject.yangutils.linker.YangLinker; | 26 | import org.onosproject.yangutils.linker.YangLinker; |
27 | import org.onosproject.yangutils.linker.exceptions.LinkerException; | 27 | import org.onosproject.yangutils.linker.exceptions.LinkerException; |
28 | -import org.onosproject.yangutils.plugin.manager.YangFileInfo; | ||
29 | 28 | ||
30 | import static org.onosproject.yangutils.utils.UtilConstants.NEW_LINE; | 29 | import static org.onosproject.yangutils.utils.UtilConstants.NEW_LINE; |
31 | 30 | ||
... | @@ -53,53 +52,51 @@ public class YangLinkerManager | ... | @@ -53,53 +52,51 @@ public class YangLinkerManager |
53 | /** | 52 | /** |
54 | * Creates YANG nodes set. | 53 | * Creates YANG nodes set. |
55 | * | 54 | * |
56 | - * @param yangFileInfoSet YANG file information set | 55 | + * @param yangNodeSet YANG node information set |
57 | */ | 56 | */ |
58 | - public void createYangNodeSet(Set<YangFileInfo> yangFileInfoSet) { | 57 | + public void createYangNodeSet(Set<YangNode> yangNodeSet) { |
59 | - for (YangFileInfo yangFileInfo : yangFileInfoSet) { | 58 | + getYangNodeSet().addAll(yangNodeSet); |
60 | - getYangNodeSet().add(yangFileInfo.getRootNode()); | ||
61 | - } | ||
62 | } | 59 | } |
63 | 60 | ||
64 | @Override | 61 | @Override |
65 | - public void resolveDependencies(Set<YangFileInfo> yangFileInfoSet) { | 62 | + public void resolveDependencies(Set<YangNode> yangNodeSet) { |
66 | 63 | ||
67 | // Create YANG node set. | 64 | // Create YANG node set. |
68 | - createYangNodeSet(yangFileInfoSet); | 65 | + createYangNodeSet(yangNodeSet); |
69 | 66 | ||
70 | // Carry out linking of sub module with module. | 67 | // Carry out linking of sub module with module. |
71 | - linkSubModulesToParentModule(yangFileInfoSet); | 68 | + linkSubModulesToParentModule(yangNodeSet); |
72 | 69 | ||
73 | // Add references to import list. | 70 | // Add references to import list. |
74 | - addRefToYangFilesImportList(yangFileInfoSet); | 71 | + addRefToYangFilesImportList(yangNodeSet); |
75 | 72 | ||
76 | // Add reference to include list. | 73 | // Add reference to include list. |
77 | - addRefToYangFilesIncludeList(yangFileInfoSet); | 74 | + addRefToYangFilesIncludeList(yangNodeSet); |
78 | 75 | ||
79 | // TODO check for circular import/include. | 76 | // TODO check for circular import/include. |
80 | 77 | ||
81 | // Carry out inter-file linking. | 78 | // Carry out inter-file linking. |
82 | - processInterFileLinking(yangFileInfoSet); | 79 | + processInterFileLinking(yangNodeSet); |
83 | } | 80 | } |
84 | 81 | ||
85 | /** | 82 | /** |
86 | * Resolves sub-module linking by linking sub module with parent module. | 83 | * Resolves sub-module linking by linking sub module with parent module. |
87 | * | 84 | * |
88 | - * @param yangFileInfoSet set of YANG files info | 85 | + * @param yangNodeSet set of YANG files info |
89 | * @throws LinkerException fails to link sub-module to parent module | 86 | * @throws LinkerException fails to link sub-module to parent module |
90 | */ | 87 | */ |
91 | - public void linkSubModulesToParentModule(Set<YangFileInfo> yangFileInfoSet) | 88 | + public void linkSubModulesToParentModule(Set<YangNode> yangNodeSet) |
92 | throws LinkerException { | 89 | throws LinkerException { |
93 | - for (YangFileInfo yangFileInfo : yangFileInfoSet) { | 90 | + for (YangNode yangNode : yangNodeSet) { |
94 | - YangNode yangNode = yangFileInfo.getRootNode(); | ||
95 | if (yangNode instanceof YangSubModule) { | 91 | if (yangNode instanceof YangSubModule) { |
96 | try { | 92 | try { |
97 | ((YangSubModule) yangNode).linkWithModule(getYangNodeSet()); | 93 | ((YangSubModule) yangNode).linkWithModule(getYangNodeSet()); |
98 | } catch (DataModelException e) { | 94 | } catch (DataModelException e) { |
99 | - String errorInfo = "YANG file error: " + yangFileInfo.getYangFileName() + " at line: " | 95 | + String errorInfo = "YANG file error: " + yangNode.getName() + " at line: " |
100 | + e.getLineNumber() + " at position: " + e.getCharPositionInLine() + NEW_LINE | 96 | + e.getLineNumber() + " at position: " + e.getCharPositionInLine() + NEW_LINE |
101 | + e.getMessage(); | 97 | + e.getMessage(); |
102 | throw new LinkerException(errorInfo); | 98 | throw new LinkerException(errorInfo); |
99 | + // TODO add file path in exception message in util manager. | ||
103 | } | 100 | } |
104 | } | 101 | } |
105 | } | 102 | } |
... | @@ -108,20 +105,20 @@ public class YangLinkerManager | ... | @@ -108,20 +105,20 @@ public class YangLinkerManager |
108 | /** | 105 | /** |
109 | * Adds imported node information to the import list. | 106 | * Adds imported node information to the import list. |
110 | * | 107 | * |
111 | - * @param yangFileInfoSet set of YANG files info | 108 | + * @param yangNodeSet set of YANG files info |
112 | * @throws LinkerException fails to find imported module | 109 | * @throws LinkerException fails to find imported module |
113 | */ | 110 | */ |
114 | - public void addRefToYangFilesImportList(Set<YangFileInfo> yangFileInfoSet) throws LinkerException { | 111 | + public void addRefToYangFilesImportList(Set<YangNode> yangNodeSet) throws LinkerException { |
115 | - for (YangFileInfo yangFileInfo : yangFileInfoSet) { | 112 | + for (YangNode yangNode : yangNodeSet) { |
116 | - YangNode yangNode = yangFileInfo.getRootNode(); | ||
117 | if (yangNode instanceof YangReferenceResolver) { | 113 | if (yangNode instanceof YangReferenceResolver) { |
118 | try { | 114 | try { |
119 | ((YangReferenceResolver) yangNode).addReferencesToImportList(getYangNodeSet()); | 115 | ((YangReferenceResolver) yangNode).addReferencesToImportList(getYangNodeSet()); |
120 | } catch (DataModelException e) { | 116 | } catch (DataModelException e) { |
121 | - String errorInfo = "Error in file: " + yangFileInfo.getYangFileName() + " at line: " | 117 | + String errorInfo = "Error in file: " + yangNode.getName() + " at line: " |
122 | + e.getLineNumber() + " at position: " + e.getCharPositionInLine() + NEW_LINE | 118 | + e.getLineNumber() + " at position: " + e.getCharPositionInLine() + NEW_LINE |
123 | + e.getMessage(); | 119 | + e.getMessage(); |
124 | throw new LinkerException(errorInfo); | 120 | throw new LinkerException(errorInfo); |
121 | + // TODO add file path in exception message in util manager. | ||
125 | } | 122 | } |
126 | } | 123 | } |
127 | } | 124 | } |
... | @@ -130,20 +127,20 @@ public class YangLinkerManager | ... | @@ -130,20 +127,20 @@ public class YangLinkerManager |
130 | /** | 127 | /** |
131 | * Adds included node information to the include list. | 128 | * Adds included node information to the include list. |
132 | * | 129 | * |
133 | - * @param yangFileInfoSet set of YANG files info | 130 | + * @param yangNodeSet set of YANG files info |
134 | * @throws LinkerException fails to find included sub-module | 131 | * @throws LinkerException fails to find included sub-module |
135 | */ | 132 | */ |
136 | - public void addRefToYangFilesIncludeList(Set<YangFileInfo> yangFileInfoSet) throws LinkerException { | 133 | + public void addRefToYangFilesIncludeList(Set<YangNode> yangNodeSet) throws LinkerException { |
137 | - for (YangFileInfo yangFileInfo : yangFileInfoSet) { | 134 | + for (YangNode yangNode : yangNodeSet) { |
138 | - YangNode yangNode = yangFileInfo.getRootNode(); | ||
139 | if (yangNode instanceof YangReferenceResolver) { | 135 | if (yangNode instanceof YangReferenceResolver) { |
140 | try { | 136 | try { |
141 | ((YangReferenceResolver) yangNode).addReferencesToIncludeList(getYangNodeSet()); | 137 | ((YangReferenceResolver) yangNode).addReferencesToIncludeList(getYangNodeSet()); |
142 | } catch (DataModelException e) { | 138 | } catch (DataModelException e) { |
143 | - String errorInfo = "Error in file: " + yangFileInfo.getYangFileName() + " at line: " | 139 | + String errorInfo = "Error in file: " + yangNode.getName() + " at line: " |
144 | + e.getLineNumber() + " at position: " + e.getCharPositionInLine() + NEW_LINE | 140 | + e.getLineNumber() + " at position: " + e.getCharPositionInLine() + NEW_LINE |
145 | + e.getMessage(); | 141 | + e.getMessage(); |
146 | throw new LinkerException(errorInfo); | 142 | throw new LinkerException(errorInfo); |
143 | + // TODO add file path in exception message in util manager. | ||
147 | } | 144 | } |
148 | } | 145 | } |
149 | } | 146 | } |
... | @@ -152,20 +149,21 @@ public class YangLinkerManager | ... | @@ -152,20 +149,21 @@ public class YangLinkerManager |
152 | /** | 149 | /** |
153 | * Processes inter file linking for type and uses. | 150 | * Processes inter file linking for type and uses. |
154 | * | 151 | * |
155 | - * @param yangFileInfoSet set of YANG files info | 152 | + * @param yangNodeSet set of YANG files info |
156 | * @throws LinkerException a violation in linker execution | 153 | * @throws LinkerException a violation in linker execution |
157 | */ | 154 | */ |
158 | - public void processInterFileLinking(Set<YangFileInfo> yangFileInfoSet) | 155 | + public void processInterFileLinking(Set<YangNode> yangNodeSet) |
159 | throws LinkerException { | 156 | throws LinkerException { |
160 | - for (YangFileInfo yangFileInfo : yangFileInfoSet) { | 157 | + for (YangNode yangNode : yangNodeSet) { |
161 | try { | 158 | try { |
162 | - ((YangReferenceResolver) yangFileInfo.getRootNode()).resolveInterFileLinking(ResolvableType.YANG_USES); | 159 | + ((YangReferenceResolver) yangNode).resolveInterFileLinking(ResolvableType.YANG_USES); |
163 | - ((YangReferenceResolver) yangFileInfo.getRootNode()) | 160 | + ((YangReferenceResolver) yangNode) |
164 | .resolveInterFileLinking(ResolvableType.YANG_DERIVED_DATA_TYPE); | 161 | .resolveInterFileLinking(ResolvableType.YANG_DERIVED_DATA_TYPE); |
165 | } catch (DataModelException e) { | 162 | } catch (DataModelException e) { |
166 | - String errorInfo = "Error in file: " + yangFileInfo.getYangFileName() + " at line: " | 163 | + String errorInfo = "Error in file: " + yangNode.getName() + " at line: " |
167 | + e.getLineNumber() + " at position: " + e.getCharPositionInLine() + NEW_LINE + e.getMessage(); | 164 | + e.getLineNumber() + " at position: " + e.getCharPositionInLine() + NEW_LINE + e.getMessage(); |
168 | throw new LinkerException(errorInfo); | 165 | throw new LinkerException(errorInfo); |
166 | + // TODO add file path in exception message in util manager. | ||
169 | } | 167 | } |
170 | } | 168 | } |
171 | } | 169 | } | ... | ... |
... | @@ -17,7 +17,6 @@ | ... | @@ -17,7 +17,6 @@ |
17 | package org.onosproject.yangutils.parser.impl; | 17 | package org.onosproject.yangutils.parser.impl; |
18 | 18 | ||
19 | import java.io.IOException; | 19 | import java.io.IOException; |
20 | - | ||
21 | import org.antlr.v4.runtime.ANTLRFileStream; | 20 | import org.antlr.v4.runtime.ANTLRFileStream; |
22 | import org.antlr.v4.runtime.ANTLRInputStream; | 21 | import org.antlr.v4.runtime.ANTLRInputStream; |
23 | import org.antlr.v4.runtime.CommonTokenStream; | 22 | import org.antlr.v4.runtime.CommonTokenStream; |
... | @@ -101,4 +100,4 @@ public class YangUtilsParserManager implements YangUtilsParser { | ... | @@ -101,4 +100,4 @@ public class YangUtilsParserManager implements YangUtilsParser { |
101 | // Returns the Root Node of the constructed data model tree. | 100 | // Returns the Root Node of the constructed data model tree. |
102 | return treeWalker.getRootNode(); | 101 | return treeWalker.getRootNode(); |
103 | } | 102 | } |
104 | -} | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
103 | +} | ... | ... |
... | @@ -31,7 +31,7 @@ import org.onosproject.yangutils.parser.exceptions.ParserException; | ... | @@ -31,7 +31,7 @@ import org.onosproject.yangutils.parser.exceptions.ParserException; |
31 | import org.onosproject.yangutils.parser.impl.TreeWalkListener; | 31 | import org.onosproject.yangutils.parser.impl.TreeWalkListener; |
32 | 32 | ||
33 | import static org.onosproject.yangutils.datamodel.utils.YangConstructType.AUGMENT_DATA; | 33 | import static org.onosproject.yangutils.datamodel.utils.YangConstructType.AUGMENT_DATA; |
34 | -import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getCapitalCase; | 34 | +import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getCapitalCase; |
35 | 35 | ||
36 | /** | 36 | /** |
37 | * Represents a utility which provides listener utilities augment node. | 37 | * Represents a utility which provides listener utilities augment node. | ... | ... |
utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/plugin/manager/YangPluginUtils.java
0 → 100644
1 | +/* | ||
2 | + * Copyright 2016-present Open Networking Laboratory | ||
3 | + * | ||
4 | + * Licensed under the Apache License, Version 2.0 (the "License"); | ||
5 | + * you may not use this file except in compliance with the License. | ||
6 | + * You may obtain a copy of the License at | ||
7 | + * | ||
8 | + * http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | + * | ||
10 | + * Unless required by applicable law or agreed to in writing, software | ||
11 | + * distributed under the License is distributed on an "AS IS" BASIS, | ||
12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
13 | + * See the License for the specific language governing permissions and | ||
14 | + * limitations under the License. | ||
15 | + */ | ||
16 | + | ||
17 | +package org.onosproject.yangutils.plugin.manager; | ||
18 | + | ||
19 | +import java.io.File; | ||
20 | +import java.io.FileInputStream; | ||
21 | +import java.io.FileOutputStream; | ||
22 | +import java.io.IOException; | ||
23 | +import java.io.InputStream; | ||
24 | +import java.io.ObjectInputStream; | ||
25 | +import java.io.ObjectOutputStream; | ||
26 | +import java.nio.file.Files; | ||
27 | +import java.nio.file.StandardCopyOption; | ||
28 | +import java.util.ArrayList; | ||
29 | +import java.util.Enumeration; | ||
30 | +import java.util.Iterator; | ||
31 | +import java.util.List; | ||
32 | +import java.util.Set; | ||
33 | +import java.util.jar.JarEntry; | ||
34 | +import java.util.jar.JarFile; | ||
35 | +import org.apache.maven.artifact.repository.ArtifactRepository; | ||
36 | +import org.apache.maven.model.Dependency; | ||
37 | +import org.apache.maven.model.Resource; | ||
38 | +import org.apache.maven.project.MavenProject; | ||
39 | +import org.onosproject.yangutils.datamodel.YangNode; | ||
40 | +import org.slf4j.Logger; | ||
41 | +import org.sonatype.plexus.build.incremental.BuildContext; | ||
42 | + | ||
43 | +import static org.onosproject.yangutils.utils.UtilConstants.HYPHEN; | ||
44 | +import static org.onosproject.yangutils.utils.UtilConstants.JAR; | ||
45 | +import static org.onosproject.yangutils.utils.UtilConstants.PERIOD; | ||
46 | +import static org.onosproject.yangutils.utils.UtilConstants.SLASH; | ||
47 | +import static org.onosproject.yangutils.utils.UtilConstants.TEMP; | ||
48 | +import static org.onosproject.yangutils.utils.UtilConstants.YANG_RESOURCES; | ||
49 | +import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getCamelCase; | ||
50 | +import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getPackageDirPathFromJavaJPackage; | ||
51 | +import static org.slf4j.LoggerFactory.getLogger; | ||
52 | + | ||
53 | +/** | ||
54 | + * Represents YANG plugin utilities. | ||
55 | + */ | ||
56 | +public final class YangPluginUtils { | ||
57 | + | ||
58 | + private static final Logger log = getLogger(YangPluginUtils.class); | ||
59 | + | ||
60 | + private static final String TARGET_RESOURCE_PATH = SLASH + TEMP + SLASH + YANG_RESOURCES + SLASH; | ||
61 | + | ||
62 | + private static final String SERIALIZED_FILE_EXTENSION = ".ser"; | ||
63 | + | ||
64 | + private YangPluginUtils() { | ||
65 | + } | ||
66 | + | ||
67 | + /** | ||
68 | + * Adds generated source directory to the compilation root. | ||
69 | + * | ||
70 | + * @param source directory | ||
71 | + * @param project current maven project | ||
72 | + * @param context current build context | ||
73 | + */ | ||
74 | + public static void addToCompilationRoot(String source, MavenProject project, BuildContext context) { | ||
75 | + project.addCompileSourceRoot(source); | ||
76 | + context.refresh(project.getBasedir()); | ||
77 | + log.info("Source directory added to compilation root: " + source); | ||
78 | + } | ||
79 | + | ||
80 | + /** | ||
81 | + * Copies YANG files to the current project's output directory. | ||
82 | + * | ||
83 | + * @param yangFileInfo list of YANG files | ||
84 | + * @param outputDir project's output directory | ||
85 | + * @param project maven project | ||
86 | + * @throws IOException when fails to copy files to destination resource directory | ||
87 | + */ | ||
88 | + public static void copyYangFilesToTarget(Set<YangFileInfo> yangFileInfo, String outputDir, MavenProject project) | ||
89 | + throws IOException { | ||
90 | + | ||
91 | + List<File> files = getListOfFile(yangFileInfo); | ||
92 | + | ||
93 | + String path = outputDir + TARGET_RESOURCE_PATH; | ||
94 | + File targetDir = new File(path); | ||
95 | + targetDir.mkdirs(); | ||
96 | + | ||
97 | + for (File file : files) { | ||
98 | + Files.copy(file.toPath(), | ||
99 | + new File(path + file.getName()).toPath(), | ||
100 | + StandardCopyOption.REPLACE_EXISTING); | ||
101 | + } | ||
102 | + addToProjectResource(outputDir + SLASH + TEMP + SLASH, project); | ||
103 | + } | ||
104 | + | ||
105 | + /** | ||
106 | + * Provides a list of files from list of strings. | ||
107 | + * | ||
108 | + * @param yangFileInfo set of yang file information | ||
109 | + * @return list of files | ||
110 | + */ | ||
111 | + private static List<File> getListOfFile(Set<YangFileInfo> yangFileInfo) { | ||
112 | + List<File> files = new ArrayList<>(); | ||
113 | + Iterator<YangFileInfo> yangFileIterator = yangFileInfo.iterator(); | ||
114 | + while (yangFileIterator.hasNext()) { | ||
115 | + YangFileInfo yangFile = yangFileIterator.next(); | ||
116 | + if (yangFile.isForTranslator()) { | ||
117 | + files.add(new File(yangFile.getYangFileName())); | ||
118 | + } | ||
119 | + } | ||
120 | + return files; | ||
121 | + } | ||
122 | + | ||
123 | + /** | ||
124 | + * Serializes data-model. | ||
125 | + * | ||
126 | + * @param directory base directory for serialized files | ||
127 | + * @param fileInfoSet YANG file info set | ||
128 | + * @param project maven project | ||
129 | + * @param operation true if need to add to resource | ||
130 | + * @throws IOException when fails to do IO operations | ||
131 | + */ | ||
132 | + public static void serializeDataModel(String directory, Set<YangFileInfo> fileInfoSet, | ||
133 | + MavenProject project, boolean operation) throws IOException { | ||
134 | + | ||
135 | + String serFileDirPath = directory + TARGET_RESOURCE_PATH; | ||
136 | + File dir = new File(serFileDirPath); | ||
137 | + dir.mkdirs(); | ||
138 | + | ||
139 | + if (operation) { | ||
140 | + addToProjectResource(directory + SLASH + TEMP + SLASH, project); | ||
141 | + } | ||
142 | + | ||
143 | + for (YangFileInfo fileInfo : fileInfoSet) { | ||
144 | + | ||
145 | + String serFileName = serFileDirPath + getCamelCase(fileInfo.getRootNode().getName(), null) | ||
146 | + + SERIALIZED_FILE_EXTENSION; | ||
147 | + fileInfo.setSerializedFile(serFileName); | ||
148 | + FileOutputStream fileOutputStream = new FileOutputStream(serFileName); | ||
149 | + ObjectOutputStream objectOutputStream = new ObjectOutputStream(fileOutputStream); | ||
150 | + objectOutputStream.writeObject(fileInfo.getRootNode()); | ||
151 | + objectOutputStream.close(); | ||
152 | + fileOutputStream.close(); | ||
153 | + } | ||
154 | + } | ||
155 | + | ||
156 | + /** | ||
157 | + * Returns de-serializes YANG data-model nodes. | ||
158 | + * | ||
159 | + * @param serailizedfileInfoSet YANG file info set | ||
160 | + * @return de-serializes YANG data-model nodes | ||
161 | + * @throws IOException when fails do IO operations | ||
162 | + */ | ||
163 | + public static List<YangNode> deSerializeDataModel(List<String> serailizedfileInfoSet) throws IOException { | ||
164 | + | ||
165 | + List<YangNode> nodes = new ArrayList<>(); | ||
166 | + for (String fileInfo : serailizedfileInfoSet) { | ||
167 | + YangNode node = null; | ||
168 | + try { | ||
169 | + FileInputStream fileInputStream = new FileInputStream(fileInfo); | ||
170 | + ObjectInputStream objectInputStream = new ObjectInputStream(fileInputStream); | ||
171 | + node = (YangNode) objectInputStream.readObject(); | ||
172 | + nodes.add(node); | ||
173 | + objectInputStream.close(); | ||
174 | + fileInputStream.close(); | ||
175 | + } catch (IOException | ClassNotFoundException e) { | ||
176 | + throw new IOException(fileInfo + " not found."); | ||
177 | + } | ||
178 | + } | ||
179 | + return nodes; | ||
180 | + } | ||
181 | + | ||
182 | + /** | ||
183 | + * Returns list of jar path. | ||
184 | + * | ||
185 | + * @param project maven project | ||
186 | + * @param localRepository local repository | ||
187 | + * @param remoteRepos remote repository | ||
188 | + * @return list of jar paths | ||
189 | + */ | ||
190 | + private static List<String> resolveDependecyJarPath(MavenProject project, ArtifactRepository localRepository, | ||
191 | + List<ArtifactRepository> remoteRepos) { | ||
192 | + | ||
193 | + StringBuilder path = new StringBuilder(); | ||
194 | + List<String> jarPaths = new ArrayList<>(); | ||
195 | + for (Dependency dependency : project.getDependencies()) { | ||
196 | + | ||
197 | + path.append(localRepository.getBasedir()); | ||
198 | + path.append(SLASH); | ||
199 | + path.append(getPackageDirPathFromJavaJPackage(dependency.getGroupId())); | ||
200 | + path.append(SLASH); | ||
201 | + path.append(dependency.getArtifactId()); | ||
202 | + path.append(SLASH); | ||
203 | + path.append(dependency.getVersion()); | ||
204 | + path.append(SLASH); | ||
205 | + path.append(dependency.getArtifactId() + HYPHEN + dependency.getVersion() + PERIOD + JAR); | ||
206 | + File jarFile = new File(path.toString()); | ||
207 | + if (jarFile.exists()) { | ||
208 | + jarPaths.add(path.toString()); | ||
209 | + } | ||
210 | + path.delete(0, path.length()); | ||
211 | + } | ||
212 | + | ||
213 | + for (ArtifactRepository repo : remoteRepos) { | ||
214 | + // TODO: add resolver for remote repo. | ||
215 | + } | ||
216 | + return jarPaths; | ||
217 | + } | ||
218 | + | ||
219 | + /** | ||
220 | + * Resolves inter jar dependencies. | ||
221 | + * | ||
222 | + * @param project current maven project | ||
223 | + * @param localRepository local maven repository | ||
224 | + * @param remoteRepos list of remote repository | ||
225 | + * @param directory directory for serialized files | ||
226 | + * @return list of resolved datamodel nodes | ||
227 | + * @throws IOException when fails to do IO operations | ||
228 | + */ | ||
229 | + public static List<YangNode> resolveInterJarDependencies(MavenProject project, ArtifactRepository localRepository, | ||
230 | + List<ArtifactRepository> remoteRepos, String directory) | ||
231 | + throws IOException { | ||
232 | + | ||
233 | + List<String> dependeciesJarPaths = resolveDependecyJarPath(project, localRepository, remoteRepos); | ||
234 | + List<YangNode> resolvedDataModelNodes = new ArrayList<>(); | ||
235 | + for (String dependecy : dependeciesJarPaths) { | ||
236 | + resolvedDataModelNodes.addAll(deSerializeDataModel(parseJarFile(dependecy, directory))); | ||
237 | + } | ||
238 | + return resolvedDataModelNodes; | ||
239 | + } | ||
240 | + | ||
241 | + /** | ||
242 | + * Parses jar file and returns list of serialized file names. | ||
243 | + * | ||
244 | + * @param jarFile jar file to be parsed | ||
245 | + * @param directory directory for keeping the searized files | ||
246 | + * @return list of serialized files | ||
247 | + * @throws IOException when fails to do IO operations | ||
248 | + */ | ||
249 | + public static List<String> parseJarFile(String jarFile, String directory) | ||
250 | + throws IOException { | ||
251 | + | ||
252 | + List<String> serailizedFiles = new ArrayList<>(); | ||
253 | + JarFile jar = new JarFile(jarFile); | ||
254 | + Enumeration<?> enumEntries = jar.entries(); | ||
255 | + | ||
256 | + File serializedFileDir = new File(directory); | ||
257 | + serializedFileDir.mkdirs(); | ||
258 | + while (enumEntries.hasMoreElements()) { | ||
259 | + JarEntry file = (JarEntry) enumEntries.nextElement(); | ||
260 | + if (file.getName().endsWith(SERIALIZED_FILE_EXTENSION)) { | ||
261 | + if (file.getName().contains(SLASH)) { | ||
262 | + String[] strArray = file.getName().split(SLASH); | ||
263 | + String tempPath = ""; | ||
264 | + for (int i = 0; i < strArray.length - 1; i++) { | ||
265 | + tempPath = SLASH + tempPath + SLASH + strArray[i]; | ||
266 | + } | ||
267 | + File dir = new File(directory + tempPath); | ||
268 | + dir.mkdirs(); | ||
269 | + } | ||
270 | + File serailizedFile = new File(directory + SLASH + file.getName()); | ||
271 | + if (file.isDirectory()) { | ||
272 | + serailizedFile.mkdirs(); | ||
273 | + continue; | ||
274 | + } | ||
275 | + InputStream inputStream = jar.getInputStream(file); | ||
276 | + | ||
277 | + FileOutputStream fileOutputStream = new FileOutputStream(serailizedFile); | ||
278 | + while (inputStream.available() > 0) { | ||
279 | + fileOutputStream.write(inputStream.read()); | ||
280 | + } | ||
281 | + fileOutputStream.close(); | ||
282 | + inputStream.close(); | ||
283 | + serailizedFiles.add(serailizedFile.toString()); | ||
284 | + } | ||
285 | + } | ||
286 | + jar.close(); | ||
287 | + return serailizedFiles; | ||
288 | + } | ||
289 | + | ||
290 | + /* Adds directory to resources of project */ | ||
291 | + private static void addToProjectResource(String dir, MavenProject project) { | ||
292 | + Resource rsc = new Resource(); | ||
293 | + rsc.setDirectory(dir); | ||
294 | + project.addResource(rsc); | ||
295 | + } | ||
296 | +} |
... | @@ -21,7 +21,6 @@ import java.util.HashSet; | ... | @@ -21,7 +21,6 @@ import java.util.HashSet; |
21 | import java.util.Iterator; | 21 | import java.util.Iterator; |
22 | import java.util.List; | 22 | import java.util.List; |
23 | import java.util.Set; | 23 | import java.util.Set; |
24 | - | ||
25 | import org.apache.maven.artifact.repository.ArtifactRepository; | 24 | import org.apache.maven.artifact.repository.ArtifactRepository; |
26 | import org.apache.maven.plugin.AbstractMojo; | 25 | import org.apache.maven.plugin.AbstractMojo; |
27 | import org.apache.maven.plugin.MojoExecutionException; | 26 | import org.apache.maven.plugin.MojoExecutionException; |
... | @@ -37,25 +36,25 @@ import org.onosproject.yangutils.linker.impl.YangLinkerManager; | ... | @@ -37,25 +36,25 @@ import org.onosproject.yangutils.linker.impl.YangLinkerManager; |
37 | import org.onosproject.yangutils.parser.YangUtilsParser; | 36 | import org.onosproject.yangutils.parser.YangUtilsParser; |
38 | import org.onosproject.yangutils.parser.exceptions.ParserException; | 37 | import org.onosproject.yangutils.parser.exceptions.ParserException; |
39 | import org.onosproject.yangutils.parser.impl.YangUtilsParserManager; | 38 | import org.onosproject.yangutils.parser.impl.YangUtilsParserManager; |
40 | -import org.onosproject.yangutils.translator.tojava.utils.YangPluginConfig; | ||
41 | -import org.onosproject.yangutils.translator.tojava.utils.YangToJavaNamingConflictUtil; | ||
42 | import org.onosproject.yangutils.utils.io.impl.YangFileScanner; | 39 | import org.onosproject.yangutils.utils.io.impl.YangFileScanner; |
40 | +import org.onosproject.yangutils.utils.io.impl.YangPluginConfig; | ||
41 | +import org.onosproject.yangutils.utils.io.impl.YangToJavaNamingConflictUtil; | ||
43 | import org.sonatype.plexus.build.incremental.BuildContext; | 42 | import org.sonatype.plexus.build.incremental.BuildContext; |
44 | 43 | ||
45 | import static org.apache.maven.plugins.annotations.LifecyclePhase.GENERATE_SOURCES; | 44 | import static org.apache.maven.plugins.annotations.LifecyclePhase.GENERATE_SOURCES; |
46 | import static org.apache.maven.plugins.annotations.ResolutionScope.COMPILE; | 45 | import static org.apache.maven.plugins.annotations.ResolutionScope.COMPILE; |
46 | +import static org.onosproject.yangutils.plugin.manager.YangPluginUtils.addToCompilationRoot; | ||
47 | +import static org.onosproject.yangutils.plugin.manager.YangPluginUtils.copyYangFilesToTarget; | ||
48 | +import static org.onosproject.yangutils.plugin.manager.YangPluginUtils.resolveInterJarDependencies; | ||
49 | +import static org.onosproject.yangutils.plugin.manager.YangPluginUtils.serializeDataModel; | ||
47 | import static org.onosproject.yangutils.translator.tojava.JavaCodeGeneratorUtil.generateJavaCode; | 50 | import static org.onosproject.yangutils.translator.tojava.JavaCodeGeneratorUtil.generateJavaCode; |
48 | import static org.onosproject.yangutils.translator.tojava.JavaCodeGeneratorUtil.translatorErrorHandler; | 51 | import static org.onosproject.yangutils.translator.tojava.JavaCodeGeneratorUtil.translatorErrorHandler; |
49 | -import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getPackageDirPathFromJavaJPackage; | ||
50 | import static org.onosproject.yangutils.utils.UtilConstants.DEFAULT_BASE_PKG; | 52 | import static org.onosproject.yangutils.utils.UtilConstants.DEFAULT_BASE_PKG; |
51 | import static org.onosproject.yangutils.utils.UtilConstants.NEW_LINE; | 53 | import static org.onosproject.yangutils.utils.UtilConstants.NEW_LINE; |
52 | import static org.onosproject.yangutils.utils.UtilConstants.SLASH; | 54 | import static org.onosproject.yangutils.utils.UtilConstants.SLASH; |
53 | -import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.addToCompilationRoot; | ||
54 | -import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.copyYangFilesToTarget; | ||
55 | import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.deleteDirectory; | 55 | import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.deleteDirectory; |
56 | import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getDirectory; | 56 | import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getDirectory; |
57 | -import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.resolveInterJarDependencies; | 57 | +import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getPackageDirPathFromJavaJPackage; |
58 | -import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.serializeDataModel; | ||
59 | 58 | ||
60 | /** | 59 | /** |
61 | * Represents ONOS YANG utility maven plugin. | 60 | * Represents ONOS YANG utility maven plugin. |
... | @@ -64,7 +63,7 @@ import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.serializeDataM | ... | @@ -64,7 +63,7 @@ import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.serializeDataM |
64 | * requiresDependencyResolution at compile time. | 63 | * requiresDependencyResolution at compile time. |
65 | */ | 64 | */ |
66 | @Mojo(name = "yang2java", defaultPhase = GENERATE_SOURCES, requiresDependencyResolution = COMPILE, | 65 | @Mojo(name = "yang2java", defaultPhase = GENERATE_SOURCES, requiresDependencyResolution = COMPILE, |
67 | - requiresProject = true) | 66 | + requiresProject = true) |
68 | public class YangUtilManager | 67 | public class YangUtilManager |
69 | extends AbstractMojo { | 68 | extends AbstractMojo { |
70 | 69 | ||
... | @@ -75,6 +74,8 @@ public class YangUtilManager | ... | @@ -75,6 +74,8 @@ public class YangUtilManager |
75 | private YangLinker yangLinker = new YangLinkerManager(); | 74 | private YangLinker yangLinker = new YangLinkerManager(); |
76 | private YangFileInfo curYangFileInfo = new YangFileInfo(); | 75 | private YangFileInfo curYangFileInfo = new YangFileInfo(); |
77 | 76 | ||
77 | + private Set<YangNode> yangNodeSet = new HashSet<>(); | ||
78 | + | ||
78 | private static final String DEFAULT_PKG = SLASH + getPackageDirPathFromJavaJPackage(DEFAULT_BASE_PKG); | 79 | private static final String DEFAULT_PKG = SLASH + getPackageDirPathFromJavaJPackage(DEFAULT_BASE_PKG); |
79 | 80 | ||
80 | /** | 81 | /** |
... | @@ -217,6 +218,15 @@ public class YangUtilManager | ... | @@ -217,6 +218,15 @@ public class YangUtilManager |
217 | } | 218 | } |
218 | 219 | ||
219 | /** | 220 | /** |
221 | + * Returns the YANG node set. | ||
222 | + * | ||
223 | + * @return YANG node set | ||
224 | + */ | ||
225 | + public Set<YangNode> getYangNodeSet() { | ||
226 | + return yangNodeSet; | ||
227 | + } | ||
228 | + | ||
229 | + /** | ||
220 | * Resolved inter-jar dependencies. | 230 | * Resolved inter-jar dependencies. |
221 | * | 231 | * |
222 | * @throws IOException when fails to do IO operations | 232 | * @throws IOException when fails to do IO operations |
... | @@ -244,10 +254,11 @@ public class YangUtilManager | ... | @@ -244,10 +254,11 @@ public class YangUtilManager |
244 | */ | 254 | */ |
245 | public void resolveDependenciesUsingLinker() | 255 | public void resolveDependenciesUsingLinker() |
246 | throws MojoExecutionException { | 256 | throws MojoExecutionException { |
257 | + createYangNodeSet(); | ||
247 | for (YangFileInfo yangFileInfo : getYangFileInfoSet()) { | 258 | for (YangFileInfo yangFileInfo : getYangFileInfoSet()) { |
248 | setCurYangFileInfo(yangFileInfo); | 259 | setCurYangFileInfo(yangFileInfo); |
249 | try { | 260 | try { |
250 | - yangLinker.resolveDependencies(getYangFileInfoSet()); | 261 | + yangLinker.resolveDependencies(getYangNodeSet()); |
251 | } catch (LinkerException e) { | 262 | } catch (LinkerException e) { |
252 | throw new MojoExecutionException(e.getMessage()); | 263 | throw new MojoExecutionException(e.getMessage()); |
253 | } | 264 | } |
... | @@ -255,6 +266,15 @@ public class YangUtilManager | ... | @@ -255,6 +266,15 @@ public class YangUtilManager |
255 | } | 266 | } |
256 | 267 | ||
257 | /** | 268 | /** |
269 | + * Creates YANG nodes set. | ||
270 | + */ | ||
271 | + public void createYangNodeSet() { | ||
272 | + for (YangFileInfo yangFileInfo : getYangFileInfoSet()) { | ||
273 | + getYangNodeSet().add(yangFileInfo.getRootNode()); | ||
274 | + } | ||
275 | + } | ||
276 | + | ||
277 | + /** | ||
258 | * Parses all the provided YANG files and generates YANG data model tree. | 278 | * Parses all the provided YANG files and generates YANG data model tree. |
259 | * | 279 | * |
260 | * @throws IOException a violation in IO | 280 | * @throws IOException a violation in IO | ... | ... |
... | @@ -17,7 +17,7 @@ | ... | @@ -17,7 +17,7 @@ |
17 | package org.onosproject.yangutils.translator.tojava; | 17 | package org.onosproject.yangutils.translator.tojava; |
18 | 18 | ||
19 | import org.onosproject.yangutils.translator.exception.TranslatorException; | 19 | import org.onosproject.yangutils.translator.exception.TranslatorException; |
20 | -import org.onosproject.yangutils.translator.tojava.utils.YangPluginConfig; | 20 | +import org.onosproject.yangutils.utils.io.impl.YangPluginConfig; |
21 | 21 | ||
22 | /** | 22 | /** |
23 | * Abstraction of an entity which provides Code generator functionalities. | 23 | * Abstraction of an entity which provides Code generator functionalities. | ... | ... |
... | @@ -14,10 +14,7 @@ | ... | @@ -14,10 +14,7 @@ |
14 | * limitations under the License. | 14 | * limitations under the License. |
15 | */ | 15 | */ |
16 | 16 | ||
17 | -package org.onosproject.yangutils.translator.tojava.javamodel; | 17 | +package org.onosproject.yangutils.translator.tojava; |
18 | - | ||
19 | -import org.onosproject.yangutils.translator.tojava.JavaFileInfoContainer; | ||
20 | -import org.onosproject.yangutils.translator.tojava.TempJavaCodeFragmentFilesContainer; | ||
21 | 18 | ||
22 | /** | 19 | /** |
23 | * Represents YANG java info containing interface for java code generator, java | 20 | * Represents YANG java info containing interface for java code generator, java | ... | ... |
... | @@ -20,7 +20,7 @@ import java.io.IOException; | ... | @@ -20,7 +20,7 @@ import java.io.IOException; |
20 | 20 | ||
21 | import org.onosproject.yangutils.datamodel.YangNode; | 21 | import org.onosproject.yangutils.datamodel.YangNode; |
22 | import org.onosproject.yangutils.translator.exception.TranslatorException; | 22 | import org.onosproject.yangutils.translator.exception.TranslatorException; |
23 | -import org.onosproject.yangutils.translator.tojava.utils.YangPluginConfig; | 23 | +import org.onosproject.yangutils.utils.io.impl.YangPluginConfig; |
24 | 24 | ||
25 | import static org.onosproject.yangutils.translator.tojava.TraversalType.CHILD; | 25 | import static org.onosproject.yangutils.translator.tojava.TraversalType.CHILD; |
26 | import static org.onosproject.yangutils.translator.tojava.TraversalType.PARENT; | 26 | import static org.onosproject.yangutils.translator.tojava.TraversalType.PARENT; | ... | ... |
... | @@ -18,7 +18,7 @@ package org.onosproject.yangutils.translator.tojava; | ... | @@ -18,7 +18,7 @@ package org.onosproject.yangutils.translator.tojava; |
18 | 18 | ||
19 | import java.io.Serializable; | 19 | import java.io.Serializable; |
20 | 20 | ||
21 | -import org.onosproject.yangutils.translator.tojava.utils.YangPluginConfig; | 21 | +import org.onosproject.yangutils.utils.io.impl.YangPluginConfig; |
22 | 22 | ||
23 | /** | 23 | /** |
24 | * Represents cached java file handle, which supports the addition of member attributes and | 24 | * Represents cached java file handle, which supports the addition of member attributes and | ... | ... |
... | @@ -22,13 +22,13 @@ import java.util.Objects; | ... | @@ -22,13 +22,13 @@ import java.util.Objects; |
22 | import org.onosproject.yangutils.datamodel.YangNode; | 22 | import org.onosproject.yangutils.datamodel.YangNode; |
23 | import org.onosproject.yangutils.translator.exception.TranslatorException; | 23 | import org.onosproject.yangutils.translator.exception.TranslatorException; |
24 | import org.onosproject.yangutils.translator.tojava.javamodel.JavaLeafInfoContainer; | 24 | import org.onosproject.yangutils.translator.tojava.javamodel.JavaLeafInfoContainer; |
25 | -import org.onosproject.yangutils.translator.tojava.utils.AttributesJavaDataType; | 25 | +import org.onosproject.yangutils.translator.tojava.javamodel.AttributesJavaDataType; |
26 | -import org.onosproject.yangutils.translator.tojava.utils.YangToJavaNamingConflictUtil; | 26 | +import org.onosproject.yangutils.utils.io.impl.YangToJavaNamingConflictUtil; |
27 | 27 | ||
28 | import com.google.common.base.MoreObjects; | 28 | import com.google.common.base.MoreObjects; |
29 | 29 | ||
30 | -import static org.onosproject.yangutils.translator.tojava.utils.AttributesJavaDataType.getJavaImportClass; | 30 | +import static org.onosproject.yangutils.translator.tojava.javamodel.AttributesJavaDataType.getJavaImportClass; |
31 | -import static org.onosproject.yangutils.translator.tojava.utils.AttributesJavaDataType.getJavaImportPackage; | 31 | +import static org.onosproject.yangutils.translator.tojava.javamodel.AttributesJavaDataType.getJavaImportPackage; |
32 | 32 | ||
33 | /** | 33 | /** |
34 | * Represents the information about individual imports in the generated file. | 34 | * Represents the information about individual imports in the generated file. | ... | ... |
... | @@ -19,7 +19,7 @@ package org.onosproject.yangutils.translator.tojava; | ... | @@ -19,7 +19,7 @@ package org.onosproject.yangutils.translator.tojava; |
19 | import java.io.File; | 19 | import java.io.File; |
20 | import java.io.IOException; | 20 | import java.io.IOException; |
21 | 21 | ||
22 | -import org.onosproject.yangutils.translator.tojava.utils.YangPluginConfig; | 22 | +import org.onosproject.yangutils.utils.io.impl.YangPluginConfig; |
23 | 23 | ||
24 | import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.CONSTRUCTOR_IMPL_MASK; | 24 | import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.CONSTRUCTOR_IMPL_MASK; |
25 | import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getConstructor; | 25 | import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getConstructor; | ... | ... |
... | @@ -21,7 +21,7 @@ import java.io.IOException; | ... | @@ -21,7 +21,7 @@ import java.io.IOException; |
21 | import org.onosproject.yangutils.datamodel.YangNode; | 21 | import org.onosproject.yangutils.datamodel.YangNode; |
22 | import org.onosproject.yangutils.datamodel.YangTypeHolder; | 22 | import org.onosproject.yangutils.datamodel.YangTypeHolder; |
23 | import org.onosproject.yangutils.translator.exception.TranslatorException; | 23 | import org.onosproject.yangutils.translator.exception.TranslatorException; |
24 | -import org.onosproject.yangutils.translator.tojava.utils.YangPluginConfig; | 24 | +import org.onosproject.yangutils.utils.io.impl.YangPluginConfig; |
25 | 25 | ||
26 | import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_ENUM_CLASS; | 26 | import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_ENUM_CLASS; |
27 | import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_INTERFACE_WITH_BUILDER; | 27 | import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_INTERFACE_WITH_BUILDER; | ... | ... |
... | @@ -28,19 +28,19 @@ import org.onosproject.yangutils.datamodel.YangEnumeration; | ... | @@ -28,19 +28,19 @@ import org.onosproject.yangutils.datamodel.YangEnumeration; |
28 | import org.onosproject.yangutils.datamodel.YangNode; | 28 | import org.onosproject.yangutils.datamodel.YangNode; |
29 | import org.onosproject.yangutils.translator.exception.TranslatorException; | 29 | import org.onosproject.yangutils.translator.exception.TranslatorException; |
30 | import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaType; | 30 | import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaType; |
31 | -import org.onosproject.yangutils.translator.tojava.utils.YangPluginConfig; | 31 | +import org.onosproject.yangutils.utils.io.impl.YangPluginConfig; |
32 | 32 | ||
33 | import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.ENUM_IMPL_MASK; | 33 | import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.ENUM_IMPL_MASK; |
34 | import static org.onosproject.yangutils.translator.tojava.JavaAttributeInfo.getAttributeInfoForTheData; | 34 | import static org.onosproject.yangutils.translator.tojava.JavaAttributeInfo.getAttributeInfoForTheData; |
35 | import static org.onosproject.yangutils.translator.tojava.utils.JavaCodeSnippetGen.generateEnumAttributeString; | 35 | import static org.onosproject.yangutils.translator.tojava.utils.JavaCodeSnippetGen.generateEnumAttributeString; |
36 | import static org.onosproject.yangutils.translator.tojava.utils.JavaFileGenerator.generateEnumClassFile; | 36 | import static org.onosproject.yangutils.translator.tojava.utils.JavaFileGenerator.generateEnumClassFile; |
37 | import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getEnumJavaAttribute; | 37 | import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getEnumJavaAttribute; |
38 | -import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getPrefixForIdentifier; | 38 | +import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getPrefixForIdentifier; |
39 | import static org.onosproject.yangutils.translator.tojava.utils.TempJavaCodeFragmentFilesUtils.closeFile; | 39 | import static org.onosproject.yangutils.translator.tojava.utils.TempJavaCodeFragmentFilesUtils.closeFile; |
40 | import static org.onosproject.yangutils.utils.UtilConstants.EMPTY_STRING; | 40 | import static org.onosproject.yangutils.utils.UtilConstants.EMPTY_STRING; |
41 | import static org.onosproject.yangutils.utils.UtilConstants.REGEX_FOR_FIRST_DIGIT; | 41 | import static org.onosproject.yangutils.utils.UtilConstants.REGEX_FOR_FIRST_DIGIT; |
42 | import static org.onosproject.yangutils.utils.UtilConstants.YANG_AUTO_PREFIX; | 42 | import static org.onosproject.yangutils.utils.UtilConstants.YANG_AUTO_PREFIX; |
43 | -import static org.onosproject.yangutils.utils.io.impl.FileSystemUtil.createPackage; | 43 | +import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.createPackage; |
44 | 44 | ||
45 | /** | 45 | /** |
46 | * Represents implementation of java code fragments temporary implementations. | 46 | * Represents implementation of java code fragments temporary implementations. | ... | ... |
... | @@ -33,7 +33,7 @@ import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaGrouping; | ... | @@ -33,7 +33,7 @@ import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaGrouping; |
33 | import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaModule; | 33 | import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaModule; |
34 | import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaSubModule; | 34 | import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaSubModule; |
35 | import org.onosproject.yangutils.translator.tojava.utils.JavaExtendsListHolder; | 35 | import org.onosproject.yangutils.translator.tojava.utils.JavaExtendsListHolder; |
36 | -import org.onosproject.yangutils.translator.tojava.utils.YangPluginConfig; | 36 | +import org.onosproject.yangutils.utils.io.impl.YangPluginConfig; |
37 | 37 | ||
38 | import static org.onosproject.yangutils.datamodel.utils.DataModelUtils.getParentNodeInGenCode; | 38 | import static org.onosproject.yangutils.datamodel.utils.DataModelUtils.getParentNodeInGenCode; |
39 | import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.BUILDER_CLASS_MASK; | 39 | import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.BUILDER_CLASS_MASK; |
... | @@ -55,7 +55,7 @@ import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType. | ... | @@ -55,7 +55,7 @@ import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType. |
55 | import static org.onosproject.yangutils.translator.tojava.JavaAttributeInfo.getAttributeInfoForTheData; | 55 | import static org.onosproject.yangutils.translator.tojava.JavaAttributeInfo.getAttributeInfoForTheData; |
56 | import static org.onosproject.yangutils.translator.tojava.JavaQualifiedTypeInfo.getQualifiedInfoOfFromString; | 56 | import static org.onosproject.yangutils.translator.tojava.JavaQualifiedTypeInfo.getQualifiedInfoOfFromString; |
57 | import static org.onosproject.yangutils.translator.tojava.JavaQualifiedTypeInfo.getQualifiedTypeInfoOfCurNode; | 57 | import static org.onosproject.yangutils.translator.tojava.JavaQualifiedTypeInfo.getQualifiedTypeInfoOfCurNode; |
58 | -import static org.onosproject.yangutils.translator.tojava.utils.AttributesJavaDataType.updateJavaFileInfo; | 58 | +import static org.onosproject.yangutils.translator.tojava.javamodel.AttributesJavaDataType.updateJavaFileInfo; |
59 | import static org.onosproject.yangutils.translator.tojava.utils.JavaCodeSnippetGen.getJavaAttributeDefination; | 59 | import static org.onosproject.yangutils.translator.tojava.utils.JavaCodeSnippetGen.getJavaAttributeDefination; |
60 | import static org.onosproject.yangutils.translator.tojava.utils.JavaCodeSnippetGen.getJavaClassDefClose; | 60 | import static org.onosproject.yangutils.translator.tojava.utils.JavaCodeSnippetGen.getJavaClassDefClose; |
61 | import static org.onosproject.yangutils.translator.tojava.utils.JavaFileGenerator.generateBuilderClassFile; | 61 | import static org.onosproject.yangutils.translator.tojava.utils.JavaFileGenerator.generateBuilderClassFile; |
... | @@ -63,9 +63,9 @@ import static org.onosproject.yangutils.translator.tojava.utils.JavaFileGenerato | ... | @@ -63,9 +63,9 @@ import static org.onosproject.yangutils.translator.tojava.utils.JavaFileGenerato |
63 | import static org.onosproject.yangutils.translator.tojava.utils.JavaFileGenerator.generateImplClassFile; | 63 | import static org.onosproject.yangutils.translator.tojava.utils.JavaFileGenerator.generateImplClassFile; |
64 | import static org.onosproject.yangutils.translator.tojava.utils.JavaFileGenerator.generateInterfaceFile; | 64 | import static org.onosproject.yangutils.translator.tojava.utils.JavaFileGenerator.generateInterfaceFile; |
65 | import static org.onosproject.yangutils.translator.tojava.utils.JavaFileGeneratorUtils.getFileObject; | 65 | import static org.onosproject.yangutils.translator.tojava.utils.JavaFileGeneratorUtils.getFileObject; |
66 | -import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getCamelCase; | 66 | +import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getCamelCase; |
67 | -import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getCapitalCase; | 67 | +import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getCapitalCase; |
68 | -import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getPackageDirPathFromJavaJPackage; | 68 | +import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getPackageDirPathFromJavaJPackage; |
69 | import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getRootPackage; | 69 | import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getRootPackage; |
70 | import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getBuildString; | 70 | import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getBuildString; |
71 | import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getDefaultConstructorString; | 71 | import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getDefaultConstructorString; |
... | @@ -104,7 +104,7 @@ import static org.onosproject.yangutils.utils.UtilConstants.REFERENCE_CARDINALIT | ... | @@ -104,7 +104,7 @@ import static org.onosproject.yangutils.utils.UtilConstants.REFERENCE_CARDINALIT |
104 | import static org.onosproject.yangutils.utils.UtilConstants.SEMI_COLAN; | 104 | import static org.onosproject.yangutils.utils.UtilConstants.SEMI_COLAN; |
105 | import static org.onosproject.yangutils.utils.UtilConstants.SERVICE; | 105 | import static org.onosproject.yangutils.utils.UtilConstants.SERVICE; |
106 | import static org.onosproject.yangutils.utils.UtilConstants.SLASH; | 106 | import static org.onosproject.yangutils.utils.UtilConstants.SLASH; |
107 | -import static org.onosproject.yangutils.utils.io.impl.FileSystemUtil.createPackage; | 107 | +import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.createPackage; |
108 | import static org.onosproject.yangutils.utils.io.impl.FileSystemUtil.readAppendFile; | 108 | import static org.onosproject.yangutils.utils.io.impl.FileSystemUtil.readAppendFile; |
109 | import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.getJavaDoc; | 109 | import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.getJavaDoc; |
110 | import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.JavaDocType.GETTER_METHOD; | 110 | import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.JavaDocType.GETTER_METHOD; | ... | ... |
... | @@ -25,7 +25,7 @@ import org.onosproject.yangutils.datamodel.YangNode; | ... | @@ -25,7 +25,7 @@ import org.onosproject.yangutils.datamodel.YangNode; |
25 | import org.onosproject.yangutils.datamodel.YangNotification; | 25 | import org.onosproject.yangutils.datamodel.YangNotification; |
26 | import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaModule; | 26 | import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaModule; |
27 | import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaSubModule; | 27 | import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaSubModule; |
28 | -import org.onosproject.yangutils.translator.tojava.utils.YangPluginConfig; | 28 | +import org.onosproject.yangutils.utils.io.impl.YangPluginConfig; |
29 | 29 | ||
30 | import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_EVENT_CLASS; | 30 | import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_EVENT_CLASS; |
31 | import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_EVENT_LISTENER_INTERFACE; | 31 | import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_EVENT_LISTENER_INTERFACE; |
... | @@ -46,10 +46,10 @@ import static org.onosproject.yangutils.translator.tojava.utils.JavaFileGenerato | ... | @@ -46,10 +46,10 @@ import static org.onosproject.yangutils.translator.tojava.utils.JavaFileGenerato |
46 | import static org.onosproject.yangutils.translator.tojava.utils.JavaFileGenerator.generateManagerClassFile; | 46 | import static org.onosproject.yangutils.translator.tojava.utils.JavaFileGenerator.generateManagerClassFile; |
47 | import static org.onosproject.yangutils.translator.tojava.utils.JavaFileGenerator.generateServiceInterfaceFile; | 47 | import static org.onosproject.yangutils.translator.tojava.utils.JavaFileGenerator.generateServiceInterfaceFile; |
48 | import static org.onosproject.yangutils.translator.tojava.utils.JavaFileGeneratorUtils.getFileObject; | 48 | import static org.onosproject.yangutils.translator.tojava.utils.JavaFileGeneratorUtils.getFileObject; |
49 | -import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getCamelCase; | 49 | +import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getCamelCase; |
50 | -import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getCapitalCase; | 50 | +import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getCapitalCase; |
51 | import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getEnumJavaAttribute; | 51 | import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getEnumJavaAttribute; |
52 | -import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getSmallCase; | 52 | +import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getSmallCase; |
53 | import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getGetterForClass; | 53 | import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getGetterForClass; |
54 | import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getRpcManagerMethod; | 54 | import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getRpcManagerMethod; |
55 | import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getRpcServiceMethod; | 55 | import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getRpcServiceMethod; |
... | @@ -67,7 +67,7 @@ import static org.onosproject.yangutils.utils.UtilConstants.NEW_LINE; | ... | @@ -67,7 +67,7 @@ import static org.onosproject.yangutils.utils.UtilConstants.NEW_LINE; |
67 | import static org.onosproject.yangutils.utils.UtilConstants.RPC_INPUT_VAR_NAME; | 67 | import static org.onosproject.yangutils.utils.UtilConstants.RPC_INPUT_VAR_NAME; |
68 | import static org.onosproject.yangutils.utils.UtilConstants.SLASH; | 68 | import static org.onosproject.yangutils.utils.UtilConstants.SLASH; |
69 | import static org.onosproject.yangutils.utils.UtilConstants.VOID; | 69 | import static org.onosproject.yangutils.utils.UtilConstants.VOID; |
70 | -import static org.onosproject.yangutils.utils.io.impl.FileSystemUtil.createPackage; | 70 | +import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.createPackage; |
71 | import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.generateJavaDocForRpc; | 71 | import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.generateJavaDocForRpc; |
72 | import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.getJavaDoc; | 72 | import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.getJavaDoc; |
73 | import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.JavaDocType.ENUM_ATTRIBUTE; | 73 | import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.JavaDocType.ENUM_ATTRIBUTE; | ... | ... |
... | @@ -26,7 +26,7 @@ import org.onosproject.yangutils.datamodel.YangType; | ... | @@ -26,7 +26,7 @@ import org.onosproject.yangutils.datamodel.YangType; |
26 | import org.onosproject.yangutils.datamodel.YangTypeHolder; | 26 | import org.onosproject.yangutils.datamodel.YangTypeHolder; |
27 | import org.onosproject.yangutils.translator.exception.TranslatorException; | 27 | import org.onosproject.yangutils.translator.exception.TranslatorException; |
28 | import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaType; | 28 | import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaType; |
29 | -import org.onosproject.yangutils.translator.tojava.utils.YangPluginConfig; | 29 | +import org.onosproject.yangutils.utils.io.impl.YangPluginConfig; |
30 | 30 | ||
31 | import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_TYPEDEF_CLASS; | 31 | import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_TYPEDEF_CLASS; |
32 | import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_UNION_CLASS; | 32 | import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_UNION_CLASS; |
... | @@ -36,13 +36,13 @@ import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType. | ... | @@ -36,13 +36,13 @@ import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType. |
36 | import static org.onosproject.yangutils.translator.tojava.JavaAttributeInfo.getAttributeInfoForTheData; | 36 | import static org.onosproject.yangutils.translator.tojava.JavaAttributeInfo.getAttributeInfoForTheData; |
37 | import static org.onosproject.yangutils.translator.tojava.utils.JavaFileGenerator.generateTypeDefClassFile; | 37 | import static org.onosproject.yangutils.translator.tojava.utils.JavaFileGenerator.generateTypeDefClassFile; |
38 | import static org.onosproject.yangutils.translator.tojava.utils.JavaFileGenerator.generateUnionClassFile; | 38 | import static org.onosproject.yangutils.translator.tojava.utils.JavaFileGenerator.generateUnionClassFile; |
39 | -import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getCamelCase; | 39 | +import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getCamelCase; |
40 | import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getOfMethodStringAndJavaDoc; | 40 | import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getOfMethodStringAndJavaDoc; |
41 | import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getTypeConstructorStringAndJavaDoc; | 41 | import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getTypeConstructorStringAndJavaDoc; |
42 | import static org.onosproject.yangutils.translator.tojava.utils.TempJavaCodeFragmentFilesUtils.closeFile; | 42 | import static org.onosproject.yangutils.translator.tojava.utils.TempJavaCodeFragmentFilesUtils.closeFile; |
43 | import static org.onosproject.yangutils.utils.UtilConstants.EMPTY_STRING; | 43 | import static org.onosproject.yangutils.utils.UtilConstants.EMPTY_STRING; |
44 | import static org.onosproject.yangutils.utils.UtilConstants.NEW_LINE; | 44 | import static org.onosproject.yangutils.utils.UtilConstants.NEW_LINE; |
45 | -import static org.onosproject.yangutils.utils.io.impl.FileSystemUtil.createPackage; | 45 | +import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.createPackage; |
46 | 46 | ||
47 | /** | 47 | /** |
48 | * Represents implementation of java data type code fragments temporary implementations. | 48 | * Represents implementation of java data type code fragments temporary implementations. | ... | ... |
... | @@ -14,10 +14,9 @@ | ... | @@ -14,10 +14,9 @@ |
14 | * limitations under the License. | 14 | * limitations under the License. |
15 | */ | 15 | */ |
16 | 16 | ||
17 | -package org.onosproject.yangutils.translator.tojava.utils; | 17 | +package org.onosproject.yangutils.translator.tojava.javamodel; |
18 | 18 | ||
19 | import java.util.Stack; | 19 | import java.util.Stack; |
20 | - | ||
21 | import org.onosproject.yangutils.datamodel.YangDataTypes; | 20 | import org.onosproject.yangutils.datamodel.YangDataTypes; |
22 | import org.onosproject.yangutils.datamodel.YangDerivedInfo; | 21 | import org.onosproject.yangutils.datamodel.YangDerivedInfo; |
23 | import org.onosproject.yangutils.datamodel.YangEnumeration; | 22 | import org.onosproject.yangutils.datamodel.YangEnumeration; |
... | @@ -26,48 +25,35 @@ import org.onosproject.yangutils.datamodel.YangType; | ... | @@ -26,48 +25,35 @@ import org.onosproject.yangutils.datamodel.YangType; |
26 | import org.onosproject.yangutils.datamodel.YangTypeDef; | 25 | import org.onosproject.yangutils.datamodel.YangTypeDef; |
27 | import org.onosproject.yangutils.datamodel.YangUnion; | 26 | import org.onosproject.yangutils.datamodel.YangUnion; |
28 | import org.onosproject.yangutils.translator.exception.TranslatorException; | 27 | import org.onosproject.yangutils.translator.exception.TranslatorException; |
28 | +import org.onosproject.yangutils.translator.tojava.JavaCodeGeneratorInfo; | ||
29 | import org.onosproject.yangutils.translator.tojava.JavaFileInfo; | 29 | import org.onosproject.yangutils.translator.tojava.JavaFileInfo; |
30 | import org.onosproject.yangutils.translator.tojava.JavaFileInfoContainer; | 30 | import org.onosproject.yangutils.translator.tojava.JavaFileInfoContainer; |
31 | -import org.onosproject.yangutils.translator.tojava.javamodel.JavaCodeGeneratorInfo; | 31 | +import org.onosproject.yangutils.utils.io.impl.YangToJavaNamingConflictUtil; |
32 | -import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaEnumeration; | ||
33 | -import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaModule; | ||
34 | -import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaSubModule; | ||
35 | -import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaTypeDef; | ||
36 | -import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaUnion; | ||
37 | 32 | ||
38 | -import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getCamelCase; | 33 | +import static org.onosproject.yangutils.translator.tojava.javamodel.YangJavaModelUtils.getCurNodePackage; |
39 | -import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getCapitalCase; | ||
40 | -import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getCurNodePackage; | ||
41 | -import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getPackageDirPathFromJavaJPackage; | ||
42 | import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getRootPackage; | 34 | import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getRootPackage; |
43 | import static org.onosproject.yangutils.utils.UtilConstants.BIG_INTEGER; | 35 | import static org.onosproject.yangutils.utils.UtilConstants.BIG_INTEGER; |
44 | import static org.onosproject.yangutils.utils.UtilConstants.BOOLEAN_DATA_TYPE; | 36 | import static org.onosproject.yangutils.utils.UtilConstants.BOOLEAN_DATA_TYPE; |
45 | import static org.onosproject.yangutils.utils.UtilConstants.BOOLEAN_WRAPPER; | 37 | import static org.onosproject.yangutils.utils.UtilConstants.BOOLEAN_WRAPPER; |
46 | import static org.onosproject.yangutils.utils.UtilConstants.BYTE; | 38 | import static org.onosproject.yangutils.utils.UtilConstants.BYTE; |
47 | import static org.onosproject.yangutils.utils.UtilConstants.BYTE_WRAPPER; | 39 | import static org.onosproject.yangutils.utils.UtilConstants.BYTE_WRAPPER; |
48 | -import static org.onosproject.yangutils.utils.UtilConstants.EMPTY_STRING; | ||
49 | -import static org.onosproject.yangutils.utils.UtilConstants.FROM_STRING_METHOD_NAME; | ||
50 | import static org.onosproject.yangutils.utils.UtilConstants.INT; | 40 | import static org.onosproject.yangutils.utils.UtilConstants.INT; |
51 | import static org.onosproject.yangutils.utils.UtilConstants.INTEGER_WRAPPER; | 41 | import static org.onosproject.yangutils.utils.UtilConstants.INTEGER_WRAPPER; |
52 | import static org.onosproject.yangutils.utils.UtilConstants.JAVA_LANG; | 42 | import static org.onosproject.yangutils.utils.UtilConstants.JAVA_LANG; |
53 | import static org.onosproject.yangutils.utils.UtilConstants.JAVA_MATH; | 43 | import static org.onosproject.yangutils.utils.UtilConstants.JAVA_MATH; |
54 | import static org.onosproject.yangutils.utils.UtilConstants.LONG; | 44 | import static org.onosproject.yangutils.utils.UtilConstants.LONG; |
55 | import static org.onosproject.yangutils.utils.UtilConstants.LONG_WRAPPER; | 45 | import static org.onosproject.yangutils.utils.UtilConstants.LONG_WRAPPER; |
56 | -import static org.onosproject.yangutils.utils.UtilConstants.NEW; | ||
57 | -import static org.onosproject.yangutils.utils.UtilConstants.PARSE_BOOLEAN; | ||
58 | -import static org.onosproject.yangutils.utils.UtilConstants.PARSE_BYTE; | ||
59 | -import static org.onosproject.yangutils.utils.UtilConstants.PARSE_INT; | ||
60 | -import static org.onosproject.yangutils.utils.UtilConstants.PARSE_LONG; | ||
61 | -import static org.onosproject.yangutils.utils.UtilConstants.PARSE_SHORT; | ||
62 | import static org.onosproject.yangutils.utils.UtilConstants.PERIOD; | 46 | import static org.onosproject.yangutils.utils.UtilConstants.PERIOD; |
63 | import static org.onosproject.yangutils.utils.UtilConstants.SHORT; | 47 | import static org.onosproject.yangutils.utils.UtilConstants.SHORT; |
64 | import static org.onosproject.yangutils.utils.UtilConstants.SHORT_WRAPPER; | 48 | import static org.onosproject.yangutils.utils.UtilConstants.SHORT_WRAPPER; |
65 | -import static org.onosproject.yangutils.utils.UtilConstants.SPACE; | ||
66 | import static org.onosproject.yangutils.utils.UtilConstants.STRING_DATA_TYPE; | 49 | import static org.onosproject.yangutils.utils.UtilConstants.STRING_DATA_TYPE; |
67 | import static org.onosproject.yangutils.utils.UtilConstants.YANG_BINARY_CLASS; | 50 | import static org.onosproject.yangutils.utils.UtilConstants.YANG_BINARY_CLASS; |
68 | import static org.onosproject.yangutils.utils.UtilConstants.YANG_BITS_CLASS; | 51 | import static org.onosproject.yangutils.utils.UtilConstants.YANG_BITS_CLASS; |
69 | import static org.onosproject.yangutils.utils.UtilConstants.YANG_DECIMAL64_CLASS; | 52 | import static org.onosproject.yangutils.utils.UtilConstants.YANG_DECIMAL64_CLASS; |
70 | import static org.onosproject.yangutils.utils.UtilConstants.YANG_TYPES_PKG; | 53 | import static org.onosproject.yangutils.utils.UtilConstants.YANG_TYPES_PKG; |
54 | +import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getCamelCase; | ||
55 | +import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getCapitalCase; | ||
56 | +import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getPackageDirPathFromJavaJPackage; | ||
71 | 57 | ||
72 | /** | 58 | /** |
73 | * Represents java data types info corresponding to YANG type. | 59 | * Represents java data types info corresponding to YANG type. |
... | @@ -121,51 +107,6 @@ public final class AttributesJavaDataType { | ... | @@ -121,51 +107,6 @@ public final class AttributesJavaDataType { |
121 | } | 107 | } |
122 | 108 | ||
123 | /** | 109 | /** |
124 | - * Returns from string method parsed string. | ||
125 | - * | ||
126 | - * @param targetDataType target data type | ||
127 | - * @param yangType YANG type | ||
128 | - * @return parsed string | ||
129 | - */ | ||
130 | - public static String getParseFromStringMethod(String targetDataType, YangType<?> yangType) { | ||
131 | - | ||
132 | - YangDataTypes type = yangType.getDataType(); | ||
133 | - | ||
134 | - switch (type) { | ||
135 | - case INT8: | ||
136 | - return BYTE_WRAPPER + PERIOD + PARSE_BYTE; | ||
137 | - case INT16: | ||
138 | - return SHORT_WRAPPER + PERIOD + PARSE_SHORT; | ||
139 | - case INT32: | ||
140 | - return INTEGER_WRAPPER + PERIOD + PARSE_INT; | ||
141 | - case INT64: | ||
142 | - return LONG_WRAPPER + PERIOD + PARSE_LONG; | ||
143 | - case UINT8: | ||
144 | - return SHORT_WRAPPER + PERIOD + PARSE_SHORT; | ||
145 | - case UINT16: | ||
146 | - return INTEGER_WRAPPER + PERIOD + PARSE_INT; | ||
147 | - case UINT32: | ||
148 | - return LONG_WRAPPER + PERIOD + PARSE_LONG; | ||
149 | - case UINT64: | ||
150 | - return NEW + SPACE + BIG_INTEGER; | ||
151 | - case STRING: | ||
152 | - return EMPTY_STRING; | ||
153 | - case EMPTY: | ||
154 | - case BOOLEAN: | ||
155 | - return BOOLEAN_WRAPPER + PERIOD + PARSE_BOOLEAN; | ||
156 | - case DECIMAL64: | ||
157 | - case BITS: | ||
158 | - case BINARY: | ||
159 | - case UNION: | ||
160 | - case ENUMERATION: | ||
161 | - case DERIVED: | ||
162 | - return targetDataType + PERIOD + FROM_STRING_METHOD_NAME; | ||
163 | - default: | ||
164 | - throw new TranslatorException("given data type is not supported."); | ||
165 | - } | ||
166 | - } | ||
167 | - | ||
168 | - /** | ||
169 | * Returns java import class. | 110 | * Returns java import class. |
170 | * | 111 | * |
171 | * @param yangType YANG type | 112 | * @param yangType YANG type |
... | @@ -174,7 +115,7 @@ public final class AttributesJavaDataType { | ... | @@ -174,7 +115,7 @@ public final class AttributesJavaDataType { |
174 | * @return java import class | 115 | * @return java import class |
175 | */ | 116 | */ |
176 | public static String getJavaImportClass(YangType<?> yangType, boolean isListAttr, | 117 | public static String getJavaImportClass(YangType<?> yangType, boolean isListAttr, |
177 | - YangToJavaNamingConflictUtil pluginConfig) { | 118 | + YangToJavaNamingConflictUtil pluginConfig) { |
178 | 119 | ||
179 | YangDataTypes type = yangType.getDataType(); | 120 | YangDataTypes type = yangType.getDataType(); |
180 | 121 | ||
... | @@ -279,7 +220,7 @@ public final class AttributesJavaDataType { | ... | @@ -279,7 +220,7 @@ public final class AttributesJavaDataType { |
279 | * @return java import package | 220 | * @return java import package |
280 | */ | 221 | */ |
281 | public static String getJavaImportPackage(YangType<?> yangType, boolean isListAttr, | 222 | public static String getJavaImportPackage(YangType<?> yangType, boolean isListAttr, |
282 | - YangToJavaNamingConflictUtil conflictResolver) { | 223 | + YangToJavaNamingConflictUtil conflictResolver) { |
283 | 224 | ||
284 | YangDataTypes type = yangType.getDataType(); | 225 | YangDataTypes type = yangType.getDataType(); |
285 | 226 | ||
... | @@ -425,7 +366,7 @@ public final class AttributesJavaDataType { | ... | @@ -425,7 +366,7 @@ public final class AttributesJavaDataType { |
425 | * @return java package from parent node | 366 | * @return java package from parent node |
426 | */ | 367 | */ |
427 | private static String getPackageFromParent(YangNode parent, | 368 | private static String getPackageFromParent(YangNode parent, |
428 | - YangToJavaNamingConflictUtil conflictResolver) { | 369 | + YangToJavaNamingConflictUtil conflictResolver) { |
429 | if (!(parent instanceof JavaFileInfoContainer)) { | 370 | if (!(parent instanceof JavaFileInfoContainer)) { |
430 | throw new TranslatorException("invalid child node is being processed."); | 371 | throw new TranslatorException("invalid child node is being processed."); |
431 | } | 372 | } |
... | @@ -444,7 +385,7 @@ public final class AttributesJavaDataType { | ... | @@ -444,7 +385,7 @@ public final class AttributesJavaDataType { |
444 | * @param conflictResolver yang plugin config | 385 | * @param conflictResolver yang plugin config |
445 | */ | 386 | */ |
446 | public static void updateJavaFileInfo(YangNode yangNode, | 387 | public static void updateJavaFileInfo(YangNode yangNode, |
447 | - YangToJavaNamingConflictUtil conflictResolver) { | 388 | + YangToJavaNamingConflictUtil conflictResolver) { |
448 | Stack<YangNode> nodesToUpdatePackage = new Stack<YangNode>(); | 389 | Stack<YangNode> nodesToUpdatePackage = new Stack<YangNode>(); |
449 | 390 | ||
450 | /* | 391 | /* | ... | ... |
... | @@ -17,7 +17,7 @@ package org.onosproject.yangutils.translator.tojava.javamodel; | ... | @@ -17,7 +17,7 @@ package org.onosproject.yangutils.translator.tojava.javamodel; |
17 | 17 | ||
18 | import org.onosproject.yangutils.datamodel.YangType; | 18 | import org.onosproject.yangutils.datamodel.YangType; |
19 | import org.onosproject.yangutils.translator.tojava.JavaQualifiedTypeInfoContainer; | 19 | import org.onosproject.yangutils.translator.tojava.JavaQualifiedTypeInfoContainer; |
20 | -import org.onosproject.yangutils.translator.tojava.utils.YangToJavaNamingConflictUtil; | 20 | +import org.onosproject.yangutils.utils.io.impl.YangToJavaNamingConflictUtil; |
21 | 21 | ||
22 | /** | 22 | /** |
23 | * Represent java based identification of the YANG leaves. | 23 | * Represent java based identification of the YANG leaves. | ... | ... |
... | @@ -16,7 +16,7 @@ | ... | @@ -16,7 +16,7 @@ |
16 | package org.onosproject.yangutils.translator.tojava.javamodel; | 16 | package org.onosproject.yangutils.translator.tojava.javamodel; |
17 | 17 | ||
18 | import org.onosproject.yangutils.translator.tojava.JavaQualifiedTypeInfoContainer; | 18 | import org.onosproject.yangutils.translator.tojava.JavaQualifiedTypeInfoContainer; |
19 | -import org.onosproject.yangutils.translator.tojava.utils.YangToJavaNamingConflictUtil; | 19 | +import org.onosproject.yangutils.utils.io.impl.YangToJavaNamingConflictUtil; |
20 | 20 | ||
21 | /** | 21 | /** |
22 | * Represent java based identification of the YANG leaves. | 22 | * Represent java based identification of the YANG leaves. | ... | ... |
... | @@ -20,12 +20,13 @@ import java.io.IOException; | ... | @@ -20,12 +20,13 @@ import java.io.IOException; |
20 | import org.onosproject.yangutils.datamodel.YangAugment; | 20 | import org.onosproject.yangutils.datamodel.YangAugment; |
21 | import org.onosproject.yangutils.translator.exception.TranslatorException; | 21 | import org.onosproject.yangutils.translator.exception.TranslatorException; |
22 | import org.onosproject.yangutils.translator.tojava.JavaCodeGenerator; | 22 | import org.onosproject.yangutils.translator.tojava.JavaCodeGenerator; |
23 | +import org.onosproject.yangutils.translator.tojava.JavaCodeGeneratorInfo; | ||
23 | import org.onosproject.yangutils.translator.tojava.JavaFileInfo; | 24 | import org.onosproject.yangutils.translator.tojava.JavaFileInfo; |
24 | import org.onosproject.yangutils.translator.tojava.TempJavaCodeFragmentFiles; | 25 | import org.onosproject.yangutils.translator.tojava.TempJavaCodeFragmentFiles; |
25 | -import org.onosproject.yangutils.translator.tojava.utils.YangPluginConfig; | 26 | +import org.onosproject.yangutils.utils.io.impl.YangPluginConfig; |
26 | 27 | ||
27 | import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_INTERFACE_WITH_BUILDER; | 28 | import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_INTERFACE_WITH_BUILDER; |
28 | -import static org.onosproject.yangutils.translator.tojava.utils.YangJavaModelUtils.generateCodeOfAugmentableNode; | 29 | +import static org.onosproject.yangutils.translator.tojava.javamodel.YangJavaModelUtils.generateCodeOfAugmentableNode; |
29 | 30 | ||
30 | /** | 31 | /** |
31 | * Represents augment information extended to support java code generation. | 32 | * Represents augment information extended to support java code generation. | ... | ... |
... | @@ -20,12 +20,13 @@ import java.io.IOException; | ... | @@ -20,12 +20,13 @@ import java.io.IOException; |
20 | import org.onosproject.yangutils.datamodel.YangCase; | 20 | import org.onosproject.yangutils.datamodel.YangCase; |
21 | import org.onosproject.yangutils.translator.exception.TranslatorException; | 21 | import org.onosproject.yangutils.translator.exception.TranslatorException; |
22 | import org.onosproject.yangutils.translator.tojava.JavaCodeGenerator; | 22 | import org.onosproject.yangutils.translator.tojava.JavaCodeGenerator; |
23 | +import org.onosproject.yangutils.translator.tojava.JavaCodeGeneratorInfo; | ||
23 | import org.onosproject.yangutils.translator.tojava.JavaFileInfo; | 24 | import org.onosproject.yangutils.translator.tojava.JavaFileInfo; |
24 | import org.onosproject.yangutils.translator.tojava.TempJavaCodeFragmentFiles; | 25 | import org.onosproject.yangutils.translator.tojava.TempJavaCodeFragmentFiles; |
25 | -import org.onosproject.yangutils.translator.tojava.utils.YangPluginConfig; | 26 | +import org.onosproject.yangutils.utils.io.impl.YangPluginConfig; |
26 | 27 | ||
27 | import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_INTERFACE_WITH_BUILDER; | 28 | import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_INTERFACE_WITH_BUILDER; |
28 | -import static org.onosproject.yangutils.translator.tojava.utils.YangJavaModelUtils.generateCodeOfAugmentableNode; | 29 | +import static org.onosproject.yangutils.translator.tojava.javamodel.YangJavaModelUtils.generateCodeOfAugmentableNode; |
29 | 30 | ||
30 | /** | 31 | /** |
31 | * Represents case information extended to support java code generation. | 32 | * Represents case information extended to support java code generation. | ... | ... |
... | @@ -20,12 +20,13 @@ import java.io.IOException; | ... | @@ -20,12 +20,13 @@ import java.io.IOException; |
20 | import org.onosproject.yangutils.datamodel.YangChoice; | 20 | import org.onosproject.yangutils.datamodel.YangChoice; |
21 | import org.onosproject.yangutils.translator.exception.TranslatorException; | 21 | import org.onosproject.yangutils.translator.exception.TranslatorException; |
22 | import org.onosproject.yangutils.translator.tojava.JavaCodeGenerator; | 22 | import org.onosproject.yangutils.translator.tojava.JavaCodeGenerator; |
23 | +import org.onosproject.yangutils.translator.tojava.JavaCodeGeneratorInfo; | ||
23 | import org.onosproject.yangutils.translator.tojava.JavaFileInfo; | 24 | import org.onosproject.yangutils.translator.tojava.JavaFileInfo; |
24 | import org.onosproject.yangutils.translator.tojava.TempJavaCodeFragmentFiles; | 25 | import org.onosproject.yangutils.translator.tojava.TempJavaCodeFragmentFiles; |
25 | -import org.onosproject.yangutils.translator.tojava.utils.YangPluginConfig; | 26 | +import org.onosproject.yangutils.utils.io.impl.YangPluginConfig; |
26 | 27 | ||
27 | import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.INTERFACE_MASK; | 28 | import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.INTERFACE_MASK; |
28 | -import static org.onosproject.yangutils.translator.tojava.utils.YangJavaModelUtils.generateCodeAndUpdateInParent; | 29 | +import static org.onosproject.yangutils.translator.tojava.javamodel.YangJavaModelUtils.generateCodeAndUpdateInParent; |
29 | 30 | ||
30 | /** | 31 | /** |
31 | * Represents choice information extended to support java code generation. | 32 | * Represents choice information extended to support java code generation. | ... | ... |
... | @@ -20,12 +20,13 @@ import java.io.IOException; | ... | @@ -20,12 +20,13 @@ import java.io.IOException; |
20 | import org.onosproject.yangutils.datamodel.YangContainer; | 20 | import org.onosproject.yangutils.datamodel.YangContainer; |
21 | import org.onosproject.yangutils.translator.exception.TranslatorException; | 21 | import org.onosproject.yangutils.translator.exception.TranslatorException; |
22 | import org.onosproject.yangutils.translator.tojava.JavaCodeGenerator; | 22 | import org.onosproject.yangutils.translator.tojava.JavaCodeGenerator; |
23 | +import org.onosproject.yangutils.translator.tojava.JavaCodeGeneratorInfo; | ||
23 | import org.onosproject.yangutils.translator.tojava.JavaFileInfo; | 24 | import org.onosproject.yangutils.translator.tojava.JavaFileInfo; |
24 | import org.onosproject.yangutils.translator.tojava.TempJavaCodeFragmentFiles; | 25 | import org.onosproject.yangutils.translator.tojava.TempJavaCodeFragmentFiles; |
25 | -import org.onosproject.yangutils.translator.tojava.utils.YangPluginConfig; | 26 | +import org.onosproject.yangutils.utils.io.impl.YangPluginConfig; |
26 | 27 | ||
27 | import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_INTERFACE_WITH_BUILDER; | 28 | import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_INTERFACE_WITH_BUILDER; |
28 | -import static org.onosproject.yangutils.translator.tojava.utils.YangJavaModelUtils.generateCodeAndUpdateInParent; | 29 | +import static org.onosproject.yangutils.translator.tojava.javamodel.YangJavaModelUtils.generateCodeAndUpdateInParent; |
29 | 30 | ||
30 | /** | 31 | /** |
31 | * Represents container information extended to support java code generation. | 32 | * Represents container information extended to support java code generation. | ... | ... |
... | @@ -21,12 +21,13 @@ import java.io.IOException; | ... | @@ -21,12 +21,13 @@ import java.io.IOException; |
21 | import org.onosproject.yangutils.datamodel.YangEnumeration; | 21 | import org.onosproject.yangutils.datamodel.YangEnumeration; |
22 | import org.onosproject.yangutils.translator.exception.TranslatorException; | 22 | import org.onosproject.yangutils.translator.exception.TranslatorException; |
23 | import org.onosproject.yangutils.translator.tojava.JavaCodeGenerator; | 23 | import org.onosproject.yangutils.translator.tojava.JavaCodeGenerator; |
24 | +import org.onosproject.yangutils.translator.tojava.JavaCodeGeneratorInfo; | ||
24 | import org.onosproject.yangutils.translator.tojava.JavaFileInfo; | 25 | import org.onosproject.yangutils.translator.tojava.JavaFileInfo; |
25 | import org.onosproject.yangutils.translator.tojava.TempJavaCodeFragmentFiles; | 26 | import org.onosproject.yangutils.translator.tojava.TempJavaCodeFragmentFiles; |
26 | -import org.onosproject.yangutils.translator.tojava.utils.YangPluginConfig; | 27 | +import org.onosproject.yangutils.utils.io.impl.YangPluginConfig; |
27 | 28 | ||
28 | import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_ENUM_CLASS; | 29 | import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_ENUM_CLASS; |
29 | -import static org.onosproject.yangutils.translator.tojava.utils.YangJavaModelUtils.generateCodeOfNode; | 30 | +import static org.onosproject.yangutils.translator.tojava.javamodel.YangJavaModelUtils.generateCodeOfNode; |
30 | 31 | ||
31 | /** | 32 | /** |
32 | * Represents YANG java enumeration information extended to support java code generation. | 33 | * Represents YANG java enumeration information extended to support java code generation. | ... | ... |
... | @@ -20,11 +20,12 @@ import java.io.IOException; | ... | @@ -20,11 +20,12 @@ import java.io.IOException; |
20 | import org.onosproject.yangutils.datamodel.YangGrouping; | 20 | import org.onosproject.yangutils.datamodel.YangGrouping; |
21 | import org.onosproject.yangutils.translator.exception.TranslatorException; | 21 | import org.onosproject.yangutils.translator.exception.TranslatorException; |
22 | import org.onosproject.yangutils.translator.tojava.JavaCodeGenerator; | 22 | import org.onosproject.yangutils.translator.tojava.JavaCodeGenerator; |
23 | +import org.onosproject.yangutils.translator.tojava.JavaCodeGeneratorInfo; | ||
23 | import org.onosproject.yangutils.translator.tojava.JavaFileInfo; | 24 | import org.onosproject.yangutils.translator.tojava.JavaFileInfo; |
24 | import org.onosproject.yangutils.translator.tojava.TempJavaCodeFragmentFiles; | 25 | import org.onosproject.yangutils.translator.tojava.TempJavaCodeFragmentFiles; |
25 | -import org.onosproject.yangutils.translator.tojava.utils.YangPluginConfig; | 26 | +import org.onosproject.yangutils.utils.io.impl.YangPluginConfig; |
26 | 27 | ||
27 | -import static org.onosproject.yangutils.translator.tojava.utils.YangJavaModelUtils.updatePackageInfo; | 28 | +import static org.onosproject.yangutils.translator.tojava.javamodel.YangJavaModelUtils.updatePackageInfo; |
28 | 29 | ||
29 | /** | 30 | /** |
30 | * Represents grouping information extended to support java code generation. | 31 | * Represents grouping information extended to support java code generation. | ... | ... |
... | @@ -21,12 +21,13 @@ import java.io.IOException; | ... | @@ -21,12 +21,13 @@ import java.io.IOException; |
21 | import org.onosproject.yangutils.datamodel.YangInput; | 21 | import org.onosproject.yangutils.datamodel.YangInput; |
22 | import org.onosproject.yangutils.translator.exception.TranslatorException; | 22 | import org.onosproject.yangutils.translator.exception.TranslatorException; |
23 | import org.onosproject.yangutils.translator.tojava.JavaCodeGenerator; | 23 | import org.onosproject.yangutils.translator.tojava.JavaCodeGenerator; |
24 | +import org.onosproject.yangutils.translator.tojava.JavaCodeGeneratorInfo; | ||
24 | import org.onosproject.yangutils.translator.tojava.JavaFileInfo; | 25 | import org.onosproject.yangutils.translator.tojava.JavaFileInfo; |
25 | import org.onosproject.yangutils.translator.tojava.TempJavaCodeFragmentFiles; | 26 | import org.onosproject.yangutils.translator.tojava.TempJavaCodeFragmentFiles; |
26 | -import org.onosproject.yangutils.translator.tojava.utils.YangPluginConfig; | 27 | +import org.onosproject.yangutils.utils.io.impl.YangPluginConfig; |
27 | 28 | ||
28 | import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_INTERFACE_WITH_BUILDER; | 29 | import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_INTERFACE_WITH_BUILDER; |
29 | -import static org.onosproject.yangutils.translator.tojava.utils.YangJavaModelUtils.generateCodeOfAugmentableNode; | 30 | +import static org.onosproject.yangutils.translator.tojava.javamodel.YangJavaModelUtils.generateCodeOfAugmentableNode; |
30 | 31 | ||
31 | /** | 32 | /** |
32 | * Represents input information extended to support java code generation. | 33 | * Represents input information extended to support java code generation. | ... | ... |
... | @@ -17,10 +17,10 @@ package org.onosproject.yangutils.translator.tojava.javamodel; | ... | @@ -17,10 +17,10 @@ package org.onosproject.yangutils.translator.tojava.javamodel; |
17 | 17 | ||
18 | import org.onosproject.yangutils.datamodel.YangLeaf; | 18 | import org.onosproject.yangutils.datamodel.YangLeaf; |
19 | import org.onosproject.yangutils.translator.tojava.JavaQualifiedTypeInfo; | 19 | import org.onosproject.yangutils.translator.tojava.JavaQualifiedTypeInfo; |
20 | -import org.onosproject.yangutils.translator.tojava.utils.YangToJavaNamingConflictUtil; | 20 | +import org.onosproject.yangutils.utils.io.impl.YangToJavaNamingConflictUtil; |
21 | 21 | ||
22 | import static org.onosproject.yangutils.translator.tojava.JavaQualifiedTypeInfo.updateLeavesJavaQualifiedInfo; | 22 | import static org.onosproject.yangutils.translator.tojava.JavaQualifiedTypeInfo.updateLeavesJavaQualifiedInfo; |
23 | -import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getCamelCase; | 23 | +import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getCamelCase; |
24 | 24 | ||
25 | /** | 25 | /** |
26 | * Represents java information corresponding to the YANG leaf. | 26 | * Represents java information corresponding to the YANG leaf. | ... | ... |
... | @@ -17,10 +17,10 @@ package org.onosproject.yangutils.translator.tojava.javamodel; | ... | @@ -17,10 +17,10 @@ package org.onosproject.yangutils.translator.tojava.javamodel; |
17 | 17 | ||
18 | import org.onosproject.yangutils.datamodel.YangLeafList; | 18 | import org.onosproject.yangutils.datamodel.YangLeafList; |
19 | import org.onosproject.yangutils.translator.tojava.JavaQualifiedTypeInfo; | 19 | import org.onosproject.yangutils.translator.tojava.JavaQualifiedTypeInfo; |
20 | -import org.onosproject.yangutils.translator.tojava.utils.YangToJavaNamingConflictUtil; | 20 | +import org.onosproject.yangutils.utils.io.impl.YangToJavaNamingConflictUtil; |
21 | 21 | ||
22 | import static org.onosproject.yangutils.translator.tojava.JavaQualifiedTypeInfo.updateLeavesJavaQualifiedInfo; | 22 | import static org.onosproject.yangutils.translator.tojava.JavaQualifiedTypeInfo.updateLeavesJavaQualifiedInfo; |
23 | -import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getCamelCase; | 23 | +import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getCamelCase; |
24 | 24 | ||
25 | /** | 25 | /** |
26 | * Represents java information corresponding to the YANG leaf-list. | 26 | * Represents java information corresponding to the YANG leaf-list. | ... | ... |
... | @@ -20,12 +20,13 @@ import java.io.IOException; | ... | @@ -20,12 +20,13 @@ import java.io.IOException; |
20 | import org.onosproject.yangutils.datamodel.YangList; | 20 | import org.onosproject.yangutils.datamodel.YangList; |
21 | import org.onosproject.yangutils.translator.exception.TranslatorException; | 21 | import org.onosproject.yangutils.translator.exception.TranslatorException; |
22 | import org.onosproject.yangutils.translator.tojava.JavaCodeGenerator; | 22 | import org.onosproject.yangutils.translator.tojava.JavaCodeGenerator; |
23 | +import org.onosproject.yangutils.translator.tojava.JavaCodeGeneratorInfo; | ||
23 | import org.onosproject.yangutils.translator.tojava.JavaFileInfo; | 24 | import org.onosproject.yangutils.translator.tojava.JavaFileInfo; |
24 | import org.onosproject.yangutils.translator.tojava.TempJavaCodeFragmentFiles; | 25 | import org.onosproject.yangutils.translator.tojava.TempJavaCodeFragmentFiles; |
25 | -import org.onosproject.yangutils.translator.tojava.utils.YangPluginConfig; | 26 | +import org.onosproject.yangutils.utils.io.impl.YangPluginConfig; |
26 | 27 | ||
27 | import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_INTERFACE_WITH_BUILDER; | 28 | import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_INTERFACE_WITH_BUILDER; |
28 | -import static org.onosproject.yangutils.translator.tojava.utils.YangJavaModelUtils.generateCodeAndUpdateInParent; | 29 | +import static org.onosproject.yangutils.translator.tojava.javamodel.YangJavaModelUtils.generateCodeAndUpdateInParent; |
29 | 30 | ||
30 | /** | 31 | /** |
31 | * Represents YANG list information extended to support java code generation. | 32 | * Represents YANG list information extended to support java code generation. | ... | ... |
... | @@ -14,24 +14,23 @@ | ... | @@ -14,24 +14,23 @@ |
14 | * limitations under the License. | 14 | * limitations under the License. |
15 | */ | 15 | */ |
16 | 16 | ||
17 | -package org.onosproject.yangutils.translator.tojava.utils; | 17 | +package org.onosproject.yangutils.translator.tojava.javamodel; |
18 | 18 | ||
19 | import java.io.IOException; | 19 | import java.io.IOException; |
20 | - | ||
21 | import org.onosproject.yangutils.datamodel.RpcNotificationContainer; | 20 | import org.onosproject.yangutils.datamodel.RpcNotificationContainer; |
22 | import org.onosproject.yangutils.datamodel.YangCase; | 21 | import org.onosproject.yangutils.datamodel.YangCase; |
23 | import org.onosproject.yangutils.datamodel.YangChoice; | 22 | import org.onosproject.yangutils.datamodel.YangChoice; |
24 | import org.onosproject.yangutils.datamodel.YangLeavesHolder; | 23 | import org.onosproject.yangutils.datamodel.YangLeavesHolder; |
25 | import org.onosproject.yangutils.datamodel.YangNode; | 24 | import org.onosproject.yangutils.datamodel.YangNode; |
26 | import org.onosproject.yangutils.datamodel.YangTypeHolder; | 25 | import org.onosproject.yangutils.datamodel.YangTypeHolder; |
26 | +import org.onosproject.yangutils.datamodel.utils.DataModelUtils; | ||
27 | import org.onosproject.yangutils.translator.exception.TranslatorException; | 27 | import org.onosproject.yangutils.translator.exception.TranslatorException; |
28 | +import org.onosproject.yangutils.translator.tojava.JavaCodeGeneratorInfo; | ||
29 | +import org.onosproject.yangutils.translator.tojava.JavaFileInfo; | ||
28 | import org.onosproject.yangutils.translator.tojava.JavaFileInfoContainer; | 30 | import org.onosproject.yangutils.translator.tojava.JavaFileInfoContainer; |
29 | import org.onosproject.yangutils.translator.tojava.JavaQualifiedTypeInfo; | 31 | import org.onosproject.yangutils.translator.tojava.JavaQualifiedTypeInfo; |
30 | import org.onosproject.yangutils.translator.tojava.TempJavaCodeFragmentFiles; | 32 | import org.onosproject.yangutils.translator.tojava.TempJavaCodeFragmentFiles; |
31 | -import org.onosproject.yangutils.translator.tojava.javamodel.JavaCodeGeneratorInfo; | 33 | +import org.onosproject.yangutils.utils.io.impl.YangPluginConfig; |
32 | -import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaEnumeration; | ||
33 | -import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaModule; | ||
34 | -import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaSubModule; | ||
35 | 34 | ||
36 | import static org.onosproject.yangutils.datamodel.utils.DataModelUtils.isRpcChildNodePresent; | 35 | import static org.onosproject.yangutils.datamodel.utils.DataModelUtils.isRpcChildNodePresent; |
37 | import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_EVENT_CLASS; | 36 | import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_EVENT_CLASS; |
... | @@ -39,10 +38,10 @@ import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType. | ... | @@ -39,10 +38,10 @@ import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType. |
39 | import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_EVENT_SUBJECT_CLASS; | 38 | import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_EVENT_SUBJECT_CLASS; |
40 | import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_SERVICE_AND_MANAGER; | 39 | import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_SERVICE_AND_MANAGER; |
41 | import static org.onosproject.yangutils.translator.tojava.TempJavaFragmentFiles.addCurNodeInfoInParentTempFile; | 40 | import static org.onosproject.yangutils.translator.tojava.TempJavaFragmentFiles.addCurNodeInfoInParentTempFile; |
42 | -import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getCamelCase; | 41 | +import static org.onosproject.yangutils.utils.UtilConstants.PERIOD; |
43 | -import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getCapitalCase; | 42 | +import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getCamelCase; |
44 | -import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getCurNodePackage; | 43 | +import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getCapitalCase; |
45 | -import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getPackageDirPathFromJavaJPackage; | 44 | +import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getPackageDirPathFromJavaJPackage; |
46 | 45 | ||
47 | /** | 46 | /** |
48 | * Represents utility class for YANG java model. | 47 | * Represents utility class for YANG java model. |
... | @@ -316,7 +315,7 @@ public final class YangJavaModelUtils { | ... | @@ -316,7 +315,7 @@ public final class YangJavaModelUtils { |
316 | * @throws IOException IO operations fails | 315 | * @throws IOException IO operations fails |
317 | */ | 316 | */ |
318 | public static void generateCodeOfRootNode(JavaCodeGeneratorInfo javaCodeGeneratorInfo, | 317 | public static void generateCodeOfRootNode(JavaCodeGeneratorInfo javaCodeGeneratorInfo, |
319 | - YangPluginConfig yangPluginConfig, String rootPkg) | 318 | + YangPluginConfig yangPluginConfig, String rootPkg) |
320 | throws IOException { | 319 | throws IOException { |
321 | if (!(javaCodeGeneratorInfo instanceof YangNode)) { | 320 | if (!(javaCodeGeneratorInfo instanceof YangNode)) { |
322 | // TODO:throw exception | 321 | // TODO:throw exception |
... | @@ -349,4 +348,26 @@ public final class YangJavaModelUtils { | ... | @@ -349,4 +348,26 @@ public final class YangJavaModelUtils { |
349 | javaCodeGeneratorInfo.getJavaFileInfo().addGeneratedFileTypes(GENERATE_EVENT_LISTENER_INTERFACE); | 348 | javaCodeGeneratorInfo.getJavaFileInfo().addGeneratedFileTypes(GENERATE_EVENT_LISTENER_INTERFACE); |
350 | } | 349 | } |
351 | 350 | ||
351 | + /** | ||
352 | + * Returns the node package string. | ||
353 | + * | ||
354 | + * @param curNode current java node whose package string needs to be set | ||
355 | + * @return returns the root package string | ||
356 | + */ | ||
357 | + public static String getCurNodePackage(YangNode curNode) { | ||
358 | + | ||
359 | + String pkg; | ||
360 | + if (!(curNode instanceof JavaFileInfoContainer) | ||
361 | + || curNode.getParent() == null) { | ||
362 | + throw new TranslatorException("missing parent node to get current node's package"); | ||
363 | + } | ||
364 | + | ||
365 | + YangNode parentNode = DataModelUtils.getParentNodeInGenCode(curNode); | ||
366 | + if (!(parentNode instanceof JavaFileInfoContainer)) { | ||
367 | + throw new TranslatorException("missing parent java node to get current node's package"); | ||
368 | + } | ||
369 | + JavaFileInfo parentJavaFileHandle = ((JavaFileInfoContainer) parentNode).getJavaFileInfo(); | ||
370 | + pkg = parentJavaFileHandle.getPackage() + PERIOD + parentJavaFileHandle.getJavaName(); | ||
371 | + return pkg.toLowerCase(); | ||
372 | + } | ||
352 | } | 373 | } | ... | ... |
... | @@ -24,16 +24,17 @@ import org.onosproject.yangutils.datamodel.YangNode; | ... | @@ -24,16 +24,17 @@ import org.onosproject.yangutils.datamodel.YangNode; |
24 | import org.onosproject.yangutils.datamodel.YangNotification; | 24 | import org.onosproject.yangutils.datamodel.YangNotification; |
25 | import org.onosproject.yangutils.translator.exception.TranslatorException; | 25 | import org.onosproject.yangutils.translator.exception.TranslatorException; |
26 | import org.onosproject.yangutils.translator.tojava.JavaCodeGenerator; | 26 | import org.onosproject.yangutils.translator.tojava.JavaCodeGenerator; |
27 | +import org.onosproject.yangutils.translator.tojava.JavaCodeGeneratorInfo; | ||
27 | import org.onosproject.yangutils.translator.tojava.JavaFileInfo; | 28 | import org.onosproject.yangutils.translator.tojava.JavaFileInfo; |
28 | import org.onosproject.yangutils.translator.tojava.TempJavaCodeFragmentFiles; | 29 | import org.onosproject.yangutils.translator.tojava.TempJavaCodeFragmentFiles; |
29 | -import org.onosproject.yangutils.translator.tojava.utils.YangPluginConfig; | 30 | +import org.onosproject.yangutils.utils.io.impl.YangPluginConfig; |
30 | 31 | ||
31 | import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_EVENT_CLASS; | 32 | import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_EVENT_CLASS; |
32 | import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_EVENT_LISTENER_INTERFACE; | 33 | import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_EVENT_LISTENER_INTERFACE; |
33 | import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_EVENT_SUBJECT_CLASS; | 34 | import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_EVENT_SUBJECT_CLASS; |
34 | import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_SERVICE_AND_MANAGER; | 35 | import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_SERVICE_AND_MANAGER; |
35 | import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getRootPackage; | 36 | import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getRootPackage; |
36 | -import static org.onosproject.yangutils.translator.tojava.utils.YangJavaModelUtils.generateCodeOfRootNode; | 37 | +import static org.onosproject.yangutils.translator.tojava.javamodel.YangJavaModelUtils.generateCodeOfRootNode; |
37 | import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.searchAndDeleteTempDir; | 38 | import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.searchAndDeleteTempDir; |
38 | 39 | ||
39 | /** | 40 | /** | ... | ... |
... | @@ -22,17 +22,18 @@ import org.onosproject.yangutils.datamodel.YangNode; | ... | @@ -22,17 +22,18 @@ import org.onosproject.yangutils.datamodel.YangNode; |
22 | import org.onosproject.yangutils.datamodel.YangNotification; | 22 | import org.onosproject.yangutils.datamodel.YangNotification; |
23 | import org.onosproject.yangutils.translator.exception.TranslatorException; | 23 | import org.onosproject.yangutils.translator.exception.TranslatorException; |
24 | import org.onosproject.yangutils.translator.tojava.JavaCodeGenerator; | 24 | import org.onosproject.yangutils.translator.tojava.JavaCodeGenerator; |
25 | +import org.onosproject.yangutils.translator.tojava.JavaCodeGeneratorInfo; | ||
25 | import org.onosproject.yangutils.translator.tojava.JavaFileInfo; | 26 | import org.onosproject.yangutils.translator.tojava.JavaFileInfo; |
26 | import org.onosproject.yangutils.translator.tojava.JavaFileInfoContainer; | 27 | import org.onosproject.yangutils.translator.tojava.JavaFileInfoContainer; |
27 | import org.onosproject.yangutils.translator.tojava.JavaQualifiedTypeInfo; | 28 | import org.onosproject.yangutils.translator.tojava.JavaQualifiedTypeInfo; |
28 | import org.onosproject.yangutils.translator.tojava.TempJavaCodeFragmentFiles; | 29 | import org.onosproject.yangutils.translator.tojava.TempJavaCodeFragmentFiles; |
29 | import org.onosproject.yangutils.translator.tojava.TempJavaCodeFragmentFilesContainer; | 30 | import org.onosproject.yangutils.translator.tojava.TempJavaCodeFragmentFilesContainer; |
30 | import org.onosproject.yangutils.translator.tojava.utils.JavaExtendsListHolder; | 31 | import org.onosproject.yangutils.translator.tojava.utils.JavaExtendsListHolder; |
31 | -import org.onosproject.yangutils.translator.tojava.utils.YangPluginConfig; | 32 | +import org.onosproject.yangutils.utils.io.impl.YangPluginConfig; |
32 | 33 | ||
33 | import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_INTERFACE_WITH_BUILDER; | 34 | import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_INTERFACE_WITH_BUILDER; |
34 | -import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getCapitalCase; | 35 | +import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getCapitalCase; |
35 | -import static org.onosproject.yangutils.translator.tojava.utils.YangJavaModelUtils.generateCodeOfAugmentableNode; | 36 | +import static org.onosproject.yangutils.translator.tojava.javamodel.YangJavaModelUtils.generateCodeOfAugmentableNode; |
36 | import static org.onosproject.yangutils.utils.UtilConstants.EVENT_LISTENER_STRING; | 37 | import static org.onosproject.yangutils.utils.UtilConstants.EVENT_LISTENER_STRING; |
37 | import static org.onosproject.yangutils.utils.UtilConstants.EVENT_STRING; | 38 | import static org.onosproject.yangutils.utils.UtilConstants.EVENT_STRING; |
38 | 39 | ... | ... |
... | @@ -21,12 +21,13 @@ import java.io.IOException; | ... | @@ -21,12 +21,13 @@ import java.io.IOException; |
21 | import org.onosproject.yangutils.datamodel.YangOutput; | 21 | import org.onosproject.yangutils.datamodel.YangOutput; |
22 | import org.onosproject.yangutils.translator.exception.TranslatorException; | 22 | import org.onosproject.yangutils.translator.exception.TranslatorException; |
23 | import org.onosproject.yangutils.translator.tojava.JavaCodeGenerator; | 23 | import org.onosproject.yangutils.translator.tojava.JavaCodeGenerator; |
24 | +import org.onosproject.yangutils.translator.tojava.JavaCodeGeneratorInfo; | ||
24 | import org.onosproject.yangutils.translator.tojava.JavaFileInfo; | 25 | import org.onosproject.yangutils.translator.tojava.JavaFileInfo; |
25 | import org.onosproject.yangutils.translator.tojava.TempJavaCodeFragmentFiles; | 26 | import org.onosproject.yangutils.translator.tojava.TempJavaCodeFragmentFiles; |
26 | -import org.onosproject.yangutils.translator.tojava.utils.YangPluginConfig; | 27 | +import org.onosproject.yangutils.utils.io.impl.YangPluginConfig; |
27 | 28 | ||
28 | import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_INTERFACE_WITH_BUILDER; | 29 | import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_INTERFACE_WITH_BUILDER; |
29 | -import static org.onosproject.yangutils.translator.tojava.utils.YangJavaModelUtils.generateCodeOfAugmentableNode; | 30 | +import static org.onosproject.yangutils.translator.tojava.javamodel.YangJavaModelUtils.generateCodeOfAugmentableNode; |
30 | 31 | ||
31 | /** | 32 | /** |
32 | * Represents output information extended to support java code generation. | 33 | * Represents output information extended to support java code generation. | ... | ... |
... | @@ -26,19 +26,20 @@ import org.onosproject.yangutils.datamodel.YangRpc; | ... | @@ -26,19 +26,20 @@ import org.onosproject.yangutils.datamodel.YangRpc; |
26 | import org.onosproject.yangutils.translator.exception.TranslatorException; | 26 | import org.onosproject.yangutils.translator.exception.TranslatorException; |
27 | import org.onosproject.yangutils.translator.tojava.JavaAttributeInfo; | 27 | import org.onosproject.yangutils.translator.tojava.JavaAttributeInfo; |
28 | import org.onosproject.yangutils.translator.tojava.JavaCodeGenerator; | 28 | import org.onosproject.yangutils.translator.tojava.JavaCodeGenerator; |
29 | +import org.onosproject.yangutils.translator.tojava.JavaCodeGeneratorInfo; | ||
29 | import org.onosproject.yangutils.translator.tojava.JavaFileInfo; | 30 | import org.onosproject.yangutils.translator.tojava.JavaFileInfo; |
30 | import org.onosproject.yangutils.translator.tojava.JavaFileInfoContainer; | 31 | import org.onosproject.yangutils.translator.tojava.JavaFileInfoContainer; |
31 | import org.onosproject.yangutils.translator.tojava.JavaQualifiedTypeInfo; | 32 | import org.onosproject.yangutils.translator.tojava.JavaQualifiedTypeInfo; |
32 | import org.onosproject.yangutils.translator.tojava.TempJavaCodeFragmentFiles; | 33 | import org.onosproject.yangutils.translator.tojava.TempJavaCodeFragmentFiles; |
33 | import org.onosproject.yangutils.translator.tojava.TempJavaCodeFragmentFilesContainer; | 34 | import org.onosproject.yangutils.translator.tojava.TempJavaCodeFragmentFilesContainer; |
34 | import org.onosproject.yangutils.translator.tojava.TempJavaFragmentFiles; | 35 | import org.onosproject.yangutils.translator.tojava.TempJavaFragmentFiles; |
35 | -import org.onosproject.yangutils.translator.tojava.utils.YangPluginConfig; | 36 | +import org.onosproject.yangutils.utils.io.impl.YangPluginConfig; |
36 | 37 | ||
37 | import static org.onosproject.yangutils.datamodel.utils.DataModelUtils.getParentNodeInGenCode; | 38 | import static org.onosproject.yangutils.datamodel.utils.DataModelUtils.getParentNodeInGenCode; |
38 | import static org.onosproject.yangutils.translator.tojava.JavaAttributeInfo.getAttributeInfoForTheData; | 39 | import static org.onosproject.yangutils.translator.tojava.JavaAttributeInfo.getAttributeInfoForTheData; |
39 | import static org.onosproject.yangutils.translator.tojava.JavaQualifiedTypeInfo.getQualifiedTypeInfoOfCurNode; | 40 | import static org.onosproject.yangutils.translator.tojava.JavaQualifiedTypeInfo.getQualifiedTypeInfoOfCurNode; |
40 | -import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getCapitalCase; | 41 | +import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getCapitalCase; |
41 | -import static org.onosproject.yangutils.translator.tojava.utils.YangJavaModelUtils.updatePackageInfo; | 42 | +import static org.onosproject.yangutils.translator.tojava.javamodel.YangJavaModelUtils.updatePackageInfo; |
42 | import static org.onosproject.yangutils.utils.UtilConstants.ACTIVATE; | 43 | import static org.onosproject.yangutils.utils.UtilConstants.ACTIVATE; |
43 | import static org.onosproject.yangutils.utils.UtilConstants.COMPONENT; | 44 | import static org.onosproject.yangutils.utils.UtilConstants.COMPONENT; |
44 | import static org.onosproject.yangutils.utils.UtilConstants.DEACTIVATE; | 45 | import static org.onosproject.yangutils.utils.UtilConstants.DEACTIVATE; | ... | ... |
... | @@ -26,16 +26,17 @@ import org.onosproject.yangutils.datamodel.YangNotification; | ... | @@ -26,16 +26,17 @@ import org.onosproject.yangutils.datamodel.YangNotification; |
26 | import org.onosproject.yangutils.datamodel.YangSubModule; | 26 | import org.onosproject.yangutils.datamodel.YangSubModule; |
27 | import org.onosproject.yangutils.translator.exception.TranslatorException; | 27 | import org.onosproject.yangutils.translator.exception.TranslatorException; |
28 | import org.onosproject.yangutils.translator.tojava.JavaCodeGenerator; | 28 | import org.onosproject.yangutils.translator.tojava.JavaCodeGenerator; |
29 | +import org.onosproject.yangutils.translator.tojava.JavaCodeGeneratorInfo; | ||
29 | import org.onosproject.yangutils.translator.tojava.JavaFileInfo; | 30 | import org.onosproject.yangutils.translator.tojava.JavaFileInfo; |
30 | import org.onosproject.yangutils.translator.tojava.TempJavaCodeFragmentFiles; | 31 | import org.onosproject.yangutils.translator.tojava.TempJavaCodeFragmentFiles; |
31 | -import org.onosproject.yangutils.translator.tojava.utils.YangPluginConfig; | 32 | +import org.onosproject.yangutils.utils.io.impl.YangPluginConfig; |
32 | 33 | ||
33 | import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_EVENT_CLASS; | 34 | import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_EVENT_CLASS; |
34 | import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_EVENT_LISTENER_INTERFACE; | 35 | import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_EVENT_LISTENER_INTERFACE; |
35 | import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_EVENT_SUBJECT_CLASS; | 36 | import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_EVENT_SUBJECT_CLASS; |
36 | import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_SERVICE_AND_MANAGER; | 37 | import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_SERVICE_AND_MANAGER; |
37 | import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getRootPackage; | 38 | import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getRootPackage; |
38 | -import static org.onosproject.yangutils.translator.tojava.utils.YangJavaModelUtils.generateCodeOfRootNode; | 39 | +import static org.onosproject.yangutils.translator.tojava.javamodel.YangJavaModelUtils.generateCodeOfRootNode; |
39 | import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.searchAndDeleteTempDir; | 40 | import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.searchAndDeleteTempDir; |
40 | 41 | ||
41 | /** | 42 | /** | ... | ... |
... | @@ -18,8 +18,7 @@ package org.onosproject.yangutils.translator.tojava.javamodel; | ... | @@ -18,8 +18,7 @@ package org.onosproject.yangutils.translator.tojava.javamodel; |
18 | import org.onosproject.yangutils.datamodel.YangType; | 18 | import org.onosproject.yangutils.datamodel.YangType; |
19 | import org.onosproject.yangutils.translator.exception.TranslatorException; | 19 | import org.onosproject.yangutils.translator.exception.TranslatorException; |
20 | import org.onosproject.yangutils.translator.tojava.JavaQualifiedTypeInfo; | 20 | import org.onosproject.yangutils.translator.tojava.JavaQualifiedTypeInfo; |
21 | -import org.onosproject.yangutils.translator.tojava.utils.AttributesJavaDataType; | 21 | +import org.onosproject.yangutils.utils.io.impl.YangToJavaNamingConflictUtil; |
22 | -import org.onosproject.yangutils.translator.tojava.utils.YangToJavaNamingConflictUtil; | ||
23 | 22 | ||
24 | /** | 23 | /** |
25 | * Represents java information corresponding to the YANG type. | 24 | * Represents java information corresponding to the YANG type. | ... | ... |
... | @@ -20,12 +20,13 @@ import java.io.IOException; | ... | @@ -20,12 +20,13 @@ import java.io.IOException; |
20 | import org.onosproject.yangutils.datamodel.YangTypeDef; | 20 | import org.onosproject.yangutils.datamodel.YangTypeDef; |
21 | import org.onosproject.yangutils.translator.exception.TranslatorException; | 21 | import org.onosproject.yangutils.translator.exception.TranslatorException; |
22 | import org.onosproject.yangutils.translator.tojava.JavaCodeGenerator; | 22 | import org.onosproject.yangutils.translator.tojava.JavaCodeGenerator; |
23 | +import org.onosproject.yangutils.translator.tojava.JavaCodeGeneratorInfo; | ||
23 | import org.onosproject.yangutils.translator.tojava.JavaFileInfo; | 24 | import org.onosproject.yangutils.translator.tojava.JavaFileInfo; |
24 | import org.onosproject.yangutils.translator.tojava.TempJavaCodeFragmentFiles; | 25 | import org.onosproject.yangutils.translator.tojava.TempJavaCodeFragmentFiles; |
25 | -import org.onosproject.yangutils.translator.tojava.utils.YangPluginConfig; | 26 | +import org.onosproject.yangutils.utils.io.impl.YangPluginConfig; |
26 | 27 | ||
27 | import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_TYPEDEF_CLASS; | 28 | import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_TYPEDEF_CLASS; |
28 | -import static org.onosproject.yangutils.translator.tojava.utils.YangJavaModelUtils.generateCodeOfNode; | 29 | +import static org.onosproject.yangutils.translator.tojava.javamodel.YangJavaModelUtils.generateCodeOfNode; |
29 | 30 | ||
30 | /** | 31 | /** |
31 | * Represents type define information extended to support java code generation. | 32 | * Represents type define information extended to support java code generation. | ... | ... |
... | @@ -20,12 +20,13 @@ import java.io.IOException; | ... | @@ -20,12 +20,13 @@ import java.io.IOException; |
20 | import org.onosproject.yangutils.datamodel.YangUnion; | 20 | import org.onosproject.yangutils.datamodel.YangUnion; |
21 | import org.onosproject.yangutils.translator.exception.TranslatorException; | 21 | import org.onosproject.yangutils.translator.exception.TranslatorException; |
22 | import org.onosproject.yangutils.translator.tojava.JavaCodeGenerator; | 22 | import org.onosproject.yangutils.translator.tojava.JavaCodeGenerator; |
23 | +import org.onosproject.yangutils.translator.tojava.JavaCodeGeneratorInfo; | ||
23 | import org.onosproject.yangutils.translator.tojava.JavaFileInfo; | 24 | import org.onosproject.yangutils.translator.tojava.JavaFileInfo; |
24 | import org.onosproject.yangutils.translator.tojava.TempJavaCodeFragmentFiles; | 25 | import org.onosproject.yangutils.translator.tojava.TempJavaCodeFragmentFiles; |
25 | -import org.onosproject.yangutils.translator.tojava.utils.YangPluginConfig; | 26 | +import org.onosproject.yangutils.utils.io.impl.YangPluginConfig; |
26 | 27 | ||
27 | import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_UNION_CLASS; | 28 | import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_UNION_CLASS; |
28 | -import static org.onosproject.yangutils.translator.tojava.utils.YangJavaModelUtils.generateCodeOfNode; | 29 | +import static org.onosproject.yangutils.translator.tojava.javamodel.YangJavaModelUtils.generateCodeOfNode; |
29 | 30 | ||
30 | /** | 31 | /** |
31 | * Represents union information extended to support java code generation. | 32 | * Represents union information extended to support java code generation. | ... | ... |
... | @@ -25,13 +25,14 @@ import org.onosproject.yangutils.datamodel.YangNode; | ... | @@ -25,13 +25,14 @@ import org.onosproject.yangutils.datamodel.YangNode; |
25 | import org.onosproject.yangutils.datamodel.YangUses; | 25 | import org.onosproject.yangutils.datamodel.YangUses; |
26 | import org.onosproject.yangutils.translator.exception.TranslatorException; | 26 | import org.onosproject.yangutils.translator.exception.TranslatorException; |
27 | import org.onosproject.yangutils.translator.tojava.JavaCodeGenerator; | 27 | import org.onosproject.yangutils.translator.tojava.JavaCodeGenerator; |
28 | +import org.onosproject.yangutils.translator.tojava.JavaCodeGeneratorInfo; | ||
28 | import org.onosproject.yangutils.translator.tojava.JavaFileInfo; | 29 | import org.onosproject.yangutils.translator.tojava.JavaFileInfo; |
29 | import org.onosproject.yangutils.translator.tojava.TempJavaCodeFragmentFiles; | 30 | import org.onosproject.yangutils.translator.tojava.TempJavaCodeFragmentFiles; |
30 | -import org.onosproject.yangutils.translator.tojava.utils.YangPluginConfig; | 31 | +import org.onosproject.yangutils.utils.io.impl.YangPluginConfig; |
31 | 32 | ||
32 | import static org.onosproject.yangutils.datamodel.utils.DataModelUtils.getParentNodeInGenCode; | 33 | import static org.onosproject.yangutils.datamodel.utils.DataModelUtils.getParentNodeInGenCode; |
33 | import static org.onosproject.yangutils.translator.tojava.TempJavaFragmentFiles.addCurNodeAsAttributeInTargetTempFile; | 34 | import static org.onosproject.yangutils.translator.tojava.TempJavaFragmentFiles.addCurNodeAsAttributeInTargetTempFile; |
34 | -import static org.onosproject.yangutils.translator.tojava.utils.YangJavaModelUtils.updatePackageInfo; | 35 | +import static org.onosproject.yangutils.translator.tojava.javamodel.YangJavaModelUtils.updatePackageInfo; |
35 | 36 | ||
36 | /** | 37 | /** |
37 | * Represents uses information extended to support java code generation. | 38 | * Represents uses information extended to support java code generation. | ... | ... |
... | @@ -17,9 +17,9 @@ | ... | @@ -17,9 +17,9 @@ |
17 | package org.onosproject.yangutils.translator.tojava.utils; | 17 | package org.onosproject.yangutils.translator.tojava.utils; |
18 | 18 | ||
19 | import org.onosproject.yangutils.datamodel.YangNode; | 19 | import org.onosproject.yangutils.datamodel.YangNode; |
20 | +import org.onosproject.yangutils.datamodel.YangNotification; | ||
20 | import org.onosproject.yangutils.translator.tojava.JavaQualifiedTypeInfo; | 21 | import org.onosproject.yangutils.translator.tojava.JavaQualifiedTypeInfo; |
21 | import org.onosproject.yangutils.translator.tojava.TempJavaCodeFragmentFilesContainer; | 22 | import org.onosproject.yangutils.translator.tojava.TempJavaCodeFragmentFilesContainer; |
22 | -import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaNotification; | ||
23 | 23 | ||
24 | import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.BUILDER_CLASS_MASK; | 24 | import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.BUILDER_CLASS_MASK; |
25 | import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.BUILDER_INTERFACE_MASK; | 25 | import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.BUILDER_INTERFACE_MASK; |
... | @@ -75,7 +75,7 @@ public final class ClassDefinitionGenerator { | ... | @@ -75,7 +75,7 @@ public final class ClassDefinitionGenerator { |
75 | * / interface definition start. | 75 | * / interface definition start. |
76 | * | 76 | * |
77 | * @param genFileTypes generated file type | 77 | * @param genFileTypes generated file type |
78 | - * @param yangName class name | 78 | + * @param yangName class name |
79 | * @return class definition | 79 | * @return class definition |
80 | */ | 80 | */ |
81 | public static String generateClassDefinition(int genFileTypes, String yangName) { | 81 | public static String generateClassDefinition(int genFileTypes, String yangName) { |
... | @@ -85,19 +85,19 @@ public final class ClassDefinitionGenerator { | ... | @@ -85,19 +85,19 @@ public final class ClassDefinitionGenerator { |
85 | * class / interface definition start. | 85 | * class / interface definition start. |
86 | */ | 86 | */ |
87 | switch (genFileTypes) { | 87 | switch (genFileTypes) { |
88 | - case BUILDER_CLASS_MASK: | 88 | + case BUILDER_CLASS_MASK: |
89 | - return getBuilderClassDefinition(yangName); | 89 | + return getBuilderClassDefinition(yangName); |
90 | - case IMPL_CLASS_MASK: | 90 | + case IMPL_CLASS_MASK: |
91 | - return getImplClassDefinition(yangName); | 91 | + return getImplClassDefinition(yangName); |
92 | - case BUILDER_INTERFACE_MASK: | 92 | + case BUILDER_INTERFACE_MASK: |
93 | - return getBuilderInterfaceDefinition(yangName); | 93 | + return getBuilderInterfaceDefinition(yangName); |
94 | - case GENERATE_TYPEDEF_CLASS: | 94 | + case GENERATE_TYPEDEF_CLASS: |
95 | - case GENERATE_UNION_CLASS: | 95 | + case GENERATE_UNION_CLASS: |
96 | - return getTypeClassDefinition(yangName); | 96 | + return getTypeClassDefinition(yangName); |
97 | - case GENERATE_ENUM_CLASS: | 97 | + case GENERATE_ENUM_CLASS: |
98 | - return getEnumClassDefinition(yangName); | 98 | + return getEnumClassDefinition(yangName); |
99 | - default: | 99 | + default: |
100 | - return null; | 100 | + return null; |
101 | } | 101 | } |
102 | } | 102 | } |
103 | 103 | ||
... | @@ -106,8 +106,8 @@ public final class ClassDefinitionGenerator { | ... | @@ -106,8 +106,8 @@ public final class ClassDefinitionGenerator { |
106 | * / interface definition start. | 106 | * / interface definition start. |
107 | * | 107 | * |
108 | * @param genFileTypes generated file type | 108 | * @param genFileTypes generated file type |
109 | - * @param yangName class name | 109 | + * @param yangName class name |
110 | - * @param curNode current YANG node | 110 | + * @param curNode current YANG node |
111 | * @return class definition | 111 | * @return class definition |
112 | */ | 112 | */ |
113 | public static String generateClassDefinition(int genFileTypes, String yangName, YangNode curNode) { | 113 | public static String generateClassDefinition(int genFileTypes, String yangName, YangNode curNode) { |
... | @@ -117,19 +117,19 @@ public final class ClassDefinitionGenerator { | ... | @@ -117,19 +117,19 @@ public final class ClassDefinitionGenerator { |
117 | * class / interface definition start. | 117 | * class / interface definition start. |
118 | */ | 118 | */ |
119 | switch (genFileTypes) { | 119 | switch (genFileTypes) { |
120 | - case INTERFACE_MASK: | 120 | + case INTERFACE_MASK: |
121 | - return getInterfaceDefinition(yangName, curNode); | 121 | + return getInterfaceDefinition(yangName, curNode); |
122 | - case GENERATE_SERVICE_AND_MANAGER: | 122 | + case GENERATE_SERVICE_AND_MANAGER: |
123 | - return getRpcInterfaceDefinition(yangName, curNode); | 123 | + return getRpcInterfaceDefinition(yangName, curNode); |
124 | - case GENERATE_EVENT_CLASS: | 124 | + case GENERATE_EVENT_CLASS: |
125 | - String eventName = yangName + SUBJECT; | 125 | + String eventName = yangName + SUBJECT; |
126 | - return getEventDefinition(yangName, eventName); | 126 | + return getEventDefinition(yangName, eventName); |
127 | - case GENERATE_EVENT_LISTENER_INTERFACE: | 127 | + case GENERATE_EVENT_LISTENER_INTERFACE: |
128 | - return getEventListenerDefinition(yangName); | 128 | + return getEventListenerDefinition(yangName); |
129 | - case GENERATE_EVENT_SUBJECT_CLASS: | 129 | + case GENERATE_EVENT_SUBJECT_CLASS: |
130 | - return getClassDefinition(yangName); | 130 | + return getClassDefinition(yangName); |
131 | - default: | 131 | + default: |
132 | - return null; | 132 | + return null; |
133 | } | 133 | } |
134 | } | 134 | } |
135 | 135 | ||
... | @@ -174,7 +174,7 @@ public final class ClassDefinitionGenerator { | ... | @@ -174,7 +174,7 @@ public final class ClassDefinitionGenerator { |
174 | * Returns builder interface file class definition. | 174 | * Returns builder interface file class definition. |
175 | * | 175 | * |
176 | * @param yangName java class name, corresponding to which the builder class | 176 | * @param yangName java class name, corresponding to which the builder class |
177 | - * is being generated | 177 | + * is being generated |
178 | * @return definition | 178 | * @return definition |
179 | */ | 179 | */ |
180 | private static String getBuilderInterfaceDefinition(String yangName) { | 180 | private static String getBuilderInterfaceDefinition(String yangName) { |
... | @@ -227,7 +227,7 @@ public final class ClassDefinitionGenerator { | ... | @@ -227,7 +227,7 @@ public final class ClassDefinitionGenerator { |
227 | * Returns RPC file interface definition. | 227 | * Returns RPC file interface definition. |
228 | * | 228 | * |
229 | * @param yangName file name | 229 | * @param yangName file name |
230 | - * @param curNode current YANG node | 230 | + * @param curNode current YANG node |
231 | * @return definition | 231 | * @return definition |
232 | */ | 232 | */ |
233 | private static String getRpcInterfaceDefinition(String yangName, YangNode curNode) { | 233 | private static String getRpcInterfaceDefinition(String yangName, YangNode curNode) { |
... | @@ -236,7 +236,7 @@ public final class ClassDefinitionGenerator { | ... | @@ -236,7 +236,7 @@ public final class ClassDefinitionGenerator { |
236 | if (holder.getExtendsList() != null && !holder.getExtendsList().isEmpty()) { | 236 | if (holder.getExtendsList() != null && !holder.getExtendsList().isEmpty()) { |
237 | curNode = curNode.getChild(); | 237 | curNode = curNode.getChild(); |
238 | while (curNode != null) { | 238 | while (curNode != null) { |
239 | - if (curNode instanceof YangJavaNotification) { | 239 | + if (curNode instanceof YangNotification) { |
240 | return getRpcInterfaceDefinitionWhenItExtends(yangName, holder); | 240 | return getRpcInterfaceDefinitionWhenItExtends(yangName, holder); |
241 | } | 241 | } |
242 | curNode = curNode.getNextSibling(); | 242 | curNode = curNode.getNextSibling(); |
... | @@ -251,7 +251,7 @@ public final class ClassDefinitionGenerator { | ... | @@ -251,7 +251,7 @@ public final class ClassDefinitionGenerator { |
251 | 251 | ||
252 | /* Provides class definition when RPC interface needs to extends any event.*/ | 252 | /* Provides class definition when RPC interface needs to extends any event.*/ |
253 | private static String getRpcInterfaceDefinitionWhenItExtends(String yangName, | 253 | private static String getRpcInterfaceDefinitionWhenItExtends(String yangName, |
254 | - JavaExtendsListHolder holder) { | 254 | + JavaExtendsListHolder holder) { |
255 | 255 | ||
256 | if (yangName.matches(REGEX_FOR_ANY_STRING_ENDING_WITH_SERVICE)) { | 256 | if (yangName.matches(REGEX_FOR_ANY_STRING_ENDING_WITH_SERVICE)) { |
257 | String[] strArray = yangName.split(SERVICE); | 257 | String[] strArray = yangName.split(SERVICE); | ... | ... |
... | @@ -17,9 +17,10 @@ | ... | @@ -17,9 +17,10 @@ |
17 | package org.onosproject.yangutils.translator.tojava.utils; | 17 | package org.onosproject.yangutils.translator.tojava.utils; |
18 | 18 | ||
19 | import org.onosproject.yangutils.translator.tojava.JavaQualifiedTypeInfo; | 19 | import org.onosproject.yangutils.translator.tojava.JavaQualifiedTypeInfo; |
20 | +import org.onosproject.yangutils.utils.io.impl.YangPluginConfig; | ||
20 | 21 | ||
21 | import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getEnumJavaAttribute; | 22 | import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getEnumJavaAttribute; |
22 | -import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getSmallCase; | 23 | +import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getSmallCase; |
23 | import static org.onosproject.yangutils.utils.UtilConstants.ARRAY_LIST; | 24 | import static org.onosproject.yangutils.utils.UtilConstants.ARRAY_LIST; |
24 | import static org.onosproject.yangutils.utils.UtilConstants.AUGMENTED_INFO; | 25 | import static org.onosproject.yangutils.utils.UtilConstants.AUGMENTED_INFO; |
25 | import static org.onosproject.yangutils.utils.UtilConstants.CLOSE_CURLY_BRACKET; | 26 | import static org.onosproject.yangutils.utils.UtilConstants.CLOSE_CURLY_BRACKET; | ... | ... |
... | @@ -27,7 +27,7 @@ import org.onosproject.yangutils.translator.tojava.JavaFileInfoContainer; | ... | @@ -27,7 +27,7 @@ import org.onosproject.yangutils.translator.tojava.JavaFileInfoContainer; |
27 | import org.onosproject.yangutils.translator.tojava.JavaImportData; | 27 | import org.onosproject.yangutils.translator.tojava.JavaImportData; |
28 | import org.onosproject.yangutils.translator.tojava.JavaQualifiedTypeInfo; | 28 | import org.onosproject.yangutils.translator.tojava.JavaQualifiedTypeInfo; |
29 | 29 | ||
30 | -import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getCapitalCase; | 30 | +import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getCapitalCase; |
31 | import static org.onosproject.yangutils.translator.tojava.utils.TempJavaCodeFragmentFilesUtils.getTempJavaFragement; | 31 | import static org.onosproject.yangutils.translator.tojava.utils.TempJavaCodeFragmentFilesUtils.getTempJavaFragement; |
32 | 32 | ||
33 | /** | 33 | /** | ... | ... |
... | @@ -28,7 +28,8 @@ import org.onosproject.yangutils.translator.tojava.TempJavaCodeFragmentFiles; | ... | @@ -28,7 +28,8 @@ import org.onosproject.yangutils.translator.tojava.TempJavaCodeFragmentFiles; |
28 | import org.onosproject.yangutils.translator.tojava.TempJavaCodeFragmentFilesContainer; | 28 | import org.onosproject.yangutils.translator.tojava.TempJavaCodeFragmentFilesContainer; |
29 | import org.onosproject.yangutils.translator.tojava.TempJavaEnumerationFragmentFiles; | 29 | import org.onosproject.yangutils.translator.tojava.TempJavaEnumerationFragmentFiles; |
30 | import org.onosproject.yangutils.translator.tojava.TempJavaServiceFragmentFiles; | 30 | import org.onosproject.yangutils.translator.tojava.TempJavaServiceFragmentFiles; |
31 | -import org.onosproject.yangutils.translator.tojava.javamodel.JavaCodeGeneratorInfo; | 31 | +import org.onosproject.yangutils.translator.tojava.JavaCodeGeneratorInfo; |
32 | +import org.onosproject.yangutils.utils.io.impl.YangPluginConfig; | ||
32 | 33 | ||
33 | import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.BUILDER_CLASS_MASK; | 34 | import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.BUILDER_CLASS_MASK; |
34 | import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.BUILDER_INTERFACE_MASK; | 35 | import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.BUILDER_INTERFACE_MASK; |
... | @@ -65,7 +66,7 @@ import static org.onosproject.yangutils.translator.tojava.utils.JavaCodeSnippetG | ... | @@ -65,7 +66,7 @@ import static org.onosproject.yangutils.translator.tojava.utils.JavaCodeSnippetG |
65 | import static org.onosproject.yangutils.translator.tojava.utils.JavaFileGeneratorUtils.getDataFromTempFileHandle; | 66 | import static org.onosproject.yangutils.translator.tojava.utils.JavaFileGeneratorUtils.getDataFromTempFileHandle; |
66 | import static org.onosproject.yangutils.translator.tojava.utils.JavaFileGeneratorUtils.getEnumsValueAttribute; | 67 | import static org.onosproject.yangutils.translator.tojava.utils.JavaFileGeneratorUtils.getEnumsValueAttribute; |
67 | import static org.onosproject.yangutils.translator.tojava.utils.JavaFileGeneratorUtils.initiateJavaFileGeneration; | 68 | import static org.onosproject.yangutils.translator.tojava.utils.JavaFileGeneratorUtils.initiateJavaFileGeneration; |
68 | -import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getCapitalCase; | 69 | +import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getCapitalCase; |
69 | import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.addActivateMethod; | 70 | import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.addActivateMethod; |
70 | import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.addDeActivateMethod; | 71 | import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.addDeActivateMethod; |
71 | import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getAddAugmentInfoMethodImpl; | 72 | import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getAddAugmentInfoMethodImpl; | ... | ... |
... | @@ -31,6 +31,7 @@ import org.onosproject.yangutils.translator.tojava.TempJavaServiceFragmentFiles; | ... | @@ -31,6 +31,7 @@ import org.onosproject.yangutils.translator.tojava.TempJavaServiceFragmentFiles; |
31 | import org.onosproject.yangutils.translator.tojava.TempJavaTypeFragmentFiles; | 31 | import org.onosproject.yangutils.translator.tojava.TempJavaTypeFragmentFiles; |
32 | import org.onosproject.yangutils.utils.io.impl.CopyrightHeader; | 32 | import org.onosproject.yangutils.utils.io.impl.CopyrightHeader; |
33 | import org.onosproject.yangutils.utils.io.impl.JavaDocGen.JavaDocType; | 33 | import org.onosproject.yangutils.utils.io.impl.JavaDocGen.JavaDocType; |
34 | +import org.onosproject.yangutils.utils.io.impl.YangPluginConfig; | ||
34 | 35 | ||
35 | import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.BUILDER_CLASS_MASK; | 36 | import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.BUILDER_CLASS_MASK; |
36 | import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.BUILDER_INTERFACE_MASK; | 37 | import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.BUILDER_INTERFACE_MASK; |
... | @@ -64,8 +65,8 @@ import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType. | ... | @@ -64,8 +65,8 @@ import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType. |
64 | import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.SETTER_FOR_INTERFACE_MASK; | 65 | import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.SETTER_FOR_INTERFACE_MASK; |
65 | import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.TO_STRING_IMPL_MASK; | 66 | import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.TO_STRING_IMPL_MASK; |
66 | import static org.onosproject.yangutils.translator.tojava.utils.ClassDefinitionGenerator.generateClassDefinition; | 67 | import static org.onosproject.yangutils.translator.tojava.utils.ClassDefinitionGenerator.generateClassDefinition; |
67 | -import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getJavaPackageFromPackagePath; | 68 | +import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getJavaPackageFromPackagePath; |
68 | -import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getSmallCase; | 69 | +import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getSmallCase; |
69 | import static org.onosproject.yangutils.utils.UtilConstants.CLOSE_PARENTHESIS; | 70 | import static org.onosproject.yangutils.utils.UtilConstants.CLOSE_PARENTHESIS; |
70 | import static org.onosproject.yangutils.utils.UtilConstants.COMPONENT_ANNOTATION; | 71 | import static org.onosproject.yangutils.utils.UtilConstants.COMPONENT_ANNOTATION; |
71 | import static org.onosproject.yangutils.utils.UtilConstants.EQUAL; | 72 | import static org.onosproject.yangutils.utils.UtilConstants.EQUAL; | ... | ... |
... | @@ -16,16 +16,18 @@ | ... | @@ -16,16 +16,18 @@ |
16 | 16 | ||
17 | package org.onosproject.yangutils.translator.tojava.utils; | 17 | package org.onosproject.yangutils.translator.tojava.utils; |
18 | 18 | ||
19 | +import java.io.File; | ||
20 | +import java.io.IOException; | ||
19 | import java.util.ArrayList; | 21 | import java.util.ArrayList; |
20 | -import java.util.Arrays; | ||
21 | import java.util.List; | 22 | import java.util.List; |
22 | - | ||
23 | import org.onosproject.yangutils.datamodel.YangNode; | 23 | import org.onosproject.yangutils.datamodel.YangNode; |
24 | -import org.onosproject.yangutils.datamodel.utils.DataModelUtils; | ||
25 | import org.onosproject.yangutils.translator.exception.TranslatorException; | 24 | import org.onosproject.yangutils.translator.exception.TranslatorException; |
26 | -import org.onosproject.yangutils.translator.tojava.JavaFileInfoContainer; | ||
27 | import org.onosproject.yangutils.translator.tojava.JavaFileInfo; | 25 | import org.onosproject.yangutils.translator.tojava.JavaFileInfo; |
26 | +import org.onosproject.yangutils.translator.tojava.JavaFileInfoContainer; | ||
27 | +import org.onosproject.yangutils.utils.io.impl.YangIoUtils; | ||
28 | +import org.onosproject.yangutils.utils.io.impl.YangToJavaNamingConflictUtil; | ||
28 | 29 | ||
30 | +import static org.onosproject.yangutils.datamodel.utils.DataModelUtils.getParentNodeInGenCode; | ||
29 | import static org.onosproject.yangutils.utils.UtilConstants.COLAN; | 31 | import static org.onosproject.yangutils.utils.UtilConstants.COLAN; |
30 | import static org.onosproject.yangutils.utils.UtilConstants.DEFAULT_BASE_PKG; | 32 | import static org.onosproject.yangutils.utils.UtilConstants.DEFAULT_BASE_PKG; |
31 | import static org.onosproject.yangutils.utils.UtilConstants.EMPTY_STRING; | 33 | import static org.onosproject.yangutils.utils.UtilConstants.EMPTY_STRING; |
... | @@ -33,23 +35,17 @@ import static org.onosproject.yangutils.utils.UtilConstants.HYPHEN; | ... | @@ -33,23 +35,17 @@ import static org.onosproject.yangutils.utils.UtilConstants.HYPHEN; |
33 | import static org.onosproject.yangutils.utils.UtilConstants.JAVA_KEY_WORDS; | 35 | import static org.onosproject.yangutils.utils.UtilConstants.JAVA_KEY_WORDS; |
34 | import static org.onosproject.yangutils.utils.UtilConstants.PERIOD; | 36 | import static org.onosproject.yangutils.utils.UtilConstants.PERIOD; |
35 | import static org.onosproject.yangutils.utils.UtilConstants.QUOTES; | 37 | import static org.onosproject.yangutils.utils.UtilConstants.QUOTES; |
36 | -import static org.onosproject.yangutils.utils.UtilConstants.REGEX_FOR_DIGITS_WITH_SINGLE_LETTER; | ||
37 | import static org.onosproject.yangutils.utils.UtilConstants.REGEX_FOR_FIRST_DIGIT; | 38 | import static org.onosproject.yangutils.utils.UtilConstants.REGEX_FOR_FIRST_DIGIT; |
38 | -import static org.onosproject.yangutils.utils.UtilConstants.REGEX_FOR_HYPHEN; | ||
39 | -import static org.onosproject.yangutils.utils.UtilConstants.REGEX_FOR_IDENTIFIER_SPECIAL_CHAR; | ||
40 | -import static org.onosproject.yangutils.utils.UtilConstants.REGEX_FOR_PERIOD; | ||
41 | -import static org.onosproject.yangutils.utils.UtilConstants.REGEX_FOR_SINGLE_LETTER; | ||
42 | -import static org.onosproject.yangutils.utils.UtilConstants.REGEX_FOR_UNDERSCORE; | ||
43 | import static org.onosproject.yangutils.utils.UtilConstants.REGEX_WITH_ALL_SPECIAL_CHAR; | 39 | import static org.onosproject.yangutils.utils.UtilConstants.REGEX_WITH_ALL_SPECIAL_CHAR; |
44 | -import static org.onosproject.yangutils.utils.UtilConstants.REGEX_WITH_DIGITS; | ||
45 | -import static org.onosproject.yangutils.utils.UtilConstants.REGEX_WITH_SINGLE_CAPITAL_CASE; | ||
46 | -import static org.onosproject.yangutils.utils.UtilConstants.REGEX_WITH_SINGLE_CAPITAL_CASE_AND_DIGITS_SMALL_CASES; | ||
47 | -import static org.onosproject.yangutils.utils.UtilConstants.REGEX_WITH_UPPERCASE; | ||
48 | import static org.onosproject.yangutils.utils.UtilConstants.REVISION_PREFIX; | 40 | import static org.onosproject.yangutils.utils.UtilConstants.REVISION_PREFIX; |
49 | import static org.onosproject.yangutils.utils.UtilConstants.SLASH; | 41 | import static org.onosproject.yangutils.utils.UtilConstants.SLASH; |
50 | import static org.onosproject.yangutils.utils.UtilConstants.UNDER_SCORE; | 42 | import static org.onosproject.yangutils.utils.UtilConstants.UNDER_SCORE; |
51 | import static org.onosproject.yangutils.utils.UtilConstants.VERSION_PREFIX; | 43 | import static org.onosproject.yangutils.utils.UtilConstants.VERSION_PREFIX; |
52 | -import static org.onosproject.yangutils.utils.UtilConstants.YANG_AUTO_PREFIX; | 44 | +import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.addPackageInfo; |
45 | +import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.createDirectories; | ||
46 | +import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getAbsolutePackagePath; | ||
47 | +import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getJavaPackageFromPackagePath; | ||
48 | +import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getPackageDirPathFromJavaJPackage; | ||
53 | 49 | ||
54 | /** | 50 | /** |
55 | * Represents an utility Class for translating the name from YANG to java convention. | 51 | * Represents an utility Class for translating the name from YANG to java convention. |
... | @@ -73,14 +69,14 @@ public final class JavaIdentifierSyntax { | ... | @@ -73,14 +69,14 @@ public final class JavaIdentifierSyntax { |
73 | /** | 69 | /** |
74 | * Returns the root package string. | 70 | * Returns the root package string. |
75 | * | 71 | * |
76 | - * @param version YANG version | 72 | + * @param version YANG version |
77 | - * @param nameSpace name space of the module | 73 | + * @param nameSpace name space of the module |
78 | - * @param revision revision of the module defined | 74 | + * @param revision revision of the module defined |
79 | * @param conflictResolver object of YANG to java naming conflict util | 75 | * @param conflictResolver object of YANG to java naming conflict util |
80 | * @return the root package string | 76 | * @return the root package string |
81 | */ | 77 | */ |
82 | public static String getRootPackage(byte version, String nameSpace, String revision, | 78 | public static String getRootPackage(byte version, String nameSpace, String revision, |
83 | - YangToJavaNamingConflictUtil conflictResolver) { | 79 | + YangToJavaNamingConflictUtil conflictResolver) { |
84 | 80 | ||
85 | String pkg; | 81 | String pkg; |
86 | pkg = DEFAULT_BASE_PKG; | 82 | pkg = DEFAULT_BASE_PKG; |
... | @@ -95,29 +91,6 @@ public final class JavaIdentifierSyntax { | ... | @@ -95,29 +91,6 @@ public final class JavaIdentifierSyntax { |
95 | } | 91 | } |
96 | 92 | ||
97 | /** | 93 | /** |
98 | - * Returns the node package string. | ||
99 | - * | ||
100 | - * @param curNode current java node whose package string needs to be set | ||
101 | - * @return returns the root package string | ||
102 | - */ | ||
103 | - public static String getCurNodePackage(YangNode curNode) { | ||
104 | - | ||
105 | - String pkg; | ||
106 | - if (!(curNode instanceof JavaFileInfoContainer) | ||
107 | - || curNode.getParent() == null) { | ||
108 | - throw new TranslatorException("missing parent node to get current node's package"); | ||
109 | - } | ||
110 | - | ||
111 | - YangNode parentNode = DataModelUtils.getParentNodeInGenCode(curNode); | ||
112 | - if (!(parentNode instanceof JavaFileInfoContainer)) { | ||
113 | - throw new TranslatorException("missing parent java node to get current node's package"); | ||
114 | - } | ||
115 | - JavaFileInfo parentJavaFileHandle = ((JavaFileInfoContainer) parentNode).getJavaFileInfo(); | ||
116 | - pkg = parentJavaFileHandle.getPackage() + PERIOD + parentJavaFileHandle.getJavaName(); | ||
117 | - return pkg.toLowerCase(); | ||
118 | - } | ||
119 | - | ||
120 | - /** | ||
121 | * Returns version. | 94 | * Returns version. |
122 | * | 95 | * |
123 | * @param ver YANG version | 96 | * @param ver YANG version |
... | @@ -130,7 +103,7 @@ public final class JavaIdentifierSyntax { | ... | @@ -130,7 +103,7 @@ public final class JavaIdentifierSyntax { |
130 | /** | 103 | /** |
131 | * Returns package name from name space. | 104 | * Returns package name from name space. |
132 | * | 105 | * |
133 | - * @param nameSpace name space of YANG module | 106 | + * @param nameSpace name space of YANG module |
134 | * @param conflictResolver object of YANG to java naming conflict util | 107 | * @param conflictResolver object of YANG to java naming conflict util |
135 | * @return java package name as per java rules | 108 | * @return java package name as per java rules |
136 | */ | 109 | */ |
... | @@ -181,7 +154,7 @@ public final class JavaIdentifierSyntax { | ... | @@ -181,7 +154,7 @@ public final class JavaIdentifierSyntax { |
181 | /** | 154 | /** |
182 | * Returns the package string. | 155 | * Returns the package string. |
183 | * | 156 | * |
184 | - * @param pkgArr package array | 157 | + * @param pkgArr package array |
185 | * @param conflictResolver object of YANG to java naming conflict util | 158 | * @param conflictResolver object of YANG to java naming conflict util |
186 | * @return package string | 159 | * @return package string |
187 | */ | 160 | */ |
... | @@ -193,7 +166,7 @@ public final class JavaIdentifierSyntax { | ... | @@ -193,7 +166,7 @@ public final class JavaIdentifierSyntax { |
193 | for (String member : pkgArr) { | 166 | for (String member : pkgArr) { |
194 | boolean presenceOfKeyword = JAVA_KEY_WORDS.contains(member.toLowerCase()); | 167 | boolean presenceOfKeyword = JAVA_KEY_WORDS.contains(member.toLowerCase()); |
195 | if (presenceOfKeyword || member.matches(REGEX_FOR_FIRST_DIGIT)) { | 168 | if (presenceOfKeyword || member.matches(REGEX_FOR_FIRST_DIGIT)) { |
196 | - String prefix = getPrefixForIdentifier(conflictResolver); | 169 | + String prefix = YangIoUtils.getPrefixForIdentifier(conflictResolver); |
197 | member = prefix + member; | 170 | member = prefix + member; |
198 | } | 171 | } |
199 | pkg = pkg + member; | 172 | pkg = pkg + member; |
... | @@ -206,252 +179,6 @@ public final class JavaIdentifierSyntax { | ... | @@ -206,252 +179,6 @@ public final class JavaIdentifierSyntax { |
206 | } | 179 | } |
207 | 180 | ||
208 | /** | 181 | /** |
209 | - * Prefix for adding with identifier and namespace, when it is a java keyword or starting with digits. | ||
210 | - * | ||
211 | - * @param conflictResolver object of YANG to java naming conflict util | ||
212 | - * @return prefix which needs to be added | ||
213 | - */ | ||
214 | - public static String getPrefixForIdentifier(YangToJavaNamingConflictUtil conflictResolver) { | ||
215 | - | ||
216 | - String prefixForIdentifier = null; | ||
217 | - if (conflictResolver != null) { | ||
218 | - prefixForIdentifier = conflictResolver.getPrefixForIdentifier(); | ||
219 | - } | ||
220 | - if (prefixForIdentifier != null) { | ||
221 | - prefixForIdentifier = prefixForIdentifier.replaceAll(REGEX_WITH_ALL_SPECIAL_CHAR, COLAN); | ||
222 | - String[] strArray = prefixForIdentifier.split(COLAN); | ||
223 | - try { | ||
224 | - if (strArray[0].isEmpty()) { | ||
225 | - List<String> stringArrangement = new ArrayList<String>(); | ||
226 | - for (int i = 1; i < strArray.length; i++) { | ||
227 | - stringArrangement.add(strArray[i]); | ||
228 | - } | ||
229 | - strArray = stringArrangement.toArray(new String[stringArrangement.size()]); | ||
230 | - } | ||
231 | - prefixForIdentifier = strArray[0]; | ||
232 | - for (int j = 1; j < strArray.length; j++) { | ||
233 | - prefixForIdentifier = prefixForIdentifier + strArray[j].substring(0, 1).toUpperCase() + | ||
234 | - strArray[j].substring(1); | ||
235 | - } | ||
236 | - } catch (ArrayIndexOutOfBoundsException outOfBoundsException) { | ||
237 | - throw new TranslatorException("The given prefix in pom.xml is invalid."); | ||
238 | - } | ||
239 | - } else { | ||
240 | - prefixForIdentifier = YANG_AUTO_PREFIX; | ||
241 | - } | ||
242 | - return prefixForIdentifier; | ||
243 | - } | ||
244 | - | ||
245 | - /** | ||
246 | - * Returns the YANG identifier name as java identifier. | ||
247 | - * | ||
248 | - * @param yangIdentifier identifier in YANG file | ||
249 | - * @param conflictResolver object of YANG to java naming conflict util | ||
250 | - * @return corresponding java identifier | ||
251 | - */ | ||
252 | - public static String getCamelCase(String yangIdentifier, YangToJavaNamingConflictUtil conflictResolver) { | ||
253 | - | ||
254 | - if (conflictResolver != null) { | ||
255 | - String replacementForHyphen = conflictResolver.getReplacementForHyphen(); | ||
256 | - String replacementForPeriod = conflictResolver.getReplacementForPeriod(); | ||
257 | - String replacementForUnderscore = conflictResolver.getReplacementForUnderscore(); | ||
258 | - if (replacementForPeriod != null) { | ||
259 | - yangIdentifier = yangIdentifier.replaceAll(REGEX_FOR_PERIOD, | ||
260 | - PERIOD + replacementForPeriod.toLowerCase() + PERIOD); | ||
261 | - } | ||
262 | - if (replacementForUnderscore != null) { | ||
263 | - yangIdentifier = yangIdentifier.replaceAll(REGEX_FOR_UNDERSCORE, | ||
264 | - UNDER_SCORE + replacementForUnderscore.toLowerCase() + UNDER_SCORE); | ||
265 | - } | ||
266 | - if (replacementForHyphen != null) { | ||
267 | - yangIdentifier = yangIdentifier.replaceAll(REGEX_FOR_HYPHEN, | ||
268 | - HYPHEN + replacementForHyphen.toLowerCase() + HYPHEN); | ||
269 | - } | ||
270 | - } | ||
271 | - yangIdentifier = yangIdentifier.replaceAll(REGEX_FOR_IDENTIFIER_SPECIAL_CHAR, COLAN); | ||
272 | - String[] strArray = yangIdentifier.split(COLAN); | ||
273 | - if (strArray[0].isEmpty()) { | ||
274 | - List<String> stringArrangement = new ArrayList<String>(); | ||
275 | - for (int i = 1; i < strArray.length; i++) { | ||
276 | - stringArrangement.add(strArray[i]); | ||
277 | - } | ||
278 | - strArray = stringArrangement.toArray(new String[stringArrangement.size()]); | ||
279 | - } | ||
280 | - return upperCaseConflictResolver(strArray, conflictResolver); | ||
281 | - } | ||
282 | - | ||
283 | - /** | ||
284 | - * Resolves the conflict when input has upper case. | ||
285 | - * | ||
286 | - * @param stringArray containing strings for upper case conflict resolver | ||
287 | - * @param conflictResolver object of YANG to java naming conflict util | ||
288 | - * @return camel cased string | ||
289 | - */ | ||
290 | - private static String upperCaseConflictResolver(String[] stringArray, | ||
291 | - YangToJavaNamingConflictUtil conflictResolver) { | ||
292 | - | ||
293 | - for (int l = 0; l < stringArray.length; l++) { | ||
294 | - String[] upperCaseSplitArray = stringArray[l].split(REGEX_WITH_UPPERCASE); | ||
295 | - for (int m = 0; m < upperCaseSplitArray.length; m++) { | ||
296 | - if (upperCaseSplitArray[m].matches(REGEX_WITH_SINGLE_CAPITAL_CASE)) { | ||
297 | - int check = m; | ||
298 | - while (check + 1 < upperCaseSplitArray.length) { | ||
299 | - if (upperCaseSplitArray[check + 1].matches(REGEX_WITH_SINGLE_CAPITAL_CASE)) { | ||
300 | - upperCaseSplitArray[check + 1] = upperCaseSplitArray[check + 1].toLowerCase(); | ||
301 | - check = check + 1; | ||
302 | - } else if (upperCaseSplitArray[check + 1] | ||
303 | - .matches(REGEX_WITH_SINGLE_CAPITAL_CASE_AND_DIGITS_SMALL_CASES)) { | ||
304 | - upperCaseSplitArray[check + 1] = upperCaseSplitArray[check + 1].toLowerCase(); | ||
305 | - break; | ||
306 | - } else { | ||
307 | - break; | ||
308 | - } | ||
309 | - } | ||
310 | - } | ||
311 | - } | ||
312 | - StringBuilder strBuilder = new StringBuilder(); | ||
313 | - for (String element : upperCaseSplitArray) { | ||
314 | - strBuilder.append(element); | ||
315 | - } | ||
316 | - stringArray[l] = strBuilder.toString(); | ||
317 | - } | ||
318 | - List<String> result = new ArrayList<String>(); | ||
319 | - for (String element : stringArray) { | ||
320 | - String[] capitalCaseSplitArray = element.split(REGEX_WITH_UPPERCASE); | ||
321 | - for (String letter : capitalCaseSplitArray) { | ||
322 | - String[] arrayForAddition = letter.split(REGEX_WITH_DIGITS); | ||
323 | - List<String> list = Arrays.asList(arrayForAddition); | ||
324 | - for (String str : list) { | ||
325 | - if (str != null && !str.isEmpty()) { | ||
326 | - result.add(str); | ||
327 | - } | ||
328 | - } | ||
329 | - } | ||
330 | - } | ||
331 | - stringArray = result.toArray(new String[result.size()]); | ||
332 | - return applyCamelCaseRule(stringArray, conflictResolver); | ||
333 | - } | ||
334 | - | ||
335 | - /** | ||
336 | - * Applies the rule that a string does not end with a capitalized letter and capitalizes | ||
337 | - * the letter next to a number in an array. | ||
338 | - * | ||
339 | - * @param stringArray containing strings for camel case separation | ||
340 | - * @param conflictResolver object of YANG to java naming conflict util | ||
341 | - * @return camel case rule checked string | ||
342 | - */ | ||
343 | - private static String applyCamelCaseRule(String[] stringArray, YangToJavaNamingConflictUtil conflictResolver) { | ||
344 | - | ||
345 | - String ruleChecker = stringArray[0].toLowerCase(); | ||
346 | - int i; | ||
347 | - if (ruleChecker.matches(REGEX_FOR_FIRST_DIGIT)) { | ||
348 | - i = 0; | ||
349 | - ruleChecker = EMPTY_STRING; | ||
350 | - } else { | ||
351 | - i = 1; | ||
352 | - } | ||
353 | - for (; i < stringArray.length; i++) { | ||
354 | - if (i + 1 == stringArray.length) { | ||
355 | - if (stringArray[i].matches(REGEX_FOR_SINGLE_LETTER) | ||
356 | - || stringArray[i].matches(REGEX_FOR_DIGITS_WITH_SINGLE_LETTER)) { | ||
357 | - ruleChecker = ruleChecker + stringArray[i].toLowerCase(); | ||
358 | - break; | ||
359 | - } | ||
360 | - } | ||
361 | - if (stringArray[i].matches(REGEX_FOR_FIRST_DIGIT)) { | ||
362 | - for (int j = 0; j < stringArray[i].length(); j++) { | ||
363 | - char letterCheck = stringArray[i].charAt(j); | ||
364 | - if (Character.isLetter(letterCheck)) { | ||
365 | - stringArray[i] = stringArray[i].substring(0, j) | ||
366 | - + stringArray[i].substring(j, j + 1).toUpperCase() + stringArray[i].substring(j + 1); | ||
367 | - break; | ||
368 | - } | ||
369 | - } | ||
370 | - ruleChecker = ruleChecker + stringArray[i]; | ||
371 | - } else { | ||
372 | - ruleChecker = ruleChecker + stringArray[i].substring(0, 1).toUpperCase() + stringArray[i].substring(1); | ||
373 | - } | ||
374 | - } | ||
375 | - String ruleCheckerWithPrefix = addPrefix(ruleChecker, conflictResolver); | ||
376 | - return restrictConsecutiveCapitalCase(ruleCheckerWithPrefix); | ||
377 | - } | ||
378 | - | ||
379 | - /** | ||
380 | - * Adds prefix, if the string begins with digit or is a java key word. | ||
381 | - * | ||
382 | - * @param camelCasePrefix string for adding prefix | ||
383 | - * @param conflictResolver object of YANG to java naming conflict util | ||
384 | - * @return prefixed camel case string | ||
385 | - */ | ||
386 | - private static String addPrefix(String camelCasePrefix, YangToJavaNamingConflictUtil conflictResolver) { | ||
387 | - | ||
388 | - String prefix = getPrefixForIdentifier(conflictResolver); | ||
389 | - if (camelCasePrefix.matches(REGEX_FOR_FIRST_DIGIT)) { | ||
390 | - camelCasePrefix = prefix + camelCasePrefix; | ||
391 | - } | ||
392 | - if (JAVA_KEY_WORDS.contains(camelCasePrefix)) { | ||
393 | - camelCasePrefix = prefix + camelCasePrefix.substring(0, 1).toUpperCase() | ||
394 | - + camelCasePrefix.substring(1); | ||
395 | - } | ||
396 | - return camelCasePrefix; | ||
397 | - } | ||
398 | - | ||
399 | - /** | ||
400 | - * Restricts consecutive capital cased string as a rule in camel case. | ||
401 | - * | ||
402 | - * @param consecCapitalCaseRemover which requires the restriction of consecutive capital case | ||
403 | - * @return string without consecutive capital case | ||
404 | - */ | ||
405 | - private static String restrictConsecutiveCapitalCase(String consecCapitalCaseRemover) { | ||
406 | - | ||
407 | - for (int k = 0; k < consecCapitalCaseRemover.length(); k++) { | ||
408 | - if (k + 1 < consecCapitalCaseRemover.length()) { | ||
409 | - if (Character.isUpperCase(consecCapitalCaseRemover.charAt(k))) { | ||
410 | - if (Character.isUpperCase(consecCapitalCaseRemover.charAt(k + 1))) { | ||
411 | - consecCapitalCaseRemover = consecCapitalCaseRemover.substring(0, k + 1) | ||
412 | - + consecCapitalCaseRemover.substring(k + 1, k + 2).toLowerCase() | ||
413 | - + consecCapitalCaseRemover.substring(k + 2); | ||
414 | - } | ||
415 | - } | ||
416 | - } | ||
417 | - } | ||
418 | - return consecCapitalCaseRemover; | ||
419 | - } | ||
420 | - | ||
421 | - /** | ||
422 | - * Returns the YANG identifier name as java identifier with first letter | ||
423 | - * in capital. | ||
424 | - * | ||
425 | - * @param yangIdentifier identifier in YANG file | ||
426 | - * @return corresponding java identifier | ||
427 | - */ | ||
428 | - public static String getCapitalCase(String yangIdentifier) { | ||
429 | - yangIdentifier = yangIdentifier.substring(0, 1).toUpperCase() + yangIdentifier.substring(1); | ||
430 | - return restrictConsecutiveCapitalCase(yangIdentifier); | ||
431 | - } | ||
432 | - | ||
433 | - /** | ||
434 | - * Returns the YANG identifier name as java identifier with first letter | ||
435 | - * in small. | ||
436 | - * | ||
437 | - * @param yangIdentifier identifier in YANG file. | ||
438 | - * @return corresponding java identifier | ||
439 | - */ | ||
440 | - public static String getSmallCase(String yangIdentifier) { | ||
441 | - return yangIdentifier.substring(0, 1).toLowerCase() + yangIdentifier.substring(1); | ||
442 | - } | ||
443 | - | ||
444 | - /** | ||
445 | - * Returns the java Package from package path. | ||
446 | - * | ||
447 | - * @param packagePath package path | ||
448 | - * @return java package | ||
449 | - */ | ||
450 | - public static String getJavaPackageFromPackagePath(String packagePath) { | ||
451 | - return packagePath.replace(SLASH, PERIOD); | ||
452 | - } | ||
453 | - | ||
454 | - /** | ||
455 | * Returns enum's java name. | 182 | * Returns enum's java name. |
456 | * | 183 | * |
457 | * @param name enum's name | 184 | * @param name enum's name |
... | @@ -479,12 +206,46 @@ public final class JavaIdentifierSyntax { | ... | @@ -479,12 +206,46 @@ public final class JavaIdentifierSyntax { |
479 | } | 206 | } |
480 | 207 | ||
481 | /** | 208 | /** |
482 | - * Returns the directory path corresponding to java package. | 209 | + * Creates a package structure with package info java file if not present. |
210 | + * | ||
211 | + * @param yangNode YANG node for which code is being generated | ||
212 | + * @throws IOException any IO exception | ||
213 | + */ | ||
214 | + public static void createPackage(YangNode yangNode) throws IOException { | ||
215 | + if (!(yangNode instanceof JavaFileInfoContainer)) { | ||
216 | + throw new TranslatorException("current node must have java file info"); | ||
217 | + } | ||
218 | + String pkgInfo; | ||
219 | + JavaFileInfo javaFileInfo = ((JavaFileInfoContainer) yangNode).getJavaFileInfo(); | ||
220 | + String pkg = getAbsolutePackagePath(javaFileInfo.getBaseCodeGenPath(), javaFileInfo.getPackageFilePath()); | ||
221 | + if (!doesPackageExist(pkg)) { | ||
222 | + try { | ||
223 | + File pack = createDirectories(pkg); | ||
224 | + YangNode parent = getParentNodeInGenCode(yangNode); | ||
225 | + if (parent != null) { | ||
226 | + pkgInfo = ((JavaFileInfoContainer) parent).getJavaFileInfo().getJavaName(); | ||
227 | + addPackageInfo(pack, pkgInfo, getJavaPackageFromPackagePath(pkg), true, | ||
228 | + ((JavaFileInfoContainer) parent).getJavaFileInfo().getPluginConfig()); | ||
229 | + } else { | ||
230 | + pkgInfo = ((JavaFileInfoContainer) yangNode).getJavaFileInfo().getJavaName(); | ||
231 | + addPackageInfo(pack, pkgInfo, getJavaPackageFromPackagePath(pkg), false, | ||
232 | + ((JavaFileInfoContainer) yangNode).getJavaFileInfo().getPluginConfig()); | ||
233 | + } | ||
234 | + } catch (IOException e) { | ||
235 | + throw new IOException("failed to create package-info file"); | ||
236 | + } | ||
237 | + } | ||
238 | + } | ||
239 | + | ||
240 | + /** | ||
241 | + * Checks if the package directory structure created. | ||
483 | * | 242 | * |
484 | - * @param packagePath package path | 243 | + * @param pkg Package to check if it is created |
485 | - * @return java package | 244 | + * @return existence status of package |
486 | */ | 245 | */ |
487 | - public static String getPackageDirPathFromJavaJPackage(String packagePath) { | 246 | + public static boolean doesPackageExist(String pkg) { |
488 | - return packagePath.replace(PERIOD, SLASH); | 247 | + File pkgDir = new File(getPackageDirPathFromJavaJPackage(pkg)); |
248 | + File pkgWithFile = new File(pkgDir + SLASH + "package-info.java"); | ||
249 | + return pkgDir.exists() && pkgWithFile.isFile(); | ||
489 | } | 250 | } |
490 | } | 251 | } | ... | ... |
... | @@ -18,31 +18,28 @@ package org.onosproject.yangutils.translator.tojava.utils; | ... | @@ -18,31 +18,28 @@ package org.onosproject.yangutils.translator.tojava.utils; |
18 | 18 | ||
19 | import java.util.List; | 19 | import java.util.List; |
20 | import java.util.Map; | 20 | import java.util.Map; |
21 | - | 21 | +import org.onosproject.yangutils.datamodel.YangDataTypes; |
22 | -import org.onosproject.yangutils.datamodel.YangNode; | 22 | +import org.onosproject.yangutils.datamodel.YangType; |
23 | -import org.onosproject.yangutils.datamodel.YangNodeIdentifier; | ||
24 | import org.onosproject.yangutils.translator.exception.TranslatorException; | 23 | import org.onosproject.yangutils.translator.exception.TranslatorException; |
25 | import org.onosproject.yangutils.translator.tojava.JavaAttributeInfo; | 24 | import org.onosproject.yangutils.translator.tojava.JavaAttributeInfo; |
26 | -import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaAugment; | ||
27 | import org.onosproject.yangutils.utils.io.impl.JavaDocGen; | 25 | import org.onosproject.yangutils.utils.io.impl.JavaDocGen; |
26 | +import org.onosproject.yangutils.utils.io.impl.YangPluginConfig; | ||
28 | 27 | ||
29 | import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_EVENT_SUBJECT_CLASS; | 28 | import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_EVENT_SUBJECT_CLASS; |
30 | import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_SERVICE_AND_MANAGER; | 29 | import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_SERVICE_AND_MANAGER; |
31 | -import static org.onosproject.yangutils.translator.tojava.utils.AttributesJavaDataType.getParseFromStringMethod; | ||
32 | -import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getCamelCase; | ||
33 | -import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getCapitalCase; | ||
34 | -import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getSmallCase; | ||
35 | import static org.onosproject.yangutils.utils.UtilConstants.ACTIVATE; | 30 | import static org.onosproject.yangutils.utils.UtilConstants.ACTIVATE; |
36 | import static org.onosproject.yangutils.utils.UtilConstants.ACTIVATE_ANNOTATION; | 31 | import static org.onosproject.yangutils.utils.UtilConstants.ACTIVATE_ANNOTATION; |
37 | import static org.onosproject.yangutils.utils.UtilConstants.ADD_STRING; | 32 | import static org.onosproject.yangutils.utils.UtilConstants.ADD_STRING; |
38 | import static org.onosproject.yangutils.utils.UtilConstants.AND; | 33 | import static org.onosproject.yangutils.utils.UtilConstants.AND; |
39 | -import static org.onosproject.yangutils.utils.UtilConstants.AUGMENTABLE; | ||
40 | import static org.onosproject.yangutils.utils.UtilConstants.AUGMENTATION; | 34 | import static org.onosproject.yangutils.utils.UtilConstants.AUGMENTATION; |
41 | import static org.onosproject.yangutils.utils.UtilConstants.AUGMENTED_INFO; | 35 | import static org.onosproject.yangutils.utils.UtilConstants.AUGMENTED_INFO; |
36 | +import static org.onosproject.yangutils.utils.UtilConstants.BIG_INTEGER; | ||
42 | import static org.onosproject.yangutils.utils.UtilConstants.BOOLEAN_DATA_TYPE; | 37 | import static org.onosproject.yangutils.utils.UtilConstants.BOOLEAN_DATA_TYPE; |
38 | +import static org.onosproject.yangutils.utils.UtilConstants.BOOLEAN_WRAPPER; | ||
43 | import static org.onosproject.yangutils.utils.UtilConstants.BUILD; | 39 | import static org.onosproject.yangutils.utils.UtilConstants.BUILD; |
44 | import static org.onosproject.yangutils.utils.UtilConstants.BUILDER; | 40 | import static org.onosproject.yangutils.utils.UtilConstants.BUILDER; |
45 | import static org.onosproject.yangutils.utils.UtilConstants.BYTE; | 41 | import static org.onosproject.yangutils.utils.UtilConstants.BYTE; |
42 | +import static org.onosproject.yangutils.utils.UtilConstants.BYTE_WRAPPER; | ||
46 | import static org.onosproject.yangutils.utils.UtilConstants.CASE; | 43 | import static org.onosproject.yangutils.utils.UtilConstants.CASE; |
47 | import static org.onosproject.yangutils.utils.UtilConstants.CATCH; | 44 | import static org.onosproject.yangutils.utils.UtilConstants.CATCH; |
48 | import static org.onosproject.yangutils.utils.UtilConstants.CHECK_NOT_NULL_STRING; | 45 | import static org.onosproject.yangutils.utils.UtilConstants.CHECK_NOT_NULL_STRING; |
... | @@ -74,8 +71,10 @@ import static org.onosproject.yangutils.utils.UtilConstants.IF; | ... | @@ -74,8 +71,10 @@ import static org.onosproject.yangutils.utils.UtilConstants.IF; |
74 | import static org.onosproject.yangutils.utils.UtilConstants.IMPL; | 71 | import static org.onosproject.yangutils.utils.UtilConstants.IMPL; |
75 | import static org.onosproject.yangutils.utils.UtilConstants.INSTANCE_OF; | 72 | import static org.onosproject.yangutils.utils.UtilConstants.INSTANCE_OF; |
76 | import static org.onosproject.yangutils.utils.UtilConstants.INT; | 73 | import static org.onosproject.yangutils.utils.UtilConstants.INT; |
74 | +import static org.onosproject.yangutils.utils.UtilConstants.INTEGER_WRAPPER; | ||
77 | import static org.onosproject.yangutils.utils.UtilConstants.LIST; | 75 | import static org.onosproject.yangutils.utils.UtilConstants.LIST; |
78 | import static org.onosproject.yangutils.utils.UtilConstants.LONG; | 76 | import static org.onosproject.yangutils.utils.UtilConstants.LONG; |
77 | +import static org.onosproject.yangutils.utils.UtilConstants.LONG_WRAPPER; | ||
79 | import static org.onosproject.yangutils.utils.UtilConstants.NEW; | 78 | import static org.onosproject.yangutils.utils.UtilConstants.NEW; |
80 | import static org.onosproject.yangutils.utils.UtilConstants.NEW_LINE; | 79 | import static org.onosproject.yangutils.utils.UtilConstants.NEW_LINE; |
81 | import static org.onosproject.yangutils.utils.UtilConstants.NULL; | 80 | import static org.onosproject.yangutils.utils.UtilConstants.NULL; |
... | @@ -88,6 +87,11 @@ import static org.onosproject.yangutils.utils.UtilConstants.OPEN_CURLY_BRACKET; | ... | @@ -88,6 +87,11 @@ import static org.onosproject.yangutils.utils.UtilConstants.OPEN_CURLY_BRACKET; |
88 | import static org.onosproject.yangutils.utils.UtilConstants.OPEN_PARENTHESIS; | 87 | import static org.onosproject.yangutils.utils.UtilConstants.OPEN_PARENTHESIS; |
89 | import static org.onosproject.yangutils.utils.UtilConstants.OTHER; | 88 | import static org.onosproject.yangutils.utils.UtilConstants.OTHER; |
90 | import static org.onosproject.yangutils.utils.UtilConstants.OVERRIDE; | 89 | import static org.onosproject.yangutils.utils.UtilConstants.OVERRIDE; |
90 | +import static org.onosproject.yangutils.utils.UtilConstants.PARSE_BOOLEAN; | ||
91 | +import static org.onosproject.yangutils.utils.UtilConstants.PARSE_BYTE; | ||
92 | +import static org.onosproject.yangutils.utils.UtilConstants.PARSE_INT; | ||
93 | +import static org.onosproject.yangutils.utils.UtilConstants.PARSE_LONG; | ||
94 | +import static org.onosproject.yangutils.utils.UtilConstants.PARSE_SHORT; | ||
91 | import static org.onosproject.yangutils.utils.UtilConstants.PERIOD; | 95 | import static org.onosproject.yangutils.utils.UtilConstants.PERIOD; |
92 | import static org.onosproject.yangutils.utils.UtilConstants.PUBLIC; | 96 | import static org.onosproject.yangutils.utils.UtilConstants.PUBLIC; |
93 | import static org.onosproject.yangutils.utils.UtilConstants.QUOTES; | 97 | import static org.onosproject.yangutils.utils.UtilConstants.QUOTES; |
... | @@ -96,6 +100,7 @@ import static org.onosproject.yangutils.utils.UtilConstants.RPC_INPUT_VAR_NAME; | ... | @@ -96,6 +100,7 @@ import static org.onosproject.yangutils.utils.UtilConstants.RPC_INPUT_VAR_NAME; |
96 | import static org.onosproject.yangutils.utils.UtilConstants.SEMI_COLAN; | 100 | import static org.onosproject.yangutils.utils.UtilConstants.SEMI_COLAN; |
97 | import static org.onosproject.yangutils.utils.UtilConstants.SET_METHOD_PREFIX; | 101 | import static org.onosproject.yangutils.utils.UtilConstants.SET_METHOD_PREFIX; |
98 | import static org.onosproject.yangutils.utils.UtilConstants.SHORT; | 102 | import static org.onosproject.yangutils.utils.UtilConstants.SHORT; |
103 | +import static org.onosproject.yangutils.utils.UtilConstants.SHORT_WRAPPER; | ||
99 | import static org.onosproject.yangutils.utils.UtilConstants.SIXTEEN_SPACE_INDENTATION; | 104 | import static org.onosproject.yangutils.utils.UtilConstants.SIXTEEN_SPACE_INDENTATION; |
100 | import static org.onosproject.yangutils.utils.UtilConstants.SPACE; | 105 | import static org.onosproject.yangutils.utils.UtilConstants.SPACE; |
101 | import static org.onosproject.yangutils.utils.UtilConstants.STARTED_LOG_INFO; | 106 | import static org.onosproject.yangutils.utils.UtilConstants.STARTED_LOG_INFO; |
... | @@ -113,7 +118,6 @@ import static org.onosproject.yangutils.utils.UtilConstants.TWELVE_SPACE_INDENTA | ... | @@ -113,7 +118,6 @@ import static org.onosproject.yangutils.utils.UtilConstants.TWELVE_SPACE_INDENTA |
113 | import static org.onosproject.yangutils.utils.UtilConstants.VALUE; | 118 | import static org.onosproject.yangutils.utils.UtilConstants.VALUE; |
114 | import static org.onosproject.yangutils.utils.UtilConstants.VOID; | 119 | import static org.onosproject.yangutils.utils.UtilConstants.VOID; |
115 | import static org.onosproject.yangutils.utils.UtilConstants.YANG_UTILS_TODO; | 120 | import static org.onosproject.yangutils.utils.UtilConstants.YANG_UTILS_TODO; |
116 | -import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.getJavaDoc; | ||
117 | import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.JavaDocType.BUILD_METHOD; | 121 | import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.JavaDocType.BUILD_METHOD; |
118 | import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.JavaDocType.CONSTRUCTOR; | 122 | import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.JavaDocType.CONSTRUCTOR; |
119 | import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.JavaDocType.DEFAULT_CONSTRUCTOR; | 123 | import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.JavaDocType.DEFAULT_CONSTRUCTOR; |
... | @@ -123,6 +127,10 @@ import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.JavaDocType.MAN | ... | @@ -123,6 +127,10 @@ import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.JavaDocType.MAN |
123 | import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.JavaDocType.OF_METHOD; | 127 | import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.JavaDocType.OF_METHOD; |
124 | import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.JavaDocType.SETTER_METHOD; | 128 | import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.JavaDocType.SETTER_METHOD; |
125 | import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.JavaDocType.TYPE_CONSTRUCTOR; | 129 | import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.JavaDocType.TYPE_CONSTRUCTOR; |
130 | +import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.getJavaDoc; | ||
131 | +import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getCamelCase; | ||
132 | +import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getCapitalCase; | ||
133 | +import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getSmallCase; | ||
126 | import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.trimAtLast; | 134 | import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.trimAtLast; |
127 | 135 | ||
128 | /** | 136 | /** |
... | @@ -139,7 +147,7 @@ public final class MethodsGenerator { | ... | @@ -139,7 +147,7 @@ public final class MethodsGenerator { |
139 | /** | 147 | /** |
140 | * Returns the methods strings for builder interface. | 148 | * Returns the methods strings for builder interface. |
141 | * | 149 | * |
142 | - * @param name attribute name | 150 | + * @param name attribute name |
143 | * @param pluginConfig plugin configurations | 151 | * @param pluginConfig plugin configurations |
144 | * @return method string for builder interface | 152 | * @return method string for builder interface |
145 | */ | 153 | */ |
... | @@ -150,13 +158,13 @@ public final class MethodsGenerator { | ... | @@ -150,13 +158,13 @@ public final class MethodsGenerator { |
150 | /** | 158 | /** |
151 | * Returns getter string. | 159 | * Returns getter string. |
152 | * | 160 | * |
153 | - * @param attr attribute info | 161 | + * @param attr attribute info |
154 | * @param generatedJavaFiles generated java files | 162 | * @param generatedJavaFiles generated java files |
155 | - * @param pluginConfig plugin configurations | 163 | + * @param pluginConfig plugin configurations |
156 | * @return getter string | 164 | * @return getter string |
157 | */ | 165 | */ |
158 | public static String getGetterString(JavaAttributeInfo attr, int generatedJavaFiles, | 166 | public static String getGetterString(JavaAttributeInfo attr, int generatedJavaFiles, |
159 | - YangPluginConfig pluginConfig) { | 167 | + YangPluginConfig pluginConfig) { |
160 | 168 | ||
161 | String returnType = getReturnType(attr); | 169 | String returnType = getReturnType(attr); |
162 | String attributeName = attr.getAttributeName(); | 170 | String attributeName = attr.getAttributeName(); |
... | @@ -168,14 +176,14 @@ public final class MethodsGenerator { | ... | @@ -168,14 +176,14 @@ public final class MethodsGenerator { |
168 | /** | 176 | /** |
169 | * Returns setter string. | 177 | * Returns setter string. |
170 | * | 178 | * |
171 | - * @param attr attribute info | 179 | + * @param attr attribute info |
172 | - * @param className java class name | 180 | + * @param className java class name |
173 | * @param generatedJavaFiles generated java files | 181 | * @param generatedJavaFiles generated java files |
174 | - * @param pluginConfig plugin configurations | 182 | + * @param pluginConfig plugin configurations |
175 | * @return setter string | 183 | * @return setter string |
176 | */ | 184 | */ |
177 | public static String getSetterString(JavaAttributeInfo attr, String className, int generatedJavaFiles, | 185 | public static String getSetterString(JavaAttributeInfo attr, String className, int generatedJavaFiles, |
178 | - YangPluginConfig pluginConfig) { | 186 | + YangPluginConfig pluginConfig) { |
179 | 187 | ||
180 | String attrType = getReturnType(attr); | 188 | String attrType = getReturnType(attr); |
181 | String attributeName = attr.getAttributeName(); | 189 | String attributeName = attr.getAttributeName(); |
... | @@ -193,7 +201,7 @@ public final class MethodsGenerator { | ... | @@ -193,7 +201,7 @@ public final class MethodsGenerator { |
193 | /** | 201 | /** |
194 | * Returns constructor method string. | 202 | * Returns constructor method string. |
195 | * | 203 | * |
196 | - * @param name class name | 204 | + * @param name class name |
197 | * @param pluginConfig plugin configurations | 205 | * @param pluginConfig plugin configurations |
198 | * @return constructor string | 206 | * @return constructor string |
199 | */ | 207 | */ |
... | @@ -204,13 +212,13 @@ public final class MethodsGenerator { | ... | @@ -204,13 +212,13 @@ public final class MethodsGenerator { |
204 | /** | 212 | /** |
205 | * Returns default constructor method string. | 213 | * Returns default constructor method string. |
206 | * | 214 | * |
207 | - * @param name class name | 215 | + * @param name class name |
208 | * @param modifierType modifier type | 216 | * @param modifierType modifier type |
209 | * @param pluginConfig plugin configurations | 217 | * @param pluginConfig plugin configurations |
210 | * @return default constructor string | 218 | * @return default constructor string |
211 | */ | 219 | */ |
212 | public static String getDefaultConstructorString(String name, String modifierType, | 220 | public static String getDefaultConstructorString(String name, String modifierType, |
213 | - YangPluginConfig pluginConfig) { | 221 | + YangPluginConfig pluginConfig) { |
214 | return getJavaDoc(DEFAULT_CONSTRUCTOR, name, false, pluginConfig) | 222 | return getJavaDoc(DEFAULT_CONSTRUCTOR, name, false, pluginConfig) |
215 | + getDefaultConstructor(name, modifierType) | 223 | + getDefaultConstructor(name, modifierType) |
216 | + NEW_LINE; | 224 | + NEW_LINE; |
... | @@ -240,7 +248,7 @@ public final class MethodsGenerator { | ... | @@ -240,7 +248,7 @@ public final class MethodsGenerator { |
240 | /** | 248 | /** |
241 | * Returns the getter method strings for class file. | 249 | * Returns the getter method strings for class file. |
242 | * | 250 | * |
243 | - * @param attr attribute info | 251 | + * @param attr attribute info |
244 | * @param generatedJavaFiles for the type of java file being generated | 252 | * @param generatedJavaFiles for the type of java file being generated |
245 | * @return getter method for class | 253 | * @return getter method for class |
246 | */ | 254 | */ |
... | @@ -259,8 +267,8 @@ public final class MethodsGenerator { | ... | @@ -259,8 +267,8 @@ public final class MethodsGenerator { |
259 | /** | 267 | /** |
260 | * Returns getter for attribute. | 268 | * Returns getter for attribute. |
261 | * | 269 | * |
262 | - * @param type return type | 270 | + * @param type return type |
263 | - * @param name attribute name | 271 | + * @param name attribute name |
264 | * @param generatedJavaFiles generated java files | 272 | * @param generatedJavaFiles generated java files |
265 | * @return getter for attribute | 273 | * @return getter for attribute |
266 | */ | 274 | */ |
... | @@ -283,23 +291,23 @@ public final class MethodsGenerator { | ... | @@ -283,23 +291,23 @@ public final class MethodsGenerator { |
283 | /*Provides string to return for type.*/ | 291 | /*Provides string to return for type.*/ |
284 | private static String parseTypeForReturnValue(String type) { | 292 | private static String parseTypeForReturnValue(String type) { |
285 | switch (type) { | 293 | switch (type) { |
286 | - case BYTE: | 294 | + case BYTE: |
287 | - case INT: | 295 | + case INT: |
288 | - case SHORT: | 296 | + case SHORT: |
289 | - case LONG: | 297 | + case LONG: |
290 | - return "0"; | 298 | + return "0"; |
291 | - case BOOLEAN_DATA_TYPE: | 299 | + case BOOLEAN_DATA_TYPE: |
292 | - return FALSE; | 300 | + return FALSE; |
293 | - default: | 301 | + default: |
294 | - return null; | 302 | + return null; |
295 | } | 303 | } |
296 | } | 304 | } |
297 | 305 | ||
298 | /** | 306 | /** |
299 | * Returns the setter method strings for class file. | 307 | * Returns the setter method strings for class file. |
300 | * | 308 | * |
301 | - * @param attr attribute info | 309 | + * @param attr attribute info |
302 | - * @param className name of the class | 310 | + * @param className name of the class |
303 | * @param generatedJavaFiles generated java files | 311 | * @param generatedJavaFiles generated java files |
304 | * @return setter method for class | 312 | * @return setter method for class |
305 | */ | 313 | */ |
... | @@ -318,8 +326,8 @@ public final class MethodsGenerator { | ... | @@ -318,8 +326,8 @@ public final class MethodsGenerator { |
318 | * Returns setter for attribute. | 326 | * Returns setter for attribute. |
319 | * | 327 | * |
320 | * @param className class name | 328 | * @param className class name |
321 | - * @param name attribute name | 329 | + * @param name attribute name |
322 | - * @param type return type | 330 | + * @param type return type |
323 | * @return setter for attribute | 331 | * @return setter for attribute |
324 | */ | 332 | */ |
325 | private static String getSetter(String className, String name, String type, int generatedJavaFiles) { | 333 | private static String getSetter(String className, String name, String type, int generatedJavaFiles) { |
... | @@ -381,14 +389,14 @@ public final class MethodsGenerator { | ... | @@ -381,14 +389,14 @@ public final class MethodsGenerator { |
381 | /** | 389 | /** |
382 | * Returns the getter method strings for interface file. | 390 | * Returns the getter method strings for interface file. |
383 | * | 391 | * |
384 | - * @param yangName name of the attribute | 392 | + * @param yangName name of the attribute |
385 | - * @param returnType return type of attribute | 393 | + * @param returnType return type of attribute |
386 | - * @param isList is list attribute | 394 | + * @param isList is list attribute |
387 | * @param generatedJavaFiles generated java files | 395 | * @param generatedJavaFiles generated java files |
388 | * @return getter method for interface | 396 | * @return getter method for interface |
389 | */ | 397 | */ |
390 | public static String getGetterForInterface(String yangName, String returnType, boolean isList, | 398 | public static String getGetterForInterface(String yangName, String returnType, boolean isList, |
391 | - int generatedJavaFiles) { | 399 | + int generatedJavaFiles) { |
392 | 400 | ||
393 | if (!isList) { | 401 | if (!isList) { |
394 | return getGetterInterfaceString(returnType, yangName, generatedJavaFiles); | 402 | return getGetterInterfaceString(returnType, yangName, generatedJavaFiles); |
... | @@ -401,11 +409,11 @@ public final class MethodsGenerator { | ... | @@ -401,11 +409,11 @@ public final class MethodsGenerator { |
401 | * Returns getter for attribute in interface. | 409 | * Returns getter for attribute in interface. |
402 | * | 410 | * |
403 | * @param returnType return type | 411 | * @param returnType return type |
404 | - * @param yangName attribute name | 412 | + * @param yangName attribute name |
405 | * @return getter for interface | 413 | * @return getter for interface |
406 | */ | 414 | */ |
407 | private static String getGetterInterfaceString(String returnType, String yangName, | 415 | private static String getGetterInterfaceString(String returnType, String yangName, |
408 | - int generatedJavaFiles) { | 416 | + int generatedJavaFiles) { |
409 | if ((generatedJavaFiles & GENERATE_SERVICE_AND_MANAGER) != 0) { | 417 | if ((generatedJavaFiles & GENERATE_SERVICE_AND_MANAGER) != 0) { |
410 | return FOUR_SPACE_INDENTATION + returnType + SPACE + GET_METHOD_PREFIX + getCapitalCase(yangName) | 418 | return FOUR_SPACE_INDENTATION + returnType + SPACE + GET_METHOD_PREFIX + getCapitalCase(yangName) |
411 | + OPEN_PARENTHESIS + CLOSE_PARENTHESIS + SEMI_COLAN; | 419 | + OPEN_PARENTHESIS + CLOSE_PARENTHESIS + SEMI_COLAN; |
... | @@ -418,15 +426,15 @@ public final class MethodsGenerator { | ... | @@ -418,15 +426,15 @@ public final class MethodsGenerator { |
418 | /** | 426 | /** |
419 | * Returns the setter method strings for interface file. | 427 | * Returns the setter method strings for interface file. |
420 | * | 428 | * |
421 | - * @param attrName name of the attribute | 429 | + * @param attrName name of the attribute |
422 | - * @param attrType return type of attribute | 430 | + * @param attrType return type of attribute |
423 | - * @param className name of the java class being generated | 431 | + * @param className name of the java class being generated |
424 | - * @param isList is list attribute | 432 | + * @param isList is list attribute |
425 | * @param generatedJavaFiles generated java files | 433 | * @param generatedJavaFiles generated java files |
426 | * @return setter method for interface | 434 | * @return setter method for interface |
427 | */ | 435 | */ |
428 | public static String getSetterForInterface(String attrName, String attrType, String className, | 436 | public static String getSetterForInterface(String attrName, String attrType, String className, |
429 | - boolean isList, int generatedJavaFiles) { | 437 | + boolean isList, int generatedJavaFiles) { |
430 | 438 | ||
431 | if (!isList) { | 439 | if (!isList) { |
432 | return getSetterInterfaceString(className, attrName, attrType, generatedJavaFiles); | 440 | return getSetterInterfaceString(className, attrName, attrType, generatedJavaFiles); |
... | @@ -439,12 +447,12 @@ public final class MethodsGenerator { | ... | @@ -439,12 +447,12 @@ public final class MethodsGenerator { |
439 | * Returns setter string for interface. | 447 | * Returns setter string for interface. |
440 | * | 448 | * |
441 | * @param className class name | 449 | * @param className class name |
442 | - * @param attrName attribute name | 450 | + * @param attrName attribute name |
443 | - * @param attrType attribute type | 451 | + * @param attrType attribute type |
444 | * @return setter string | 452 | * @return setter string |
445 | */ | 453 | */ |
446 | private static String getSetterInterfaceString(String className, String attrName, String attrType, | 454 | private static String getSetterInterfaceString(String className, String attrName, String attrType, |
447 | - int generatedJavaFiles) { | 455 | + int generatedJavaFiles) { |
448 | if ((generatedJavaFiles & GENERATE_SERVICE_AND_MANAGER) != 0) { | 456 | if ((generatedJavaFiles & GENERATE_SERVICE_AND_MANAGER) != 0) { |
449 | 457 | ||
450 | return FOUR_SPACE_INDENTATION + VOID + SPACE + SET_METHOD_PREFIX + getCapitalCase(attrName) | 458 | return FOUR_SPACE_INDENTATION + VOID + SPACE + SET_METHOD_PREFIX + getCapitalCase(attrName) |
... | @@ -494,7 +502,7 @@ public final class MethodsGenerator { | ... | @@ -494,7 +502,7 @@ public final class MethodsGenerator { |
494 | /** | 502 | /** |
495 | * Returns constructor string for impl class. | 503 | * Returns constructor string for impl class. |
496 | * | 504 | * |
497 | - * @param yangName class name | 505 | + * @param yangName class name |
498 | * @param pluginConfig plugin configurations | 506 | * @param pluginConfig plugin configurations |
499 | * @return constructor string | 507 | * @return constructor string |
500 | */ | 508 | */ |
... | @@ -512,14 +520,14 @@ public final class MethodsGenerator { | ... | @@ -512,14 +520,14 @@ public final class MethodsGenerator { |
512 | /** | 520 | /** |
513 | * Returns the constructor strings for class file. | 521 | * Returns the constructor strings for class file. |
514 | * | 522 | * |
515 | - * @param yangName name of the class | 523 | + * @param yangName name of the class |
516 | - * @param attr attribute info | 524 | + * @param attr attribute info |
517 | * @param generatedJavaFiles generated java files | 525 | * @param generatedJavaFiles generated java files |
518 | - * @param pluginConfig plugin configurations | 526 | + * @param pluginConfig plugin configurations |
519 | * @return constructor for class | 527 | * @return constructor for class |
520 | */ | 528 | */ |
521 | public static String getConstructor(String yangName, JavaAttributeInfo attr, int generatedJavaFiles, | 529 | public static String getConstructor(String yangName, JavaAttributeInfo attr, int generatedJavaFiles, |
522 | - YangPluginConfig pluginConfig) { | 530 | + YangPluginConfig pluginConfig) { |
523 | 531 | ||
524 | String attributeName = attr.getAttributeName(); | 532 | String attributeName = attr.getAttributeName(); |
525 | String constructor; | 533 | String constructor; |
... | @@ -545,14 +553,14 @@ public final class MethodsGenerator { | ... | @@ -545,14 +553,14 @@ public final class MethodsGenerator { |
545 | /** | 553 | /** |
546 | * Returns the rpc strings for service interface. | 554 | * Returns the rpc strings for service interface. |
547 | * | 555 | * |
548 | - * @param rpcName name of the rpc | 556 | + * @param rpcName name of the rpc |
549 | - * @param inputName name of input | 557 | + * @param inputName name of input |
550 | - * @param outputName name of output | 558 | + * @param outputName name of output |
551 | * @param pluginConfig plugin configurations | 559 | * @param pluginConfig plugin configurations |
552 | * @return rpc method string | 560 | * @return rpc method string |
553 | */ | 561 | */ |
554 | public static String getRpcServiceMethod(String rpcName, String inputName, String outputName, | 562 | public static String getRpcServiceMethod(String rpcName, String inputName, String outputName, |
555 | - YangPluginConfig pluginConfig) { | 563 | + YangPluginConfig pluginConfig) { |
556 | 564 | ||
557 | rpcName = getCamelCase(rpcName, pluginConfig.getConflictResolver()); | 565 | rpcName = getCamelCase(rpcName, pluginConfig.getConflictResolver()); |
558 | if (!inputName.equals(EMPTY_STRING)) { | 566 | if (!inputName.equals(EMPTY_STRING)) { |
... | @@ -565,14 +573,14 @@ public final class MethodsGenerator { | ... | @@ -565,14 +573,14 @@ public final class MethodsGenerator { |
565 | /** | 573 | /** |
566 | * Returns the rpc strings for manager impl. | 574 | * Returns the rpc strings for manager impl. |
567 | * | 575 | * |
568 | - * @param rpcName name of the rpc | 576 | + * @param rpcName name of the rpc |
569 | - * @param inputName name of input | 577 | + * @param inputName name of input |
570 | - * @param outputName name of output | 578 | + * @param outputName name of output |
571 | * @param pluginConfig plugin configurations | 579 | * @param pluginConfig plugin configurations |
572 | * @return rpc method string | 580 | * @return rpc method string |
573 | */ | 581 | */ |
574 | public static String getRpcManagerMethod(String rpcName, String inputName, String outputName, | 582 | public static String getRpcManagerMethod(String rpcName, String inputName, String outputName, |
575 | - YangPluginConfig pluginConfig) { | 583 | + YangPluginConfig pluginConfig) { |
576 | 584 | ||
577 | rpcName = getCamelCase(rpcName, pluginConfig.getConflictResolver()); | 585 | rpcName = getCamelCase(rpcName, pluginConfig.getConflictResolver()); |
578 | if (!inputName.equals(EMPTY_STRING)) { | 586 | if (!inputName.equals(EMPTY_STRING)) { |
... | @@ -608,7 +616,7 @@ public final class MethodsGenerator { | ... | @@ -608,7 +616,7 @@ public final class MethodsGenerator { |
608 | /** | 616 | /** |
609 | * Returns the Default constructor strings for class file. | 617 | * Returns the Default constructor strings for class file. |
610 | * | 618 | * |
611 | - * @param name name of the class | 619 | + * @param name name of the class |
612 | * @param modifierType modifier type for default constructor | 620 | * @param modifierType modifier type for default constructor |
613 | * @return Default constructor for class | 621 | * @return Default constructor for class |
614 | */ | 622 | */ |
... | @@ -663,7 +671,7 @@ public final class MethodsGenerator { | ... | @@ -663,7 +671,7 @@ public final class MethodsGenerator { |
663 | /** | 671 | /** |
664 | * Returns from string method's open string. | 672 | * Returns from string method's open string. |
665 | * | 673 | * |
666 | - * @param className name of the class | 674 | + * @param className name of the class |
667 | * @param pluginConfig plugin configurations | 675 | * @param pluginConfig plugin configurations |
668 | * @return from string method's open string | 676 | * @return from string method's open string |
669 | */ | 677 | */ |
... | @@ -687,13 +695,13 @@ public final class MethodsGenerator { | ... | @@ -687,13 +695,13 @@ public final class MethodsGenerator { |
687 | /** | 695 | /** |
688 | * Return from string method's body string. | 696 | * Return from string method's body string. |
689 | * | 697 | * |
690 | - * @param attr attribute info | 698 | + * @param attr attribute info |
691 | * @param fromStringAttributeInfo attribute info for the from string | 699 | * @param fromStringAttributeInfo attribute info for the from string |
692 | - * wrapper type | 700 | + * wrapper type |
693 | * @return from string method's body string | 701 | * @return from string method's body string |
694 | */ | 702 | */ |
695 | public static String getFromStringMethod(JavaAttributeInfo attr, | 703 | public static String getFromStringMethod(JavaAttributeInfo attr, |
696 | - JavaAttributeInfo fromStringAttributeInfo) { | 704 | + JavaAttributeInfo fromStringAttributeInfo) { |
697 | 705 | ||
698 | return EIGHT_SPACE_INDENTATION + getTrySubString() + NEW_LINE + TWELVE_SPACE_INDENTATION | 706 | return EIGHT_SPACE_INDENTATION + getTrySubString() + NEW_LINE + TWELVE_SPACE_INDENTATION |
699 | + getParsedSubString(attr, fromStringAttributeInfo) + SEMI_COLAN + NEW_LINE + TWELVE_SPACE_INDENTATION | 707 | + getParsedSubString(attr, fromStringAttributeInfo) + SEMI_COLAN + NEW_LINE + TWELVE_SPACE_INDENTATION |
... | @@ -736,7 +744,7 @@ public final class MethodsGenerator { | ... | @@ -736,7 +744,7 @@ public final class MethodsGenerator { |
736 | * @return sub string with parsed statement for union's from string method | 744 | * @return sub string with parsed statement for union's from string method |
737 | */ | 745 | */ |
738 | private static String getParsedSubString(JavaAttributeInfo attr, | 746 | private static String getParsedSubString(JavaAttributeInfo attr, |
739 | - JavaAttributeInfo fromStringAttributeInfo) { | 747 | + JavaAttributeInfo fromStringAttributeInfo) { |
740 | 748 | ||
741 | String targetDataType = getReturnType(attr); | 749 | String targetDataType = getReturnType(attr); |
742 | String parseFromStringMethod = getParseFromStringMethod(targetDataType, | 750 | String parseFromStringMethod = getParseFromStringMethod(targetDataType, |
... | @@ -865,13 +873,13 @@ public final class MethodsGenerator { | ... | @@ -865,13 +873,13 @@ public final class MethodsGenerator { |
865 | /** | 873 | /** |
866 | * Returns of method's string and java doc for special type. | 874 | * Returns of method's string and java doc for special type. |
867 | * | 875 | * |
868 | - * @param attr attribute info | 876 | + * @param attr attribute info |
869 | * @param generatedJavaClassName class name | 877 | * @param generatedJavaClassName class name |
870 | - * @param pluginConfig plugin configurations | 878 | + * @param pluginConfig plugin configurations |
871 | * @return of method's string and java doc for special type | 879 | * @return of method's string and java doc for special type |
872 | */ | 880 | */ |
873 | public static String getOfMethodStringAndJavaDoc(JavaAttributeInfo attr, String generatedJavaClassName, | 881 | public static String getOfMethodStringAndJavaDoc(JavaAttributeInfo attr, String generatedJavaClassName, |
874 | - YangPluginConfig pluginConfig) { | 882 | + YangPluginConfig pluginConfig) { |
875 | 883 | ||
876 | String attrType = getReturnType(attr); | 884 | String attrType = getReturnType(attr); |
877 | String attrName = attr.getAttributeName(); | 885 | String attrName = attr.getAttributeName(); |
... | @@ -883,7 +891,7 @@ public final class MethodsGenerator { | ... | @@ -883,7 +891,7 @@ public final class MethodsGenerator { |
883 | /** | 891 | /** |
884 | * Returns of method's string. | 892 | * Returns of method's string. |
885 | * | 893 | * |
886 | - * @param type data type | 894 | + * @param type data type |
887 | * @param className class name | 895 | * @param className class name |
888 | * @return of method's string | 896 | * @return of method's string |
889 | */ | 897 | */ |
... | @@ -898,13 +906,14 @@ public final class MethodsGenerator { | ... | @@ -898,13 +906,14 @@ public final class MethodsGenerator { |
898 | /** | 906 | /** |
899 | * Returns string and java doc for constructor of type class. | 907 | * Returns string and java doc for constructor of type class. |
900 | * | 908 | * |
901 | - * @param attr attribute info | 909 | + * @param attr attribute info |
902 | * @param generatedJavaClassName class name | 910 | * @param generatedJavaClassName class name |
903 | - * @param pluginConfig plugin configurations | 911 | + * @param pluginConfig plugin configurations |
904 | * @return string and java doc for constructor of type class | 912 | * @return string and java doc for constructor of type class |
905 | */ | 913 | */ |
906 | public static String getTypeConstructorStringAndJavaDoc(JavaAttributeInfo attr, | 914 | public static String getTypeConstructorStringAndJavaDoc(JavaAttributeInfo attr, |
907 | - String generatedJavaClassName, YangPluginConfig pluginConfig) { | 915 | + String generatedJavaClassName, |
916 | + YangPluginConfig pluginConfig) { | ||
908 | 917 | ||
909 | String attrType = getReturnType(attr); | 918 | String attrType = getReturnType(attr); |
910 | String attrName = attr.getAttributeName(); | 919 | String attrName = attr.getAttributeName(); |
... | @@ -916,8 +925,8 @@ public final class MethodsGenerator { | ... | @@ -916,8 +925,8 @@ public final class MethodsGenerator { |
916 | /** | 925 | /** |
917 | * Returns type constructor string. | 926 | * Returns type constructor string. |
918 | * | 927 | * |
919 | - * @param type data type | 928 | + * @param type data type |
920 | - * @param name attribute name | 929 | + * @param name attribute name |
921 | * @param className class name | 930 | * @param className class name |
922 | * @return type constructor string | 931 | * @return type constructor string |
923 | */ | 932 | */ |
... | @@ -989,47 +998,18 @@ public final class MethodsGenerator { | ... | @@ -989,47 +998,18 @@ public final class MethodsGenerator { |
989 | } | 998 | } |
990 | 999 | ||
991 | /** | 1000 | /** |
992 | - * Provides string to be added in augment node's constructor. | ||
993 | - * | ||
994 | - * @param curNode current YANG node | ||
995 | - * @return constructors string | ||
996 | - */ | ||
997 | - public static String getAugmentsAddToAugmentedMethod(YangNode curNode) { | ||
998 | - | ||
999 | - if (!(curNode instanceof YangJavaAugment)) { | ||
1000 | - throw new TranslatorException("current node should be of type augment node."); | ||
1001 | - } | ||
1002 | - YangJavaAugment augment = (YangJavaAugment) curNode; | ||
1003 | - List<YangNodeIdentifier> targetNodes = augment.getTargetNode(); | ||
1004 | - | ||
1005 | - String name = targetNodes.get(targetNodes.size() - 1).getName(); | ||
1006 | - String captialCase = getCapitalCase(name); | ||
1007 | - String smallCase = getSmallCase(captialCase); | ||
1008 | - return EIGHT_SPACE_INDENTATION + captialCase + IMPL + SPACE + smallCase + IMPL + SPACE + EQUAL + SPACE | ||
1009 | - + NEW + SPACE + captialCase + BUILDER + OPEN_PARENTHESIS + CLOSE_PARENTHESIS + PERIOD + NEW + SPACE | ||
1010 | - + captialCase + IMPL + OPEN_PARENTHESIS + CLOSE_PARENTHESIS + SEMI_COLAN + NEW_LINE | ||
1011 | - + EIGHT_SPACE_INDENTATION + smallCase + IMPL + PERIOD + ADD_STRING + AUGMENTATION | ||
1012 | - + OPEN_PARENTHESIS + THIS + CLOSE_PARENTHESIS + SEMI_COLAN + NEW_LINE; | ||
1013 | - | ||
1014 | - } | ||
1015 | - | ||
1016 | - private static String getAugmentsAddToAugmentedMethodStart() { | ||
1017 | - return FOUR_SPACE_INDENTATION + PUBLIC + SPACE + VOID + SPACE + ADD_STRING + AUGMENTABLE + OPEN_PARENTHESIS | ||
1018 | - + CLOSE_PARENTHESIS + SPACE + OPEN_CURLY_BRACKET; | ||
1019 | - } | ||
1020 | - | ||
1021 | - /** | ||
1022 | * Returns of method for enum class. | 1001 | * Returns of method for enum class. |
1023 | * | 1002 | * |
1024 | - * @param className class name | 1003 | + * @param className class name |
1025 | - * @param attr java attribute | 1004 | + * @param attr java attribute |
1026 | - * @param enumMap enum's sets map | 1005 | + * @param enumMap enum's sets map |
1027 | - * @param enumList enum's sets list | 1006 | + * @param enumList enum's sets list |
1028 | * @param pluginConfig plugin configurations | 1007 | * @param pluginConfig plugin configurations |
1029 | * @return of method | 1008 | * @return of method |
1030 | */ | 1009 | */ |
1031 | public static String getEnumsOfMethod(String className, JavaAttributeInfo attr, | 1010 | public static String getEnumsOfMethod(String className, JavaAttributeInfo attr, |
1032 | - Map<String, Integer> enumMap, List<String> enumList, YangPluginConfig pluginConfig) { | 1011 | + Map<String, Integer> enumMap, List<String> enumList, |
1012 | + YangPluginConfig pluginConfig) { | ||
1033 | String attrType = getReturnType(attr); | 1013 | String attrType = getReturnType(attr); |
1034 | String attrName = attr.getAttributeName(); | 1014 | String attrName = attr.getAttributeName(); |
1035 | 1015 | ||
... | @@ -1083,4 +1063,48 @@ public final class MethodsGenerator { | ... | @@ -1083,4 +1063,48 @@ public final class MethodsGenerator { |
1083 | + STOPPED_LOG_INFO + FOUR_SPACE_INDENTATION + CLOSE_CURLY_BRACKET + NEW_LINE; | 1063 | + STOPPED_LOG_INFO + FOUR_SPACE_INDENTATION + CLOSE_CURLY_BRACKET + NEW_LINE; |
1084 | } | 1064 | } |
1085 | 1065 | ||
1066 | + /** | ||
1067 | + * Returns from string method parsed string. | ||
1068 | + * | ||
1069 | + * @param targetDataType target data type | ||
1070 | + * @param yangType YANG type | ||
1071 | + * @return parsed string | ||
1072 | + */ | ||
1073 | + public static String getParseFromStringMethod(String targetDataType, YangType<?> yangType) { | ||
1074 | + | ||
1075 | + YangDataTypes type = yangType.getDataType(); | ||
1076 | + | ||
1077 | + switch (type) { | ||
1078 | + case INT8: | ||
1079 | + return BYTE_WRAPPER + PERIOD + PARSE_BYTE; | ||
1080 | + case INT16: | ||
1081 | + return SHORT_WRAPPER + PERIOD + PARSE_SHORT; | ||
1082 | + case INT32: | ||
1083 | + return INTEGER_WRAPPER + PERIOD + PARSE_INT; | ||
1084 | + case INT64: | ||
1085 | + return LONG_WRAPPER + PERIOD + PARSE_LONG; | ||
1086 | + case UINT8: | ||
1087 | + return SHORT_WRAPPER + PERIOD + PARSE_SHORT; | ||
1088 | + case UINT16: | ||
1089 | + return INTEGER_WRAPPER + PERIOD + PARSE_INT; | ||
1090 | + case UINT32: | ||
1091 | + return LONG_WRAPPER + PERIOD + PARSE_LONG; | ||
1092 | + case UINT64: | ||
1093 | + return NEW + SPACE + BIG_INTEGER; | ||
1094 | + case STRING: | ||
1095 | + return EMPTY_STRING; | ||
1096 | + case EMPTY: | ||
1097 | + case BOOLEAN: | ||
1098 | + return BOOLEAN_WRAPPER + PERIOD + PARSE_BOOLEAN; | ||
1099 | + case DECIMAL64: | ||
1100 | + case BITS: | ||
1101 | + case BINARY: | ||
1102 | + case UNION: | ||
1103 | + case ENUMERATION: | ||
1104 | + case DERIVED: | ||
1105 | + return targetDataType + PERIOD + FROM_STRING_METHOD_NAME; | ||
1106 | + default: | ||
1107 | + throw new TranslatorException("given data type is not supported."); | ||
1108 | + } | ||
1109 | + } | ||
1086 | } | 1110 | } | ... | ... |
... | @@ -19,51 +19,29 @@ package org.onosproject.yangutils.translator.tojava.utils; | ... | @@ -19,51 +19,29 @@ package org.onosproject.yangutils.translator.tojava.utils; |
19 | import java.io.File; | 19 | import java.io.File; |
20 | import java.io.IOException; | 20 | import java.io.IOException; |
21 | import java.util.List; | 21 | import java.util.List; |
22 | - | ||
23 | import org.onosproject.yangutils.datamodel.YangNode; | 22 | import org.onosproject.yangutils.datamodel.YangNode; |
24 | -import org.onosproject.yangutils.datamodel.YangNodeIdentifier; | ||
25 | -import org.onosproject.yangutils.translator.exception.TranslatorException; | ||
26 | -import org.onosproject.yangutils.translator.tojava.JavaFileInfoContainer; | ||
27 | import org.onosproject.yangutils.translator.tojava.JavaQualifiedTypeInfo; | 23 | import org.onosproject.yangutils.translator.tojava.JavaQualifiedTypeInfo; |
28 | import org.onosproject.yangutils.translator.tojava.TempJavaCodeFragmentFiles; | 24 | import org.onosproject.yangutils.translator.tojava.TempJavaCodeFragmentFiles; |
29 | import org.onosproject.yangutils.translator.tojava.TempJavaCodeFragmentFilesContainer; | 25 | import org.onosproject.yangutils.translator.tojava.TempJavaCodeFragmentFilesContainer; |
30 | import org.onosproject.yangutils.translator.tojava.TempJavaFragmentFiles; | 26 | import org.onosproject.yangutils.translator.tojava.TempJavaFragmentFiles; |
31 | -import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaAugment; | ||
32 | -import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaModule; | ||
33 | 27 | ||
34 | -import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getCapitalCase; | ||
35 | -import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getSmallCase; | ||
36 | import static org.onosproject.yangutils.utils.UtilConstants.ACTIVATE_ANNOTATION_IMPORT; | 28 | import static org.onosproject.yangutils.utils.UtilConstants.ACTIVATE_ANNOTATION_IMPORT; |
37 | -import static org.onosproject.yangutils.utils.UtilConstants.ADD_STRING; | ||
38 | -import static org.onosproject.yangutils.utils.UtilConstants.AUGMENTATION; | ||
39 | import static org.onosproject.yangutils.utils.UtilConstants.AUGMENTATION_HOLDER; | 29 | import static org.onosproject.yangutils.utils.UtilConstants.AUGMENTATION_HOLDER; |
40 | import static org.onosproject.yangutils.utils.UtilConstants.AUGMENTED_INFO; | 30 | import static org.onosproject.yangutils.utils.UtilConstants.AUGMENTED_INFO; |
41 | -import static org.onosproject.yangutils.utils.UtilConstants.BUILDER; | ||
42 | -import static org.onosproject.yangutils.utils.UtilConstants.CLOSE_PARENTHESIS; | ||
43 | import static org.onosproject.yangutils.utils.UtilConstants.COMPONENT_ANNOTATION_IMPORT; | 31 | import static org.onosproject.yangutils.utils.UtilConstants.COMPONENT_ANNOTATION_IMPORT; |
44 | import static org.onosproject.yangutils.utils.UtilConstants.DEACTIVATE_ANNOTATION_IMPORT; | 32 | import static org.onosproject.yangutils.utils.UtilConstants.DEACTIVATE_ANNOTATION_IMPORT; |
45 | -import static org.onosproject.yangutils.utils.UtilConstants.EIGHT_SPACE_INDENTATION; | ||
46 | import static org.onosproject.yangutils.utils.UtilConstants.ENUM; | 33 | import static org.onosproject.yangutils.utils.UtilConstants.ENUM; |
47 | -import static org.onosproject.yangutils.utils.UtilConstants.EQUAL; | ||
48 | import static org.onosproject.yangutils.utils.UtilConstants.FOUR_SPACE_INDENTATION; | 34 | import static org.onosproject.yangutils.utils.UtilConstants.FOUR_SPACE_INDENTATION; |
49 | -import static org.onosproject.yangutils.utils.UtilConstants.IMPL; | ||
50 | -import static org.onosproject.yangutils.utils.UtilConstants.IMPORT; | ||
51 | import static org.onosproject.yangutils.utils.UtilConstants.LISTENER_SERVICE; | 35 | import static org.onosproject.yangutils.utils.UtilConstants.LISTENER_SERVICE; |
52 | import static org.onosproject.yangutils.utils.UtilConstants.LOGGER_FACTORY_IMPORT; | 36 | import static org.onosproject.yangutils.utils.UtilConstants.LOGGER_FACTORY_IMPORT; |
53 | import static org.onosproject.yangutils.utils.UtilConstants.LOGGER_IMPORT; | 37 | import static org.onosproject.yangutils.utils.UtilConstants.LOGGER_IMPORT; |
54 | -import static org.onosproject.yangutils.utils.UtilConstants.NEW; | ||
55 | import static org.onosproject.yangutils.utils.UtilConstants.NEW_LINE; | 38 | import static org.onosproject.yangutils.utils.UtilConstants.NEW_LINE; |
56 | import static org.onosproject.yangutils.utils.UtilConstants.OPEN_CURLY_BRACKET; | 39 | import static org.onosproject.yangutils.utils.UtilConstants.OPEN_CURLY_BRACKET; |
57 | -import static org.onosproject.yangutils.utils.UtilConstants.OPEN_PARENTHESIS; | ||
58 | -import static org.onosproject.yangutils.utils.UtilConstants.PERIOD; | ||
59 | import static org.onosproject.yangutils.utils.UtilConstants.PUBLIC; | 40 | import static org.onosproject.yangutils.utils.UtilConstants.PUBLIC; |
60 | -import static org.onosproject.yangutils.utils.UtilConstants.SEMI_COLAN; | ||
61 | import static org.onosproject.yangutils.utils.UtilConstants.SERVICE_ANNOTATION_IMPORT; | 41 | import static org.onosproject.yangutils.utils.UtilConstants.SERVICE_ANNOTATION_IMPORT; |
62 | import static org.onosproject.yangutils.utils.UtilConstants.SPACE; | 42 | import static org.onosproject.yangutils.utils.UtilConstants.SPACE; |
63 | -import static org.onosproject.yangutils.utils.UtilConstants.THIS; | ||
64 | import static org.onosproject.yangutils.utils.UtilConstants.TYPE; | 43 | import static org.onosproject.yangutils.utils.UtilConstants.TYPE; |
65 | import static org.onosproject.yangutils.utils.io.impl.FileSystemUtil.updateFileHandle; | 44 | import static org.onosproject.yangutils.utils.io.impl.FileSystemUtil.updateFileHandle; |
66 | - | ||
67 | import static java.util.Collections.sort; | 45 | import static java.util.Collections.sort; |
68 | 46 | ||
69 | /** | 47 | /** |
... | @@ -121,84 +99,6 @@ public final class TempJavaCodeFragmentFilesUtils { | ... | @@ -121,84 +99,6 @@ public final class TempJavaCodeFragmentFilesUtils { |
121 | } | 99 | } |
122 | 100 | ||
123 | /** | 101 | /** |
124 | - * Updated imports with augmented nodes import. | ||
125 | - * | ||
126 | - * @param curNode current YANG node | ||
127 | - * @param imports list of imports | ||
128 | - * @param operation to add or to delete | ||
129 | - */ | ||
130 | - public static void addAugmentedNodesImport(YangNode curNode, List<String> imports, boolean operation) { | ||
131 | - | ||
132 | - String nodesImport = ""; | ||
133 | - | ||
134 | - if (!(curNode instanceof YangJavaAugment)) { | ||
135 | - throw new TranslatorException("current node should be of type augment node."); | ||
136 | - } | ||
137 | - YangJavaAugment augment = (YangJavaAugment) curNode; | ||
138 | - List<YangNodeIdentifier> targetNodes = augment.getTargetNode(); | ||
139 | - YangNode parent = curNode.getParent(); | ||
140 | - if (parent instanceof YangJavaModule) { | ||
141 | - // Add impl class import. | ||
142 | - nodesImport = getAugmendtedNodesImports(parent, targetNodes, true) + SEMI_COLAN + NEW_LINE; | ||
143 | - performOperationOnImports(imports, nodesImport, operation); | ||
144 | - // Add builder class import. | ||
145 | - if (targetNodes.size() > 2) { | ||
146 | - nodesImport = getAugmendtedNodesImports(parent, targetNodes, false) + SEMI_COLAN + NEW_LINE; | ||
147 | - performOperationOnImports(imports, nodesImport, operation); | ||
148 | - } | ||
149 | - } | ||
150 | - // TODO: add functionality for submodule and uses. | ||
151 | - } | ||
152 | - | ||
153 | - /** | ||
154 | - * Returns imports for augmented node. | ||
155 | - * | ||
156 | - * @param parent parent YANG node | ||
157 | - * @param targetNodes list of target nodes | ||
158 | - * @param isImplClass if impl class's import required | ||
159 | - * @return imports for augmented node | ||
160 | - */ | ||
161 | - private static String getAugmendtedNodesImports(YangNode parent, List<YangNodeIdentifier> targetNodes, | ||
162 | - boolean isImplClass) { | ||
163 | - String pkgInfo = ((JavaFileInfoContainer) parent).getJavaFileInfo().getPackage(); | ||
164 | - | ||
165 | - for (int i = 0; i < targetNodes.size() - 1; i++) { | ||
166 | - pkgInfo = pkgInfo + PERIOD + targetNodes.get(i).getName(); | ||
167 | - } | ||
168 | - String classInfo = targetNodes.get(targetNodes.size() - 1).getName(); | ||
169 | - if (!isImplClass) { | ||
170 | - return IMPORT + pkgInfo.toLowerCase() + PERIOD + getCapitalCase(classInfo) + BUILDER; | ||
171 | - } | ||
172 | - return IMPORT + pkgInfo.toLowerCase() + PERIOD + getCapitalCase(classInfo) + BUILDER + PERIOD | ||
173 | - + getCapitalCase(classInfo) + IMPL; | ||
174 | - } | ||
175 | - | ||
176 | - /** | ||
177 | - * Provides string to be added in augment node's constructor. | ||
178 | - * | ||
179 | - * @param curNode current YANG node | ||
180 | - * @return constructors string | ||
181 | - */ | ||
182 | - public static String getAugmentsAddToAugmentedClassString(YangNode curNode) { | ||
183 | - | ||
184 | - if (!(curNode instanceof YangJavaAugment)) { | ||
185 | - throw new TranslatorException("current node should be of type augment node."); | ||
186 | - } | ||
187 | - YangJavaAugment augment = (YangJavaAugment) curNode; | ||
188 | - List<YangNodeIdentifier> targetNodes = augment.getTargetNode(); | ||
189 | - | ||
190 | - String name = targetNodes.get(targetNodes.size() - 1).getName(); | ||
191 | - String captialCase = getCapitalCase(name); | ||
192 | - String smallCase = getSmallCase(captialCase); | ||
193 | - return EIGHT_SPACE_INDENTATION + captialCase + IMPL + SPACE + smallCase + IMPL + SPACE + EQUAL + SPACE + NEW | ||
194 | - + SPACE + captialCase + BUILDER + OPEN_PARENTHESIS + CLOSE_PARENTHESIS + PERIOD + NEW + SPACE | ||
195 | - + captialCase + IMPL + OPEN_PARENTHESIS + CLOSE_PARENTHESIS + SEMI_COLAN + NEW_LINE | ||
196 | - + EIGHT_SPACE_INDENTATION + smallCase + IMPL + PERIOD + ADD_STRING + AUGMENTATION + OPEN_PARENTHESIS | ||
197 | - + THIS + CLOSE_PARENTHESIS + SEMI_COLAN + NEW_LINE; | ||
198 | - | ||
199 | - } | ||
200 | - | ||
201 | - /** | ||
202 | * Adds import for array list. | 102 | * Adds import for array list. |
203 | * | 103 | * |
204 | * @param curNode current YANG node | 104 | * @param curNode current YANG node |
... | @@ -227,7 +127,7 @@ public final class TempJavaCodeFragmentFilesUtils { | ... | @@ -227,7 +127,7 @@ public final class TempJavaCodeFragmentFilesUtils { |
227 | * @param classInfo class info to be added to import list | 127 | * @param classInfo class info to be added to import list |
228 | */ | 128 | */ |
229 | public static void addListnersImport(YangNode curNode, List<String> imports, boolean operation, | 129 | public static void addListnersImport(YangNode curNode, List<String> imports, boolean operation, |
230 | - String classInfo) { | 130 | + String classInfo) { |
231 | String thisImport = ""; | 131 | String thisImport = ""; |
232 | if (classInfo.equals(LISTENER_SERVICE)) { | 132 | if (classInfo.equals(LISTENER_SERVICE)) { |
233 | thisImport = getTempJavaFragement(curNode).getJavaImportData().getListenerServiceImport(); | 133 | thisImport = getTempJavaFragement(curNode).getJavaImportData().getListenerServiceImport(); |
... | @@ -272,7 +172,7 @@ public final class TempJavaCodeFragmentFilesUtils { | ... | @@ -272,7 +172,7 @@ public final class TempJavaCodeFragmentFilesUtils { |
272 | * @return import list | 172 | * @return import list |
273 | */ | 173 | */ |
274 | private static List<String> performOperationOnImports(List<String> imports, String curImport, | 174 | private static List<String> performOperationOnImports(List<String> imports, String curImport, |
275 | - boolean operation) { | 175 | + boolean operation) { |
276 | if (operation) { | 176 | if (operation) { |
277 | imports.add(curImport); | 177 | imports.add(curImport); |
278 | } else { | 178 | } else { | ... | ... |
... | @@ -25,24 +25,12 @@ import java.io.PrintWriter; | ... | @@ -25,24 +25,12 @@ import java.io.PrintWriter; |
25 | import java.util.ArrayList; | 25 | import java.util.ArrayList; |
26 | import java.util.List; | 26 | import java.util.List; |
27 | 27 | ||
28 | -import org.onosproject.yangutils.datamodel.YangNode; | ||
29 | -import org.onosproject.yangutils.translator.exception.TranslatorException; | ||
30 | -import org.onosproject.yangutils.translator.tojava.JavaFileInfo; | ||
31 | -import org.onosproject.yangutils.translator.tojava.JavaFileInfoContainer; | ||
32 | - | ||
33 | -import static org.onosproject.yangutils.datamodel.utils.DataModelUtils.getParentNodeInGenCode; | ||
34 | -import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getJavaPackageFromPackagePath; | ||
35 | -import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getPackageDirPathFromJavaJPackage; | ||
36 | import static org.onosproject.yangutils.utils.UtilConstants.EIGHT_SPACE_INDENTATION; | 28 | import static org.onosproject.yangutils.utils.UtilConstants.EIGHT_SPACE_INDENTATION; |
37 | import static org.onosproject.yangutils.utils.UtilConstants.EMPTY_STRING; | 29 | import static org.onosproject.yangutils.utils.UtilConstants.EMPTY_STRING; |
38 | import static org.onosproject.yangutils.utils.UtilConstants.FOUR_SPACE_INDENTATION; | 30 | import static org.onosproject.yangutils.utils.UtilConstants.FOUR_SPACE_INDENTATION; |
39 | import static org.onosproject.yangutils.utils.UtilConstants.MULTIPLE_NEW_LINE; | 31 | import static org.onosproject.yangutils.utils.UtilConstants.MULTIPLE_NEW_LINE; |
40 | import static org.onosproject.yangutils.utils.UtilConstants.NEW_LINE; | 32 | import static org.onosproject.yangutils.utils.UtilConstants.NEW_LINE; |
41 | -import static org.onosproject.yangutils.utils.UtilConstants.SLASH; | ||
42 | import static org.onosproject.yangutils.utils.UtilConstants.SPACE; | 33 | import static org.onosproject.yangutils.utils.UtilConstants.SPACE; |
43 | -import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.addPackageInfo; | ||
44 | -import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.createDirectories; | ||
45 | -import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getAbsolutePackagePath; | ||
46 | 34 | ||
47 | /** | 35 | /** |
48 | * Represents utility to handle file system operations. | 36 | * Represents utility to handle file system operations. |
... | @@ -56,57 +44,13 @@ public final class FileSystemUtil { | ... | @@ -56,57 +44,13 @@ public final class FileSystemUtil { |
56 | } | 44 | } |
57 | 45 | ||
58 | /** | 46 | /** |
59 | - * Checks if the package directory structure created. | ||
60 | - * | ||
61 | - * @param pkg Package to check if it is created | ||
62 | - * @return existence status of package | ||
63 | - */ | ||
64 | - public static boolean doesPackageExist(String pkg) { | ||
65 | - File pkgDir = new File(getPackageDirPathFromJavaJPackage(pkg)); | ||
66 | - File pkgWithFile = new File(pkgDir + SLASH + "package-info.java"); | ||
67 | - return pkgDir.exists() && pkgWithFile.isFile(); | ||
68 | - } | ||
69 | - | ||
70 | - /** | ||
71 | - * Creates a package structure with package info java file if not present. | ||
72 | - * | ||
73 | - * @param yangNode YANG node for which code is being generated | ||
74 | - * @throws IOException any IO exception | ||
75 | - */ | ||
76 | - public static void createPackage(YangNode yangNode) throws IOException { | ||
77 | - if (!(yangNode instanceof JavaFileInfoContainer)) { | ||
78 | - throw new TranslatorException("current node must have java file info"); | ||
79 | - } | ||
80 | - String pkgInfo; | ||
81 | - JavaFileInfo javaFileInfo = ((JavaFileInfoContainer) yangNode).getJavaFileInfo(); | ||
82 | - String pkg = getAbsolutePackagePath(javaFileInfo.getBaseCodeGenPath(), javaFileInfo.getPackageFilePath()); | ||
83 | - if (!doesPackageExist(pkg)) { | ||
84 | - try { | ||
85 | - File pack = createDirectories(pkg); | ||
86 | - YangNode parent = getParentNodeInGenCode(yangNode); | ||
87 | - if (parent != null) { | ||
88 | - pkgInfo = ((JavaFileInfoContainer) parent).getJavaFileInfo().getJavaName(); | ||
89 | - addPackageInfo(pack, pkgInfo, getJavaPackageFromPackagePath(pkg), true, | ||
90 | - ((JavaFileInfoContainer) parent).getJavaFileInfo().getPluginConfig()); | ||
91 | - } else { | ||
92 | - pkgInfo = ((JavaFileInfoContainer) yangNode).getJavaFileInfo().getJavaName(); | ||
93 | - addPackageInfo(pack, pkgInfo, getJavaPackageFromPackagePath(pkg), false, | ||
94 | - ((JavaFileInfoContainer) yangNode).getJavaFileInfo().getPluginConfig()); | ||
95 | - } | ||
96 | - } catch (IOException e) { | ||
97 | - throw new IOException("failed to create package-info file"); | ||
98 | - } | ||
99 | - } | ||
100 | - } | ||
101 | - | ||
102 | - /** | ||
103 | * Reads the contents from source file and append its contents to append | 47 | * Reads the contents from source file and append its contents to append |
104 | * file. | 48 | * file. |
105 | * | 49 | * |
106 | * @param toAppend destination file in which the contents of source file is | 50 | * @param toAppend destination file in which the contents of source file is |
107 | - * appended | 51 | + * appended |
108 | - * @param srcFile source file from which data is read and added to to append | 52 | + * @param srcFile source file from which data is read and added to to append |
109 | - * file | 53 | + * file |
110 | * @throws IOException any IO errors | 54 | * @throws IOException any IO errors |
111 | */ | 55 | */ |
112 | public static void appendFileContents(File toAppend, File srcFile) | 56 | public static void appendFileContents(File toAppend, File srcFile) |
... | @@ -118,7 +62,7 @@ public final class FileSystemUtil { | ... | @@ -118,7 +62,7 @@ public final class FileSystemUtil { |
118 | * Reads file and convert it to string. | 62 | * Reads file and convert it to string. |
119 | * | 63 | * |
120 | * @param toAppend file to be converted | 64 | * @param toAppend file to be converted |
121 | - * @param spaces spaces to be appended | 65 | + * @param spaces spaces to be appended |
122 | * @return string of file | 66 | * @return string of file |
123 | * @throws IOException when fails to convert to string | 67 | * @throws IOException when fails to convert to string |
124 | */ | 68 | */ |
... | @@ -153,9 +97,9 @@ public final class FileSystemUtil { | ... | @@ -153,9 +97,9 @@ public final class FileSystemUtil { |
153 | /** | 97 | /** |
154 | * Updates the generated file handle. | 98 | * Updates the generated file handle. |
155 | * | 99 | * |
156 | - * @param inputFile input file | 100 | + * @param inputFile input file |
157 | * @param contentTobeAdded content to be appended to the file | 101 | * @param contentTobeAdded content to be appended to the file |
158 | - * @param isClose when close of file is called. | 102 | + * @param isClose when close of file is called. |
159 | * @throws IOException if the named file exists but is a directory rather than a regular file, | 103 | * @throws IOException if the named file exists but is a directory rather than a regular file, |
160 | * does not exist but cannot be created, or cannot be opened for any other reason | 104 | * does not exist but cannot be created, or cannot be opened for any other reason |
161 | */ | 105 | */ | ... | ... |
... | @@ -16,10 +16,7 @@ | ... | @@ -16,10 +16,7 @@ |
16 | 16 | ||
17 | package org.onosproject.yangutils.utils.io.impl; | 17 | package org.onosproject.yangutils.utils.io.impl; |
18 | 18 | ||
19 | -import org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax; | 19 | +import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getCamelCase; |
20 | -import org.onosproject.yangutils.translator.tojava.utils.YangPluginConfig; | ||
21 | - | ||
22 | -import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getCamelCase; | ||
23 | import static org.onosproject.yangutils.utils.UtilConstants.BUILDER; | 20 | import static org.onosproject.yangutils.utils.UtilConstants.BUILDER; |
24 | import static org.onosproject.yangutils.utils.UtilConstants.BUILDER_CLASS_JAVA_DOC; | 21 | import static org.onosproject.yangutils.utils.UtilConstants.BUILDER_CLASS_JAVA_DOC; |
25 | import static org.onosproject.yangutils.utils.UtilConstants.BUILDER_INTERFACE_JAVA_DOC; | 22 | import static org.onosproject.yangutils.utils.UtilConstants.BUILDER_INTERFACE_JAVA_DOC; |
... | @@ -202,7 +199,7 @@ public final class JavaDocGen { | ... | @@ -202,7 +199,7 @@ public final class JavaDocGen { |
202 | */ | 199 | */ |
203 | public static String getJavaDoc(JavaDocType type, String name, boolean isList, YangPluginConfig pluginConfig) { | 200 | public static String getJavaDoc(JavaDocType type, String name, boolean isList, YangPluginConfig pluginConfig) { |
204 | 201 | ||
205 | - name = JavaIdentifierSyntax.getSmallCase(getCamelCase(name, pluginConfig.getConflictResolver())); | 202 | + name = YangIoUtils.getSmallCase(getCamelCase(name, pluginConfig.getConflictResolver())); |
206 | switch (type) { | 203 | switch (type) { |
207 | case IMPL_CLASS: { | 204 | case IMPL_CLASS: { |
208 | return generateForClass(name); | 205 | return generateForClass(name); | ... | ... |
... | @@ -19,73 +19,60 @@ package org.onosproject.yangutils.utils.io.impl; | ... | @@ -19,73 +19,60 @@ package org.onosproject.yangutils.utils.io.impl; |
19 | import java.io.BufferedReader; | 19 | import java.io.BufferedReader; |
20 | import java.io.BufferedWriter; | 20 | import java.io.BufferedWriter; |
21 | import java.io.File; | 21 | import java.io.File; |
22 | -import java.io.FileInputStream; | ||
23 | -import java.io.FileOutputStream; | ||
24 | import java.io.FileReader; | 22 | import java.io.FileReader; |
25 | import java.io.FileWriter; | 23 | import java.io.FileWriter; |
26 | import java.io.IOException; | 24 | import java.io.IOException; |
27 | -import java.io.InputStream; | ||
28 | -import java.io.ObjectInputStream; | ||
29 | -import java.io.ObjectOutputStream; | ||
30 | -import java.nio.file.Files; | ||
31 | -import java.nio.file.StandardCopyOption; | ||
32 | import java.util.ArrayList; | 25 | import java.util.ArrayList; |
33 | -import java.util.Enumeration; | 26 | +import java.util.Arrays; |
34 | -import java.util.Iterator; | ||
35 | import java.util.LinkedList; | 27 | import java.util.LinkedList; |
36 | import java.util.List; | 28 | import java.util.List; |
37 | -import java.util.Set; | ||
38 | import java.util.Stack; | 29 | import java.util.Stack; |
39 | -import java.util.jar.JarEntry; | ||
40 | -import java.util.jar.JarFile; | ||
41 | import java.util.regex.Pattern; | 30 | import java.util.regex.Pattern; |
42 | - | ||
43 | import org.apache.commons.io.FileUtils; | 31 | import org.apache.commons.io.FileUtils; |
44 | -import org.apache.maven.artifact.repository.ArtifactRepository; | 32 | +import org.onosproject.yangutils.translator.exception.TranslatorException; |
45 | -import org.apache.maven.model.Dependency; | 33 | + |
46 | -import org.apache.maven.model.Resource; | 34 | +import static org.onosproject.yangutils.utils.UtilConstants.COLAN; |
47 | -import org.apache.maven.project.MavenProject; | ||
48 | -import org.onosproject.yangutils.datamodel.YangNode; | ||
49 | -import org.onosproject.yangutils.plugin.manager.YangFileInfo; | ||
50 | -import org.onosproject.yangutils.translator.tojava.utils.YangPluginConfig; | ||
51 | -import org.slf4j.Logger; | ||
52 | -import org.sonatype.plexus.build.incremental.BuildContext; | ||
53 | - | ||
54 | -import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getCamelCase; | ||
55 | -import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getPackageDirPathFromJavaJPackage; | ||
56 | import static org.onosproject.yangutils.utils.UtilConstants.COMMA; | 35 | import static org.onosproject.yangutils.utils.UtilConstants.COMMA; |
57 | import static org.onosproject.yangutils.utils.UtilConstants.EMPTY_STRING; | 36 | import static org.onosproject.yangutils.utils.UtilConstants.EMPTY_STRING; |
58 | import static org.onosproject.yangutils.utils.UtilConstants.HASH; | 37 | import static org.onosproject.yangutils.utils.UtilConstants.HASH; |
59 | import static org.onosproject.yangutils.utils.UtilConstants.HYPHEN; | 38 | import static org.onosproject.yangutils.utils.UtilConstants.HYPHEN; |
60 | -import static org.onosproject.yangutils.utils.UtilConstants.JAR; | 39 | +import static org.onosproject.yangutils.utils.UtilConstants.JAVA_KEY_WORDS; |
61 | import static org.onosproject.yangutils.utils.UtilConstants.NEW_LINE; | 40 | import static org.onosproject.yangutils.utils.UtilConstants.NEW_LINE; |
62 | import static org.onosproject.yangutils.utils.UtilConstants.OPEN_PARENTHESIS; | 41 | import static org.onosproject.yangutils.utils.UtilConstants.OPEN_PARENTHESIS; |
63 | import static org.onosproject.yangutils.utils.UtilConstants.ORG; | 42 | import static org.onosproject.yangutils.utils.UtilConstants.ORG; |
64 | import static org.onosproject.yangutils.utils.UtilConstants.PACKAGE; | 43 | import static org.onosproject.yangutils.utils.UtilConstants.PACKAGE; |
65 | import static org.onosproject.yangutils.utils.UtilConstants.PERIOD; | 44 | import static org.onosproject.yangutils.utils.UtilConstants.PERIOD; |
45 | +import static org.onosproject.yangutils.utils.UtilConstants.REGEX_FOR_DIGITS_WITH_SINGLE_LETTER; | ||
46 | +import static org.onosproject.yangutils.utils.UtilConstants.REGEX_FOR_FIRST_DIGIT; | ||
47 | +import static org.onosproject.yangutils.utils.UtilConstants.REGEX_FOR_HYPHEN; | ||
48 | +import static org.onosproject.yangutils.utils.UtilConstants.REGEX_FOR_IDENTIFIER_SPECIAL_CHAR; | ||
49 | +import static org.onosproject.yangutils.utils.UtilConstants.REGEX_FOR_PERIOD; | ||
50 | +import static org.onosproject.yangutils.utils.UtilConstants.REGEX_FOR_SINGLE_LETTER; | ||
51 | +import static org.onosproject.yangutils.utils.UtilConstants.REGEX_FOR_UNDERSCORE; | ||
52 | +import static org.onosproject.yangutils.utils.UtilConstants.REGEX_WITH_ALL_SPECIAL_CHAR; | ||
53 | +import static org.onosproject.yangutils.utils.UtilConstants.REGEX_WITH_DIGITS; | ||
54 | +import static org.onosproject.yangutils.utils.UtilConstants.REGEX_WITH_SINGLE_CAPITAL_CASE; | ||
55 | +import static org.onosproject.yangutils.utils.UtilConstants.REGEX_WITH_SINGLE_CAPITAL_CASE_AND_DIGITS_SMALL_CASES; | ||
56 | +import static org.onosproject.yangutils.utils.UtilConstants.REGEX_WITH_UPPERCASE; | ||
66 | import static org.onosproject.yangutils.utils.UtilConstants.SEMI_COLAN; | 57 | import static org.onosproject.yangutils.utils.UtilConstants.SEMI_COLAN; |
67 | import static org.onosproject.yangutils.utils.UtilConstants.SLASH; | 58 | import static org.onosproject.yangutils.utils.UtilConstants.SLASH; |
68 | import static org.onosproject.yangutils.utils.UtilConstants.SPACE; | 59 | import static org.onosproject.yangutils.utils.UtilConstants.SPACE; |
69 | -import static org.onosproject.yangutils.utils.UtilConstants.TEMP; | ||
70 | import static org.onosproject.yangutils.utils.UtilConstants.TWELVE_SPACE_INDENTATION; | 60 | import static org.onosproject.yangutils.utils.UtilConstants.TWELVE_SPACE_INDENTATION; |
71 | -import static org.onosproject.yangutils.utils.UtilConstants.YANG_RESOURCES; | 61 | +import static org.onosproject.yangutils.utils.UtilConstants.UNDER_SCORE; |
62 | +import static org.onosproject.yangutils.utils.UtilConstants.YANG_AUTO_PREFIX; | ||
72 | import static org.onosproject.yangutils.utils.io.impl.FileSystemUtil.appendFileContents; | 63 | import static org.onosproject.yangutils.utils.io.impl.FileSystemUtil.appendFileContents; |
73 | import static org.onosproject.yangutils.utils.io.impl.FileSystemUtil.updateFileHandle; | 64 | import static org.onosproject.yangutils.utils.io.impl.FileSystemUtil.updateFileHandle; |
74 | -import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.getJavaDoc; | ||
75 | import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.JavaDocType.PACKAGE_INFO; | 65 | import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.JavaDocType.PACKAGE_INFO; |
76 | -import static org.slf4j.LoggerFactory.getLogger; | 66 | +import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.getJavaDoc; |
77 | 67 | ||
78 | /** | 68 | /** |
79 | * Represents common utility functionalities for code generation. | 69 | * Represents common utility functionalities for code generation. |
80 | */ | 70 | */ |
81 | public final class YangIoUtils { | 71 | public final class YangIoUtils { |
82 | 72 | ||
83 | - private static final Logger log = getLogger(YangIoUtils.class); | ||
84 | - private static final String TARGET_RESOURCE_PATH = SLASH + TEMP + SLASH + YANG_RESOURCES + SLASH; | ||
85 | private static final int LINE_SIZE = 118; | 73 | private static final int LINE_SIZE = 118; |
86 | private static final int SUB_LINE_SIZE = 112; | 74 | private static final int SUB_LINE_SIZE = 112; |
87 | private static final int ZERO = 0; | 75 | private static final int ZERO = 0; |
88 | - private static final String SERIALIZED_FILE_EXTENSION = ".ser"; | ||
89 | 76 | ||
90 | /** | 77 | /** |
91 | * Creates an instance of YANG io utils. | 78 | * Creates an instance of YANG io utils. |
... | @@ -223,19 +210,6 @@ public final class YangIoUtils { | ... | @@ -223,19 +210,6 @@ public final class YangIoUtils { |
223 | } | 210 | } |
224 | 211 | ||
225 | /** | 212 | /** |
226 | - * Adds generated source directory to the compilation root. | ||
227 | - * | ||
228 | - * @param source directory | ||
229 | - * @param project current maven project | ||
230 | - * @param context current build context | ||
231 | - */ | ||
232 | - public static void addToCompilationRoot(String source, MavenProject project, BuildContext context) { | ||
233 | - project.addCompileSourceRoot(source); | ||
234 | - context.refresh(project.getBasedir()); | ||
235 | - log.info("Source directory added to compilation root: " + source); | ||
236 | - } | ||
237 | - | ||
238 | - /** | ||
239 | * Removes extra char from the string. | 213 | * Removes extra char from the string. |
240 | * | 214 | * |
241 | * @param valueString string to be trimmed | 215 | * @param valueString string to be trimmed |
... | @@ -303,49 +277,6 @@ public final class YangIoUtils { | ... | @@ -303,49 +277,6 @@ public final class YangIoUtils { |
303 | } | 277 | } |
304 | 278 | ||
305 | /** | 279 | /** |
306 | - * Copies YANG files to the current project's output directory. | ||
307 | - * | ||
308 | - * @param yangFileInfo list of YANG files | ||
309 | - * @param outputDir project's output directory | ||
310 | - * @param project maven project | ||
311 | - * @throws IOException when fails to copy files to destination resource directory | ||
312 | - */ | ||
313 | - public static void copyYangFilesToTarget(Set<YangFileInfo> yangFileInfo, String outputDir, MavenProject project) | ||
314 | - throws IOException { | ||
315 | - | ||
316 | - List<File> files = getListOfFile(yangFileInfo); | ||
317 | - | ||
318 | - String path = outputDir + TARGET_RESOURCE_PATH; | ||
319 | - File targetDir = new File(path); | ||
320 | - targetDir.mkdirs(); | ||
321 | - | ||
322 | - for (File file : files) { | ||
323 | - Files.copy(file.toPath(), | ||
324 | - new File(path + file.getName()).toPath(), | ||
325 | - StandardCopyOption.REPLACE_EXISTING); | ||
326 | - } | ||
327 | - addToProjectResource(outputDir + SLASH + TEMP + SLASH, project); | ||
328 | - } | ||
329 | - | ||
330 | - /** | ||
331 | - * Provides a list of files from list of strings. | ||
332 | - * | ||
333 | - * @param yangFileInfo set of yang file information | ||
334 | - * @return list of files | ||
335 | - */ | ||
336 | - private static List<File> getListOfFile(Set<YangFileInfo> yangFileInfo) { | ||
337 | - List<File> files = new ArrayList<>(); | ||
338 | - Iterator<YangFileInfo> yangFileIterator = yangFileInfo.iterator(); | ||
339 | - while (yangFileIterator.hasNext()) { | ||
340 | - YangFileInfo yangFile = yangFileIterator.next(); | ||
341 | - if (yangFile.isForTranslator()) { | ||
342 | - files.add(new File(yangFile.getYangFileName())); | ||
343 | - } | ||
344 | - } | ||
345 | - return files; | ||
346 | - } | ||
347 | - | ||
348 | - /** | ||
349 | * Merges the temp java files to main java files. | 280 | * Merges the temp java files to main java files. |
350 | * | 281 | * |
351 | * @param appendFile temp file | 282 | * @param appendFile temp file |
... | @@ -501,173 +432,258 @@ public final class YangIoUtils { | ... | @@ -501,173 +432,258 @@ public final class YangIoUtils { |
501 | } | 432 | } |
502 | 433 | ||
503 | /** | 434 | /** |
504 | - * Serializes data-model. | 435 | + * Returns the java Package from package path. |
505 | * | 436 | * |
506 | - * @param directory base directory for serialized files | 437 | + * @param packagePath package path |
507 | - * @param fileInfoSet YANG file info set | 438 | + * @return java package |
508 | - * @param project maven project | ||
509 | - * @param operation true if need to add to resource | ||
510 | - * @throws IOException when fails to do IO operations | ||
511 | */ | 439 | */ |
512 | - public static void serializeDataModel(String directory, Set<YangFileInfo> fileInfoSet, | 440 | + public static String getJavaPackageFromPackagePath(String packagePath) { |
513 | - MavenProject project, boolean operation) throws IOException { | 441 | + return packagePath.replace(SLASH, PERIOD); |
442 | + } | ||
514 | 443 | ||
515 | - String serFileDirPath = directory + TARGET_RESOURCE_PATH; | 444 | + /** |
516 | - File dir = new File(serFileDirPath); | 445 | + * Returns the directory path corresponding to java package. |
517 | - dir.mkdirs(); | 446 | + * |
447 | + * @param packagePath package path | ||
448 | + * @return java package | ||
449 | + */ | ||
450 | + public static String getPackageDirPathFromJavaJPackage(String packagePath) { | ||
451 | + return packagePath.replace(PERIOD, SLASH); | ||
452 | + } | ||
518 | 453 | ||
519 | - if (operation) { | 454 | + /** |
520 | - addToProjectResource(directory + SLASH + TEMP + SLASH, project); | 455 | + * Returns the YANG identifier name as java identifier with first letter |
521 | - } | 456 | + * in small. |
457 | + * | ||
458 | + * @param yangIdentifier identifier in YANG file. | ||
459 | + * @return corresponding java identifier | ||
460 | + */ | ||
461 | + public static String getSmallCase(String yangIdentifier) { | ||
462 | + return yangIdentifier.substring(0, 1).toLowerCase() + yangIdentifier.substring(1); | ||
463 | + } | ||
522 | 464 | ||
523 | - for (YangFileInfo fileInfo : fileInfoSet) { | 465 | + /** |
466 | + * Returns the YANG identifier name as java identifier with first letter | ||
467 | + * in capital. | ||
468 | + * | ||
469 | + * @param yangIdentifier identifier in YANG file | ||
470 | + * @return corresponding java identifier | ||
471 | + */ | ||
472 | + public static String getCapitalCase(String yangIdentifier) { | ||
473 | + yangIdentifier = yangIdentifier.substring(0, 1).toUpperCase() + yangIdentifier.substring(1); | ||
474 | + return restrictConsecutiveCapitalCase(yangIdentifier); | ||
475 | + } | ||
524 | 476 | ||
525 | - String serFileName = serFileDirPath + getCamelCase(fileInfo.getRootNode().getName(), null) | 477 | + /** |
526 | - + SERIALIZED_FILE_EXTENSION; | 478 | + * Restricts consecutive capital cased string as a rule in camel case. |
527 | - fileInfo.setSerializedFile(serFileName); | 479 | + * |
528 | - FileOutputStream fileOutputStream = new FileOutputStream(serFileName); | 480 | + * @param consecCapitalCaseRemover which requires the restriction of consecutive capital case |
529 | - ObjectOutputStream objectOutputStream = new ObjectOutputStream(fileOutputStream); | 481 | + * @return string without consecutive capital case |
530 | - objectOutputStream.writeObject(fileInfo.getRootNode()); | 482 | + */ |
531 | - objectOutputStream.close(); | 483 | + public static String restrictConsecutiveCapitalCase(String consecCapitalCaseRemover) { |
532 | - fileOutputStream.close(); | 484 | + |
485 | + for (int k = 0; k < consecCapitalCaseRemover.length(); k++) { | ||
486 | + if (k + 1 < consecCapitalCaseRemover.length()) { | ||
487 | + if (Character.isUpperCase(consecCapitalCaseRemover.charAt(k))) { | ||
488 | + if (Character.isUpperCase(consecCapitalCaseRemover.charAt(k + 1))) { | ||
489 | + consecCapitalCaseRemover = consecCapitalCaseRemover.substring(0, k + 1) | ||
490 | + + consecCapitalCaseRemover.substring(k + 1, k + 2).toLowerCase() | ||
491 | + + consecCapitalCaseRemover.substring(k + 2); | ||
492 | + } | ||
493 | + } | ||
494 | + } | ||
533 | } | 495 | } |
496 | + return consecCapitalCaseRemover; | ||
534 | } | 497 | } |
535 | 498 | ||
536 | - /* Adds directory to resources of project */ | 499 | + /** |
537 | - private static void addToProjectResource(String dir, MavenProject project) { | 500 | + * Adds prefix, if the string begins with digit or is a java key word. |
538 | - Resource rsc = new Resource(); | 501 | + * |
539 | - rsc.setDirectory(dir); | 502 | + * @param camelCasePrefix string for adding prefix |
540 | - project.addResource(rsc); | 503 | + * @param conflictResolver object of YANG to java naming conflict util |
504 | + * @return prefixed camel case string | ||
505 | + */ | ||
506 | + public static String addPrefix(String camelCasePrefix, YangToJavaNamingConflictUtil conflictResolver) { | ||
507 | + | ||
508 | + String prefix = getPrefixForIdentifier(conflictResolver); | ||
509 | + if (camelCasePrefix.matches(REGEX_FOR_FIRST_DIGIT)) { | ||
510 | + camelCasePrefix = prefix + camelCasePrefix; | ||
511 | + } | ||
512 | + if (JAVA_KEY_WORDS.contains(camelCasePrefix)) { | ||
513 | + camelCasePrefix = prefix + camelCasePrefix.substring(0, 1).toUpperCase() | ||
514 | + + camelCasePrefix.substring(1); | ||
515 | + } | ||
516 | + return camelCasePrefix; | ||
541 | } | 517 | } |
542 | 518 | ||
543 | /** | 519 | /** |
544 | - * Returns de-serializes YANG data-model nodes. | 520 | + * Applies the rule that a string does not end with a capitalized letter and capitalizes |
521 | + * the letter next to a number in an array. | ||
545 | * | 522 | * |
546 | - * @param serailizedfileInfoSet YANG file info set | 523 | + * @param stringArray containing strings for camel case separation |
547 | - * @return de-serializes YANG data-model nodes | 524 | + * @param conflictResolver object of YANG to java naming conflict util |
548 | - * @throws IOException when fails do IO operations | 525 | + * @return camel case rule checked string |
549 | */ | 526 | */ |
550 | - public static List<YangNode> deSerializeDataModel(List<String> serailizedfileInfoSet) throws IOException { | 527 | + public static String applyCamelCaseRule(String[] stringArray, YangToJavaNamingConflictUtil conflictResolver) { |
551 | 528 | ||
552 | - List<YangNode> nodes = new ArrayList<>(); | 529 | + String ruleChecker = stringArray[0].toLowerCase(); |
553 | - for (String fileInfo : serailizedfileInfoSet) { | 530 | + int i; |
554 | - YangNode node = null; | 531 | + if (ruleChecker.matches(REGEX_FOR_FIRST_DIGIT)) { |
555 | - try { | 532 | + i = 0; |
556 | - FileInputStream fileInputStream = new FileInputStream(fileInfo); | 533 | + ruleChecker = EMPTY_STRING; |
557 | - ObjectInputStream objectInputStream = new ObjectInputStream(fileInputStream); | 534 | + } else { |
558 | - node = (YangNode) objectInputStream.readObject(); | 535 | + i = 1; |
559 | - nodes.add(node); | 536 | + } |
560 | - objectInputStream.close(); | 537 | + for (; i < stringArray.length; i++) { |
561 | - fileInputStream.close(); | 538 | + if (i + 1 == stringArray.length) { |
562 | - } catch (IOException | ClassNotFoundException e) { | 539 | + if (stringArray[i].matches(REGEX_FOR_SINGLE_LETTER) |
563 | - throw new IOException(fileInfo + " not found."); | 540 | + || stringArray[i].matches(REGEX_FOR_DIGITS_WITH_SINGLE_LETTER)) { |
541 | + ruleChecker = ruleChecker + stringArray[i].toLowerCase(); | ||
542 | + break; | ||
543 | + } | ||
544 | + } | ||
545 | + if (stringArray[i].matches(REGEX_FOR_FIRST_DIGIT)) { | ||
546 | + for (int j = 0; j < stringArray[i].length(); j++) { | ||
547 | + char letterCheck = stringArray[i].charAt(j); | ||
548 | + if (Character.isLetter(letterCheck)) { | ||
549 | + stringArray[i] = stringArray[i].substring(0, j) | ||
550 | + + stringArray[i].substring(j, j + 1).toUpperCase() + stringArray[i].substring(j + 1); | ||
551 | + break; | ||
552 | + } | ||
553 | + } | ||
554 | + ruleChecker = ruleChecker + stringArray[i]; | ||
555 | + } else { | ||
556 | + ruleChecker = ruleChecker + stringArray[i].substring(0, 1).toUpperCase() + stringArray[i].substring(1); | ||
564 | } | 557 | } |
565 | } | 558 | } |
566 | - return nodes; | 559 | + String ruleCheckerWithPrefix = addPrefix(ruleChecker, conflictResolver); |
560 | + return restrictConsecutiveCapitalCase(ruleCheckerWithPrefix); | ||
567 | } | 561 | } |
568 | 562 | ||
569 | /** | 563 | /** |
570 | - * Resolves inter jar dependencies. | 564 | + * Resolves the conflict when input has upper case. |
571 | * | 565 | * |
572 | - * @param project current maven project | 566 | + * @param stringArray containing strings for upper case conflict resolver |
573 | - * @param localRepository local maven repository | 567 | + * @param conflictResolver object of YANG to java naming conflict util |
574 | - * @param remoteRepos list of remote repository | 568 | + * @return camel cased string |
575 | - * @param directory directory for serialized files | ||
576 | - * @return list of resolved datamodel nodes | ||
577 | - * @throws IOException when fails to do IO operations | ||
578 | */ | 569 | */ |
579 | - public static List<YangNode> resolveInterJarDependencies(MavenProject project, ArtifactRepository localRepository, | 570 | + public static String upperCaseConflictResolver(String[] stringArray, |
580 | - List<ArtifactRepository> remoteRepos, String directory) throws IOException { | 571 | + YangToJavaNamingConflictUtil conflictResolver) { |
581 | - | 572 | + |
582 | - List<String> dependeciesJarPaths = resolveDependecyJarPath(project, localRepository, remoteRepos); | 573 | + for (int l = 0; l < stringArray.length; l++) { |
583 | - List<YangNode> resolvedDataModelNodes = new ArrayList<>(); | 574 | + String[] upperCaseSplitArray = stringArray[l].split(REGEX_WITH_UPPERCASE); |
584 | - for (String dependecy : dependeciesJarPaths) { | 575 | + for (int m = 0; m < upperCaseSplitArray.length; m++) { |
585 | - resolvedDataModelNodes.addAll(deSerializeDataModel(parseJarFile(dependecy, directory))); | 576 | + if (upperCaseSplitArray[m].matches(REGEX_WITH_SINGLE_CAPITAL_CASE)) { |
577 | + int check = m; | ||
578 | + while (check + 1 < upperCaseSplitArray.length) { | ||
579 | + if (upperCaseSplitArray[check + 1].matches(REGEX_WITH_SINGLE_CAPITAL_CASE)) { | ||
580 | + upperCaseSplitArray[check + 1] = upperCaseSplitArray[check + 1].toLowerCase(); | ||
581 | + check = check + 1; | ||
582 | + } else if (upperCaseSplitArray[check + 1] | ||
583 | + .matches(REGEX_WITH_SINGLE_CAPITAL_CASE_AND_DIGITS_SMALL_CASES)) { | ||
584 | + upperCaseSplitArray[check + 1] = upperCaseSplitArray[check + 1].toLowerCase(); | ||
585 | + break; | ||
586 | + } else { | ||
587 | + break; | ||
588 | + } | ||
589 | + } | ||
590 | + } | ||
591 | + } | ||
592 | + StringBuilder strBuilder = new StringBuilder(); | ||
593 | + for (String element : upperCaseSplitArray) { | ||
594 | + strBuilder.append(element); | ||
595 | + } | ||
596 | + stringArray[l] = strBuilder.toString(); | ||
586 | } | 597 | } |
587 | - return resolvedDataModelNodes; | 598 | + List<String> result = new ArrayList<String>(); |
599 | + for (String element : stringArray) { | ||
600 | + String[] capitalCaseSplitArray = element.split(REGEX_WITH_UPPERCASE); | ||
601 | + for (String letter : capitalCaseSplitArray) { | ||
602 | + String[] arrayForAddition = letter.split(REGEX_WITH_DIGITS); | ||
603 | + List<String> list = Arrays.asList(arrayForAddition); | ||
604 | + for (String str : list) { | ||
605 | + if (str != null && !str.isEmpty()) { | ||
606 | + result.add(str); | ||
607 | + } | ||
608 | + } | ||
609 | + } | ||
610 | + } | ||
611 | + stringArray = result.toArray(new String[result.size()]); | ||
612 | + return applyCamelCaseRule(stringArray, conflictResolver); | ||
588 | } | 613 | } |
589 | 614 | ||
590 | /** | 615 | /** |
591 | - * Returns list of jar path. | 616 | + * Returns the YANG identifier name as java identifier. |
592 | * | 617 | * |
593 | - * @return list of jar paths | 618 | + * @param yangIdentifier identifier in YANG file |
619 | + * @param conflictResolver object of YANG to java naming conflict util | ||
620 | + * @return corresponding java identifier | ||
594 | */ | 621 | */ |
595 | - private static List<String> resolveDependecyJarPath(MavenProject project, ArtifactRepository localRepository, | 622 | + public static String getCamelCase(String yangIdentifier, YangToJavaNamingConflictUtil conflictResolver) { |
596 | - List<ArtifactRepository> remoteRepos) { | 623 | + |
597 | - | 624 | + if (conflictResolver != null) { |
598 | - StringBuilder path = new StringBuilder(); | 625 | + String replacementForHyphen = conflictResolver.getReplacementForHyphen(); |
599 | - List<String> jarPaths = new ArrayList<>(); | 626 | + String replacementForPeriod = conflictResolver.getReplacementForPeriod(); |
600 | - for (Dependency dependency : project.getDependencies()) { | 627 | + String replacementForUnderscore = conflictResolver.getReplacementForUnderscore(); |
601 | - | 628 | + if (replacementForPeriod != null) { |
602 | - path.append(localRepository.getBasedir()); | 629 | + yangIdentifier = yangIdentifier.replaceAll(REGEX_FOR_PERIOD, |
603 | - path.append(SLASH); | 630 | + PERIOD + replacementForPeriod.toLowerCase() + PERIOD); |
604 | - path.append(getPackageDirPathFromJavaJPackage(dependency.getGroupId())); | 631 | + } |
605 | - path.append(SLASH); | 632 | + if (replacementForUnderscore != null) { |
606 | - path.append(dependency.getArtifactId()); | 633 | + yangIdentifier = yangIdentifier.replaceAll(REGEX_FOR_UNDERSCORE, |
607 | - path.append(SLASH); | 634 | + UNDER_SCORE + replacementForUnderscore.toLowerCase() + UNDER_SCORE); |
608 | - path.append(dependency.getVersion()); | 635 | + } |
609 | - path.append(SLASH); | 636 | + if (replacementForHyphen != null) { |
610 | - path.append(dependency.getArtifactId() + HYPHEN + dependency.getVersion() + PERIOD + JAR); | 637 | + yangIdentifier = yangIdentifier.replaceAll(REGEX_FOR_HYPHEN, |
611 | - File jarFile = new File(path.toString()); | 638 | + HYPHEN + replacementForHyphen.toLowerCase() + HYPHEN); |
612 | - if (jarFile.exists()) { | ||
613 | - jarPaths.add(path.toString()); | ||
614 | } | 639 | } |
615 | - path.delete(0, path.length()); | ||
616 | } | 640 | } |
617 | - | 641 | + yangIdentifier = yangIdentifier.replaceAll(REGEX_FOR_IDENTIFIER_SPECIAL_CHAR, COLAN); |
618 | - for (ArtifactRepository repo : remoteRepos) { | 642 | + String[] strArray = yangIdentifier.split(COLAN); |
619 | - // TODO: add resolver for remote repo. | 643 | + if (strArray[0].isEmpty()) { |
644 | + List<String> stringArrangement = new ArrayList<String>(); | ||
645 | + for (int i = 1; i < strArray.length; i++) { | ||
646 | + stringArrangement.add(strArray[i]); | ||
647 | + } | ||
648 | + strArray = stringArrangement.toArray(new String[stringArrangement.size()]); | ||
620 | } | 649 | } |
621 | - return jarPaths; | 650 | + return upperCaseConflictResolver(strArray, conflictResolver); |
622 | } | 651 | } |
623 | 652 | ||
624 | /** | 653 | /** |
625 | - * Parses jar file and returns list of serialized file names. | 654 | + * Prefix for adding with identifier and namespace, when it is a java keyword or starting with digits. |
626 | * | 655 | * |
627 | - * @param jarFile jar file to be parsed | 656 | + * @param conflictResolver object of YANG to java naming conflict util |
628 | - * @param directory directory for keeping the searized files | 657 | + * @return prefix which needs to be added |
629 | - * @return list of serialized files | ||
630 | - * @throws IOException when fails to do IO operations | ||
631 | */ | 658 | */ |
632 | - public static List<String> parseJarFile(String jarFile, String directory) | 659 | + public static String getPrefixForIdentifier(YangToJavaNamingConflictUtil conflictResolver) { |
633 | - throws IOException { | ||
634 | 660 | ||
635 | - List<String> serailizedFiles = new ArrayList<>(); | 661 | + String prefixForIdentifier = null; |
636 | - JarFile jar = new JarFile(jarFile); | 662 | + if (conflictResolver != null) { |
637 | - Enumeration<?> enumEntries = jar.entries(); | 663 | + prefixForIdentifier = conflictResolver.getPrefixForIdentifier(); |
638 | - | 664 | + } |
639 | - File serializedFileDir = new File(directory); | 665 | + if (prefixForIdentifier != null) { |
640 | - serializedFileDir.mkdirs(); | 666 | + prefixForIdentifier = prefixForIdentifier.replaceAll(REGEX_WITH_ALL_SPECIAL_CHAR, COLAN); |
641 | - while (enumEntries.hasMoreElements()) { | 667 | + String[] strArray = prefixForIdentifier.split(COLAN); |
642 | - JarEntry file = (JarEntry) enumEntries.nextElement(); | 668 | + try { |
643 | - if (file.getName().endsWith(SERIALIZED_FILE_EXTENSION)) { | 669 | + if (strArray[0].isEmpty()) { |
644 | - if (file.getName().contains(SLASH)) { | 670 | + List<String> stringArrangement = new ArrayList<String>(); |
645 | - String[] strArray = file.getName().split(SLASH); | 671 | + for (int i = 1; i < strArray.length; i++) { |
646 | - String tempPath = ""; | 672 | + stringArrangement.add(strArray[i]); |
647 | - for (int i = 0; i < strArray.length - 1; i++) { | ||
648 | - tempPath = SLASH + tempPath + SLASH + strArray[i]; | ||
649 | } | 673 | } |
650 | - File dir = new File(directory + tempPath); | 674 | + strArray = stringArrangement.toArray(new String[stringArrangement.size()]); |
651 | - dir.mkdirs(); | ||
652 | - } | ||
653 | - File serailizedFile = new File(directory + SLASH + file.getName()); | ||
654 | - if (file.isDirectory()) { | ||
655 | - serailizedFile.mkdirs(); | ||
656 | - continue; | ||
657 | } | 675 | } |
658 | - InputStream inputStream = jar.getInputStream(file); | 676 | + prefixForIdentifier = strArray[0]; |
659 | - | 677 | + for (int j = 1; j < strArray.length; j++) { |
660 | - FileOutputStream fileOutputStream = new FileOutputStream(serailizedFile); | 678 | + prefixForIdentifier = prefixForIdentifier + strArray[j].substring(0, 1).toUpperCase() + |
661 | - while (inputStream.available() > 0) { | 679 | + strArray[j].substring(1); |
662 | - fileOutputStream.write(inputStream.read()); | ||
663 | } | 680 | } |
664 | - fileOutputStream.close(); | 681 | + } catch (ArrayIndexOutOfBoundsException outOfBoundsException) { |
665 | - inputStream.close(); | 682 | + throw new TranslatorException("The given prefix in pom.xml is invalid."); |
666 | - serailizedFiles.add(serailizedFile.toString()); | ||
667 | } | 683 | } |
684 | + } else { | ||
685 | + prefixForIdentifier = YANG_AUTO_PREFIX; | ||
668 | } | 686 | } |
669 | - jar.close(); | 687 | + return prefixForIdentifier; |
670 | - return serailizedFiles; | ||
671 | } | 688 | } |
672 | - | ||
673 | } | 689 | } | ... | ... |
... | @@ -14,7 +14,7 @@ | ... | @@ -14,7 +14,7 @@ |
14 | * limitations under the License. | 14 | * limitations under the License. |
15 | */ | 15 | */ |
16 | 16 | ||
17 | -package org.onosproject.yangutils.translator.tojava.utils; | 17 | +package org.onosproject.yangutils.utils.io.impl; |
18 | 18 | ||
19 | /** | 19 | /** |
20 | * Representation of plugin configurations required for YANG utils. | 20 | * Representation of plugin configurations required for YANG utils. | ... | ... |
... | @@ -14,7 +14,7 @@ | ... | @@ -14,7 +14,7 @@ |
14 | * limitations under the License. | 14 | * limitations under the License. |
15 | */ | 15 | */ |
16 | 16 | ||
17 | -package org.onosproject.yangutils.translator.tojava.utils; | 17 | +package org.onosproject.yangutils.utils.io.impl; |
18 | 18 | ||
19 | /** | 19 | /** |
20 | * Representation of YANG to java naming conflict resolver util. | 20 | * Representation of YANG to java naming conflict resolver util. | ... | ... |
... | @@ -22,7 +22,7 @@ import org.onosproject.yangutils.linker.impl.YangLinkerManager; | ... | @@ -22,7 +22,7 @@ import org.onosproject.yangutils.linker.impl.YangLinkerManager; |
22 | import org.onosproject.yangutils.parser.exceptions.ParserException; | 22 | import org.onosproject.yangutils.parser.exceptions.ParserException; |
23 | import org.onosproject.yangutils.parser.impl.YangUtilsParserManager; | 23 | import org.onosproject.yangutils.parser.impl.YangUtilsParserManager; |
24 | import org.onosproject.yangutils.plugin.manager.YangUtilManager; | 24 | import org.onosproject.yangutils.plugin.manager.YangUtilManager; |
25 | -import org.onosproject.yangutils.translator.tojava.utils.YangPluginConfig; | 25 | +import org.onosproject.yangutils.utils.io.impl.YangPluginConfig; |
26 | import org.onosproject.yangutils.utils.io.impl.YangFileScanner; | 26 | import org.onosproject.yangutils.utils.io.impl.YangFileScanner; |
27 | 27 | ||
28 | import java.io.IOException; | 28 | import java.io.IOException; | ... | ... |
... | @@ -34,10 +34,9 @@ import org.onosproject.yangutils.datamodel.utils.ResolvableStatus; | ... | @@ -34,10 +34,9 @@ import org.onosproject.yangutils.datamodel.utils.ResolvableStatus; |
34 | import org.onosproject.yangutils.linker.impl.YangLinkerManager; | 34 | import org.onosproject.yangutils.linker.impl.YangLinkerManager; |
35 | import org.onosproject.yangutils.parser.exceptions.ParserException; | 35 | import org.onosproject.yangutils.parser.exceptions.ParserException; |
36 | import org.onosproject.yangutils.parser.impl.YangUtilsParserManager; | 36 | import org.onosproject.yangutils.parser.impl.YangUtilsParserManager; |
37 | -import org.onosproject.yangutils.plugin.manager.YangFileInfo; | ||
38 | import org.onosproject.yangutils.plugin.manager.YangUtilManager; | 37 | import org.onosproject.yangutils.plugin.manager.YangUtilManager; |
39 | -import org.onosproject.yangutils.translator.tojava.utils.YangPluginConfig; | ||
40 | import org.onosproject.yangutils.utils.io.impl.YangFileScanner; | 38 | import org.onosproject.yangutils.utils.io.impl.YangFileScanner; |
39 | +import org.onosproject.yangutils.utils.io.impl.YangPluginConfig; | ||
41 | 40 | ||
42 | import static org.hamcrest.CoreMatchers.nullValue; | 41 | import static org.hamcrest.CoreMatchers.nullValue; |
43 | import static org.hamcrest.MatcherAssert.assertThat; | 42 | import static org.hamcrest.MatcherAssert.assertThat; |
... | @@ -67,29 +66,30 @@ public class InterFileLinkingTest { | ... | @@ -67,29 +66,30 @@ public class InterFileLinkingTest { |
67 | String searchDir = "src/test/resources/interfiletype"; | 66 | String searchDir = "src/test/resources/interfiletype"; |
68 | utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(searchDir)); | 67 | utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(searchDir)); |
69 | utilManager.parseYangFileInfoSet(); | 68 | utilManager.parseYangFileInfoSet(); |
69 | + utilManager.createYangNodeSet(); | ||
70 | 70 | ||
71 | YangNode refNode = null; | 71 | YangNode refNode = null; |
72 | YangNode selfNode = null; | 72 | YangNode selfNode = null; |
73 | 73 | ||
74 | // Create YANG node set | 74 | // Create YANG node set |
75 | - yangLinkerManager.createYangNodeSet(utilManager.getYangFileInfoSet()); | 75 | + yangLinkerManager.createYangNodeSet(utilManager.getYangNodeSet()); |
76 | 76 | ||
77 | // Add references to import list. | 77 | // Add references to import list. |
78 | - yangLinkerManager.addRefToYangFilesImportList(utilManager.getYangFileInfoSet()); | 78 | + yangLinkerManager.addRefToYangFilesImportList(utilManager.getYangNodeSet()); |
79 | 79 | ||
80 | // Carry out inter-file linking. | 80 | // Carry out inter-file linking. |
81 | - yangLinkerManager.processInterFileLinking(utilManager.getYangFileInfoSet()); | 81 | + yangLinkerManager.processInterFileLinking(utilManager.getYangNodeSet()); |
82 | 82 | ||
83 | - Iterator<YangFileInfo> yangFileInfoIterator = utilManager.getYangFileInfoSet().iterator(); | 83 | + Iterator<YangNode> yangNodeIterator = utilManager.getYangNodeSet().iterator(); |
84 | 84 | ||
85 | - YangFileInfo yangFileInfo = yangFileInfoIterator.next(); | 85 | + YangNode rootNode = yangNodeIterator.next(); |
86 | 86 | ||
87 | - if (yangFileInfo.getRootNode().getName().equals("module1")) { | 87 | + if (rootNode.getName().equals("module1")) { |
88 | - selfNode = yangFileInfo.getRootNode(); | 88 | + selfNode = rootNode; |
89 | - refNode = yangFileInfoIterator.next().getRootNode(); | 89 | + refNode = yangNodeIterator.next(); |
90 | } else { | 90 | } else { |
91 | - refNode = yangFileInfo.getRootNode(); | 91 | + refNode = rootNode; |
92 | - selfNode = yangFileInfoIterator.next().getRootNode(); | 92 | + selfNode = yangNodeIterator.next(); |
93 | } | 93 | } |
94 | 94 | ||
95 | // Check whether the data model tree returned is of type module. | 95 | // Check whether the data model tree returned is of type module. |
... | @@ -136,29 +136,30 @@ public class InterFileLinkingTest { | ... | @@ -136,29 +136,30 @@ public class InterFileLinkingTest { |
136 | String searchDir = "src/test/resources/interfileuses"; | 136 | String searchDir = "src/test/resources/interfileuses"; |
137 | utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(searchDir)); | 137 | utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(searchDir)); |
138 | utilManager.parseYangFileInfoSet(); | 138 | utilManager.parseYangFileInfoSet(); |
139 | + utilManager.createYangNodeSet(); | ||
139 | 140 | ||
140 | YangNode refNode = null; | 141 | YangNode refNode = null; |
141 | YangNode selfNode = null; | 142 | YangNode selfNode = null; |
142 | 143 | ||
143 | // Create YANG node set | 144 | // Create YANG node set |
144 | - yangLinkerManager.createYangNodeSet(utilManager.getYangFileInfoSet()); | 145 | + yangLinkerManager.createYangNodeSet(utilManager.getYangNodeSet()); |
145 | 146 | ||
146 | // Add references to import list. | 147 | // Add references to import list. |
147 | - yangLinkerManager.addRefToYangFilesImportList(utilManager.getYangFileInfoSet()); | 148 | + yangLinkerManager.addRefToYangFilesImportList(utilManager.getYangNodeSet()); |
148 | 149 | ||
149 | // Carry out inter-file linking. | 150 | // Carry out inter-file linking. |
150 | - yangLinkerManager.processInterFileLinking(utilManager.getYangFileInfoSet()); | 151 | + yangLinkerManager.processInterFileLinking(utilManager.getYangNodeSet()); |
151 | 152 | ||
152 | - Iterator<YangFileInfo> yangFileInfoIterator = utilManager.getYangFileInfoSet().iterator(); | 153 | + Iterator<YangNode> yangNodeIterator = utilManager.getYangNodeSet().iterator(); |
153 | 154 | ||
154 | - YangFileInfo yangFileInfo = yangFileInfoIterator.next(); | 155 | + YangNode rootNode = yangNodeIterator.next(); |
155 | 156 | ||
156 | - if (yangFileInfo.getRootNode().getName().equals("module1")) { | 157 | + if (rootNode.getName().equals("module1")) { |
157 | - selfNode = yangFileInfo.getRootNode(); | 158 | + selfNode = rootNode; |
158 | - refNode = yangFileInfoIterator.next().getRootNode(); | 159 | + refNode = yangNodeIterator.next(); |
159 | } else { | 160 | } else { |
160 | - refNode = yangFileInfo.getRootNode(); | 161 | + refNode = rootNode; |
161 | - selfNode = yangFileInfoIterator.next().getRootNode(); | 162 | + selfNode = yangNodeIterator.next(); |
162 | } | 163 | } |
163 | 164 | ||
164 | // Check whether the data model tree returned is of type module. | 165 | // Check whether the data model tree returned is of type module. |
... | @@ -193,14 +194,6 @@ public class InterFileLinkingTest { | ... | @@ -193,14 +194,6 @@ public class InterFileLinkingTest { |
193 | // Check whether uses get resolved. | 194 | // Check whether uses get resolved. |
194 | assertThat(uses.getResolvableStatus(), | 195 | assertThat(uses.getResolvableStatus(), |
195 | is(ResolvableStatus.RESOLVED)); | 196 | is(ResolvableStatus.RESOLVED)); |
196 | - | ||
197 | -// leafIterator = yangNode.getListOfLeaf().listIterator(); | ||
198 | -// leafInfo = leafIterator.next(); | ||
199 | -// | ||
200 | -// // Check whether the information in the leaf is correct under module. | ||
201 | -// assertThat(leafInfo.getName(), is("hello")); | ||
202 | -// assertThat(leafInfo.getDataType().getDataTypeName(), is("string")); | ||
203 | -// assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.STRING)); | ||
204 | } | 197 | } |
205 | 198 | ||
206 | /** | 199 | /** |
... | @@ -213,32 +206,33 @@ public class InterFileLinkingTest { | ... | @@ -213,32 +206,33 @@ public class InterFileLinkingTest { |
213 | String searchDir = "src/test/resources/interfiletypewithinclude"; | 206 | String searchDir = "src/test/resources/interfiletypewithinclude"; |
214 | utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(searchDir)); | 207 | utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(searchDir)); |
215 | utilManager.parseYangFileInfoSet(); | 208 | utilManager.parseYangFileInfoSet(); |
209 | + utilManager.createYangNodeSet(); | ||
216 | 210 | ||
217 | YangNode refNode = null; | 211 | YangNode refNode = null; |
218 | YangNode selfNode = null; | 212 | YangNode selfNode = null; |
219 | 213 | ||
220 | // Create YANG node set | 214 | // Create YANG node set |
221 | - yangLinkerManager.createYangNodeSet(utilManager.getYangFileInfoSet()); | 215 | + yangLinkerManager.createYangNodeSet(utilManager.getYangNodeSet()); |
222 | 216 | ||
223 | // Carry out linking of sub module with module. | 217 | // Carry out linking of sub module with module. |
224 | - yangLinkerManager.linkSubModulesToParentModule(utilManager.getYangFileInfoSet()); | 218 | + yangLinkerManager.linkSubModulesToParentModule(utilManager.getYangNodeSet()); |
225 | 219 | ||
226 | // Add reference to include list. | 220 | // Add reference to include list. |
227 | - yangLinkerManager.addRefToYangFilesIncludeList(utilManager.getYangFileInfoSet()); | 221 | + yangLinkerManager.addRefToYangFilesIncludeList(utilManager.getYangNodeSet()); |
228 | 222 | ||
229 | // Carry out inter-file linking. | 223 | // Carry out inter-file linking. |
230 | - yangLinkerManager.processInterFileLinking(utilManager.getYangFileInfoSet()); | 224 | + yangLinkerManager.processInterFileLinking(utilManager.getYangNodeSet()); |
231 | 225 | ||
232 | - Iterator<YangFileInfo> yangFileInfoIterator = utilManager.getYangFileInfoSet().iterator(); | 226 | + Iterator<YangNode> yangNodeIterator = utilManager.getYangNodeSet().iterator(); |
233 | 227 | ||
234 | - YangFileInfo yangFileInfo = yangFileInfoIterator.next(); | 228 | + YangNode rootNode = yangNodeIterator.next(); |
235 | 229 | ||
236 | - if (yangFileInfo.getRootNode().getName().equals("module1")) { | 230 | + if (rootNode.getName().equals("module1")) { |
237 | - selfNode = yangFileInfo.getRootNode(); | 231 | + selfNode = rootNode; |
238 | - refNode = yangFileInfoIterator.next().getRootNode(); | 232 | + refNode = yangNodeIterator.next(); |
239 | } else { | 233 | } else { |
240 | - refNode = yangFileInfo.getRootNode(); | 234 | + refNode = rootNode; |
241 | - selfNode = yangFileInfoIterator.next().getRootNode(); | 235 | + selfNode = yangNodeIterator.next(); |
242 | } | 236 | } |
243 | 237 | ||
244 | // Check whether the data model tree returned is of type module. | 238 | // Check whether the data model tree returned is of type module. |
... | @@ -285,32 +279,33 @@ public class InterFileLinkingTest { | ... | @@ -285,32 +279,33 @@ public class InterFileLinkingTest { |
285 | String searchDir = "src/test/resources/interfileuseswithinclude"; | 279 | String searchDir = "src/test/resources/interfileuseswithinclude"; |
286 | utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(searchDir)); | 280 | utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(searchDir)); |
287 | utilManager.parseYangFileInfoSet(); | 281 | utilManager.parseYangFileInfoSet(); |
282 | + utilManager.createYangNodeSet(); | ||
288 | 283 | ||
289 | YangNode refNode = null; | 284 | YangNode refNode = null; |
290 | YangNode selfNode = null; | 285 | YangNode selfNode = null; |
291 | 286 | ||
292 | // Create YANG node set | 287 | // Create YANG node set |
293 | - yangLinkerManager.createYangNodeSet(utilManager.getYangFileInfoSet()); | 288 | + yangLinkerManager.createYangNodeSet(utilManager.getYangNodeSet()); |
294 | 289 | ||
295 | // Carry out linking of sub module with module. | 290 | // Carry out linking of sub module with module. |
296 | - yangLinkerManager.linkSubModulesToParentModule(utilManager.getYangFileInfoSet()); | 291 | + yangLinkerManager.linkSubModulesToParentModule(utilManager.getYangNodeSet()); |
297 | 292 | ||
298 | // Add reference to include list. | 293 | // Add reference to include list. |
299 | - yangLinkerManager.addRefToYangFilesIncludeList(utilManager.getYangFileInfoSet()); | 294 | + yangLinkerManager.addRefToYangFilesIncludeList(utilManager.getYangNodeSet()); |
300 | 295 | ||
301 | // Carry out inter-file linking. | 296 | // Carry out inter-file linking. |
302 | - yangLinkerManager.processInterFileLinking(utilManager.getYangFileInfoSet()); | 297 | + yangLinkerManager.processInterFileLinking(utilManager.getYangNodeSet()); |
303 | 298 | ||
304 | - Iterator<YangFileInfo> yangFileInfoIterator = utilManager.getYangFileInfoSet().iterator(); | 299 | + Iterator<YangNode> yangNodeIterator = utilManager.getYangNodeSet().iterator(); |
305 | 300 | ||
306 | - YangFileInfo yangFileInfo = yangFileInfoIterator.next(); | 301 | + YangNode rootNode = yangNodeIterator.next(); |
307 | 302 | ||
308 | - if (yangFileInfo.getRootNode().getName().equals("module1")) { | 303 | + if (rootNode.getName().equals("module1")) { |
309 | - selfNode = yangFileInfo.getRootNode(); | 304 | + selfNode = rootNode; |
310 | - refNode = yangFileInfoIterator.next().getRootNode(); | 305 | + refNode = yangNodeIterator.next(); |
311 | } else { | 306 | } else { |
312 | - refNode = yangFileInfo.getRootNode(); | 307 | + refNode = rootNode; |
313 | - selfNode = yangFileInfoIterator.next().getRootNode(); | 308 | + selfNode = yangNodeIterator.next(); |
314 | } | 309 | } |
315 | 310 | ||
316 | // Check whether the data model tree returned is of type module. | 311 | // Check whether the data model tree returned is of type module. |
... | @@ -345,14 +340,6 @@ public class InterFileLinkingTest { | ... | @@ -345,14 +340,6 @@ public class InterFileLinkingTest { |
345 | // Check whether uses get resolved. | 340 | // Check whether uses get resolved. |
346 | assertThat(uses.getResolvableStatus(), | 341 | assertThat(uses.getResolvableStatus(), |
347 | is(ResolvableStatus.RESOLVED)); | 342 | is(ResolvableStatus.RESOLVED)); |
348 | - | ||
349 | -// leafIterator = yangNode.getListOfLeaf().listIterator(); | ||
350 | -// leafInfo = leafIterator.next(); | ||
351 | -// | ||
352 | -// // Check whether the information in the leaf is correct under module. | ||
353 | -// assertThat(leafInfo.getName(), is("hello")); | ||
354 | -// assertThat(leafInfo.getDataType().getDataTypeName(), is("string")); | ||
355 | -// assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.STRING)); | ||
356 | } | 343 | } |
357 | 344 | ||
358 | /** | 345 | /** |
... | @@ -365,29 +352,30 @@ public class InterFileLinkingTest { | ... | @@ -365,29 +352,30 @@ public class InterFileLinkingTest { |
365 | String searchDir = "src/test/resources/interfiletypewithrevision"; | 352 | String searchDir = "src/test/resources/interfiletypewithrevision"; |
366 | utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(searchDir)); | 353 | utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(searchDir)); |
367 | utilManager.parseYangFileInfoSet(); | 354 | utilManager.parseYangFileInfoSet(); |
355 | + utilManager.createYangNodeSet(); | ||
368 | 356 | ||
369 | YangNode refNode = null; | 357 | YangNode refNode = null; |
370 | YangNode selfNode = null; | 358 | YangNode selfNode = null; |
371 | 359 | ||
372 | // Create YANG node set | 360 | // Create YANG node set |
373 | - yangLinkerManager.createYangNodeSet(utilManager.getYangFileInfoSet()); | 361 | + yangLinkerManager.createYangNodeSet(utilManager.getYangNodeSet()); |
374 | 362 | ||
375 | // Add references to import list. | 363 | // Add references to import list. |
376 | - yangLinkerManager.addRefToYangFilesImportList(utilManager.getYangFileInfoSet()); | 364 | + yangLinkerManager.addRefToYangFilesImportList(utilManager.getYangNodeSet()); |
377 | 365 | ||
378 | // Carry out inter-file linking. | 366 | // Carry out inter-file linking. |
379 | - yangLinkerManager.processInterFileLinking(utilManager.getYangFileInfoSet()); | 367 | + yangLinkerManager.processInterFileLinking(utilManager.getYangNodeSet()); |
380 | 368 | ||
381 | - Iterator<YangFileInfo> yangFileInfoIterator = utilManager.getYangFileInfoSet().iterator(); | 369 | + Iterator<YangNode> yangNodeIterator = utilManager.getYangNodeSet().iterator(); |
382 | 370 | ||
383 | - YangFileInfo yangFileInfo = yangFileInfoIterator.next(); | 371 | + YangNode rootNode = yangNodeIterator.next(); |
384 | 372 | ||
385 | - if (yangFileInfo.getRootNode().getName().equals("module1")) { | 373 | + if (rootNode.getName().equals("module1")) { |
386 | - selfNode = yangFileInfo.getRootNode(); | 374 | + selfNode = rootNode; |
387 | - refNode = yangFileInfoIterator.next().getRootNode(); | 375 | + refNode = yangNodeIterator.next(); |
388 | } else { | 376 | } else { |
389 | - refNode = yangFileInfo.getRootNode(); | 377 | + refNode = rootNode; |
390 | - selfNode = yangFileInfoIterator.next().getRootNode(); | 378 | + selfNode = yangNodeIterator.next(); |
391 | } | 379 | } |
392 | 380 | ||
393 | // Check whether the data model tree returned is of type module. | 381 | // Check whether the data model tree returned is of type module. |
... | @@ -434,29 +422,30 @@ public class InterFileLinkingTest { | ... | @@ -434,29 +422,30 @@ public class InterFileLinkingTest { |
434 | String searchDir = "src/test/resources/interfiletypewithrevisioninname"; | 422 | String searchDir = "src/test/resources/interfiletypewithrevisioninname"; |
435 | utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(searchDir)); | 423 | utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(searchDir)); |
436 | utilManager.parseYangFileInfoSet(); | 424 | utilManager.parseYangFileInfoSet(); |
425 | + utilManager.createYangNodeSet(); | ||
437 | 426 | ||
438 | YangNode refNode = null; | 427 | YangNode refNode = null; |
439 | YangNode selfNode = null; | 428 | YangNode selfNode = null; |
440 | 429 | ||
441 | // Create YANG node set | 430 | // Create YANG node set |
442 | - yangLinkerManager.createYangNodeSet(utilManager.getYangFileInfoSet()); | 431 | + yangLinkerManager.createYangNodeSet(utilManager.getYangNodeSet()); |
443 | 432 | ||
444 | // Add references to import list. | 433 | // Add references to import list. |
445 | - yangLinkerManager.addRefToYangFilesImportList(utilManager.getYangFileInfoSet()); | 434 | + yangLinkerManager.addRefToYangFilesImportList(utilManager.getYangNodeSet()); |
446 | 435 | ||
447 | // Carry out inter-file linking. | 436 | // Carry out inter-file linking. |
448 | - yangLinkerManager.processInterFileLinking(utilManager.getYangFileInfoSet()); | 437 | + yangLinkerManager.processInterFileLinking(utilManager.getYangNodeSet()); |
449 | 438 | ||
450 | - Iterator<YangFileInfo> yangFileInfoIterator = utilManager.getYangFileInfoSet().iterator(); | 439 | + Iterator<YangNode> yangNodeIterator = utilManager.getYangNodeSet().iterator(); |
451 | 440 | ||
452 | - YangFileInfo yangFileInfo = yangFileInfoIterator.next(); | 441 | + YangNode rootNode = yangNodeIterator.next(); |
453 | 442 | ||
454 | - if (yangFileInfo.getRootNode().getName().equals("module1")) { | 443 | + if (rootNode.getName().equals("module1")) { |
455 | - selfNode = yangFileInfo.getRootNode(); | 444 | + selfNode = rootNode; |
456 | - refNode = yangFileInfoIterator.next().getRootNode(); | 445 | + refNode = yangNodeIterator.next(); |
457 | } else { | 446 | } else { |
458 | - refNode = yangFileInfo.getRootNode(); | 447 | + refNode = rootNode; |
459 | - selfNode = yangFileInfoIterator.next().getRootNode(); | 448 | + selfNode = yangNodeIterator.next(); |
460 | } | 449 | } |
461 | 450 | ||
462 | // Check whether the data model tree returned is of type module. | 451 | // Check whether the data model tree returned is of type module. |
... | @@ -503,27 +492,28 @@ public class InterFileLinkingTest { | ... | @@ -503,27 +492,28 @@ public class InterFileLinkingTest { |
503 | String searchDir = "src/test/resources/hierarchicalinterfiletype"; | 492 | String searchDir = "src/test/resources/hierarchicalinterfiletype"; |
504 | utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(searchDir)); | 493 | utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(searchDir)); |
505 | utilManager.parseYangFileInfoSet(); | 494 | utilManager.parseYangFileInfoSet(); |
495 | + utilManager.createYangNodeSet(); | ||
506 | 496 | ||
507 | YangNode refNode1 = null; | 497 | YangNode refNode1 = null; |
508 | YangNode refNode2 = null; | 498 | YangNode refNode2 = null; |
509 | YangNode selfNode = null; | 499 | YangNode selfNode = null; |
510 | 500 | ||
511 | // Create YANG node set | 501 | // Create YANG node set |
512 | - yangLinkerManager.createYangNodeSet(utilManager.getYangFileInfoSet()); | 502 | + yangLinkerManager.createYangNodeSet(utilManager.getYangNodeSet()); |
513 | 503 | ||
514 | // Add references to import list. | 504 | // Add references to import list. |
515 | - yangLinkerManager.addRefToYangFilesImportList(utilManager.getYangFileInfoSet()); | 505 | + yangLinkerManager.addRefToYangFilesImportList(utilManager.getYangNodeSet()); |
516 | 506 | ||
517 | // Carry out inter-file linking. | 507 | // Carry out inter-file linking. |
518 | - yangLinkerManager.processInterFileLinking(utilManager.getYangFileInfoSet()); | 508 | + yangLinkerManager.processInterFileLinking(utilManager.getYangNodeSet()); |
519 | 509 | ||
520 | - for (YangFileInfo yangFile : utilManager.getYangFileInfoSet()) { | 510 | + for (YangNode rootNode : utilManager.getYangNodeSet()) { |
521 | - if (yangFile.getRootNode().getName().equals("ietf-network-topology")) { | 511 | + if (rootNode.getName().equals("ietf-network-topology")) { |
522 | - selfNode = yangFile.getRootNode(); | 512 | + selfNode = rootNode; |
523 | - } else if (yangFile.getRootNode().getName().equals("ietf-network")) { | 513 | + } else if (rootNode.getName().equals("ietf-network")) { |
524 | - refNode1 = yangFile.getRootNode(); | 514 | + refNode1 = rootNode; |
525 | } else { | 515 | } else { |
526 | - refNode2 = yangFile.getRootNode(); | 516 | + refNode2 = rootNode; |
527 | } | 517 | } |
528 | } | 518 | } |
529 | 519 | ||
... | @@ -571,24 +561,25 @@ public class InterFileLinkingTest { | ... | @@ -571,24 +561,25 @@ public class InterFileLinkingTest { |
571 | String searchDir = "src/test/resources/hierarchicalintrawithinterfiletype"; | 561 | String searchDir = "src/test/resources/hierarchicalintrawithinterfiletype"; |
572 | utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(searchDir)); | 562 | utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(searchDir)); |
573 | utilManager.parseYangFileInfoSet(); | 563 | utilManager.parseYangFileInfoSet(); |
564 | + utilManager.createYangNodeSet(); | ||
574 | 565 | ||
575 | YangNode refNode1 = null; | 566 | YangNode refNode1 = null; |
576 | YangNode selfNode = null; | 567 | YangNode selfNode = null; |
577 | 568 | ||
578 | // Create YANG node set | 569 | // Create YANG node set |
579 | - yangLinkerManager.createYangNodeSet(utilManager.getYangFileInfoSet()); | 570 | + yangLinkerManager.createYangNodeSet(utilManager.getYangNodeSet()); |
580 | 571 | ||
581 | // Add references to import list. | 572 | // Add references to import list. |
582 | - yangLinkerManager.addRefToYangFilesImportList(utilManager.getYangFileInfoSet()); | 573 | + yangLinkerManager.addRefToYangFilesImportList(utilManager.getYangNodeSet()); |
583 | 574 | ||
584 | // Carry out inter-file linking. | 575 | // Carry out inter-file linking. |
585 | - yangLinkerManager.processInterFileLinking(utilManager.getYangFileInfoSet()); | 576 | + yangLinkerManager.processInterFileLinking(utilManager.getYangNodeSet()); |
586 | 577 | ||
587 | - for (YangFileInfo yangFile : utilManager.getYangFileInfoSet()) { | 578 | + for (YangNode rootNode : utilManager.getYangNodeSet()) { |
588 | - if (yangFile.getRootNode().getName().equals("ietf-network")) { | 579 | + if (rootNode.getName().equals("ietf-network")) { |
589 | - selfNode = yangFile.getRootNode(); | 580 | + selfNode = rootNode; |
590 | - } else if (yangFile.getRootNode().getName().equals("ietf-inet-types")) { | 581 | + } else if (rootNode.getName().equals("ietf-inet-types")) { |
591 | - refNode1 = yangFile.getRootNode(); | 582 | + refNode1 = rootNode; |
592 | } | 583 | } |
593 | } | 584 | } |
594 | 585 | ... | ... |
1 | -/* | ||
2 | - * Copyright 2016-present Open Networking Laboratory | ||
3 | - * | ||
4 | - * Licensed under the Apache License, Version 2.0 (the "License"); | ||
5 | - * you may not use this file except in compliance with the License. | ||
6 | - * You may obtain a copy of the License at | ||
7 | - * | ||
8 | - * http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | - * | ||
10 | - * Unless required by applicable law or agreed to in writing, software | ||
11 | - * distributed under the License is distributed on an "AS IS" BASIS, | ||
12 | - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
13 | - * See the License for the specific language governing permissions and | ||
14 | - * limitations under the License. | ||
15 | - */ | ||
16 | - | ||
17 | -package org.onosproject.yangutils.linker; | ||
18 | - | ||
19 | -import java.io.File; | ||
20 | -import java.io.IOException; | ||
21 | -import java.util.ArrayList; | ||
22 | -import java.util.Iterator; | ||
23 | -import java.util.List; | ||
24 | -import java.util.ListIterator; | ||
25 | - | ||
26 | -import org.apache.maven.plugin.MojoExecutionException; | ||
27 | -import org.junit.Test; | ||
28 | -import org.onosproject.yangutils.datamodel.YangContainer; | ||
29 | -import org.onosproject.yangutils.datamodel.YangDerivedInfo; | ||
30 | -import org.onosproject.yangutils.datamodel.YangGrouping; | ||
31 | -import org.onosproject.yangutils.datamodel.YangLeaf; | ||
32 | -import org.onosproject.yangutils.datamodel.YangNode; | ||
33 | -import org.onosproject.yangutils.plugin.manager.YangFileInfo; | ||
34 | -import org.onosproject.yangutils.plugin.manager.YangUtilManager; | ||
35 | -import org.onosproject.yangutils.utils.io.impl.YangFileScanner; | ||
36 | - | ||
37 | -import static org.hamcrest.MatcherAssert.assertThat; | ||
38 | -import static org.hamcrest.core.Is.is; | ||
39 | -import static org.onosproject.yangutils.datamodel.YangDataTypes.DERIVED; | ||
40 | -import static org.onosproject.yangutils.datamodel.YangDataTypes.STRING; | ||
41 | -import static org.onosproject.yangutils.datamodel.utils.ResolvableStatus.RESOLVED; | ||
42 | -import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.deSerializeDataModel; | ||
43 | -import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.deleteDirectory; | ||
44 | -import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.parseJarFile; | ||
45 | - | ||
46 | -/** | ||
47 | - * Unit test case for inter-jar linker. | ||
48 | - */ | ||
49 | -public class InterJarLinkingTest { | ||
50 | - | ||
51 | - private final YangUtilManager utilManager = new YangUtilManager(); | ||
52 | - | ||
53 | - private static final String TARGET = "target/interJarFileLinking"; | ||
54 | - private static final String SEARCH_DIR_FOR_YANG_FILES = "src/test/resources/interJarFileLinking/yangFiles"; | ||
55 | - private static final String SEARCH_DIR_FOR_SINGLE_JAR_FILES = "src/test/resources/interJarFileLinking/" | ||
56 | - + "jarFiles/single"; | ||
57 | - private static final String SEARCH_DIR_FOR_MULTI_JAR_FILES = "src/test/resources/interJarFileLinking/" | ||
58 | - + "jarFiles/multi"; | ||
59 | - | ||
60 | - /** | ||
61 | - * Unit test case for a single jar dependency. | ||
62 | - * | ||
63 | - * @throws IOException when fails to do IO operations | ||
64 | - * @throws MojoExecutionException when fails to do mojo operations | ||
65 | - */ | ||
66 | - @Test | ||
67 | - public void processSingleJarLinking() | ||
68 | - throws IOException, MojoExecutionException { | ||
69 | - utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(SEARCH_DIR_FOR_YANG_FILES)); | ||
70 | - | ||
71 | - int size1 = utilManager.getYangFileInfoSet().size(); | ||
72 | - | ||
73 | - for (String file : getListOfTestJar(SEARCH_DIR_FOR_SINGLE_JAR_FILES)) { | ||
74 | - addInterJarRootNodes(file); | ||
75 | - } | ||
76 | - | ||
77 | - utilManager.parseYangFileInfoSet(); | ||
78 | - | ||
79 | - utilManager.resolveDependenciesUsingLinker(); | ||
80 | - | ||
81 | - Iterator<YangFileInfo> yangFileInfoIterator = utilManager.getYangFileInfoSet().iterator(); | ||
82 | - | ||
83 | - YangFileInfo yangFileInfo = yangFileInfoIterator.next(); | ||
84 | - | ||
85 | - int size2 = utilManager.getYangFileInfoSet().size(); | ||
86 | - assertThat(true, is(size1 != size2)); | ||
87 | - assertThat(true, is(yangFileInfo.getRootNode().getName().equals("port-pair"))); | ||
88 | - | ||
89 | - deleteDirectory(TARGET); | ||
90 | - | ||
91 | - } | ||
92 | - | ||
93 | - /** | ||
94 | - * Unit test case for a multiple jar dependency. | ||
95 | - * | ||
96 | - * @throws IOException when fails to do IO operations | ||
97 | - * @throws MojoExecutionException when fails to do mojo operations | ||
98 | - */ | ||
99 | - @Test | ||
100 | - public void processMultipleJarLinking() | ||
101 | - throws IOException, MojoExecutionException { | ||
102 | - utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(SEARCH_DIR_FOR_YANG_FILES)); | ||
103 | - | ||
104 | - int size1 = utilManager.getYangFileInfoSet().size(); | ||
105 | - | ||
106 | - for (String file : getListOfTestJar(SEARCH_DIR_FOR_MULTI_JAR_FILES)) { | ||
107 | - addInterJarRootNodes(file); | ||
108 | - } | ||
109 | - | ||
110 | - utilManager.parseYangFileInfoSet(); | ||
111 | - | ||
112 | - utilManager.resolveDependenciesUsingLinker(); | ||
113 | - | ||
114 | - Iterator<YangFileInfo> yangFileInfoIterator = utilManager.getYangFileInfoSet().iterator(); | ||
115 | - | ||
116 | - YangFileInfo yangFileInfo = yangFileInfoIterator.next(); | ||
117 | - | ||
118 | - int size2 = utilManager.getYangFileInfoSet().size(); | ||
119 | - assertThat(true, is(size1 != size2)); | ||
120 | - assertThat(true, is(yangFileInfo.getRootNode().getName().equals("port-pair"))); | ||
121 | - | ||
122 | - yangFileInfo = yangFileInfoIterator.next(); | ||
123 | - assertThat(true, is(yangFileInfo.getRootNode().getName().equals("flow-classifier"))); | ||
124 | - | ||
125 | - /* | ||
126 | - * grouping flow-classifier { | ||
127 | - * container flow-classifier { | ||
128 | - * leaf id { | ||
129 | - * type flow-classifier-id; | ||
130 | - * } | ||
131 | - * | ||
132 | - * leaf tenant-id { | ||
133 | - * type port-pair:tenant-id; | ||
134 | - * } | ||
135 | - * . | ||
136 | - * . | ||
137 | - * . | ||
138 | - * | ||
139 | - */ | ||
140 | - | ||
141 | - YangNode node = yangFileInfo.getRootNode(); | ||
142 | - node = node.getChild(); | ||
143 | - while (node != null) { | ||
144 | - if (node instanceof YangGrouping) { | ||
145 | - break; | ||
146 | - } | ||
147 | - node = node.getNextSibling(); | ||
148 | - } | ||
149 | - | ||
150 | - node = node.getChild(); | ||
151 | - ListIterator<YangLeaf> leafIterator = ((YangContainer) node).getListOfLeaf().listIterator(); | ||
152 | - YangLeaf leafInfo = leafIterator.next(); | ||
153 | - | ||
154 | - assertThat(leafInfo.getName(), is("id")); | ||
155 | - assertThat(leafInfo.getDataType().getDataTypeName(), is("flow-classifier-id")); | ||
156 | - assertThat(leafInfo.getDataType().getDataType(), is(DERIVED)); | ||
157 | - | ||
158 | - leafInfo = leafIterator.next(); | ||
159 | - | ||
160 | - assertThat(leafInfo.getName(), is("tenant-id")); | ||
161 | - assertThat(leafInfo.getDataType().getDataType(), is(DERIVED)); | ||
162 | - | ||
163 | - assertThat(true, is(((YangDerivedInfo<?>) leafInfo.getDataType().getDataTypeExtendedInfo()).getReferredTypeDef() | ||
164 | - .getName().equals("tenant-id"))); | ||
165 | - | ||
166 | - assertThat(leafInfo.getDataType().getResolvableStatus(), is(RESOLVED)); | ||
167 | - | ||
168 | - YangDerivedInfo<?> derivedInfo = (YangDerivedInfo<?>) leafInfo.getDataType().getDataTypeExtendedInfo(); | ||
169 | - | ||
170 | - // Check for the effective built-in type. | ||
171 | - assertThat(derivedInfo.getEffectiveBuiltInType(), is(STRING)); | ||
172 | - | ||
173 | - deleteDirectory(TARGET); | ||
174 | - } | ||
175 | - | ||
176 | - /** | ||
177 | - * Returns list of test jar files. | ||
178 | - * | ||
179 | - * @param searchdir search directory | ||
180 | - * @return list of test jar files | ||
181 | - */ | ||
182 | - private List<String> getListOfTestJar(String searchdir) { | ||
183 | - List<String> jarFiles = new ArrayList<>(); | ||
184 | - | ||
185 | - File directory = new File(searchdir + "/"); | ||
186 | - File[] files = directory.listFiles(); | ||
187 | - | ||
188 | - for (File file : files) { | ||
189 | - jarFiles.add(file.toString()); | ||
190 | - } | ||
191 | - | ||
192 | - return jarFiles; | ||
193 | - } | ||
194 | - | ||
195 | - /** | ||
196 | - * Adds data model nodes of jar to file info set. | ||
197 | - * | ||
198 | - * @param jarFile jar file name | ||
199 | - * @throws IOException when fails to do IO operations | ||
200 | - */ | ||
201 | - private void addInterJarRootNodes(String jarFile) throws IOException { | ||
202 | - try { | ||
203 | - List<YangNode> interJarResolvedNodes = deSerializeDataModel(parseJarFile(jarFile, TARGET)); | ||
204 | - | ||
205 | - for (YangNode node : interJarResolvedNodes) { | ||
206 | - YangFileInfo dependentFileInfo = new YangFileInfo(); | ||
207 | - dependentFileInfo.setRootNode(node); | ||
208 | - dependentFileInfo.setForTranslator(false); | ||
209 | - dependentFileInfo.setYangFileName(node.getName()); | ||
210 | - utilManager.getYangFileInfoSet().add(dependentFileInfo); | ||
211 | - } | ||
212 | - } catch (IOException e) { | ||
213 | - throw new IOException("failed to resolve in interjar scenario."); | ||
214 | - } | ||
215 | - } | ||
216 | - | ||
217 | -} |
... | @@ -17,6 +17,7 @@ | ... | @@ -17,6 +17,7 @@ |
17 | package org.onosproject.yangutils.linker; | 17 | package org.onosproject.yangutils.linker; |
18 | 18 | ||
19 | import java.io.IOException; | 19 | import java.io.IOException; |
20 | +import java.util.List; | ||
20 | import java.util.ListIterator; | 21 | import java.util.ListIterator; |
21 | import org.junit.Rule; | 22 | import org.junit.Rule; |
22 | import org.junit.Test; | 23 | import org.junit.Test; |
... | @@ -92,13 +93,15 @@ public class IntraFileUsesLinkingTest { | ... | @@ -92,13 +93,15 @@ public class IntraFileUsesLinkingTest { |
92 | assertThat(uses.getResolvableStatus(), | 93 | assertThat(uses.getResolvableStatus(), |
93 | is(ResolvableStatus.RESOLVED)); | 94 | is(ResolvableStatus.RESOLVED)); |
94 | 95 | ||
95 | -// leafIterator = yangNode.getListOfLeaf().listIterator(); | 96 | + ListIterator<List<YangLeaf>> leafIterator1 = uses.getUsesResolvedLeavesList().listIterator(); |
96 | -// leafInfo = leafIterator.next(); | 97 | + List<YangLeaf> leafInfo1 = leafIterator1.next(); |
97 | -// | 98 | + ListIterator<YangLeaf> leafIterator2 = leafInfo1.listIterator(); |
98 | -// // Check whether the information in the leaf is correct under module. | 99 | + YangLeaf leafInfo2 = leafIterator2.next(); |
99 | -// assertThat(leafInfo.getName(), is("hello")); | 100 | + |
100 | -// assertThat(leafInfo.getDataType().getDataTypeName(), is("string")); | 101 | + // Check whether the information in the leaf is correct under module. |
101 | -// assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.STRING)); | 102 | + assertThat(leafInfo2.getName(), is("hello")); |
103 | + assertThat(leafInfo2.getDataType().getDataTypeName(), is("string")); | ||
104 | + assertThat(leafInfo2.getDataType().getDataType(), is(YangDataTypes.STRING)); | ||
102 | 105 | ||
103 | } | 106 | } |
104 | 107 | ||
... | @@ -161,28 +164,32 @@ public class IntraFileUsesLinkingTest { | ... | @@ -161,28 +164,32 @@ public class IntraFileUsesLinkingTest { |
161 | assertThat(uses.getResolvableStatus(), | 164 | assertThat(uses.getResolvableStatus(), |
162 | is(ResolvableStatus.RESOLVED)); | 165 | is(ResolvableStatus.RESOLVED)); |
163 | 166 | ||
164 | -// leafIterator = yangNode.getListOfLeaf().listIterator(); | 167 | + ListIterator<List<YangLeaf>> leafIterator1 = uses.getUsesResolvedLeavesList().listIterator(); |
165 | -// leafInfo = leafIterator.next(); | 168 | + List<YangLeaf> leafInfo1 = leafIterator1.next(); |
166 | -// | 169 | + ListIterator<YangLeaf> leafIterator2 = leafInfo1.listIterator(); |
167 | -// // Check whether the information in the leaf is correct under module. | 170 | + YangLeaf leafInfo2 = leafIterator2.next(); |
168 | -// assertThat(leafInfo.getName(), is("treat")); | 171 | + |
169 | -// assertThat(leafInfo.getDataType().getDataTypeName(), is("string")); | 172 | + // Check whether the information in the leaf is correct under module. |
170 | -// assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.STRING)); | 173 | + assertThat(leafInfo2.getName(), is("treat")); |
171 | - | 174 | + assertThat(leafInfo2.getDataType().getDataTypeName(), is("string")); |
172 | -// // Check whether container is the child of module. | 175 | + assertThat(leafInfo2.getDataType().getDataType(), is(YangDataTypes.STRING)); |
173 | -// assertThat((grouping.getNextSibling() instanceof YangContainer), is(true)); | 176 | + |
174 | -// container = (YangContainer) grouping.getNextSibling(); | 177 | + ListIterator<YangNode> usesChildren = uses.getUsesResolvedNodeList().listIterator(); |
175 | -// | 178 | + YangNode usesChild = usesChildren.next(); |
176 | -// // Check whether the container name is set correctly which is under module. | 179 | + // Check whether container is the child of module. |
177 | -// assertThat(container.getName(), is("test")); | 180 | + assertThat((usesChild instanceof YangContainer), is(true)); |
178 | -// | 181 | + container = (YangContainer) usesChild; |
179 | -// leafIterator = container.getListOfLeaf().listIterator(); | 182 | + |
180 | -// leafInfo = leafIterator.next(); | 183 | + // Check whether the container name is set correctly which is under module. |
181 | -// | 184 | + assertThat(container.getName(), is("test")); |
182 | -// // Check whether the information in the leaf is correct under container which is under module. | 185 | + |
183 | -// assertThat(leafInfo.getName(), is("leaf2")); | 186 | + leafIterator = container.getListOfLeaf().listIterator(); |
184 | -// assertThat(leafInfo.getDataType().getDataTypeName(), is("string")); | 187 | + leafInfo = leafIterator.next(); |
185 | -// assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.STRING)); | 188 | + |
189 | + // Check whether the information in the leaf is correct under container which is under module. | ||
190 | + assertThat(leafInfo.getName(), is("leaf2")); | ||
191 | + assertThat(leafInfo.getDataType().getDataTypeName(), is("string")); | ||
192 | + assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.STRING)); | ||
186 | } | 193 | } |
187 | 194 | ||
188 | /** | 195 | /** |
... | @@ -241,52 +248,56 @@ public class IntraFileUsesLinkingTest { | ... | @@ -241,52 +248,56 @@ public class IntraFileUsesLinkingTest { |
241 | assertThat(uses.getResolvableStatus(), | 248 | assertThat(uses.getResolvableStatus(), |
242 | is(ResolvableStatus.RESOLVED)); | 249 | is(ResolvableStatus.RESOLVED)); |
243 | 250 | ||
244 | -// // Check whether list is the sibling of uses which has been deep copied from grouping. | 251 | + ListIterator<YangNode> usesChildren = uses.getUsesResolvedNodeList().listIterator(); |
245 | -// assertThat((yangNode.getChild().getChild().getNextSibling().getChild().getNextSibling() instanceof YangList), | 252 | + YangNode usesChild = usesChildren.next(); |
246 | -// is(true)); | 253 | + |
247 | -// YangList yangList = (YangList) yangNode.getChild().getChild().getNextSibling().getChild().getNextSibling(); | 254 | + // Check whether list is the sibling of uses which has been deep copied from grouping. |
248 | -// | 255 | + assertThat((usesChild instanceof YangList), is(true)); |
249 | -// // Check whether the list name is set correctly. | 256 | + |
250 | -// assertThat(yangList.getName(), is("valid")); | 257 | + YangList yangList = (YangList) usesChild; |
251 | -// | 258 | + |
252 | -// leafIterator = yangList.getListOfLeaf().listIterator(); | 259 | + // Check whether the list name is set correctly. |
253 | -// leafInfo = leafIterator.next(); | 260 | + assertThat(yangList.getName(), is("valid")); |
254 | -// | 261 | + |
255 | -// // Check whether the information in the leaf is correct under list which is deep copied. | 262 | + leafIterator = yangList.getListOfLeaf().listIterator(); |
256 | -// assertThat(leafInfo.getName(), is("invalid-interval")); | 263 | + leafInfo = leafIterator.next(); |
257 | -// assertThat(leafInfo.getDataType().getDataTypeName(), is("uint16")); | 264 | + |
258 | -// assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.UINT16)); | 265 | + // Check whether the information in the leaf is correct under list which is deep copied. |
259 | -// assertThat(leafInfo.getUnits(), is("\"seconds\"")); | 266 | + assertThat(leafInfo.getName(), is("invalid-interval")); |
260 | -// assertThat(leafInfo.getReference(), is("\"RFC 6020\"")); | 267 | + assertThat(leafInfo.getDataType().getDataTypeName(), is("uint16")); |
261 | -// | 268 | + assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.UINT16)); |
262 | -// // Check whether uses is output's child. | 269 | + assertThat(leafInfo.getUnits(), is("\"seconds\"")); |
263 | -// assertThat((yangNode.getChild().getChild().getNextSibling().getNextSibling().getChild() instanceof YangUses), | 270 | + assertThat(leafInfo.getReference(), is("\"RFC 6020\"")); |
264 | -// is(true)); | 271 | + |
265 | -// YangUses usesInOuput = (YangUses) yangNode.getChild().getChild().getNextSibling().getNextSibling().getChild(); | 272 | + // Check whether uses is output's child. |
266 | -// | 273 | + assertThat((yangNode.getChild().getChild().getNextSibling().getNextSibling().getChild() instanceof YangUses), |
267 | -// // Check whether uses get resolved. | 274 | + is(true)); |
268 | -// assertThat(usesInOuput.getResolvableStatus(), | 275 | + YangUses usesInOuput = (YangUses) yangNode.getChild().getChild().getNextSibling().getNextSibling().getChild(); |
269 | -// is(ResolvableStatus.RESOLVED)); | 276 | + |
270 | -// | 277 | + // Check whether uses get resolved. |
271 | -// // Check whether list is the sibling of uses which has been deep copied from grouping. | 278 | + assertThat(usesInOuput.getResolvableStatus(), |
272 | -// assertThat((yangNode.getChild().getChild().getNextSibling().getChild().getNextSibling() instanceof YangList), | 279 | + is(ResolvableStatus.RESOLVED)); |
273 | -// is(true)); | 280 | + |
274 | -// | 281 | + ListIterator<YangNode> usesInOuputChildren = usesInOuput.getUsesResolvedNodeList().listIterator(); |
275 | -// YangList yangListInOutput = (YangList) yangNode.getChild().getChild().getNextSibling().getNextSibling() | 282 | + YangNode usesInOuputChild = usesInOuputChildren.next(); |
276 | -// .getChild().getNextSibling(); | 283 | + |
277 | -// | 284 | + // Check whether list is the sibling of uses which has been deep copied from grouping. |
278 | -// // Check whether the list name is set correctly. | 285 | + assertThat((usesInOuputChild instanceof YangList), is(true)); |
279 | -// assertThat(yangListInOutput.getName(), is("valid")); | 286 | + |
280 | -// | 287 | + YangList yangListInOutput = (YangList) usesInOuputChild; |
281 | -// leafIterator = yangListInOutput.getListOfLeaf().listIterator(); | 288 | + |
282 | -// leafInfo = leafIterator.next(); | 289 | + // Check whether the list name is set correctly. |
283 | -// | 290 | + assertThat(yangListInOutput.getName(), is("valid")); |
284 | -// // Check whether the information in the leaf is correct under list which is deep copied. | 291 | + |
285 | -// assertThat(leafInfo.getName(), is("invalid-interval")); | 292 | + leafIterator = yangListInOutput.getListOfLeaf().listIterator(); |
286 | -// assertThat(leafInfo.getDataType().getDataTypeName(), is("uint16")); | 293 | + leafInfo = leafIterator.next(); |
287 | -// assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.UINT16)); | 294 | + |
288 | -// assertThat(leafInfo.getUnits(), is("\"seconds\"")); | 295 | + // Check whether the information in the leaf is correct under list which is deep copied. |
289 | -// assertThat(leafInfo.getReference(), is("\"RFC 6020\"")); | 296 | + assertThat(leafInfo.getName(), is("invalid-interval")); |
297 | + assertThat(leafInfo.getDataType().getDataTypeName(), is("uint16")); | ||
298 | + assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.UINT16)); | ||
299 | + assertThat(leafInfo.getUnits(), is("\"seconds\"")); | ||
300 | + assertThat(leafInfo.getReference(), is("\"RFC 6020\"")); | ||
290 | } | 301 | } |
291 | 302 | ||
292 | /** | 303 | /** |
... | @@ -342,6 +353,24 @@ public class IntraFileUsesLinkingTest { | ... | @@ -342,6 +353,24 @@ public class IntraFileUsesLinkingTest { |
342 | assertThat(firstUses.getResolvableStatus(), | 353 | assertThat(firstUses.getResolvableStatus(), |
343 | is(ResolvableStatus.RESOLVED)); | 354 | is(ResolvableStatus.RESOLVED)); |
344 | 355 | ||
356 | + ListIterator<YangNode> firstUsesChildren = firstUses.getUsesResolvedNodeList().listIterator(); | ||
357 | + YangNode firstUsesChild = firstUsesChildren.next(); | ||
358 | + | ||
359 | + // Check whether list is the sibling of uses. | ||
360 | + assertThat((firstUsesChild instanceof YangList), is(true)); | ||
361 | + YangList yangList = (YangList) firstUsesChild; | ||
362 | + assertThat(yangList.getName(), is("valid")); | ||
363 | + | ||
364 | + leafIterator = yangList.getListOfLeaf().listIterator(); | ||
365 | + leafInfo = leafIterator.next(); | ||
366 | + | ||
367 | + // Check whether the information in the leaf is correct under list which has been deep copied from grouping. | ||
368 | + assertThat(leafInfo.getName(), is("invalid-interval")); | ||
369 | + assertThat(leafInfo.getDataType().getDataTypeName(), is("uint16")); | ||
370 | + assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.UINT16)); | ||
371 | + assertThat(leafInfo.getUnits(), is("\"seconds\"")); | ||
372 | + assertThat(leafInfo.getReference(), is("\"RFC 6020\"")); | ||
373 | + | ||
345 | // Check whether container is the sibling of uses. | 374 | // Check whether container is the sibling of uses. |
346 | assertThat((firstUses.getNextSibling() instanceof YangContainer), is(true)); | 375 | assertThat((firstUses.getNextSibling() instanceof YangContainer), is(true)); |
347 | YangContainer yangContainer = (YangContainer) firstUses.getNextSibling(); | 376 | YangContainer yangContainer = (YangContainer) firstUses.getNextSibling(); |
... | @@ -349,14 +378,6 @@ public class IntraFileUsesLinkingTest { | ... | @@ -349,14 +378,6 @@ public class IntraFileUsesLinkingTest { |
349 | // Check whether the container name is set correctly. | 378 | // Check whether the container name is set correctly. |
350 | assertThat(yangContainer.getName(), is("design")); | 379 | assertThat(yangContainer.getName(), is("design")); |
351 | 380 | ||
352 | -// leafIterator = yangContainer.getListOfLeaf().listIterator(); | ||
353 | -// leafInfo = leafIterator.next(); | ||
354 | -// | ||
355 | -// // Check whether the information in the leaf is correct under design-container. | ||
356 | -// assertThat(leafInfo.getName(), is("ink")); | ||
357 | -// assertThat(leafInfo.getDataType().getDataTypeName(), is("int32")); | ||
358 | -// assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.INT32)); | ||
359 | - | ||
360 | // Check whether uses is design-container's child. | 381 | // Check whether uses is design-container's child. |
361 | assertThat((yangContainer.getChild() instanceof YangUses), is(true)); | 382 | assertThat((yangContainer.getChild() instanceof YangUses), is(true)); |
362 | YangUses secondUses = (YangUses) yangContainer.getChild(); | 383 | YangUses secondUses = (YangUses) yangContainer.getChild(); |
... | @@ -365,6 +386,16 @@ public class IntraFileUsesLinkingTest { | ... | @@ -365,6 +386,16 @@ public class IntraFileUsesLinkingTest { |
365 | assertThat(secondUses.getResolvableStatus(), | 386 | assertThat(secondUses.getResolvableStatus(), |
366 | is(ResolvableStatus.RESOLVED)); | 387 | is(ResolvableStatus.RESOLVED)); |
367 | 388 | ||
389 | + ListIterator<List<YangLeaf>> leafIterator1 = secondUses.getUsesResolvedLeavesList().listIterator(); | ||
390 | + List<YangLeaf> leafInfo1 = leafIterator1.next(); | ||
391 | + ListIterator<YangLeaf> leafIterator2 = leafInfo1.listIterator(); | ||
392 | + YangLeaf leafInfo2 = leafIterator2.next(); | ||
393 | + | ||
394 | + // Check whether the information in the leaf is correct under design-container. | ||
395 | + assertThat(leafInfo2.getName(), is("ink")); | ||
396 | + assertThat(leafInfo2.getDataType().getDataTypeName(), is("int32")); | ||
397 | + assertThat(leafInfo2.getDataType().getDataType(), is(YangDataTypes.INT32)); | ||
398 | + | ||
368 | // Check whether container is the sibling of uses. | 399 | // Check whether container is the sibling of uses. |
369 | assertThat((secondUses.getNextSibling() instanceof YangContainer), is(true)); | 400 | assertThat((secondUses.getNextSibling() instanceof YangContainer), is(true)); |
370 | YangContainer yangContainer2 = (YangContainer) secondUses.getNextSibling(); | 401 | YangContainer yangContainer2 = (YangContainer) secondUses.getNextSibling(); |
... | @@ -386,85 +417,88 @@ public class IntraFileUsesLinkingTest { | ... | @@ -386,85 +417,88 @@ public class IntraFileUsesLinkingTest { |
386 | assertThat(thirdUses.getResolvableStatus(), | 417 | assertThat(thirdUses.getResolvableStatus(), |
387 | is(ResolvableStatus.RESOLVED)); | 418 | is(ResolvableStatus.RESOLVED)); |
388 | 419 | ||
389 | -// // Check whether container is the sibling of uses. | 420 | + ListIterator<YangNode> thirdUsesChildren = thirdUses.getUsesResolvedNodeList().listIterator(); |
390 | -// assertThat((thirdUses.getNextSibling() instanceof YangContainer), is(true)); | 421 | + YangNode thirdUsesChild = thirdUsesChildren.next(); |
391 | -// | 422 | + |
392 | -// YangContainer yangContainer3 = (YangContainer) thirdUses.getNextSibling(); | 423 | + // Check whether container is the child of uses. |
393 | -// assertThat(yangContainer3.getName(), is("value")); | 424 | + assertThat((thirdUsesChild instanceof YangContainer), is(true)); |
394 | -// | 425 | + |
395 | -// leafIterator = yangContainer3.getListOfLeaf().listIterator(); | 426 | + YangContainer yangContainer3 = (YangContainer) thirdUsesChild; |
396 | -// leafInfo = leafIterator.next(); | 427 | + assertThat(yangContainer3.getName(), is("value")); |
397 | -// | 428 | + |
398 | -// // Check whether the information in the leaf is correct under container | 429 | + leafIterator = yangContainer3.getListOfLeaf().listIterator(); |
399 | -// // which has been deep copied from grouping. | 430 | + leafInfo = leafIterator.next(); |
400 | -// assertThat(leafInfo.getName(), is("zip-code")); | 431 | + |
401 | -// assertThat(leafInfo.getDataType().getDataTypeName(), is("string")); | 432 | + // Check whether the information in the leaf is correct under container |
402 | -// assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.STRING)); | 433 | + // which has been deep copied from grouping. |
403 | -// | 434 | + assertThat(leafInfo.getName(), is("zip-code")); |
404 | -// // Check whether uses is the sibling of container-design. | 435 | + assertThat(leafInfo.getDataType().getDataTypeName(), is("string")); |
405 | -// assertThat((yangContainer.getNextSibling() instanceof YangUses), is(true)); | 436 | + assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.STRING)); |
406 | -// YangUses fourthUses = (YangUses) yangContainer.getNextSibling(); | 437 | + |
407 | -// | 438 | + |
408 | -// // Check whether uses get resolved. | 439 | + // Check whether uses is the sibling of container-design. |
409 | -// assertThat(fourthUses.getResolvableStatus(), | 440 | + assertThat((yangContainer.getNextSibling() instanceof YangUses), is(true)); |
410 | -// is(ResolvableStatus.RESOLVED)); | 441 | + YangUses fourthUses = (YangUses) yangContainer.getNextSibling(); |
411 | -// | 442 | + assertThat(fourthUses.getName(), is("fourth")); |
412 | -// // Check whether uses is the sibling of previous uses. | 443 | + // Check whether uses get resolved. |
413 | -// assertThat((fourthUses.getNextSibling() instanceof YangUses), is(true)); | 444 | + assertThat(fourthUses.getResolvableStatus(), |
414 | -// YangUses fifthUses = (YangUses) fourthUses.getNextSibling(); | 445 | + is(ResolvableStatus.RESOLVED)); |
415 | -// | 446 | + |
416 | -// // Check whether uses get resolved. | 447 | + ListIterator<List<YangLeaf>> fourthUsesChildren = fourthUses.getUsesResolvedLeavesList().listIterator(); |
417 | -// assertThat(fifthUses.getResolvableStatus(), | 448 | + List<YangLeaf> fourthUsesChild = fourthUsesChildren.next(); |
418 | -// is(ResolvableStatus.RESOLVED)); | 449 | + ListIterator<YangLeaf> fourthUsesChildren1 = fourthUsesChild.listIterator(); |
419 | -// | 450 | + YangLeaf fourthUsesChild1 = fourthUsesChildren1.next(); |
420 | -// // Check whether list is the sibling of uses. | 451 | + |
421 | -// assertThat((fifthUses.getNextSibling() instanceof YangList), is(true)); | 452 | + // Check whether the information in the leaf is correct under correct-container. |
422 | -// YangList yangList = (YangList) fifthUses.getNextSibling(); | 453 | + assertThat(fourthUsesChild1.getName(), is("correct")); |
423 | -// assertThat(yangList.getName(), is("valid")); | 454 | + assertThat(fourthUsesChild1.getDataType().getDataTypeName(), is("my-type")); |
424 | -// | 455 | + assertThat(fourthUsesChild1.getDataType().getDataType(), is(YangDataTypes.DERIVED)); |
425 | -// leafIterator = yangList.getListOfLeaf().listIterator(); | 456 | + |
426 | -// leafInfo = leafIterator.next(); | 457 | + // Check whether uses is the sibling of previous uses. |
427 | -// | 458 | + assertThat((fourthUses.getNextSibling() instanceof YangUses), is(true)); |
428 | -// // Check whether the information in the leaf is correct under list which has been deep copied from grouping. | 459 | + YangUses fifthUses = (YangUses) fourthUses.getNextSibling(); |
429 | -// assertThat(leafInfo.getName(), is("invalid-interval")); | 460 | + assertThat(fifthUses.getName(), is("fifth")); |
430 | -// assertThat(leafInfo.getDataType().getDataTypeName(), is("uint16")); | 461 | + |
431 | -// assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.UINT16)); | 462 | + // Check whether uses get resolved. |
432 | -// assertThat(leafInfo.getUnits(), is("\"seconds\"")); | 463 | + assertThat(fifthUses.getResolvableStatus(), |
433 | -// assertThat(leafInfo.getReference(), is("\"RFC 6020\"")); | 464 | + is(ResolvableStatus.RESOLVED)); |
434 | -// | 465 | + |
435 | -// // Check whether typedef is the sibling of list. | 466 | + ListIterator<List<YangLeaf>> fifthUsesChildren = fifthUses.getUsesResolvedLeavesList().listIterator(); |
436 | -// assertThat((yangList.getNextSibling() instanceof YangTypeDef), is(true)); | 467 | + List<YangLeaf> fifthUsesChild = fifthUsesChildren.next(); |
437 | -// YangTypeDef yangTypeDef = (YangTypeDef) yangList.getNextSibling(); | 468 | + ListIterator<YangLeaf> fifthUsesChildren1 = fifthUsesChild.listIterator(); |
438 | -// assertThat(yangTypeDef.getName(), is("my-type")); | 469 | + YangLeaf fifthUsesChild1 = fifthUsesChildren1.next(); |
439 | -// | 470 | + |
440 | -// leafIterator = grouping.getListOfLeaf().listIterator(); | 471 | + //Check whether the information in the leaf is correct under correct-container. |
441 | -// leafInfo = leafIterator.next(); | 472 | + assertThat(fifthUsesChild1.getName(), is("abc")); |
442 | -// | 473 | + assertThat(fifthUsesChild1.getDataType().getDataTypeName(), is("string")); |
443 | -// // Check whether the information in the leaf is correct under grouping. | 474 | + assertThat(fifthUsesChild1.getDataType().getDataType(), is(YangDataTypes.STRING)); |
444 | -// assertThat(leafInfo.getName(), is("zip-code")); | 475 | + |
445 | -// assertThat(leafInfo.getDataType().getDataTypeName(), is("string")); | 476 | + //Check whether uses is endpoint-grouping's sibling. |
446 | -// assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.STRING)); | 477 | + assertThat((grouping.getNextSibling() instanceof YangUses), is(true)); |
447 | -// | 478 | + YangUses endpointUses = (YangUses) grouping.getNextSibling(); |
448 | -// // Check whether uses is endpoint-grouping's sibling. | 479 | + |
449 | -// assertThat((grouping.getNextSibling() instanceof YangUses), is(true)); | 480 | + // Check whether uses get resolved. |
450 | -// YangUses endpointUses = (YangUses) grouping.getNextSibling(); | 481 | + assertThat(endpointUses.getResolvableStatus(), |
451 | -// | 482 | + is(ResolvableStatus.RESOLVED)); |
452 | -// // Check whether uses get resolved. | 483 | + assertThat(endpointUses.getName(), is("endpoint")); |
453 | -// assertThat(endpointUses.getResolvableStatus(), | 484 | + |
454 | -// is(ResolvableStatus.RESOLVED)); | 485 | + ListIterator<YangNode> endpointUsesUsesChildren = endpointUses.getUsesResolvedNodeList().listIterator(); |
455 | -// | 486 | + YangNode endpointUsesUsesChild = endpointUsesUsesChildren.next(); |
456 | -// assertThat((endpointUses.getNextSibling().getNextSibling().getNextSibling().getNextSibling().getNextSibling() | 487 | + |
457 | -// .getNextSibling() instanceof YangUses), is(true)); | 488 | + // Check whether list is the sibling of uses. |
458 | -// | 489 | + assertThat((endpointUsesUsesChild instanceof YangList), is(true)); |
459 | -// YangUses yangUsesInEndpoint = (YangUses) endpointUses.getNextSibling().getNextSibling().getNextSibling() | 490 | + YangList yangList1 = (YangList) firstUsesChild; |
460 | -// .getNextSibling().getNextSibling().getNextSibling(); | 491 | + assertThat(yangList1.getName(), is("valid")); |
461 | -// assertThat(yangUsesInEndpoint.getResolvableStatus(), | 492 | + |
462 | -// is(ResolvableStatus.RESOLVED)); | 493 | + leafIterator = yangList1.getListOfLeaf().listIterator(); |
463 | -// | 494 | + leafInfo = leafIterator.next(); |
464 | -// assertThat((yangUsesInEndpoint.getNextSibling() instanceof YangContainer), is(true)); | 495 | + |
465 | -// YangContainer yangContainerInEndPoint = (YangContainer) yangUsesInEndpoint.getNextSibling(); | 496 | + // Check whether the information in the leaf is correct under list which has been deep copied from grouping. |
466 | -// | 497 | + assertThat(leafInfo.getName(), is("invalid-interval")); |
467 | -// assertThat(yangContainerInEndPoint.getName(), is("design")); | 498 | + assertThat(leafInfo.getDataType().getDataTypeName(), is("uint16")); |
499 | + assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.UINT16)); | ||
500 | + assertThat(leafInfo.getUnits(), is("\"seconds\"")); | ||
501 | + assertThat(leafInfo.getReference(), is("\"RFC 6020\"")); | ||
468 | } | 502 | } |
469 | 503 | ||
470 | /** | 504 | /** | ... | ... |
... | @@ -26,8 +26,10 @@ import org.onosproject.yangutils.datamodel.YangNode; | ... | @@ -26,8 +26,10 @@ import org.onosproject.yangutils.datamodel.YangNode; |
26 | import org.onosproject.yangutils.datamodel.YangType; | 26 | import org.onosproject.yangutils.datamodel.YangType; |
27 | import org.onosproject.yangutils.datamodel.exceptions.DataModelException; | 27 | import org.onosproject.yangutils.datamodel.exceptions.DataModelException; |
28 | import org.onosproject.yangutils.translator.tojava.JavaFileInfo; | 28 | import org.onosproject.yangutils.translator.tojava.JavaFileInfo; |
29 | +import org.onosproject.yangutils.translator.tojava.javamodel.AttributesJavaDataType; | ||
29 | import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaModule; | 30 | import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaModule; |
30 | import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaTypeDef; | 31 | import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaTypeDef; |
32 | +import org.onosproject.yangutils.utils.io.impl.YangToJavaNamingConflictUtil; | ||
31 | 33 | ||
32 | import static org.hamcrest.core.Is.is; | 34 | import static org.hamcrest.core.Is.is; |
33 | import static org.hamcrest.core.IsNot.not; | 35 | import static org.hamcrest.core.IsNot.not; |
... | @@ -37,9 +39,9 @@ import static org.onosproject.yangutils.datamodel.YangDataTypes.DERIVED; | ... | @@ -37,9 +39,9 @@ import static org.onosproject.yangutils.datamodel.YangDataTypes.DERIVED; |
37 | import static org.onosproject.yangutils.datamodel.YangDataTypes.INT32; | 39 | import static org.onosproject.yangutils.datamodel.YangDataTypes.INT32; |
38 | import static org.onosproject.yangutils.datamodel.YangDataTypes.STRING; | 40 | import static org.onosproject.yangutils.datamodel.YangDataTypes.STRING; |
39 | import static org.onosproject.yangutils.datamodel.YangDataTypes.UINT8; | 41 | import static org.onosproject.yangutils.datamodel.YangDataTypes.UINT8; |
40 | -import static org.onosproject.yangutils.translator.tojava.utils.AttributesJavaDataType.getJavaDataType; | 42 | +import static org.onosproject.yangutils.translator.tojava.javamodel.AttributesJavaDataType.getJavaDataType; |
41 | -import static org.onosproject.yangutils.translator.tojava.utils.AttributesJavaDataType.getJavaImportClass; | 43 | +import static org.onosproject.yangutils.translator.tojava.javamodel.AttributesJavaDataType.getJavaImportClass; |
42 | -import static org.onosproject.yangutils.translator.tojava.utils.AttributesJavaDataType.getJavaImportPackage; | 44 | +import static org.onosproject.yangutils.translator.tojava.javamodel.AttributesJavaDataType.getJavaImportPackage; |
43 | import static org.onosproject.yangutils.utils.UtilConstants.JAVA_LANG; | 45 | import static org.onosproject.yangutils.utils.UtilConstants.JAVA_LANG; |
44 | 46 | ||
45 | /** | 47 | /** | ... | ... |
... | @@ -22,6 +22,7 @@ import org.junit.Test; | ... | @@ -22,6 +22,7 @@ import org.junit.Test; |
22 | import org.onosproject.yangutils.datamodel.YangNode; | 22 | import org.onosproject.yangutils.datamodel.YangNode; |
23 | import org.onosproject.yangutils.parser.exceptions.ParserException; | 23 | import org.onosproject.yangutils.parser.exceptions.ParserException; |
24 | import org.onosproject.yangutils.parser.impl.YangUtilsParserManager; | 24 | import org.onosproject.yangutils.parser.impl.YangUtilsParserManager; |
25 | +import org.onosproject.yangutils.utils.io.impl.YangPluginConfig; | ||
25 | 26 | ||
26 | import static org.onosproject.yangutils.translator.tojava.JavaCodeGeneratorUtil.generateJavaCode; | 27 | import static org.onosproject.yangutils.translator.tojava.JavaCodeGeneratorUtil.generateJavaCode; |
27 | import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.deleteDirectory; | 28 | import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.deleteDirectory; | ... | ... |
... | @@ -22,6 +22,7 @@ import org.junit.Test; | ... | @@ -22,6 +22,7 @@ import org.junit.Test; |
22 | import org.onosproject.yangutils.datamodel.YangNode; | 22 | import org.onosproject.yangutils.datamodel.YangNode; |
23 | import org.onosproject.yangutils.parser.exceptions.ParserException; | 23 | import org.onosproject.yangutils.parser.exceptions.ParserException; |
24 | import org.onosproject.yangutils.parser.impl.YangUtilsParserManager; | 24 | import org.onosproject.yangutils.parser.impl.YangUtilsParserManager; |
25 | +import org.onosproject.yangutils.utils.io.impl.YangPluginConfig; | ||
25 | 26 | ||
26 | import static org.onosproject.yangutils.translator.tojava.JavaCodeGeneratorUtil.generateJavaCode; | 27 | import static org.onosproject.yangutils.translator.tojava.JavaCodeGeneratorUtil.generateJavaCode; |
27 | import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.deleteDirectory; | 28 | import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.deleteDirectory; | ... | ... |
... | @@ -23,16 +23,17 @@ import org.junit.Rule; | ... | @@ -23,16 +23,17 @@ import org.junit.Rule; |
23 | import org.junit.Test; | 23 | import org.junit.Test; |
24 | import org.junit.rules.ExpectedException; | 24 | import org.junit.rules.ExpectedException; |
25 | import org.onosproject.yangutils.translator.exception.TranslatorException; | 25 | import org.onosproject.yangutils.translator.exception.TranslatorException; |
26 | +import org.onosproject.yangutils.utils.io.impl.YangToJavaNamingConflictUtil; | ||
26 | 27 | ||
27 | import static org.hamcrest.core.Is.is; | 28 | import static org.hamcrest.core.Is.is; |
28 | import static org.hamcrest.core.IsNot.not; | 29 | import static org.hamcrest.core.IsNot.not; |
29 | import static org.junit.Assert.assertThat; | 30 | import static org.junit.Assert.assertThat; |
30 | -import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getCamelCase; | 31 | +import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getCamelCase; |
31 | -import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getCapitalCase; | 32 | +import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getCapitalCase; |
32 | -import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getJavaPackageFromPackagePath; | 33 | +import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getJavaPackageFromPackagePath; |
33 | -import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getPackageDirPathFromJavaJPackage; | 34 | +import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getPackageDirPathFromJavaJPackage; |
34 | import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getRootPackage; | 35 | import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getRootPackage; |
35 | -import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getSmallCase; | 36 | +import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getSmallCase; |
36 | import static org.onosproject.yangutils.utils.UtilConstants.DEFAULT_BASE_PKG; | 37 | import static org.onosproject.yangutils.utils.UtilConstants.DEFAULT_BASE_PKG; |
37 | import static org.onosproject.yangutils.utils.UtilConstants.PERIOD; | 38 | import static org.onosproject.yangutils.utils.UtilConstants.PERIOD; |
38 | 39 | ... | ... |
... | @@ -23,13 +23,14 @@ import org.junit.Test; | ... | @@ -23,13 +23,14 @@ import org.junit.Test; |
23 | import org.onosproject.yangutils.datamodel.YangType; | 23 | import org.onosproject.yangutils.datamodel.YangType; |
24 | import org.onosproject.yangutils.translator.tojava.JavaAttributeInfo; | 24 | import org.onosproject.yangutils.translator.tojava.JavaAttributeInfo; |
25 | import org.onosproject.yangutils.translator.tojava.JavaQualifiedTypeInfo; | 25 | import org.onosproject.yangutils.translator.tojava.JavaQualifiedTypeInfo; |
26 | +import org.onosproject.yangutils.utils.io.impl.YangPluginConfig; | ||
26 | 27 | ||
27 | import static org.hamcrest.core.Is.is; | 28 | import static org.hamcrest.core.Is.is; |
28 | import static org.hamcrest.core.IsNot.not; | 29 | import static org.hamcrest.core.IsNot.not; |
29 | import static org.junit.Assert.assertThat; | 30 | import static org.junit.Assert.assertThat; |
30 | import static org.onosproject.yangutils.datamodel.YangDataTypes.STRING; | 31 | import static org.onosproject.yangutils.datamodel.YangDataTypes.STRING; |
31 | import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_SERVICE_AND_MANAGER; | 32 | import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_SERVICE_AND_MANAGER; |
32 | -import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getCapitalCase; | 33 | +import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getCapitalCase; |
33 | import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getBuild; | 34 | import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getBuild; |
34 | import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getBuildForInterface; | 35 | import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getBuildForInterface; |
35 | import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getCheckNotNull; | 36 | import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getCheckNotNull; | ... | ... |
... | @@ -22,6 +22,7 @@ import org.junit.Test; | ... | @@ -22,6 +22,7 @@ import org.junit.Test; |
22 | import org.onosproject.yangutils.datamodel.YangNode; | 22 | import org.onosproject.yangutils.datamodel.YangNode; |
23 | import org.onosproject.yangutils.parser.exceptions.ParserException; | 23 | import org.onosproject.yangutils.parser.exceptions.ParserException; |
24 | import org.onosproject.yangutils.parser.impl.YangUtilsParserManager; | 24 | import org.onosproject.yangutils.parser.impl.YangUtilsParserManager; |
25 | +import org.onosproject.yangutils.utils.io.impl.YangPluginConfig; | ||
25 | 26 | ||
26 | import static org.onosproject.yangutils.translator.tojava.JavaCodeGeneratorUtil.generateJavaCode; | 27 | import static org.onosproject.yangutils.translator.tojava.JavaCodeGeneratorUtil.generateJavaCode; |
27 | import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.deleteDirectory; | 28 | import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.deleteDirectory; | ... | ... |
... | @@ -22,6 +22,7 @@ import org.junit.Test; | ... | @@ -22,6 +22,7 @@ import org.junit.Test; |
22 | import org.onosproject.yangutils.datamodel.YangNode; | 22 | import org.onosproject.yangutils.datamodel.YangNode; |
23 | import org.onosproject.yangutils.parser.exceptions.ParserException; | 23 | import org.onosproject.yangutils.parser.exceptions.ParserException; |
24 | import org.onosproject.yangutils.parser.impl.YangUtilsParserManager; | 24 | import org.onosproject.yangutils.parser.impl.YangUtilsParserManager; |
25 | +import org.onosproject.yangutils.utils.io.impl.YangPluginConfig; | ||
25 | 26 | ||
26 | import static org.onosproject.yangutils.translator.tojava.JavaCodeGeneratorUtil.generateJavaCode; | 27 | import static org.onosproject.yangutils.translator.tojava.JavaCodeGeneratorUtil.generateJavaCode; |
27 | import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.deleteDirectory; | 28 | import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.deleteDirectory; | ... | ... |
... | @@ -22,6 +22,7 @@ import org.junit.Test; | ... | @@ -22,6 +22,7 @@ import org.junit.Test; |
22 | import org.onosproject.yangutils.datamodel.YangNode; | 22 | import org.onosproject.yangutils.datamodel.YangNode; |
23 | import org.onosproject.yangutils.parser.exceptions.ParserException; | 23 | import org.onosproject.yangutils.parser.exceptions.ParserException; |
24 | import org.onosproject.yangutils.parser.impl.YangUtilsParserManager; | 24 | import org.onosproject.yangutils.parser.impl.YangUtilsParserManager; |
25 | +import org.onosproject.yangutils.utils.io.impl.YangPluginConfig; | ||
25 | 26 | ||
26 | import static org.onosproject.yangutils.translator.tojava.JavaCodeGeneratorUtil.generateJavaCode; | 27 | import static org.onosproject.yangutils.translator.tojava.JavaCodeGeneratorUtil.generateJavaCode; |
27 | import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.deleteDirectory; | 28 | import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.deleteDirectory; | ... | ... |
utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/utils/io/impl/FileSystemUtilTest.java
... | @@ -25,7 +25,6 @@ import org.junit.Test; | ... | @@ -25,7 +25,6 @@ import org.junit.Test; |
25 | import org.onosproject.yangutils.datamodel.YangNode; | 25 | import org.onosproject.yangutils.datamodel.YangNode; |
26 | import org.onosproject.yangutils.translator.tojava.JavaFileInfo; | 26 | import org.onosproject.yangutils.translator.tojava.JavaFileInfo; |
27 | import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaModule; | 27 | import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaModule; |
28 | -import org.onosproject.yangutils.translator.tojava.utils.YangPluginConfig; | ||
29 | 28 | ||
30 | import static org.apache.commons.io.FileUtils.deleteDirectory; | 29 | import static org.apache.commons.io.FileUtils.deleteDirectory; |
31 | import static org.hamcrest.core.Is.is; | 30 | import static org.hamcrest.core.Is.is; |
... | @@ -34,8 +33,8 @@ import static org.junit.Assert.assertThat; | ... | @@ -34,8 +33,8 @@ import static org.junit.Assert.assertThat; |
34 | import static org.onosproject.yangutils.utils.UtilConstants.PERIOD; | 33 | import static org.onosproject.yangutils.utils.UtilConstants.PERIOD; |
35 | import static org.onosproject.yangutils.utils.UtilConstants.SLASH; | 34 | import static org.onosproject.yangutils.utils.UtilConstants.SLASH; |
36 | import static org.onosproject.yangutils.utils.io.impl.FileSystemUtil.appendFileContents; | 35 | import static org.onosproject.yangutils.utils.io.impl.FileSystemUtil.appendFileContents; |
37 | -import static org.onosproject.yangutils.utils.io.impl.FileSystemUtil.createPackage; | 36 | +import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.createPackage; |
38 | -import static org.onosproject.yangutils.utils.io.impl.FileSystemUtil.doesPackageExist; | 37 | +import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.doesPackageExist; |
39 | import static org.onosproject.yangutils.utils.io.impl.FileSystemUtil.updateFileHandle; | 38 | import static org.onosproject.yangutils.utils.io.impl.FileSystemUtil.updateFileHandle; |
40 | 39 | ||
41 | /** | 40 | /** | ... | ... |
... | @@ -22,7 +22,6 @@ import java.lang.reflect.InvocationTargetException; | ... | @@ -22,7 +22,6 @@ import java.lang.reflect.InvocationTargetException; |
22 | import org.junit.Rule; | 22 | import org.junit.Rule; |
23 | import org.junit.Test; | 23 | import org.junit.Test; |
24 | import org.junit.rules.ExpectedException; | 24 | import org.junit.rules.ExpectedException; |
25 | -import org.onosproject.yangutils.translator.tojava.utils.YangPluginConfig; | ||
26 | 25 | ||
27 | import static org.hamcrest.core.Is.is; | 26 | import static org.hamcrest.core.Is.is; |
28 | import static org.hamcrest.core.IsNot.not; | 27 | import static org.hamcrest.core.IsNot.not; |
... | @@ -207,4 +206,4 @@ public final class JavaDocGenTest { | ... | @@ -207,4 +206,4 @@ public final class JavaDocGenTest { |
207 | pluginConfig.setConflictResolver(null); | 206 | pluginConfig.setConflictResolver(null); |
208 | return pluginConfig; | 207 | return pluginConfig; |
209 | } | 208 | } |
210 | -} | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
209 | +} | ... | ... |
... | @@ -26,17 +26,15 @@ import org.apache.maven.project.MavenProject; | ... | @@ -26,17 +26,15 @@ import org.apache.maven.project.MavenProject; |
26 | import org.junit.Rule; | 26 | import org.junit.Rule; |
27 | import org.junit.Test; | 27 | import org.junit.Test; |
28 | import org.junit.rules.ExpectedException; | 28 | import org.junit.rules.ExpectedException; |
29 | -import org.onosproject.yangutils.translator.tojava.utils.YangPluginConfig; | ||
30 | import org.onosproject.yangutils.utils.UtilConstants; | 29 | import org.onosproject.yangutils.utils.UtilConstants; |
31 | import org.sonatype.plexus.build.incremental.BuildContext; | 30 | import org.sonatype.plexus.build.incremental.BuildContext; |
32 | import org.sonatype.plexus.build.incremental.DefaultBuildContext; | 31 | import org.sonatype.plexus.build.incremental.DefaultBuildContext; |
33 | 32 | ||
34 | -import static org.apache.commons.io.FileUtils.deleteDirectory; | ||
35 | import static org.hamcrest.core.Is.is; | 33 | import static org.hamcrest.core.Is.is; |
36 | import static org.hamcrest.core.IsNot.not; | 34 | import static org.hamcrest.core.IsNot.not; |
37 | import static org.junit.Assert.assertThat; | 35 | import static org.junit.Assert.assertThat; |
38 | import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.addPackageInfo; | 36 | import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.addPackageInfo; |
39 | -import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.addToCompilationRoot; | 37 | +import static org.onosproject.yangutils.plugin.manager.YangPluginUtils.addToCompilationRoot; |
40 | import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.deleteDirectory; | 38 | import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.deleteDirectory; |
41 | import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.createDirectories; | 39 | import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.createDirectories; |
42 | import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.trimAtLast; | 40 | import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.trimAtLast; | ... | ... |
-
Please register or login to post a comment