@Test public void testGetTlvBodyAsByteArray() throws Exception { channelBuffer = ChannelBuffers.copiedBuffer(packet9); linkTlv.readFrom(channelBuffer); result = linkTlv.getTlvBodyAsByteArray(); assertThat(result, is(notNullValue())); }
public byte[] getTlvBodyAsByteArray() throws Exception { List<Byte> bodyLst = new ArrayList<>(); for (LinkSubType tlv : subTlv) { if (tlv instanceof LinkType) { LinkType linkType = (LinkType) tlv; bodyLst.addAll(Bytes.asList(linkType.asBytes())); } else if (tlv instanceof LinkId) { LinkId linkId = (LinkId) tlv; bodyLst.addAll(Bytes.asList(linkId.asBytes())); } else if (tlv instanceof LocalInterfaceIpAddress) { LocalInterfaceIpAddress localInterfaceIpAddress = (LocalInterfaceIpAddress) tlv; bodyLst.addAll(Bytes.asList(localInterfaceIpAddress.asBytes())); } else if (tlv instanceof RemoteInterfaceIpAddress) { RemoteInterfaceIpAddress remoteInterfaceIpAddress = (RemoteInterfaceIpAddress) tlv; bodyLst.addAll(Bytes.asList(remoteInterfaceIpAddress.asBytes())); } else if (tlv instanceof TrafficEngineeringMetric) { TrafficEngineeringMetric trafficEngineeringMetric = (TrafficEngineeringMetric) tlv; bodyLst.addAll(Bytes.asList(trafficEngineeringMetric.asBytes())); } else if (tlv instanceof MaximumBandwidth) { MaximumBandwidth maximumBandwidth = (MaximumBandwidth) tlv; bodyLst.addAll(Bytes.asList(maximumBandwidth.asBytes())); } else if (tlv instanceof MaximumReservableBandwidth) { MaximumReservableBandwidth maximumReservableBandwidth = (MaximumReservableBandwidth) tlv; bodyLst.addAll(Bytes.asList(maximumReservableBandwidth.asBytes())); } else if (tlv instanceof UnreservedBandwidth) { UnreservedBandwidth unreservedBandwidth = (UnreservedBandwidth) tlv; bodyLst.addAll(Bytes.asList(unreservedBandwidth.asBytes())); } else if (tlv instanceof AdministrativeGroup) { AdministrativeGroup administrativeGroup = (AdministrativeGroup) tlv; bodyLst.addAll(Bytes.asList(administrativeGroup.asBytes())); } else { UnknownLinkSubType unknownLinkSubType = (UnknownLinkSubType) tlv; bodyLst.addAll(Bytes.asList(unknownLinkSubType.asBytes())); } } return Bytes.toArray(bodyLst); }
LinkTlv extends TlvHeader implements TopLevelTlv { public byte[] getTlvBodyAsByteArray() throws Exception { List<Byte> bodyLst = new ArrayList<>(); for (LinkSubType tlv : subTlv) { if (tlv instanceof LinkType) { LinkType linkType = (LinkType) tlv; bodyLst.addAll(Bytes.asList(linkType.asBytes())); } else if (tlv instanceof LinkId) { LinkId linkId = (LinkId) tlv; bodyLst.addAll(Bytes.asList(linkId.asBytes())); } else if (tlv instanceof LocalInterfaceIpAddress) { LocalInterfaceIpAddress localInterfaceIpAddress = (LocalInterfaceIpAddress) tlv; bodyLst.addAll(Bytes.asList(localInterfaceIpAddress.asBytes())); } else if (tlv instanceof RemoteInterfaceIpAddress) { RemoteInterfaceIpAddress remoteInterfaceIpAddress = (RemoteInterfaceIpAddress) tlv; bodyLst.addAll(Bytes.asList(remoteInterfaceIpAddress.asBytes())); } else if (tlv instanceof TrafficEngineeringMetric) { TrafficEngineeringMetric trafficEngineeringMetric = (TrafficEngineeringMetric) tlv; bodyLst.addAll(Bytes.asList(trafficEngineeringMetric.asBytes())); } else if (tlv instanceof MaximumBandwidth) { MaximumBandwidth maximumBandwidth = (MaximumBandwidth) tlv; bodyLst.addAll(Bytes.asList(maximumBandwidth.asBytes())); } else if (tlv instanceof MaximumReservableBandwidth) { MaximumReservableBandwidth maximumReservableBandwidth = (MaximumReservableBandwidth) tlv; bodyLst.addAll(Bytes.asList(maximumReservableBandwidth.asBytes())); } else if (tlv instanceof UnreservedBandwidth) { UnreservedBandwidth unreservedBandwidth = (UnreservedBandwidth) tlv; bodyLst.addAll(Bytes.asList(unreservedBandwidth.asBytes())); } else if (tlv instanceof AdministrativeGroup) { AdministrativeGroup administrativeGroup = (AdministrativeGroup) tlv; bodyLst.addAll(Bytes.asList(administrativeGroup.asBytes())); } else { UnknownLinkSubType unknownLinkSubType = (UnknownLinkSubType) tlv; bodyLst.addAll(Bytes.asList(unknownLinkSubType.asBytes())); } } return Bytes.toArray(bodyLst); } }
LinkTlv extends TlvHeader implements TopLevelTlv { public byte[] getTlvBodyAsByteArray() throws Exception { List<Byte> bodyLst = new ArrayList<>(); for (LinkSubType tlv : subTlv) { if (tlv instanceof LinkType) { LinkType linkType = (LinkType) tlv; bodyLst.addAll(Bytes.asList(linkType.asBytes())); } else if (tlv instanceof LinkId) { LinkId linkId = (LinkId) tlv; bodyLst.addAll(Bytes.asList(linkId.asBytes())); } else if (tlv instanceof LocalInterfaceIpAddress) { LocalInterfaceIpAddress localInterfaceIpAddress = (LocalInterfaceIpAddress) tlv; bodyLst.addAll(Bytes.asList(localInterfaceIpAddress.asBytes())); } else if (tlv instanceof RemoteInterfaceIpAddress) { RemoteInterfaceIpAddress remoteInterfaceIpAddress = (RemoteInterfaceIpAddress) tlv; bodyLst.addAll(Bytes.asList(remoteInterfaceIpAddress.asBytes())); } else if (tlv instanceof TrafficEngineeringMetric) { TrafficEngineeringMetric trafficEngineeringMetric = (TrafficEngineeringMetric) tlv; bodyLst.addAll(Bytes.asList(trafficEngineeringMetric.asBytes())); } else if (tlv instanceof MaximumBandwidth) { MaximumBandwidth maximumBandwidth = (MaximumBandwidth) tlv; bodyLst.addAll(Bytes.asList(maximumBandwidth.asBytes())); } else if (tlv instanceof MaximumReservableBandwidth) { MaximumReservableBandwidth maximumReservableBandwidth = (MaximumReservableBandwidth) tlv; bodyLst.addAll(Bytes.asList(maximumReservableBandwidth.asBytes())); } else if (tlv instanceof UnreservedBandwidth) { UnreservedBandwidth unreservedBandwidth = (UnreservedBandwidth) tlv; bodyLst.addAll(Bytes.asList(unreservedBandwidth.asBytes())); } else if (tlv instanceof AdministrativeGroup) { AdministrativeGroup administrativeGroup = (AdministrativeGroup) tlv; bodyLst.addAll(Bytes.asList(administrativeGroup.asBytes())); } else { UnknownLinkSubType unknownLinkSubType = (UnknownLinkSubType) tlv; bodyLst.addAll(Bytes.asList(unknownLinkSubType.asBytes())); } } return Bytes.toArray(bodyLst); } LinkTlv(TlvHeader header); }
LinkTlv extends TlvHeader implements TopLevelTlv { public byte[] getTlvBodyAsByteArray() throws Exception { List<Byte> bodyLst = new ArrayList<>(); for (LinkSubType tlv : subTlv) { if (tlv instanceof LinkType) { LinkType linkType = (LinkType) tlv; bodyLst.addAll(Bytes.asList(linkType.asBytes())); } else if (tlv instanceof LinkId) { LinkId linkId = (LinkId) tlv; bodyLst.addAll(Bytes.asList(linkId.asBytes())); } else if (tlv instanceof LocalInterfaceIpAddress) { LocalInterfaceIpAddress localInterfaceIpAddress = (LocalInterfaceIpAddress) tlv; bodyLst.addAll(Bytes.asList(localInterfaceIpAddress.asBytes())); } else if (tlv instanceof RemoteInterfaceIpAddress) { RemoteInterfaceIpAddress remoteInterfaceIpAddress = (RemoteInterfaceIpAddress) tlv; bodyLst.addAll(Bytes.asList(remoteInterfaceIpAddress.asBytes())); } else if (tlv instanceof TrafficEngineeringMetric) { TrafficEngineeringMetric trafficEngineeringMetric = (TrafficEngineeringMetric) tlv; bodyLst.addAll(Bytes.asList(trafficEngineeringMetric.asBytes())); } else if (tlv instanceof MaximumBandwidth) { MaximumBandwidth maximumBandwidth = (MaximumBandwidth) tlv; bodyLst.addAll(Bytes.asList(maximumBandwidth.asBytes())); } else if (tlv instanceof MaximumReservableBandwidth) { MaximumReservableBandwidth maximumReservableBandwidth = (MaximumReservableBandwidth) tlv; bodyLst.addAll(Bytes.asList(maximumReservableBandwidth.asBytes())); } else if (tlv instanceof UnreservedBandwidth) { UnreservedBandwidth unreservedBandwidth = (UnreservedBandwidth) tlv; bodyLst.addAll(Bytes.asList(unreservedBandwidth.asBytes())); } else if (tlv instanceof AdministrativeGroup) { AdministrativeGroup administrativeGroup = (AdministrativeGroup) tlv; bodyLst.addAll(Bytes.asList(administrativeGroup.asBytes())); } else { UnknownLinkSubType unknownLinkSubType = (UnknownLinkSubType) tlv; bodyLst.addAll(Bytes.asList(unknownLinkSubType.asBytes())); } } return Bytes.toArray(bodyLst); } LinkTlv(TlvHeader header); List<LinkSubType> subTlvList(); void readFrom(ChannelBuffer channelBuffer); byte[] asBytes(); byte[] getTlvBodyAsByteArray(); @Override String toString(); }
LinkTlv extends TlvHeader implements TopLevelTlv { public byte[] getTlvBodyAsByteArray() throws Exception { List<Byte> bodyLst = new ArrayList<>(); for (LinkSubType tlv : subTlv) { if (tlv instanceof LinkType) { LinkType linkType = (LinkType) tlv; bodyLst.addAll(Bytes.asList(linkType.asBytes())); } else if (tlv instanceof LinkId) { LinkId linkId = (LinkId) tlv; bodyLst.addAll(Bytes.asList(linkId.asBytes())); } else if (tlv instanceof LocalInterfaceIpAddress) { LocalInterfaceIpAddress localInterfaceIpAddress = (LocalInterfaceIpAddress) tlv; bodyLst.addAll(Bytes.asList(localInterfaceIpAddress.asBytes())); } else if (tlv instanceof RemoteInterfaceIpAddress) { RemoteInterfaceIpAddress remoteInterfaceIpAddress = (RemoteInterfaceIpAddress) tlv; bodyLst.addAll(Bytes.asList(remoteInterfaceIpAddress.asBytes())); } else if (tlv instanceof TrafficEngineeringMetric) { TrafficEngineeringMetric trafficEngineeringMetric = (TrafficEngineeringMetric) tlv; bodyLst.addAll(Bytes.asList(trafficEngineeringMetric.asBytes())); } else if (tlv instanceof MaximumBandwidth) { MaximumBandwidth maximumBandwidth = (MaximumBandwidth) tlv; bodyLst.addAll(Bytes.asList(maximumBandwidth.asBytes())); } else if (tlv instanceof MaximumReservableBandwidth) { MaximumReservableBandwidth maximumReservableBandwidth = (MaximumReservableBandwidth) tlv; bodyLst.addAll(Bytes.asList(maximumReservableBandwidth.asBytes())); } else if (tlv instanceof UnreservedBandwidth) { UnreservedBandwidth unreservedBandwidth = (UnreservedBandwidth) tlv; bodyLst.addAll(Bytes.asList(unreservedBandwidth.asBytes())); } else if (tlv instanceof AdministrativeGroup) { AdministrativeGroup administrativeGroup = (AdministrativeGroup) tlv; bodyLst.addAll(Bytes.asList(administrativeGroup.asBytes())); } else { UnknownLinkSubType unknownLinkSubType = (UnknownLinkSubType) tlv; bodyLst.addAll(Bytes.asList(unknownLinkSubType.asBytes())); } } return Bytes.toArray(bodyLst); } LinkTlv(TlvHeader header); List<LinkSubType> subTlvList(); void readFrom(ChannelBuffer channelBuffer); byte[] asBytes(); byte[] getTlvBodyAsByteArray(); @Override String toString();  }