blob: 6702f39432d5824cdb4a5ee470b50df2718e99c5 [file] [log] [blame]
Meki Cherkaouiabb973b2012-05-09 14:25:57 -07001
2
3var ForwardingEntry = function ForwardingEntry(
4 //ActionType
5 _action,
6 //ContentName
7 _prefixName,
8 //PublisherPublicKeyDigest
9 _ccndId,
10 //Integer
11 _faceID,
12 //Integer
13 _flags,
14 //Integer
15 _lifetime){
16
17
18
19 //String
20 this.Action = _action;
21 //ContentName\
22 this.PrefixName = _prefixName;
23 //PublisherPublicKeyDigest
24 this.CCNID = _ccndId;
25 //Integer
26 this.FaceID = _faceID;
27 //Integer
28 this.Flags = _flags;
29 //Integer
30 this.Lifetime = _lifetime; // in seconds
31
32};
33
34ForwardingEntry.prototype.decode =function(
35 //XMLDecoder
36 decoder)
37 //throws ContentDecodingException
38 {
39 decoder.readStartElement(this.getElementLabel());
40 if (decoder.peekStartElement(CCNProtocolDTags.Action)) {
41 this.Action = decoder.readUTF8Element(CCNProtocolDTags.Action);
42 }
43 if (decoder.peekStartElement(CCNProtocolDTags.Name)) {
44 this.PrefixName = new ContentName();
45 this.PrefixName.decode(decoder) ;
46 }
47 if (decoder.peekStartElement(CCNProtocolDTags.PublisherPublicKeyDigest)) {
48 this.CcndId = new PublisherPublicKeyDigest();
49 this.CcndId.decode(decoder);
50 }
51 if (decoder.peekStartElement(CCNProtocolDTags.FaceID)) {
52 this.FaceID = decoder.readIntegerElement(CCNProtocolDTags.FaceID);
53 }
54 if (decoder.peekStartElement(CCNProtocolDTags.ForwardingFlags)) {
55 this.Flags = decoder.readIntegerElement(CCNProtocolDTags.ForwardingFlags);
56 }
57 if (decoder.peekStartElement(CCNProtocolDTags.FreshnessSeconds)) {
58 this.Lifetime = decoder.readIntegerElement(CCNProtocolDTags.FreshnessSeconds);
59 }
60 decoder.readEndElement();
61 };
62
63 /**
64 * Used by NetworkObject to encode the object to a network stream.
65 * @see org.ccnx.ccn.impl.encoding.XMLEncodable
66 */
67ForwardingEntry.prototype.encode =function(
68 //XMLEncoder
69encoder)
70{
71
72
73 //if (!validate()) {
74 //throw new ContentEncodingException("Cannot encode " + this.getClass().getName() + ": field values missing.");
75 //}
76 encoder.writeStartElement(this.getElementLabel());
77 if (null != this.Action && this.Action.length != 0)
78 encoder.writeElement(CCNProtocolDTags.Action, this.Action);
79 if (null != this.PrefixName) {
80 this.PrefixName.encode(encoder);
81 }
82 if (null != this.CcndId) {
83 this.CcndId.encode(encoder);
84 }
85 if (null != this.FaceID) {
86 encoder.writeElement(CCNProtocolDTags.FaceID, this.FaceID);
87 }
88 if (null != this.Flags) {
89 encoder.writeElement(CCNProtocolDTags.ForwardingFlags, this.Flags);
90 }
91 if (null != this.Lifetime) {
92 encoder.writeElement(CCNProtocolDTags.FreshnessSeconds, this.Lifetime);
93 }
94 encoder.writeEndElement();
95 };
96
97ForwardingEntry.prototype.getElementLabel = function() { return CCNProtocolDTags.ForwardingEntry; }