blob: 2d1121b04139b3d68b6daa7534e0b8109d545c99 [file] [log] [blame]
Meki Cherkaoui97e7a592012-04-14 02:50:06 -07001//todo parse this
2/*
3 *
4 *
5 * static {
6 canonicalWriteDateFormat =
7 new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'");
8 new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.S'Z'"); // writing ns doesn't format leading 0's correctly
9 canonicalWriteDateFormat.setTimeZone(TimeZone.getTimeZone("GMT"));
10 canonicalReadDateFormat =
11 new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
12 // new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.S'Z'");
13 canonicalReadDateFormat.setTimeZone(TimeZone.getTimeZone("GMT"));
14 }
15 *
16 */
17
18var DataUtils = require('./DataUtils').DataUtils;
19
20 var /*DateFormat*/ canonicalWriteDateFormat = null;
21 var /* DateFormat*/ canonicalReadDateFormat = null;
22 var /*String*/ PAD_STRING = "000000000";
23 var /*int*/ NANO_LENGTH = 9;
24
25var TextXMLCodec = function TextXMLCodec(){
26
27 this.CCN_NAMESPACE = "http://www.parc.com/ccn"; // String
28 this.CCN_PREFIX = "ccn"; // String
29 this.CODEC_NAME = "Text";// String
30 this.BINARY_ATTRIBUTE = "ccnbencoding";// String
31 this.BINARY_ATTRIBUTE_VALUE = "base64Binary";// String
32
33
34};
35
36//returns a string
37
38TextXMLCodec.protpotype.codecName = function() { return this.CODEC_NAME; } ;
39
40//returns a string
41TextXMLCodec.protottype.encodeBinaryElement = function(/*byte []*/ element) {
42 if ((null == element) || (0 == element.length))
43 return new String("");
44 return new String(DataUtils.base64Encode(element));
45 };
46
47/* returns a string */
48TextXMLCodec.prototype.encodeBinaryElement = function(/*byte []*/ element, /*int*/ offset, /*int*/ length) {
49 if ((null == element) || (0 == element.length))
50 return new String("");
51 ByteBuffer bbuf = ByteBuffer.wrap(element, offset, length);
52 return new String(DataUtils.base64Encode(bbuf.array()));
53 };
54
55/*returns a byte array*/
56TextXMLCodec.prototype.decodeBinaryElement = function(/*String*/ element) {
57 if ((null == element) || (0 == element.length()))
58 return new byte[0];
59 return DataUtils.base64Decode(element.getBytes());
60 };
61
62
63/*
64 Decode Data
65*/
66
67
68/*
69 Encode Date
70*/