Committed by
Gerrit Code Review
[ONOS-3884] Common interface for parser and translator
Change-Id: I0e556f4324375132787a6b1abefccdd1414abf50
Showing
5 changed files
with
339 additions
and
0 deletions
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.datamodel; | ||
18 | + | ||
19 | +/** | ||
20 | + * Abstraction of YANG entity's common meta data. Abstracted to unify the | ||
21 | + * parsing and translator processing. | ||
22 | + */ | ||
23 | +public interface YangCommonInfo extends YangDesc, YangReference, YangStatus { | ||
24 | +} |
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.datamodel; | ||
18 | + | ||
19 | +/** | ||
20 | + * Abstraction of textual description for a YANG entity. Abstracted to unify the | ||
21 | + * parsing and translator processing of description. | ||
22 | + */ | ||
23 | +public interface YangDesc { | ||
24 | + /** | ||
25 | + * Get the description of YANG entity. | ||
26 | + * | ||
27 | + * @return the description of YANG entity. | ||
28 | + */ | ||
29 | + String getDescription(); | ||
30 | + | ||
31 | + /** | ||
32 | + * Set the description of YANG entity. | ||
33 | + * | ||
34 | + * @param description set the description of YANG entity. | ||
35 | + */ | ||
36 | + void setDescription(String description); | ||
37 | +} |
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.datamodel; | ||
18 | + | ||
19 | +import org.onosproject.yangutils.datamodel.exceptions.DataModelException; | ||
20 | +import org.onosproject.yangutils.parser.Parsable; | ||
21 | +import org.onosproject.yangutils.parser.ParsableDataType; | ||
22 | + | ||
23 | +/* | ||
24 | + * Reference:RFC 6020. | ||
25 | + * The "namespace" statement defines the XML namespace that all | ||
26 | + * identifiers defined by the module are qualified by, with the | ||
27 | + * exception of data node identifiers defined inside a grouping. | ||
28 | + * The argument to the "namespace" statement is the URI of the | ||
29 | + * namespace. | ||
30 | + */ | ||
31 | + | ||
32 | +/** | ||
33 | + * Name space to be used for the XML data tree. | ||
34 | + */ | ||
35 | +public class YangNameSpace implements Parsable { | ||
36 | + | ||
37 | + private String uri; | ||
38 | + | ||
39 | + /** | ||
40 | + * Default constructor. | ||
41 | + */ | ||
42 | + public YangNameSpace() { | ||
43 | + } | ||
44 | + | ||
45 | + /** | ||
46 | + * Get the name space URI. | ||
47 | + * | ||
48 | + * @return the URI. | ||
49 | + */ | ||
50 | + public String getUri() { | ||
51 | + return uri; | ||
52 | + } | ||
53 | + | ||
54 | + /** | ||
55 | + * Set the name space URI. | ||
56 | + * | ||
57 | + * @param uri the URI to set | ||
58 | + */ | ||
59 | + public void setUri(String uri) { | ||
60 | + this.uri = uri; | ||
61 | + } | ||
62 | + | ||
63 | + /** | ||
64 | + * Returns the type of the parsed data. | ||
65 | + * | ||
66 | + * @return returns NAMESPACE_DATA. | ||
67 | + */ | ||
68 | + public ParsableDataType getParsableDataType() { | ||
69 | + return ParsableDataType.NAMESPACE_DATA; | ||
70 | + } | ||
71 | + | ||
72 | + /** | ||
73 | + * Validate the data on entering the corresponding parse tree node. | ||
74 | + * | ||
75 | + * @throws DataModelException a violation of data model rules. | ||
76 | + */ | ||
77 | + public void validateDataOnEntry() throws DataModelException { | ||
78 | + // TODO auto-generated method stub, to be implemented by parser | ||
79 | + | ||
80 | + } | ||
81 | + | ||
82 | + /** | ||
83 | + * Validate the data on exiting the corresponding parse tree node. | ||
84 | + * | ||
85 | + * @throws DataModelException a violation of data model rules. | ||
86 | + */ | ||
87 | + public void validateDataOnExit() throws DataModelException { | ||
88 | + // TODO auto-generated method stub, to be implemented by parser | ||
89 | + | ||
90 | + } | ||
91 | +} |
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 | +package org.onosproject.yangutils.datamodel; | ||
17 | + | ||
18 | +/** | ||
19 | + * Abstraction of textual reference for a YANG entity. Abstracted to unify the | ||
20 | + * parsing and translator processing of reference. | ||
21 | + */ | ||
22 | +public interface YangReference { | ||
23 | + /** | ||
24 | + * Get the textual reference. | ||
25 | + * | ||
26 | + * @return the reference. | ||
27 | + */ | ||
28 | + String getReference(); | ||
29 | + | ||
30 | + /** | ||
31 | + * Set the textual reference. | ||
32 | + * | ||
33 | + * @param reference the reference to set. | ||
34 | + */ | ||
35 | + void setReference(String reference); | ||
36 | + | ||
37 | +} |
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 | +package org.onosproject.yangutils.datamodel; | ||
17 | + | ||
18 | +import org.onosproject.yangutils.datamodel.exceptions.DataModelException; | ||
19 | +import org.onosproject.yangutils.parser.Parsable; | ||
20 | +import org.onosproject.yangutils.parser.ParsableDataType; | ||
21 | + | ||
22 | +/* | ||
23 | + * Reference:RFC 6020. | ||
24 | + * The "revision" statement specifies the editorial revision history of | ||
25 | + * the module, including the initial revision. A series of revision | ||
26 | + * statements detail the changes in the module's definition. The | ||
27 | + * argument is a date string in the format "YYYY-MM-DD", followed by a | ||
28 | + * block of sub-statements that holds detailed revision information. A | ||
29 | + * module SHOULD have at least one initial "revision" statement. For | ||
30 | + * every published editorial change, a new one SHOULD be added in front | ||
31 | + * of the revisions sequence, so that all revisions are in reverse | ||
32 | + * chronological order. | ||
33 | + * The revision's sub-statement | ||
34 | + * | ||
35 | + * +--------------+---------+-------------+------------------+ | ||
36 | + * | substatement | section | cardinality |data model mapping| | ||
37 | + * +--------------+---------+-------------+------------------+ | ||
38 | + * | description | 7.19.3 | 0..1 |string | | ||
39 | + * | reference | 7.19.4 | 0..1 |sring | | ||
40 | + * +--------------+---------+-------------+------------------+ | ||
41 | + */ | ||
42 | +/** | ||
43 | + * Maintains the information about the revision. | ||
44 | + */ | ||
45 | +public class YangRevision implements YangDesc, YangReference, Parsable { | ||
46 | + | ||
47 | + /** | ||
48 | + * Revision date. Date string in the format "YYYY-MM-DD" | ||
49 | + */ | ||
50 | + private String revDate; | ||
51 | + | ||
52 | + /** | ||
53 | + * Description of revision. | ||
54 | + */ | ||
55 | + private String description; | ||
56 | + | ||
57 | + /** | ||
58 | + * Textual reference for revision. | ||
59 | + */ | ||
60 | + private String reference; | ||
61 | + | ||
62 | + /** | ||
63 | + * Default constructor. | ||
64 | + */ | ||
65 | + public YangRevision() { | ||
66 | + } | ||
67 | + | ||
68 | + /** | ||
69 | + * Get the revision date. | ||
70 | + * | ||
71 | + * @return the revision date | ||
72 | + */ | ||
73 | + public String getRevDate() { | ||
74 | + return revDate; | ||
75 | + } | ||
76 | + | ||
77 | + /** | ||
78 | + * Set the revision date. | ||
79 | + * | ||
80 | + * @param revDate the revision date to set | ||
81 | + */ | ||
82 | + public void setRevDate(String revDate) { | ||
83 | + this.revDate = revDate; | ||
84 | + } | ||
85 | + | ||
86 | + /** | ||
87 | + * Get the description. | ||
88 | + * | ||
89 | + * @return the description. | ||
90 | + */ | ||
91 | + public String getDescription() { | ||
92 | + return description; | ||
93 | + } | ||
94 | + | ||
95 | + /** | ||
96 | + * Set the description. | ||
97 | + * | ||
98 | + * @param description set the description. | ||
99 | + */ | ||
100 | + public void setDescription(String description) { | ||
101 | + this.description = description; | ||
102 | + } | ||
103 | + | ||
104 | + /** | ||
105 | + * Get the textual reference. | ||
106 | + * | ||
107 | + * @return the reference. | ||
108 | + */ | ||
109 | + public String getReference() { | ||
110 | + return reference; | ||
111 | + } | ||
112 | + | ||
113 | + /** | ||
114 | + * Set the textual reference. | ||
115 | + * | ||
116 | + * @param reference the reference to set. | ||
117 | + */ | ||
118 | + public void setReference(String reference) { | ||
119 | + this.reference = reference; | ||
120 | + } | ||
121 | + | ||
122 | + /** | ||
123 | + * Returns the type of the parsed data. | ||
124 | + * | ||
125 | + * @return returns REVISION_DATA. | ||
126 | + */ | ||
127 | + public ParsableDataType getParsableDataType() { | ||
128 | + return ParsableDataType.REVISION_DATA; | ||
129 | + } | ||
130 | + | ||
131 | + /** | ||
132 | + * Validate the data on entering the corresponding parse tree node. | ||
133 | + * | ||
134 | + * @throws DataModelException a violation of data model rules. | ||
135 | + */ | ||
136 | + public void validateDataOnEntry() throws DataModelException { | ||
137 | + // TODO auto-generated method stub, to be implemented by parser | ||
138 | + | ||
139 | + } | ||
140 | + | ||
141 | + /** | ||
142 | + * Validate the data on exiting the corresponding parse tree node. | ||
143 | + * | ||
144 | + * @throws DataModelException a violation of data model rules. | ||
145 | + */ | ||
146 | + public void validateDataOnExit() throws DataModelException { | ||
147 | + // TODO auto-generated method stub, to be implemented by parser | ||
148 | + | ||
149 | + } | ||
150 | +} |
-
Please register or login to post a comment