Meki Cherkaoui | 97e7a59 | 2012-04-14 02:50:06 -0700 | [diff] [blame^] | 1 | |
| 2 | var ContentName = function ContentName(_Components){ |
| 3 | |
| 4 | |
| 5 | this.SCHEME = "ccnx:"; |
| 6 | |
| 7 | this.ORIGINAL_SCHEME = "ccn:"; |
| 8 | |
| 9 | this.SEPARATOR = "/"; |
| 10 | this.ROOT = null; |
| 11 | |
| 12 | this.Components = _Components; |
| 13 | }; |
| 14 | |
| 15 | ContentName.prototype.decode = function(/*XMLDecoder*/ decoder) { |
| 16 | decoder.readStartElement(this.getElementLabel()); |
| 17 | |
| 18 | |
| 19 | this.Components = new Array(); //new ArrayList<byte []>(); |
| 20 | |
| 21 | while (decoder.peekStartElement(CCNProtocolDTags.Component)) { |
| 22 | this.add(decoder.readBinaryElement(CCNProtocolDTags.Component)); |
| 23 | } |
| 24 | |
| 25 | decoder.readEndElement(); |
| 26 | }; |
| 27 | |
| 28 | ContentName.prototype.encode = function(/*XMLEncoder*/ encoder) { |
| 29 | //if (!validate()) { |
| 30 | //throw new ContentEncodingException("Cannot encode " + this.getClass().getName() + ": field values missing."); |
| 31 | //} |
| 32 | |
| 33 | encoder.writeStartElement(this.getElementLabel()); |
| 34 | var count = this.Components.length; |
| 35 | for (var i=0; i < count; i++) { |
| 36 | encoder.writeElement(CCNProtocolDTags.Component, this.Components[i]); |
| 37 | } |
| 38 | |
| 39 | encoder.writeEndElement(); |
| 40 | }; |
| 41 | |
| 42 | ContentName.prototype.getElementLabel = function(){ |
| 43 | return CCNProtocolDTags.Name; |
| 44 | }; |
| 45 | |
| 46 | ContentName.prototype.add = function(param){ |
| 47 | return this.Components.push(param); |
| 48 | }; |
| 49 | |