Brian O'Connor

Moving yangtools to separate repo

https://gerrit.onosproject.org/onos-yang-tools

Change-Id: I0dc994264b9b698cba2344b48e4e226b22951f55
Showing 1000 changed files with 0 additions and 5217 deletions

Too many changes to show.

To preserve performance only 1000 of 1000+ files are displayed.

...@@ -33,7 +33,6 @@ ...@@ -33,7 +33,6 @@
33 <modules> 33 <modules>
34 <module>junit</module> 34 <module>junit</module>
35 <module>misc</module> 35 <module>misc</module>
36 - <module>yangutils</module>
37 <module>osgi</module> 36 <module>osgi</module>
38 <module>rest</module> 37 <module>rest</module>
39 <module>osgiwrap</module> 38 <module>osgiwrap</module>
......
1 -<!--
2 - ~ Copyright 2016-present 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 -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
17 - xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
18 - <modelVersion>4.0.0</modelVersion>
19 -
20 - <parent>
21 - <groupId>org.onosproject</groupId>
22 - <artifactId>onos-yangutils</artifactId>
23 - <version>1.7.0-SNAPSHOT</version>
24 - </parent>
25 -
26 - <artifactId>yangutils-datamodel</artifactId>
27 - <version>1.7.0-SNAPSHOT</version>
28 - <name>onos-yang-utils-datamodel</name>
29 - <packaging>jar</packaging>
30 -
31 - <properties>
32 - <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
33 - </properties>
34 -</project>
1 -/*-
2 - * Copyright 2016-present 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 java.io.Serializable;
19 -import org.onosproject.yangutils.datamodel.utils.builtindatatype.DataTypeException;
20 -import org.onosproject.yangutils.datamodel.utils.builtindatatype.YangBuiltInDataTypeInfo;
21 -import org.onosproject.yangutils.datamodel.utils.builtindatatype.YangDataTypes;
22 -import org.onosproject.yangutils.datamodel.utils.builtindatatype.YangInt16;
23 -import org.onosproject.yangutils.datamodel.utils.builtindatatype.YangInt32;
24 -import org.onosproject.yangutils.datamodel.utils.builtindatatype.YangInt64;
25 -import org.onosproject.yangutils.datamodel.utils.builtindatatype.YangInt8;
26 -import org.onosproject.yangutils.datamodel.utils.builtindatatype.YangUint16;
27 -import org.onosproject.yangutils.datamodel.utils.builtindatatype.YangUint32;
28 -import org.onosproject.yangutils.datamodel.utils.builtindatatype.YangUint64;
29 -import org.onosproject.yangutils.datamodel.utils.builtindatatype.YangUint8;
30 -
31 -/**
32 - * Factory to create an object of required type.
33 - */
34 -public final class BuiltInTypeObjectFactory implements Serializable {
35 -
36 - private static final long serialVersionUID = 8006201671L;
37 -
38 - /**
39 - * Utility factory class, hence the object creation is forbidden.
40 - */
41 - private BuiltInTypeObjectFactory() {
42 - }
43 -
44 - /**
45 - * Given the value represented in string return the corresponding types
46 - * object with the value initialized.
47 - *
48 - * @param valueInStr value represented in string
49 - * @param builtInType built in data type
50 - * @param <T> the data type of the target object
51 - * @return the target data type object with the value initialized
52 - */
53 - public static <T extends YangBuiltInDataTypeInfo<?>> T getDataObjectFromString(String valueInStr,
54 - YangDataTypes builtInType) {
55 -
56 - switch (builtInType) {
57 - case INT8: {
58 - return (T) new YangInt8(valueInStr);
59 - }
60 - case INT16: {
61 - return (T) new YangInt16(valueInStr);
62 - }
63 - case INT32: {
64 - return (T) new YangInt32(valueInStr);
65 - }
66 - case INT64: {
67 - return (T) new YangInt64(valueInStr);
68 - }
69 - case UINT8: {
70 - return (T) new YangUint8(valueInStr);
71 - }
72 - case UINT16: {
73 - return (T) new YangUint16(valueInStr);
74 - }
75 - case UINT32: {
76 - return (T) new YangUint32(valueInStr);
77 - }
78 - case UINT64: {
79 - return (T) new YangUint64(valueInStr);
80 - }
81 - case DECIMAL64: {
82 - return (T) new YangDecimal64(valueInStr);
83 - }
84 - default: {
85 - throw new DataTypeException("YANG file error : Unsupported data type");
86 - }
87 - }
88 - }
89 -}
1 -/*
2 - * Copyright 2016-present 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.datamodel.utils.YangConstructType;
21 -
22 -/**
23 - * Abstraction of YANG collision function. Abstracted to unify the collision
24 - * detection functionality.
25 - */
26 -public interface CollisionDetector {
27 - /**
28 - * Checks for the colliding child.
29 - *
30 - * @param identifierName name of identifier for which collision to be
31 - * checked
32 - * @param dataType type of the YANG construct for which collision to be
33 - * checked
34 - * @throws DataModelException if there is any collision in YANG rules in
35 - * parsed data, corresponding exception should be thrown
36 - */
37 - void detectCollidingChild(String identifierName, YangConstructType dataType)
38 - throws DataModelException;
39 -
40 - /**
41 - * Check for the self collision.
42 - *
43 - * @param identifierName name of identifier for which collision to be
44 - * checked
45 - * @param dataType type of the YANG construct for which collision to be
46 - * checked
47 - * @throws DataModelException if there is any collision in YANG rules in
48 - * parsed data, corresponding exception should be thrown
49 - */
50 - void detectSelfCollision(String identifierName, YangConstructType dataType)
51 - throws DataModelException;
52 -}
1 -/*
2 - * Copyright 2016-present 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 location information, this is used during resolution is
21 - * carried out and line/character position in line is required to point
22 - * out the error location in YANG file.
23 - */
24 -public interface LocationInfo {
25 -
26 - /**
27 - * Returns the line number YANG construct in file.
28 - *
29 - * @return the line number YANG construct in file
30 - */
31 - int getLineNumber();
32 -
33 - /**
34 - * Returns the character position in line.
35 - *
36 - * @return the character position in line
37 - */
38 - int getCharPosition();
39 -
40 - /**
41 - * Sets line number of YANG construct.
42 - *
43 - * @param lineNumber the line number of YANG construct in file
44 - */
45 - void setLineNumber(int lineNumber);
46 -
47 - /**
48 - * Sets character position of YANG construct.
49 - *
50 - * @param charPositionInLine character position of YANG construct in file
51 - */
52 - void setCharPosition(int charPositionInLine);
53 -}
1 -/*
2 - * Copyright 2016-present 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.datamodel.utils.ResolvableStatus;
21 -
22 -/**
23 - * Abstraction of YANG resolvable information. Abstracted to obtain the
24 - * information required for linking resolution.
25 - *
26 - * @param <T> YANG resolvable info
27 - */
28 -public interface Resolvable<T> {
29 -
30 - /**
31 - * Returns the status of resolution. If completely resolved returns enum
32 - * value "RESOLVED", if not returns "UNRESOLVED", in case reference of
33 - * grouping/typedef is added to uses/type but it's not resolved
34 - * "INTRA_FILE_RESOLVED" is returned.
35 - *
36 - * @return status of resolution
37 - */
38 - ResolvableStatus getResolvableStatus();
39 -
40 - /**
41 - * Set the status of type/uses resolution. If completely resolved set enum
42 - * value "RESOLVED", if not set it to "UNRESOLVED", in case reference of
43 - * grouping/typedef is added to uses/type but it's not resolved
44 - * "INTRA_FILE_RESOLVED" should be set.
45 - *
46 - * @param resolvableStatus status of resolution
47 - */
48 - void setResolvableStatus(ResolvableStatus resolvableStatus);
49 -
50 - /**
51 - * Resolves the linking.
52 - *
53 - * @return list of entities to be added for resolution
54 - * @throws DataModelException data model exception
55 - */
56 - T resolve()
57 - throws DataModelException;
58 -}
1 -/*
2 - * Copyright 2016-present 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 - * Type of the resolvable info.
21 - */
22 -public enum ResolvableType {
23 -
24 - /**
25 - * Identifies the derived data type.
26 - */
27 - YANG_DERIVED_DATA_TYPE,
28 -
29 - /**
30 - * Identifies the uses.
31 - */
32 - YANG_USES,
33 -
34 - /**
35 - * Identifies the if-feature.
36 - */
37 - YANG_IF_FEATURE,
38 -
39 - /**
40 - * Identifies the leafref.
41 - */
42 - YANG_LEAFREF,
43 -
44 - /**
45 - * Identifies the base.
46 - */
47 - YANG_BASE,
48 -
49 - /**
50 - * Identifies the identityref.
51 - */
52 - YANG_IDENTITYREF,
53 -
54 - /**
55 - * Identifies the augment.
56 - */
57 - YANG_AUGMENT
58 -}
1 -/*
2 - * Copyright 2016-present 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 - * Represents class having rpc and notification.
21 - */
22 -public interface RpcNotificationContainer {
23 -}
1 -/*
2 - * Copyright 2016-present 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 - * Represents data model tree traversal types.
21 - */
22 -public enum TraversalType {
23 -
24 - /**
25 - * Start of traversal at the tree root.
26 - */
27 - ROOT,
28 -
29 - /**
30 - * Child node traversal.
31 - */
32 - CHILD,
33 -
34 - /**
35 - * Sibling node traversal.
36 - */
37 - SIBILING,
38 -
39 - /**
40 - * Parent node traversal.
41 - */
42 - PARENT
43 -}
1 -/*
2 - * Copyright 2016-present 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 java.util.LinkedList;
20 -import java.util.List;
21 -import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
22 -import org.onosproject.yangutils.datamodel.utils.Parsable;
23 -import org.onosproject.yangutils.datamodel.utils.YangConstructType;
24 -
25 -/**
26 - * Represents data model node to maintain information defined in YANG app-data-structure.
27 - */
28 -public class YangAppDataStructure implements Parsable {
29 -
30 - /**
31 - * Data structure information.
32 - */
33 - private YangDataStructure dataStructure;
34 -
35 - /**
36 - * List of key names.
37 - */
38 - private List<String> keyList;
39 -
40 - /**
41 - * Prefix of app-data-structure.
42 - */
43 - private String prefix;
44 -
45 - /**
46 - * Returns the YANG data structure information.
47 - *
48 - * @return the YANG data structure information
49 - */
50 - public YangDataStructure getDataStructure() {
51 - return dataStructure;
52 - }
53 -
54 - /**
55 - * Sets the YANG data structure information.
56 - *
57 - * @param dataStructure the YANG data structure to set
58 - */
59 - public void setDataStructure(YangDataStructure dataStructure) {
60 - this.dataStructure = dataStructure;
61 - }
62 -
63 - /**
64 - * Returns the list of key field names.
65 - *
66 - * @return the list of key field names
67 - */
68 - public List<String> getKeyList() {
69 - return keyList;
70 - }
71 -
72 - /**
73 - * Sets the list of key field names.
74 - *
75 - * @param keyList the list of key field names
76 - */
77 - public void setKeyList(List<String> keyList) {
78 - this.keyList = keyList;
79 - }
80 -
81 - /**
82 - * Adds a key field name.
83 - *
84 - * @param key key field name
85 - */
86 - public void addKey(String key) {
87 - if (getKeyList() == null) {
88 - setKeyList(new LinkedList<>());
89 - }
90 - getKeyList().add(key);
91 - }
92 -
93 - /**
94 - * Returns the prefix.
95 - *
96 - * @return the prefix
97 - */
98 - public String getPrefix() {
99 - return prefix;
100 - }
101 -
102 - /**
103 - * Sets the prefix information.
104 - *
105 - * @param prefix the prefix to set
106 - */
107 - public void setPrefix(String prefix) {
108 - this.prefix = prefix;
109 - }
110 -
111 - @Override
112 - public YangConstructType getYangConstructType() {
113 - return YangConstructType.APP_DATA_STRUCTURE;
114 - }
115 -
116 - @Override
117 - public void validateDataOnEntry() throws DataModelException {
118 - // TODO : to be implemented
119 - }
120 -
121 - @Override
122 - public void validateDataOnExit() throws DataModelException {
123 - // TODO : to be implemented
124 - }
125 -}
1 -/*
2 - * Copyright 2016-present 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 - * Represents data model node to maintain YANG app error message information.
21 - */
22 -public interface YangAppErrorHolder {
23 -
24 - /**
25 - * Sets the application's error information.
26 - *
27 - * @param yangAppErrorInfo the application's error information
28 - */
29 - void setAppErrorInfo(YangAppErrorInfo yangAppErrorInfo);
30 -
31 - /**
32 - * Returns application's error information.
33 - *
34 - * @return application's error information
35 - */
36 - YangAppErrorInfo getAppErrorInfo();
37 -
38 -}
1 -/*
2 - * Copyright 2016-present 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 java.io.Serializable;
20 -
21 -/**
22 - * Represents data model to maintain yang app error information.
23 - */
24 -public class YangAppErrorInfo implements Serializable {
25 -
26 - private static final long serialVersionUID = 807201693L;
27 -
28 - /**
29 - * Application's error message, to be used for data error.
30 - */
31 - private String errorMessage;
32 -
33 - /**
34 - * Error tag, to be filled in data validation error response.
35 - */
36 - private String errorTag;
37 -
38 - /**
39 - * Application's error tag, to be filled in data validation error response.
40 - */
41 - private String errorAppTag;
42 -
43 - /**
44 - * Application's error path, to be filled in data validation error response.
45 - */
46 - private String errorAppPath;
47 -
48 - /**
49 - * Application's error info, to be filled in data validation error response.
50 - */
51 - private String errorAppInfo;
52 -
53 - /**
54 - * Creates a YANG app error info object.
55 - */
56 - @SuppressWarnings("unused")
57 - public YangAppErrorInfo() {
58 - }
59 -
60 - /**
61 - * Returns application's error message, to be used for data error.
62 - *
63 - * @return Application's error message, to be used for data error
64 - */
65 - public String getGetErrorMessage() {
66 - return errorMessage;
67 - }
68 -
69 - /**
70 - * Sets Application's error message, to be used for data error.
71 - *
72 - * @param errMsg Application's error message, to be used for data error
73 - */
74 - public void setErrorMessage(String errMsg) {
75 - errorMessage = errMsg;
76 - }
77 -
78 - /**
79 - * Returns error tag, to be used for data error.
80 - *
81 - * @return error tag, to be used for data error
82 - */
83 - public String getGetErrorTag() {
84 - return errorTag;
85 - }
86 -
87 - /**
88 - * Sets error tag, to be used for data error.
89 - *
90 - * @param errTag error tag, to be used for data error
91 - */
92 - public void setErrorTag(String errTag) {
93 - errorTag = errTag;
94 - }
95 -
96 - /**
97 - * Returns application's error tag, to be used for data error.
98 - *
99 - * @return application's error tag, to be used for data error
100 - */
101 - public String getGetErrorAppTag() {
102 - return errorAppTag;
103 - }
104 -
105 - /**
106 - * Sets application's error tag, to be used for data error.
107 - *
108 - * @param errTag application's error tag, to be used for data error
109 - */
110 - public void setErrorAppTag(String errTag) {
111 - errorAppTag = errTag;
112 - }
113 -
114 - /**
115 - * Returns application's error path, to be used for data error.
116 - *
117 - * @return application's error path, to be used for data error
118 - */
119 - public String getGetErrorAppPath() {
120 - return errorAppPath;
121 - }
122 -
123 - /**
124 - * Sets application's error path, to be used for data error.
125 - *
126 - * @param errPath application's error path, to be used for data error
127 - */
128 - public void setErrorAppPath(String errPath) {
129 - errorAppPath = errPath;
130 - }
131 -
132 - /**
133 - * Returns application's error info, to be used for data error.
134 - *
135 - * @return application's error info, to be used for data error
136 - */
137 - public String getGetErrorAppInfo() {
138 - return errorAppInfo;
139 - }
140 -
141 - /**
142 - * Sets application's error info, to be used for data error.
143 - *
144 - * @param errInfo application's error info, to be used for data error
145 - */
146 - public void setErrorAppInfo(String errInfo) {
147 - errorAppInfo = errInfo;
148 - }
149 -}
1 -/*
2 - * Copyright 2016-present 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.datamodel.utils.Parsable;
21 -import org.onosproject.yangutils.datamodel.utils.YangConstructType;
22 -
23 -/**
24 - * Represents data model node to maintain information defined in YANG extended name.
25 - */
26 -public class YangAppExtendedName implements Parsable {
27 -
28 - /**
29 - * App extended name information.
30 - */
31 - private String yangAppExtendedName;
32 -
33 - /**
34 - * Prefix of extended name.
35 - */
36 - private String prefix;
37 -
38 - /**
39 - * Returns the YANG app extended name information.
40 - *
41 - * @return the YANG app extended name information
42 - */
43 - public String getYangAppExtendedName() {
44 - return yangAppExtendedName;
45 - }
46 -
47 - /**
48 - * Sets the YANG app extended name information.
49 - *
50 - * @param yangAppExtendedName the YANG app extended name to set
51 - */
52 - public void setYangAppExtendedName(String yangAppExtendedName) {
53 - this.yangAppExtendedName = yangAppExtendedName;
54 - }
55 -
56 - /**
57 - * Returns the prefix.
58 - *
59 - * @return the prefix
60 - */
61 - public String getPrefix() {
62 - return prefix;
63 - }
64 -
65 - /**
66 - * Sets the prefix information.
67 - *
68 - * @param prefix the prefix to set
69 - */
70 - public void setPrefix(String prefix) {
71 - this.prefix = prefix;
72 - }
73 -
74 - @Override
75 - public YangConstructType getYangConstructType() {
76 - return YangConstructType.APP_EXTENDED_NAME_DATA;
77 - }
78 -
79 - @Override
80 - public void validateDataOnEntry() throws DataModelException {
81 - // TODO : to be implemented
82 - }
83 -
84 - @Override
85 - public void validateDataOnExit() throws DataModelException {
86 - // TODO : to be implemented
87 - }
88 -}
1 -/*
2 - * Copyright 2016-present 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 java.io.Serializable;
19 -import java.util.List;
20 -
21 -/**
22 - * Representation of data model node to maintain absolute path defined in YANG path-arg.
23 - */
24 -public class YangAtomicPath implements Serializable {
25 -
26 - private static final long serialVersionUID = 806201688L;
27 -
28 - // YANG node identifier.
29 - private YangNodeIdentifier nodeIdentifier;
30 -
31 - // List of path predicates expression.
32 - private List<YangPathPredicate> pathPredicatesList;
33 -
34 - /**
35 - * Resolved node for the absolute path.
36 - */
37 - private YangNode resolvedNode;
38 -
39 - /**
40 - * Returns the node identifier.
41 - *
42 - * @return the node identifier
43 - */
44 - public YangNodeIdentifier getNodeIdentifier() {
45 - return nodeIdentifier;
46 - }
47 -
48 - /**
49 - * Sets the node identifier.
50 - *
51 - * @param nodeIdentifier Sets the node identifier
52 - */
53 - public void setNodeIdentifier(YangNodeIdentifier nodeIdentifier) {
54 - this.nodeIdentifier = nodeIdentifier;
55 - }
56 -
57 - /**
58 - * Returns the path predicate expression.
59 - *
60 - * @return the path predicate expression
61 - */
62 - public List<YangPathPredicate> getPathPredicatesList() {
63 - return pathPredicatesList;
64 - }
65 -
66 - /**
67 - * Sets the path predicate expression.
68 - *
69 - * @param pathPredicatesList Sets the path predicate expression
70 - */
71 - public void setPathPredicatesList(List<YangPathPredicate> pathPredicatesList) {
72 - this.pathPredicatesList = pathPredicatesList;
73 - }
74 -
75 - /**
76 - * Adds predicate expression in data holder.
77 - *
78 - * @param predicatesExp the predicate expression to be added
79 - */
80 - public void addLeavesPredicate(YangPathPredicate predicatesExp) {
81 - getPathPredicatesList().add(predicatesExp);
82 - }
83 -
84 -
85 - /**
86 - * Returns resolved node.
87 - *
88 - * @return resolved node
89 - */
90 - public YangNode getResolvedNode() {
91 - return resolvedNode;
92 - }
93 -
94 - /**
95 - * Sets resolved node.
96 - *
97 - * @param resolvedNode resolved node
98 - */
99 - public void setResolvedNode(YangNode resolvedNode) {
100 - this.resolvedNode = resolvedNode;
101 - }
102 -}
1 -/*
2 - * Copyright 2016-present 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 java.util.List;
20 -
21 -/**
22 - * Represents YANG constructs which can be augmented.
23 - */
24 -public interface YangAugmentableNode {
25 -
26 - /**
27 - * Adds augment info to the augment info list.
28 - *
29 - * @param augmentInfo augment info of node
30 - */
31 - void addAugmentation(YangAugmentedInfo augmentInfo);
32 -
33 - /**
34 - * Removes augment info from the node.
35 - *
36 - * @param augmentInfo augment info of node
37 - */
38 - void removeAugmentation(YangAugmentedInfo augmentInfo);
39 -
40 - /**
41 - * Returns list of augment info.
42 - *
43 - * @return list of augment info
44 - */
45 - List<YangAugmentedInfo> getAugmentedInfoList();
46 -}
1 -/*
2 - * Copyright 2016-present 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 an entity which represents YANG augmented info.
21 - */
22 -public interface YangAugmentedInfo {
23 -}
1 -/*
2 - * Copyright 2016-present 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 an entity which represent operation parameter info for augmentable node.
20 - */
21 -public interface YangAugmentedOpParamInfo extends YangAugmentedInfo {
22 -
23 - /**
24 - * Returns class object of base class.
25 - *
26 - * @return class object of base class
27 - */
28 - Class<?> getBaseClass();
29 -
30 - /**
31 - * Returns if augmented info's contents matches.
32 - *
33 - * @param augmentedInfo augmented info
34 - * @return true or false
35 - */
36 - boolean isFilterContentMatch(Object augmentedInfo);
37 -}
1 -/*
2 - * Copyright 2016-present 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.datamodel.utils.ResolvableStatus;
20 -
21 -import java.io.Serializable;
22 -
23 -/**
24 - * Reference RFC 6020.
25 - *
26 - * Represents data model node to maintain information defined in YANG base.
27 - * The "base" statement, which is optional, takes as an argument a
28 - * string that is the name of an existing identity, from which the new
29 - * identity is derived. If no "base" statement is present, the identity
30 - * is defined from scratch.
31 - *
32 - * If a prefix is present on the base name, it refers to an identity
33 - * defined in the module that was imported with that prefix, or the
34 - * local module if the prefix matches the local module's prefix.
35 - * Otherwise, an identity with the matching name MUST be defined in the
36 - * current module or an included submodule.
37 - */
38 -
39 -/**
40 - * Represents data model node to maintain information defined in YANG base.
41 - */
42 - public class YangBase implements Resolvable, Serializable {
43 -
44 - private static final long serialVersionUID = 806201693L;
45 -
46 - // YANG node identifier.
47 - private YangNodeIdentifier baseIdentifier;
48 -
49 - // Referred identity parent information.
50 - private YangIdentity referredIdentity;
51 -
52 - /**
53 - * Status of resolution. If completely resolved enum value is "RESOLVED",
54 - * if not enum value is "UNRESOLVED", in case reference of grouping/typedef/base/identityref
55 - * is added to uses/type/base/identityref but it's not resolved value of enum should be
56 - * "INTRA_FILE_RESOLVED".
57 - */
58 - private ResolvableStatus resolvableStatus;
59 -
60 - // Creates a base type of node.
61 - public YangBase() {
62 - resolvableStatus = ResolvableStatus.UNRESOLVED;
63 - }
64 -
65 - /**
66 - * Returns the YANG node identifier.
67 - *
68 - * @return the YANG node identifier
69 - */
70 - public YangNodeIdentifier getBaseIdentifier() {
71 - return baseIdentifier;
72 - }
73 -
74 - /**
75 - * Sets the YANG node identifier.
76 - *
77 - * @param baseIdentifier the YANG node identifier to set
78 - */
79 - public void setBaseIdentifier(YangNodeIdentifier baseIdentifier) {
80 - this.baseIdentifier = baseIdentifier;
81 - }
82 -
83 - /**
84 - * Returns the parent identity node.
85 - *
86 - * @return the parent identity node
87 - */
88 - public YangIdentity getReferredIdentity() {
89 - return referredIdentity;
90 - }
91 -
92 - /**
93 - * Sets the parent identity node.
94 - *
95 - * @param referredIdentity the parent identity node to set
96 - */
97 - public void setReferredIdentity(YangIdentity referredIdentity) {
98 - this.referredIdentity = referredIdentity;
99 - }
100 -
101 - @Override
102 - public ResolvableStatus getResolvableStatus() {
103 - return resolvableStatus;
104 - }
105 -
106 - @Override
107 - public void setResolvableStatus(ResolvableStatus resolvableStatus) {
108 - this.resolvableStatus = resolvableStatus;
109 - }
110 -
111 - @Override
112 - public Object resolve() throws DataModelException {
113 - return null;
114 - }
115 -}
1 -/*
2 - * Copyright 2016-present 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 java.io.Serializable;
19 -import java.util.Set;
20 -
21 -import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
22 -import org.onosproject.yangutils.datamodel.utils.Parsable;
23 -import org.onosproject.yangutils.datamodel.utils.YangConstructType;
24 -
25 -import static org.onosproject.yangutils.datamodel.utils.DataModelUtils.findReferredNode;
26 -
27 -/*-
28 - * Reference 6020.
29 - *
30 - * The "belongs-to" statement specifies the module to which the
31 - * submodule belongs. The argument is an identifier that is the name of
32 - * the module.
33 - *
34 - * A submodule MUST only be included by the module to which it belongs,
35 - * or by another submodule that belongs to that module.
36 - *
37 - * The mandatory "prefix" sub-statement assigns a prefix for the module
38 - * to which the submodule belongs. All definitions in the local
39 - * submodule and any included submodules can be accessed by using the
40 - * prefix.
41 - *
42 - * The belongs-to's sub-statements
43 - *
44 - * +--------------+---------+-------------+
45 - * | substatement | section | cardinality |
46 - * +--------------+---------+-------------+
47 - * | prefix | 7.1.4 | 1 |
48 - * +--------------+---------+-------------+
49 - */
50 -
51 -/**
52 - * Represents the belongs-to data type information.
53 - */
54 -public class YangBelongsTo implements Parsable, LocationInfo, Serializable {
55 -
56 - private static final long serialVersionUID = 806201639L;
57 -
58 - /**
59 - * Reference RFC 6020.
60 - *
61 - * The "belongs-to" statement specifies the module to which the submodule
62 - * belongs. The argument is an identifier that is the name of the module.
63 - */
64 - private String belongsToModuleName;
65 -
66 - /**
67 - * Module node to which sub-module belongs to.
68 - */
69 - private YangNode moduleNode;
70 -
71 - /**
72 - * Reference RFC 6020.
73 - *
74 - * The mandatory "prefix" substatement assigns a prefix for the module to
75 - * which the submodule belongs. All definitions in the local submodule and
76 - * any included submodules can be accessed by using the prefix.
77 - */
78 - private String prefix;
79 -
80 - // Error Line number.
81 - private transient int lineNumber;
82 -
83 - // Error character position.
84 - private transient int charPosition;
85 -
86 - /**
87 - * Create a belongs to object.
88 - */
89 - public YangBelongsTo() {
90 -
91 - }
92 -
93 - /**
94 - * Returns the belongs to module name.
95 - *
96 - * @return the belongs to module name
97 - */
98 - public String getBelongsToModuleName() {
99 - return belongsToModuleName;
100 - }
101 -
102 - /**
103 - * Sets the belongs to module name.
104 - *
105 - * @param belongsToModuleName the belongs to module name to set
106 - */
107 - public void setBelongsToModuleName(String belongsToModuleName) {
108 - this.belongsToModuleName = belongsToModuleName;
109 - }
110 -
111 - /**
112 - * Returns the prefix.
113 - *
114 - * @return the prefix
115 - */
116 - public String getPrefix() {
117 - return prefix;
118 - }
119 -
120 - /**
121 - * Sets the prefix.
122 - *
123 - * @param prefix the prefix to set
124 - */
125 - public void setPrefix(String prefix) {
126 - this.prefix = prefix;
127 - }
128 -
129 - /**
130 - * Returns the module data model node.
131 - *
132 - * @return the module data model node
133 - */
134 - public YangNode getModuleNode() {
135 - return moduleNode;
136 - }
137 -
138 - /**
139 - * Sets the module node.
140 - *
141 - * @param moduleNode module data model node
142 - */
143 - public void setModuleNode(YangNode moduleNode) {
144 - this.moduleNode = moduleNode;
145 - }
146 -
147 - /**
148 - * Returns the type of the data as belongs-to.
149 - *
150 - * @return ParsedDataType returns BELONGS_TO_DATA
151 - */
152 - @Override
153 - public YangConstructType getYangConstructType() {
154 - return YangConstructType.BELONGS_TO_DATA;
155 - }
156 -
157 - /**
158 - * Validates the data on entering the corresponding parse tree node.
159 - *
160 - * @throws DataModelException a violation of data model rules
161 - */
162 - @Override
163 - public void validateDataOnEntry() throws DataModelException {
164 - // TODO auto-generated method stub, to be implemented by parser
165 - }
166 -
167 - /**
168 - * Validates the data on exiting the corresponding parse tree node.
169 - *
170 - * @throws DataModelException a violation of data model rules
171 - */
172 - @Override
173 - public void validateDataOnExit() throws DataModelException {
174 - // TODO auto-generated method stub, to be implemented by parser
175 - }
176 -
177 - @Override
178 - public int getLineNumber() {
179 - return lineNumber;
180 - }
181 -
182 - @Override
183 - public int getCharPosition() {
184 - return charPosition;
185 - }
186 -
187 - @Override
188 - public void setLineNumber(int lineNumber) {
189 - this.lineNumber = lineNumber;
190 - }
191 -
192 - @Override
193 - public void setCharPosition(int charPositionInLine) {
194 - charPosition = charPositionInLine;
195 - }
196 -
197 - /**
198 - * Links the belongs to with a module.
199 - *
200 - * @param yangNodeSet YANG file information set
201 - * @throws DataModelException a violation in data model rule
202 - */
203 - public void linkWithModule(Set<YangNode> yangNodeSet)
204 - throws DataModelException {
205 - String belongsToModuleName = getBelongsToModuleName();
206 - YangNode moduleNode = findReferredNode(yangNodeSet, belongsToModuleName);
207 - if (moduleNode != null) {
208 - if (moduleNode instanceof YangModule) {
209 - setModuleNode(moduleNode);
210 - return;
211 - }
212 - }
213 - DataModelException exception = new DataModelException("YANG file error : Module " + belongsToModuleName +
214 - "to which sub-module belongs to is not found.");
215 - exception.setLine(getLineNumber());
216 - exception.setCharPosition(getCharPosition());
217 - throw exception;
218 - }
219 -}
1 -/*
2 - * Copyright 2016-present 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 java.io.Serializable;
20 -import java.util.Base64;
21 -
22 -import org.onosproject.yangutils.datamodel.utils.builtindatatype.YangBuiltInDataTypeInfo;
23 -import org.onosproject.yangutils.datamodel.utils.builtindatatype.YangDataTypes;
24 -
25 -/*
26 - * Reference RFC 6020.
27 - *
28 - * The binary built-in type represents any binary data,
29 - * i.e., a sequence of octets.
30 - */
31 -public class YangBinary implements YangBuiltInDataTypeInfo<YangBinary>, Serializable, Comparable<YangBinary> {
32 -
33 - private static final long serialVersionUID = 2106201608L;
34 -
35 - // Binary data is a decoded value by base64 decoding scheme from data input (jason)
36 - private byte[] binaryData;
37 -
38 - /**
39 - * Creates a binary object corresponding to the base 64 encoding value.
40 - *
41 - * @param strValue base64 encoded value
42 - */
43 - public YangBinary(String strValue) {
44 - setBinaryData(Base64.getDecoder().decode(strValue));
45 - }
46 -
47 - /**
48 - * Retrieves decoded binary data.
49 - *
50 - * @return binary data
51 - */
52 - public byte[] getBinaryData() {
53 - return binaryData;
54 - }
55 -
56 - /**
57 - * Sets binary data.
58 - *
59 - * @param binaryData binary data
60 - */
61 - public void setBinaryData(byte[] binaryData) {
62 - this.binaryData = binaryData;
63 - }
64 -
65 - /**
66 - * Encodes binary data by base64 encoding scheme.
67 - *
68 - * @return encoded binary data
69 - */
70 - public String toString() {
71 - return Base64.getEncoder()
72 - .encodeToString(binaryData);
73 - }
74 -
75 - @Override
76 - public YangDataTypes getYangType() {
77 - return YangDataTypes.BINARY;
78 - }
79 -
80 - @Override
81 - public int compareTo(YangBinary o) {
82 - for (int i = 0, j = 0; i < this.binaryData.length && j < o.binaryData.length; i++, j++) {
83 - int a = (this.binaryData[i] & 0xff);
84 - int b = (o.binaryData[j] & 0xff);
85 - if (a != b) {
86 - return a - b;
87 - }
88 - }
89 - return this.binaryData.length - o.binaryData.length;
90 - }
91 -}
1 -/*
2 - * Copyright 2016-present 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 java.io.Serializable;
20 -import java.util.Objects;
21 -
22 -import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
23 -import org.onosproject.yangutils.datamodel.utils.Parsable;
24 -import org.onosproject.yangutils.datamodel.utils.YangConstructType;
25 -
26 -/*-
27 - * The "bit" statement, which is a sub-statement to the "type" statement,
28 - * MUST be present if the type is "bits". It is repeatedly used to
29 - * specify each assigned named bit of a bits type. It takes as an
30 - * argument a string that is the assigned name of the bit. It is
31 - * followed by a block of sub-statements that holds detailed bit
32 - * information.
33 - * All assigned names in a bits type MUST be unique.
34 - *
35 - * The bit's sub-statements
36 - *
37 - * +--------------+---------+-------------+------------------+
38 - * | substatement | section | cardinality |data model mapping|
39 - * +--------------+---------+-------------+------------------+
40 - * | description | 7.19.3 | 0..1 | - string |
41 - * | reference | 7.19.4 | 0..1 | - string |
42 - * | status | 7.19.2 | 0..1 | - YangStatus |
43 - * | position | 9.7.4.2 | 0..1 | - int |
44 - * +--------------+---------+-------------+------------------+
45 - */
46 -
47 -/**
48 - * Represents the bit data type information.
49 - */
50 -public class YangBit implements YangCommonInfo, Parsable, Serializable {
51 -
52 - private static final long serialVersionUID = 806201640L;
53 -
54 - /**
55 - * Name of the bit.
56 - */
57 - private String bitName;
58 -
59 - /**
60 - * Description of the bit field.
61 - */
62 - private String description;
63 -
64 - /**
65 - * Reference info of the bit field.
66 - */
67 - private String reference;
68 -
69 - /**
70 - * Status of the bit field.
71 - */
72 - private YangStatusType status;
73 -
74 - /**
75 - * Position of the bit whose name bit is described.
76 - */
77 - private int position;
78 -
79 - /**
80 - * Create a YANG bit type object.
81 - */
82 - public YangBit() {
83 -
84 - }
85 -
86 - /**
87 - * Returns bit name.
88 - *
89 - * @return the bit name
90 - */
91 - public String getBitName() {
92 - return bitName;
93 - }
94 -
95 - /**
96 - * Sets the bit name.
97 - *
98 - * @param bitName the bit name to set
99 - */
100 - public void setBitName(String bitName) {
101 - this.bitName = bitName;
102 - }
103 -
104 - /**
105 - * Returns description.
106 - *
107 - * @return the description
108 - */
109 - @Override
110 - public String getDescription() {
111 - return description;
112 - }
113 -
114 - /**
115 - * Sets the description.
116 - *
117 - * @param description set the description
118 - */
119 - @Override
120 - public void setDescription(String description) {
121 - this.description = description;
122 - }
123 -
124 - /**
125 - * Returns textual reference.
126 - *
127 - * @return the reference
128 - */
129 - @Override
130 - public String getReference() {
131 - return reference;
132 - }
133 -
134 - /**
135 - * Sets the textual reference.
136 - *
137 - * @param reference the reference to set
138 - */
139 - @Override
140 - public void setReference(String reference) {
141 - this.reference = reference;
142 - }
143 -
144 - /**
145 - * Returns status.
146 - *
147 - * @return the status
148 - */
149 - @Override
150 - public YangStatusType getStatus() {
151 - return status;
152 - }
153 -
154 - /**
155 - * Sets the status.
156 - *
157 - * @param status the status to set
158 - */
159 - @Override
160 - public void setStatus(YangStatusType status) {
161 - this.status = status;
162 - }
163 -
164 - /**
165 - * Returns bit position.
166 - *
167 - * @return the position
168 - */
169 - public int getPosition() {
170 - return position;
171 - }
172 -
173 - /**
174 - * Sets the bit position.
175 - *
176 - * @param position the position to set
177 - */
178 - public void setPosition(int position) {
179 - this.position = position;
180 - }
181 -
182 - /**
183 - * Returns the type of the data.
184 - *
185 - * @return ParsedDataType returns BIT_DATA
186 - */
187 - @Override
188 - public YangConstructType getYangConstructType() {
189 - return YangConstructType.BIT_DATA;
190 - }
191 -
192 - @Override
193 - public boolean equals(Object obj) {
194 -
195 - if (this == obj) {
196 - return true;
197 - }
198 - if (obj instanceof YangBit) {
199 - final YangBit other = (YangBit) obj;
200 - return Objects.equals(bitName, other.bitName);
201 - }
202 - return false;
203 - }
204 -
205 - @Override
206 - public int hashCode() {
207 - return Objects.hashCode(bitName);
208 - }
209 -
210 - /**
211 - * Validates the data on entering the corresponding parse tree node.
212 - *
213 - * @throws DataModelException a violation of data model rules
214 - */
215 - @Override
216 - public void validateDataOnEntry() throws DataModelException {
217 - // TODO auto-generated method stub, to be implemented by parser
218 - }
219 -
220 - /**
221 - * Validates the data on exiting the corresponding parse tree node.
222 - *
223 - * @throws DataModelException a violation of data model rules
224 - */
225 - @Override
226 - public void validateDataOnExit() throws DataModelException {
227 - // TODO auto-generated method stub, to be implemented by parser
228 - }
229 -}
1 -/*
2 - * Copyright 2016-present 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 java.io.Serializable;
20 -import java.util.BitSet;
21 -import java.util.HashMap;
22 -import java.util.Map;
23 -import java.util.regex.Pattern;
24 -
25 -import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
26 -import org.onosproject.yangutils.datamodel.utils.Parsable;
27 -import org.onosproject.yangutils.datamodel.utils.YangConstructType;
28 -
29 -/*
30 - * Reference RFC 6020.
31 - *
32 - * The bits built-in type represents a bit set. That is, a bits value
33 - * is a set of flags identified by small integer position numbers
34 - * starting at 0. Each bit number has an assigned name.
35 - */
36 -
37 -/**
38 - * Represents the bits data type information.
39 - */
40 -public class YangBits implements Parsable, Serializable {
41 -
42 - private static final long serialVersionUID = 806201641L;
43 - private static final String SPACE = " ";
44 -
45 - // Bits name
46 - private String bitsName;
47 - // Bits data contains bit-positions will be used to send to ONOS application
48 - private BitSet bitDataSet;
49 - /**
50 - * Mapping bit name to YangBit. In data input (jason), only bit name will be received.
51 - * By using the bit name corresponding (yang) bit-position will be retrieved from bitNameMap map.
52 - */
53 - private Map<String, YangBit> bitNameMap;
54 - /**
55 - * Mapping bit position to YangBit. The bit-position received from ONOS application
56 - * will be converted into bit-name by using bitPositionMap map to send (jason) output data as response.
57 - */
58 - private Map<Integer, YangBit> bitPositionMap;
59 -
60 - /**
61 - * Creates a YANG bits type object.
62 - */
63 - public YangBits() {
64 - bitDataSet = new BitSet();
65 - setBitNameMap(new HashMap<>());
66 - setBitPositionMap(new HashMap<>());
67 - }
68 -
69 - /**
70 - * Returns the bits name.
71 - *
72 - * @return the bits name
73 - */
74 - public String getBitsName() {
75 - return bitsName;
76 - }
77 -
78 - /**
79 - * Sets the bits name.
80 - *
81 - * @param bitsName the bits name
82 - */
83 - public void setBitsName(String bitsName) {
84 - this.bitsName = bitsName;
85 - }
86 -
87 - /**
88 - * Returns the bit data set.
89 - *
90 - * @return the bit data set
91 - */
92 - public BitSet getBitDataSet() {
93 - return bitDataSet;
94 - }
95 -
96 - /**
97 - * Sets the bit data set.
98 - *
99 - * @param bitNames the set of bit names
100 - * @throws DataModelException due to violation in data model rules
101 - */
102 - public void setBitDataSet(String[] bitNames) throws DataModelException {
103 - YangBit bit;
104 - for (String bitName : bitNames) {
105 - bit = bitNameMap.get(bitName);
106 - if (bit == null) {
107 - throw new DataModelException("YANG file error: Unable to find " +
108 - "corresponding bit position for bit name: " + bitName);
109 - }
110 - bitDataSet.set(bit.getPosition());
111 - }
112 - }
113 -
114 - /**
115 - * Returns the bit name map.
116 - *
117 - * @return the bit name map
118 - */
119 - public Map<String, YangBit> getBitNameMap() {
120 - return bitNameMap;
121 - }
122 -
123 - /**
124 - * Sets the bit name map.
125 - *
126 - * @param bitNameMap the bit name map
127 - */
128 - public void setBitNameMap(Map<String, YangBit> bitNameMap) {
129 - this.bitNameMap = bitNameMap;
130 - }
131 -
132 - /**
133 - * Checks whether bit name already available.
134 - *
135 - * @param bitName bit name
136 - * @return true if bit name already available otherwise returns false
137 - */
138 - public boolean isBitNameExists(String bitName) {
139 - return bitNameMap.containsKey(bitName);
140 - }
141 -
142 - /**
143 - * Returns the bit position map.
144 - *
145 - * @return the bit position map
146 - */
147 - public Map<Integer, YangBit> getBitPositionMap() {
148 - return bitPositionMap;
149 - }
150 -
151 - /**
152 - * Sets the bit position map.
153 - *
154 - * @param bitPositionMap the bit position map
155 - */
156 - public void setBitPositionMap(Map<Integer, YangBit> bitPositionMap) {
157 - this.bitPositionMap = bitPositionMap;
158 - }
159 -
160 - /**
161 - * Checks whether bit position already available.
162 - *
163 - * @param bitPosition bit position
164 - * @return true if bit position already available otherwise returns false
165 - */
166 - public boolean isBitPositionExists(Integer bitPosition) {
167 - return bitPositionMap.containsKey(bitPosition);
168 - }
169 -
170 - /**
171 - * Adds bit info.
172 - *
173 - * @param bitInfo the bit information to be added
174 - * @throws DataModelException due to violation in data model rules
175 - */
176 - public void addBitInfo(YangBit bitInfo) throws DataModelException {
177 - if (bitNameMap.put(bitInfo.getBitName(), bitInfo) != null) {
178 - throw new DataModelException("YANG file error: Duplicate bit name detected, same as bit name \""
179 - + bitInfo.getBitName() + "\"");
180 - }
181 - if (bitPositionMap.put(bitInfo.getPosition(), bitInfo) != null) {
182 - throw new DataModelException("YANG file error: Duplicate bit position detected, same as bit position \""
183 - + bitInfo.getPosition() + "\"");
184 - }
185 - }
186 -
187 - /**
188 - * Returns the type of the data.
189 - *
190 - * @return ParsedDataType returns BITS_DATA
191 - */
192 - @Override
193 - public YangConstructType getYangConstructType() {
194 - return YangConstructType.BITS_DATA;
195 - }
196 -
197 - @Override
198 - public String toString() {
199 - YangBit bit;
200 - String bits = new String();
201 - for (int i = bitDataSet.nextSetBit(0); i >= 0; i = bitDataSet.nextSetBit(i + 1)) {
202 - bit = bitPositionMap.get(i);
203 - if (bit == null) {
204 - return null;
205 - }
206 - if (bits.isEmpty()) {
207 - bits = bit.getBitName();
208 - } else {
209 - bits += " " + bit.getBitName();
210 - }
211 - }
212 - return bits.trim();
213 - }
214 -
215 - /**
216 - * Returns the object of YANG bits based on specific set of bit names.
217 - *
218 - * @param bits set of bit names
219 - * @return Object of YANG bits
220 - */
221 - public YangBits fromString(String bits) {
222 - try {
223 - String[] bitNames = bits.trim().split(Pattern.quote(SPACE));
224 - setBitDataSet(bitNames);
225 - return this;
226 - } catch (Exception e) {
227 - }
228 - return null;
229 - }
230 -
231 - /**
232 - * Validates the data on entering the corresponding parse tree node.
233 - *
234 - * @throws DataModelException a violation of data model rules
235 - */
236 - @Override
237 - public void validateDataOnEntry() throws DataModelException {
238 - // TODO auto-generated method stub, to be implemented by parser
239 - }
240 -
241 - /**
242 - * Validates the data on exiting the corresponding parse tree node.
243 - *
244 - * @throws DataModelException a violation of data model rules
245 - */
246 - @Override
247 - public void validateDataOnExit() throws DataModelException {
248 - // TODO auto-generated method stub, to be implemented by parser
249 - }
250 -}
1 -/*
2 - * Copyright 2016-present 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-present 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.datamodel.utils.Parsable;
21 -import org.onosproject.yangutils.datamodel.utils.YangConstructType;
22 -
23 -/**
24 - * Represents data model node to maintain information defined in YANG compiler-annotation.
25 - */
26 -public class YangCompilerAnnotation implements Parsable {
27 -
28 - /**
29 - * App data structure information.
30 - */
31 - private YangAppDataStructure yangAppDataStructure;
32 -
33 - /**
34 - * App extended name information.
35 - */
36 - private YangAppExtendedName yangAppExtendedName;
37 -
38 - /**
39 - * Prefix of compiler-annotation.
40 - */
41 - private String prefix;
42 -
43 - /**
44 - * Path of compiler-annotation.
45 - */
46 - private String path;
47 -
48 - /**
49 - * Returns the YANG app data structure information.
50 - *
51 - * @return the YANG app data structure information
52 - */
53 - public YangAppDataStructure getYangAppDataStructure() {
54 - return yangAppDataStructure;
55 - }
56 -
57 - /**
58 - * Sets the YANG app data structure information.
59 - *
60 - * @param yangAppDataStructure the YANG app data structure to set
61 - */
62 - public void setYangAppDataStructure(YangAppDataStructure yangAppDataStructure) {
63 - this.yangAppDataStructure = yangAppDataStructure;
64 - }
65 -
66 - /**
67 - * Returns the prefix.
68 - *
69 - * @return the prefix
70 - */
71 - public String getPrefix() {
72 - return prefix;
73 - }
74 -
75 - /**
76 - * Sets the prefix information.
77 - *
78 - * @param prefix the prefix to set
79 - */
80 - public void setPrefix(String prefix) {
81 - this.prefix = prefix;
82 - }
83 -
84 - /**
85 - * Returns the path.
86 - *
87 - * @return the path
88 - */
89 - public String getPath() {
90 - return path;
91 - }
92 -
93 - /**
94 - * Sets the path.
95 - *
96 - * @param path the path to set
97 - */
98 - public void setPath(String path) {
99 - this.path = path;
100 - }
101 -
102 - /**
103 - * Returns the YANG app extended name information.
104 - *
105 - * @return the YANG app extended name information
106 - */
107 - public YangAppExtendedName getYangAppExtendedName() {
108 - return yangAppExtendedName;
109 - }
110 -
111 - /**
112 - * Sets the YANG app extended name information.
113 - *
114 - * @param yangAppExtendedName the YANG app extended name to set
115 - */
116 - public void setYangAppExtendedName(YangAppExtendedName yangAppExtendedName) {
117 - this.yangAppExtendedName = yangAppExtendedName;
118 - }
119 -
120 - @Override
121 - public YangConstructType getYangConstructType() {
122 - return YangConstructType.COMPILER_ANNOTATION_DATA;
123 - }
124 -
125 - @Override
126 - public void validateDataOnEntry() throws DataModelException {
127 - // TODO : to be implemented
128 - }
129 -
130 - @Override
131 - public void validateDataOnExit() throws DataModelException {
132 - // TODO : to be implemented
133 - }
134 -}
1 -/*
2 - * Copyright 2016-present 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 data node, used by YMS to abstractly refer the data
21 - * nodes in YANG data tree.
22 - */
23 -public interface YangDataNode {
24 -}
1 -/*
2 - * Copyright 2016-present 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 - * Represents ENUM to identify the YANG data type.
21 - */
22 -public enum YangDataStructure {
23 -
24 - MAP,
25 -
26 - LIST,
27 -
28 - SET;
29 -
30 - /**
31 - * Returns YANG data structure type for corresponding data structure name.
32 - *
33 - * @param name data structure name from YANG file.
34 - * @return YANG data structure for corresponding data structure name.
35 - */
36 - public static YangDataStructure getType(String name) {
37 - name = name.replace("\"", "");
38 - for (YangDataStructure dataStructure : values()) {
39 - if (dataStructure.name().toLowerCase().equals(name)) {
40 - return dataStructure;
41 - }
42 - }
43 - return null;
44 - }
45 -}
1 -/*
2 - * Copyright 2016-present 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 - /**
26 - * Returns the description of YANG entity.
27 - *
28 - * @return the description of YANG entity.
29 - */
30 - String getDescription();
31 -
32 - /**
33 - * Set the description of YANG entity.
34 - *
35 - * @param description set the description of YANG entity.
36 - */
37 - void setDescription(String description);
38 -}
1 -/*
2 - * Copyright 2016-present 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 information about entity being resolved.
21 - *
22 - * @param <T> type of entity being resolved, uses / grouping
23 - */
24 -public interface YangEntityToResolveInfo<T> {
25 -
26 - /**
27 - * Retrieves the entity to be resolved.
28 - *
29 - * @return entity to be resolved
30 - */
31 - T getEntityToResolve();
32 -
33 - /**
34 - * Sets entity to be resolved.
35 - *
36 - * @param entityToResolve entity to be resolved
37 - */
38 - void setEntityToResolve(T entityToResolve);
39 -
40 - /**
41 - * Retrieves the parent node which contains the entity to be resolved.
42 - *
43 - * @return parent node which contains the entity to be resolved
44 - */
45 - YangNode getHolderOfEntityToResolve();
46 -
47 - /**
48 - * Sets parent node which contains the entity to be resolved.
49 - *
50 - * @param holderOfEntityToResolve parent node which contains the entity to
51 - * be resolved
52 - */
53 - void setHolderOfEntityToResolve(YangNode holderOfEntityToResolve);
54 -}
1 -/*
2 - * Copyright 2016-present 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 java.io.Serializable;
19 -
20 -/**
21 - * Represents implementation of information about entity being resolved.
22 - *
23 - * @param <T> type of entity being resolved, uses / grouping
24 - */
25 -public class YangEntityToResolveInfoImpl<T> implements YangEntityToResolveInfo<T>, Serializable, LocationInfo {
26 -
27 - private static final long serialVersionUID = 806201659L;
28 -
29 - /**
30 - * Parsable node for which resolution is to be performed.
31 - */
32 - private T entityToResolve;
33 -
34 - /**
35 - * Holder of the YANG construct for which resolution has to be carried out.
36 - */
37 - private YangNode holderOfEntityToResolve;
38 -
39 - /**
40 - * Error line number.
41 - */
42 - private transient int lineNumber;
43 -
44 - /**
45 - * Error character position in number.
46 - */
47 - private transient int charPositionInLine;
48 -
49 - @Override
50 - public T getEntityToResolve() {
51 - return entityToResolve;
52 - }
53 -
54 - @Override
55 - public void setEntityToResolve(T entityToResolve) {
56 - this.entityToResolve = entityToResolve;
57 - }
58 -
59 - @Override
60 - public YangNode getHolderOfEntityToResolve() {
61 - return holderOfEntityToResolve;
62 - }
63 -
64 - @Override
65 - public void setHolderOfEntityToResolve(YangNode holderOfEntityToResolve) {
66 - this.holderOfEntityToResolve = holderOfEntityToResolve;
67 - }
68 -
69 - @Override
70 - public int getLineNumber() {
71 - return lineNumber;
72 - }
73 -
74 - @Override
75 - public int getCharPosition() {
76 - return charPositionInLine;
77 - }
78 -
79 - @Override
80 - public void setLineNumber(int lineNumber) {
81 - this.lineNumber = lineNumber;
82 - }
83 -
84 - @Override
85 - public void setCharPosition(int charPositionInLine) {
86 - this.charPositionInLine = charPositionInLine;
87 - }
88 -}
1 -/*
2 - * Copyright 2016-present 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 java.io.Serializable;
20 -import java.util.Objects;
21 -
22 -import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
23 -import org.onosproject.yangutils.datamodel.utils.Parsable;
24 -import org.onosproject.yangutils.datamodel.utils.YangConstructType;
25 -
26 -/*-
27 - * The "ENUM" statement, which is a sub-statement to the "type"
28 - * statement, MUST be present if the type is "enumeration". It is
29 - * repeatedly used to specify each assigned name of an enumeration type.
30 - * It takes as an argument a string which is the assigned name. The
31 - * string MUST NOT be empty and MUST NOT have any leading or trailing
32 - * whitespace characters. The use of Unicode control codes SHOULD be
33 - * avoided.
34 - *
35 - * The statement is optionally followed by a block of sub-statements that
36 - * holds detailed ENUM information.
37 - * All assigned names in an enumeration MUST be unique.
38 - *
39 - * The ENUM's sub-statements
40 - *
41 - * +--------------+---------+-------------+------------------+
42 - * | substatement | section | cardinality |data model mapping|
43 - * +--------------+---------+-------------+------------------+
44 - * | description | 7.19.3 | 0..1 | - string |
45 - * | reference | 7.19.4 | 0..1 | - string |
46 - * | status | 7.19.2 | 0..1 | - YangStatus |
47 - * | value | 9.6.4.2 | 0..1 | - int |
48 - * +--------------+---------+-------------+------------------+
49 - */
50 -
51 -/**
52 - * Represents the ENUM data type information.
53 - */
54 -public class YangEnum implements YangCommonInfo, Parsable, Comparable<YangEnum>, Serializable {
55 -
56 - private static final long serialVersionUID = 806201643L;
57 -
58 - /**
59 - * Named value for the ENUM.
60 - */
61 - private String namedValue;
62 -
63 - /**
64 - * Description of the ENUM value.
65 - */
66 - private String description;
67 -
68 - /**
69 - * Reference info of the ENUM value.
70 - */
71 - private String reference;
72 -
73 - /**
74 - * Status of the ENUM value.
75 - */
76 - private YangStatusType status;
77 -
78 - /**
79 - * Value of ENUM.
80 - */
81 - private int value;
82 -
83 - /**
84 - * Create a YANG ENUM.
85 - */
86 - public YangEnum() {
87 -
88 - }
89 -
90 - /**
91 - * Returns the named value.
92 - *
93 - * @return the named value
94 - */
95 - public String getNamedValue() {
96 - return namedValue;
97 - }
98 -
99 - /**
100 - * Sets the named value.
101 - *
102 - * @param namedValue the named value to set
103 - */
104 - public void setNamedValue(String namedValue) {
105 - this.namedValue = namedValue;
106 - }
107 -
108 - /**
109 - * Returns the description.
110 - *
111 - * @return the description
112 - */
113 - @Override
114 - public String getDescription() {
115 - return description;
116 - }
117 -
118 - /**
119 - * Sets the description.
120 - *
121 - * @param description set the description
122 - */
123 - @Override
124 - public void setDescription(String description) {
125 - this.description = description;
126 - }
127 -
128 - /**
129 - * Returns the textual reference.
130 - *
131 - * @return the reference
132 - */
133 - @Override
134 - public String getReference() {
135 - return reference;
136 - }
137 -
138 - /**
139 - * Sets the textual reference.
140 - *
141 - * @param reference the reference to set
142 - */
143 - @Override
144 - public void setReference(String reference) {
145 - this.reference = reference;
146 - }
147 -
148 - /**
149 - * Returns the status.
150 - *
151 - * @return the status
152 - */
153 - @Override
154 - public YangStatusType getStatus() {
155 - return status;
156 - }
157 -
158 - /**
159 - * Sets the status.
160 - *
161 - * @param status the status to set
162 - */
163 - @Override
164 - public void setStatus(YangStatusType status) {
165 - this.status = status;
166 - }
167 -
168 - /**
169 - * Returns the value.
170 - *
171 - * @return the value
172 - */
173 - public int getValue() {
174 - return value;
175 - }
176 -
177 - /**
178 - * Sets the value.
179 - *
180 - * @param value the value to set
181 - */
182 - public void setValue(int value) {
183 - this.value = value;
184 - }
185 -
186 - /**
187 - * Returns the type of the data.
188 - *
189 - * @return ParsedDataType returns ENUM_DATA
190 - */
191 - @Override
192 - public YangConstructType getYangConstructType() {
193 - return YangConstructType.ENUM_DATA;
194 - }
195 -
196 - @Override
197 - public boolean equals(Object obj) {
198 - if (this == obj) {
199 - return true;
200 - }
201 - if (obj instanceof YangEnum) {
202 - final YangEnum other = (YangEnum) obj;
203 - return Objects.equals(namedValue, other.namedValue);
204 - }
205 - return false;
206 - }
207 -
208 - @Override
209 - public int hashCode() {
210 - return Objects.hashCode(namedValue);
211 - }
212 -
213 - /**
214 - * Validates the data on entering the corresponding parse tree node.
215 - *
216 - * @throws DataModelException a violation of data model rules
217 - */
218 - @Override
219 - public void validateDataOnEntry() throws DataModelException {
220 - // TODO auto-generated method stub, to be implemented by parser
221 - }
222 -
223 - /**
224 - * Validates the data on exiting the corresponding parse tree node.
225 - *
226 - * @throws DataModelException a violation of data model rules
227 - */
228 - @Override
229 - public void validateDataOnExit() throws DataModelException {
230 - // TODO auto-generated method stub, to be implemented by parser
231 - }
232 -
233 - @Override
234 - public int compareTo(YangEnum otherEnum) {
235 - if (namedValue.equals(otherEnum.getNamedValue())) {
236 - return 0;
237 - }
238 - return new Integer(value).compareTo(otherEnum.getValue());
239 - }
240 -}
1 -/*
2 - * Copyright 2016-present 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 java.util.SortedSet;
20 -import java.util.TreeSet;
21 -
22 -import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
23 -import org.onosproject.yangutils.datamodel.utils.Parsable;
24 -import org.onosproject.yangutils.datamodel.utils.YangConstructType;
25 -
26 -/*
27 - * The enumeration built-in type represents values from a set of
28 - * assigned names.
29 - */
30 -
31 -/**
32 - * Represents the enumeration data type information.
33 - */
34 -public class YangEnumeration
35 - extends YangNode
36 - implements Parsable, CollisionDetector {
37 -
38 - private static final long serialVersionUID = 806201606L;
39 -
40 - // Enumeration info set.
41 - private SortedSet<YangEnum> enumSet;
42 -
43 - // Enumeration name.
44 - private String name;
45 -
46 - /**
47 - * Creates an enumeration object.
48 - */
49 - public YangEnumeration() {
50 - super(YangNodeType.ENUMERATION_NODE);
51 - setEnumSet(new TreeSet<YangEnum>());
52 - }
53 -
54 - /**
55 - * Returns the ENUM set.
56 - *
57 - * @return the ENUM set
58 - */
59 - public SortedSet<YangEnum> getEnumSet() {
60 - return enumSet;
61 - }
62 -
63 - /**
64 - * Sets the ENUM set.
65 - *
66 - * @param enumSet the ENUM set to set
67 - */
68 - private void setEnumSet(SortedSet<YangEnum> enumSet) {
69 - this.enumSet = enumSet;
70 - }
71 -
72 - /**
73 - * Adds ENUM information.
74 - *
75 - * @param enumInfo the ENUM information to be added
76 - * @throws DataModelException due to violation in data model rules
77 - */
78 - public void addEnumInfo(YangEnum enumInfo)
79 - throws DataModelException {
80 - if (!getEnumSet().add(enumInfo)) {
81 - throw new DataModelException("YANG ENUM already exists");
82 - }
83 - }
84 -
85 - /**
86 - * Returns enumeration name.
87 - *
88 - * @return the enumeration name
89 - */
90 - @Override
91 - public String getName() {
92 - return name;
93 - }
94 -
95 - /**
96 - * Sets the enumeration name.
97 - *
98 - * @param name enumeration name
99 - */
100 - @Override
101 - public void setName(String name) {
102 - this.name = name;
103 - }
104 -
105 - /**
106 - * Returns the type of the data.
107 - *
108 - * @return returns ENUMERATION_DATA
109 - */
110 - @Override
111 - public YangConstructType getYangConstructType() {
112 - return YangConstructType.ENUMERATION_DATA;
113 - }
114 -
115 - /**
116 - * Validates the data on entering the corresponding parse tree node.
117 - *
118 - * @throws DataModelException a violation of data model rules
119 - */
120 - @Override
121 - public void validateDataOnEntry()
122 - throws DataModelException {
123 - // TODO auto-generated method stub, to be implemented by parser
124 - }
125 -
126 - /**
127 - * Validates the data on exiting the corresponding parse tree node.
128 - *
129 - * @throws DataModelException a violation of data model rules
130 - */
131 - @Override
132 - public void validateDataOnExit()
133 - throws DataModelException {
134 - // TODO auto-generated method stub, to be implemented by parser
135 - }
136 -
137 - @Override
138 - public void detectCollidingChild(String identifierName, YangConstructType dataType)
139 - throws DataModelException {
140 - /*
141 - Do nothing, since it is not part of the schema tree, it is only type of an existing node in schema tree.
142 - */
143 - }
144 -
145 - @Override
146 - public void detectSelfCollision(String identifierName, YangConstructType dataType)
147 - throws DataModelException {
148 - /*
149 - Do nothing, since it is not part of the schema tree, it is only type of an existing node in schema tree.
150 - */
151 - }
152 -}
1 -/*
2 - * Copyright 2016-present 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 java.io.Serializable;
20 -import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
21 -import org.onosproject.yangutils.datamodel.utils.Parsable;
22 -import org.onosproject.yangutils.datamodel.utils.YangConstructType;
23 -
24 -/*-
25 - * Reference RFC 6020.
26 - *
27 - * The "extension" statement allows the definition of new statements
28 - * within the YANG language. This new statement definition can be
29 - * imported and used by other modules.
30 - *
31 - * The statement's argument is an identifier that is the new keyword for
32 - * the extension and must be followed by a block of sub-statements that
33 - * holds detailed extension information. The purpose of the "extension"
34 - * statement is to define a keyword, so that it can be imported and used
35 - * by other modules.
36 - *
37 - * The extension can be used like a normal YANG statement, with the
38 - * statement name followed by an argument if one is defined by the
39 - * extension, and an optional block of sub-statements. The statement's
40 - * name is created by combining the prefix of the module in which the
41 - * extension was defined, a colon (":"), and the extension's keyword,
42 - * with no interleaving whitespace. The sub-statements of an extension
43 - * are defined by the extension, using some mechanism outside the scope
44 - * of this specification. Syntactically, the sub-statements MUST be YANG
45 - * statements, or also defined using "extension" statements.
46 - *
47 - * The extension's Sub-statements
48 - *
49 - * +--------------+---------+-------------+------------------+
50 - * | substatement | section | cardinality |data model mapping|
51 - * +--------------+---------+-------------+------------------+
52 - * | description | 7.19.3 | 0..1 | -string |
53 - * | reference | 7.19.4 | 0..1 | -string |
54 - * | status | 7.19.2 | 0..1 | -YangStatus |
55 - * | argument | 7.17.2 | 0..1 | -string |
56 - * +--------------+---------+-------------+------------------+
57 - */
58 -
59 -/**
60 - * Represents data model node to maintain information defined in YANG extension.
61 - */
62 -public class YangExtension
63 - implements YangCommonInfo, Serializable, Parsable {
64 -
65 - private static final long serialVersionUID = 806201605L;
66 -
67 - /**
68 - * Name of the extension.
69 - */
70 - private String name;
71 -
72 - /**
73 - * Name of the argument.
74 - */
75 - private String argumentName;
76 -
77 - /**
78 - * Description of extension.
79 - */
80 - private String description;
81 -
82 - /**
83 - * Reference of the extension.
84 - */
85 - private String reference;
86 -
87 - /**
88 - * Status of the extension.
89 - */
90 - private YangStatusType status = YangStatusType.CURRENT;
91 -
92 - /**
93 - * Returns the YANG name of extension.
94 - *
95 - * @return the name of extension as defined in YANG file
96 - */
97 - public String getName() {
98 - return name;
99 - }
100 -
101 - /**
102 - * Sets the YANG name of extension.
103 - *
104 - * @param name the name of extension as defined in YANG file
105 - */
106 - public void setName(String name) {
107 - this.name = name;
108 - }
109 -
110 - /**
111 - * Returns the YANG argument name of extension.
112 - *
113 - * @return the name of argument as defined in YANG file
114 - */
115 - public String getArgumentName() {
116 - return argumentName;
117 - }
118 -
119 - /**
120 - * Sets the YANG argument name of extension.
121 - *
122 - * @param argumentName the name of argument as defined in YANG file
123 - */
124 - public void setArgumentName(String argumentName) {
125 - this.argumentName = argumentName;
126 - }
127 -
128 - /**
129 - * Returns the description.
130 - *
131 - * @return the description
132 - */
133 - @Override
134 - public String getDescription() {
135 - return description;
136 - }
137 -
138 - /**
139 - * Sets the description.
140 - *
141 - * @param description set the description
142 - */
143 - @Override
144 - public void setDescription(String description) {
145 - this.description = description;
146 - }
147 -
148 - /**
149 - * Returns the textual reference.
150 - *
151 - * @return the reference
152 - */
153 - @Override
154 - public String getReference() {
155 - return reference;
156 - }
157 -
158 - /**
159 - * Sets the textual reference.
160 - *
161 - * @param reference the reference to set
162 - */
163 - @Override
164 - public void setReference(String reference) {
165 - this.reference = reference;
166 - }
167 -
168 - /**
169 - * Returns the status.
170 - *
171 - * @return the status
172 - */
173 - @Override
174 - public YangStatusType getStatus() {
175 - return status;
176 - }
177 -
178 - /**
179 - * Sets the status.
180 - *
181 - * @param status the status to set
182 - */
183 - @Override
184 - public void setStatus(YangStatusType status) {
185 - this.status = status;
186 - }
187 -
188 - /**
189 - * Returns the type of the data.
190 - *
191 - * @return returns EXTENSION_DATA
192 - */
193 - @Override
194 - public YangConstructType getYangConstructType() {
195 - return YangConstructType.EXTENSION_DATA;
196 - }
197 -
198 - /**
199 - * Validates the data on entering the corresponding parse tree node.
200 - *
201 - * @throws DataModelException a violation of data model rules
202 - */
203 - @Override
204 - public void validateDataOnEntry()
205 - throws DataModelException {
206 - // TODO auto-generated method stub, to be implemented by parser
207 - }
208 -
209 - /**
210 - * Validates the data on exiting the corresponding parse tree node.
211 - *
212 - * @throws DataModelException a violation of data model rules
213 - */
214 - @Override
215 - public void validateDataOnExit()
216 - throws DataModelException {
217 - // TODO : to be implemented
218 - }
219 -}
1 -/*
2 - * Copyright 2016-present 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 java.io.Serializable;
20 -import java.util.LinkedList;
21 -import java.util.List;
22 -import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
23 -import org.onosproject.yangutils.datamodel.utils.Parsable;
24 -import org.onosproject.yangutils.datamodel.utils.YangConstructType;
25 -
26 -/*
27 - * Reference RFC 6020.
28 - *
29 - * The "feature" statement is used to define a mechanism by which
30 - * portions of the schema are marked as conditional. A feature name is
31 - * defined that can later be referenced using the "if-feature" statement.
32 - * Schema nodes tagged with a feature are ignored by the device unless
33 - * the device supports the given feature. This allows portions of the
34 - * YANG module to be conditional based on conditions on the device.
35 - * The model can represent the abilities of the device within the model,
36 - * giving a richer model that allows for differing device abilities and roles.
37 - *
38 - * The argument to the "feature" statement is the name of the new
39 - * feature, and follows the rules for identifiers. This name is used by the
40 - * "if-feature" statement to tie the schema nodes to the feature.
41 - *
42 - * The feature's Substatements
43 - *
44 - * +--------------+---------+-------------+------------------+
45 - * | substatement | section | cardinality |data model mapping|
46 - * +--------------+---------+-------------+------------------+
47 - * | description | 7.19.3 | 0..1 | -string |
48 - * | if-feature | 7.18.2 | 0..n | -YangIfFeature |
49 - * | reference | 7.19.4 | 0..1 | -string |
50 - * | status | 7.19.2 | 0..1 | -YangStatus |
51 - * +--------------+---------+-------------+------------------+
52 - */
53 -
54 -/**
55 - * Represents data model node to maintain information defined in YANG feature.
56 - */
57 -public class YangFeature implements YangCommonInfo, Parsable, YangIfFeatureHolder, Serializable {
58 -
59 - private static final long serialVersionUID = 806201635L;
60 -
61 - /**
62 - * Name of the feature.
63 - */
64 - private String name;
65 -
66 - /**
67 - * Description of feature.
68 - */
69 - private String description;
70 -
71 - /**
72 - * Reference of the feature.
73 - */
74 - private String reference;
75 -
76 - /**
77 - * Status of feature.
78 - */
79 - private YangStatusType statusType;
80 -
81 - /**
82 - * List of if-feature.
83 - */
84 - private List<YangIfFeature> ifFeatureList;
85 -
86 - @Override
87 - public String getDescription() {
88 - return description;
89 - }
90 -
91 - @Override
92 - public void setDescription(String description) {
93 - this.description = description;
94 - }
95 -
96 - @Override
97 - public String getReference() {
98 - return reference;
99 - }
100 -
101 - @Override
102 - public void setReference(String reference) {
103 - this.reference = reference;
104 - }
105 -
106 - @Override
107 - public YangStatusType getStatus() {
108 - return statusType;
109 - }
110 -
111 - @Override
112 - public void setStatus(YangStatusType status) {
113 - this.statusType = status;
114 - }
115 -
116 - public String getName() {
117 - return name;
118 - }
119 -
120 - public void setName(String name) {
121 - this.name = name;
122 - }
123 -
124 - @Override
125 - public YangConstructType getYangConstructType() {
126 - return YangConstructType.FEATURE_DATA;
127 - }
128 -
129 - @Override
130 - public void validateDataOnEntry() throws DataModelException {
131 - //TODO : To be implemented
132 - }
133 -
134 - @Override
135 - public void validateDataOnExit() throws DataModelException {
136 - //TODO : To be implemented
137 - }
138 -
139 - @Override
140 - public List<YangIfFeature> getIfFeatureList() {
141 - return ifFeatureList;
142 - }
143 -
144 - @Override
145 - public void addIfFeatureList(YangIfFeature ifFeature) {
146 - if (getIfFeatureList() == null) {
147 - setIfFeatureList(new LinkedList<>());
148 - }
149 - getIfFeatureList().add(ifFeature);
150 - }
151 -
152 - @Override
153 - public void setIfFeatureList(List<YangIfFeature> ifFeatureList) {
154 - this.ifFeatureList = ifFeatureList;
155 - }
156 -}
1 -/*Copyright 2016.year Open Networking Laboratory
2 -
3 -Licensed under the Apache License, Version 2.0 (the "License");
4 -you may not use this file except in compliance with the License.
5 -You may obtain a copy of the License at
6 -
7 - http://www.apache.org/licenses/LICENSE-2.0
8 -
9 -Unless required by applicable law or agreed to in writing, software
10 -distributed under the License is distributed on an "AS IS" BASIS,
11 -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 -See the License for the specific language governing permissions and
13 -limitations under the License.*/
14 -
15 -package org.onosproject.yangutils.datamodel;
16 -
17 -import java.util.List;
18 -
19 -/**
20 - * Abstraction of feature entity. It is used to abstract the data holders of feature.
21 - */
22 -public interface YangFeatureHolder {
23 -
24 - /**
25 - * Returns the list of feature from data holder like container / list.
26 - *
27 - * @return the list of feature
28 - */
29 - List<YangFeature> getFeatureList();
30 -
31 - /**
32 - * Adds feature in feature list.
33 - *
34 - * @param feature the feature to be added
35 - */
36 - void addFeatureList(YangFeature feature);
37 -
38 - /**
39 - * Sets the list of feature.
40 - *
41 - * @param listOfFeature the list of feature to set
42 - */
43 - void setListOfFeature(List<YangFeature> listOfFeature);
44 -}
1 -/*
2 - * Copyright 2016-present 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 java.util.LinkedList;
19 -import java.util.List;
20 -
21 -import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
22 -import org.onosproject.yangutils.datamodel.utils.Parsable;
23 -import org.onosproject.yangutils.datamodel.utils.YangConstructType;
24 -
25 -import static org.onosproject.yangutils.datamodel.utils.DataModelUtils.detectCollidingChildUtil;
26 -
27 -/*-
28 - * Reference RFC 6020.
29 - *
30 - * The "grouping" statement is used to define a reusable block of nodes,
31 - * which may be used locally in the module, in modules that include it,
32 - * and by other modules that import from it. It takes one argument,
33 - * which is an identifier, followed by a block of sub-statements that
34 - * holds detailed grouping information.
35 - *
36 - * The "grouping" statement is not a data definition statement and, as
37 - * such, does not define any nodes in the schema tree.
38 - *
39 - * A grouping is like a "structure" or a "record" in conventional
40 - * programming languages.
41 - * Once a grouping is defined, it can be referenced in a "uses"
42 - * statement. A grouping MUST NOT reference itself,
43 - * neither directly nor indirectly through a chain of other groupings.
44 - *
45 - * If the grouping is defined at the top level of a YANG module or
46 - * submodule, the grouping's identifier MUST be unique within the
47 - * module.
48 - *
49 - * A grouping is more than just a mechanism for textual substitution,
50 - * but defines a collection of nodes. Identifiers appearing inside the
51 - * grouping are resolved relative to the scope in which the grouping is
52 - * defined, not where it is used. Prefix mappings, type names, grouping
53 - * names, and extension usage are evaluated in the hierarchy where the
54 - * "grouping" statement appears. For extensions, this means that
55 - * extensions are applied to the grouping node, not the uses node.
56 - *
57 - * The grouping's sub-statements
58 - *
59 - * +--------------+---------+-------------+------------------+
60 - * | substatement | section | cardinality |data model mapping|
61 - * +--------------+---------+-------------+------------------+
62 - * | anyxml | 7.10 | 0..n |-not supported |
63 - * | choice | 7.9 | 0..n |-child nodes |
64 - * | container | 7.5 | 0..n |-child nodes |
65 - * | description | 7.19.3 | 0..1 |-string |
66 - * | grouping | 7.11 | 0..n |-child nodes |
67 - * | leaf | 7.6 | 0..n |-YangLeaf |
68 - * | leaf-list | 7.7 | 0..n |-YangLeafList |
69 - * | list | 7.8 | 0..n |-child nodes |
70 - * | reference | 7.19.4 | 0..1 |-string |
71 - * | status | 7.19.2 | 0..1 |-YangStatus |
72 - * | typedef | 7.3 | 0..n |-child nodes |
73 - * | uses | 7.12 | 0..n |-child nodes |
74 - * +--------------+---------+-------------+------------------+
75 - */
76 -
77 -/**
78 - * Represents data model node to maintain information defined in YANG grouping.
79 - */
80 -public class YangGrouping
81 - extends YangNode
82 - implements YangLeavesHolder, YangCommonInfo, Parsable, CollisionDetector, YangTranslatorOperatorNode {
83 -
84 - private static final long serialVersionUID = 806201607L;
85 -
86 - /**
87 - * Name of the grouping.
88 - */
89 - private String name;
90 -
91 - /**
92 - * Description.
93 - */
94 - private String description;
95 -
96 - /**
97 - * List of leaves.
98 - */
99 - private List<YangLeaf> listOfLeaf;
100 -
101 - /**
102 - * List of leaf lists.
103 - */
104 - private List<YangLeafList> listOfLeafList;
105 -
106 - /**
107 - * Reference of the module.
108 - */
109 - private String reference;
110 -
111 - /**
112 - * Status of the node.
113 - */
114 - private YangStatusType status;
115 -
116 - /**
117 - * Creates the grouping node.
118 - */
119 - public YangGrouping() {
120 - super(YangNodeType.GROUPING_NODE);
121 - listOfLeaf = new LinkedList<YangLeaf>();
122 - listOfLeafList = new LinkedList<YangLeafList>();
123 - }
124 -
125 - /**
126 - * Returns YANG grouping name.
127 - *
128 - * @return YANG grouping name
129 - */
130 - @Override
131 - public String getName() {
132 - return name;
133 - }
134 -
135 - /**
136 - * Sets YANG grouping name.
137 - *
138 - * @param name YANG grouping name
139 - */
140 - @Override
141 - public void setName(String name) {
142 - this.name = name;
143 - }
144 -
145 - /**
146 - * Returns the description.
147 - *
148 - * @return the description
149 - */
150 - @Override
151 - public String getDescription() {
152 - return description;
153 - }
154 -
155 - /**
156 - * Sets the description.
157 - *
158 - * @param description set the description
159 - */
160 - @Override
161 - public void setDescription(String description) {
162 - this.description = description;
163 - }
164 -
165 - /**
166 - * Returns the list of leaves.
167 - *
168 - * @return the list of leaves
169 - */
170 - @Override
171 - public List<YangLeaf> getListOfLeaf() {
172 - return listOfLeaf;
173 - }
174 -
175 - /**
176 - * Sets the list of leaves.
177 - *
178 - * @param leafsList the list of leaf to set
179 - */
180 - @Override
181 - public void setListOfLeaf(List<YangLeaf> leafsList) {
182 - listOfLeaf = leafsList;
183 - }
184 -
185 - /**
186 - * Adds a leaf.
187 - *
188 - * @param leaf the leaf to be added
189 - */
190 - @Override
191 - public void addLeaf(YangLeaf leaf) {
192 - getListOfLeaf().add(leaf);
193 - }
194 -
195 - /**
196 - * Returns the list of leaf-list.
197 - *
198 - * @return the list of leaf-list
199 - */
200 - @Override
201 - public List<YangLeafList> getListOfLeafList() {
202 - return listOfLeafList;
203 - }
204 -
205 - /**
206 - * Sets the list of leaf-list.
207 - *
208 - * @param listOfLeafList the list of leaf-list to set
209 - */
210 - @Override
211 - public void setListOfLeafList(List<YangLeafList> listOfLeafList) {
212 - this.listOfLeafList = listOfLeafList;
213 - }
214 -
215 - /**
216 - * Adds a leaf-list.
217 - *
218 - * @param leafList the leaf-list to be added
219 - */
220 - @Override
221 - public void addLeafList(YangLeafList leafList) {
222 - getListOfLeafList().add(leafList);
223 - }
224 -
225 - /**
226 - * Returns the textual reference.
227 - *
228 - * @return the reference
229 - */
230 - @Override
231 - public String getReference() {
232 - return reference;
233 - }
234 -
235 - /**
236 - * Sets the textual reference.
237 - *
238 - * @param reference the reference to set
239 - */
240 - @Override
241 - public void setReference(String reference) {
242 - this.reference = reference;
243 - }
244 -
245 - /**
246 - * Returns the status.
247 - *
248 - * @return the status
249 - */
250 - @Override
251 - public YangStatusType getStatus() {
252 - return status;
253 - }
254 -
255 - /**
256 - * Sets the status.
257 - *
258 - * @param status the status to set
259 - */
260 - @Override
261 - public void setStatus(YangStatusType status) {
262 - this.status = status;
263 - }
264 -
265 - /**
266 - * Returns the type of the data.
267 - *
268 - * @return returns GROUPING_DATA
269 - */
270 - @Override
271 - public YangConstructType getYangConstructType() {
272 - return YangConstructType.GROUPING_DATA;
273 - }
274 -
275 - /**
276 - * Validates the data on entering the corresponding parse tree node.
277 - *
278 - * @throws DataModelException a violation of data model rules
279 - */
280 - @Override
281 - public void validateDataOnEntry()
282 - throws DataModelException {
283 - // TODO auto-generated method stub, to be implemented by parser
284 - }
285 -
286 - /**
287 - * Validates the data on exiting the corresponding parse tree node.
288 - *
289 - * @throws DataModelException a violation of data model rules
290 - */
291 - @Override
292 - public void validateDataOnExit()
293 - throws DataModelException {
294 - // TODO auto-generated method stub, to be implemented by parser
295 - }
296 -
297 - /*
298 - * Reference RFC6020
299 - *
300 - * Once a grouping is defined, it can be referenced in a "uses"
301 - * statement (see Section 7.12). A grouping MUST NOT reference itself,
302 - * neither directly nor indirectly through a chain of other groupings.
303 - *
304 - * If the grouping is defined at the top level of a YANG module or
305 - * submodule, the grouping's identifier MUST be unique within the
306 - * module.
307 - */
308 - @Override
309 - public void detectCollidingChild(String identifierName, YangConstructType dataType)
310 - throws DataModelException {
311 - // Asks helper to detect colliding child.
312 - detectCollidingChildUtil(identifierName, dataType, this);
313 - }
314 -
315 - @Override
316 - public void detectSelfCollision(String identifierName, YangConstructType dataType)
317 - throws DataModelException {
318 - if (getName().equals(identifierName)) {
319 - throw new DataModelException("YANG file error: Duplicate input identifier detected, same as grouping \"" +
320 - getName() + "\"");
321 - }
322 - }
323 - // TODO A grouping MUST NOT reference itself, neither directly nor indirectly through a chain of other groupings.
324 -}
1 -/*
2 - * Copyright 2016-present 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.datamodel.utils.Parsable;
20 -import org.onosproject.yangutils.datamodel.utils.YangConstructType;
21 -
22 -import java.io.Serializable;
23 -
24 -/*-
25 - * Reference RFC 6020.
26 - *
27 - * The "identity" statement is used to define a new globally unique,
28 - * abstract, and untyped identity. Its only purpose is to denote its
29 - * name, semantics, and existence. An identity can either be defined
30 - * from scratch or derived from a base identity. The identity's
31 - * argument is an identifier that is the name of the identity. It is
32 - * followed by a block of substatements that holds detailed identity
33 - * information.
34 - *
35 - * The identity's Substatements
36 - *
37 - * +--------------+---------+-------------+-----------------------+
38 - * | substatement | section | cardinality | data model mapping |
39 - * +--------------+---------+-------------+-----------------------+
40 - * | base | 7.16.2 | 0..1 | -YangNodeIdentifier |
41 - * | description | 7.19.3 | 0..1 | -string |
42 - * | reference | 7.19.4 | 0..1 | -string |
43 - * | status | 7.19.2 | 0..1 | -YangStatus |
44 - * +--------------+---------+-------------+-----------------------+
45 - */
46 -
47 -/**
48 - * Represents data model node to maintain information defined in YANG identity.
49 - */
50 -public class YangIdentity extends YangNode implements YangCommonInfo, Parsable, Serializable {
51 -
52 - private static final long serialVersionUID = 806201691L;
53 -
54 - //Name of the identity.
55 - private String name;
56 -
57 - //Base node of identity.
58 - private YangBase baseNode;
59 -
60 - //Status of YANG identity.
61 - private YangStatusType status;
62 -
63 - //Description of YANG identity.
64 - private String description;
65 -
66 - //YANG reference of the identity.
67 - private String reference;
68 -
69 - //Creates a identity type of node.
70 - public YangIdentity() {
71 - super(YangNodeType.IDENTITY_NODE);
72 - }
73 -
74 - /**
75 - * Returns the name of identity.
76 - *
77 - * @return the identity name
78 - */
79 - public String getName() {
80 - return name;
81 - }
82 -
83 - /**
84 - * Sets the name of identity.
85 - *
86 - * @param name the identity name to set
87 - */
88 - public void setName(String name) {
89 - this.name = name;
90 - }
91 -
92 - @Override
93 - public YangStatusType getStatus() {
94 - return status;
95 - }
96 -
97 - @Override
98 - public void setStatus(YangStatusType status) {
99 - this.status = status;
100 - }
101 -
102 - @Override
103 - public String getDescription() {
104 - return description;
105 - }
106 -
107 - @Override
108 - public void setDescription(String description) {
109 - this.description = description;
110 - }
111 -
112 - @Override
113 - public String getReference() {
114 - return reference;
115 - }
116 -
117 - @Override
118 - public void setReference(String reference) {
119 - this.reference = reference;
120 - }
121 -
122 - @Override
123 - public YangConstructType getYangConstructType() {
124 - return YangConstructType.IDENTITY_DATA;
125 - }
126 -
127 - @Override
128 - public void validateDataOnEntry() throws DataModelException {
129 - }
130 -
131 - @Override
132 - public void validateDataOnExit() throws DataModelException {
133 - }
134 -
135 - /**
136 - * Returns base node of identity.
137 - *
138 - * @return the base node of identity
139 - */
140 - public YangBase getBaseNode() {
141 - return baseNode;
142 - }
143 -
144 - /**
145 - * Sets the base node.
146 - *
147 - * @param baseNode the base node to set
148 - */
149 - public void setBaseNode(YangBase baseNode) {
150 - this.baseNode = baseNode;
151 - }
152 -}
1 -/*
2 - * Copyright 2016-present 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.datamodel.utils.Parsable;
20 -import org.onosproject.yangutils.datamodel.utils.ResolvableStatus;
21 -import org.onosproject.yangutils.datamodel.utils.YangConstructType;
22 -
23 -import java.io.Serializable;
24 -
25 -/*-
26 - * Reference RFC 6020.
27 - *
28 - * The identityref type is used to reference an existing identity.
29 - *
30 - * The identityref's base Statement :
31 - * The "base" statement, which is a substatement to the "type"
32 - * statement, MUST be present if the type is "identityref". The
33 - * argument is the name of an identity, as defined by an "identity"
34 - * statement. If a prefix is present on the identity name, it refers to
35 - * an identity defined in the module that was imported with that prefix.
36 - * Otherwise, an identity with the matching name MUST be defined in the
37 - * current module or an included submodule.
38 - * Valid values for an identityref are any identities derived from the
39 - * identityref's base identity. On a particular server, the valid
40 - * values are further restricted to the set of identities defined in the
41 - * modules supported by the server.
42 - */
43 -
44 -/**
45 - * Represents data model node to maintain information defined in YANG identityref.
46 - */
47 -public class YangIdentityRef extends YangNode implements Parsable, Resolvable, Serializable {
48 -
49 - private static final long serialVersionUID = 806201692L;
50 -
51 - // Get referred identity parent information.
52 - private YangIdentity referredIdentity;
53 -
54 - // YANG node identifier.
55 - private YangNodeIdentifier baseIdentity;
56 -
57 - /**
58 - * Status of resolution. If completely resolved enum value is "RESOLVED",
59 - * if not enum value is "UNRESOLVED", in case reference of grouping/typedef/identityref/base
60 - * is added to uses/type/identityref/base but it's not resolved value of enum should be
61 - * "INTRA_FILE_RESOLVED".
62 - */
63 - private ResolvableStatus resolvableStatus;
64 -
65 - // Creates a specific identityref of node.
66 - public YangIdentityRef() {
67 - super(YangNodeType.IDENTITYREF_NODE);
68 - baseIdentity = new YangNodeIdentifier();
69 - resolvableStatus = ResolvableStatus.UNRESOLVED;
70 - }
71 -
72 - @Override
73 - public ResolvableStatus getResolvableStatus() {
74 - return resolvableStatus;
75 - }
76 -
77 - @Override
78 - public void setResolvableStatus(ResolvableStatus resolvableStatus) {
79 - this.resolvableStatus = resolvableStatus;
80 - }
81 -
82 - @Override
83 - public Object resolve() throws DataModelException {
84 -
85 - // Check if the derived info is present.
86 - YangIdentity identity = getReferredIdentity();
87 -
88 - if (identity == null) {
89 - throw new DataModelException("Linker Error: Identity information is missing.");
90 - }
91 -
92 - while (identity.getBaseNode() != null) {
93 - if (identity.getBaseNode().getResolvableStatus() != ResolvableStatus.RESOLVED) {
94 - setResolvableStatus(ResolvableStatus.INTRA_FILE_RESOLVED);
95 - return null;
96 - }
97 - identity = identity.getBaseNode().getReferredIdentity();
98 - }
99 - return null;
100 - }
101 -
102 - /**
103 - * Returns the YANG base node identifier.
104 - *
105 - * @return the YANG base node identifier
106 - */
107 - public YangNodeIdentifier getBaseIdentity() {
108 - return baseIdentity;
109 - }
110 -
111 - /**
112 - * Sets the YANG node identifier.
113 - *
114 - * @param baseIdentity the YANG node identifier to set
115 - */
116 - public void setBaseIdentity(YangNodeIdentifier baseIdentity) {
117 - this.baseIdentity = baseIdentity;
118 - }
119 -
120 - /**
121 - * Returns the name of identity.
122 - *
123 - * @return the identity name
124 - */
125 - @Override
126 - public String getName() {
127 - return baseIdentity.getName();
128 - }
129 -
130 - /**
131 - * Sets the name of identity.
132 - *
133 - * @param name the identity name to set
134 - */
135 - @Override
136 - public void setName(String name) {
137 - baseIdentity.setName(name);
138 - }
139 -
140 - /**
141 - * Sets node identifier.
142 - *
143 - * @param nodeIdentifier the node identifier
144 - */
145 - public void setNodeIdentifier(YangNodeIdentifier nodeIdentifier) {
146 - this.baseIdentity = nodeIdentifier;
147 - }
148 -
149 - /**
150 - * Returns prefix associated with base.
151 - *
152 - * @return prefix associated with base
153 - */
154 - public String getPrefix() {
155 - return baseIdentity.getPrefix();
156 - }
157 -
158 - /**
159 - * Sets prefix associated with base.
160 - *
161 - * @param prefix prefix associated with base
162 - */
163 - public void setPrefix(String prefix) {
164 - baseIdentity.setPrefix(prefix);
165 - }
166 -
167 - @Override
168 - public YangConstructType getYangConstructType() {
169 - return YangConstructType.IDENTITYREF_DATA;
170 - }
171 -
172 - @Override
173 - public void validateDataOnEntry() throws DataModelException {
174 - }
175 -
176 - @Override
177 - public void validateDataOnExit() throws DataModelException {
178 - }
179 -
180 - /**
181 - * Returns the parent identity node.
182 - *
183 - * @return the parent identity node
184 - */
185 - public YangIdentity getReferredIdentity() {
186 - return referredIdentity;
187 - }
188 -
189 - /**
190 - * Sets the parent identity node.
191 - *
192 - * @param referredIdentity the parent identity node to set
193 - */
194 - public void setReferredIdentity(YangIdentity referredIdentity) {
195 - this.referredIdentity = referredIdentity;
196 - }
197 -}
1 -/*
2 - * Copyright 2016-present 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 java.io.Serializable;
20 -import java.util.Iterator;
21 -import java.util.List;
22 -import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
23 -import org.onosproject.yangutils.datamodel.utils.Parsable;
24 -import org.onosproject.yangutils.datamodel.utils.ResolvableStatus;
25 -import org.onosproject.yangutils.datamodel.utils.YangConstructType;
26 -
27 -/*
28 - * Reference RFC 6020.
29 - *
30 - * The "if-feature" statement makes its parent statement conditional.
31 - * The argument is the name of a feature, as defined by a "feature"
32 - * statement. The parent statement is implemented by servers that
33 - * support this feature. If a prefix is present on the feature name, it
34 - * refers to a feature defined in the module that was imported with that
35 - * prefix, or the local module if the prefix matches the local module's
36 - * prefix. Otherwise, a feature with the matching name MUST be defined
37 - * in the current module or an included submodule.
38 - *
39 - * Since submodules cannot include the parent module, any features in
40 - * the module that need to be exposed to submodules MUST be defined in a
41 - * submodule. Submodules can then include this submodule to find the
42 - * definition of the feature.
43 - */
44 -
45 -/**
46 - * Represents data model node to maintain information defined in YANG if-feature.
47 - */
48 -public class YangIfFeature implements Parsable, Resolvable, Serializable {
49 -
50 - private static final long serialVersionUID = 806201635L;
51 -
52 - /**
53 - * if-feature argument.
54 - */
55 - YangNodeIdentifier name;
56 -
57 - /**
58 - * Referred feature information.
59 - */
60 - YangFeature referredFeature;
61 -
62 - /**
63 - * Referred feature parent information.
64 - */
65 - YangNode referredFeatureHolder;
66 -
67 - /**
68 - * Status of resolution. If completely resolved enum value is "RESOLVED",
69 - * if not enum value is "UNRESOLVED", in case reference of grouping/typedef
70 - * is added to uses/type but it's not resolved value of enum should be
71 - * "INTRA_FILE_RESOLVED".
72 - */
73 - private ResolvableStatus resolvableStatus;
74 -
75 - /**
76 - * Returns referred feature holder.
77 - *
78 - * @return referred feature holder
79 - */
80 - public YangNode getReferredFeatureHolder() {
81 - return referredFeatureHolder;
82 - }
83 -
84 - /**
85 - * Sets the referred feature holder.
86 - *
87 - * @param referredFeatureHolder referred feature holder
88 - */
89 - public void setReferredFeatureHolder(YangNode referredFeatureHolder) {
90 - this.referredFeatureHolder = referredFeatureHolder;
91 - }
92 -
93 - /**
94 - * Returns prefix associated with identifier.
95 - *
96 - * @return prefix associated with identifier
97 - */
98 - public String getPrefix() {
99 - return name.getPrefix();
100 - }
101 -
102 - /**
103 - * Sets prefix associated with identifier.
104 - *
105 - * @param prefix prefix associated with identifier
106 - */
107 - public void setPrefix(String prefix) {
108 - name.setPrefix(prefix);
109 - }
110 -
111 - /**
112 - * Returns referred feature associated with if-feature.
113 - *
114 - * @return referred feature associated with if-feature
115 - */
116 - public YangFeature getReferredFeature() {
117 - return referredFeature;
118 - }
119 -
120 - /**
121 - * Sets referred feature associated with if-feature.
122 - *
123 - * @param referredFeature referred feature associated with if-feature
124 - */
125 - public void setReferredFeature(YangFeature referredFeature) {
126 - this.referredFeature = referredFeature;
127 - }
128 -
129 - /**
130 - * Returns the YANG name of if-feature.
131 - *
132 - * @return the name of if-feature as defined in YANG file
133 - */
134 - public YangNodeIdentifier getName() {
135 - return name;
136 - }
137 -
138 - /**
139 - * Sets the YANG name of if-feature.
140 - *
141 - * @param name the name of if-feature as defined in YANG file
142 - */
143 - public void setName(YangNodeIdentifier name) {
144 - this.name = name;
145 - }
146 -
147 - @Override
148 - public YangConstructType getYangConstructType() {
149 - return YangConstructType.IF_FEATURE_DATA;
150 - }
151 -
152 - @Override
153 - public void validateDataOnEntry() throws DataModelException {
154 - // do nothing, no validation required for if-feature
155 - }
156 -
157 - @Override
158 - public void validateDataOnExit() throws DataModelException {
159 - // do nothing, no validation required for if-feature
160 - }
161 -
162 - @Override
163 - public ResolvableStatus getResolvableStatus() {
164 - return resolvableStatus;
165 - }
166 -
167 - @Override
168 - public void setResolvableStatus(ResolvableStatus resolvableStatus) {
169 - this.resolvableStatus = resolvableStatus;
170 - }
171 -
172 - @Override
173 - public Object resolve() throws DataModelException {
174 - YangFeature feature = getReferredFeature();
175 -
176 - // check whether feature has if-feature
177 - List<YangIfFeature> ifFeatureList = feature.getIfFeatureList();
178 - if (ifFeatureList != null && !ifFeatureList.isEmpty()) {
179 - Iterator<YangIfFeature> ifFeatureIterator = ifFeatureList.iterator();
180 - while (ifFeatureIterator.hasNext()) {
181 - YangIfFeature ifFeature = ifFeatureIterator.next();
182 - if (ifFeature.getResolvableStatus() != ResolvableStatus.RESOLVED) {
183 - setResolvableStatus(ResolvableStatus.INTRA_FILE_RESOLVED);
184 - return null;
185 - }
186 - }
187 - }
188 - return null;
189 - }
190 -}
1 -/*Copyright 2016.year Open Networking Laboratory
2 -
3 -Licensed under the Apache License, Version 2.0 (the "License");
4 -you may not use this file except in compliance with the License.
5 -You may obtain a copy of the License at
6 -
7 - http://www.apache.org/licenses/LICENSE-2.0
8 -
9 -Unless required by applicable law or agreed to in writing, software
10 -distributed under the License is distributed on an "AS IS" BASIS,
11 -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 -See the License for the specific language governing permissions and
13 -limitations under the License.*/
14 -
15 -package org.onosproject.yangutils.datamodel;
16 -
17 -import java.util.List;
18 -
19 -/**
20 - * Abstraction of if-feature entity. It is used to abstract the data holders of if-feature.
21 - */
22 -public interface YangIfFeatureHolder {
23 -
24 - /**
25 - * Returns the list of if-feature from data holder like container / list.
26 - *
27 - * @return the list of if-feature
28 - */
29 - List<YangIfFeature> getIfFeatureList();
30 -
31 - /**
32 - * Adds if-feature in if-feature list.
33 - *
34 - * @param ifFeature the if-feature to be added
35 - */
36 - void addIfFeatureList(YangIfFeature ifFeature);
37 -
38 - /**
39 - * Sets the list of if-feature.
40 - *
41 - * @param ifFeatureList the list of if-feature to set
42 - */
43 - void setIfFeatureList(List<YangIfFeature> ifFeatureList);
44 -}
1 -/*
2 - * Copyright 2016-present 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 java.io.Serializable;
19 -import java.util.Date;
20 -import java.util.Set;
21 -
22 -import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
23 -import org.onosproject.yangutils.datamodel.utils.Parsable;
24 -import org.onosproject.yangutils.datamodel.utils.YangConstructType;
25 -
26 -import static org.onosproject.yangutils.datamodel.utils.DataModelUtils.findReferredNode;
27 -
28 -/*
29 - * Reference:RFC 6020.
30 - * The "import" statement makes definitions from one module available
31 - * inside another module or submodule. The argument is the name of the
32 - * module to import, and the statement is followed by a block of
33 - * sub statements that holds detailed import information.
34 - * When a module is imported, the importing module may:
35 - * o use any grouping and typedef defined at the top level in the
36 - * imported module or its submodules.
37 - *
38 - * o use any extension, feature, and identity defined in the imported
39 - * module or its submodules.
40 - *
41 - * o use any node in the imported module's schema tree in "must",
42 - * "path", and "when" statements, or as the target node in "augment"
43 - * and "deviation" statements.
44 - *
45 - * The mandatory "prefix" sub statement assigns a prefix for the imported
46 - * module that is scoped to the importing module or submodule. Multiple
47 - * "import" statements may be specified to import from different
48 - * modules.
49 - * When the optional "revision-date" sub-statement is present, any
50 - * typedef, grouping, extension, feature, and identity referenced by
51 - * definitions in the local module are taken from the specified revision
52 - * of the imported module. It is an error if the specified revision of
53 - * the imported module does not exist. If no "revision-date"
54 - * sub-statement is present, it is undefined from which revision of the
55 - * module they are taken.
56 - *
57 - * Multiple revisions of the same module MUST NOT be imported.
58 - *
59 - * The import's Substatements
60 - *
61 - * +---------------+---------+-------------+------------------+
62 - * | substatement | section | cardinality |data model mapping|
63 - * +---------------+---------+-------------+------------------+
64 - * | prefix | 7.1.4 | 1 | string |
65 - * | revision-date | 7.1.5.1 | 0..1 | Date |
66 - * +---------------+---------+-------------+------------------+
67 - */
68 -
69 -/**
70 - * Represents the information about the imported modules.
71 - */
72 -public class YangImport
73 - implements Parsable, LocationInfo, Serializable {
74 -
75 - private static final long serialVersionUID = 806201642L;
76 -
77 - /**
78 - * Name of the module that is being imported.
79 - */
80 - private String name;
81 -
82 - /**
83 - * Prefix used to identify the entities from the imported module.
84 - */
85 - private String prefixId;
86 -
87 - /**
88 - * Reference:RFC 6020.
89 - * <p>
90 - * The import's "revision-date" statement is used to specify the exact
91 - * version of the module to import. The "revision-date" statement MUST match
92 - * the most recent "revision" statement in the imported module. organization
93 - * which defined the YANG module.
94 - */
95 - private Date revision;
96 -
97 - /**
98 - * Reference to node which is imported.
99 - */
100 - private YangNode importedNode;
101 -
102 - // Error Line number.
103 - private transient int lineNumber;
104 -
105 - // Error character position.
106 - private transient int charPosition;
107 -
108 - /**
109 - * Creates a YANG import.
110 - */
111 - public YangImport() {
112 - }
113 -
114 - /**
115 - * Returns the imported module name.
116 - *
117 - * @return the module name
118 - */
119 - public String getModuleName() {
120 - return name;
121 - }
122 -
123 - /**
124 - * Sets module name.
125 - *
126 - * @param moduleName the module name to set
127 - */
128 - public void setModuleName(String moduleName) {
129 - name = moduleName;
130 - }
131 -
132 - /**
133 - * Returns the prefix used to identify the entities from the imported module.
134 - *
135 - * @return the prefix used to identify the entities from the imported
136 - * module
137 - */
138 - public String getPrefixId() {
139 - return prefixId;
140 - }
141 -
142 - /**
143 - * Sets prefix identifier.
144 - *
145 - * @param prefixId set the prefix identifier of the imported module
146 - */
147 - public void setPrefixId(String prefixId) {
148 - this.prefixId = prefixId;
149 - }
150 -
151 - /**
152 - * Returns the revision of the imported module.
153 - *
154 - * @return the revision of the imported module
155 - */
156 - public Date getRevision() {
157 - return revision;
158 - }
159 -
160 - /**
161 - * Sets the revision of the imported module.
162 - *
163 - * @param rev set the revision of the imported module
164 - */
165 - public void setRevision(Date rev) {
166 - revision = rev;
167 - }
168 -
169 - /**
170 - * Returns the type of the parsed data.
171 - *
172 - * @return returns IMPORT_DATA
173 - */
174 - @Override
175 - public YangConstructType getYangConstructType() {
176 - return YangConstructType.IMPORT_DATA;
177 - }
178 -
179 - /**
180 - * Validates the data on entering the corresponding parse tree node.
181 - *
182 - * @throws DataModelException a violation of data model rules
183 - */
184 - @Override
185 - public void validateDataOnEntry()
186 - throws DataModelException {
187 - // TODO auto-generated method stub, to be implemented by parser
188 -
189 - }
190 -
191 - /**
192 - * Validates the data on exiting the corresponding parse tree node.
193 - *
194 - * @throws DataModelException a violation of data model rules
195 - */
196 - @Override
197 - public void validateDataOnExit()
198 - throws DataModelException {
199 - // TODO auto-generated method stub, to be implemented by parser
200 -
201 - }
202 -
203 - /**
204 - * Returns imported node.
205 - *
206 - * @return imported node
207 - */
208 - public YangNode getImportedNode() {
209 - return importedNode;
210 - }
211 -
212 - /**
213 - * Sets imported node.
214 - *
215 - * @param importedNode imported node
216 - */
217 - public void setImportedNode(YangNode importedNode) {
218 - this.importedNode = importedNode;
219 - }
220 -
221 - @Override
222 - public int getLineNumber() {
223 - return lineNumber;
224 - }
225 -
226 - @Override
227 - public int getCharPosition() {
228 - return charPosition;
229 - }
230 -
231 - @Override
232 - public void setLineNumber(int lineNumber) {
233 - this.lineNumber = lineNumber;
234 - }
235 -
236 - @Override
237 - public void setCharPosition(int charPositionInLine) {
238 - charPosition = charPositionInLine;
239 - }
240 -
241 - /**
242 - * Adds reference to an import.
243 - *
244 - * @param yangNodeSet YANG file info set
245 - * @throws DataModelException a violation of data model rules
246 - */
247 - public void addReferenceToImport(Set<YangNode> yangNodeSet) throws DataModelException {
248 - String importedModuleName = getModuleName();
249 - Date importedModuleRevision = getRevision();
250 - YangNode moduleNode = null;
251 - /*
252 - * Find the imported module node for a given module name with a
253 - * specified revision if revision is not null.
254 - */
255 - if (importedModuleRevision != null) {
256 - String importedModuleNameWithRevision = importedModuleName + "@" + importedModuleRevision;
257 - moduleNode = findReferredNode(yangNodeSet, importedModuleNameWithRevision);
258 - }
259 -
260 - /*
261 - * Find the imported module node for a given module name without
262 - * revision if can't find with revision.
263 - */
264 - if (moduleNode == null) {
265 - moduleNode = findReferredNode(yangNodeSet, importedModuleName);
266 - }
267 -
268 - if (moduleNode != null) {
269 - if (moduleNode instanceof YangModule) {
270 - if (getRevision() == null) {
271 - setImportedNode(moduleNode);
272 - return;
273 - }
274 - // Match revision if import is with revision.
275 - if (((YangModule) moduleNode).getRevision().getRevDate().equals(importedModuleRevision)) {
276 - setImportedNode(moduleNode);
277 - return;
278 - }
279 - }
280 - }
281 -
282 - // Exception if there is no match.
283 - DataModelException exception = new DataModelException("YANG file error : Imported module "
284 - + importedModuleName + " with revision " + importedModuleRevision + " is not found.");
285 - exception.setLine(getLineNumber());
286 - exception.setCharPosition(getCharPosition());
287 - throw exception;
288 - }
289 -}
1 -/*
2 - * Copyright 2016-present 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 java.io.Serializable;
19 -import java.util.Date;
20 -import java.util.Set;
21 -
22 -import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
23 -import org.onosproject.yangutils.datamodel.utils.Parsable;
24 -import org.onosproject.yangutils.datamodel.utils.YangConstructType;
25 -
26 -import static org.onosproject.yangutils.datamodel.utils.DataModelUtils.findReferredNode;
27 -
28 -/*
29 - * Reference:RFC 6020.
30 - * The "include" statement is used to make content from a submodule
31 - * available to that submodule's parent module, or to another submodule
32 - * of that parent module. The argument is an identifier that is the
33 - * name of the submodule to include.
34 - * The includes's Substatements
35 - *
36 - * +---------------+---------+-------------+------------------+
37 - * | substatement | section | cardinality |data model mapping|
38 - * +---------------+---------+-------------+------------------+
39 - * | revision-date | 7.1.5.1 | 0..1 | string |
40 - * +---------------+---------+-------------+------------------+
41 - */
42 -
43 -/**
44 - * Represents the information about the included sub-modules.
45 - */
46 -public class YangInclude
47 - implements Parsable, LocationInfo, Serializable {
48 -
49 - private static final long serialVersionUID = 806201644L;
50 -
51 - /**
52 - * Name of the sub-module that is being included.
53 - */
54 - private String subModuleName;
55 -
56 - /**
57 - * The include's "revision-date" statement is used to specify the exact
58 - * version of the submodule to import.
59 - */
60 - private Date revision;
61 -
62 - /**
63 - * Reference to node which is included.
64 - */
65 - private YangNode includedNode;
66 -
67 - // Error Line number.
68 - private transient int lineNumber;
69 -
70 - // Error character position.
71 - private transient int charPosition;
72 -
73 - /**
74 - * Creates a YANG include.
75 - */
76 - public YangInclude() {
77 - }
78 -
79 - /**
80 - * Returns the name of included sub-module.
81 - *
82 - * @return the sub-module name
83 - */
84 - public String getSubModuleName() {
85 - return subModuleName;
86 - }
87 -
88 - /**
89 - * Sets the name of included sub-modules.
90 - *
91 - * @param subModuleName the sub-module name to set
92 - */
93 - public void setSubModuleName(String subModuleName) {
94 - this.subModuleName = subModuleName;
95 - }
96 -
97 - /**
98 - * Returns the revision.
99 - *
100 - * @return the revision
101 - */
102 - public Date getRevision() {
103 - return revision;
104 - }
105 -
106 - /**
107 - * Sets the revision.
108 - *
109 - * @param revision the revision to set
110 - */
111 - public void setRevision(Date revision) {
112 - this.revision = revision;
113 - }
114 -
115 - /**
116 - * Returns the type of parsed data.
117 - *
118 - * @return returns INCLUDE_DATA
119 - */
120 - @Override
121 - public YangConstructType getYangConstructType() {
122 - return YangConstructType.INCLUDE_DATA;
123 - }
124 -
125 - /**
126 - * Validates the data on entering the corresponding parse tree node.
127 - *
128 - * @throws DataModelException a violation of data model rules
129 - */
130 - @Override
131 - public void validateDataOnEntry()
132 - throws DataModelException {
133 - // TODO auto-generated method stub, to be implemented by parser
134 -
135 - }
136 -
137 - /**
138 - * Validates the data on exiting the corresponding parse tree node.
139 - *
140 - * @throws DataModelException a violation of data model rules
141 - */
142 - @Override
143 - public void validateDataOnExit()
144 - throws DataModelException {
145 - // TODO auto-generated method stub, to be implemented by parser
146 -
147 - }
148 -
149 - public YangNode getIncludedNode() {
150 - return includedNode;
151 - }
152 -
153 - public void setIncludedNode(YangNode includedNode) {
154 - this.includedNode = includedNode;
155 - }
156 -
157 - @Override
158 - public int getLineNumber() {
159 - return lineNumber;
160 - }
161 -
162 - @Override
163 - public int getCharPosition() {
164 - return charPosition;
165 - }
166 -
167 - @Override
168 - public void setLineNumber(int lineNumber) {
169 - this.lineNumber = lineNumber;
170 - }
171 -
172 - @Override
173 - public void setCharPosition(int charPositionInLine) {
174 - charPosition = charPositionInLine;
175 - }
176 -
177 - /**
178 - * Adds reference to an include.
179 - *
180 - * @param yangNodeSet YANG node set
181 - * @return YANG sub module node
182 - * @throws DataModelException a violation of data model rules
183 - */
184 - public YangSubModule addReferenceToInclude(Set<YangNode> yangNodeSet) throws DataModelException {
185 - String includedSubModuleName = getSubModuleName();
186 - Date includedSubModuleRevision = getRevision();
187 - YangNode subModuleNode = null;
188 -
189 - /*
190 - * Find the included sub-module node for a given module name with a
191 - * specified revision if revision is not null.
192 - */
193 - if (includedSubModuleRevision != null) {
194 - String includedSubModuleNameWithRevision = includedSubModuleName + "@" + includedSubModuleRevision;
195 - subModuleNode = findReferredNode(yangNodeSet, includedSubModuleNameWithRevision);
196 - }
197 -
198 - /*
199 - * Find the imported sub module node for a given module name without
200 - * revision if can't find with revision.
201 - */
202 - if (subModuleNode == null) {
203 - subModuleNode = findReferredNode(yangNodeSet, includedSubModuleName);
204 - }
205 -
206 - if (subModuleNode != null) {
207 - if (subModuleNode instanceof YangSubModule) {
208 - if (getRevision() == null) {
209 - setIncludedNode(subModuleNode);
210 - return (YangSubModule) subModuleNode;
211 - }
212 - // Match revision if inclusion is with revision.
213 - if (((YangSubModule) subModuleNode).getRevision().getRevDate().equals(includedSubModuleRevision)) {
214 - setIncludedNode(subModuleNode);
215 - return (YangSubModule) subModuleNode;
216 - }
217 - }
218 - }
219 - // Exception if there is no match.
220 - DataModelException exception = new DataModelException("YANG file error : Included sub module " +
221 - includedSubModuleName + "with a given revision is not found.");
222 - exception.setLine(getLineNumber());
223 - exception.setCharPosition(getCharPosition());
224 - throw exception;
225 - }
226 -
227 - /**
228 - * Reports an error when included sub-module doesn't meet condition that
229 - * "included sub-modules should belong module, as defined by the
230 - * "belongs-to" statement or sub-modules are only allowed to include other
231 - * sub-modules belonging to the same module.
232 - *
233 - * @throws DataModelException a violation in data model rule
234 - */
235 - public void reportIncludeError() throws DataModelException {
236 - DataModelException exception = new DataModelException("YANG file error : Included sub-module " +
237 - getSubModuleName() + "doesn't belongs to parent module also it doesn't belongs" +
238 - "to sub-module belonging to the same parent module.");
239 - exception.setLine(getLineNumber());
240 - exception.setCharPosition(getCharPosition());
241 - throw exception;
242 - }
243 -}
1 -/*
2 - * Copyright 2016-present 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 java.util.ArrayList;
20 -import java.util.LinkedList;
21 -import java.util.List;
22 -
23 -import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
24 -import org.onosproject.yangutils.datamodel.utils.Parsable;
25 -import org.onosproject.yangutils.datamodel.utils.YangConstructType;
26 -
27 -import static org.onosproject.yangutils.datamodel.utils.DataModelUtils.detectCollidingChildUtil;
28 -
29 -/*
30 - * Reference RFC 6020.
31 - *
32 - * The "input" statement, which is optional, is used to define input
33 - * parameters to the RPC operation. It does not take an argument. The
34 - * substatements to "input" define nodes under the RPC's input node.
35 - *
36 - * If a leaf in the input tree has a "mandatory" statement with the
37 - * value "true", the leaf MUST be present in a NETCONF RPC invocation.
38 - * Otherwise, the server MUST return a "missing-element" error.
39 - *
40 - * If a leaf in the input tree has a default value, the NETCONF server
41 - * MUST use this value in the same cases as described in Section 7.6.1.
42 - * In these cases, the server MUST operationally behave as if the leaf
43 - * was present in the NETCONF RPC invocation with the default value as
44 - * its value.
45 - *
46 - * If a "config" statement is present for any node in the input tree,
47 - * the "config" statement is ignored.
48 - *
49 - * If any node has a "when" statement that would evaluate to false, then
50 - * this node MUST NOT be present in the input tree.
51 - *
52 - * The input substatements
53 - *
54 - * +--------------+---------+-------------+------------------+
55 - * | substatement | section | cardinality |data model mapping|
56 - * +--------------+---------+-------------+------------------+
57 - * | anyxml | 7.10 | 0..n | -not supported |
58 - * | choice | 7.9 | 0..n | -child nodes |
59 - * | container | 7.5 | 0..n | -child nodes |
60 - * | grouping | 7.11 | 0..n | -child nodes |
61 - * | leaf | 7.6 | 0..n | -YangLeaf |
62 - * | leaf-list | 7.7 | 0..n | -YangLeafList |
63 - * | list | 7.8 | 0..n | -child nodes |
64 - * | typedef | 7.3 | 0..n | -child nodes |
65 - * | uses | 7.12 | 0..n | -child nodes |
66 - * +--------------+---------+-------------+------------------+
67 - */
68 -
69 -/**
70 - * Represents data model node to maintain information defined in YANG input.
71 - */
72 -public class YangInput
73 - extends YangNode
74 - implements YangLeavesHolder, Parsable, CollisionDetector, YangAugmentableNode, YangIsFilterContentNodes {
75 -
76 - private static final long serialVersionUID = 806201608L;
77 -
78 - /**
79 - * Name of the input.
80 - */
81 - private String name;
82 -
83 - /**
84 - * List of leaves contained.
85 - */
86 - private List<YangLeaf> listOfLeaf;
87 -
88 - /**
89 - * List of leaf-lists contained.
90 - */
91 - private List<YangLeafList> listOfLeafList;
92 -
93 - private List<YangAugmentedInfo> yangAugmentedInfo = new ArrayList<>();
94 -
95 - /**
96 - * Create a rpc input node.
97 - */
98 - public YangInput() {
99 - super(YangNodeType.INPUT_NODE);
100 - listOfLeaf = new LinkedList<>();
101 - listOfLeafList = new LinkedList<>();
102 - }
103 -
104 - @Override
105 - public void detectCollidingChild(String identifierName, YangConstructType dataType)
106 - throws DataModelException {
107 - // Detect colliding child.
108 - detectCollidingChildUtil(identifierName, dataType, this);
109 - }
110 -
111 - @Override
112 - public void detectSelfCollision(String identifierName, YangConstructType dataType)
113 - throws DataModelException {
114 - if (getName().equals(identifierName)) {
115 - throw new DataModelException("YANG file error: Duplicate input identifier detected, same as input \""
116 - + getName() + "\"");
117 - }
118 - }
119 -
120 - @Override
121 - public YangConstructType getYangConstructType() {
122 - return YangConstructType.INPUT_DATA;
123 - }
124 -
125 - @Override
126 - public void validateDataOnEntry()
127 - throws DataModelException {
128 - //TODO: implement the method.
129 - }
130 -
131 - @Override
132 - public void validateDataOnExit()
133 - throws DataModelException {
134 - //TODO: implement the method.
135 - }
136 -
137 - @Override
138 - public List<YangLeaf> getListOfLeaf() {
139 - return listOfLeaf;
140 - }
141 -
142 - @Override
143 - public void setListOfLeaf(List<YangLeaf> leafsList) {
144 - listOfLeaf = leafsList;
145 - }
146 -
147 - @Override
148 - public void addLeaf(YangLeaf leaf) {
149 - getListOfLeaf().add(leaf);
150 - }
151 -
152 - @Override
153 - public List<YangLeafList> getListOfLeafList() {
154 - return listOfLeafList;
155 - }
156 -
157 - @Override
158 - public void setListOfLeafList(List<YangLeafList> listOfLeafList) {
159 - this.listOfLeafList = listOfLeafList;
160 - }
161 -
162 - @Override
163 - public void addLeafList(YangLeafList leafList) {
164 - getListOfLeafList().add(leafList);
165 - }
166 -
167 - @Override
168 - public String getName() {
169 - return name;
170 - }
171 -
172 - @Override
173 - public void setName(String name) {
174 - this.name = name;
175 - }
176 -
177 - @Override
178 - public void addAugmentation(YangAugmentedInfo augmentInfo) {
179 - yangAugmentedInfo.add(augmentInfo);
180 - }
181 -
182 - @Override
183 - public void removeAugmentation(YangAugmentedInfo augmentInfo) {
184 - yangAugmentedInfo.remove(augmentInfo);
185 - }
186 -
187 - @Override
188 - public List<YangAugmentedInfo> getAugmentedInfoList() {
189 - return yangAugmentedInfo;
190 - }
191 -}
1 -/*
2 - * Copyright 2016-present 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 - * Represent the YANG nodes which can contain is filter content match.
21 - */
22 -public interface YangIsFilterContentNodes {
23 -}
1 -/*
2 - * Copyright 2016-present 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 java.io.Serializable;
20 -import java.util.LinkedList;
21 -import java.util.List;
22 -import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
23 -import org.onosproject.yangutils.datamodel.utils.Parsable;
24 -import org.onosproject.yangutils.datamodel.utils.YangConstructType;
25 -
26 -/*
27 - * Reference:RFC 6020.
28 - * The "leaf" statement is used to define a leaf node in the schema
29 - * tree. It takes one argument, which is an identifier, followed by a
30 - * block of sub-statements that holds detailed leaf information.
31 - *
32 - * A leaf node has a value, but no child nodes in the data tree.
33 - * Conceptually, the value in the data tree is always in the canonical
34 - * form.
35 - *
36 - * A leaf node exists in zero or one instances in the data tree.
37 - *
38 - * The "leaf" statement is used to define a scalar variable of a
39 - * particular built-in or derived type.
40 - *
41 - * The leaf's sub-statements
42 - *
43 - * +--------------+---------+-------------+------------------+
44 - * | substatement | section | cardinality |data model mapping|
45 - * +--------------+---------+-------------+------------------+
46 - * | config | 7.19.1 | 0..1 | - boolean |
47 - * | default | 7.6.4 | 0..1 | - string |
48 - * | description | 7.19.3 | 0..1 | - string |
49 - * | if-feature | 7.18.2 | 0..n | - YangIfFeature |
50 - * | mandatory | 7.6.5 | 0..1 | - boolean |
51 - * | must | 7.5.3 | 0..n | - YangMust |
52 - * | reference | 7.19.4 | 0..1 | - string |
53 - * | status | 7.19.2 | 0..1 | - YangStatus |
54 - * | type | 7.6.3 | 1 | - YangType |
55 - * | units | 7.3.3 | 0..1 | - String |
56 - * | when | 7.19.5 | 0..1 | - YangWhen |
57 - * +--------------+---------+-------------+------------------+
58 - */
59 -
60 -/**
61 - * Represents leaf data represented in YANG.
62 - */
63 -public class YangLeaf
64 - implements YangCommonInfo, Parsable, Cloneable, Serializable,
65 - YangMustHolder, YangIfFeatureHolder, YangWhenHolder, YangDataNode {
66 -
67 - private static final long serialVersionUID = 806201635L;
68 -
69 - /**
70 - * Name of leaf.
71 - */
72 - private String name;
73 -
74 - /**
75 - * If the leaf is a config parameter.
76 - */
77 - private Boolean isConfig;
78 -
79 - /**
80 - * description of leaf.
81 - */
82 - private String description;
83 -
84 - /**
85 - * If mandatory leaf.
86 - */
87 - private boolean isMandatory;
88 -
89 - /**
90 - * The textual reference to this leaf.
91 - */
92 - private String reference;
93 -
94 - /**
95 - * Status of leaf in YANG definition.
96 - */
97 - private YangStatusType status = YangStatusType.CURRENT;
98 -
99 - /**
100 - * Textual units info.
101 - */
102 - private String units;
103 -
104 - /**
105 - * Data type of the leaf.
106 - */
107 - private YangType<?> dataType;
108 -
109 - /**
110 - * Default value in string, needs to be converted to the target object,
111 - * based on the type.
112 - */
113 - private String defaultValueInString;
114 -
115 - /**
116 - * When data of the leaf.
117 - */
118 - private YangWhen when;
119 -
120 - /**
121 - * YANG Node in which the leaf is contained.
122 - */
123 - private transient YangLeavesHolder containedIn;
124 -
125 - /**
126 - * List of must statement constraints.
127 - */
128 - private List<YangMust> mustConstraintList;
129 -
130 - /**
131 - * List of if-feature.
132 - */
133 - private List<YangIfFeature> ifFeatureList;
134 -
135 - /**
136 - * Creates a YANG leaf.
137 - */
138 - public YangLeaf() {
139 - }
140 -
141 - /**
142 - * Returns the name of leaf.
143 - *
144 - * @return the leaf name
145 - */
146 - public String getName() {
147 - return name;
148 - }
149 -
150 - /**
151 - * Sets the name of leaf.
152 - *
153 - * @param leafName the leaf name to set
154 - */
155 - public void setLeafName(String leafName) {
156 - name = leafName;
157 - }
158 -
159 - /**
160 - * Returns the config flag.
161 - *
162 - * @return if config flag
163 - */
164 - public Boolean isConfig() {
165 - return isConfig;
166 - }
167 -
168 - /**
169 - * Sets the config flag.
170 - *
171 - * @param isCfg the flag value to set
172 - */
173 - public void setConfig(boolean isCfg) {
174 - isConfig = isCfg;
175 - }
176 -
177 - /**
178 - * Returns the when.
179 - *
180 - * @return the when
181 - */
182 - @Override
183 - public YangWhen getWhen() {
184 - return when;
185 - }
186 -
187 - /**
188 - * Sets the when.
189 - *
190 - * @param when the when to set
191 - */
192 - @Override
193 - public void setWhen(YangWhen when) {
194 - this.when = when;
195 - }
196 -
197 - /**
198 - * Returns the description.
199 - *
200 - * @return the description
201 - */
202 - @Override
203 - public String getDescription() {
204 - return description;
205 - }
206 -
207 - /**
208 - * Sets the description.
209 - *
210 - * @param description set the description
211 - */
212 - @Override
213 - public void setDescription(String description) {
214 - this.description = description;
215 - }
216 -
217 - /**
218 - * Returns if the leaf is mandatory.
219 - *
220 - * @return if leaf is mandatory
221 - */
222 - public boolean isMandatory() {
223 - return isMandatory;
224 - }
225 -
226 - /**
227 - * Sets if the leaf is mandatory.
228 - *
229 - * @param isReq if the leaf is mandatory
230 - */
231 - public void setMandatory(boolean isReq) {
232 - isMandatory = isReq;
233 - }
234 -
235 - /**
236 - * Returns the textual reference.
237 - *
238 - * @return the reference
239 - */
240 - @Override
241 - public String getReference() {
242 - return reference;
243 - }
244 -
245 - /**
246 - * Sets the textual reference.
247 - *
248 - * @param reference the reference to set
249 - */
250 - @Override
251 - public void setReference(String reference) {
252 - this.reference = reference;
253 - }
254 -
255 - /**
256 - * Returns the status.
257 - *
258 - * @return the status
259 - */
260 - @Override
261 - public YangStatusType getStatus() {
262 - return status;
263 - }
264 -
265 - /**
266 - * Sets the status.
267 - *
268 - * @param status the status to set
269 - */
270 - @Override
271 - public void setStatus(YangStatusType status) {
272 - this.status = status;
273 - }
274 -
275 - /**
276 - * Returns the units.
277 - *
278 - * @return the units
279 - */
280 - public String getUnits() {
281 - return units;
282 - }
283 -
284 - /**
285 - * Sets the units.
286 - *
287 - * @param units the units to set
288 - */
289 - public void setUnits(String units) {
290 - this.units = units;
291 - }
292 -
293 - /**
294 - * Returns the default value.
295 - *
296 - * @return the default value
297 - */
298 - public String getDefaultValueInString() {
299 - return defaultValueInString;
300 - }
301 -
302 - /**
303 - * Sets the default value.
304 - *
305 - * @param defaultValueInString the default value
306 - */
307 - public void setDefaultValueInString(String defaultValueInString) {
308 - this.defaultValueInString = defaultValueInString;
309 - }
310 -
311 - /**
312 - * Returns the data type.
313 - *
314 - * @return the data type
315 - */
316 - public YangType<?> getDataType() {
317 - return dataType;
318 - }
319 -
320 - /**
321 - * Sets the data type.
322 - *
323 - * @param dataType the data type to set
324 - */
325 - public void setDataType(YangType<?> dataType) {
326 - this.dataType = dataType;
327 - }
328 -
329 - /**
330 - * Retrieves the YANG node in which the leaf is defined.
331 - *
332 - * @return the YANG node in which the leaf is defined
333 - */
334 - public YangLeavesHolder getContainedIn() {
335 - return containedIn;
336 - }
337 -
338 - /**
339 - * Assigns the YANG node in which the leaf is defined.
340 - *
341 - * @param containedIn the YANG node in which the leaf is defined
342 - */
343 - public void setContainedIn(YangLeavesHolder containedIn) {
344 - this.containedIn = containedIn;
345 - }
346 -
347 - @Override
348 - public YangLeaf clone()
349 - throws CloneNotSupportedException {
350 - return (YangLeaf) super.clone();
351 - }
352 -
353 - /**
354 - * Returns the type of the parsed data.
355 - *
356 - * @return returns LEAF_DATA
357 - */
358 - @Override
359 - public YangConstructType getYangConstructType() {
360 - return YangConstructType.LEAF_DATA;
361 - }
362 -
363 - /**
364 - * Validates the data on entering the corresponding parse tree node.
365 - *
366 - * @throws DataModelException a violation of data model rules
367 - */
368 - @Override
369 - public void validateDataOnEntry()
370 - throws DataModelException {
371 - // TODO auto-generated method stub, to be implemented by parser
372 -
373 - }
374 -
375 - /**
376 - * Validates the data on exiting the corresponding parse tree node.
377 - *
378 - * @throws DataModelException a violation of data model rules
379 - */
380 - @Override
381 - public void validateDataOnExit()
382 - throws DataModelException {
383 - if (defaultValueInString != null && !defaultValueInString.isEmpty() && dataType != null) {
384 - dataType.isValidValue(defaultValueInString);
385 - }
386 - }
387 -
388 - @Override
389 - public List<YangMust> getListOfMust() {
390 - return mustConstraintList;
391 - }
392 -
393 - @Override
394 - public void setListOfMust(List<YangMust> mustConstraintList) {
395 - this.mustConstraintList = mustConstraintList;
396 - }
397 -
398 - @Override
399 - public void addMust(YangMust must) {
400 - if (getListOfMust() == null) {
401 - setListOfMust(new LinkedList<>());
402 - }
403 - getListOfMust().add(must);
404 - }
405 -
406 - @Override
407 - public List<YangIfFeature> getIfFeatureList() {
408 - return ifFeatureList;
409 - }
410 -
411 - @Override
412 - public void addIfFeatureList(YangIfFeature ifFeature) {
413 - if (getIfFeatureList() == null) {
414 - setIfFeatureList(new LinkedList<>());
415 - }
416 - getIfFeatureList().add(ifFeature);
417 - }
418 -
419 - @Override
420 - public void setIfFeatureList(List<YangIfFeature> ifFeatureList) {
421 - this.ifFeatureList = ifFeatureList;
422 - }
423 -}
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.