/// <summary> /// Encode this Schedule. /// </summary> /// /// <returns>The encoded buffer.</returns> public Blob wireEncode() { // For now, don't use WireFormat and hardcode to use TLV since the encoding // doesn't go out over the wire, only into the local SQL database. TlvEncoder encoder = new TlvEncoder(256); int saveLength = encoder.getLength(); // Encode backwards. // Encode the blackIntervalList. int saveLengthForList = encoder.getLength(); for (IIterator i = blackIntervalList_.descendingIterator(); i.HasNext();) { RepetitiveInterval element = (RepetitiveInterval)i.Next(); encodeRepetitiveInterval(element, encoder); } encoder.writeTypeAndLength(net.named_data.jndn.encoding.tlv.Tlv.Encrypt_BlackIntervalList, encoder.getLength() - saveLengthForList); // Encode the whiteIntervalList. saveLengthForList = encoder.getLength(); for (IIterator i_0 = whiteIntervalList_.descendingIterator(); i_0.HasNext();) { RepetitiveInterval element_1 = (RepetitiveInterval)i_0.Next(); encodeRepetitiveInterval(element_1, encoder); } encoder.writeTypeAndLength(net.named_data.jndn.encoding.tlv.Tlv.Encrypt_WhiteIntervalList, encoder.getLength() - saveLengthForList); encoder.writeTypeAndLength(net.named_data.jndn.encoding.tlv.Tlv.Encrypt_Schedule, encoder.getLength() - saveLength); return(new Blob(encoder.getOutput(), false)); }
/// <summary> /// Encode this Schedule. /// </summary> /// /// <returns>The encoded buffer.</returns> public Blob wireEncode() { // For now, don't use WireFormat and hardcode to use TLV since the encoding // doesn't go out over the wire, only into the local SQL database. TlvEncoder encoder = new TlvEncoder(256); int saveLength = encoder.getLength(); // Encode backwards. // Encode the blackIntervalList. int saveLengthForList = encoder.getLength(); Object[] array = ILOG.J2CsMapping.Collections.Collections.ToArray(blackIntervalList_); System.Array.Sort(array); for (int i = array.Length - 1; i >= 0; --i) { RepetitiveInterval element = (RepetitiveInterval)array[i]; encodeRepetitiveInterval(element, encoder); } encoder.writeTypeAndLength(net.named_data.jndn.encoding.tlv.Tlv.Encrypt_BlackIntervalList, encoder.getLength() - saveLengthForList); // Encode the whiteIntervalList. saveLengthForList = encoder.getLength(); array = ILOG.J2CsMapping.Collections.Collections.ToArray(whiteIntervalList_); System.Array.Sort(array); for (int i_0 = array.Length - 1; i_0 >= 0; --i_0) { RepetitiveInterval element_1 = (RepetitiveInterval)array[i_0]; encodeRepetitiveInterval(element_1, encoder); } encoder.writeTypeAndLength(net.named_data.jndn.encoding.tlv.Tlv.Encrypt_WhiteIntervalList, encoder.getLength() - saveLengthForList); encoder.writeTypeAndLength(net.named_data.jndn.encoding.tlv.Tlv.Encrypt_Schedule, encoder.getLength() - saveLength); return(new Blob(encoder.getOutput(), false)); }
wireEncode() { TlvEncoder encoder = new TlvEncoder(256); int saveLength = encoder.getLength(); // Encode backwards. if (!other_.isNull()) { encoder.writeBlobTlv(ContentMetaInfo_Other, other_.buf()); } if (hasSegments_) { encoder.writeTypeAndLength(ContentMetaInfo_HasSegments, 0); } encoder.writeNonNegativeIntegerTlv (ContentMetaInfo_Timestamp, (long)Math.Round(timestamp_)); encoder.writeBlobTlv (ContentMetaInfo_ContentType, new Blob(contentType_).buf()); encoder.writeTypeAndLength (ContentMetaInfo_ContentMetaInfo, encoder.getLength() - saveLength); return(new Blob(encoder.getOutput(), false)); }
/// <summary> /// Encode this as an NDN-TLV SafeBag. /// </summary> /// /// <returns>The encoded byte array as a Blob.</returns> public Blob wireEncode() { // Encode directly as TLV. We don't support the WireFormat abstraction // because this isn't meant to go directly on the wire. TlvEncoder encoder = new TlvEncoder(256); int saveLength = encoder.getLength(); // Encode backwards. encoder.writeBlobTlv(net.named_data.jndn.encoding.tlv.Tlv.SafeBag_EncryptedKeyBag, privateKeyBag_.buf()); // Add the entire Data packet encoding as is. encoder.writeBuffer(certificate_.wireEncode(net.named_data.jndn.encoding.TlvWireFormat.get()).buf()); encoder.writeTypeAndLength(net.named_data.jndn.encoding.tlv.Tlv.SafeBag_SafeBag, encoder.getLength() - saveLength); return(new Blob(encoder.getOutput(), false)); }
/// <summary> /// Encode the RepetitiveInterval as NDN-TLV to the encoder. /// </summary> /// /// <param name="repetitiveInterval">The RepetitiveInterval to encode.</param> /// <param name="encoder">The TlvEncoder to receive the encoding.</param> private static void encodeRepetitiveInterval( RepetitiveInterval repetitiveInterval, TlvEncoder encoder) { int saveLength = encoder.getLength(); // Encode backwards. encoder.writeNonNegativeIntegerTlv(net.named_data.jndn.encoding.tlv.Tlv.Encrypt_RepeatUnit, repetitiveInterval.getRepeatUnit().getNumericType()); encoder.writeNonNegativeIntegerTlv(net.named_data.jndn.encoding.tlv.Tlv.Encrypt_NRepeats, repetitiveInterval.getNRepeats()); encoder.writeNonNegativeIntegerTlv(net.named_data.jndn.encoding.tlv.Tlv.Encrypt_IntervalEndHour, repetitiveInterval.getIntervalEndHour()); encoder.writeNonNegativeIntegerTlv(net.named_data.jndn.encoding.tlv.Tlv.Encrypt_IntervalStartHour, repetitiveInterval.getIntervalStartHour()); // Use Blob to convert the string to UTF8 encoding. encoder.writeBlobTlv(net.named_data.jndn.encoding.tlv.Tlv.Encrypt_EndDate, new Blob( toIsoString(repetitiveInterval.getEndDate())).buf()); encoder.writeBlobTlv(net.named_data.jndn.encoding.tlv.Tlv.Encrypt_StartDate, new Blob( toIsoString(repetitiveInterval.getStartDate())).buf()); encoder.writeTypeAndLength(net.named_data.jndn.encoding.tlv.Tlv.Encrypt_RepetitiveInterval, encoder.getLength() - saveLength); }