/*
+ * Copyright (c) 2014, 2015 Cisco Systems, Inc. and others. All rights reserved.
*
- * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
*/
package org.opendaylight.controller.cluster.datastore.node.utils.stream;
import java.io.InputStream;
import java.math.BigDecimal;
import java.math.BigInteger;
+import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
private boolean readSignatureMarker = true;
- public NormalizedNodeInputStreamReader(InputStream stream) throws IOException {
+ public NormalizedNodeInputStreamReader(final InputStream stream) throws IOException {
Preconditions.checkNotNull(stream);
input = new DataInputStream(stream);
}
- public NormalizedNodeInputStreamReader(DataInput input) {
+ public NormalizedNodeInputStreamReader(final DataInput input) {
this.input = Preconditions.checkNotNull(input);
}
return leafSetEntryBuilder;
}
- private NormalizedNode<?, ?> readNodeIdentifierDependentNode(byte nodeType, NodeIdentifier identifier)
+ private NormalizedNode<?, ?> readNodeIdentifierDependentNode(final byte nodeType, final NodeIdentifier identifier)
throws IOException {
switch(nodeType) {
case ValueTypes.STRING_TYPE :
return input.readUTF();
+ case ValueTypes.STRING_BYTES_TYPE:
+ return readStringBytes();
+
case ValueTypes.BIG_DECIMAL_TYPE :
return new BigDecimal(input.readUTF());
}
}
+ private String readStringBytes() throws IOException {
+ byte[] bytes = new byte[input.readInt()];
+ input.readFully(bytes);
+ return new String(bytes, StandardCharsets.UTF_8);
+ }
+
public YangInstanceIdentifier readYangInstanceIdentifier() throws IOException {
readSignatureMarkerAndVersionIfNeeded();
return readYangInstanceIdentifierInternal();
}
@SuppressWarnings("unchecked")
- private ListNodeBuilder<Object, LeafSetEntryNode<Object>> addLeafSetChildren(QName nodeType,
- ListNodeBuilder<Object, LeafSetEntryNode<Object>> builder) throws IOException {
+ private ListNodeBuilder<Object, LeafSetEntryNode<Object>> addLeafSetChildren(final QName nodeType,
+ final ListNodeBuilder<Object, LeafSetEntryNode<Object>> builder) throws IOException {
LOG.debug("Reading children of leaf set");
@SuppressWarnings({ "unchecked", "rawtypes" })
private NormalizedNodeContainerBuilder addDataContainerChildren(
- NormalizedNodeContainerBuilder builder) throws IOException {
+ final NormalizedNodeContainerBuilder builder) throws IOException {
LOG.debug("Reading data container (leaf nodes) nodes");
NormalizedNode<?, ?> child = readNormalizedNodeInternal();