blob: 75350d5df20b2f55e50ff9f55eda1bcfb73f3e4d [file] [log] [blame]
Bharat saraswal870c56f2016-02-20 21:57:16 +05301/*
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
17package org.onosproject.yangutils.translator;
18
Bharat saraswal2f00b4b2016-03-04 20:08:09 +053019import java.io.FileNotFoundException;
Bharat saraswal870c56f2016-02-20 21:57:16 +053020import java.io.IOException;
21
22import org.onosproject.yangutils.datamodel.YangType;
Bharat saraswal2f00b4b2016-03-04 20:08:09 +053023import org.onosproject.yangutils.translator.tojava.utils.TempDataStoreTypes;
Bharat saraswal870c56f2016-02-20 21:57:16 +053024
25/**
26 * Cached java file handle, which supports the addition of member attributes and
27 * methods.
28 */
29public interface CachedFileHandle {
30
31 /**
32 * Add a new attribute to the file(s).
33 *
Vinod Kumar Sc4216002016-03-03 19:55:30 +053034 * @param attrType data type of the added attribute
35 * @param name name of the attribute
Bharat saraswal870c56f2016-02-20 21:57:16 +053036 * @param isListAttr if the current added attribute needs to be maintained
Vinod Kumar Sc4216002016-03-03 19:55:30 +053037 * in a list
Bharat saraswal870c56f2016-02-20 21:57:16 +053038 */
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 Sc4216002016-03-03 19:55:30 +053044 * @throws IOException when failes to generated java files
Bharat saraswal870c56f2016-02-20 21:57:16 +053045 */
46 void close() throws IOException;
Bharat saraswal594bc6d2016-02-22 22:15:21 +053047
48 /**
Bharat saraswal4bf8b152016-02-25 02:26:43 +053049 * Sets directory package path for code generation.
50 *
51 * @param filePath directory package path for code generation
52 */
Vinod Kumar Sc4216002016-03-03 19:55:30 +053053 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 saraswal2f00b4b2016-03-04 20:08:09 +053061
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 saraswal870c56f2016-02-20 21:57:16 +0530100}