blob: 716aa6db1ca1247bedd79698110623fca37a0291 [file] [log] [blame]
Meki Cherkaouif441d3a2012-04-22 15:17:52 -07001//TODO INCOMPLETE
2/*
3 * @author: ucla-cs
4 *
5 * Encodes CCN object into xml tags
6 */
7var DataUtils = require('./DataUtils').DataUtils;
8
9 var /*DateFormat*/ canonicalWriteDateFormat = null;
10 var /* DateFormat*/ canonicalReadDateFormat = null;
11 var /*String*/ PAD_STRING = "000000000";
12 var /*int*/ NANO_LENGTH = 9;
13
14var TextXMLCodec = function TextXMLCodec(){
15
16 this.CCN_NAMESPACE = "http://www.parc.com/ccn"; // String
17 this.CCN_PREFIX = "ccn"; // String
18 this.CODEC_NAME = "Text";// String
19 this.BINARY_ATTRIBUTE = "ccnbencoding";// String
20 this.BINARY_ATTRIBUTE_VALUE = "base64Binary";// String
21
22
23};
24
25//returns a string
26
27TextXMLCodec.protpotype.codecName = function() { return this.CODEC_NAME; } ;
28
29//returns a string
30TextXMLCodec.protottype.encodeBinaryElement = function(/*byte []*/ element) {
31 if ((null == element) || (0 == element.length))
32 return new String("");
33 return new String(DataUtils.base64Encode(element));
34 };
35
36/* returns a string */
37TextXMLCodec.prototype.encodeBinaryElement = function(/*byte []*/ element, /*int*/ offset, /*int*/ length) {
38 if ((null == element) || (0 == element.length))
39 return new String("");
40 ByteBuffer bbuf = ByteBuffer.wrap(element, offset, length);
41 return new String(DataUtils.base64Encode(bbuf.array()));
42 };
43
44/*returns a byte array*/
45TextXMLCodec.prototype.decodeBinaryElement = function(/*String*/ element) {
46 if ((null == element) || (0 == element.length()))
47 return new byte[0];
48 return DataUtils.base64Decode(element.getBytes());
49 };
50
51
52/*
53 Decode Data
54*/
55
56
57/*
58 Encode Date
59*/