*
*/
-public class NormalizedNodeInputStreamReader implements NormalizedNodeStreamReader {
+public class NormalizedNodeInputStreamReader implements NormalizedNodeDataInput {
private static final Logger LOG = LoggerFactory.getLogger(NormalizedNodeInputStreamReader.class);
private NormalizedNodeAttrBuilder<YangInstanceIdentifier.NodeIdentifier,
Object, LeafNode<Object>> leafBuilder;
- private NormalizedNodeAttrBuilder<NodeWithValue, Object,
- LeafSetEntryNode<Object>> leafSetEntryBuilder;
+ private NormalizedNodeAttrBuilder<NodeWithValue, Object, LeafSetEntryNode<Object>> leafSetEntryBuilder;
private final StringBuilder reusableStringBuilder = new StringBuilder(50);
*/
@Deprecated
public NormalizedNodeInputStreamReader(final InputStream stream) throws IOException {
- Preconditions.checkNotNull(stream);
- input = new DataInputStream(stream);
+ this((DataInput) new DataInputStream(Preconditions.checkNotNull(stream)));
}
+ /**
+ * @deprecated Use {@link NormalizedNodeInputOutput#newDataInput(DataInput)} instead.
+ */
+ @Deprecated
public NormalizedNodeInputStreamReader(final DataInput input) {
+ this(input, false);
+ }
+
+ NormalizedNodeInputStreamReader(final DataInput input, final boolean versionChecked) {
this.input = Preconditions.checkNotNull(input);
+ readSignatureMarker = !versionChecked;
}
@Override
withNodeIdentifier(augIdentifier)).build();
case NodeTypes.LEAF_SET_ENTRY_NODE :
+ QName name = lastLeafSetQName;
+ if(name == null) {
+ name = readQName();
+ }
+
Object value = readObject();
- NodeWithValue leafIdentifier = new NodeWithValue(lastLeafSetQName, value);
+ NodeWithValue<Object> leafIdentifier = new NodeWithValue<>(name, value);
LOG.debug("Reading leaf set entry node {}, value {}", leafIdentifier, value);
return addLeafSetChildren(identifier.getNodeType(),
Builders.leafSetBuilder().withNodeIdentifier(identifier)).build();
+ case NodeTypes.ORDERED_LEAF_SET:
+ LOG.debug("Read ordered leaf set node {}", identifier);
+ ListNodeBuilder<Object, LeafSetEntryNode<Object>> orderedLeafSetBuilder =
+ Builders.orderedLeafSetBuilder().withNodeIdentifier(identifier);
+ orderedLeafSetBuilder = addLeafSetChildren(identifier.getNodeType(), orderedLeafSetBuilder);
+ return orderedLeafSetBuilder.build();
+
default :
return null;
}
return new String(bytes, StandardCharsets.UTF_8);
}
+ @Override
public YangInstanceIdentifier readYangInstanceIdentifier() throws IOException {
readSignatureMarkerAndVersionIfNeeded();
return readYangInstanceIdentifierInternal();
return children;
}
+ @Override
public PathArgument readPathArgument() throws IOException {
// read Type
int type = input.readByte();
return new NodeIdentifierWithPredicates(readQName(), readKeyValueMap());
case PathArgumentTypes.NODE_IDENTIFIER_WITH_VALUE :
- return new NodeWithValue(readQName(), readObject());
+ return new NodeWithValue<>(readQName(), readObject());
default :
return null;
}
return builder;
}
+
+ @Override
+ public void readFully(final byte[] b) throws IOException {
+ readSignatureMarkerAndVersionIfNeeded();
+ input.readFully(b);
+ }
+
+ @Override
+ public void readFully(final byte[] b, final int off, final int len) throws IOException {
+ readSignatureMarkerAndVersionIfNeeded();
+ input.readFully(b, off, len);
+ }
+
+ @Override
+ public int skipBytes(final int n) throws IOException {
+ readSignatureMarkerAndVersionIfNeeded();
+ return input.skipBytes(n);
+ }
+
+ @Override
+ public boolean readBoolean() throws IOException {
+ readSignatureMarkerAndVersionIfNeeded();
+ return input.readBoolean();
+ }
+
+ @Override
+ public byte readByte() throws IOException {
+ readSignatureMarkerAndVersionIfNeeded();
+ return input.readByte();
+ }
+
+ @Override
+ public int readUnsignedByte() throws IOException {
+ readSignatureMarkerAndVersionIfNeeded();
+ return input.readUnsignedByte();
+ }
+
+ @Override
+ public short readShort() throws IOException {
+ readSignatureMarkerAndVersionIfNeeded();
+ return input.readShort();
+ }
+
+ @Override
+ public int readUnsignedShort() throws IOException {
+ readSignatureMarkerAndVersionIfNeeded();
+ return input.readUnsignedShort();
+ }
+
+ @Override
+ public char readChar() throws IOException {
+ readSignatureMarkerAndVersionIfNeeded();
+ return input.readChar();
+ }
+
+ @Override
+ public int readInt() throws IOException {
+ readSignatureMarkerAndVersionIfNeeded();
+ return input.readInt();
+ }
+
+ @Override
+ public long readLong() throws IOException {
+ readSignatureMarkerAndVersionIfNeeded();
+ return input.readLong();
+ }
+
+ @Override
+ public float readFloat() throws IOException {
+ readSignatureMarkerAndVersionIfNeeded();
+ return input.readFloat();
+ }
+
+ @Override
+ public double readDouble() throws IOException {
+ readSignatureMarkerAndVersionIfNeeded();
+ return input.readDouble();
+ }
+
+ @Override
+ public String readLine() throws IOException {
+ readSignatureMarkerAndVersionIfNeeded();
+ return input.readLine();
+ }
+
+ @Override
+ public String readUTF() throws IOException {
+ readSignatureMarkerAndVersionIfNeeded();
+ return input.readUTF();
+ }
}