/** * DeSerialize a PathArgument which is in the protocol buffer format into * a yang PathArgument. The protocol buffer path argument is specially * encoded and can only be interpreted in the context of a top level * serialized NormalizedNode protocol buffer message. The reason for this * is that during the NormalizedNode serialization process certain repeated * strings are encoded into a "codes" list and the actual strings are * replaced by an integer which is an index into that list. * * @param node * @param pathArgument * @return */ public static YangInstanceIdentifier.PathArgument deSerialize(final NormalizedNodeMessages.Node node, final NormalizedNodeMessages.PathArgument pathArgument){ Preconditions.checkNotNull(node, "node should not be null"); Preconditions.checkNotNull(pathArgument, "pathArgument should not be null"); return new DeSerializer(null, node).deSerialize(pathArgument); }
public NormalizedNode<?, ?> deSerialize() { NormalizedNode<?, ?> deserializedNode = deSerialize(node); if(path != null) { deserializedPath = InstanceIdentifierUtils.fromSerializable(path, this); } return deserializedNode; }
public static DeSerializer newDeSerializer(final NormalizedNodeMessages.InstanceIdentifier path, final NormalizedNodeMessages.Node node) { Preconditions.checkNotNull(node, "node should not be null"); return new DeSerializer(path, node); }
public Decoded decode(NormalizedNodeMessages.InstanceIdentifier path, NormalizedNodeMessages.Node node) { if(node.getIntType() < 0 || node.getSerializedSize() == 0){ return new DecodedImpl(null, null); } DeSerializer deSerializer = NormalizedNodeSerializer.newDeSerializer(path, node); NormalizedNode<?,?> decodedNode = deSerializer.deSerialize(); return new DecodedImpl(decodedNode, deSerializer.getDeserializedPath()); }
/** * DeSerialize a protocol buffer message back into a NormalizedNode * * @param node * @return */ public static NormalizedNode<?, ?> deSerialize(final NormalizedNodeMessages.Node node) { Preconditions.checkNotNull(node, "node should not be null"); return new DeSerializer(null, node).deSerialize(); }
private NormalizedNode<?, ?> buildDataContainer(final DataContainerNodeBuilder<?, ?> builder, final NormalizedNodeMessages.Node node){ for(NormalizedNodeMessages.Node child : node.getChildList()){ builder.withChild((DataContainerChild<?, ?>) deSerialize(child)); } //TODO : Also handle attributes return builder.build(); }
private NormalizedNode<?, ?> buildListNode( final ListNodeBuilder<Object, LeafSetEntryNode<Object>> builder, final NormalizedNodeMessages.Node node) { builder.withNodeIdentifier(toNodeIdentifier(node.getPathArgument())); for(NormalizedNodeMessages.Node child : node.getChildList()){ builder.withChild((LeafSetEntryNode<Object>) deSerialize(child)); } return builder.build(); }
private NormalizedNode<?, ?> buildCollectionNode( final CollectionNodeBuilder builder, final NormalizedNodeMessages.Node node) { builder.withNodeIdentifier(toNodeIdentifier(node.getPathArgument())); for(NormalizedNodeMessages.Node child : node.getChildList()){ builder.withChild(deSerialize(child)); } return builder.build(); }