blob: 0b892f9a659ef18ce1d16def7e9437969da353df [file] [log] [blame]
Vinod Kumar S38046502016-03-23 15:30:27 +05301/*
Brian O'Connor5ab426f2016-04-09 01:19:45 -07002 * Copyright 2016-present Open Networking Laboratory
Vinod Kumar S38046502016-03-23 15:30:27 +05303 *
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
17package org.onosproject.yangutils.translator.tojava;
18
Bharat saraswal6ef0b762016-04-05 12:45:45 +053019import org.onosproject.yangutils.translator.exception.TranslatorException;
20
Vinod Kumar S38046502016-03-23 15:30:27 +053021/**
Bharat saraswald9822e92016-04-05 15:13:44 +053022 * Represents cached java file handle, which supports the addition of member attributes and
Vinod Kumar S38046502016-03-23 15:30:27 +053023 * methods.
24 */
25public class JavaFileInfo {
Bharat saraswal6ef0b762016-04-05 12:45:45 +053026
Vinod Kumar S38046502016-03-23 15:30:27 +053027 /**
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 /**
Bharat saraswald9822e92016-04-05 15:13:44 +053054 * Returns the types of files being generated corresponding to the YANG
Vinod Kumar S38046502016-03-23 15:30:27 +053055 * 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 /**
Bharat saraswald9822e92016-04-05 15:13:44 +053065 * Sets the types of files being generated corresponding to the YANG
Vinod Kumar S38046502016-03-23 15:30:27 +053066 * 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 /**
Bharat saraswald9822e92016-04-05 15:13:44 +053076 * Returns the java name of the node.
Vinod Kumar S38046502016-03-23 15:30:27 +053077 *
78 * @return the java name of node
79 */
80 public String getJavaName() {
81 return javaName;
82 }
83
84 /**
Bharat saraswald9822e92016-04-05 15:13:44 +053085 * Sets the java name of the node.
Vinod Kumar S38046502016-03-23 15:30:27 +053086 *
87 * @param name the java name of node
88 */
89 public void setJavaName(String name) {
90 javaName = name;
91 }
92
93 /**
Bharat saraswald9822e92016-04-05 15:13:44 +053094 * Returns the mapped java package.
Vinod Kumar S38046502016-03-23 15:30:27 +053095 *
96 * @return the java package
97 */
98 public String getPackage() {
Bharat saraswal6ef0b762016-04-05 12:45:45 +053099
Vinod Kumar S38046502016-03-23 15:30:27 +0530100 if (pkg == null) {
Bharat saraswal6ef0b762016-04-05 12:45:45 +0530101 throw new TranslatorException("Referencing package of a generated java file which is not set");
Vinod Kumar S38046502016-03-23 15:30:27 +0530102 }
103 return pkg;
104 }
105
106 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530107 * Sets the node's package.
Vinod Kumar S38046502016-03-23 15:30:27 +0530108 *
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 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530125 * Returns directory package path for code generation.
Vinod Kumar S38046502016-03-23 15:30:27 +0530126 *
127 * @return directory package path for code generation
128 */
129 public String getPackageFilePath() {
130 return relativeFilePath;
131 }
132
133 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530134 * Returns base directory package path for code generation.
Vinod Kumar S38046502016-03-23 15:30:27 +0530135 *
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}