blob: d158e4cdd5e870eb3e470ff5a8d4c41720c1a9ea [file] [log] [blame]
Vinod Kumar S2ff139c2016-02-16 01:37:16 +05301/*
2 * Copyright 2016 Open Networking Laboratory
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package org.onosproject.yangutils.datamodel;
18
19import java.util.HashSet;
20import java.util.Set;
21
22import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
23import org.onosproject.yangutils.parser.Parsable;
24import org.onosproject.yangutils.parser.ParsableDataType;
25
26/*
27 * Reference RFC 6020.
28 *
29 * The bits built-in type represents a bit set. That is, a bits value
30 * is a set of flags identified by small integer position numbers
31 * starting at 0. Each bit number has an assigned name.
32 */
33
34/**
35 * Maintains the bits data type information.
36 */
37public class YangBits implements Parsable {
38
39 private Set<YangBit> bitSet;
40
41 /**
42 * Create a YANG bits type object.
43 */
44 public YangBits() {
45 setBitSet(new HashSet<YangBit>());
46 }
47
48 /**
49 * Get the bit set.
50 *
51 * @return the bit set
52 */
53 public Set<YangBit> getBitSet() {
54 return bitSet;
55 }
56
57 /**
58 * set the bit set.
59 *
60 * @param bitSet the bit set
61 */
62 private void setBitSet(Set<YangBit> bitSet) {
63 this.bitSet = bitSet;
64 }
65
66 /**
67 * Add bit info.
68 *
69 * @param bitInfo the bit Info to add.
70 */
71 public void addBitInfo(YangBit bitInfo) {
72 getBitSet().add(bitInfo);
73 }
74
75 /**
76 * Returns the type of the data.
77 *
78 * @return ParsedDataType returns BITS_DATA
79 */
80 public ParsableDataType getParsableDataType() {
81 return ParsableDataType.BITS_DATA;
82 }
83
84 /**
85 * Validate the data on entering the corresponding parse tree node.
86 *
87 * @throws DataModelException a violation of data model rules.
88 */
89 public void validateDataOnEntry() throws DataModelException {
90 // TODO auto-generated method stub, to be implemented by parser
91 }
92
93 /**
94 * Validate the data on exiting the corresponding parse tree node.
95 *
96 * @throws DataModelException a violation of data model rules.
97 */
98 public void validateDataOnExit() throws DataModelException {
99 // TODO auto-generated method stub, to be implemented by parser
100 }
101}