Meki Cherkaoui | b0365a7 | 2012-02-18 00:59:57 -0800 | [diff] [blame] | 1 | var CCNProtocolDTags = require('./CCNProtocolDTags').CCNProtocolDTags; |
| 2 | |
| 3 | |
| 4 | var KeyName = function KeyName() { |
| 5 | |
| 6 | |
| 7 | this.ContentName = this.ContentName;//ContentName |
| 8 | this.PublisherID =this.PublisherID;//PublisherID |
| 9 | |
| 10 | }; |
| 11 | |
| 12 | exports.KeyName = KeyName; |
| 13 | |
| 14 | KeyName.prototype.decode=function( decoder){ |
| 15 | |
| 16 | |
| 17 | decoder.readStartElement(this.getElementLabel()); |
| 18 | |
| 19 | this.ContentName = new ContentName(); |
| 20 | this.ContentName.decode(decoder); |
| 21 | |
| 22 | if (PublisherID.peek(decoder)) { |
| 23 | this.PublisherID = new PublisherID(); |
| 24 | this.PublisherID.decode(decoder); |
| 25 | } |
| 26 | |
| 27 | decoder.readEndElement(); |
| 28 | }; |
| 29 | |
| 30 | KeyName.prototype.encode = function( encoder) { |
| 31 | if (!this.validate()) { |
| 32 | throw new Exception("Cannot encode : field values missing."); |
| 33 | } |
| 34 | |
| 35 | encoder.writeStartElement(this.getElementLabel()); |
| 36 | |
| 37 | this.ContentName.encode(encoder); |
| 38 | if (null != this.PublisherID) |
| 39 | this.PublisherID.encode(encoder); |
| 40 | |
| 41 | encoder.writeEndElement(); |
| 42 | }; |
| 43 | |
| 44 | KeyName.prototype.getElementLabel = function() { return CCNProtocolDTags.KeyName; }; |
| 45 | |
| 46 | KeyName.prototype.validate = function() { |
| 47 | // DKS -- do we do recursive validation? |
| 48 | // null signedInfo ok |
| 49 | return (null != this.ContentName); |
| 50 | }; |