Meki Cherkaoui | 8f17361 | 2012-06-06 01:05:40 -0700 | [diff] [blame] | 1 | |
| 2 | |
| 3 | |
| 4 | |
| 5 | function encodeToHexInterest(int){ |
| 6 | |
| 7 | var enc = new BinaryXMLEncoder(); |
| 8 | |
| 9 | int.encode(enc); |
| 10 | |
| 11 | var hex = DataUtils.toHex(enc.getReducedOstream()); |
| 12 | |
| 13 | return hex; |
| 14 | |
| 15 | |
| 16 | } |
| 17 | |
| 18 | |
| 19 | function encodeToHexContentObject(co){ |
| 20 | var enc = new BinaryXMLEncoder(); |
| 21 | |
| 22 | co.encode(enc); |
| 23 | |
| 24 | var hex = DataUtils.toHex(enc.getReducedOstream()); |
| 25 | |
| 26 | return hex; |
| 27 | |
| 28 | |
| 29 | } |
| 30 | |
| 31 | function encodeToBinaryContentObject(co){ |
| 32 | var enc = new BinaryXMLEncoder(); |
| 33 | |
| 34 | co.encode(enc); |
| 35 | |
| 36 | var hex = enc.getReducedOstream(); |
| 37 | |
| 38 | return hex; |
| 39 | |
| 40 | |
| 41 | } |
| 42 | |
| 43 | function encodeForwardingEntry(co){ |
| 44 | var enc = new BinaryXMLEncoder(); |
| 45 | |
| 46 | co.encode(enc); |
| 47 | |
| 48 | var bytes = enc.getReducedOstream(); |
| 49 | |
| 50 | return bytes; |
| 51 | |
| 52 | |
| 53 | } |
| 54 | |
| 55 | |
| 56 | |
| 57 | function decodeHexFaceInstance(result){ |
| 58 | |
| 59 | var numbers = DataUtils.toNumbers(result); |
| 60 | |
| 61 | |
| 62 | decoder = new BinaryXMLDecoder(numbers); |
| 63 | |
| 64 | if(LOG>3)console.log('DECODING HEX FACE INSTANCE \n'+numbers); |
| 65 | |
| 66 | i = new FaceInstance(); |
| 67 | |
| 68 | i.decode(decoder); |
| 69 | |
| 70 | return i; |
| 71 | |
| 72 | } |
| 73 | |
| 74 | function decodeHexInterest(result){ |
| 75 | var numbers = DataUtils.toNumbers(result); |
| 76 | |
| 77 | |
| 78 | decoder = new BinaryXMLDecoder(numbers); |
| 79 | if(LOG>3)console.log('DECODING HEX INTERST \n'+numbers); |
| 80 | |
| 81 | i = new Interest(); |
| 82 | |
| 83 | i.decode(decoder); |
| 84 | |
| 85 | return i; |
| 86 | |
| 87 | } |
| 88 | |
| 89 | |
| 90 | |
| 91 | function decodeHexContentObject(result){ |
| 92 | var numbers = DataUtils.toNumbers(result); |
| 93 | |
| 94 | decoder = new BinaryXMLDecoder(numbers); |
| 95 | if(LOG>3)console.log('DECODED HEX CONTENT OBJECT \n'+numbers); |
| 96 | |
| 97 | co = new ContentObject(); |
| 98 | |
| 99 | co.decode(decoder); |
| 100 | |
| 101 | return co; |
| 102 | |
| 103 | } |
| 104 | |
| 105 | |
| 106 | |
| 107 | function decodeHexForwardingEntry(result){ |
| 108 | var numbers = DataUtils.toNumbers(result); |
| 109 | |
| 110 | decoder = new BinaryXMLDecoder(numbers); |
| 111 | |
| 112 | if(LOG>3)console.log('DECODED HEX FORWARDING ENTRY \n'+numbers); |
| 113 | |
| 114 | co = new ForwardingEntry(); |
| 115 | |
| 116 | co.decode(decoder); |
| 117 | |
| 118 | return co; |
| 119 | |
| 120 | } |