Bharat saraswal | 9745996 | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2016 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.translator; |
| 18 | |
Bharat saraswal | 022dae9 | 2016-03-04 20:08:09 +0530 | [diff] [blame] | 19 | import java.io.FileNotFoundException; |
Bharat saraswal | 9745996 | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 20 | import java.io.IOException; |
| 21 | |
| 22 | import org.onosproject.yangutils.datamodel.YangType; |
Bharat saraswal | 022dae9 | 2016-03-04 20:08:09 +0530 | [diff] [blame] | 23 | import org.onosproject.yangutils.translator.tojava.utils.TempDataStoreTypes; |
Bharat saraswal | 9745996 | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 24 | |
| 25 | /** |
| 26 | * Cached java file handle, which supports the addition of member attributes and |
| 27 | * methods. |
| 28 | */ |
| 29 | public interface CachedFileHandle { |
| 30 | |
| 31 | /** |
| 32 | * Add a new attribute to the file(s). |
| 33 | * |
Vinod Kumar S | 0871098 | 2016-03-03 19:55:30 +0530 | [diff] [blame] | 34 | * @param attrType data type of the added attribute |
| 35 | * @param name name of the attribute |
Bharat saraswal | 9745996 | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 36 | * @param isListAttr if the current added attribute needs to be maintained |
Vinod Kumar S | 0871098 | 2016-03-03 19:55:30 +0530 | [diff] [blame] | 37 | * in a list |
Bharat saraswal | 9745996 | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 38 | */ |
| 39 | void addAttributeInfo(YangType<?> attrType, String name, boolean isListAttr); |
| 40 | |
| 41 | /** |
| 42 | * Flushes the cached contents to the target file, frees used resources. |
| 43 | * |
Vinod Kumar S | 0871098 | 2016-03-03 19:55:30 +0530 | [diff] [blame] | 44 | * @throws IOException when failes to generated java files |
Bharat saraswal | 9745996 | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 45 | */ |
| 46 | void close() throws IOException; |
Bharat saraswal | 5e3c45c | 2016-02-22 22:15:21 +0530 | [diff] [blame] | 47 | |
| 48 | /** |
Bharat saraswal | c46ee2a | 2016-02-25 02:26:43 +0530 | [diff] [blame] | 49 | * Sets directory package path for code generation. |
| 50 | * |
| 51 | * @param filePath directory package path for code generation |
| 52 | */ |
Vinod Kumar S | 0871098 | 2016-03-03 19:55:30 +0530 | [diff] [blame] | 53 | void setRelativeFilePath(String filePath); |
| 54 | |
| 55 | /** |
| 56 | * Gets directory package path for code generation. |
| 57 | * |
| 58 | * @return directory package path for code generation |
| 59 | */ |
| 60 | String getRelativeFilePath(); |
Bharat saraswal | 022dae9 | 2016-03-04 20:08:09 +0530 | [diff] [blame] | 61 | |
| 62 | /** |
| 63 | * Gets base directory package path for code generation. |
| 64 | * |
| 65 | * @return directory package path for code generation |
| 66 | */ |
| 67 | String getCodeGenFilePath(); |
| 68 | |
| 69 | /** |
| 70 | * Sets base directory package path for code generation. |
| 71 | * |
| 72 | * @param path base directory path |
| 73 | */ |
| 74 | void setCodeGenFilePath(String path); |
| 75 | |
| 76 | /** |
| 77 | * Writes specific info to a Temp file. |
| 78 | * |
| 79 | * @param data data to be stored |
| 80 | * @param type type of Temp data store |
| 81 | * @param className class name |
| 82 | * @param genDir generated directory |
| 83 | * @throws IOException when fails to create a Temp data file |
| 84 | */ |
| 85 | void setTempData(String data, TempDataStoreTypes type, String className, String genDir) throws IOException; |
| 86 | |
| 87 | /** |
| 88 | * Get the Temp data. |
| 89 | * |
| 90 | * @param type type of Temp data store |
| 91 | * @param className name of the class |
| 92 | * @param genDir generated directory |
| 93 | * @return temp data |
| 94 | * @throws IOException when fails to read from the file |
| 95 | * @throws ClassNotFoundException when class is missing |
| 96 | * @throws FileNotFoundException when file is missing |
| 97 | */ |
| 98 | String getTempData(TempDataStoreTypes type, String className, String genDir) |
| 99 | throws IOException, FileNotFoundException, ClassNotFoundException; |
Bharat saraswal | 9745996 | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 100 | } |