- public void leafSetEntryNode(Object value) throws IOException, IllegalArgumentException {
- LOG.debug("Writing a new leaf set entry node");
-
- output.writeByte(NodeTypes.LEAF_SET_ENTRY_NODE);
- writeObject(value);
- }
-
- @Override
- public void startContainerNode(YangInstanceIdentifier.NodeIdentifier name, int childSizeHint) throws IOException, IllegalArgumentException {
- Preconditions.checkNotNull(name, "Node identifier should not be null");
-
- LOG.debug("Starting a new container node");
-
- startNode(name.getNodeType(), NodeTypes.CONTAINER_NODE);
- }
-
- @Override
- public void startUnkeyedList(YangInstanceIdentifier.NodeIdentifier name, int childSizeHint) throws IOException, IllegalArgumentException {
- Preconditions.checkNotNull(name, "Node identifier should not be null");
- LOG.debug("Starting a new unkeyed list");
-
- startNode(name.getNodeType(), NodeTypes.UNKEYED_LIST);
- }
-
- @Override
- public void startUnkeyedListItem(YangInstanceIdentifier.NodeIdentifier name, int childSizeHint) throws IOException, IllegalStateException {
- Preconditions.checkNotNull(name, "Node identifier should not be null");
- LOG.debug("Starting a new unkeyed list item");
-
- startNode(name.getNodeType(), NodeTypes.UNKEYED_LIST_ITEM);
- }
-
- @Override
- public void startMapNode(YangInstanceIdentifier.NodeIdentifier name, int childSizeHint) throws IOException, IllegalArgumentException {
- Preconditions.checkNotNull(name, "Node identifier should not be null");
- LOG.debug("Starting a new map node");
-
- startNode(name.getNodeType(), NodeTypes.MAP_NODE);
- }
-
- @Override
- public void startMapEntryNode(YangInstanceIdentifier.NodeIdentifierWithPredicates identifier, int childSizeHint) throws IOException, IllegalArgumentException {
- Preconditions.checkNotNull(identifier, "Node identifier should not be null");
- LOG.debug("Starting a new map entry node");
- startNode(identifier.getNodeType(), NodeTypes.MAP_ENTRY_NODE);
-
- writeKeyValueMap(identifier.getKeyValues());
-
- }
-
- @Override
- public void startOrderedMapNode(YangInstanceIdentifier.NodeIdentifier name, int childSizeHint) throws IOException, IllegalArgumentException {
- Preconditions.checkNotNull(name, "Node identifier should not be null");
- LOG.debug("Starting a new ordered map node");
-
- startNode(name.getNodeType(), NodeTypes.ORDERED_MAP_NODE);
- }
-
- @Override
- public void startChoiceNode(YangInstanceIdentifier.NodeIdentifier name, int childSizeHint) throws IOException, IllegalArgumentException {
- Preconditions.checkNotNull(name, "Node identifier should not be null");
- LOG.debug("Starting a new choice node");
-
- startNode(name.getNodeType(), NodeTypes.CHOICE_NODE);
- }
-
- @Override
- public void startAugmentationNode(YangInstanceIdentifier.AugmentationIdentifier identifier) throws IOException, IllegalArgumentException {
- Preconditions.checkNotNull(identifier, "Node identifier should not be null");
- LOG.debug("Starting a new augmentation node");
-
- output.writeByte(NodeTypes.AUGMENTATION_NODE);
- writeQNameSet(identifier.getPossibleChildNames());
- }
-
- @Override
- public void anyxmlNode(YangInstanceIdentifier.NodeIdentifier name, Object value) throws IOException, IllegalArgumentException {
- Preconditions.checkNotNull(name, "Node identifier should not be null");
- LOG.debug("Writing a new xml node");
-
- startNode(name.getNodeType(), NodeTypes.ANY_XML_NODE);
-
- writeObject(value);
- }
-
- @Override
- public void endNode() throws IOException, IllegalStateException {
- LOG.debug("Ending the node");
-
- output.writeByte(NodeTypes.END_NODE);
- }
-
- @Override
- public void close() throws IOException {
- }
-
- @Override
- public void flush() throws IOException {
- }
-
- private void startNode(final QName qName, byte nodeType) throws IOException {
-
- Preconditions.checkNotNull(qName, "QName of node identifier should not be null.");
- // First write the type of node
- output.writeByte(nodeType);
- // Write Start Tag
- writeQName(qName);
- }
-
- private void writeQName(QName qName) throws IOException {
-
- writeCodedString(qName.getLocalName());
- writeCodedString(qName.getNamespace().toString());
- writeCodedString(qName.getFormattedRevision());
- }
-
- private void writeCodedString(String key) throws IOException {
- Integer value = stringCodeMap.get(key);
- if(value != null) {
- output.writeByte(IS_CODE_VALUE);
- output.writeInt(value);
- } else {
- if(key != null) {
- output.writeByte(IS_STRING_VALUE);
- stringCodeMap.put(key, Integer.valueOf(stringCodeMap.size()));
- output.writeUTF(key);