Vinod Kumar S | 9f26ae5 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 1 | /* |
Brian O'Connor | 0f7908b | 2016-04-09 01:19:45 -0700 | [diff] [blame^] | 2 | * Copyright 2016-present Open Networking Laboratory |
Vinod Kumar S | 9f26ae5 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 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.translator.tojava; |
| 18 | |
Bharat saraswal | 780eca3 | 2016-04-05 12:45:45 +0530 | [diff] [blame] | 19 | import org.onosproject.yangutils.translator.exception.TranslatorException; |
| 20 | |
Vinod Kumar S | 9f26ae5 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 21 | /** |
| 22 | * Cached java file handle, which supports the addition of member attributes and |
| 23 | * methods. |
| 24 | */ |
| 25 | public class JavaFileInfo { |
Bharat saraswal | 780eca3 | 2016-04-05 12:45:45 +0530 | [diff] [blame] | 26 | |
Vinod Kumar S | 9f26ae5 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 27 | /** |
| 28 | * The type(s) of java source file(s) to be generated when the cached file |
| 29 | * handle is closed. |
| 30 | */ |
| 31 | private int genFileTypes; |
| 32 | |
| 33 | /** |
| 34 | * Name of the module. |
| 35 | */ |
| 36 | private String javaName; |
| 37 | |
| 38 | /** |
| 39 | * java Package of the mapped java class. |
| 40 | */ |
| 41 | private String pkg; |
| 42 | |
| 43 | /** |
| 44 | * File generation directory path. |
| 45 | */ |
| 46 | private String relativeFilePath; |
| 47 | |
| 48 | /** |
| 49 | * File generation base directory path. |
| 50 | */ |
| 51 | private String codeGenDirFilePath; |
| 52 | |
| 53 | /** |
| 54 | * Get the types of files being generated corresponding to the YANG |
| 55 | * definition. |
| 56 | * |
| 57 | * @return the types of files being generated corresponding to the YANG |
| 58 | * definition |
| 59 | */ |
| 60 | public int getGeneratedFileTypes() { |
| 61 | return genFileTypes; |
| 62 | } |
| 63 | |
| 64 | /** |
| 65 | * Set the types of files being generated corresponding to the YANG |
| 66 | * definition. |
| 67 | * |
| 68 | * @param fileTypes the types of files being generated corresponding to the |
| 69 | * YANG definition |
| 70 | */ |
| 71 | public void setGeneratedFileTypes(int fileTypes) { |
| 72 | genFileTypes = fileTypes; |
| 73 | } |
| 74 | |
| 75 | /** |
| 76 | * Get the java name of the node. |
| 77 | * |
| 78 | * @return the java name of node |
| 79 | */ |
| 80 | public String getJavaName() { |
| 81 | return javaName; |
| 82 | } |
| 83 | |
| 84 | /** |
| 85 | * Set the java name of the node. |
| 86 | * |
| 87 | * @param name the java name of node |
| 88 | */ |
| 89 | public void setJavaName(String name) { |
| 90 | javaName = name; |
| 91 | } |
| 92 | |
| 93 | /** |
| 94 | * Get the mapped java package. |
| 95 | * |
| 96 | * @return the java package |
| 97 | */ |
| 98 | public String getPackage() { |
Bharat saraswal | 780eca3 | 2016-04-05 12:45:45 +0530 | [diff] [blame] | 99 | |
Vinod Kumar S | 9f26ae5 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 100 | if (pkg == null) { |
Bharat saraswal | 780eca3 | 2016-04-05 12:45:45 +0530 | [diff] [blame] | 101 | throw new TranslatorException("Referencing package of a generated java file which is not set"); |
Vinod Kumar S | 9f26ae5 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 102 | } |
| 103 | return pkg; |
| 104 | } |
| 105 | |
| 106 | /** |
| 107 | * Set the node's package. |
| 108 | * |
| 109 | * @param nodePackage node's package |
| 110 | */ |
| 111 | public void setPackage(String nodePackage) { |
| 112 | pkg = nodePackage; |
| 113 | } |
| 114 | |
| 115 | /** |
| 116 | * Sets directory package path for code generation. |
| 117 | * |
| 118 | * @param path directory package path for code generation |
| 119 | */ |
| 120 | public void setPackageFilePath(String path) { |
| 121 | relativeFilePath = path; |
| 122 | } |
| 123 | |
| 124 | /** |
| 125 | * Gets directory package path for code generation. |
| 126 | * |
| 127 | * @return directory package path for code generation |
| 128 | */ |
| 129 | public String getPackageFilePath() { |
| 130 | return relativeFilePath; |
| 131 | } |
| 132 | |
| 133 | /** |
| 134 | * Gets base directory package path for code generation. |
| 135 | * |
| 136 | * @return directory package path for code generation |
| 137 | */ |
| 138 | public String getBaseCodeGenPath() { |
| 139 | return codeGenDirFilePath; |
| 140 | } |
| 141 | |
| 142 | /** |
| 143 | * Sets base directory package path for code generation. |
| 144 | * |
| 145 | * @param path base directory path |
| 146 | */ |
| 147 | public void setBaseCodeGenPath(String path) { |
| 148 | codeGenDirFilePath = path; |
| 149 | } |
| 150 | } |