Cleaning up
diff --git a/latest/CCNProtocolDTags.js b/latest/CCNProtocolDTags.js
deleted file mode 100644
index 4305151..0000000
--- a/latest/CCNProtocolDTags.js
+++ /dev/null
@@ -1,152 +0,0 @@
-
-
-
-var CCNProtocolDTags = {
-
- /**
- * Note if you add one of these, add it to the reverse string map as well.
- * Emphasize getting the work done at compile time over trying to make something
- * flexible and developer error-proof.
- */
-
- Any : 13,
- Name : 14,
- Component : 15,
- Certificate : 16,
- Collection : 17,
- CompleteName : 18,
- Content : 19,
- SignedInfo : 20,
- ContentDigest : 21,
- ContentHash : 22,
- Count : 24,
- Header : 25,
- Interest : 26, /* 20090915 */
- Key : 27,
- KeyLocator : 28,
- KeyName : 29,
- Length : 30,
- Link : 31,
- LinkAuthenticator : 32,
- NameComponentCount : 33, /* DeprecatedInInterest */
- RootDigest : 36,
- Signature : 37,
- Start : 38,
- Timestamp : 39,
- Type : 40,
- Nonce : 41,
- Scope : 42,
- Exclude : 43,
- Bloom : 44,
- BloomSeed : 45,
- AnswerOriginKind : 47,
- InterestLifetime : 48,
- Witness : 53,
- SignatureBits : 54,
- DigestAlgorithm : 55,
- BlockSize : 56,
- FreshnessSeconds : 58,
- FinalBlockID : 59,
- PublisherPublicKeyDigest : 60,
- PublisherCertificateDigest : 61,
- PublisherIssuerKeyDigest : 62,
- PublisherIssuerCertificateDigest : 63,
- ContentObject : 64, /* 20090915 */
- WrappedKey : 65,
- WrappingKeyIdentifier : 66,
- WrapAlgorithm : 67,
- KeyAlgorithm : 68,
- Label : 69,
- EncryptedKey : 70,
- EncryptedNonceKey : 71,
- WrappingKeyName : 72,
- Action : 73,
- FaceID : 74,
- IPProto : 75,
- Host : 76,
- Port : 77,
- MulticastInterface : 78,
- ForwardingFlags : 79,
- FaceInstance : 80,
- ForwardingEntry : 81,
- MulticastTTL : 82,
- MinSuffixComponents : 83,
- MaxSuffixComponents : 84,
- ChildSelector : 85,
- RepositoryInfo : 86,
- Version : 87,
- RepositoryVersion : 88,
- GlobalPrefix : 89,
- LocalName : 90,
- Policy : 91,
- Namespace : 92,
- GlobalPrefixName : 93,
- PolicyVersion : 94,
- KeyValueSet : 95,
- KeyValuePair : 96,
- IntegerValue : 97,
- DecimalValue : 98,
- StringValue : 99,
- BinaryValue : 100,
- NameValue : 101,
- Entry : 102,
- ACL : 103,
- ParameterizedName : 104,
- Prefix : 105,
- Suffix : 106,
- Root : 107,
- ProfileName : 108,
- Parameters : 109,
- InfoString : 110,
- // 111 unallocated
- StatusResponse : 112,
- StatusCode : 113,
- StatusText : 114,
-
- // Sync protocol
- SyncNode : 115,
- SyncNodeKind : 116,
- SyncNodeElement : 117,
- SyncVersion : 118,
- SyncNodeElements : 119,
- SyncContentHash : 120,
- SyncLeafCount : 121,
- SyncTreeDepth : 122,
- SyncByteCount : 123,
- ConfigSlice : 124,
- ConfigSliceList : 125,
- ConfigSliceOp : 126,
-
- // Remember to keep in sync with schema/tagnames.csvsdict
- CCNProtocolDataUnit : 17702112,
- CCNPROTOCOL_DATA_UNIT : "CCNProtocolDataUnit"
-};
-
-var CCNProtocolDTagsStrings = [
- null, null, null, null, null, null, null, null, null, null, null,
- null, null,
- "Any", "Name", "Component", "Certificate", "Collection", "CompleteName",
- "Content", "SignedInfo", "ContentDigest", "ContentHash", null, "Count", "Header",
- "Interest", "Key", "KeyLocator", "KeyName", "Length", "Link", "LinkAuthenticator",
- "NameComponentCount", null, null, "RootDigest", "Signature", "Start", "Timestamp", "Type",
- "Nonce", "Scope", "Exclude", "Bloom", "BloomSeed", null, "AnswerOriginKind",
- "InterestLifetime", null, null, null, null, "Witness", "SignatureBits", "DigestAlgorithm", "BlockSize",
- null, "FreshnessSeconds", "FinalBlockID", "PublisherPublicKeyDigest", "PublisherCertificateDigest",
- "PublisherIssuerKeyDigest", "PublisherIssuerCertificateDigest", "ContentObject",
- "WrappedKey", "WrappingKeyIdentifier", "WrapAlgorithm", "KeyAlgorithm", "Label",
- "EncryptedKey", "EncryptedNonceKey", "WrappingKeyName", "Action", "FaceID", "IPProto",
- "Host", "Port", "MulticastInterface", "ForwardingFlags", "FaceInstance",
- "ForwardingEntry", "MulticastTTL", "MinSuffixComponents", "MaxSuffixComponents", "ChildSelector",
- "RepositoryInfo", "Version", "RepositoryVersion", "GlobalPrefix", "LocalName",
- "Policy", "Namespace", "GlobalPrefixName", "PolicyVersion", "KeyValueSet", "KeyValuePair",
- "IntegerValue", "DecimalValue", "StringValue", "BinaryValue", "NameValue", "Entry",
- "ACL", "ParameterizedName", "Prefix", "Suffix", "Root", "ProfileName", "Parameters",
- "InfoString", null,
- "StatusResponse", "StatusCode", "StatusText", "SyncNode", "SyncNodeKind", "SyncNodeElement",
- "SyncVersion", "SyncNodeElements", "SyncContentHash", "SyncLeafCount", "SyncTreeDepth", "SyncByteCount",
- "ConfigSlice", "ConfigSliceList", "ConfigSliceOp" ];
-
-
-//TESTING
-//console.log(exports.CCNProtocolDTagsStrings[17]);
-
diff --git a/latest/CCNTime.js b/latest/CCNTime.js
deleted file mode 100644
index fc6d2ae..0000000
--- a/latest/CCNTime.js
+++ /dev/null
@@ -1,226 +0,0 @@
-
-var CCNTime = function CCNTime(
- //long
-msec) {
-
-
-
- //byte []
- //this.binarytime = null;
-
-
- this.NANOS_MAX = 999877929;
-
- this.date = new Date(msec);
-};
-
-
-//public CCNTime(long msec) {
- //this((msec/1000) * 1000, (msec % 1000) * 1000000L);
-//}
-
- /**
- * Create a CCNTime
- * @param timestamp source timestamp to initialize from, some precision will be lost
- */
- //public CCNTime(Timestamp timestamp) {
- //this(timestamp.getTime(), timestamp.getNanos());
- //}
-
- /**
- * Create a CCNTime
- * @param time source Date to initialize from, some precision will be lost
- * as CCNTime does not round to unitary milliseconds
- */
-CCNTime.prototype.setDate = function(
- //Date
- date) {
-
- this.date = date;
-};
-
- /**
- * Create a CCNTime from its binary encoding
- * @param binaryTime12 the binary representation of a CCNTime
- */
-CCNTime.prototype.setDateBinary = function(
- //byte []
- binaryTime12) {
-
-
- if ((null == binaryTime12) || (binaryTime12.length == 0)) {
- throw new IllegalArgumentException("Invalid binary time!");
- }
-
-
- value = 0;
- for(i = 0; i < binaryTime12.length; i++) {
- value = value << 8;
- // Java will assume the byte is signed, so extend it and trim it.
- b = (binaryTime12[i]) & 0xFF;
- value |= b;
- }
-
- this.date = new Date(value);
-
-};
-
-//byte[]
-CCNTime.prototype.toBinaryTime = function() {
-
-
-
- return unsignedLongToByteArray(this.date.getTime());
-
-}
-
-unsignedLongToByteArray= function( value) {
- if( 0 == value )
- return [0];
-
- if( 0 <= value && value <= 0x00FF ) {
- //byte []
- bb = new Array[1];
- bb[0] = (value & 0x00FF);
- return bb;
- }
-
-
- //byte []
- out = null;
- //int
- offset = -1;
- for(var i = 7; i >=0; --i) {
- //byte
- b = ((value >> (i * 8)) & 0xFF);
- if( out == null && b != 0 ) {
- out = new Array(i+1);//byte[i+1];
- offset = i;
- }
- if( out != null )
- out[ offset - i ] = b;
- }
- return out;
-}
-
-/**
- * Generate the binary representation of a CCNTime
- * @return the binary representation we use for encoding
- */
-//byte []
-/*CCCCNTime.prototype.toBinaryTime = function() {
-
- if( null == _binarytime ) {
- byte [] b = DataUtils.unsignedLongToByteArray(toBinaryTimeAsLong());
- _binarytime = b;
- }
- return _binarytime;
-};*/
-
- /**
- * Generate the internal long representation of a CCNTime, useful for comparisons
- * and used internally
- * @return the long representation of this time in our internal units
- */
- //public long toBinaryTimeAsLong() {
- //return toBinaryTimeAsLong(getTime(), getNanos());
- //}
-
- /**
- * Static method to convert from milliseconds and nanoseconds to our
- * internal long representation.
- * Assumes that nanos also contains the integral milliseconds for this
- * time. Ignores msec component in msec.
- * @param msec milliseconds
- * @param nanos nanoseconds
- * @return
- */
- //public static long toBinaryTimeAsLong(long msec, long nanos) {
- //long timeVal = (msec / 1000) * 4096L + (nanos * 4096L + 500000000L) / 1000000000L;
- //return timeVal;
- //}
-
- /*protected void setFromBinaryTimeAsLong(long binaryTimeAsLong) {
- _binarytime = null;
- super.setTime((binaryTimeAsLong / 4096L) * 1000L);
- super.setNanos((int)(((binaryTimeAsLong % 4096L) * 1000000000L) / 4096L));
- }*/
-
- /*@Override
- public void setTime(long msec) {
- _binarytime = null;
- long binaryTimeAsLong = toBinaryTimeAsLong((msec/1000) * 1000, (msec % 1000) * 1000000L);
- super.setTime((binaryTimeAsLong / 4096L) * 1000L);
- super.setNanos((int)(((binaryTimeAsLong % 4096L) * 1000000000L) / 4096L));
- }*/
-
- /*@Override
- public void setNanos(int nanos) {
- _binarytime = null;
- int quantizedNanos = (int)(((((nanos * 4096L + 500000000L) / 1000000000L)) * 1000000000L) / 4096L);
- if ((quantizedNanos < 0) || (quantizedNanos > 999999999)) {
- System.out.println("Quantizing nanos " + nanos + " resulted in out of range value " + quantizedNanos + "!");
- }
- super.setNanos(quantizedNanos);
- }*/
-
- /*public void addNanos(int nanos) {
- _binarytime = null;
- setNanos(nanos + getNanos());
- }*/
-
- /*
- public void increment(int timeUnits) {
- _binarytime = null;
- long binaryTimeAsLong = toBinaryTimeAsLong();
- binaryTimeAsLong += timeUnits;
- setFromBinaryTimeAsLong(binaryTimeAsLong);
- }
-
- @Override
- public boolean equals(Timestamp ts) {
- return super.equals(new CCNTime(ts));
- }
-
- @Override
- public int compareTo(Date o) {
- return super.compareTo(new CCNTime(o));
- }
-
- @Override
- public int compareTo(Timestamp ts) {
- return super.compareTo(new CCNTime(ts));
- }
-
- @Override
- public boolean before(Timestamp ts) {
- return super.before(new CCNTime(ts));
- }
-
- @Override
- public boolean after(Timestamp ts) {
- return super.after(new CCNTime(ts));
- }
-
- @Override
- public boolean before(Date when) {
- return super.before(new CCNTime(when));
- }
-
- @Override
- public boolean after(Date when) {
- return super.after(new CCNTime(when));
- }
-
-
- public static CCNTime now() {
- return new CCNTime();
- }
-
-
- public String toShortString() {
- // use . instead of : as URI printer will make it look nicer in the logs
- SimpleDateFormat df = new SimpleDateFormat("yy-MM-dd-HH.mm.ss");
- return df.format(this);
- }
-}*/
diff --git a/latest/ContentName.js b/latest/ContentName.js
deleted file mode 100644
index 9aa90bc..0000000
--- a/latest/ContentName.js
+++ /dev/null
@@ -1,49 +0,0 @@
-
-var ContentName = function ContentName(_Components){
-
-
- this.SCHEME = "ccnx:";
-
- this.ORIGINAL_SCHEME = "ccn:";
-
- this.SEPARATOR = "/";
- this.ROOT = null;
-
- this.Components = _Components;
-};
-
-ContentName.prototype.decode = function(/*XMLDecoder*/ decoder) {
- decoder.readStartElement(this.getElementLabel());
-
-
- this.Components = new Array(); //new ArrayList<byte []>();
-
- while (decoder.peekStartElement(CCNProtocolDTags.Component)) {
- this.add(decoder.readBinaryElement(CCNProtocolDTags.Component));
- }
-
- decoder.readEndElement();
-};
-
-ContentName.prototype.encode = function(/*XMLEncoder*/ encoder) {
- //if (!validate()) {
- //throw new ContentEncodingException("Cannot encode " + this.getClass().getName() + ": field values missing.");
- //}
-
- encoder.writeStartElement(this.getElementLabel());
- var count = this.Components.length;
- for (var i=0; i < count; i++) {
- encoder.writeElement(CCNProtocolDTags.Component, this.Components[i]);
- }
-
- encoder.writeEndElement();
-};
-
-ContentName.prototype.getElementLabel = function(){
- return CCNProtocolDTags.Name;
-};
-
-ContentName.prototype.add = function(param){
- return this.Components.push(param);
-};
-
diff --git a/latest/ContentObject.js b/latest/ContentObject.js
deleted file mode 100644
index 7d1759d..0000000
--- a/latest/ContentObject.js
+++ /dev/null
@@ -1,61 +0,0 @@
-
-var ContentObject = function ContentObject(_Name,_SignedInfo,_Content,_Signature){
-
-
- if (typeof _Name === 'string'){
- var n = new Name(_Name);
- }
- else{
- //TODO Check the class of _Name
- this.Name = _Name;
- }
- this.SignedInfo = _SignedInfo;
- this.Content=_Content;
- this.Signature = _Signature;
-
-};
-
-
-ContentObject.prototype.decode = function(/*XMLDecoder*/ decoder) {
-
- decoder.readStartElement(this.getElementLabel());
-
- this.Signature = new Signature();
- this.Signature.decode(decoder);
-
- this.Name = new ContentName();
- this.Name.decode(decoder);
-
- this.SignedInfo = new SignedInfo();
- this.SignedInfo.decode(decoder);
-
- this.Content = decoder.readBinaryElement(CCNProtocolDTags.Content);
-
- decoder.readEndElement();
-
-};
-
-ContentObject.prototype.encode = function(/*XMLEncoder*/ encoder) {
-
- /*if((null == this.Name) && (null==this.SignedInfo) && (null ==this.Signature)){
-
- throw "Illegal input inside encode of Content Object";
- }*/
- /*
- * if (!validate()) {
- throw new ContentEncodingException("Cannot encode " + this.getClass().getName() + ": field values missing.");
- }*/
-
- encoder.writeStartElement(this.getElementLabel());
-
- if(null!=this.Signature) this.Signature.encode(encoder);
- if(null!=this.Name) this.Name.encode(encoder);
- if(null!=this.SignedInfo) this.SignedInfo.encode(encoder);
-
- encoder.writeElement(CCNProtocolDTags.Content, this.Content);
-
- encoder.writeEndElement();
-
-};
-
-ContentObject.prototype.getElementLabel= function(){return CCNProtocolDTags.ContentObject;};
diff --git a/latest/DateFormat.js b/latest/DateFormat.js
deleted file mode 100644
index 1e63760..0000000
--- a/latest/DateFormat.js
+++ /dev/null
@@ -1,125 +0,0 @@
-/*
- * Date Format 1.2.3
- * (c) 2007-2009 Steven Levithan <stevenlevithan.com>
- * MIT license
- *
- * Includes enhancements by Scott Trenda <scott.trenda.net>
- * and Kris Kowal <cixar.com/~kris.kowal/>
- *
- * Accepts a date, a mask, or a date and a mask.
- * Returns a formatted version of the given date.
- * The date defaults to the current date/time.
- * The mask defaults to dateFormat.masks.default.
- */
-
-var DateFormat = function () {
- var token = /d{1,4}|m{1,4}|yy(?:yy)?|([HhMsTt])\1?|[LloSZ]|"[^"]*"|'[^']*'/g,
- timezone = /\b(?:[PMCEA][SDP]T|(?:Pacific|Mountain|Central|Eastern|Atlantic) (?:Standard|Daylight|Prevailing) Time|(?:GMT|UTC)(?:[-+]\d{4})?)\b/g,
- timezoneClip = /[^-+\dA-Z]/g,
- pad = function (val, len) {
- val = String(val);
- len = len || 2;
- while (val.length < len) val = "0" + val;
- return val;
- };
-
- // Regexes and supporting functions are cached through closure
- return function (date, mask, utc) {
- var dF = dateFormat;
-
- // You can't provide utc if you skip other args (use the "UTC:" mask prefix)
- if (arguments.length == 1 && Object.prototype.toString.call(date) == "[object String]" && !/\d/.test(date)) {
- mask = date;
- date = undefined;
- }
-
- // Passing date through Date applies Date.parse, if necessary
- date = date ? new Date(date) : new Date;
- if (isNaN(date)) throw SyntaxError("invalid date");
-
- mask = String(dF.masks[mask] || mask || dF.masks["default"]);
-
- // Allow setting the utc argument via the mask
- if (mask.slice(0, 4) == "UTC:") {
- mask = mask.slice(4);
- utc = true;
- }
-
- var _ = utc ? "getUTC" : "get",
- d = date[_ + "Date"](),
- D = date[_ + "Day"](),
- m = date[_ + "Month"](),
- y = date[_ + "FullYear"](),
- H = date[_ + "Hours"](),
- M = date[_ + "Minutes"](),
- s = date[_ + "Seconds"](),
- L = date[_ + "Milliseconds"](),
- o = utc ? 0 : date.getTimezoneOffset(),
- flags = {
- d: d,
- dd: pad(d),
- ddd: dF.i18n.dayNames[D],
- dddd: dF.i18n.dayNames[D + 7],
- m: m + 1,
- mm: pad(m + 1),
- mmm: dF.i18n.monthNames[m],
- mmmm: dF.i18n.monthNames[m + 12],
- yy: String(y).slice(2),
- yyyy: y,
- h: H % 12 || 12,
- hh: pad(H % 12 || 12),
- H: H,
- HH: pad(H),
- M: M,
- MM: pad(M),
- s: s,
- ss: pad(s),
- l: pad(L, 3),
- L: pad(L > 99 ? Math.round(L / 10) : L),
- t: H < 12 ? "a" : "p",
- tt: H < 12 ? "am" : "pm",
- T: H < 12 ? "A" : "P",
- TT: H < 12 ? "AM" : "PM",
- Z: utc ? "UTC" : (String(date).match(timezone) || [""]).pop().replace(timezoneClip, ""),
- o: (o > 0 ? "-" : "+") + pad(Math.floor(Math.abs(o) / 60) * 100 + Math.abs(o) % 60, 4),
- S: ["th", "st", "nd", "rd"][d % 10 > 3 ? 0 : (d % 100 - d % 10 != 10) * d % 10]
- };
-
- return mask.replace(token, function ($0) {
- return $0 in flags ? flags[$0] : $0.slice(1, $0.length - 1);
- });
- };
-}();
-
-// Some common format strings
-DateFormat.masks = {
- "default": "ddd mmm dd yyyy HH:MM:ss",
- shortDate: "m/d/yy",
- mediumDate: "mmm d, yyyy",
- longDate: "mmmm d, yyyy",
- fullDate: "dddd, mmmm d, yyyy",
- shortTime: "h:MM TT",
- mediumTime: "h:MM:ss TT",
- longTime: "h:MM:ss TT Z",
- isoDate: "yyyy-mm-dd",
- isoTime: "HH:MM:ss",
- isoDateTime: "yyyy-mm-dd'T'HH:MM:ss",
- isoUtcDateTime: "UTC:yyyy-mm-dd'T'HH:MM:ss'Z'"
-};
-
-// Internationalization strings
-DateFormat.i18n = {
- dayNames: [
- "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat",
- "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"
- ],
- monthNames: [
- "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec",
- "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"
- ]
-};
-
-// For convenience...
-Date.prototype.format = function (mask, utc) {
- return dateFormat(this, mask, utc);
-};
diff --git a/latest/Exclude.js b/latest/Exclude.js
deleted file mode 100644
index 878a6d9..0000000
--- a/latest/Exclude.js
+++ /dev/null
@@ -1,47 +0,0 @@
-
-var Exclude = function Exclude(_Values){
-
- this.OPTIMUM_FILTER_SIZE = 100;
-
-
- this.Values = _Values; //array of elements
-
-}
-
-Exclude.prototype.decode = function(/*XMLDecoder*/ decoder) {
-
-
-
- decoder.readStartElement(this.getElementLabel());
-
- //TODO
- /*var component;
- var any = false;
- while ((component = decoder.peekStartElement(CCNProtocolDTags.Component)) ||
- (any = decoder.peekStartElement(CCNProtocolDTags.Any)) ||
- decoder.peekStartElement(CCNProtocolDTags.Bloom)) {
- var ee = component?new ExcludeComponent(): any ? new ExcludeAny() : new BloomFilter();
- ee.decode(decoder);
- _values.add(ee);
- }*/
-
- decoder.readEndElement();
-
-};
-
-Exclude.prototype.encode=function(/*XMLEncoder*/ encoder) {
- if (!validate()) {
- throw new ContentEncodingException("Cannot encode " + this.getClass().getName() + ": field values missing.");
- }
- // if everything is null, output nothing
- if (empty())
- return;
-
- encoder.writeStartElement(getElementLabel());
-
- encoder.writeEndElement();
-
- };
-
-Exclude.prototype.getElementLabel = function() { return CCNProtocolDTags.Exclude; };
-
diff --git a/latest/ExcludeAny.js b/latest/ExcludeAny.js
deleted file mode 100644
index 898d250..0000000
--- a/latest/ExcludeAny.js
+++ /dev/null
@@ -1,17 +0,0 @@
-
-var ExcludeAny = function ExcludeAny() {
-
-};
-
-ExcludeAny.prototype.decode = function(decoder) {
- decoder.readStartElement(this.getElementLabel());
- decoder.readEndElement();
-};
-
-
-ExcludeAny.prototype.encode = function( encoder) {
- encoder.writeStartElement(this.getElementLabel());
- encoder.writeEndElement();
-};
-
-ExcludeAny.prototype.getElementLabel=function() { return CCNProtocolDTags.Any; };
diff --git a/latest/ExcludeComponent.js b/latest/ExcludeComponent.js
deleted file mode 100644
index 1eac988..0000000
--- a/latest/ExcludeComponent.js
+++ /dev/null
@@ -1,21 +0,0 @@
-
-/*
- * _Body is an array of componenets
- */
-var ExcludeComponent = function ExcludeComponent(_Body) {
-
- //TODO Check BODY is an Array of componenets.
-
- this.Body = _Body
-};
-
-ExcludeComponent.prototype.decode = function( decoder) {
- body = decoder.readBinaryElement(this.getElementLabel());
-};
-
-ExcludeComponent.prototype.encode = function(encoder) {
- encoder.writeElement(this.getElementLabel(), body);
-};
-
-ExcludeComponent.prototype.getElementLabel = function() { return CCNProtocolDTags.Component; };
-
diff --git a/latest/Interest.js b/latest/Interest.js
deleted file mode 100644
index 152704f..0000000
--- a/latest/Interest.js
+++ /dev/null
@@ -1,124 +0,0 @@
-
-var Interest = function Interest(_Name,_MinSuffixComponents,_MaxSuffixComponents,_PublisherPublicKeyDigest, _Exclude, _ChildSelector,_AnswerOriginKind,_Scope,_InterestLifetime,_Nonce){
-
-
- this.Name = _Name;
- this.MaxSuffixComponents = _MaxSuffixComponents;
- this.MinSuffixComponents = _MinSuffixComponents;
-
- this.PublisherKeyDigest = _PublisherPublicKeyDigest;
- this.Exclude = _Exclude;
- this.ChildSelector = _ChildSelector;
- this.AnswerOriginKind = _AnswerOriginKind;
- this.Scope = _Scope;
- this.InterestLifetime = null; // For now we don't have the ability to set an interest lifetime
- this.Nonce = _Nonce;
-
- /*Not sure if the rest is needed*/
- this.Publisher = _Publisher;
-
- this.UserTime=_UserTime;
-
- this.RECURSIVE_POSTFIX = "*";
-
- this.CHILD_SELECTOR_LEFT = 0;
- this.CHILD_SELECTOR_RIGHT = 1;
- this.ANSWER_CONTENT_STORE = 1;
- this.ANSWER_GENERATED = 2;
- this.ANSWER_STALE = 4; // Stale answer OK
- this.MARK_STALE = 16; // Must have Scope 0. Michael calls this a "hack"
-
- this.DEFAULT_ANSWER_ORIGIN_KIND = ANSWER_CONTENT_STORE | ANSWER_GENERATED;
-
-
-};
-
-Interest.prototype.decode = function(/*XMLDecoder*/ decoder) {
-
- decoder.readStartElement(CCNProtocolDTags.Interest);
-
- this.Name = new ContentName();
- this.Name.decode(decoder);
-
- if (decoder.peekStartElement(CCNProtocolDTags.MinSuffixComponents)) {
- this.MinSuffixComponents = decoder.readIntegerElement(CCNProtocolDTags.MinSuffixComponents);
- }
-
- if (decoder.peekStartElement(CCNProtocolDTags.MaxSuffixComponents)) {
- this.MaxSuffixComponents = decoder.readIntegerElement(CCNProtocolDTags.MaxSuffixComponents);
- }
-
- //TODO something about that guy
- /*if (PublisherID.peek(decoder)) {
- this.Publisher = new PublisherID();
- this.Publisher.decode(decoder);
- }*/
-
- if (decoder.peekStartElement(CCNProtocolDTags.Exclude)) {
- this.Exclude = new Exclude();
- this.Exclude.decode(decoder);
- }
-
- if (decoder.peekStartElement(CCNProtocolDTags.ChildSelector)) {
- this.ChildSelector = decoder.readIntegerElement(CCNProtocolDTags.ChildSelector);
- }
-
- if (decoder.peekStartElement(CCNProtocolDTags.AnswerOriginKind)) {
- // call setter to handle defaulting
- this.AnswerOriginKind = decoder.readIntegerElement(CCNProtocolDTags.AnswerOriginKind);
- }
-
- if (decoder.peekStartElement(CCNProtocolDTags.Scope)) {
- this.Scope = decoder.readIntegerElement(CCNProtocolDTags.Scope);
- }
-
- if (decoder.peekStartElement(CCNProtocolDTags.InterestLifetime)) {
- this.InterestLifetime = decoder.readBinaryElement(CCNProtocolDTags.InterestLifetime);
- }
-
- if (decoder.peekStartElement(CCNProtocolDTags.Nonce)) {
- this.Nonce = decoder.readBinaryElement(CCNProtocolDTags.Nonce);
- }
-
- decoder.readEndElement();
-};
-
-
-Interest.prototype.encode = function(/*XMLEncoder*/ encoder){
- if (!validate()) {
- throw new ContentEncodingException("Cannot encode " + this.getClass().getName() + ": field values missing.");
- }
-
- encoder.writeStartElement(CCNProtocolDTags.Interest);
-
- this.Name.encode(encoder);
-
- if (null != this.MinSuffixComponents)
- encoder.writeElement(CCNProtocolDTags.MinSuffixComponents, this.MinSuffixComponents);
-
- if (null != this.MaxSuffixComponents)
- encoder.writeElement(CCNProtocolDTags.MaxSuffixComponents, this.MaxSuffixComponents);
-
- //TODO
-
- /*if (null != this.PublisherID)
- publisherID().encode(encoder);*/
-
- //if (null != this.Exclude)
- //exclude().encode(encoder);
-
- if (null != this.ChildSelector)
- encoder.writeElement(CCNProtocolDTags.ChildSelector, this.ChildSelector);
-
- if (this.DEFAULT_ANSWER_ORIGIN_KIND != this.AnswerOriginKind)
- encoder.writeElement(CCNProtocolDTags.AnswerOriginKind, this.AnswerOriginKind);
-
- if (null != this.Scope)
- encoder.writeElement(CCNProtocolDTags.Scope, this.Scope);
-
- if (null != this.Nonce)
- encoder.writeElement(CCNProtocolDTags.Nonce, this.Nonce);
-
- encoder.writeEndElement();
-};
-
diff --git a/latest/JavaSocketBridge.jar b/latest/JavaSocketBridge.jar
deleted file mode 100644
index 56ef77b..0000000
--- a/latest/JavaSocketBridge.jar
+++ /dev/null
Binary files differ
diff --git a/latest/KeyLocator.js b/latest/KeyLocator.js
deleted file mode 100644
index 73c95fb..0000000
--- a/latest/KeyLocator.js
+++ /dev/null
@@ -1,119 +0,0 @@
-
-
-
-
-
-var KeyLocatorType = {
- NAME:1,
- KEY:2,
- CERTIFICATE:3
-};
-
-var KeyLocator = function KeyLocator(_Input,_Type){
-
- //this.KeyName = _KeyName;
- //this.PublicKey = _PublicKey;
- //this.Certificate = _Certificate;
-
- this.Type=_Type;
-
- if (_Type==KeyLocatorType.NAME){
- this.KeyName = _Input;
- }
- else if(_Type==KeyLocatorType.KEY){
- this.PublicKey = _Input;
- }
- else if(_Type==KeyLocatorType.CERTIFICATE){
- this.Certificate = _Input;
- }
-
-};
-
-KeyLocator.prototype.decode = function(decoder) {
-
- decoder.readStartElement(this.getElementLabel());
-
- if (decoder.peekStartElement(CCNProtocolDTags.Key)) {
- try {
- encodedKey = decoder.readBinaryElement(CCNProtocolDTags.Key);
- // This is a DER-encoded SubjectPublicKeyInfo.
-
- //TODO FIX THIS, SHOULDN'T be like that
- this.Key = encodedKey;//CryptoUtil.getPublicKey(encodedKey);
-
- this.PublicKey = encodedKey;
-
-
- } catch (e) {
- console.log("Cannot parse stored key: error: " + e);
- throw new ContentDecodingException("Cannot parse key: ", e);
- }
-
- if (null == this.Key) {
- throw new Exception("Cannot parse key: ");
- }
-
- } else if ( decoder.peekStartElement(CCNProtocolDTags.Certificate)) {
- try {
- encodedCert = decoder.readBinaryElement(CCNProtocolDTags.Certificate);
-
- /*
- * Certificates not yet working
- */
-
- //CertificateFactory factory = CertificateFactory.getInstance("X.509");
- //this.Certificate = (X509Certificate) factory.generateCertificate(new ByteArrayInputStream(encodedCert));
-
- } catch ( e) {
- throw new Exception("Cannot decode certificate: " + e);
- }
- if (null == this.Certificate) {
- throw new Exception("Cannot parse certificate! ");
- }
- } else {
- this.KeyName = new KeyName();
- this.KeyName.decode(decoder);
- }
- decoder.readEndElement();
- }
-
-
- KeyLocator.prototype.encode = function( encoder) {
- /*if (!validate()) {
- throw new ContentEncodingException("Cannot encode " + this.getClass().getName() + ": field values missing.");
- }*/
-
-
- //TODO FIX THIS TOO
- encoder.writeStartElement(this.getElementLabel());
-
- if (this._Type == KeyLocatorType.KEY) {
- console.log('HERE');
-
- encoder.writeElement(CCNProtocolDTags.Key, this.PublicKey);
-
- } else if (this.Type == KeyLocatorType.CERTIFICATE) {
- console.log('NO HERE');
-
- try {
- encoder.writeElement(CCNProtocolDTags.Certificate, this.Certificate.getEncoded());
- } catch ( e) {
- throw new Exception("CertificateEncodingException attempting to write key locator: " + e);
- }
-
- } else if (this.Type == KeyLocatorType.NAME) {
- console.log('ACTUALLY HERE');
- this.KeyName.encode(encoder);
- }
- encoder.writeEndElement();
-
-};
-
-KeyLocator.prototype.getElementLabel = function() {
- return CCNProtocolDTags.KeyLocator;
-};
-
-KeyLocator.prototype.validate = function() {
- return ( (null != this.keyName) || (null != this.PublicKey) || (null != this.Certificate) );
-};
-
\ No newline at end of file
diff --git a/latest/KeyName.js b/latest/KeyName.js
deleted file mode 100644
index 9c9ba93..0000000
--- a/latest/KeyName.js
+++ /dev/null
@@ -1,48 +0,0 @@
-
-
-var KeyName = function KeyName() {
-
-
- this.ContentName = this.ContentName;//ContentName
- this.PublisherID =this.PublisherID;//PublisherID
-
-};
-
-
-KeyName.prototype.decode=function( decoder){
-
-
- decoder.readStartElement(this.getElementLabel());
-
- this.ContentName = new ContentName();
- this.ContentName.decode(decoder);
-
- if (PublisherID.peek(decoder)) {
- this.PublisherID = new PublisherID();
- this.PublisherID.decode(decoder);
- }
-
- decoder.readEndElement();
-};
-
-KeyName.prototype.encode = function( encoder) {
- if (!this.validate()) {
- throw new Exception("Cannot encode : field values missing.");
- }
-
- encoder.writeStartElement(this.getElementLabel());
-
- this.ContentName.encode(encoder);
- if (null != this.PublisherID)
- this.PublisherID.encode(encoder);
-
- encoder.writeEndElement();
-};
-
-KeyName.prototype.getElementLabel = function() { return CCNProtocolDTags.KeyName; };
-
-KeyName.prototype.validate = function() {
- // DKS -- do we do recursive validation?
- // null signedInfo ok
- return (null != this.ContentName);
-};
diff --git a/latest/PublisherID.js b/latest/PublisherID.js
deleted file mode 100644
index dd90aab..0000000
--- a/latest/PublisherID.js
+++ /dev/null
@@ -1,73 +0,0 @@
-
-
-var PublisherType = function PublisherType(_tag){
- this.KEY =(CCNProtocolDTags.PublisherPublicKeyDigest);
- this.CERTIFICATE= (CCNProtocolDTags.PublisherCertificateDigest);
- this.ISSUER_KEY= (CCNProtocolDTags.PublisherIssuerKeyDigest);
- this.ISSUER_CERTIFICATE =(CCNProtocolDTags.PublisherIssuerCertificateDigest);
-
- this.Tag = _tag;
-};
-PublisherType.prototype.isTypeTagVal = function(tagVal) {
- if ((tagVal == CCNProtocolDTags.PublisherPublicKeyDigest) ||
- (tagVal == CCNProtocolDTags.PublisherCertificateDigest) ||
- (tagVal == CCNProtocolDTags.PublisherIssuerKeyDigest) ||
- (tagVal == CCNProtocolDTags.PublisherIssuerCertificateDigest)) {
- return true;
- }
- return false;
-};
-
-
-var PublisherID = function PublisherID() {
-
- this.PUBLISHER_ID_DIGEST_ALGORITHM = "SHA-256";
- this.PUBLISHER_ID_LEN = 256/8;
-
-
- this.PublisherID = generatePublicKeyDigest(key);//ByteArray
- //CryptoUtil.generateKeyID(PUBLISHER_ID_DIGEST_ALGORITHM, key);
- this.PublisherType = isIssuer ? PublisherType.ISSUER_KEY : PublisherType.KEY;//publisher Type
-
-};
-
-
-PublisherID.prototype.decode = function(decoder) {
-
- // We have a choice here of one of 4 binary element types.
- var nextTag = decoder.peekStartElementAsLong();
-
- if (null == nextTag) {
- throw new Exception("Cannot parse publisher ID.");
- }
-
- this.PublisherType = new PublisherType(nextTag);
-
- if (!this.PublisherType.isTypeTagVal(nextTag)) {
- throw new Exception("Invalid publisher ID, got unexpected type: " + nextTag);
- }
- this.PublisherID = decoder.readBinaryElement(nextTag);
- if (null == _publisherID) {
- throw new ContentDecodingException("Cannot parse publisher ID of type : " + nextTag + ".");
- }
-};
-
-PublisherID.prototype.encode = function(encoder) {
- if (!this.validate()) {
- throw new Exception("Cannot encode " + this.getClass().getName() + ": field values missing.");
- }
-
- encoder.writeElement(this.getElementLabel(), this.PublisherID);
-};
-
-PublisherID.prototype.getElementLabel = function() {
- return this.PublisherType.Tag;
-};
-
-
-PublisherID.prototype.validate = function(){
- return ((null != id() && (null != type())));
-};
-
-
-
diff --git a/latest/PublisherPublicKeyDigest.js b/latest/PublisherPublicKeyDigest.js
deleted file mode 100644
index f60c649..0000000
--- a/latest/PublisherPublicKeyDigest.js
+++ /dev/null
@@ -1,32 +0,0 @@
-
-var PublisherPublicKeyDigest = function PublisherPublicKeyDigest(_pkd){
-
- if( typeof _pkd == "ByteArray") this.PublisherPublicKeyDigest = _pkd; // Byte Array
- else if( typeof _pkd == "PublicKey") ;//TODO...
-
-};
-
-PublisherPublicKeyDigest.prototype.decode = function( decoder) {
-
- this.PublisherPublicKeyDigest = decoder.readBinaryElement(this.getElementLabel());
- if (null == this.PublisherPublicKeyDigest) {
- throw new Exception("Cannot parse publisher key digest.");
- }
- /*if (this.PublisherPublicKeyDigest.length != PublisherID.PUBLISHER_ID_LEN) {
- console.log('SHOULD NOT GO HERE !!!!!!!!!!!!!!!!!!');
- this.PublisherPublicKeyDigest = new PublisherPublicKeyDigest(this.PublisherPublicKeyDigest).PublisherKeyDigest;
- }*/
- };
-
-PublisherPublicKeyDigest.prototype.encode= function( encoder) {
- /*if (!this.validate()) {
- throw new Exception("Cannot encode : field values missing.");
- }*/
- if (this.PublisherKeyDigest!=null)this.encoder.writeElement(this.getElementLabel(), this.PublisherKeyDigest);
-};
-
-PublisherPublicKeyDigest.prototype.getElementLabel = function() { return CCNProtocolDTags.PublisherPublicKeyDigest; };
-
-PublisherPublicKeyDigest.prototype.validate =function() {
- return (null != this.PublisherKeyDigest);
-};
diff --git a/latest/Signature.js b/latest/Signature.js
deleted file mode 100644
index c562711..0000000
--- a/latest/Signature.js
+++ /dev/null
@@ -1,53 +0,0 @@
-
-
-var Signature = function Signature(_Witness,_Signature,_DigestAlgorithm) {
-
- this.Witness = _Witness;//byte [] _witness;
- this.Signature = _Signature;//byte [] _signature;
- this.DigestAlgorithm = _DigestAlgorithm//String _digestAlgorithm;
-};
-
-
-Signature.prototype.decode =function( decoder) {
- decoder.readStartElement(this.getElementLabel());
- if (decoder.peekStartElement(CCNProtocolDTags.DigestAlgorithm)) {
- this.DigestAlgorithm = decoder.readUTF8Element(CCNProtocolDTags.DigestAlgorithm);
- }
- if (decoder.peekStartElement(CCNProtocolDTags.Witness)) {
- this.Witness = decoder.readBinaryElement(CCNProtocolDTags.Witness);
- }
- this.Signature = decoder.readBinaryElement(CCNProtocolDTags.SignatureBits);
- decoder.readEndElement();
-
-};
-
-
-Signature.prototype.encode= function( encoder){
-
- if (!this.validate()) {
- throw new Exception("Cannot encode: field values missing.");
- }
-
- encoder.writeStartElement(this.getElementLabel());
-
- if ((null != this.DigestAlgorithm) && (!this.DigestAlgorithm.equals(CCNDigestHelper.DEFAULT_DIGEST_ALGORITHM))) {
- encoder.writeElement(CCNProtocolDTags.DigestAlgorithm, OIDLookup.getDigestOID(this.DigestAlgorithm));
- }
-
- if (null != this.Witness) {
- // needs to handle null witness
- encoder.writeElement(CCNProtocolDTags.Witness, this.Witness);
- }
-
- encoder.writeElement(CCNProtocolDTags.SignatureBits, this.Signature);
-
- encoder.writeEndElement();
-};
-
-Signature.prototype.getElementLabel = function() { return CCNProtocolDTags.Signature; };
-
-
-Signature.prototype.validate = function() {
- return null != this.Signature;
-};
-
diff --git a/latest/SignedInfo.js b/latest/SignedInfo.js
deleted file mode 100644
index 9c7f61e..0000000
--- a/latest/SignedInfo.js
+++ /dev/null
@@ -1,113 +0,0 @@
-
-var ContentType = {DATA:0, ENCR:1, GONE:2, KEY:3, LINK:4, NACK:5};
-
-var ContentTypeValue = {0:0x0C04C0, 1:0x10D091,2:0x18E344,3:0x28463F,4:0x2C834A,5:0x34008A};
-var ContentTypeValueReverse = {0x0C04C0:0, 0x10D091:1,0x18E344:2,0x28463F:3,0x2C834A:4,0x34008A:5};
-
-
-var SignedInfo = function SignedInfo(_publisher,_timestamp,_type,_locator,_freshnessSeconds,_finalBlockID){
-
- //TODO, Check types
-
- this.Publisher = _publisher; //PublisherPublicKeyDigest
- this.Timestamp=_timestamp; // CCN Time
- this.Type=_type; // ContentType
- this.Locator =_locator;//KeyLocator
- this.FreshnessSeconds =_freshnessSeconds; // Integer
- this.FinalBlockID=_finalBlockID; //byte array
-
-};
-
-//exports.SignedInfo.Working;
-
-
-SignedInfo.prototype.decode = function( decoder){
-
- decoder.readStartElement( this.getElementLabel() );
-
- if (decoder.peekStartElement(CCNProtocolDTags.PublisherPublicKeyDigest)) {
- this.Publisher = new PublisherPublicKeyDigest();
- this.Publisher.decode(decoder);
- }
-
- if (decoder.peekStartElement(CCNProtocolDTags.Timestamp)) {
- this.Timestamp = decoder.readDateTime(CCNProtocolDTags.Timestamp);
- }
-
- if (decoder.peekStartElement(CCNProtocolDTags.Type)) {
- binType = decoder.readBinaryElement(CCNProtocolDTags.Type);//byte []
- //TODO Implement valueToType
-
- this.Type = valueToType(binType);
- //console.log('GOT HERRRRRRRRRRRRRRRRRE');
- //console.log(binType);
- if (null == this.Type) {
- throw new Exception("Cannot parse signedInfo type: bytes.");
- }
-
- } else {
- this.Type = ContentType.DATA; // default
- }
-
- if (decoder.peekStartElement(CCNProtocolDTags.FreshnessSeconds)) {
- this.FreshnessSeconds = decoder.readIntegerElement(CCNProtocolDTags.FreshnessSeconds);
- }
-
- if (decoder.peekStartElement(CCNProtocolDTags.FinalBlockID)) {
- this.FinalBlockID = decoder.readBinaryElement(CCNProtocolDTags.FinalBlockID);
- }
-
- if (decoder.peekStartElement(CCNProtocolDTags.KeyLocator)) {
- this.Locator = new KeyLocator();
- this.Locator.decode(decoder);
- }
-
- decoder.readEndElement();
-};
-
-SignedInfo.prototype.encode = function( encoder) {
- if (!this.validate()) {
- throw new Exception("Cannot encode : field values missing.");
- }
- encoder.writeStartElement(this.getElementLabel());
-
- if (null!=this.Publisher) {
- this.Publisher.encode(encoder);
- }
-
- if (null!=this.Timestamp) {
- encoder.writeDateTime(CCNProtocolDTags.Timestamp, this.Timestamp);
- }
-
- if (null!=this.Type && this.Type !=0) {
-
- encoder.writeElement(CCNProtocolDTags.Type, this.Type);
- }
-
- if (null!=this.FreshnessSeconds) {
- encoder.writeElement(CCNProtocolDTags.FreshnessSeconds, this.FreshnessSeconds);
- }
-
- if (null!=this.FinalBlockID) {
- encoder.writeElement(CCNProtocolDTags.FinalBlockID, this.FinalBlockID);
- }
-
- if (null!=this.Locator) {
- this.Locator.encode(encoder);
- }
-
- encoder.writeEndElement();
-};
-
-SignedInfo.prototype.getElementLabel = function() {
- return CCNProtocolDTags.SignedInfo;
-};
-
-SignedInfo.prototype.validate = function() {
- // We don't do partial matches any more, even though encoder/decoder
- // is still pretty generous.
- if (null ==this.Publisher || null==this.Timestamp ||null== this.Locator)
- return false;
- return true;
- };
-
diff --git a/latest/encoding/BinaryXMLCodec.js b/latest/encoding/BinaryXMLCodec.js
deleted file mode 100644
index 349f4e5..0000000
--- a/latest/encoding/BinaryXMLCodec.js
+++ /dev/null
@@ -1,338 +0,0 @@
-
-var XML_EXT = 0x00;
-
-var XML_TAG = 0x01;
-
-var XML_DTAG = 0x02;
-
-var XML_ATTR = 0x03;
-
-var XML_DATTR = 0x04;
-
-var XML_BLOB = 0x05;
-
-var XML_UDATA = 0x06;
-
-var XML_CLOSE = 0x0;
-
-var XML_SUBTYPE_PROCESSING_INSTRUCTIONS = 16;
-
-
-var XML_TT_BITS = 3;
-var XML_TT_MASK = ((1 << XML_TT_BITS) - 1);
-var XML_TT_VAL_BITS = XML_TT_BITS + 1;
-var XML_TT_VAL_MASK = ((1 << (XML_TT_VAL_BITS)) - 1);
-var XML_REG_VAL_BITS = 7;
-var XML_REG_VAL_MASK = ((1 << XML_REG_VAL_BITS) - 1);
-var XML_TT_NO_MORE = (1 << XML_REG_VAL_BITS); // 0x80
-var BYTE_MASK = 0xFF;
-var LONG_BYTES = 8;
-var LONG_BITS = 64;
-
-var bits_11 = 0x0000007FF;
-var bits_18 = 0x00003FFFF;
-var bits_32 = 0x0FFFFFFFF;
-
-
-var TypeAndVal = function TypeAndVal(_type,_val) {
- this.type = _type;
- this.val = _val;
-
-};
-
-var BinaryXMLCodec = function BinaryXMLCodec(){
- this.CODEC_NAME = "Binary";
-};
-
-BinaryXMLCodec.prototype.encodeTypeAndValOffset = function(
- //int
- type,
- //long
- val,
- //byte []
- buf,
- //int
- offset) {
-
- if ((type > XML_UDATA) || (type < 0) || (val < 0)) {
- throw new Exception("Tag and value must be positive, and tag valid.");
- }
-
- // Encode backwards. Calculate how many bytes we need:
- var/*int*/ numEncodingBytes = numEncodingBytes(val);
-
- if ((offset + numEncodingBytes) > buf.length) {
- throw new Exception("Buffer space of " + (buf.length-offset) +
- " bytes insufficient to hold " +
- numEncodingBytes + " of encoded type and value.");
- }
-
-
- buf[offset + numEncodingBytes - 1] =
- (BYTE_MASK &
- (((XML_TT_MASK & type) |
- ((XML_TT_VAL_MASK & val) << XML_TT_BITS))) |
- XML_TT_NO_MORE);
- val = val >>> XML_TT_VAL_BITS;;
-
- var /*int*/ i = offset + numEncodingBytes - 2;
- while ((0 != val) && (i >= offset)) {
- buf[i] = (BYTE_MASK &
- (val & XML_REG_VAL_MASK));
- val = val >>> XML_REG_VAL_BITS;
- --i;
- }
-
- return numEncodingBytes;
-};
-
-//BinaryXMLCodec.prototype.encodeTypeAndVal = function(
- // //final int
- //type,
- //final long
- //value,
- //final OutputStream
- //ostream,
- //offset){
-
- /*
- We exploit the fact that encoding is done from the right, so this actually means
- there is a deterministic encoding from a long to a Type/Value pair:
-
- | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 |
- |ABCD.EFGH|IJKL.MNOP|QRST.UVWX|YZ01.2345|6789.abcd|efgh.ijkl|mnop.qrst|uvwx.yz@#
-
- 60> 53> 46> 39> 32> 25> 18> 11> 4>
- |_000.ABCD|_EFG.HIJK|_LMN.OPQR|_STU.VWXY|_Z01.2345|_678.9abc|_defg.hij|_klm.nopq|_rst.uvwx|_yz@#___
-
- What we want to do is compute the result in MSB order and write it directly
- to the channel without any intermediate form.
- */
-
- //var/*int*/ bits;
- //var/*int*/ count = 0;
-
- // once we start writing bits, we keep writing bits even if they are "0"
- // var/*bool*/ writing = false;
-
- // a few heuristic to catch the small-bit length patterns
- /*if( value < 0 || value > 15 ) {
- var start = 60;
- if( 0 <= value ) {
- if( value < bits_11 )
- start = 4;
- else if( value < bits_18 )
- start = 11;
- else if( value < bits_32 )
- start = 25;
- }
-
- for( var i = start; i >= 4; i -= 7) {
- bits = (value >>> i) & BinaryXMLCodec.XML_REG_VAL_MASK;
- if( bits != 0 || writing ) {
- ostream.write(bits);
- count++;
- writing = true;
- }
- }
- }
-
- // Explicit computation of the bottom byte
- bits = type & BinaryXMLCodec.XML_TT_MASK;
- var bottom4 = value & BinaryXMLCodec.XML_TT_VAL_MASK;
- bits |= bottom4 << BinaryXMLCodec.XML_TT_BITS;
- // the bottom byte always has the NO_MORE flag
- bits |= BinaryXMLCodec.XML_TT_NO_MORE;
-
- //console.log(ostream.constructor.name);
- //console.log(ostream);
-
- //ostream.writable = true;
- //console.log(ostream.)
- ostream.write(bits.toString());
-
- count++;
-
-// byte [] encoding = encodeTypeAndVal(tag, val);
-// ostream.write(encoding);
- return count;
-
-}*/
-
-
-BinaryXMLCodec.prototype.encodeTypeAndVal = function(
- //int
- type,
- //long
- val,
- //byte []
- buf,
- //int
- offset) {
-
- if ((type > XML_UDATA) || (type < 0) || (val < 0)) {
- throw new Exception("Tag and value must be positive, and tag valid.");
- }
-
- // Encode backwards. Calculate how many bytes we need:
- //int
- var numEncodingBytes = numEncodingBytes(val);
-
- if ((offset + numEncodingBytes) > buf.length) {
- throw new Exception("Buffer space of " + (buf.length-offset) +
- " bytes insufficient to hold " +
- numEncodingBytes + " of encoded type and value.");
- }
-
- // Bottom 4 bits of val go in last byte with tag.
- buf[offset + numEncodingBytes - 1] =
- //(byte)
- (BYTE_MASK &
- (((XML_TT_MASK & type) |
- ((XML_TT_VAL_MASK & val) << XML_TT_BITS))) |
- XML_TT_NO_MORE); // set top bit for last byte
- val = val >>> XML_TT_VAL_BITS;;
-
- // Rest of val goes into preceding bytes, 7 bits per byte, top bit
- // is "more" flag.
- var i = offset + numEncodingBytes - 2;
- while ((0 != val) && (i >= offset)) {
- buf[i] = //(byte)
- (BYTE_MASK &
- (val & XML_REG_VAL_MASK)); // leave top bit unset
- val = val >>> XML_REG_VAL_BITS;
- --i;
- }
- if (val != 0) {
- throw new Exception( "This should not happen: miscalculated encoding");
- //Log.warning(Log.FAC_ENCODING, "This should not happen: miscalculated encoding length, have " + val + " left.");
- }
-
- return numEncodingBytes;
-}
-
-
-
-BinaryXMLCodec.prototype.decodeTypeAndVal = function(
- /*InputStream*/
- istream) {
-
- /*int*/next;
- /*int*/type = -1;
- /*long*/val = 0;
- /*boolean*/more = true;
-
- do {
- next = istream.read();
-
- if (next < 0) {
- return null;
- }
-
- if ((0 == next) && (0 == val)) {
- return null;
- }
-
- more = (0 == (next & XML_TT_NO_MORE));
-
- if (more) {
- val = val << XML_REG_VAL_BITS;
- val |= (next & XML_REG_VAL_MASK);
- } else {
-
- type = next & XML_TT_MASK;
- val = val << XML_TT_VAL_BITS;
- val |= ((next >>> XML_TT_BITS) & XML_TT_VAL_MASK);
- }
-
- } while (more);
-
- return new TypeAndVal(type, val);
-};
-
-BinaryXMLCodec.prototype.encodeUString = function(
- //OutputStream
- ostream,
- //String
- ustring,
- //byte
- type,
- offset) {
-
- // We elide the encoding of a 0-length UString
- if ((null == ustring) || (ustring.length == 0)) {
- //if (Log.isLoggable(Log.FAC_ENCODING, Level.FINER))
- //Log.finer(Log.FAC_ENCODING, "Eliding 0-length UString.");
- return;
- }
-
- //byte [] data utils
- /*custom*/
- //byte[]
- strBytes = new Array(ustring.Length);
- var i = 0;
- for( ;i<ustring.lengh;i++) //in InStr.ToCharArray())
- {
- strBytes[i] = ustring[i];
- }
- //strBytes = DataUtils.getBytesFromUTF8String(ustring);
-
- this.encodeTypeAndVal(type,
- (((type == XML_TAG) || (type == XML_ATTR)) ?
- (strBytes.length-1) :
- strBytes.length), ostream);
- //
- console.log(strBytes.toString());
-
- ostream.write(strBytes.toString(),offset);
-
- //
-};
-
-BinaryXMLCodec.prototype.encodeBlob = function(
- //OutputStream
- ostream,
- //byte []
- blob,
- //int
- offset,
- //int
- length) {
- // We elide the encoding of a 0-length blob
- if ((null == blob) || (length == 0)) {
-
- return;
- }
-
- encodeTypeAndVal(XML_BLOB, length, ostream,offset);
- if (null != blob) {
- ostream.write(blob, this.offset, length);
- this.offset += length;
- }
-};
-
-
-var ENCODING_LIMIT_1_BYTE = ((1 << (XML_TT_VAL_BITS)) - 1);
-var ENCODING_LIMIT_2_BYTES = ((1 << (XML_TT_VAL_BITS + XML_REG_VAL_BITS)) - 1);
-var ENCODING_LIMIT_3_BYTES = ((1 << (XML_TT_VAL_BITS + 2 * XML_REG_VAL_BITS)) - 1);
-
-var numEncodingBytes = function(
- //long
- x) {
- if (x <= ENCODING_LIMIT_1_BYTE) return (1);
- if (x <= ENCODING_LIMIT_2_BYTES) return (2);
- if (x <= ENCODING_LIMIT_3_BYTES) return (3);
-
- var numbytes = 1;
-
- // Last byte gives you XML_TT_VAL_BITS
- // Remainder each give you XML_REG_VAL_BITS
- x = x >>> XML_TT_VAL_BITS;
- while (x != 0) {
- numbytes++;
- x = x >>> XML_REG_VAL_BITS;
- }
- return (numbytes);
-}
-
-//TODO
\ No newline at end of file
diff --git a/latest/encoding/BinaryXMLDecoder.js b/latest/encoding/BinaryXMLDecoder.js
deleted file mode 100644
index 87a3530..0000000
--- a/latest/encoding/BinaryXMLDecoder.js
+++ /dev/null
@@ -1,812 +0,0 @@
-//TODO:go back on DEBUG stuff
-//MARK LENGTH STUFF NOT SURE WHAT IT"S ABOUT
-//PUSH instead of PUT on attributes
-var XML_EXT = 0x00;
-
-var XML_TAG = 0x01;
-
-var XML_DTAG = 0x02;
-
-var XML_ATTR = 0x03;
-
-var XML_DATTR = 0x04;
-
-var XML_BLOB = 0x05;
-
-var XML_UDATA = 0x06;
-
-var XML_CLOSE = 0x0;
-
-var XML_SUBTYPE_PROCESSING_INSTRUCTIONS = 16;
-
-
-var XML_TT_BITS = 3;
-var XML_TT_MASK = ((1 << XML_TT_BITS) - 1);
-var XML_TT_VAL_BITS = XML_TT_BITS + 1;
-var XML_TT_VAL_MASK = ((1 << (XML_TT_VAL_BITS)) - 1);
-var XML_REG_VAL_BITS = 7;
-var XML_REG_VAL_MASK = ((1 << XML_REG_VAL_BITS) - 1);
-var XML_TT_NO_MORE = (1 << XML_REG_VAL_BITS); // 0x80
-var BYTE_MASK = 0xFF;
-var LONG_BYTES = 8;
-var LONG_BITS = 64;
-
-var bits_11 = 0x0000007FF;
-var bits_18 = 0x00003FFFF;
-var bits_32 = 0x0FFFFFFFF;
-
-
-
-//returns a string
-tagToString = function(/*long*/ tagVal) {
- if ((tagVal >= 0) && (tagVal < CCNProtocolDTagsStrings.length)) {
- return CCNProtocolDTagsStrings[tagVal];
- } else if (tagVal == CCNProtocolDTags.CCNProtocolDataUnit) {
- return CCNProtocolDTags.CCNPROTOCOL_DATA_UNIT;
- }
- return null;
-};
-
-//returns a Long
-stringToTag = function(/*String*/ tagName) {
- // the slow way, but right now we don't care.... want a static lookup for the forward direction
- for (var i=0; i < CCNProtocolDTagsStrings.length; ++i) {
- if ((null != CCNProtocolDTagsStrings[i]) && (CCNProtocolDTagsStrings[i] == tagName)) {
- return i;
- }
- }
- if (CCNProtocolDTags.CCNPROTOCOL_DATA_UNIT == tagName) {
- return CCNProtocolDTags.CCNProtocolDataUnit;
- }
- return null;
-};
-
-//console.log(stringToTag(64));
-var BinaryXMLDecoder = function BinaryXMLDecoder(istream){
- var MARK_LEN=512;
- var DEBUG_MAX_LEN = 32768;
-
- this.istream = istream;
- //console.log('istream is '+ this.istream);
- this.offset = 0;
-};
-
-
-BinaryXMLDecoder.prototype.readStartElement =function(
- //String
- startTag,
- //TreeMap<String, String>
- attributes) {
-
- try {
- //this.TypeAndVal
- tv = this.decodeTypeAndVal(this.istream);
-
- if (null == tv) {
- throw new Exception("Expected start element: " + startTag + " got something not a tag.");
- }
-
- //String
- decodedTag = null;
-
- if (tv.type() == XML_TAG) {
-
- decodedTag = this.decodeUString(this.Istream, tv.val()+1);
-
- } else if (tv.type() == XML_DTAG) {
- decodedTag = tagToString(tv.val());
- }
-
- if ((null == decodedTag) || decodedTag != startTag) {
- throw new Exception("Expected start element: " + startTag + " got: " + decodedTag + "(" + tv.val() + ")");
- }
-
- if (null != attributes) {
- readAttributes(attributes);
- }
-
- } catch (e) {
- throw new Exception("readStartElement", e);
- }
-};
-
-BinaryXMLDecoder.prototype.readAttributes = function(
- //TreeMap<String,String>
- attributes){
-
- if (null == attributes) {
- return;
- }
-
- try {
-
- //this.TypeAndVal
- nextTV = this.peekTypeAndVal(this.istream);
-
- while ((null != nextTV) && ((XML_ATTR == nextTV.type()) ||
- (XML_DATTR == nextTV.type()))) {
-
- //this.TypeAndVal
- thisTV = this.decodeTypeAndVal(this.Istream);
-
- var attributeName = null;
- if (XML_ATTR == thisTV.type()) {
-
- attributeName = this.decodeUString(this.istream, thisTV.val()+1);
-
- } else if (XML_DATTR == thisTV.type()) {
- // DKS TODO are attributes same or different dictionary?
- attributeName = tagToString(thisTV.val());
- if (null == attributeName) {
- throw new ContentDecodingException("Unknown DATTR value" + thisTV.val());
- }
- }
-
- var attributeValue = this.decodeUString(this.istream);
-
- attributes.put(attributeName, attributeValue);
-
- nextTV = this.peekTypeAndVal(this.istream);
- }
-
- } catch ( e) {
-
- throw new ContentDecodingException("readStartElement", e);
- }
-};
-
-
-BinaryXMLDecoder.prototype.initializeDecoding = function() {
- //if (!this.istream.markSupported()) {
- //throw new IllegalArgumentException(this.getClass().getName() + ": input stream must support marking!");
- //}
-}
-
-BinaryXMLDecoder.prototype.readStartDocument = function(){
- // Currently no start document in binary encoding.
- }
-
-BinaryXMLDecoder.prototype.readEndDocument = function() {
- // Currently no end document in binary encoding.
- };
-
-BinaryXMLDecoder.prototype.readStartElement = function(
- //String
- startTag,
- //TreeMap<String, String>
- attributes) {
-
-
- //NOT SURE
- //if(typeof startTag == 'number')
- //startTag = tagToString(startTag);
-
- //try {
- //TypeAndVal
- tv = this.decodeTypeAndVal(this.istream);
-
- if (null == tv) {
- throw new Exception("Expected start element: " + startTag + " got something not a tag.");
- }
-
- //String
- decodedTag = null;
- console.log(tv);
- console.log(typeof tv);
-
- console.log(XML_TAG);
- if (tv.type() == XML_TAG) {
- //console.log('got here');
- //Log.info(Log.FAC_ENCODING, "Unexpected: got tag in readStartElement; looking for tag " + startTag + " got length: " + (int)tv.val()+1);
- // Tag value represents length-1 as tags can never be empty.
- var valval ;
- if(typeof tv.val() == 'string'){
- valval = (parseInt(tv.val())) + 1;
- }
- else
- valval = (tv.val())+ 1;
-
- console.log('valval is ' +valval);
-
- decodedTag = this.decodeUString(this.istream, valval);
-
- } else if (tv.type() == XML_DTAG) {
- console.log('gothere');
- //console.log(tv.val());
- //decodedTag = tagToString(tv.val());
- //console.log()
- decodedTag = tv.val();
- }
-
- //console.log(decodedTag);
- console.log('startTag is '+startTag);
-
-
- if ((null == decodedTag) || decodedTag != startTag ) {
- console.log('expecting '+ startag + ' but got '+ decodedTag);
- throw new Exception("Expected start element: " + startTag + " got: " + decodedTag + "(" + tv.val() + ")");
- }
-
- // DKS: does not read attributes out of stream if caller doesn't
- // ask for them. Should possibly peek and skip over them regardless.
- // TODO: fix this
- if (null != attributes) {
- readAttributes(attributes);
- }
-
- //} catch ( e) {
- //console.log(e);
- //throw new Exception("readStartElement", e);
- //}
- }
-
-
-BinaryXMLDecoder.prototype.readAttributes = function(
- //TreeMap<String,String>
- attributes) {
-
- if (null == attributes) {
- return;
- }
-
- try {
- // Now need to get attributes.
- //TypeAndVal
- nextTV = this.peekTypeAndVal(this.istream);
-
- while ((null != nextTV) && ((XML_ATTR == nextTV.type()) ||
- (XML_DATTR == nextTV.type()))) {
-
- // Decode this attribute. First, really read the type and value.
- //this.TypeAndVal
- thisTV = this.decodeTypeAndVal(this.istream);
-
- //String
- attributeName = null;
- if (XML_ATTR == thisTV.type()) {
- // Tag value represents length-1 as attribute names cannot be empty.
- var valval ;
- if(typeof tv.val() == 'string'){
- valval = (parseInt(tv.val())) + 1;
- }
- else
- valval = (tv.val())+ 1;
-
- attributeName = this.decodeUString(this.istream,valval);
-
- } else if (XML_DATTR == thisTV.type()) {
- // DKS TODO are attributes same or different dictionary?
- attributeName = tagToString(thisTV.val());
- if (null == attributeName) {
- throw new Exception("Unknown DATTR value" + thisTV.val());
- }
- }
- // Attribute values are always UDATA
- //String
- attributeValue = this.decodeUString(this.istream);
-
- //
- attributes.push([attributeName, attributeValue]);
-
- nextTV = this.peekTypeAndVal(this.istream);
- }
-
- } catch ( e) {
- Log.logStackTrace(Log.FAC_ENCODING, Level.WARNING, e);
- throw new Exception("readStartElement", e);
- }
-};
-
-//returns a string
-BinaryXMLDecoder.prototype.peekStartElementAsString = function() {
- //this.istream.mark(MARK_LEN);
-
- //String
- decodedTag = null;
- var previousOffset = this.offset;
- try {
- // Have to distinguish genuine errors from wrong tags. Could either use
- // a special exception subtype, or redo the work here.
- //this.TypeAndVal
- tv = this.decodeTypeAndVal(this.istream);
-
- if (null != tv) {
-
- if (tv.type() == XML_TAG) {
- /*if (tv.val()+1 > DEBUG_MAX_LEN) {
- throw new ContentDecodingException("Decoding error: length " + tv.val()+1 + " longer than expected maximum length!");
- }*/
-
- // Tag value represents length-1 as tags can never be empty.
- var valval ;
- if(typeof tv.val() == 'string'){
- valval = (parseInt(tv.val())) + 1;
- }
- else
- valval = (tv.val())+ 1;
-
- decodedTag = this.decodeUString(this.istream, valval);
-
- //Log.info(Log.FAC_ENCODING, "Unexpected: got text tag in peekStartElement; length: " + valval + " decoded tag = " + decodedTag);
-
- } else if (tv.type() == XML_DTAG) {
- decodedTag = tagToString(tv.val());
- }
-
- } // else, not a type and val, probably an end element. rewind and return false.
-
- } catch ( e) {
- /*try {
- this.istream.reset();
- this.istream.mark(MARK_LEN);
- long ms = System.currentTimeMillis();
- File tempFile = new File("data_" + Long.toString(ms) + ".ccnb");
- FileOutputStream fos = new FileOutputStream(tempFile);
- try {
- byte buf[] = new byte[1024];
- while (this.istream.available() > 0) {
- int count = this.istream.read(buf);
- fos.write(buf,0, count);
- }
- } finally {
- fos.close();
- }
- this.istream.reset();
- Log.info(Log.FAC_ENCODING, "BinaryXMLDecoder: exception in peekStartElement, dumping offending object to file: " + tempFile.getAbsolutePath());
- throw e;
-
- } catch (IOException ie) {
- Log.warning(Log.FAC_ENCODING, "IOException in BinaryXMLDecoder error handling: " + e.getMessage());
- Log.logStackTrace(Log.FAC_ENCODING, Level.WARNING, ie);
- throw new ContentDecodingException("peekStartElement", e);
-
- }
- } catch (IOException e) {
- Log.warning(Log.FAC_ENCODING, "IOException in BinaryXMLDecoder: " + e.getMessage());
- Log.logStackTrace(Log.FAC_ENCODING, Level.WARNING, e);
- throw new ContentDecodingException("peekStartElement", e);
- */
- } finally {
- try {
- //this.istream.reset();
- this.offset = previousOffset;
- } catch ( e) {
- Log.logStackTrace(Log.FAC_ENCODING, Level.WARNING, e);
- throw new ContentDecodingException("Cannot reset stream! " + e.getMessage(), e);
- }
- }
- return decodedTag;
-};
-
-BinaryXMLDecoder.prototype.peekStartElement = function(
- //String
- startTag) {
- //String
- if(typeof startTag == 'string'){
- decodedTag = this.peekStartElementAsString();
-
- if ((null != decodedTag) && decodedTag == startTag) {
- return true;
- }
- return false;
- }
- else if(typeof startTag == 'number'){
- decodedTag = this.peekStartElementAsLong();
- if ((null != decodedTag) && decodedTag == startTag) {
- return true;
- }
- return false;
- }
- else{
- throw new Exception("SHOULD BE STRING OR NUMBER");
- }
-}
-//returns Long
-BinaryXMLDecoder.prototype.peekStartElementAsLong = function() {
- //this.istream.mark(MARK_LEN);
-
- //Long
- decodedTag = null;
-
- var previousOffset = this.offset;
-
- try {
- // Have to distinguish genuine errors from wrong tags. Could either use
- // a special exception subtype, or redo the work here.
- //this.TypeAndVal
- tv = this.decodeTypeAndVal(this.istream);
-
- if (null != tv) {
-
- if (tv.type() == XML_TAG) {
- if (tv.val()+1 > DEBUG_MAX_LEN) {
- throw new ContentDecodingException("Decoding error: length " + tv.val()+1 + " longer than expected maximum length!");
- }
-
- var valval ;
- if(typeof tv.val() == 'string'){
- valval = (parseInt(tv.val())) + 1;
- }
- else
- valval = (tv.val())+ 1;
-
- // Tag value represents length-1 as tags can never be empty.
- //String
- strTag = this.decodeUString(this.istream, valval);
-
- decodedTag = stringToTag(strTag);
-
- //Log.info(Log.FAC_ENCODING, "Unexpected: got text tag in peekStartElement; length: " + valval + " decoded tag = " + decodedTag);
-
- } else if (tv.type() == XML_DTAG) {
- decodedTag = tv.val();
- }
-
- } // else, not a type and val, probably an end element. rewind and return false.
-
- } catch ( e) {
- /*try {
- this.istream.reset();
- this.istream.mark(MARK_LEN);
- long ms = System.currentTimeMillis();
- File tempFile = new File("data_" + Long.toString(ms) + ".ccnb");
- FileOutputStream fos = new FileOutputStream(tempFile);
- try {
- byte buf[] = new byte[1024];
- while (this.istream.available() > 0) {
- int count = this.istream.read(buf);
- fos.write(buf,0, count);
- }
- } finally {
- fos.close();
- }
- this.istream.reset();
- Log.info(Log.FAC_ENCODING, "BinaryXMLDecoder: exception in peekStartElement, dumping offending object to file: " + tempFile.getAbsolutePath());
- throw e;
-
- } catch (IOException ie) {
- Log.warning(Log.FAC_ENCODING, "IOException in BinaryXMLDecoder error handling: " + e.getMessage());
- Log.logStackTrace(Log.FAC_ENCODING, Level.WARNING, e);
- throw new ContentDecodingException("peekStartElement", e);
-
- }
- } catch (IOException e) {
- Log.warning(Log.FAC_ENCODING, "IOException in BinaryXMLDecoder peekStartElementAsLong: " + e.getMessage());
- Log.logStackTrace(Log.FAC_ENCODING, Level.WARNING, e);
- throw new ContentDecodingException("peekStartElement", e);
- */
- } finally {
- try {
- //this.istream.reset();
- this.offset = previousOffset;
- } catch ( e) {
- Log.logStackTrace(Log.FAC_ENCODING, Level.WARNING, e);
- throw new Exception("Cannot reset stream! " + e.getMessage(), e);
- }
- }
- return decodedTag;
- };
-
-
-//byte[]
-BinaryXMLDecoder.prototype.readBinaryElement = function(
- //long
- startTag,
- //TreeMap<String, String>
- attributes){
- //byte []
- blob = null;
- //try {
- this.readStartElement(startTag, attributes);
- blob = this.readBlob();
- // readEndElement(); // readBlob consumes end element
- //} catch ( e) {
- //throw new ContentDecodingException(e.getMessage(), e);
- //}
-
- return blob;
-
-};
-
-
-BinaryXMLDecoder.prototype.readEndElement = function(){
- try {
- var next = this.istream[this.offset];
- this.offset++;
- //read();
- if (next != XML_CLOSE) {
- throw new ContentDecodingException("Expected end element, got: " + next);
- }
- } catch ( e) {
- throw new ContentDecodingException(e);
- }
- };
-
- /**
- * Read a UString. Force this to consume the end element to match the
- * behavior on the text side.
- */
-//String
-BinaryXMLDecoder.prototype.readUString = function(){
- //try {
- //String
- ustring = this.decodeUString(this.istream);
- this.readEndElement();
- return ustring;
- //} catch ( e) {
- //throw new Exception(e.getMessage(),e);
- //}
- };
-
- /**
- * Read a BLOB. Force this to consume the end element to match the
- * behavior on the text side.
- */
-//returns a byte[]
-BinaryXMLDecoder.prototype.readBlob = function() {
- //try {
- //byte []
-
- blob = this.decodeBlob(this.istream);
- this.readEndElement();
- return blob;
- //} catch ( e) {
- //throw new Exception(e.getMessage(),e);
- //}
- };
-
-//read time returns CCNTime
-/*BinaryXMLDecoder.prototype.readDateTime = function(
- //String
- startTag) {
- //byte []
- byteTimestamp = this.readBinaryElement(startTag);
- //CCNTime
- timestamp = new CCNTime(byteTimestamp);
- if (null == timestamp) {
- throw new ContentDecodingException("Cannot parse timestamp: " + DataUtils.printHexBytes(byteTimestamp));
- }
- return timestamp;
-};
-*/
-//CCNTime
-
-BinaryXMLDecoder.prototype.readDateTime = function(
- //long
- startTag) {
- //byte []
-
- byteTimestamp = this.readBinaryElement(startTag);
- //CCNTime
- timestamp = new CCNTime();
- timestamp.setDateBinary(byteTimestamp);
-
- if (null == timestamp) {
- throw new ContentDecodingException("Cannot parse timestamp: " + DataUtils.printHexBytes(byteTimestamp));
- }
- return timestamp;
-};
-
-BinaryXMLDecoder.prototype.decodeTypeAndVal = function(
- /*InputStream*/
- istream) {
-
- /*int*/next;
- /*int*/type = -1;
- /*long*/val = 0;
- /*boolean*/more = true;
-
-
- //var savedOffset = this.offset;
- var count = 0;
-
- do {
- //next = istream.read();
- //console.log('a');
- console.log('offset is' + this.offset);
- var next = this.istream[this.offset ];
- console.log('next is' + next);
- //console.log('istream is ' + this.istream);
-
-
- if (next < 0) {
- return null;
- }
-
- if ((0 == next) && (0 == val)) {
- return null;
- }
-
- more = (0 == (next & XML_TT_NO_MORE));
-
- if (more) {
- val = val << XML_REG_VAL_BITS;
- val |= (next & XML_REG_VAL_MASK);
- } else {
-
- type = next & XML_TT_MASK;
- val = val << XML_TT_VAL_BITS;
- val |= ((next >>> XML_TT_BITS) & XML_TT_VAL_MASK);
- }
-
- this.offset++;
-
- } while (more);
-
- return new TypeAndVal(type, val);
-};
-
-
-
-//TypeAndVal
-BinaryXMLDecoder.peekTypeAndVal = function(
- //InputStream
- istream) {
- //TypeAndVal
- tv = null;
-
- //istream.mark(LONG_BYTES*2);
-
- var previousOffset = this.offset;
-
- try {
- tv = this.decodeTypeAndVal(this.istream);
- } finally {
- //istream.reset();
- this.offset = previousOffset;
- }
-
- return tv;
-};
-
-//byte []
-/*BinaryXMLDecoder.prototype.decodeBlob = function(
- //InputStream
-
- istream) {
- //istream.mark(LONG_BYTES*2);
-
- TypeAndVal tv = decodeTypeAndVal(istream);
- if ((null == tv) || (XML_BLOB != tv.type())) { // if we just have closers left, will get back null
- if (Log.isLoggable(Log.FAC_ENCODING, Level.FINEST))
- Log.finest(Log.FAC_ENCODING, "Expected BLOB, got " + ((null == tv) ? " not a tag " : tv.type()) + ", assuming elided 0-length blob.");
- istream.reset();
- return new byte[0];
- }
-
- var valval ;
- if(typeof tv.val() == 'string'){
- valval = (parseInt(tv.val()));
- }
- else
- valval = (tv.val());
-
- return decodeBlob(istream, valval);
-};*/
-
-//byte[]
-BinaryXMLDecoder.prototype.decodeBlob = function(
- //InputStream
- istream,
- //int
- blobLength) {
-
-
- if(null == blobLength){
- //TypeAndVal
- tv = this.decodeTypeAndVal(this.istream);
-
- var valval ;
- if(typeof tv.val() == 'string'){
- valval = (parseInt(tv.val()));
- }
- else
- valval = (tv.val());
-
- console.log('valval here is ' + valval);
- return this.decodeBlob(this.istream, valval);
- }
-
- //
- //byte []
- //bytes = new byte[blobLength];
- console.log('this.offset is '+ this.offset);
- console.log('blogLength is '+ blobLength);
-
- bytes = this.istream.slice(this.offset, this.offset+ blobLength);
- this.offset += blobLength;
-
- //int
- return bytes;
-
- count = 0;
- /*
- while (true) {
- count += istream.read(bytes, count, (blobLength - count));
- //Library.info("read "+count+" bytes out of "+blobLength+" in decodeBlob");
- if (count < bytes.length) {
- //we couldn't read enough.. need to try to read all of the bytes
- //loop again...
- //should we add a max number of tries?
- } else if (count == bytes.length) {
- //we are done reading! return now.
- return bytes;
- } else {
- //we somehow read more than we should have...
-
- throw new Exception("Expected to read " + bytes.length +
- " bytes of data, read: " + count);
- }
- }*/
-};
-
-//String
-/*BinaryXMLDecoder.prototype.decodeUString = function(
- //InputStream
- istream) {
- //istream.mark(LONG_BYTES*2);
-
- //TypeAndVal
- tv = this.decodeTypeAndVal(istream);
-
- /*if ((null == tv) || (XML_UDATA != tv.type())) { // if we just have closers left, will get back null
- if (Log.isLoggable(Log.FAC_ENCODING, Level.FINEST))
- Log.finest(Log.FAC_ENCODING, "Expected UDATA, got " + ((null == tv) ? " not a tag " : tv.type()) + ", assuming elided 0-length blob.");
- istream.reset();
- return "";
- }*/
-/*
- var valval ;
- if(typeof tv.val() == 'string'){
- valval = (parseInt(tv.val()));
- }
- else
- valval = (tv.val());
-
- return this.decodeUString(istream, valval);
-}*/
-
-//String
-BinaryXMLDecoder.prototype.decodeUString = function(
- //InputStream
- istream,
- //int
- byteLength) {
-
- if(null == byteLength){
- tv = this.decodeTypeAndVal(this.istream);
- var valval ;
- if(typeof tv.val() == 'string'){
- valval = (parseInt(tv.val()));
- }
- else
- valval = (tv.val());
-
- byteLength= this.decodeUString(this.istream, valval);
- }
-
- //byte []
- console.log('bytes Length here is '+ byteLength);
-
- stringBytes = this.decodeBlob(this.istream, byteLength);
-
- tempBuffer = this.istream.slice(this.offset, this.offset+byteLength);
- this.offset+= byteLength;
- console.log('read the String' + tempBuffer.toString('ascii'));
- return tempBuffer.toString('ascii');//DataUtils.getUTF8StringFromBytes(stringBytes);
-};
-
-var TypeAndVal = function TypeAndVal(_type,_val) {
- this.t = _type;
- this.v = _val;
-
-};
-
-TypeAndVal.prototype.type = function(){
- return this.t;
-};
-
-TypeAndVal.prototype.val = function(){
- return this.v;
-};
-//TODO
\ No newline at end of file
diff --git a/latest/encoding/BinaryXMLEncoder.js b/latest/encoding/BinaryXMLEncoder.js
deleted file mode 100644
index e5039ee..0000000
--- a/latest/encoding/BinaryXMLEncoder.js
+++ /dev/null
@@ -1,459 +0,0 @@
-
-var XML_EXT = 0x00;
-
-var XML_TAG = 0x01;
-
-var XML_DTAG = 0x02;
-
-var XML_ATTR = 0x03;
-
-var XML_DATTR = 0x04;
-
-var XML_BLOB = 0x05;
-
-var XML_UDATA = 0x06;
-
-var XML_CLOSE = 0x0;
-
-var XML_SUBTYPE_PROCESSING_INSTRUCTIONS = 16;
-
-
-var XML_TT_BITS = 3;
-var XML_TT_MASK = ((1 << XML_TT_BITS) - 1);
-var XML_TT_VAL_BITS = XML_TT_BITS + 1;
-var XML_TT_VAL_MASK = ((1 << (XML_TT_VAL_BITS)) - 1);
-var XML_REG_VAL_BITS = 7;
-var XML_REG_VAL_MASK = ((1 << XML_REG_VAL_BITS) - 1);
-var XML_TT_NO_MORE = (1 << XML_REG_VAL_BITS); // 0x80
-var BYTE_MASK = 0xFF;
-var LONG_BYTES = 8;
-var LONG_BITS = 64;
-
-var bits_11 = 0x0000007FF;
-var bits_18 = 0x00003FFFF;
-var bits_32 = 0x0FFFFFFFF;
-
-//var BinaryXMLCodec = require('./BinaryXMLCodec').BinaryXMLCodec;
-
-//var codec = new BinaryXMLCodec();
-
-
-var BinaryXMLEncoder = function BinaryXMLEncoder(){
-
- this.ostream = new Array(1024);
-
- this.offset =0;
-
- this.CODEC_NAME = "Binary";
-
-};
-
-
-/*BinaryXMLEncoder.prototype.beginEncoding = function() {
- this.ostream = new Buffer(1024);
- this.offset = 0;
-};
-
-BinaryXMLEncoder.prototype.endEncoding = function(){
- //this.ostream.end();
-};*/
-
-BinaryXMLEncoder.prototype.writeUString = function(/*String*/ utf8Content){
- this.encodeUString(this.ostream, utf8Content);
-};
-
-BinaryXMLEncoder.prototype.writeBlob = function(/*byte []*/ binaryContent
- //, /*int*/ offset, /*int*/ length
- ) {
- //console.log(binaryContent);
- this.encodeBlob(this.ostream, binaryContent, this.offset, binaryContent.length);
-};
-
-BinaryXMLEncoder.prototype.writeStartElement = function(/*String*/ tag, /*TreeMap<String,String>*/ attributes){
-
- /*Long*/ dictionaryVal = tag;//stringToTag(tag);
-
- if (null == dictionaryVal) {
-
- this.encodeUString(this.ostream, tag, XML_TAG);
-
- } else {
- this.encodeTypeAndVal(XML_DTAG, dictionaryVal, this.ostream);
- }
-
- if (null != attributes) {
- this.writeAttributes(attributes);
- }
-};
-
-
-BinaryXMLEncoder.prototype.writeEndElement = function(){
- //console.log(XML_CLOSE);
- //console.log(tagToString(XML_CLOSE));
- //this.ostream.writeUInt8( XML_CLOSE ,this.offset);
- this.ostream[this.offset] = XML_CLOSE;
- this.offset+= 1;
-}
-
-BinaryXMLEncoder.prototype.writeAttributes = function(/*TreeMap<String,String>*/ attributes) {
-
- if (null == attributes) {
- return;
- }
-
- // the keySet of a TreeMap is sorted.
- /*Set<String> keySet = attributes.keySet();
- Iterator<String> it = keySet.iterator();*/
-
- for(var i=0; i<attributes.length;i++){
- var strAttr = attributes[i].k;
- var strValue = attributes[i].v;
-
- var dictionaryAttr = stringToTag(strAttr);
- if (null == dictionaryAttr) {
- // not in dictionary, encode as attr
- // compressed format wants length of tag represented as length-1
- // to save that extra bit, as tag cannot be 0 length.
- // encodeUString knows to do that.
- this.encodeUString(this.ostream, strAttr, XML_ATTR);
- } else {
- this.encodeTypeAndVal(XML_DATTR, dictionaryAttr, this.ostream);
- }
- // Write value
- this.encodeUString(this.ostream, strValue);
-
- }
-
-
-}
-
-//returns a string
-stringToTag = function(/*long*/ tagVal) {
- if ((tagVal >= 0) && (tagVal < CCNProtocolDTagsStrings.length)) {
- return CCNProtocolDTagsStrings[tagVal];
- } else if (tagVal == CCNProtocolDTags.CCNProtocolDataUnit) {
- return CCNProtocolDTags.CCNPROTOCOL_DATA_UNIT;
- }
- return null;
-};
-
-//returns a Long
-tagToString = function(/*String*/ tagName) {
- // the slow way, but right now we don't care.... want a static lookup for the forward direction
- for (var i=0; i < CCNProtocolDTagsStrings.length; ++i) {
- if ((null != CCNProtocolDTagsStrings[i]) && (CCNProtocolDTagsStrings[i] == tagName)) {
- return i;
- }
- }
- if (CCNProtocolDTags.CCNPROTOCOL_DATA_UNIT == tagName) {
- return CCNProtocolDTags.CCNProtocolDataUnit;
- }
- return null;
-};
-
-
-BinaryXMLEncoder.prototype.writeElement = function(
- //long
- tag,
- //byte[]
- binaryContent,
- //TreeMap<String, String>
- attributes) {
- this.writeStartElement(tag, attributes);
- // Will omit if 0-length
-
- this.writeBlob(binaryContent);
- this.writeEndElement();
-}
-
-//TODO
-//console.log(stringToTag(0));
-
-
-
-
-
-
-
-
-
-var TypeAndVal = function TypeAndVal(_type,_val) {
- this.type = _type;
- this.val = _val;
-
-};
-
-
-
-/*BinaryXMLEncoder.prototype.encodeTypeAndValOffset = function(
- //int
- type,
- //long
- val,
- //byte []
- buf,
- //int
- offset) {
-
- if ((type > XML_UDATA) || (type < 0) || (val < 0)) {
- throw new Exception("Tag and value must be positive, and tag valid.");
- }
-
- // Encode backwards. Calculate how many bytes we need:
- //int
- var numEncodingBytes = numEncodingBytes(val);
-
- if ((offset + numEncodingBytes) > buf.length) {
- throw new Exception("Buffer space of " + (buf.length-offset) +
- " bytes insufficient to hold " +
- numEncodingBytes + " of encoded type and value.");
- }
-
-
- buf[offset + numEncodingBytes - 1] =
- (BYTE_MASK &
- (((XML_TT_MASK & type) |
- ((XML_TT_VAL_MASK & val) << XML_TT_BITS))) |
- XML_TT_NO_MORE);
- val = val >>> XML_TT_VAL_BITS;;
- //int
- var i = offset + numEncodingBytes - 2;
- while ((0 != val) && (i >= offset)) {
- buf[i] = (BYTE_MASK &
- (val & XML_REG_VAL_MASK));
- val = val >>> XML_REG_VAL_BITS;
- --i;
- }
-
- return numEncodingBytes;
-};*/
-
-//BinaryXMLCodec.prototype.encodeTypeAndVal = function(
- // //final int
- //type,
- //final long
- //value,
- //final OutputStream
- //ostream,
- //offset){
-
- /*
- We exploit the fact that encoding is done from the right, so this actually means
- there is a deterministic encoding from a long to a Type/Value pair:
-
- | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 |
- |ABCD.EFGH|IJKL.MNOP|QRST.UVWX|YZ01.2345|6789.abcd|efgh.ijkl|mnop.qrst|uvwx.yz@#
-
- 60> 53> 46> 39> 32> 25> 18> 11> 4>
- |_000.ABCD|_EFG.HIJK|_LMN.OPQR|_STU.VWXY|_Z01.2345|_678.9abc|_defg.hij|_klm.nopq|_rst.uvwx|_yz@#___
-
- What we want to do is compute the result in MSB order and write it directly
- to the channel without any intermediate form.
- */
-
- //var/*int*/ bits;
- //var/*int*/ count = 0;
-
- // once we start writing bits, we keep writing bits even if they are "0"
- // var/*bool*/ writing = false;
-
- // a few heuristic to catch the small-bit length patterns
- /*if( value < 0 || value > 15 ) {
- var start = 60;
- if( 0 <= value ) {
- if( value < bits_11 )
- start = 4;
- else if( value < bits_18 )
- start = 11;
- else if( value < bits_32 )
- start = 25;
- }
-
- for( var i = start; i >= 4; i -= 7) {
- bits = (value >>> i) & BinaryXMLCodec.XML_REG_VAL_MASK;
- if( bits != 0 || writing ) {
- ostream.write(bits);
- count++;
- writing = true;
- }
- }
- }
-
- // Explicit computation of the bottom byte
- bits = type & BinaryXMLCodec.XML_TT_MASK;
- var bottom4 = value & BinaryXMLCodec.XML_TT_VAL_MASK;
- bits |= bottom4 << BinaryXMLCodec.XML_TT_BITS;
- // the bottom byte always has the NO_MORE flag
- bits |= BinaryXMLCodec.XML_TT_NO_MORE;
-
- //console.log(ostream.constructor.name);
- //console.log(ostream);
-
- //ostream.writable = true;
- //console.log(ostream.)
- ostream.write(bits.toString());
-
- count++;
-
-// byte [] encoding = encodeTypeAndVal(tag, val);
-// ostream.write(encoding);
- return count;
-
-}*/
-
-
-BinaryXMLEncoder.prototype.encodeTypeAndVal = function(
- //int
- type,
- //long
- val,
- //byte []
- buf) {
-
- console.log('Encoding type '+ type+ ' and value '+ val);
-
- if ((type > XML_UDATA) || (type < 0) || (val < 0)) {
- throw new Exception("Tag and value must be positive, and tag valid.");
- }
-
- // Encode backwards. Calculate how many bytes we need:
- var numEncodingBytes = this.numEncodingBytes(val);
-
- if ((this.offset + numEncodingBytes) > buf.length) {
- throw new Exception("Buffer space of " + (buf.length-this.offset) +
- " bytes insufficient to hold " +
- numEncodingBytes + " of encoded type and value.");
- }
-
- // Bottom 4 bits of val go in last byte with tag.
- buf[this.offset + numEncodingBytes - 1] =
- //(byte)
- (BYTE_MASK &
- (((XML_TT_MASK & type) |
- ((XML_TT_VAL_MASK & val) << XML_TT_BITS))) |
- XML_TT_NO_MORE); // set top bit for last byte
- val = val >>> XML_TT_VAL_BITS;;
-
- // Rest of val goes into preceding bytes, 7 bits per byte, top bit
- // is "more" flag.
- var i = this.offset + numEncodingBytes - 2;
- while ((0 != val) && (i >= this.offset)) {
- buf[i] = //(byte)
- (BYTE_MASK &
- (val & XML_REG_VAL_MASK)); // leave top bit unset
- val = val >>> XML_REG_VAL_BITS;
- --i;
- }
- if (val != 0) {
- throw new Exception( "This should not happen: miscalculated encoding");
- //Log.warning(Log.FAC_ENCODING, "This should not happen: miscalculated encoding length, have " + val + " left.");
- }
- this.offset+= numEncodingBytes;
- console.log('offset increased after tag to '+this.offset);
-
- return numEncodingBytes;
-};
-
-BinaryXMLEncoder.prototype.encodeUString = function(
- //OutputStream
- ostream,
- //String
- ustring,
- //byte
- type) {
-
- // We elide the encoding of a 0-length UString
- if ((null == ustring) || (ustring.length == 0)) {
- //if (Log.isLoggable(Log.FAC_ENCODING, Level.FINER))
- //Log.finer(Log.FAC_ENCODING, "Eliding 0-length UString.");
- return;
- }
-
- console.log('Writting String to '+ ustring);
-
- //byte [] data utils
- /*custom*/
- //byte[]
- strBytes = new Array(ustring.Length);
- var i = 0;
- for( ;i<ustring.lengh;i++) //in InStr.ToCharArray())
- {
- strBytes[i] = ustring[i];
- }
- //strBytes = DataUtils.getBytesFromUTF8String(ustring);
-
- this.encodeTypeAndVal(type,
- (((type == XML_TAG) || (type == XML_ATTR)) ?
- (strBytes.length-1) :
- strBytes.length), ostream);
-
- //console.log(strBytes.toString());
-
- ostream.write(strBytes.toString(),this.offset);
- this.offset+= strBytes.length;
- console.log('offset increased after String to '+this.offset);
- //
-};
-
-BinaryXMLEncoder.prototype.encodeBlob = function(
- //OutputStream
- ostream,
- //byte []
- blob,
- //int
- offset,
- //int
- length) {
-
- console.log('Writting Blob ');
- console.log('length is '+ length);
-
- // We elide the encoding of a 0-length blob
- if ((null == blob) || (length == 0)) {
-
- return;
- }
-
-
- this.encodeTypeAndVal(XML_BLOB, length, ostream,offset);
-
- if (null != blob) {
- //console.log(blob);
- //maybe blog.t
- ostream.write(blob.toString(), this.offset);
- this.offset += length;
- console.log('offset increased after blob to '+this.offset);
- }
-};
-
-
-var ENCODING_LIMIT_1_BYTE = ((1 << (XML_TT_VAL_BITS)) - 1);
-var ENCODING_LIMIT_2_BYTES = ((1 << (XML_TT_VAL_BITS + XML_REG_VAL_BITS)) - 1);
-var ENCODING_LIMIT_3_BYTES = ((1 << (XML_TT_VAL_BITS + 2 * XML_REG_VAL_BITS)) - 1);
-
-BinaryXMLEncoder.prototype.numEncodingBytes = function(
- //long
- x) {
- if (x <= ENCODING_LIMIT_1_BYTE) return (1);
- if (x <= ENCODING_LIMIT_2_BYTES) return (2);
- if (x <= ENCODING_LIMIT_3_BYTES) return (3);
-
- var numbytes = 1;
-
- // Last byte gives you XML_TT_VAL_BITS
- // Remainder each give you XML_REG_VAL_BITS
- x = x >>> XML_TT_VAL_BITS;
- while (x != 0) {
- numbytes++;
- x = x >>> XML_REG_VAL_BITS;
- }
- return (numbytes);
-};
-
-BinaryXMLEncoder.prototype.writeDateTime = function(
- //String
- tag,
- //CCNTime
- dateTime) {
- this.writeElement(tag, dateTime.toBinaryTime());
-};
diff --git a/latest/encoding/DataUtils.js b/latest/encoding/DataUtils.js
deleted file mode 100644
index 8c931bf..0000000
--- a/latest/encoding/DataUtils.js
+++ /dev/null
@@ -1,135 +0,0 @@
-
-
-var DataUtils = function DataUtils(){
-
-
-};
-
-//exports.DataUtils =DataUtils;
-
-
- var keyStr = "ABCDEFGHIJKLMNOP" +
- "QRSTUVWXYZabcdef" +
- "ghijklmnopqrstuv" +
- "wxyz0123456789+/" +
- "=";
-
-DataUtils.encode64=function encode64(input) {
- input = escape(input);
- var output = "";
- var chr1, chr2, chr3 = "";
- var enc1, enc2, enc3, enc4 = "";
- var i = 0;
-
- do {
- chr1 = input.charCodeAt(i++);
- chr2 = input.charCodeAt(i++);
- chr3 = input.charCodeAt(i++);
-
- enc1 = chr1 >> 2;
- enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);
- enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);
- enc4 = chr3 & 63;
-
- if (isNaN(chr2)) {
- enc3 = enc4 = 64;
- } else if (isNaN(chr3)) {
- enc4 = 64;
- }
-
- output = output +
- keyStr.charAt(enc1) +
- keyStr.charAt(enc2) +
- keyStr.charAt(enc3) +
- keyStr.charAt(enc4);
- chr1 = chr2 = chr3 = "";
- enc1 = enc2 = enc3 = enc4 = "";
- } while (i < input.length);
-
- return output;
- }
-
-DataUtils.decode64 = function decode64(input) {
- var output = "";
- var chr1, chr2, chr3 = "";
- var enc1, enc2, enc3, enc4 = "";
- var i = 0;
-
- // remove all characters that are not A-Z, a-z, 0-9, +, /, or =
- var base64test = /[^A-Za-z0-9\+\/\=]/g;
- if (base64test.exec(input)) {
- alert("There were invalid base64 characters in the input text.\n" +
- "Valid base64 characters are A-Z, a-z, 0-9, '+', '/',and '='\n" +
- "Expect errors in decoding.");
- }
- input = input.replace(/[^A-Za-z0-9\+\/\=]/g, "");
-
- do {
- enc1 = keyStr.indexOf(input.charAt(i++));
- enc2 = keyStr.indexOf(input.charAt(i++));
- enc3 = keyStr.indexOf(input.charAt(i++));
- enc4 = keyStr.indexOf(input.charAt(i++));
-
- chr1 = (enc1 << 2) | (enc2 >> 4);
- chr2 = ((enc2 & 15) << 4) | (enc3 >> 2);
- chr3 = ((enc3 & 3) << 6) | enc4;
-
- output = output + String.fromCharCode(chr1);
-
- if (enc3 != 64) {
- output = output + String.fromCharCode(chr2);
- }
- if (enc4 != 64) {
- output = output + String.fromCharCode(chr3);
- }
-
- chr1 = chr2 = chr3 = "";
- enc1 = enc2 = enc3 = enc4 = "";
-
- } while (i < input.length);
-
- return unescape(output);
- };
-
-
-
-
-
-//byte []
-DataUtils.prototype.unsignedLongToByteArray= function( value) {
- if( 0 == value )
- return [0];
-
- if( 0 <= value && value <= 0x00FF ) {
- //byte []
- bb = new Array[1];
- bb[0] = (value & 0x00FF);
- return bb;
- }
-
-
- //byte []
- out = null;
- //int
- var offset = -1;
- for(var i = 7; i >=0; --i) {
- //byte
- b = ((value >> (i * 8)) & 0xFF);
- if( out == null && b != 0 ) {
- out = new byte[i+1];
- offset = i;
- }
- if( out != null )
- out[ offset - i ] = b;
- }
- return out;
-}
-
-//function init(){
-
- //var encoded = DataUtils.encode64('abc');
- //console.log(encoded);
-//}
-//init();
-
-
diff --git a/latest/encoding/TextXMLCodec.js b/latest/encoding/TextXMLCodec.js
deleted file mode 100644
index 2d1121b..0000000
--- a/latest/encoding/TextXMLCodec.js
+++ /dev/null
@@ -1,70 +0,0 @@
-//todo parse this
-/*
- *
- *
- * static {
- canonicalWriteDateFormat =
- new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'");
- new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.S'Z'"); // writing ns doesn't format leading 0's correctly
- canonicalWriteDateFormat.setTimeZone(TimeZone.getTimeZone("GMT"));
- canonicalReadDateFormat =
- new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
- // new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.S'Z'");
- canonicalReadDateFormat.setTimeZone(TimeZone.getTimeZone("GMT"));
- }
- *
- */
-
-var DataUtils = require('./DataUtils').DataUtils;
-
- var /*DateFormat*/ canonicalWriteDateFormat = null;
- var /* DateFormat*/ canonicalReadDateFormat = null;
- var /*String*/ PAD_STRING = "000000000";
- var /*int*/ NANO_LENGTH = 9;
-
-var TextXMLCodec = function TextXMLCodec(){
-
- this.CCN_NAMESPACE = "http://www.parc.com/ccn"; // String
- this.CCN_PREFIX = "ccn"; // String
- this.CODEC_NAME = "Text";// String
- this.BINARY_ATTRIBUTE = "ccnbencoding";// String
- this.BINARY_ATTRIBUTE_VALUE = "base64Binary";// String
-
-
-};
-
-//returns a string
-
-TextXMLCodec.protpotype.codecName = function() { return this.CODEC_NAME; } ;
-
-//returns a string
-TextXMLCodec.protottype.encodeBinaryElement = function(/*byte []*/ element) {
- if ((null == element) || (0 == element.length))
- return new String("");
- return new String(DataUtils.base64Encode(element));
- };
-
-/* returns a string */
-TextXMLCodec.prototype.encodeBinaryElement = function(/*byte []*/ element, /*int*/ offset, /*int*/ length) {
- if ((null == element) || (0 == element.length))
- return new String("");
- ByteBuffer bbuf = ByteBuffer.wrap(element, offset, length);
- return new String(DataUtils.base64Encode(bbuf.array()));
- };
-
-/*returns a byte array*/
-TextXMLCodec.prototype.decodeBinaryElement = function(/*String*/ element) {
- if ((null == element) || (0 == element.length()))
- return new byte[0];
- return DataUtils.base64Decode(element.getBytes());
- };
-
-
-/*
- Decode Data
-*/
-
-
-/*
- Encode Date
-*/
\ No newline at end of file
diff --git a/latest/encoding/TextXMLDecoder.js b/latest/encoding/TextXMLDecoder.js
deleted file mode 100644
index 32ac1c5..0000000
--- a/latest/encoding/TextXMLDecoder.js
+++ /dev/null
@@ -1,225 +0,0 @@
-
-
-var TextXMLDecoder = function TextXMLDecoder(){
-
- this.reader = null;
-
-};
-
-
-exports.TextXMLDecoder = TextXMLDecoder;
-
-
-exports.prototype.initializeDecoding = function(){
- try {
- XmlPullParserFactory factory = XmlPullParserFactory.newInstance();
- factory.setNamespaceAware(true);
- _reader = factory.newPullParser();
- _reader.setInput(_istream, null);
- } catch (XmlPullParserException e) {
- throw new ContentDecodingException(e.getMessage(), e);
- }
-};
-
-exports.prototype.readStartDocument = function(){
- try {
- int event = _reader.getEventType();
- _reader.next();
- if (event != XmlPullParser.START_DOCUMENT) {
- throw new ContentDecodingException("Expected start document, got: " + XmlPullParser.TYPES[event]);
- }
- } catch (XmlPullParserException e) {
- throw new ContentDecodingException(e.getMessage(), e);
- } catch (IOException e) {
- throw new ContentDecodingException(e.getMessage(), e);
- }
-};
-
-public void readEndDocument() throws ContentDecodingException {
- int event;
- try {
- event = _reader.getEventType();
- } catch (XmlPullParserException e) {
- throw new ContentDecodingException(e.getMessage(), e);
- }
- if (event != XmlPullParser.END_DOCUMENT) {
- throw new ContentDecodingException("Expected end document, got: " + XmlPullParser.TYPES[event]);
- }
-};
-
-exports.prototype.readStartElement = function(/*String*/ startTag,
- TreeMap<String, String> attributes) throws ContentDecodingException {
-
- int event = readToNextTag(XmlPullParser.START_TAG);
- if (event != XmlPullParser.START_TAG) {
- throw new ContentDecodingException("Expected start element, got: " + XmlPullParser.TYPES[event]);
- }
- // Use getLocalPart to strip namespaces.
- // Assumes we are working with a global default namespace of CCN.
- if (!startTag.equals(_reader.getName())) {
- // Coming back with namespace decoration doesn't match
- throw new ContentDecodingException("Expected start element: " + startTag + " got: " + _reader.getName());
- }
- if (null != attributes) {
- // we might be expecting attributes
- for (int i=0; i < _reader.getAttributeCount(); ++i) {
- // may need fancier namespace handling.
- attributes.put(_reader.getAttributeName(i), _reader.getAttributeValue(i));
- }
- }
- try {
- _reader.next();
- } catch (XmlPullParserException e) {
- throw new ContentDecodingException(e.getMessage());
- } catch (IOException e) {
- throw new ContentDecodingException(e.getMessage());
- }
-}
-
- public void readStartElement(long startTagLong,
- TreeMap<String, String> attributes) throws ContentDecodingException {
-
- String startTag = tagToString(startTagLong);
-
- int event = readToNextTag(XmlPullParser.START_TAG);
- if (event != XmlPullParser.START_TAG) {
- throw new ContentDecodingException("Expected start element, got: " + XmlPullParser.TYPES[event]);
- }
- // Use getLocalPart to strip namespaces.
- // Assumes we are working with a global default namespace of CCN.
- if (!startTag.equals(_reader.getName())) {
- // Coming back with namespace decoration doesn't match
- throw new ContentDecodingException("Expected start element: " + startTag + " got: " + _reader.getName());
- }
- if (null != attributes) {
- // we might be expecting attributes
- for (int i=0; i < _reader.getAttributeCount(); ++i) {
- // may need fancier namespace handling.
- attributes.put(_reader.getAttributeName(i), _reader.getAttributeValue(i));
- }
- }
- try {
- _reader.next();
- } catch (XmlPullParserException e) {
- throw new ContentDecodingException(e.getMessage());
- } catch (IOException e) {
- throw new ContentDecodingException(e.getMessage());
- }
- }
- public String peekStartElementAsString() throws ContentDecodingException {
- int event = readToNextTag(XmlPullParser.START_TAG);
- if (event != XmlPullParser.START_TAG) {
- return null;
- }
- return _reader.getName();
- }
-
- public Long peekStartElementAsLong() throws ContentDecodingException {
- String strTag = peekStartElementAsString();
- if (null == strTag) {
- return null; // e.g. hit an end tag...
- }
- return stringToTag(strTag);
- }
-
- /**
- * Helper method to decode text (UTF-8) and binary elements. Consumes the end element,
- * behavior which other decoders are forced to match.
- * @return the read data, as a String
- * @throws ContentDecodingException if there is a problem decoding the data
- */
- public String readUString() throws ContentDecodingException {
- StringBuffer buf = new StringBuffer();
- try {
- int event = _reader.getEventType();;
- // Handles empty text element.
- while (event == XmlPullParser.TEXT) {
- buf.append(_reader.getText());
- event = _reader.next();
- }
- if (event == XmlPullParser.START_TAG) {
- throw new ContentDecodingException("readElementText expects start element to have been previously consumed, got: " + XmlPullParser.TYPES[event]);
- } else if (event != XmlPullParser.END_TAG) {
- throw new ContentDecodingException("Expected end of text element, got: " + XmlPullParser.TYPES[event]);
- }
- readEndElement();
- return buf.toString();
- } catch (XmlPullParserException e) {
- throw new ContentDecodingException(e.getMessage(), e);
- } catch (IOException e) {
- throw new ContentDecodingException(e.getMessage(), e);
- }
- }
-
- public void readEndElement() throws ContentDecodingException {
- int event = readToNextTag(XmlPullParser.END_TAG);
- if (event != XmlPullParser.END_TAG) {
- throw new ContentDecodingException("Expected end element, got: " + XmlPullParser.TYPES[event]);
- }
- try {
- _reader.next();
- } catch (XmlPullParserException e) {
- throw new ContentDecodingException(e.getMessage());
- } catch (IOException e) {
- throw new ContentDecodingException(e.getMessage());
- }
- }
-
- /**
- * Read a BLOB. Consumes the end element, so force other versions
- * to match.
- */
- public byte [] readBlob() throws ContentDecodingException {
- try {
- String strElementText = readUString();
- // readEndElement(); // readElementText consumes end element
- return TextXMLCodec.decodeBinaryElement(strElementText);
- } catch (IOException e) {
- throw new ContentDecodingException(e.getMessage(),e);
- }
- }
-
- public CCNTime readDateTime(String startTag) throws ContentDecodingException {
- String strTimestamp = readUTF8Element(startTag);
- CCNTime timestamp;
- try {
- timestamp = TextXMLCodec.parseDateTime(strTimestamp);
- } catch (ParseException e) {
- timestamp = null;
- }
- if (null == timestamp) {
- throw new ContentDecodingException("Cannot parse timestamp: " + strTimestamp);
- }
- return timestamp;
- }
-
- public CCNTime readDateTime(long startTag) throws ContentDecodingException {
- String strTimestamp = readUTF8Element(startTag);
- CCNTime timestamp;
- try {
- timestamp = TextXMLCodec.parseDateTime(strTimestamp);
- } catch (ParseException e) {
- timestamp = null;
- }
- if (null == timestamp) {
- throw new ContentDecodingException("Cannot parse timestamp: " + strTimestamp);
- }
- return timestamp;
- }
-
- private int readToNextTag(int type) throws ContentDecodingException {
- int event;
- try {
- event = _reader.getEventType();
- if (event == type)
- return event;
- if (event == XmlPullParser.TEXT || event == XmlPullParser.COMMENT)
- event = _reader.next();
- } catch (IOException e) {
- throw new ContentDecodingException(e.getMessage(), e);
- } catch (XmlPullParserException e) {
- throw new ContentDecodingException(e.getMessage(), e);
- }
- return event;
- }
-};
diff --git a/latest/encoding/TextXMLEncoder.js b/latest/encoding/TextXMLEncoder.js
deleted file mode 100644
index 29291ea..0000000
--- a/latest/encoding/TextXMLEncoder.js
+++ /dev/null
@@ -1,134 +0,0 @@
-var Stream = require('stream').Stream;
-var TextXMLCodec = require('TextXMLCodec').TextXMLCodec;
-
-
-
-
-var TextXMLEncoder = function TextXMLEncoder(){
-
-
- this.ostream = new String();
-};
-
-exports.TextXMLEncoder = TextXMLEncoder;
-
-TextXMLEncoder.prototype.beginEncoding = function(/*OutputStream*/ ostream){
- if (null == ostream)
- throw new IllegalArgumentException("TextXMLEncoder: output stream cannot be null!");
-
-
- /*Start by encoing the begining*/
- //this.IStream = ostream;
- this.ostream.write('<?xml version="1.0" encoding="UTF-8"?>');
-};
-
-TextXMLEncoder.prototype.endEncoding =function() {
- this.IStream.end();
-}
-
-//TextXMLEncoder.prototype.writeStartElement = function(/*long*/ tag, /*TreeMap<String, String>*/ attributes){
- /* String strTag = tagToString(tag);
- if (null == strTag) {
- strTag = XMLDictionaryStack.unknownTagMarker(tag);
- }
- writeStartElement(strTag, attributes);
-};*/
-
-
-TextXMLEncoder.prorotype.writeStartElement(/*String*/ tag, /*TreeMap<String, String>*/ attributes) {
-
-
- this.ostream.write('<'+tab);
-
- if (null != attributes) {
-
- for(var i=0; i<attributes.length;i++){
- this.ostream.write(' '+attributes[i].key +'='+attributes[i].value);
- }
-
- // keySet of a TreeMap is ordered
- }
- this.ostream.write('>');
-};
-
-TextXMLEncoder.prototype.writeUString = function(/*String*/ utf8Content) {
-
- this.ostream.write(utf8Content);
-
-};
-
-
-TextXMLEncoder.prototype.writeBlob = function(/*byte []*/ binaryContent, /*int*/ offset, /*int*/ length) {
-
- this.ostream.write(TextXMLCodec.encodeBinaryElement(binaryContent, offset, length));
-
-};
-
-TextXMLEncoder.prototype.writeElement = function(/*String*/ tag, /*byte[]*/ binaryContent,
- /*TreeMap<String, String>*/ attributes) {
-
- /*if (null == attributes) {
-
- attributes = new TreeMap<String,String>();
- }*/
- if (!attributes.containsKey(TextXMLCodec.BINARY_ATTRIBUTE)) {
- attributes.put(TextXMLCodec.BINARY_ATTRIBUTE, TextXMLCodec.BINARY_ATTRIBUTE_VALUE);
- }
- super.writeElement(tag, binaryContent, attributes);
-}
-
-//TextXMLEncoder.prototype.writeElement = function(/*String*/ tag, /*byte[]*/ binaryContent, /*int*/ offset, int length,
- /* TreeMap<String, String> attributes) throws ContentEncodingException {
- if (null == attributes) {
- attributes = new TreeMap<String,String>();
- }
- if (!attributes.containsKey(TextXMLCodec.BINARY_ATTRIBUTE)) {
- attributes.put(TextXMLCodec.BINARY_ATTRIBUTE, TextXMLCodec.BINARY_ATTRIBUTE_VALUE);
- }
- super.writeElement(tag, binaryContent, offset, length, attributes);
- }*/
-
-/* public void writeDateTime(String tag, CCNTime dateTime) throws ContentEncodingException {
- writeElement(tag, TextXMLCodec.formatDateTime(dateTime));
- }
-
- public void writeDateTime(long tag, CCNTime dateTime) throws ContentEncodingException {
- writeElement(tag, TextXMLCodec.formatDateTime(dateTime));
- }*/
-
-TextXMLEncoder.prototype.writeEndElement(tag) {
-
- this.ostream.write('<'+tab+'>');
-
- };
-
-
-//returns number long
-stringToTag = function(/*String*/ tagName) {
-
- if (null == tagName) {
- return null;
- }
- Long tagVal = null;
- if (null != _dictionaryStack) {
- for (/*XMLDictionary*/ dictionary in _dictionaryStack) {
- tagVal = dictionary.stringToTag(tagName);
- if (null != tagVal) {
- return tagVal;
- }
- }
- }
-
- /*for (XMLDictionary dictionary : XMLDictionaryStack.getGlobalDictionaries()) {
- tagVal = dictionary.stringToTag(tagName);
- if (null != tagVal) {
- return tagVal;
- }
- }*/
-
- if (XMLDictionaryStack.isUnknownTag(tagName)) {
- return XMLDictionaryStack.decodeUnknownTag(tagName);
- }
- return null;
-};
-
diff --git a/latest/encoding/dom-js.js b/latest/encoding/dom-js.js
deleted file mode 100644
index 3cabaec..0000000
--- a/latest/encoding/dom-js.js
+++ /dev/null
@@ -1,188 +0,0 @@
-var sax = require("./sax");
-var strict = true;
-
-/**
- * Really simple XML DOM implementation based on sax that works with Strings.
- *
- * If you have an XML string and want a DOM this utility is convenient.
- *
- * var domjs = new DomJS();
- * domjs.parse(xmlString, function(err, dom) {
- *
- * });
- *
- * If you want to compile C there are versions based on libxml2
- * and jsdom is full featured but complicated.
- *
- * This is "lightweight" meaning really simple and serves my purpose, it does not support namespaces or all
- * of the features of XML 1.0 it just takes a string and returns a JavaScript object graph.
- *
- * There are only three types of object supported Element, Text and Comment.
- *
- * e.g.
- *
- * take <xml><elem att="val1"/><elem att="val1"/><elem att="val1"/></xml>
- *
- * return { name : "xml",
- * attributes : {}
- * children [
- * { name : "elem", attributes : {att:'val1'}, children [] },
- * { name : "elem", attributes : {att:'val1'}, children [] },
- * { name : "elem", attributes : {att:'val1'}, children [] }
- * ]
- * }
- *
- * The object returned can be serialized back out with obj.toXml();
- *
- *
- * @constructor DomJS
- */
-DomJS = function() {
- this.root = null;
- this.stack = new Array();
- this.currElement = null;
- this.error = false;
-};
-
-DomJS.prototype.parse = function(string, cb) {
- if (typeof string != 'string') {
- cb(true, 'Data is not a string');
- return;
- }
- var self = this;
- parser = sax.parser(strict);
-
- parser.onerror = function (err) {
- self.error = true;
- cb(true, err);
- };
- parser.ontext = function (text) {
- if (self.currElement == null) {
- // console.log("Content in the prolog " + text);
- return;
- }
- var textNode = new Text(text);
- self.currElement.children.push(textNode);
- };
- parser.onopencdata = function () {
- var cdataNode = new CDATASection();
- self.currElement.children.push(cdataNode);
- };
- parser.oncdata = function (data) {
- var cdataNode = self.currElement.children[self.currElement.children.length - 1];
- cdataNode.appendData(data);
- };
- // do nothing on parser.onclosecdata
- parser.onopentag = function (node) {
- var elem = new Element(node.name, node.attributes);
- if (self.root == null) {
- self.root = elem;
- }
- if (self.currElement != null) {
- self.currElement.children.push(elem);
- }
- self.currElement = elem;
- self.stack.push(self.currElement);
- };
- parser.onclosetag = function (node) {
- self.stack.pop();
- self.currElement = self.stack[self.stack.length - 1 ];// self.stack.peek();
- };
- parser.oncomment = function (comment) {
- if (self.currElement == null) {
- //console.log("Comments in the prolog discarded " + comment);
- return;
- }
- var commentNode = new Comment(comment);
- self.currElement.children.push(commentNode);
- };
-
- parser.onend = function () {
- if ( self.error == false) {
- cb(false, self.root);
- }
- };
-
- parser.write(string).close();
-};
-
-DomJS.prototype.reset = function() {
- this.root = null;
- this.stack = new Array();
- this.currElement = null;
- this.error = false;
-};
-
-var escape = function(string) {
- return string.replace(/&/g, '&').replace(/>/g, '>').replace(/</g, '<').replace(/"/g, '"').replace(/'/g, ''');
-};
-
-
-Element = function(name, attributes, children ) {
- this.name = name;
- this.attributes = attributes || [];
- this.children = children || [];
-}
-Element.prototype.toXml = function(sb) {
- if (typeof sb == 'undefined') {
- sb = {buf:''}; // Strings are pass by value in JS it seems
- }
- sb.buf += '<' + this.name;
- for (att in this.attributes) {
-
- sb.buf += ' ' + att + '="' + escape(this.attributes[att]) + '"';
- }
- if (this.children.length != 0) {
- sb.buf += '>';
- for (var i = 0 ; i < this.children.length ; i++) {
- this.children[i].toXml(sb);
- }
- sb.buf += '</' + this.name + '>';
- }
- else {
- sb.buf += '/>';
- }
- return sb.buf;
-};
-Element.prototype.firstChild = function() {
- if ( this.children.length > 0) {
- return this.children[0];
- }
- return null;
-};
-Element.prototype.text = function() {
- if ( this.children.length > 0) {
- if (typeof this.children[0].text == 'string') {
- return this.children[0].text;
- };
- }
- return null;
-};
-
-Text = function(data){
- this.text = data;
-};
-Text.prototype.toXml = function(sb) {
- sb.buf += escape(this.text);
-};
-
-Comment = function(comment) {
- this.comment = comment;
-};
-Comment.prototype.toXml = function(sb) {
- sb.buf += '<!--' + this.comment + '-->';
-};
-
-CDATASection = function(data){
- this.text = data || '';
-};
-CDATASection.prototype.toXml = function(sb) {
- sb.buf += '<![CDATA[' + this.text + ']]>';
-};
-CDATASection.prototype.appendData = function(data) {
- this.text += data;
-};
-
-
-
-
diff --git a/latest/encoding/sax.js b/latest/encoding/sax.js
deleted file mode 100644
index f982712..0000000
--- a/latest/encoding/sax.js
+++ /dev/null
@@ -1,1005 +0,0 @@
-// wrapper for non-node envs
-;(function (sax) {
-
-sax.parser = function (strict, opt) { return new SAXParser(strict, opt) }
-sax.SAXParser = SAXParser
-sax.SAXStream = SAXStream
-sax.createStream = createStream
-
-// When we pass the MAX_BUFFER_LENGTH position, start checking for buffer overruns.
-// When we check, schedule the next check for MAX_BUFFER_LENGTH - (max(buffer lengths)),
-// since that's the earliest that a buffer overrun could occur. This way, checks are
-// as rare as required, but as often as necessary to ensure never crossing this bound.
-// Furthermore, buffers are only tested at most once per write(), so passing a very
-// large string into write() might have undesirable effects, but this is manageable by
-// the caller, so it is assumed to be safe. Thus, a call to write() may, in the extreme
-// edge case, result in creating at most one complete copy of the string passed in.
-// Set to Infinity to have unlimited buffers.
-sax.MAX_BUFFER_LENGTH = 64 * 1024
-
-var buffers = [
- "comment", "sgmlDecl", "textNode", "tagName", "doctype",
- "procInstName", "procInstBody", "entity", "attribName",
- "attribValue", "cdata", "script"
-]
-
-sax.EVENTS = // for discoverability.
- [ "text"
- , "processinginstruction"
- , "sgmldeclaration"
- , "doctype"
- , "comment"
- , "attribute"
- , "opentag"
- , "closetag"
- , "opencdata"
- , "cdata"
- , "closecdata"
- , "error"
- , "end"
- , "ready"
- , "script"
- , "opennamespace"
- , "closenamespace"
- ]
-
-function SAXParser (strict, opt) {
- if (!(this instanceof SAXParser)) return new SAXParser(strict, opt)
-
- var parser = this
- clearBuffers(parser)
- parser.q = parser.c = ""
- parser.bufferCheckPosition = sax.MAX_BUFFER_LENGTH
- parser.opt = opt || {}
- parser.tagCase = parser.opt.lowercasetags ? "toLowerCase" : "toUpperCase"
- parser.tags = []
- parser.closed = parser.closedRoot = parser.sawRoot = false
- parser.tag = parser.error = null
- parser.strict = !!strict
- parser.noscript = !!(strict || parser.opt.noscript)
- parser.state = S.BEGIN
- parser.ENTITIES = Object.create(sax.ENTITIES)
- parser.attribList = []
-
- // namespaces form a prototype chain.
- // it always points at the current tag,
- // which protos to its parent tag.
- if (parser.opt.xmlns) parser.ns = Object.create(rootNS)
-
- // mostly just for error reporting
- parser.position = parser.line = parser.column = 0
- emit(parser, "onready")
-}
-
-if (!Object.create) Object.create = function (o) {
- function f () { this.__proto__ = o }
- f.prototype = o
- return new f
-}
-
-if (!Object.getPrototypeOf) Object.getPrototypeOf = function (o) {
- return o.__proto__
-}
-
-if (!Object.keys) Object.keys = function (o) {
- var a = []
- for (var i in o) if (o.hasOwnProperty(i)) a.push(i)
- return a
-}
-
-function checkBufferLength (parser) {
- var maxAllowed = Math.max(sax.MAX_BUFFER_LENGTH, 10)
- , maxActual = 0
- for (var i = 0, l = buffers.length; i < l; i ++) {
- var len = parser[buffers[i]].length
- if (len > maxAllowed) {
- // Text/cdata nodes can get big, and since they're buffered,
- // we can get here under normal conditions.
- // Avoid issues by emitting the text node now,
- // so at least it won't get any bigger.
- switch (buffers[i]) {
- case "textNode":
- closeText(parser)
- break
-
- case "cdata":
- emitNode(parser, "oncdata", parser.cdata)
- parser.cdata = ""
- break
-
- case "script":
- emitNode(parser, "onscript", parser.script)
- parser.script = ""
- break
-
- default:
- error(parser, "Max buffer length exceeded: "+buffers[i])
- }
- }
- maxActual = Math.max(maxActual, len)
- }
- // schedule the next check for the earliest possible buffer overrun.
- parser.bufferCheckPosition = (sax.MAX_BUFFER_LENGTH - maxActual)
- + parser.position
-}
-
-function clearBuffers (parser) {
- for (var i = 0, l = buffers.length; i < l; i ++) {
- parser[buffers[i]] = ""
- }
-}
-
-SAXParser.prototype =
- { end: function () { end(this) }
- , write: write
- , resume: function () { this.error = null; return this }
- , close: function () { return this.write(null) }
- }
-
-try {
- var Stream = require("stream").Stream
-} catch (ex) {
- var Stream = function () {}
-}
-
-
-var streamWraps = sax.EVENTS.filter(function (ev) {
- return ev !== "error" && ev !== "end"
-})
-
-function createStream (strict, opt) {
- return new SAXStream(strict, opt)
-}
-
-function SAXStream (strict, opt) {
- if (!(this instanceof SAXStream)) return new SAXStream(strict, opt)
-
- Stream.apply(me)
-
- this._parser = new SAXParser(strict, opt)
- this.writable = true
- this.readable = true
-
-
- var me = this
-
- this._parser.onend = function () {
- me.emit("end")
- }
-
- this._parser.onerror = function (er) {
- me.emit("error", er)
-
- // if didn't throw, then means error was handled.
- // go ahead and clear error, so we can write again.
- me._parser.error = null
- }
-
- streamWraps.forEach(function (ev) {
- Object.defineProperty(me, "on" + ev, {
- get: function () { return me._parser["on" + ev] },
- set: function (h) {
- if (!h) {
- me.removeAllListeners(ev)
- return me._parser["on"+ev] = h
- }
- me.on(ev, h)
- },
- enumerable: true,
- configurable: false
- })
- })
-}
-
-SAXStream.prototype = Object.create(Stream.prototype,
- { constructor: { value: SAXStream } })
-
-SAXStream.prototype.write = function (data) {
- this._parser.write(data.toString())
- this.emit("data", data)
- return true
-}
-
-SAXStream.prototype.end = function (chunk) {
- if (chunk && chunk.length) this._parser.write(chunk.toString())
- this._parser.end()
- return true
-}
-
-SAXStream.prototype.on = function (ev, handler) {
- var me = this
- if (!me._parser["on"+ev] && streamWraps.indexOf(ev) !== -1) {
- me._parser["on"+ev] = function () {
- var args = arguments.length === 1 ? [arguments[0]]
- : Array.apply(null, arguments)
- args.splice(0, 0, ev)
- me.emit.apply(me, args)
- }
- }
-
- return Stream.prototype.on.call(me, ev, handler)
-}
-
-
-
-// character classes and tokens
-var whitespace = "\r\n\t "
- // this really needs to be replaced with character classes.
- // XML allows all manner of ridiculous numbers and digits.
- , number = "0124356789"
- , letter = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
- // (Letter | "_" | ":")
- , nameStart = letter+"_:"
- , nameBody = nameStart+number+"-."
- , quote = "'\""
- , entity = number+letter+"#"
- , attribEnd = whitespace + ">"
- , CDATA = "[CDATA["
- , DOCTYPE = "DOCTYPE"
- , XML_NAMESPACE = "http://www.w3.org/XML/1998/namespace"
- , XMLNS_NAMESPACE = "http://www.w3.org/2000/xmlns/"
- , rootNS = { xml: XML_NAMESPACE, xmlns: XMLNS_NAMESPACE }
-
-// turn all the string character sets into character class objects.
-whitespace = charClass(whitespace)
-number = charClass(number)
-letter = charClass(letter)
-nameStart = charClass(nameStart)
-nameBody = charClass(nameBody)
-quote = charClass(quote)
-entity = charClass(entity)
-attribEnd = charClass(attribEnd)
-
-function charClass (str) {
- return str.split("").reduce(function (s, c) {
- s[c] = true
- return s
- }, {})
-}
-
-function is (charclass, c) {
- return charclass[c]
-}
-
-function not (charclass, c) {
- return !charclass[c]
-}
-
-var S = 0
-sax.STATE =
-{ BEGIN : S++
-, TEXT : S++ // general stuff
-, TEXT_ENTITY : S++ // & and such.
-, OPEN_WAKA : S++ // <
-, SGML_DECL : S++ // <!BLARG
-, SGML_DECL_QUOTED : S++ // <!BLARG foo "bar
-, DOCTYPE : S++ // <!DOCTYPE
-, DOCTYPE_QUOTED : S++ // <!DOCTYPE "//blah
-, DOCTYPE_DTD : S++ // <!DOCTYPE "//blah" [ ...
-, DOCTYPE_DTD_QUOTED : S++ // <!DOCTYPE "//blah" [ "foo
-, COMMENT_STARTING : S++ // <!-
-, COMMENT : S++ // <!--
-, COMMENT_ENDING : S++ // <!-- blah -
-, COMMENT_ENDED : S++ // <!-- blah --
-, CDATA : S++ // <![CDATA[ something
-, CDATA_ENDING : S++ // ]
-, CDATA_ENDING_2 : S++ // ]]
-, PROC_INST : S++ // <?hi
-, PROC_INST_BODY : S++ // <?hi there
-, PROC_INST_QUOTED : S++ // <?hi "there
-, PROC_INST_ENDING : S++ // <?hi "there" ?
-, OPEN_TAG : S++ // <strong
-, OPEN_TAG_SLASH : S++ // <strong /
-, ATTRIB : S++ // <a
-, ATTRIB_NAME : S++ // <a foo
-, ATTRIB_NAME_SAW_WHITE : S++ // <a foo _
-, ATTRIB_VALUE : S++ // <a foo=
-, ATTRIB_VALUE_QUOTED : S++ // <a foo="bar
-, ATTRIB_VALUE_UNQUOTED : S++ // <a foo=bar
-, ATTRIB_VALUE_ENTITY_Q : S++ // <foo bar="""
-, ATTRIB_VALUE_ENTITY_U : S++ // <foo bar="
-, CLOSE_TAG : S++ // </a
-, CLOSE_TAG_SAW_WHITE : S++ // </a >
-, SCRIPT : S++ // <script> ...
-, SCRIPT_ENDING : S++ // <script> ... <
-}
-
-sax.ENTITIES =
-{ "apos" : "'"
-, "quot" : "\""
-, "amp" : "&"
-, "gt" : ">"
-, "lt" : "<"
-}
-
-for (var S in sax.STATE) sax.STATE[sax.STATE[S]] = S
-
-// shorthand
-S = sax.STATE
-
-function emit (parser, event, data) {
- parser[event] && parser[event](data)
-}
-
-function emitNode (parser, nodeType, data) {
- if (parser.textNode) closeText(parser)
- emit(parser, nodeType, data)
-}
-
-function closeText (parser) {
- parser.textNode = textopts(parser.opt, parser.textNode)
- if (parser.textNode) emit(parser, "ontext", parser.textNode)
- parser.textNode = ""
-}
-
-function textopts (opt, text) {
- if (opt.trim) text = text.trim()
- if (opt.normalize) text = text.replace(/\s+/g, " ")
- return text
-}
-
-function error (parser, er) {
- closeText(parser)
- er += "\nLine: "+parser.line+
- "\nColumn: "+parser.column+
- "\nChar: "+parser.c
- er = new Error(er)
- parser.error = er
- emit(parser, "onerror", er)
- return parser
-}
-
-function end (parser) {
- if (parser.state !== S.TEXT) error(parser, "Unexpected end")
- closeText(parser)
- parser.c = ""
- parser.closed = true
- emit(parser, "onend")
- SAXParser.call(parser, parser.strict, parser.opt)
- return parser
-}
-
-function strictFail (parser, message) {
- if (parser.strict) error(parser, message)
-}
-
-function newTag (parser) {
- if (!parser.strict) parser.tagName = parser.tagName[parser.tagCase]()
- var parent = parser.tags[parser.tags.length - 1] || parser
- , tag = parser.tag = { name : parser.tagName, attributes : {} }
-
- // will be overridden if tag contails an xmlns="foo" or xmlns:foo="bar"
- if (parser.opt.xmlns) tag.ns = parent.ns
- parser.attribList.length = 0
-}
-
-function qname (name) {
- var i = name.indexOf(":")
- , qualName = i < 0 ? [ "", name ] : name.split(":")
- , prefix = qualName[0]
- , local = qualName[1]
-
- // <x "xmlns"="http://foo">
- if (name === "xmlns") {
- prefix = "xmlns"
- local = ""
- }
-
- return { prefix: prefix, local: local }
-}
-
-function attrib (parser) {
- if (parser.opt.xmlns) {
- var qn = qname(parser.attribName)
- , prefix = qn.prefix
- , local = qn.local
-
- if (prefix === "xmlns") {
- // namespace binding attribute; push the binding into scope
- if (local === "xml" && parser.attribValue !== XML_NAMESPACE) {
- strictFail( parser
- , "xml: prefix must be bound to " + XML_NAMESPACE + "\n"
- + "Actual: " + parser.attribValue )
- } else if (local === "xmlns" && parser.attribValue !== XMLNS_NAMESPACE) {
- strictFail( parser
- , "xmlns: prefix must be bound to " + XMLNS_NAMESPACE + "\n"
- + "Actual: " + parser.attribValue )
- } else {
- var tag = parser.tag
- , parent = parser.tags[parser.tags.length - 1] || parser
- if (tag.ns === parent.ns) {
- tag.ns = Object.create(parent.ns)
- }
- tag.ns[local] = parser.attribValue
- }
- }
-
- // defer onattribute events until all attributes have been seen
- // so any new bindings can take effect; preserve attribute order
- // so deferred events can be emitted in document order
- parser.attribList.push([parser.attribName, parser.attribValue])
- } else {
- // in non-xmlns mode, we can emit the event right away
- parser.tag.attributes[parser.attribName] = parser.attribValue
- emitNode( parser
- , "onattribute"
- , { name: parser.attribName
- , value: parser.attribValue } )
- }
-
- parser.attribName = parser.attribValue = ""
-}
-
-function openTag (parser, selfClosing) {
- if (parser.opt.xmlns) {
- // emit namespace binding events
- var tag = parser.tag
-
- // add namespace info to tag
- var qn = qname(parser.tagName)
- tag.prefix = qn.prefix
- tag.local = qn.local
- tag.uri = tag.ns[qn.prefix] || qn.prefix
-
- if (tag.prefix && !tag.uri) {
- strictFail(parser, "Unbound namespace prefix: "
- + JSON.stringify(parser.tagName))
- }
-
- var parent = parser.tags[parser.tags.length - 1] || parser
- if (tag.ns && parent.ns !== tag.ns) {
- Object.keys(tag.ns).forEach(function (p) {
- emitNode( parser
- , "onopennamespace"
- , { prefix: p , uri: tag.ns[p] } )
- })
- }
-
- // handle deferred onattribute events
- for (var i = 0, l = parser.attribList.length; i < l; i ++) {
- var nv = parser.attribList[i]
- var name = nv[0]
- , value = nv[1]
- , qualName = qname(name)
- , prefix = qualName.prefix
- , local = qualName.local
- , uri = tag.ns[prefix] || ""
- , a = { name: name
- , value: value
- , prefix: prefix
- , local: local
- , uri: uri
- }
-
- // if there's any attributes with an undefined namespace,
- // then fail on them now.
- if (prefix && prefix != "xmlns" && !uri) {
- strictFail(parser, "Unbound namespace prefix: "
- + JSON.stringify(prefix))
- a.uri = prefix
- }
- parser.tag.attributes[name] = a
- emitNode(parser, "onattribute", a)
- }
- parser.attribList.length = 0
- }
-
- // process the tag
- parser.sawRoot = true
- parser.tags.push(parser.tag)
- emitNode(parser, "onopentag", parser.tag)
- if (!selfClosing) {
- // special case for <script> in non-strict mode.
- if (!parser.noscript && parser.tagName.toLowerCase() === "script") {
- parser.state = S.SCRIPT
- } else {
- parser.state = S.TEXT
- }
- parser.tag = null
- parser.tagName = ""
- }
- parser.attribName = parser.attribValue = ""
- parser.attribList.length = 0
-}
-
-function closeTag (parser) {
- if (!parser.tagName) {
- strictFail(parser, "Weird empty close tag.")
- parser.textNode += "</>"
- parser.state = S.TEXT
- return
- }
- // first make sure that the closing tag actually exists.
- // <a><b></c></b></a> will close everything, otherwise.
- var t = parser.tags.length
- var tagName = parser.tagName
- if (!parser.strict) tagName = tagName[parser.tagCase]()
- var closeTo = tagName
- while (t --) {
- var close = parser.tags[t]
- if (close.name !== closeTo) {
- // fail the first time in strict mode
- strictFail(parser, "Unexpected close tag")
- } else break
- }
-
- // didn't find it. we already failed for strict, so just abort.
- if (t < 0) {
- strictFail(parser, "Unmatched closing tag: "+parser.tagName)
- parser.textNode += "</" + parser.tagName + ">"
- parser.state = S.TEXT
- return
- }
- parser.tagName = tagName
- var s = parser.tags.length
- while (s --> t) {
- var tag = parser.tag = parser.tags.pop()
- parser.tagName = parser.tag.name
- emitNode(parser, "onclosetag", parser.tagName)
-
- var x = {}
- for (var i in tag.ns) x[i] = tag.ns[i]
-
- var parent = parser.tags[parser.tags.length - 1] || parser
- if (parser.opt.xmlns && tag.ns !== parent.ns) {
- // remove namespace bindings introduced by tag
- Object.keys(tag.ns).forEach(function (p) {
- var n = tag.ns[p]
- emitNode(parser, "onclosenamespace", { prefix: p, uri: n })
- })
- }
- }
- if (t === 0) parser.closedRoot = true
- parser.tagName = parser.attribValue = parser.attribName = ""
- parser.attribList.length = 0
- parser.state = S.TEXT
-}
-
-function parseEntity (parser) {
- var entity = parser.entity.toLowerCase()
- , num
- , numStr = ""
- if (parser.ENTITIES[entity]) return parser.ENTITIES[entity]
- if (entity.charAt(0) === "#") {
- if (entity.charAt(1) === "x") {
- entity = entity.slice(2)
- num = parseInt(entity, 16)
- numStr = num.toString(16)
- } else {
- entity = entity.slice(1)
- num = parseInt(entity, 10)
- numStr = num.toString(10)
- }
- }
- entity = entity.replace(/^0+/, "")
- if (numStr.toLowerCase() !== entity) {
- strictFail(parser, "Invalid character entity")
- return "&"+parser.entity + ";"
- }
- return String.fromCharCode(num)
-}
-
-function write (chunk) {
- var parser = this
- if (this.error) throw this.error
- if (parser.closed) return error(parser,
- "Cannot write after close. Assign an onready handler.")
- if (chunk === null) return end(parser)
- var i = 0, c = ""
- while (parser.c = c = chunk.charAt(i++)) {
- parser.position ++
- if (c === "\n") {
- parser.line ++
- parser.column = 0
- } else parser.column ++
- switch (parser.state) {
-
- case S.BEGIN:
- if (c === "<") parser.state = S.OPEN_WAKA
- else if (not(whitespace,c)) {
- // have to process this as a text node.
- // weird, but happens.
- strictFail(parser, "Non-whitespace before first tag.")
- parser.textNode = c
- parser.state = S.TEXT
- }
- continue
-
- case S.TEXT:
- if (parser.sawRoot && !parser.closedRoot) {
- var starti = i-1
- while (c && c!=="<" && c!=="&") {
- c = chunk.charAt(i++)
- if (c) {
- parser.position ++
- if (c === "\n") {
- parser.line ++
- parser.column = 0
- } else parser.column ++
- }
- }
- parser.textNode += chunk.substring(starti, i-1)
- }
- if (c === "<") parser.state = S.OPEN_WAKA
- else {
- if (not(whitespace, c) && (!parser.sawRoot || parser.closedRoot))
- strictFail("Text data outside of root node.")
- if (c === "&") parser.state = S.TEXT_ENTITY
- else parser.textNode += c
- }
- continue
-
- case S.SCRIPT:
- // only non-strict
- if (c === "<") {
- parser.state = S.SCRIPT_ENDING
- } else parser.script += c
- continue
-
- case S.SCRIPT_ENDING:
- if (c === "/") {
- emitNode(parser, "onscript", parser.script)
- parser.state = S.CLOSE_TAG
- parser.script = ""
- parser.tagName = ""
- } else {
- parser.script += "<" + c
- parser.state = S.SCRIPT
- }
- continue
-
- case S.OPEN_WAKA:
- // either a /, ?, !, or text is coming next.
- if (c === "!") {
- parser.state = S.SGML_DECL
- parser.sgmlDecl = ""
- } else if (is(whitespace, c)) {
- // wait for it...
- } else if (is(nameStart,c)) {
- parser.startTagPosition = parser.position - 1
- parser.state = S.OPEN_TAG
- parser.tagName = c
- } else if (c === "/") {
- parser.startTagPosition = parser.position - 1
- parser.state = S.CLOSE_TAG
- parser.tagName = ""
- } else if (c === "?") {
- parser.state = S.PROC_INST
- parser.procInstName = parser.procInstBody = ""
- } else {
- strictFail(parser, "Unencoded <")
- parser.textNode += "<" + c
- parser.state = S.TEXT
- }
- continue
-
- case S.SGML_DECL:
- if ((parser.sgmlDecl+c).toUpperCase() === CDATA) {
- emitNode(parser, "onopencdata")
- parser.state = S.CDATA
- parser.sgmlDecl = ""
- parser.cdata = ""
- } else if (parser.sgmlDecl+c === "--") {
- parser.state = S.COMMENT
- parser.comment = ""
- parser.sgmlDecl = ""
- } else if ((parser.sgmlDecl+c).toUpperCase() === DOCTYPE) {
- parser.state = S.DOCTYPE
- if (parser.doctype || parser.sawRoot) strictFail(parser,
- "Inappropriately located doctype declaration")
- parser.doctype = ""
- parser.sgmlDecl = ""
- } else if (c === ">") {
- emitNode(parser, "onsgmldeclaration", parser.sgmlDecl)
- parser.sgmlDecl = ""
- parser.state = S.TEXT
- } else if (is(quote, c)) {
- parser.state = S.SGML_DECL_QUOTED
- parser.sgmlDecl += c
- } else parser.sgmlDecl += c
- continue
-
- case S.SGML_DECL_QUOTED:
- if (c === parser.q) {
- parser.state = S.SGML_DECL
- parser.q = ""
- }
- parser.sgmlDecl += c
- continue
-
- case S.DOCTYPE:
- if (c === ">") {
- parser.state = S.TEXT
- emitNode(parser, "ondoctype", parser.doctype)
- parser.doctype = true // just remember that we saw it.
- } else {
- parser.doctype += c
- if (c === "[") parser.state = S.DOCTYPE_DTD
- else if (is(quote, c)) {
- parser.state = S.DOCTYPE_QUOTED
- parser.q = c
- }
- }
- continue
-
- case S.DOCTYPE_QUOTED:
- parser.doctype += c
- if (c === parser.q) {
- parser.q = ""
- parser.state = S.DOCTYPE
- }
- continue
-
- case S.DOCTYPE_DTD:
- parser.doctype += c
- if (c === "]") parser.state = S.DOCTYPE
- else if (is(quote,c)) {
- parser.state = S.DOCTYPE_DTD_QUOTED
- parser.q = c
- }
- continue
-
- case S.DOCTYPE_DTD_QUOTED:
- parser.doctype += c
- if (c === parser.q) {
- parser.state = S.DOCTYPE_DTD
- parser.q = ""
- }
- continue
-
- case S.COMMENT:
- if (c === "-") parser.state = S.COMMENT_ENDING
- else parser.comment += c
- continue
-
- case S.COMMENT_ENDING:
- if (c === "-") {
- parser.state = S.COMMENT_ENDED
- parser.comment = textopts(parser.opt, parser.comment)
- if (parser.comment) emitNode(parser, "oncomment", parser.comment)
- parser.comment = ""
- } else {
- parser.comment += "-" + c
- parser.state = S.COMMENT
- }
- continue
-
- case S.COMMENT_ENDED:
- if (c !== ">") {
- strictFail(parser, "Malformed comment")
- // allow <!-- blah -- bloo --> in non-strict mode,
- // which is a comment of " blah -- bloo "
- parser.comment += "--" + c
- parser.state = S.COMMENT
- } else parser.state = S.TEXT
- continue
-
- case S.CDATA:
- if (c === "]") parser.state = S.CDATA_ENDING
- else parser.cdata += c
- continue
-
- case S.CDATA_ENDING:
- if (c === "]") parser.state = S.CDATA_ENDING_2
- else {
- parser.cdata += "]" + c
- parser.state = S.CDATA
- }
- continue
-
- case S.CDATA_ENDING_2:
- if (c === ">") {
- if (parser.cdata) emitNode(parser, "oncdata", parser.cdata)
- emitNode(parser, "onclosecdata")
- parser.cdata = ""
- parser.state = S.TEXT
- } else if (c === "]") {
- parser.cdata += "]"
- } else {
- parser.cdata += "]]" + c
- parser.state = S.CDATA
- }
- continue
-
- case S.PROC_INST:
- if (c === "?") parser.state = S.PROC_INST_ENDING
- else if (is(whitespace, c)) parser.state = S.PROC_INST_BODY
- else parser.procInstName += c
- continue
-
- case S.PROC_INST_BODY:
- if (!parser.procInstBody && is(whitespace, c)) continue
- else if (c === "?") parser.state = S.PROC_INST_ENDING
- else if (is(quote, c)) {
- parser.state = S.PROC_INST_QUOTED
- parser.q = c
- parser.procInstBody += c
- } else parser.procInstBody += c
- continue
-
- case S.PROC_INST_ENDING:
- if (c === ">") {
- emitNode(parser, "onprocessinginstruction", {
- name : parser.procInstName,
- body : parser.procInstBody
- })
- parser.procInstName = parser.procInstBody = ""
- parser.state = S.TEXT
- } else {
- parser.procInstBody += "?" + c
- parser.state = S.PROC_INST_BODY
- }
- continue
-
- case S.PROC_INST_QUOTED:
- parser.procInstBody += c
- if (c === parser.q) {
- parser.state = S.PROC_INST_BODY
- parser.q = ""
- }
- continue
-
- case S.OPEN_TAG:
- if (is(nameBody, c)) parser.tagName += c
- else {
- newTag(parser)
- if (c === ">") openTag(parser)
- else if (c === "/") parser.state = S.OPEN_TAG_SLASH
- else {
- if (not(whitespace, c)) strictFail(
- parser, "Invalid character in tag name")
- parser.state = S.ATTRIB
- }
- }
- continue
-
- case S.OPEN_TAG_SLASH:
- if (c === ">") {
- openTag(parser, true)
- closeTag(parser)
- } else {
- strictFail(parser, "Forward-slash in opening tag not followed by >")
- parser.state = S.ATTRIB
- }
- continue
-
- case S.ATTRIB:
- // haven't read the attribute name yet.
- if (is(whitespace, c)) continue
- else if (c === ">") openTag(parser)
- else if (c === "/") parser.state = S.OPEN_TAG_SLASH
- else if (is(nameStart, c)) {
- parser.attribName = c
- parser.attribValue = ""
- parser.state = S.ATTRIB_NAME
- } else strictFail(parser, "Invalid attribute name")
- continue
-
- case S.ATTRIB_NAME:
- if (c === "=") parser.state = S.ATTRIB_VALUE
- else if (is(whitespace, c)) parser.state = S.ATTRIB_NAME_SAW_WHITE
- else if (is(nameBody, c)) parser.attribName += c
- else strictFail(parser, "Invalid attribute name")
- continue
-
- case S.ATTRIB_NAME_SAW_WHITE:
- if (c === "=") parser.state = S.ATTRIB_VALUE
- else if (is(whitespace, c)) continue
- else {
- strictFail(parser, "Attribute without value")
- parser.tag.attributes[parser.attribName] = ""
- parser.attribValue = ""
- emitNode(parser, "onattribute",
- { name : parser.attribName, value : "" })
- parser.attribName = ""
- if (c === ">") openTag(parser)
- else if (is(nameStart, c)) {
- parser.attribName = c
- parser.state = S.ATTRIB_NAME
- } else {
- strictFail(parser, "Invalid attribute name")
- parser.state = S.ATTRIB
- }
- }
- continue
-
- case S.ATTRIB_VALUE:
- if (is(whitespace, c)) continue
- else if (is(quote, c)) {
- parser.q = c
- parser.state = S.ATTRIB_VALUE_QUOTED
- } else {
- strictFail(parser, "Unquoted attribute value")
- parser.state = S.ATTRIB_VALUE_UNQUOTED
- parser.attribValue = c
- }
- continue
-
- case S.ATTRIB_VALUE_QUOTED:
- if (c !== parser.q) {
- if (c === "&") parser.state = S.ATTRIB_VALUE_ENTITY_Q
- else parser.attribValue += c
- continue
- }
- attrib(parser)
- parser.q = ""
- parser.state = S.ATTRIB
- continue
-
- case S.ATTRIB_VALUE_UNQUOTED:
- if (not(attribEnd,c)) {
- if (c === "&") parser.state = S.ATTRIB_VALUE_ENTITY_U
- else parser.attribValue += c
- continue
- }
- attrib(parser)
- if (c === ">") openTag(parser)
- else parser.state = S.ATTRIB
- continue
-
- case S.CLOSE_TAG:
- if (!parser.tagName) {
- if (is(whitespace, c)) continue
- else if (not(nameStart, c)) strictFail(parser,
- "Invalid tagname in closing tag.")
- else parser.tagName = c
- }
- else if (c === ">") closeTag(parser)
- else if (is(nameBody, c)) parser.tagName += c
- else {
- if (not(whitespace, c)) strictFail(parser,
- "Invalid tagname in closing tag")
- parser.state = S.CLOSE_TAG_SAW_WHITE
- }
- continue
-
- case S.CLOSE_TAG_SAW_WHITE:
- if (is(whitespace, c)) continue
- if (c === ">") closeTag(parser)
- else strictFail("Invalid characters in closing tag")
- continue
-
- case S.TEXT_ENTITY:
- case S.ATTRIB_VALUE_ENTITY_Q:
- case S.ATTRIB_VALUE_ENTITY_U:
- switch(parser.state) {
- case S.TEXT_ENTITY:
- var returnState = S.TEXT, buffer = "textNode"
- break
-
- case S.ATTRIB_VALUE_ENTITY_Q:
- var returnState = S.ATTRIB_VALUE_QUOTED, buffer = "attribValue"
- break
-
- case S.ATTRIB_VALUE_ENTITY_U:
- var returnState = S.ATTRIB_VALUE_UNQUOTED, buffer = "attribValue"
- break
- }
- if (c === ";") {
- parser[buffer] += parseEntity(parser)
- parser.entity = ""
- parser.state = returnState
- }
- else if (is(entity, c)) parser.entity += c
- else {
- strictFail("Invalid character entity")
- parser[buffer] += "&" + parser.entity + c
- parser.entity = ""
- parser.state = returnState
- }
- continue
-
- default:
- throw new Error(parser, "Unknown state: " + parser.state)
- }
- } // while
- // cdata blocks can get very big under normal conditions. emit and move on.
- // if (parser.state === S.CDATA && parser.cdata) {
- // emitNode(parser, "oncdata", parser.cdata)
- // parser.cdata = ""
- // }
- if (parser.position >= parser.bufferCheckPosition) checkBufferLength(parser)
- return parser
-}
-
-})(typeof exports === "undefined" ? sax = {} : exports)
\ No newline at end of file
diff --git a/latest/encoding/xml2object.js b/latest/encoding/xml2object.js
deleted file mode 100644
index c6711b6..0000000
--- a/latest/encoding/xml2object.js
+++ /dev/null
@@ -1,170 +0,0 @@
-/**
- * Simple xml 2 javascript object parser based on sax.js
- *
- * https://github.com/emberfeather/node-xml2object
- */
-var emitter = require('events').EventEmitter;
-var fs = require('fs');
-var sax = require('./sax');
-var util = require('util');
-
-var xml2object = function(xmlFile, elements) {
- elements = elements || [];
-
- this._hasStarted = false;
-
- var self = this;
- var currentObject;
- var inObject = false;
- var inObjectName;
- var ancestors = [];
-
- this.fileStream = fs.createReadStream(xmlFile);
- this.saxStream = sax.createStream(true);
-
- this.saxStream.on("opentag", function (args) {
- if(!inObject) {
- // If we are not in an object and not tracking the element
- // then we don't need to do anything
- if (elements.indexOf(args.name) < 0) {
- return;
- }
-
- // Start tracking a new object
- inObject = true;
- inObjectName = args.name;
-
- currentObject = {};
- }
-
- if (!(args.name in currentObject)) {
- currentObject[args.name] = args.attributes;
- } else if (!util.isArray(currentObject[args.name])) {
- // Put the existing object in an array.
- var newArray = [currentObject[args.name]];
-
- // Add the new object to the array.
- newArray.push(args.attributes);
-
- // Point to the new array.
- currentObject[args.name] = newArray;
- } else {
- // An array already exists, push the attributes on to it.
- currentObject[args.name].push(args.attributes);
- }
-
- // Store the current (old) parent.
- ancestors.push(currentObject);
-
- // We are now working with this object, so it becomes the current parent.
- if (currentObject[args.name] instanceof Array) {
- // If it is an array, get the last element of the array.
- currentObject = currentObject[args.name][currentObject[args.name].length - 1];
- } else {
- // Otherwise, use the object itself.
- currentObject = currentObject[args.name];
- }
- });
-
- this.saxStream.on("text", function (data) {
- if(!inObject) {
- return;
- }
-
- data = data.trim();
-
- if (!data.length) {
- return;
- }
-
- currentObject['$t'] = (currentObject['$t'] || "") + data;
- });
-
- this.saxStream.on("closetag", function (name) {
- if(!inObject) {
- return;
- }
-
- if(inObject && inObjectName === name) {
- // Finished building the object
- self.emit('object', name, currentObject);
-
- inObject = false;
- ancestors = [];
-
- return;
- }
-
- if(ancestors.length) {
- var ancestor = ancestors.pop();
- var keys = Object.keys(currentObject);
-
- if (keys.length == 1 && '$t' in currentObject) {
- // Convert the text only objects into just the text
- if (ancestor[name] instanceof Array) {
- ancestor[name].push(ancestor[name].pop()['$t']);
- } else {
- ancestor[name] = currentObject['$t'];
- }
- } else if (!keys.length) {
- // Remove empty keys
- delete ancestor[name];
- }
-
- currentObject = ancestor;
- } else {
- currentObject = {};
- }
- });
-
- // Rebroadcast the error and keep going
- this.saxStream.on("error", function (e) {
- this.emit('error', e);
-
- // clear the error and resume
- this._parser.error = null;
- this._parser.resume();
- });
-
- // Rebroadcast the end of the file read
- this.fileStream.on("end", function() {
- self.emit("end");
- });
-};
-
-util.inherits(xml2object, emitter);
-
-xml2object.prototype.start = function() {
- // Can only start once
- if(this._hasStarted) {
- return;
- }
-
- this._hasStarted = true;
-
- this.emit('start');
-
- // Start the streaming!
- this.fileStream.pipe(this.saxStream);
-};
-
-
-//TEST///////////////////////////////////////////////////////////////////////////////
-//var xml2object = require('xml2object');
-
-// Create a new xml parser with an array of xml elements to look for
-/*var parser = new xml2object('./src/encoding/ContentObject1.xml', [ 'ContentObject' ]);
-
-// Bind to the object event to work with the objects found in the XML file
-parser.on('object', function(name, obj) {
- console.log('Found an object: %s', name);
- console.log(obj);
-});
-
-// Bind to the file end event to tell when the file is done being streamed
-parser.on('end', function(name, obj) {
- console.log('Finished parsing xml!');
-});
-
-// Start parsing the XML
-parser.start();*/
\ No newline at end of file
diff --git a/latest/index.html b/latest/index.html
deleted file mode 100644
index 0ff6078..0000000
--- a/latest/index.html
+++ /dev/null
@@ -1,74 +0,0 @@
-<?xml version = "1.0" encoding="utf-8" ?>
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
-"DTD/xhtml1-strict.dtd">
-<html xmlns = "http://www.w3.org/1999/xhtml">
-
-<head>
- <title>NDN Request Example</title>
- <script type="text/javascript" src="java_socket_bridge.js"></script>
-
- <script type="text/javascript" src="CCNProtocolDTags.js"></script>
-
- <script type="text/javascript" src="CCNTime.js"></script>
-
- <script type="text/javascript" src="ContentName.js"></script>
-
- <script type="text/javascript" src="ContentObject.js"></script>
-
- <script type="text/javascript" src="DateFormat.js"></script>
-
- <script type="text/javascript" src="Exclude.js"></script>
-
- <script type="text/javascript" src="ExcludeAny.js"></script>
-
- <script type="text/javascript" src="ExcludeComponent.js"></script>
-
- <script type="text/javascript" src="Interest.js"></script>
-
- <script type="text/javascript" src="KeyLocator.js"></script>
-
- <script type="text/javascript" src="KeyName.js"></script>
-
- <script type="text/javascript" src="PublisherID.js"></script>
- <script type="text/javascript" src="Signature.js"></script>
-
- <script type="text/javascript" src="SignedInfo.js"></script>
-
-
-
- <script type="text/javascript" src="encoding/BinaryXMLCodec.js"></script>
-
- <script type="text/javascript" src="encoding/BinaryXMLDecoder.js"></script>
-
- <script type="text/javascript" src="encoding/DataUtils.js"></script>
-
-
-
- <script type="text/javascript">
- function run(){
- console.log(document.getElementById('ip').value);
- createRoute(document.getElementById('ip').value,document.getElementById('port').value);
- document.getElementById('result').innerHTML = queryPrefix(document.getElementById('contentname').value);
-
- //createRoute('localhost', 9695);
- //document.getElementById('result').innerHTML = queryPrefix('01d2f2faa55041524300fa9d000102000000');
- }
- </script>
-
-</head>
-<body>
- <form>
- <input id="ip" type="text" name="IP" value="localhost" /> IP<br />
- <input id="port" type="text" name="PORT" value="9695" /> URL<br />
- <input id="contentname" type="text" name="CONTENTNAME" value="/PARC/%00%01%02" /> Content Name<br />
- </form>
- <button onclick="run()">Run!</button>
- <div>
- <applet id="JavaSocketBridge" archive="JavaSocketBridge.jar" code="JavaSocketBridge.class" width="0" height="0">
- </applet>
- </div>
-
- <p id="result"></p>
-
-</body>
-</html>
\ No newline at end of file
diff --git a/latest/java_socket_bridge.js b/latest/java_socket_bridge.js
deleted file mode 100644
index ee91dcb..0000000
--- a/latest/java_socket_bridge.js
+++ /dev/null
@@ -1,63 +0,0 @@
-// Global variables
-var java_socket_bridge_ready_flag = false;
-
-var ndnport =null;
-var ndnurl=null;
-
-// Applet reports it is ready to use
-function java_socket_bridge_ready(){
- java_socket_bridge_ready_flag = true;
-}
-
-function createRoute(url, port){
- ndnport = port;
- ndnurl=url;
-}
-
-// Connect to a given url and port
-function queryPrefix(message){
- if(ndnport!=null && ndnurl!=null){
- var newMessage ='';
-
- enc = new BinaryXMLEncoder();
-
- //encoder.beginEncoding();
-
-
- int = new Interest(new ContentName(['PARC','%00','%01','%02']));
-
- int.encode(enc);
-
- var hex = byte2hex(enc.ostream);
-
- console.log('Conect and start '+ ndnurl +':'+ndnport+'-'+message);
-
- return get_java_socket_bridge().connectAndStart(ndnurl,ndnport,message);
- }
- else{
- console.log('ERROR URL OR PORT NOT SET');
- return '';
- }
-
-}
-
-
-function byte2hex(bytearray){var result = [];
- var length = bytearray.length;
- for (var i = 0;i < length;++i) {
- result.push(AddFillerLeft(bytearray[i].toString(16).toUpperCase(), '0', 2));
- }
- return result.join('');
-}
-// Get something from the socket
-function on_socket_get(message){}
-
-// Report an error
-function on_socket_error(message){
- alert(message);
-}
-
-// Get the applet object
-function get_java_socket_bridge(){
- return document.getElementById('JavaSocketBridge');
-}
\ No newline at end of file
diff --git a/src-old/ContentObject.js b/src-old/ContentObject.js
deleted file mode 100644
index 0802479..0000000
--- a/src-old/ContentObject.js
+++ /dev/null
@@ -1,12 +0,0 @@
-// JavaScript Document
-
-var ContentObject = function ContentObject(_Signature,_Name,_SignedInfo,_Content){
-
- this.Signature = _Signature;
- this.Name = _Name;
- this.SignedInfo = _SignedInfo;
- this.Content=_Content;
-
-};
-
-exports.ContentObject = ContentObject;
diff --git a/src-old/ContentObjectDecoder.js b/src-old/ContentObjectDecoder.js
deleted file mode 100644
index 83e5aee..0000000
--- a/src-old/ContentObjectDecoder.js
+++ /dev/null
@@ -1,214 +0,0 @@
-// JavaScript Document
-/*
- @author: Meki Cherkaoui
-*/
-var DTAGS = require('./TAG').d;
-var TT = require('./TAG').tt;
-
-
-var ContentObjectEncoder = function ContentObjectEncoder(){
-
-
-};
-
-
-/*
- TT bits specify the type of nodes
-
-*/
-var CCN_TT_BITS=3;
-var CCN_TT_MASK=((1 << CCN_TT_BITS) - 1);
-var CCN_MAX_TINY=((1 << (7-CCN_TT_BITS)) - 1);
-var CCN_TT_HBIT=((1 << 7));
-
-Encoder.prototype.encodeContentObject = function(_ContentObject){
-
- //var slit = function splitNumber(number){
- //};
- var i = 0;
-
- var addToBuffer = function addToBuffer(buffer,number,tt){
-
-
- var sizeOfBuffer = 1+8*((sizeof(number)+6)/7);
-
-
-
- splitNumbers = new Buffer(sizeOfBuffer);
-
- number >>= 7-CCN_TT_BITS;
-
- splitNumbers.write((CCN_TT_HBIT & ~require('./TAG').d.CCN_CLOSE) |
- ((number & CCN_MAX_TINY) << CCN_TT_BITS) |
- (CCN_TT_MASK & tt));
-
- var index = 1;
- while(number>0){
- splitNumbers.write( number & ~CCN_TT_HBIT |require('./TAG').d.CCN_CLOSE);
- index++;
- number>>=7;
- }
-
- for( i=0, j=sizeofBuffer-1;i <sizeOfBuffer;i++,j--) {
-
- buffer[index+i] = splitNumbers[j];
- }
-
- };
- //NOTE NUMBETR= SIZE
- var addToBufferData = function addToBuffer(buffer,data,tt){
-
- var number = sizeof(data);
- var sizeOfBuffer = 1+8*((sizeof(number)+6)/7);
-
- splitNumbers = new Buffer(sizeOfBuffer);
-
- number >>= 7-CCN_TT_BITS;
-
- splitNumbers.write((CCN_TT_HBIT & ~require('./TAG').d.CCN_CLOSE) |
- ((number & CCN_MAX_TINY) << CCN_TT_BITS) |
- (CCN_TT_MASK & tt));
-
-
- while(number>0){
- splitNumbers.write( number & ~CCN_TT_HBIT |require('./TAG').d.CCN_CLOSE);
- index++;
- number>>=7;
- }
-
- for( i=0, j=sizeofBuffer-1;i <sizeOfBuffer;i++,j--) {
-
- buffer[index+i] = splitNumbers[j];
- }
-
- for(i=0;i<10;i++){
- buffer[index+i] = data[i];
- }
-
- };
-
- //NOTE NUMBETR= SIZE
- var addName = function addToBuffer(buffer,name){
-
- for(i=0;i<name.size;i++){
- tt = require('./TAG').tt.CCN_BLOB ;
- addToBufferData(buffer,_ContentObject.moSignature.SignatureBits,tt);
- addCloseTag(buffer);
- }
-
- };
-
-
- var addCloseTag = function addCloseTag(buffer){
- var tag = DTAGS.CCN_CLOSE;
- buffer.write(tag);
- };
-
- var buffer = new Buffer(1000);
-
- var tag = DTAGS.CCN_DTAG_ContentObject;
- var tt = TT.CCN_DTAG ;
- addToBuffer(buffer,tag,tt);
-
-
- tag = DTAGS.CCN_Signature;
- tt = TT.CCN_DTAG ;
- addToBuffer(buffer,tag,tt);
-
-
- tag = DTAGS.CCN_SignatureBits;
- tt = TT.CCN_DTAG ;
- addToBuffer(buffer,tag,tt);
-
- tt = TT.CCN_BLOB ;
- addToBufferData(buffer,_ContentObject.moSignature.SignatureBits,tt);
-
- addCloseTag(buffer);
-
- addCloseTag(buffer);
-
- tag = DTAGS.CCN_Name;
- tt = TT.CCN_DTAG ;
- addToBuffer(buffer,tag,tt);
-
-
- addName(buffer,_ContentObject.moName,tt);
-
- addCloseTag(buffer);
-
- tag = DTAGS.CCN_DTAG_SignedInfo;
- tt = TT.CCN_DTAG ;
- addToBuffer(buffer,tag,tt);
-
- tag = DTAGS.CCN_DTAG_PublisherPublicKeyDigest;
- tt = TT.CCN_DTAG ;
- addToBuffer(buffer,tag,tt);
-
- addToBufferData(buffer,_ContentObject.moSignedInfo.msPublisherPublicKeyDigest ,tt);
-
- addCloseTag(buffer);
-
- tag = DTAGS.CCN_DTAG_Timestamp;
- tt = TT.CCN_DTAG ;
- addToBuffer(buffer,tag,tt);
-
- addToBufferData(buffer,_ContentObject.moSignedInfo.msTimestamp ,tt);
-
- addCloseTag(buffer);
-
- tag = DTAGS.CCN_DTAG_KeyLocator;
- tt = TT.CCN_DTAG ;
- addToBuffer(buffer,tag,tt);
-
- tag = DTAGS.CCN_DTAG_key;
- tt = TT.CCN_DTAG ;
- addToBuffer(buffer,tag,tt);
-
- addToBufferData(buffer,_ContentObject.moSignedInfo.msKeyLocator ,tt);
-
- addCloseTag(buffer);
-
- addCloseTag(buffer);
-
- tag = DTAGS.CCN_DTAG_Content;
- tt = TT.CCN_DTAG ;
- addToBuffer(buffer,tag,tt);
-
- addToBufferData(buffer,_ContentObject.msContent,tt);
-
- addCloseTag(buffer);
-
- addCloseTag(buffer);
-
-}
-
-
-Encoder.prototype.encodeContentObjectToFile = function(_filename){
-
-
- var content = "hello world";
-
- var name = new require('./Name').Name(['hello']);
-
- var sigInfo = new require('./SignatureInfo').SignatureInfo(new Buffer('h7exThsbBBViA/knAnWd2lMdaAgW/lcI6EIAK6ln4Ut8/owZ0tobVQ4YJ3lHkl3qwzldAqLT8RayMU8cxpqrT6sa/nHFatbiObj2GrAAKbsJRSiV/ESzeVXPUHdbNJ75iDc5wjqvC4aJL8tGJt8vAOjJ7fy4MWD+mgFBYqn+1bw='));
-
- var sig = new require('./Signature').Signature(new Buffer("IEh0BFqfrJjrt9+txLvRqxWm5AZTScbIOoRghE6rMYU=",'base64'), new Buffer('BPMrnKOi','base64'), new Buffer('MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC9lWVVnBeVwEml703J0byLmBtmCX6iU/XQ9Q8aHfkIrE5pp5fa3SwFkJRKboSeH7tzccU9/dvngCZW4dX0SbhTDZx9qNar69kOBhJNkn8vbFch8dDknn9qEWfK+WDZb/Wvqi0lZzN3cqlEyObOuFmyWiMdnsqHNXT/mCJchT847wIDAQAB','base64'));
-
- sig.generateSignature(name,sigInfo,content);
-
- var co = new require('./ContentObject').ContentObject(sig,name,sigInfo,content);
-
- var buffer = this.encodeContentObject(co);
-
- fs.writeFile(_filename);
-
-
-}
-
-
-var co = new ContentObjectEncoder();
-
-
-var file = ContentObjectEncoder.decodeFile('/Users/eastman/Desktop/CCN/ccnx-0.5.0rc1/hello');
-
-
diff --git a/src-old/ContentObjectEncoder.js b/src-old/ContentObjectEncoder.js
deleted file mode 100644
index ae10a5f..0000000
--- a/src-old/ContentObjectEncoder.js
+++ /dev/null
@@ -1,260 +0,0 @@
-// JavaScript Document
-/*
- @author: Meki Cherkaoui
-*/
-var DTAGS = require('./TAG').d;
-var TT = require('./TAG').tt;
-
-
-var ContentObjectEncoder = function ContentObjectEncoder(){
-
-
-};
-
-
-/*
- TT bits specify the type of nodes
-
-*/
-var CCN_TT_BITS=3;
-var CCN_TT_MASK=((1 << CCN_TT_BITS) - 1);
-var CCN_MAX_TINY=((1 << (7-CCN_TT_BITS)) - 1);
-var CCN_TT_HBIT=((1 << 7));
-
-Encoder.prototype.encodeContentObject = function(_ContentObject){
-
- //var slit = function splitNumber(number){
- //};
-
- /*
- * returns an integer
- */
- var encodeTypeAndVal = function(itype, lvalue, bstream) {
- /*
- We exploit the fact that encoding is done from the right, so this actually means
- there is a deterministic encoding from a long to a Type/Value pair:
-
- | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 |
- |ABCD.EFGH|IJKL.MNOP|QRST.UVWX|YZ01.2345|6789.abcd|efgh.ijkl|mnop.qrst|uvwx.yz@#
-
- 60> 53> 46> 39> 32> 25> 18> 11> 4>
- |_000.ABCD|_EFG.HIJK|_LMN.OPQR|_STU.VWXY|_Z01.2345|_678.9abc|_defg.hij|_klm.nopq|_rst.uvwx|_yz@#___
-
- What we want to do is compute the result in MSB order and write it directly
- to the channel without any intermediate form.
- */
-
- var bits;
- var count = 0;
-
- // once we start writing bits, we keep writing bits even if they are "0"
- var writing = false;
-
- // a few heuristic to catch the small-bit length patterns
- if( value < 0 || value > 15 ) {
- int start = 60;
- if( 0 <= value ) {
- if( value < bits_11 )
- start = 4;
- else if( value < bits_18 )
- start = 11;
- else if( value < bits_32 )
- start = 25;
- }
-
- for( var i = start; i >= 4; i -= 7) {
- bits = (int) (value >>> i) & BinaryXMLCodec.XML_REG_VAL_MASK;
- if( bits != 0 || writing ) {
- ostream.write(bits);
- count++;
- writing = true;
- }
- }
- }
- };
-
- var addToBuffer = function addToBuffer(buffer,number,tt){
-
-
- var sizeOfBuffer = 1+8*((sizeof(number)+6)/7);
-
-
-
- splitNumbers = new Buffer(sizeOfBuffer);
-
- number >>= 7-CCN_TT_BITS;
-
- splitNumbers.write((CCN_TT_HBIT & ~require('./TAG').d.CCN_CLOSE) |
- ((number & CCN_MAX_TINY) << CCN_TT_BITS) |
- (CCN_TT_MASK & tt));
-
- var index = 1;
- while(number>0){
- splitNumbers.write( number & ~CCN_TT_HBIT |require('./TAG').d.CCN_CLOSE);
- index++;
- number>>=7;
- }
-
- for( i=0, j=sizeofBuffer-1;i <sizeOfBuffer;i++,j--) {
-
- buffer[index+i] = splitNumbers[j];
- }
-
- };
- //NOTE NUMBETR= SIZE
- var addToBufferData = function addToBuffer(buffer,data,tt){
-
- var number = sizeof(data);
- var sizeOfBuffer = 1+8*((sizeof(number)+6)/7);
-
- splitNumbers = new Buffer(sizeOfBuffer);
-
- number >>= 7-CCN_TT_BITS;
-
- splitNumbers.write((CCN_TT_HBIT & ~require('./TAG').d.CCN_CLOSE) |
- ((number & CCN_MAX_TINY) << CCN_TT_BITS) |
- (CCN_TT_MASK & tt));
-
-
- while(number>0){
- splitNumbers.write( number & ~CCN_TT_HBIT |require('./TAG').d.CCN_CLOSE);
- index++;
- number>>=7;
- }
-
- for( i=0, j=sizeofBuffer-1;i <sizeOfBuffer;i++,j--) {
-
- buffer[index+i] = splitNumbers[j];
- }
-
- for(i=0;i<10;i++){
- buffer[index+i] = data[i];
- }
-
- };
-
- //NOTE NUMBETR= SIZE
- var addName = function addToBuffer(buffer,name){
-
- for(i=0;i<name.size;i++){
- tt = require('./TAG').tt.CCN_BLOB ;
- addToBufferData(buffer,_ContentObject.moSignature.SignatureBits,tt);
- addCloseTag(buffer);
- }
-
- };
-
-
- var addCloseTag = function addCloseTag(buffer){
- var tag = DTAGS.CCN_CLOSE;
- buffer.write(tag);
- };
-
- var buffer = new Buffer(1000);
-
- var tag = DTAGS.CCN_DTAG_ContentObject;
- var tt = TT.CCN_DTAG ;
- addToBuffer(buffer,tag,tt);
-
-
- tag = DTAGS.CCN_Signature;
- tt = TT.CCN_DTAG ;
- addToBuffer(buffer,tag,tt);
-
-
- tag = DTAGS.CCN_SignatureBits;
- tt = TT.CCN_DTAG ;
- addToBuffer(buffer,tag,tt);
-
- tt = TT.CCN_BLOB ;
- addToBufferData(buffer,_ContentObject.moSignature.SignatureBits,tt);
-
- addCloseTag(buffer);
-
- addCloseTag(buffer);
-
- tag = DTAGS.CCN_Name;
- tt = TT.CCN_DTAG ;
- addToBuffer(buffer,tag,tt);
-
-
- addName(buffer,_ContentObject.moName,tt);
-
- addCloseTag(buffer);
-
- tag = DTAGS.CCN_DTAG_SignedInfo;
- tt = TT.CCN_DTAG ;
- addToBuffer(buffer,tag,tt);
-
- tag = DTAGS.CCN_DTAG_PublisherPublicKeyDigest;
- tt = TT.CCN_DTAG ;
- addToBuffer(buffer,tag,tt);
-
- addToBufferData(buffer,_ContentObject.moSignedInfo.msPublisherPublicKeyDigest ,tt);
-
- addCloseTag(buffer);
-
- tag = DTAGS.CCN_DTAG_Timestamp;
- tt = TT.CCN_DTAG ;
- addToBuffer(buffer,tag,tt);
-
- addToBufferData(buffer,_ContentObject.moSignedInfo.msTimestamp ,tt);
-
- addCloseTag(buffer);
-
- tag = DTAGS.CCN_DTAG_KeyLocator;
- tt = TT.CCN_DTAG ;
- addToBuffer(buffer,tag,tt);
-
- tag = DTAGS.CCN_DTAG_key;
- tt = TT.CCN_DTAG ;
- addToBuffer(buffer,tag,tt);
-
- addToBufferData(buffer,_ContentObject.moSignedInfo.msKeyLocator ,tt);
-
- addCloseTag(buffer);
-
- addCloseTag(buffer);
-
- tag = DTAGS.CCN_DTAG_Content;
- tt = TT.CCN_DTAG ;
- addToBuffer(buffer,tag,tt);
-
- addToBufferData(buffer,_ContentObject.msContent,tt);
-
- addCloseTag(buffer);
-
- addCloseTag(buffer);
-
-}
-
-
-Encoder.prototype.encodeContentObjectToFile = function(_filename){
-
-
- var content = "hello world";
-
- var name = new require('./Name').Name(['hello']);
-
- var sigInfo = new require('./SignatureInfo').SignatureInfo(new Buffer('h7exThsbBBViA/knAnWd2lMdaAgW/lcI6EIAK6ln4Ut8/owZ0tobVQ4YJ3lHkl3qwzldAqLT8RayMU8cxpqrT6sa/nHFatbiObj2GrAAKbsJRSiV/ESzeVXPUHdbNJ75iDc5wjqvC4aJL8tGJt8vAOjJ7fy4MWD+mgFBYqn+1bw='));
-
- var sig = new require('./Signature').Signature(new Buffer("IEh0BFqfrJjrt9+txLvRqxWm5AZTScbIOoRghE6rMYU=",'base64'), new Buffer('BPMrnKOi','base64'), new Buffer('MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC9lWVVnBeVwEml703J0byLmBtmCX6iU/XQ9Q8aHfkIrE5pp5fa3SwFkJRKboSeH7tzccU9/dvngCZW4dX0SbhTDZx9qNar69kOBhJNkn8vbFch8dDknn9qEWfK+WDZb/Wvqi0lZzN3cqlEyObOuFmyWiMdnsqHNXT/mCJchT847wIDAQAB','base64'));
-
- sig.generateSignature(name,sigInfo,content);
-
- var co = new require('./ContentObject').ContentObject(sig,name,sigInfo,content);
-
- var buffer = this.encodeContentObject(co);
-
- fs.writeFile(_filename);
-
-
-}
-
-
-var co = new ContentObjectEncoder();
-
-
-var file = ContentObjectEncoder.decodeFile('/Users/eastman/Desktop/CCN/ccnx-0.5.0rc1/hello');
-
-
diff --git a/src-old/Decoder.js b/src-old/Decoder.js
deleted file mode 100644
index 7a59e5e..0000000
--- a/src-old/Decoder.js
+++ /dev/null
@@ -1,42 +0,0 @@
-// JavaScript Document
-
-
-var Decoder = function Decoder(){
-
-
- //PRIVATE FUNCTIONS
-
-
-}
-
-
-//PUBLIC FUNCTIONS
-
-Decoder.prototype.decodeFile = function(filename){
- var fs = require('fs');
-
- var file = fs.readFile(filename, function(err,data){
- if(err) {
- console.error("Could not open file: %s", err);
- process.exit(1);
- }
-
- //console.log(data);
- //console.log(data.toString('binary'));
- for( i=0;i<data.length ;i++) {
- var v = data[i];
- console.log(v.toString(2)+'\n');
- }
-
- console.log( require('./TAG.js').d.CCN_DTAG_Any);
- var a =new Buffer('aGVsbG8gd29ybGQK','base64');
- console.log(a.toString('base64'));
-
- });
-}
-
-
-
-var decoder = new Decoder();
-var file = decoder.decodeFile('/Users/eastman/Desktop/CCN/ccnx-0.5.0rc1/hello');
-
diff --git a/src-old/Encoder.js b/src-old/Encoder.js
deleted file mode 100644
index 4ced16c..0000000
--- a/src-old/Encoder.js
+++ /dev/null
@@ -1,208 +0,0 @@
-// JavaScript Document
-/*
- Meki Cherkaoui
-*/
-var DTAGS = require('./TAG').d;
-var TT = require('./TAG').tt;
-
-
-var Encoder = function Encoder(){
-
-
-};
-/*
- TT bits specify the type of nodes
-
-*/
-var CCN_TT_BITS=3;
-var CCN_TT_MASK=((1 << CCN_TT_BITS) - 1);
-var CCN_MAX_TINY=((1 << (7-CCN_TT_BITS)) - 1);
-var CCN_TT_HBIT=((1 << 7));
-
-Encoder.prototype.encodeContentObject = function(_ContentObject){
-
- //var slit = function splitNumber(number){
- //};
- var i = 0;
-
- var addToBuffer = function addToBuffer(buffer,number,tt){
-
- var sizeOfBuffer = 1+8*((sizeof(number)+6)/7);
-
- splitNumbers = new Buffer(sizeOfBuffer);
-
- number >>= 7-CCN_TT_BITS;
-
- splitNumbers.write((CCN_TT_HBIT & ~require('./TAG').d.CCN_CLOSE) |
- ((number & CCN_MAX_TINY) << CCN_TT_BITS) |
- (CCN_TT_MASK & tt));
-
- var index = 1;
- while(number>0){
- splitNumbers.write( number & ~CCN_TT_HBIT |require('./TAG').d.CCN_CLOSE);
- index++;
- number>>=7;
- }
-
- for( i=0, j=sizeofBuffer-1;i <sizeOfBuffer;i++,j--) {
-
- buffer[index+i] = splitNumbers[j];
- }
-
- };
- //NOTE NUMBETR= SIZE
- var addToBufferData = function addToBuffer(buffer,data,tt){
-
- var number = sizeof(data);
- var sizeOfBuffer = 1+8*((sizeof(number)+6)/7);
-
- splitNumbers = new Buffer(sizeOfBuffer);
-
- number >>= 7-CCN_TT_BITS;
-
- splitNumbers.write((CCN_TT_HBIT & ~require('./TAG').d.CCN_CLOSE) |
- ((number & CCN_MAX_TINY) << CCN_TT_BITS) |
- (CCN_TT_MASK & tt));
-
-
- while(number>0){
- splitNumbers.write( number & ~CCN_TT_HBIT |require('./TAG').d.CCN_CLOSE);
- index++;
- number>>=7;
- }
-
- for( i=0, j=sizeofBuffer-1;i <sizeOfBuffer;i++,j--) {
-
- buffer[index+i] = splitNumbers[j];
- }
-
- for(i=0;i<10;i++){
- buffer[index+i] = data[i];
- }
-
- };
-
- //NOTE NUMBETR= SIZE
- var addName = function addToBuffer(buffer,name){
-
- for(i=0;i<name.size;i++){
- tt = require('./TAG').tt.CCN_BLOB ;
- addToBufferData(buffer,_ContentObject.moSignature.SignatureBits,tt);
- addCloseTag(buffer);
- }
-
- };
-
-
- var addCloseTag = function addCloseTag(buffer){
- var tag = DTAGS.CCN_CLOSE;
- buffer.write(tag);
- };
-
- var buffer = new Buffer(1000);
-
- var tag = DTAGS.CCN_DTAG_ContentObject;
- var tt = require('./TAG').tt.CCN_DTAG ;
- addToBuffer(buffer,tag,tt);
-
-
- tag = DTAGS.CCN_Signature;
- tt = require('./TAG').tt.CCN_DTAG ;
- addToBuffer(buffer,tag,tt);
-
-
- tag = DTAGS.CCN_SignatureBits;
- tt = require('./TAG').tt.CCN_DTAG ;
- addToBuffer(buffer,tag,tt);
-
- tt = require('./TAG').tt.CCN_BLOB ;
- addToBufferData(buffer,_ContentObject.moSignature.SignatureBits,tt);
-
- addCloseTag(buffer);
-
- addCloseTag(buffer);
-
- tag = DTAGS.CCN_Name;
- tt = require('./TAG').tt.CCN_DTAG ;
- addToBuffer(buffer,tag,tt);
-
-
- addName(buffer,_ContentObject.moName,tt);
-
- addCloseTag(buffer);
-
- tag = DTAGS.CCN_DTAG_SignedInfo;
- tt = require('./TAG').tt.CCN_DTAG ;
- addToBuffer(buffer,tag,tt);
-
- tag = DTAGS.CCN_DTAG_PublisherPublicKeyDigest;
- tt = require('./TAG').tt.CCN_DTAG ;
- addToBuffer(buffer,tag,tt);
-
- addToBufferData(buffer,_ContentObject.moSignedInfo.msPublisherPublicKeyDigest ,tt);
-
- addCloseTag(buffer);
-
- tag = DTAGS.CCN_DTAG_Timestamp;
- tt = require('./TAG').tt.CCN_DTAG ;
- addToBuffer(buffer,tag,tt);
-
- addToBufferData(buffer,_ContentObject.moSignedInfo.msTimestamp ,tt);
-
- addCloseTag(buffer);
-
- tag = DTAGS.CCN_DTAG_KeyLocator;
- tt = require('./TAG').tt.CCN_DTAG ;
- addToBuffer(buffer,tag,tt);
-
- tag = DTAGS.CCN_DTAG_key;
- tt = require('./TAG').tt.CCN_DTAG ;
- addToBuffer(buffer,tag,tt);
-
- addToBufferData(buffer,_ContentObject.moSignedInfo.msKeyLocator ,tt);
-
- addCloseTag(buffer);
-
- addCloseTag(buffer);
-
- tag = DTAGS.CCN_DTAG_Content;
- tt = require('./TAG').tt.CCN_DTAG ;
- addToBuffer(buffer,tag,tt);
-
- addToBufferData(buffer,_ContentObject.msContent,tt);
-
- addCloseTag(buffer);
-
- addCloseTag(buffer);
-
-}
-
-
-Encoder.prototype.encodeContentObjectToFile = function(_filename){
-
-
- var content = "hello world";
-
- var name = new require('./Name').Name(['hello']);
-
- var sigInfo = new require('./SignatureInfo').SignatureInfo(new Buffer('h7exThsbBBViA/knAnWd2lMdaAgW/lcI6EIAK6ln4Ut8/owZ0tobVQ4YJ3lHkl3qwzldAqLT8RayMU8cxpqrT6sa/nHFatbiObj2GrAAKbsJRSiV/ESzeVXPUHdbNJ75iDc5wjqvC4aJL8tGJt8vAOjJ7fy4MWD+mgFBYqn+1bw='));
-
- var sig = new require('./Signature').Signature(new Buffer("IEh0BFqfrJjrt9+txLvRqxWm5AZTScbIOoRghE6rMYU=",'base64'), new Buffer('BPMrnKOi','base64'), new Buffer('MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC9lWVVnBeVwEml703J0byLmBtmCX6iU/XQ9Q8aHfkIrE5pp5fa3SwFkJRKboSeH7tzccU9/dvngCZW4dX0SbhTDZx9qNar69kOBhJNkn8vbFch8dDknn9qEWfK+WDZb/Wvqi0lZzN3cqlEyObOuFmyWiMdnsqHNXT/mCJchT847wIDAQAB','base64'));
-
- sig.generateSignature(name,sigInfo,content);
-
- var co = new require('./ContentObject').ContentObject(sig,name,sigInfo,content);
-
- var buffer = this.encodeContentObject(co);
-
- fs.writeFile(_filename);
-
-
-}
-
-
-var Encoder = new Encoder();
-
-var file = Encoder.decodeFile('/Users/eastman/Desktop/CCN/ccnx-0.5.0rc1/hello');
-
-
diff --git a/src-old/InterestMessage.js b/src-old/InterestMessage.js
deleted file mode 100644
index 90177b4..0000000
--- a/src-old/InterestMessage.js
+++ /dev/null
@@ -1,17 +0,0 @@
-// JavaScript Document
-
-var InterestMessage = function InterestMessage(_Name,_MinSuffixComponents,_MaxSuffixComponents,_PublisherPublicKeyDigest, _Exclude, _ChildSelector,_AnswerOriginKind,_Scope,_InterestLifetime,_Nonce){
-
- this.Name = _Name;
- this.MinSuffixComponents = _MinSuffixComponents;
- this.MaxSuffixComponents = _MaxSuffixComponents;
- this.PublisherPublicKeyDigest=_PublisherPublicKeyDigest;
- this.Exclude=_Exclude;
- this.ChildSelector=_ChildSelector;
- this.Scope=_Scope;
- this.InterestLifetime=_InterestLifetime;
- this.Nonce = _Nonce;
-
-};
-
-exports.InterestMessage = InterestMessage;
diff --git a/src-old/InterestMessageDecoder.js b/src-old/InterestMessageDecoder.js
deleted file mode 100644
index 565c1a9..0000000
--- a/src-old/InterestMessageDecoder.js
+++ /dev/null
@@ -1,207 +0,0 @@
-// JavaScript Document
-/*
- @author: Meki Cherkaoui
-*/
-var DTAGS = require('./TAG').d;
-var TT = require('./TAG').tt;
-
-
-var Encoder = function Encoder(){
-
-
-};
-/*
- TT bits specify the type of nodes
-
-*/
-var CCN_TT_BITS=3;
-var CCN_TT_MASK=((1 << CCN_TT_BITS) - 1);
-var CCN_MAX_TINY=((1 << (7-CCN_TT_BITS)) - 1);
-var CCN_TT_HBIT=((1 << 7));
-
-Encoder.prototype.encodeContentObject = function(_ContentObject){
-
- //var slit = function splitNumber(number){
- //};
- var i = 0;
-
- var addToBuffer = function addToBuffer(buffer,number,tt){
-
- var sizeOfBuffer = 1+8*((sizeof(number)+6)/7);
-
- splitNumbers = new Buffer(sizeOfBuffer);
-
- number >>= 7-CCN_TT_BITS;
-
- splitNumbers.write((CCN_TT_HBIT & ~require('./TAG').d.CCN_CLOSE) |
- ((number & CCN_MAX_TINY) << CCN_TT_BITS) |
- (CCN_TT_MASK & tt));
-
- var index = 1;
- while(number>0){
- splitNumbers.write( number & ~CCN_TT_HBIT |require('./TAG').d.CCN_CLOSE);
- index++;
- number>>=7;
- }
-
- for( i=0, j=sizeofBuffer-1;i <sizeOfBuffer;i++,j--) {
-
- buffer[index+i] = splitNumbers[j];
- }
-
- };
- //NOTE NUMBETR= SIZE
- var addToBufferData = function addToBuffer(buffer,data,tt){
-
- var number = sizeof(data);
- var sizeOfBuffer = 1+8*((sizeof(number)+6)/7);
-
- splitNumbers = new Buffer(sizeOfBuffer);
-
- number >>= 7-CCN_TT_BITS;
-
- splitNumbers.write((CCN_TT_HBIT & ~require('./TAG').d.CCN_CLOSE) |
- ((number & CCN_MAX_TINY) << CCN_TT_BITS) |
- (CCN_TT_MASK & tt));
-
-
- while(number>0){
- splitNumbers.write( number & ~CCN_TT_HBIT |require('./TAG').d.CCN_CLOSE);
- index++;
- number>>=7;
- }
-
- for( i=0, j=sizeofBuffer-1;i <sizeOfBuffer;i++,j--) {
-
- buffer[index+i] = splitNumbers[j];
- }
-
- for(i=0;i<10;i++){
- buffer[index+i] = data[i];
- }
-
- };
-
- //NOTE NUMBETR= SIZE
- var addName = function addToBuffer(buffer,name){
-
- for(i=0;i<name.size;i++){
- tt = require('./TAG').tt.CCN_BLOB ;
- addToBufferData(buffer,_ContentObject.moSignature.SignatureBits,tt);
- addCloseTag(buffer);
- }
-
- };
-
-
- var addCloseTag = function addCloseTag(buffer){
- var tag = DTAGS.CCN_CLOSE;
- buffer.write(tag);
- };
-
- var buffer = new Buffer(1000);
-
- var tag = DTAGS.CCN_DTAG_ContentObject;
- var tt = TT.CCN_DTAG ;
- addToBuffer(buffer,tag,tt);
-
-
- tag = DTAGS.CCN_Signature;
- tt = TT.CCN_DTAG ;
- addToBuffer(buffer,tag,tt);
-
-
- tag = DTAGS.CCN_SignatureBits;
- tt = TT.CCN_DTAG ;
- addToBuffer(buffer,tag,tt);
-
- tt = TT.CCN_BLOB ;
- addToBufferData(buffer,_ContentObject.moSignature.SignatureBits,tt);
-
- addCloseTag(buffer);
-
- addCloseTag(buffer);
-
- tag = DTAGS.CCN_Name;
- tt = TT.CCN_DTAG ;
- addToBuffer(buffer,tag,tt);
-
-
- addName(buffer,_ContentObject.moName,tt);
-
- addCloseTag(buffer);
-
- tag = DTAGS.CCN_DTAG_SignedInfo;
- tt = TT.CCN_DTAG ;
- addToBuffer(buffer,tag,tt);
-
- tag = DTAGS.CCN_DTAG_PublisherPublicKeyDigest;
- tt = TT.CCN_DTAG ;
- addToBuffer(buffer,tag,tt);
-
- addToBufferData(buffer,_ContentObject.moSignedInfo.msPublisherPublicKeyDigest ,tt);
-
- addCloseTag(buffer);
-
- tag = DTAGS.CCN_DTAG_Timestamp;
- tt = TT.CCN_DTAG ;
- addToBuffer(buffer,tag,tt);
-
- addToBufferData(buffer,_ContentObject.moSignedInfo.msTimestamp ,tt);
-
- addCloseTag(buffer);
-
- tag = DTAGS.CCN_DTAG_KeyLocator;
- tt = TT.CCN_DTAG ;
- addToBuffer(buffer,tag,tt);
-
- tag = DTAGS.CCN_DTAG_key;
- tt = TT.CCN_DTAG ;
- addToBuffer(buffer,tag,tt);
-
- addToBufferData(buffer,_ContentObject.moSignedInfo.msKeyLocator ,tt);
-
- addCloseTag(buffer);
-
- addCloseTag(buffer);
-
- tag = DTAGS.CCN_DTAG_Content;
- tt = TT.CCN_DTAG ;
- addToBuffer(buffer,tag,tt);
-
- addToBufferData(buffer,_ContentObject.msContent,tt);
-
- addCloseTag(buffer);
-
- addCloseTag(buffer);
-
-}
-
-
-Encoder.prototype.encodeContentObjectToFile = function(_filename){
-
-
- var content = "hello world";
-
- var name = new require('./Name').Name(['hello']);
-
- var sigInfo = new require('./SignatureInfo').SignatureInfo(new Buffer('h7exThsbBBViA/knAnWd2lMdaAgW/lcI6EIAK6ln4Ut8/owZ0tobVQ4YJ3lHkl3qwzldAqLT8RayMU8cxpqrT6sa/nHFatbiObj2GrAAKbsJRSiV/ESzeVXPUHdbNJ75iDc5wjqvC4aJL8tGJt8vAOjJ7fy4MWD+mgFBYqn+1bw='));
-
- var sig = new require('./Signature').Signature(new Buffer("IEh0BFqfrJjrt9+txLvRqxWm5AZTScbIOoRghE6rMYU=",'base64'), new Buffer('BPMrnKOi','base64'), new Buffer('MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC9lWVVnBeVwEml703J0byLmBtmCX6iU/XQ9Q8aHfkIrE5pp5fa3SwFkJRKboSeH7tzccU9/dvngCZW4dX0SbhTDZx9qNar69kOBhJNkn8vbFch8dDknn9qEWfK+WDZb/Wvqi0lZzN3cqlEyObOuFmyWiMdnsqHNXT/mCJchT847wIDAQAB','base64'));
-
- sig.generateSignature(name,sigInfo,content);
-
- var co = new require('./ContentObject').ContentObject(sig,name,sigInfo,content);
-
- var buffer = this.encodeContentObject(co);
-
- fs.writeFile(_filename);
-
-}
-
-
-var Encoder = new Encoder();
-
-var file = Encoder.decodeFile('/Users/eastman/Desktop/CCN/ccnx-0.5.0rc1/hello');
-
-
diff --git a/src-old/InterestMessageEncoder.js b/src-old/InterestMessageEncoder.js
deleted file mode 100644
index ba90934..0000000
--- a/src-old/InterestMessageEncoder.js
+++ /dev/null
@@ -1,234 +0,0 @@
-// JavaScript Document
-/*
- InterestMessageEncoder is used to convert XML Interest Message into Binary Interest Message.
- @author: Meki Cherkaoui
-
-*/
-var DTAGS = require('./TAG').d;
-var TT = require('./TAG').tt;
-
-
-/*
- Constructor for the IME
-*/
-var InterestMessageEncoder = function InterestMessageEncoder(){
-
-
-};
-
-/*
- TT bits specify the type of nodes
-
-*/
-var CCN_TT_BITS=3;
-var CCN_TT_MASK=((1 << CCN_TT_BITS) - 1);
-var CCN_MAX_TINY=((1 << (7-CCN_TT_BITS)) - 1);
-var CCN_TT_HBIT=((1 << 7));
-
-
-/*
- Encode function takes in a content object and returs a buffer containing the whole binary encoding.
-
-*/
-Encoder.prototype.encodeContentObject = function(_ContentObject){
-
-
- var i = 0;
-
-
-
- /*
- This function will add a Tag to the buffer
- The number is the dtag number and tt is the tag type
- http://www.ccnx.org/documentation/protocol/ccnx-protocol-2/ccnx-binary-encoding-ccnb/
-
- */
- var addTagToBuffer = function(buffer,number,tt){
-
- var sizeOfBuffer = 1+8*((sizeof(number)+6)/7);
-
- splitNumbers = new Buffer(sizeOfBuffer);
-
- number >>= 7-CCN_TT_BITS;
-
- splitNumbers.write((CCN_TT_HBIT & DTAGS.CCN_CLOSE) |
- ((number & CCN_MAX_TINY) << CCN_TT_BITS) |
- (CCN_TT_MASK & tt));
-
- var index = 1;
- while(number>0){
- splitNumbers.write( number & ~CCN_TT_HBIT | DTAGS.CCN_CLOSE);
- index++;
- number>>=7;
- }
-
- for( i=0, j=sizeofBuffer-1;i <sizeOfBuffer;i++,j--) {
-
- buffer.write(splitNumbers[j]);
- }
-
- };
-
- //NOTE NUMBETR= SIZE
- var addToBuffer = function(buffer,data,tt){
-
- var number = sizeof(data);
- var sizeOfBuffer = 1+8*((sizeof(number)+6)/7);
-
- splitNumbers = new Buffer(sizeOfBuffer);
-
- number >>= 7-CCN_TT_BITS;
-
- splitNumbers.write((CCN_TT_HBIT & ~DTAGS.CCN_CLOSE) |
- ((number & CCN_MAX_TINY) << CCN_TT_BITS) |
- (CCN_TT_MASK & tt));
-
-
- while(number>0){
- splitNumbers.write( number & ~CCN_TT_HBIT | DTAGS.CCN_CLOSE);
- index++;
- number>>=7;
- }
-
- for( i=0, j=sizeofBuffer-1;i <sizeOfBuffer;i++,j--) {
-
- buffer[index+i] = splitNumbers[j];
- }
-
- for(i=0;i<data.length;i++){
- buffer[index+i] = data[i];
- }
-
- };
-
-
- /*
- Add tag to buffer:
-
-
- */
- var addName = function(buffer,name){
-
- for(i=0;i<name.size;i++){
- tt = require('./TAG').tt.CCN_BLOB ;
- addToBufferData(buffer,_ContentObject.moSignature.SignatureBits,tt);
- addCloseTag(buffer);
- }
-
- };
-
-
- var addCloseTag = function(buffer){
- var tag = DTAGS.CCN_CLOSE;
- buffer.write(tag);
- };
-
- var buffer = new Buffer(1000);
-
- var tag = DTAGS.CCN_DTAG_ContentObject;
- var tt = TT.CCN_DTAG ;
- addToBuffer(buffer,tag,tt);
-
-
- tag = DTAGS.CCN_Signature;
- tt = TT.CCN_DTAG ;
- addToBuffer(buffer,tag,tt);
-
-
- tag = DTAGS.CCN_SignatureBits;
- tt = TT.CCN_DTAG ;
- addToBuffer(buffer,tag,tt);
-
- tt = TT.CCN_BLOB ;
- addToBufferData(buffer,_ContentObject.moSignature.SignatureBits,tt);
-
- addCloseTag(buffer);
-
- addCloseTag(buffer);
-
- tag = DTAGS.CCN_Name;
- tt = TT.CCN_DTAG ;
- addToBuffer(buffer,tag,tt);
-
-
- addName(buffer,_ContentObject.moName,tt);
-
- addCloseTag(buffer);
-
- tag = DTAGS.CCN_DTAG_SignedInfo;
- tt = TT.CCN_DTAG ;
- addToBuffer(buffer,tag,tt);
-
- tag = DTAGS.CCN_DTAG_PublisherPublicKeyDigest;
- tt = TT.CCN_DTAG ;
- addToBuffer(buffer,tag,tt);
-
- addToBufferData(buffer,_ContentObject.moSignedInfo.msPublisherPublicKeyDigest ,tt);
-
- addCloseTag(buffer);
-
- tag = DTAGS.CCN_DTAG_Timestamp;
- tt = TT.CCN_DTAG ;
- addToBuffer(buffer,tag,tt);
-
- addToBufferData(buffer,_ContentObject.moSignedInfo.msTimestamp ,tt);
-
- addCloseTag(buffer);
-
- tag = DTAGS.CCN_DTAG_KeyLocator;
- tt = TT.CCN_DTAG ;
- addToBuffer(buffer,tag,tt);
-
- tag = DTAGS.CCN_DTAG_key;
- tt = TT.CCN_DTAG ;
- addToBuffer(buffer,tag,tt);
-
- addToBufferData(buffer,_ContentObject.moSignedInfo.msKeyLocator ,tt);
-
- addCloseTag(buffer);
-
- addCloseTag(buffer);
-
- tag = DTAGS.CCN_DTAG_Content;
- tt = TT.CCN_DTAG ;
- addToBuffer(buffer,tag,tt);
-
- addToBufferData(buffer,_ContentObject.msContent,tt);
-
- addCloseTag(buffer);
-
- addCloseTag(buffer);
-
-
- return buffer;
-}
-
-
-Encoder.prototype.encodeToFile = function(_filename){
-
-
- var content = "hello world";
-
- var name = new require('./Name').Name(['hello']);
-
- var sigInfo = new require('./SignatureInfo').SignatureInfo(new Buffer('h7exThsbBBViA/knAnWd2lMdaAgW/lcI6EIAK6ln4Ut8/owZ0tobVQ4YJ3lHkl3qwzldAqLT8RayMU8cxpqrT6sa/nHFatbiObj2GrAAKbsJRSiV/ESzeVXPUHdbNJ75iDc5wjqvC4aJL8tGJt8vAOjJ7fy4MWD+mgFBYqn+1bw='));
-
- var sig = new require('./Signature').Signature(new Buffer("IEh0BFqfrJjrt9+txLvRqxWm5AZTScbIOoRghE6rMYU=",'base64'), new Buffer('BPMrnKOi','base64'), new Buffer('MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC9lWVVnBeVwEml703J0byLmBtmCX6iU/XQ9Q8aHfkIrE5pp5fa3SwFkJRKboSeH7tzccU9/dvngCZW4dX0SbhTDZx9qNar69kOBhJNkn8vbFch8dDknn9qEWfK+WDZb/Wvqi0lZzN3cqlEyObOuFmyWiMdnsqHNXT/mCJchT847wIDAQAB','base64'));
-
- sig.generateSignature(name,sigInfo,content);
-
- var co = new require('./ContentObject').ContentObject(sig,name,sigInfo,content);
-
- var buffer = this.encodeContentObject(co);
-
- fs.writeFile(_filename);
-
-
-}
-
-
-var InterestMessageEncoder = new InterestMessageEncoder();
-
-var file = InterestMessageEncoder.encodeToFile('/Users/eastman/Desktop/CCN/ccnx-0.5.0rc1/hello');
-
-
diff --git a/src-old/InterestMessageEncodingTest.js b/src-old/InterestMessageEncodingTest.js
deleted file mode 100644
index a5c843d..0000000
--- a/src-old/InterestMessageEncodingTest.js
+++ /dev/null
@@ -1,235 +0,0 @@
-// JavaScript Document
-/*
- InterestMessageEncoder is used to convert XML Interest Message into Binary Interest Message.
- @author: Meki Cherkaoui
-
-*/
-var DTAGS = require('./TAG').d;
-var TT = require('./TAG').tt;
-
-
-
-/*
- Constructor for the IME
-*/
-var InterestMessageEncoder = function InterestMessageEncoder(){
-
-
-};
-
-/*
- TT bits specify the type of nodes
-
-*/
-var CCN_TT_BITS=3;
-var CCN_TT_MASK=((1 << CCN_TT_BITS) - 1);
-var CCN_MAX_TINY=((1 << (7-CCN_TT_BITS)) - 1);
-var CCN_TT_HBIT=((1 << 7));
-
-
-/*
- Encode function takes in a content object and returs a buffer containing the whole binary encoding.
-
-*/
-InterestMessageEncoder.prototype.encodeContentObject = function(_InterestMessage){
-
-
- var i = 0;
-
-
-
- /*
- This function will add a Tag to the buffer
- The number is the dtag number and tt is the tag type
- http://www.ccnx.org/documentation/protocol/ccnx-protocol-2/ccnx-binary-encoding-ccnb/
-
- */
- var addTagToBuffer = function(buffer,number,tt){
-
- var sizeOfBuffer = 1+8*((sizeof(number)+6)/7);
-
- splitNumbers = new Buffer(sizeOfBuffer);
-
- number >>= 7-CCN_TT_BITS;
-
- splitNumbers.write((CCN_TT_HBIT & DTAGS.CCN_CLOSE) |
- ((number & CCN_MAX_TINY) << CCN_TT_BITS) |
- (CCN_TT_MASK & tt));
-
- var index = 1;
- while(number>0){
- splitNumbers.write( number & ~CCN_TT_HBIT | DTAGS.CCN_CLOSE);
- index++;
- number>>=7;
- }
-
- for( i=0, j=sizeofBuffer-1;i <sizeOfBuffer;i++,j--) {
-
- buffer.write(splitNumbers[j]);
- }
-
- };
-
- //NOTE NUMBETR= SIZE
- var addToBuffer = function(buffer,data,tt){
-
- var number = sizeof(data);
- var sizeOfBuffer = 1+8*((sizeof(number)+6)/7);
-
- splitNumbers = new Buffer(sizeOfBuffer);
-
- number >>= 7-CCN_TT_BITS;
-
- splitNumbers.write((CCN_TT_HBIT & ~DTAGS.CCN_CLOSE) |
- ((number & CCN_MAX_TINY) << CCN_TT_BITS) |
- (CCN_TT_MASK & tt));
-
-
- while(number>0){
- splitNumbers.write( number & ~CCN_TT_HBIT | DTAGS.CCN_CLOSE);
- index++;
- number>>=7;
- }
-
- for( i=0, j=sizeofBuffer-1;i <sizeOfBuffer;i++,j--) {
-
- buffer[index+i] = splitNumbers[j];
- }
-
- for(i=0;i<data.length;i++){
- buffer[index+i] = data[i];
- }
-
- };
-
-
- /*
- Add tag to buffer:
-
-
- */
- var addName = function(buffer,name){
-
- for(i=0;i<name.size;i++){
- tt = require('./TAG').tt.CCN_BLOB ;
- addToBufferData(buffer,_ContentObject.moSignature.SignatureBits,tt);
- addCloseTag(buffer);
- }
-
- };
-
-
- var addCloseTag = function(buffer){
- var tag = DTAGS.CCN_CLOSE;
- buffer.write(tag);
- };
-
- var buffer = new Buffer(1000);
-
- var tag = DTAGS.CCN_DTAG_ContentObject;
- var tt = TT.CCN_DTAG ;
- addToBuffer(buffer,tag,tt);
-
-
- tag = DTAGS.CCN_Signature;
- tt = TT.CCN_DTAG ;
- addToBuffer(buffer,tag,tt);
-
-
- tag = DTAGS.CCN_SignatureBits;
- tt = TT.CCN_DTAG ;
- addToBuffer(buffer,tag,tt);
-
- tt = TT.CCN_BLOB ;
- addToBufferData(buffer,_ContentObject.moSignature.SignatureBits,tt);
-
- addCloseTag(buffer);
-
- addCloseTag(buffer);
-
- tag = DTAGS.CCN_Name;
- tt = TT.CCN_DTAG ;
- addToBuffer(buffer,tag,tt);
-
-
- addName(buffer,_ContentObject.moName,tt);
-
- addCloseTag(buffer);
-
- tag = DTAGS.CCN_DTAG_SignedInfo;
- tt = TT.CCN_DTAG ;
- addToBuffer(buffer,tag,tt);
-
- tag = DTAGS.CCN_DTAG_PublisherPublicKeyDigest;
- tt = TT.CCN_DTAG ;
- addToBuffer(buffer,tag,tt);
-
- addToBufferData(buffer,_ContentObject.moSignedInfo.msPublisherPublicKeyDigest ,tt);
-
- addCloseTag(buffer);
-
- tag = DTAGS.CCN_DTAG_Timestamp;
- tt = TT.CCN_DTAG ;
- addToBuffer(buffer,tag,tt);
-
- addToBufferData(buffer,_ContentObject.moSignedInfo.msTimestamp ,tt);
-
- addCloseTag(buffer);
-
- tag = DTAGS.CCN_DTAG_KeyLocator;
- tt = TT.CCN_DTAG ;
- addToBuffer(buffer,tag,tt);
-
- tag = DTAGS.CCN_DTAG_key;
- tt = TT.CCN_DTAG ;
- addToBuffer(buffer,tag,tt);
-
- addToBufferData(buffer,_ContentObject.moSignedInfo.msKeyLocator ,tt);
-
- addCloseTag(buffer);
-
- addCloseTag(buffer);
-
- tag = DTAGS.CCN_DTAG_Content;
- tt = TT.CCN_DTAG ;
- addToBuffer(buffer,tag,tt);
-
- addToBufferData(buffer,_ContentObject.msContent,tt);
-
- addCloseTag(buffer);
-
- addCloseTag(buffer);
-
-
- return buffer;
-}
-
-
-Encoder.prototype.encodeToFile = function(_filename){
-
-
- var content = "hello world";
-
- var name = new require('./Name').Name(['hello']);
-
- var sigInfo = new require('./SignatureInfo').SignatureInfo(new Buffer('h7exThsbBBViA/knAnWd2lMdaAgW/lcI6EIAK6ln4Ut8/owZ0tobVQ4YJ3lHkl3qwzldAqLT8RayMU8cxpqrT6sa/nHFatbiObj2GrAAKbsJRSiV/ESzeVXPUHdbNJ75iDc5wjqvC4aJL8tGJt8vAOjJ7fy4MWD+mgFBYqn+1bw='));
-
- var sig = new require('./Signature').Signature(new Buffer("IEh0BFqfrJjrt9+txLvRqxWm5AZTScbIOoRghE6rMYU=",'base64'), new Buffer('BPMrnKOi','base64'), new Buffer('MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC9lWVVnBeVwEml703J0byLmBtmCX6iU/XQ9Q8aHfkIrE5pp5fa3SwFkJRKboSeH7tzccU9/dvngCZW4dX0SbhTDZx9qNar69kOBhJNkn8vbFch8dDknn9qEWfK+WDZb/Wvqi0lZzN3cqlEyObOuFmyWiMdnsqHNXT/mCJchT847wIDAQAB','base64'));
-
- sig.generateSignature(name,sigInfo,content);
-
- var co = new require('./ContentObject').ContentObject(sig,name,sigInfo,content);
-
- var buffer = this.encodeContentObject(co);
-
- fs.writeFile(_filename);
-
-
-}
-
-
-var InterestMessageEncoder = new InterestMessageEncoder();
-
-var file = InterestMessageEncoder.encodeToFile('/Users/eastman/Desktop/CCN/ccnx-0.5.0rc1/hello');
-
-
diff --git a/src-old/Name.js b/src-old/Name.js
deleted file mode 100644
index 6882f0e..0000000
--- a/src-old/Name.js
+++ /dev/null
@@ -1,6 +0,0 @@
-// JavaScript Document
-var Name = function Name(_Component){
- this.Component = _Component;
-};
-
-exports.Name = Name;
\ No newline at end of file
diff --git a/src-old/Signature.js b/src-old/Signature.js
deleted file mode 100644
index 2d1d878..0000000
--- a/src-old/Signature.js
+++ /dev/null
@@ -1,8 +0,0 @@
-// JavaScript Document
-var Signature = function(_DigestAlgorithm, _Witness, _SignatureBits){
- this.DigestAlgorithm = _DigestAlgorithm;
- this.Witness = _Witness;
- this.SignatureBits = _SignatureBits;
-}
-
-exports.Signature = Signature;
\ No newline at end of file
diff --git a/src-old/SignedInfo.js b/src-old/SignedInfo.js
deleted file mode 100644
index dcc083f..0000000
--- a/src-old/SignedInfo.js
+++ /dev/null
@@ -1,12 +0,0 @@
-// JavaScript Document
-var SignedInfo = function SignedInfo(_PublisherPublicKeyDigest,_Timestamp,_Type, _KeyLocator,_FreshnessSeconds,_FinalBlockID){
-
- this.PublisherPublicKeyDigest = _PublisherPublicKeyDigest;
- this.Timestamp = _Timestamp;
- this.FreshnessSeconds = _FinalBlockID;
- this.FinalBlockID = _FinalBlockID;
- this.KeyLocator= _KeyLocator;
-}
-
-exports.SignedInfo = SignedInfo;
-
diff --git a/src-old/TAG.js b/src-old/TAG.js
deleted file mode 100644
index d95c610..0000000
--- a/src-old/TAG.js
+++ /dev/null
@@ -1,113 +0,0 @@
-// JavaScript Document
-
-
-//d are the dictionnary tags
-exports.tt= {
- CCN_EXT : 0x00,
- CCN_TAG : 0x01,
- CCN_DTAG : 0x02,
- CCN_ATTR : 0x03,
- CCN_DATTR : 0x04,
- CCN_BLOB : 0x05,
- CCN_UDATA : 0x06
-};
-
-//d are the dictionnary tags
-exports.dtags= {
- CCN_CLOSE :0,
- CCN_DTAG_Any : 13,
- CCN_DTAG_Name : 14,
- CCN_DTAG_Component : 15,
- CCN_DTAG_Certificate : 16,
- CCN_DTAG_Collection : 17,
- CCN_DTAG_CompleteName : 18,
- CCN_DTAG_Content : 19,
- CCN_DTAG_SignedInfo : 20,
- CCN_DTAG_ContentDigest : 21,
- CCN_DTAG_ContentHash : 22,
- CCN_DTAG_Count : 24,
- CCN_DTAG_Header : 25,
- CCN_DTAG_Interest : 26, /* 20090915 */
- CCN_DTAG_Key : 27,
- CCN_DTAG_KeyLocator : 28,
- CCN_DTAG_KeyName : 29,
- CCN_DTAG_Length : 30,
- CCN_DTAG_Link : 31,
- CCN_DTAG_LinkAuthenticator : 32,
- CCN_DTAG_NameComponentCount : 33, /* DeprecatedInInterest */
- CCN_DTAG_RootDigest : 36,
- CCN_DTAG_Signature : 37,
- CCN_DTAG_Start : 38,
- CCN_DTAG_Timestamp : 39,
- CCN_DTAG_Type : 40,
- CCN_DTAG_Nonce : 41,
- CCN_DTAG_Scope : 42,
- CCN_DTAG_Exclude : 43,
- CCN_DTAG_Bloom : 44,
- CCN_DTAG_BloomSeed : 45,
- CCN_DTAG_AnswerOriginKind : 47,
- CCN_DTAG_InterestLifetime : 48,
- CCN_DTAG_Witness : 53,
- CCN_DTAG_SignatureBits : 54,
- CCN_DTAG_DigestAlgorithm : 55,
- CCN_DTAG_BlockSize : 56,
- CCN_DTAG_FreshnessSeconds : 58,
- CCN_DTAG_FinalBlockID : 59,
- CCN_DTAG_PublisherPublicKeyDigest : 60,
- CCN_DTAG_PublisherCertificateDigest : 61,
- CCN_DTAG_PublisherIssuerKeyDigest : 62,
- CCN_DTAG_PublisherIssuerCertificateDigest : 63,
- CCN_DTAG_ContentObject : 64, /* 20090915 */
- CCN_DTAG_WrappedKey : 65,
- CCN_DTAG_WrappingKeyIdentifier : 66,
- CCN_DTAG_WrapAlgorithm : 67,
- CCN_DTAG_KeyAlgorithm : 68,
- CCN_DTAG_Label : 69,
- CCN_DTAG_EncryptedKey : 70,
- CCN_DTAG_EncryptedNonceKey : 71,
- CCN_DTAG_WrappingKeyName : 72,
- CCN_DTAG_Action : 73,
- CCN_DTAG_FaceID : 74,
- CCN_DTAG_IPProto : 75,
- CCN_DTAG_Host : 76,
- CCN_DTAG_Port : 77,
- CCN_DTAG_MulticastInterface : 78,
- CCN_DTAG_ForwardingFlags : 79,
- CCN_DTAG_FaceInstance : 80,
- CCN_DTAG_ForwardingEntry : 81,
- CCN_DTAG_MulticastTTL : 82,
- CCN_DTAG_MinSuffixComponents : 83,
- CCN_DTAG_MaxSuffixComponents : 84,
- CCN_DTAG_ChildSelector : 85,
- CCN_DTAG_RepositoryInfo : 86,
- CCN_DTAG_Version : 87,
- CCN_DTAG_RepositoryVersion : 88,
- CCN_DTAG_GlobalPrefix : 89,
- CCN_DTAG_LocalName : 90,
- CCN_DTAG_Policy : 91,
- CCN_DTAG_Namespace : 92,
- CCN_DTAG_GlobalPrefixName : 93,
- CCN_DTAG_PolicyVersion : 94,
- CCN_DTAG_KeyValueSet : 95,
- CCN_DTAG_KeyValuePair : 96,
- CCN_DTAG_IntegerValue : 97,
- CCN_DTAG_DecimalValue : 98,
- CCN_DTAG_StringValue : 99,
- CCN_DTAG_BinaryValue : 100,
- CCN_DTAG_NameValue : 101,
- CCN_DTAG_Entry : 102,
- CCN_DTAG_ACL : 103,
- CCN_DTAG_ParameterizedName : 104,
- CCN_DTAG_Prefix : 105,
- CCN_DTAG_Suffix : 106,
- CCN_DTAG_Root : 107,
- CCN_DTAG_ProfileName : 108,
- CCN_DTAG_Parameters : 109,
- CCN_DTAG_InfoString : 110,
- CCN_DTAG_StatusResponse : 112,
- CCN_DTAG_StatusCode : 113,
- CCN_DTAG_StatusText : 114,
- CCN_DTAG_Nack : 200,
- CCN_DTAG_SequenceNumber : 256,
- CCN_DTAG_CCNProtocolDataUnit : 17702112
-};
\ No newline at end of file
diff --git a/src-old/TextXMLEncoder.js b/src-old/TextXMLEncoder.js
deleted file mode 100644
index 402022d..0000000
--- a/src-old/TextXMLEncoder.js
+++ /dev/null
@@ -1,18 +0,0 @@
-/*
-
- */
-
-
-/**
- * An implementation of XMLEncoder for the Text codec.
- *
- * @see TextXMLCodec
- * @see XMLEncoder
- */
-var TextXMLEncoder = function TextXMLEncoder(){
-
-
-
-};
-
-
diff --git a/src/CCNProtocolDTags.js b/src/CCNProtocolDTags.js
deleted file mode 100644
index cab4a4c..0000000
--- a/src/CCNProtocolDTags.js
+++ /dev/null
@@ -1,125 +0,0 @@
-
-
-
-exports.CCNProtocolDTags = {
-
- /**
- * Note if you add one of these, add it to the reverse string map as well.
- * Emphasize getting the work done at compile time over trying to make something
- * flexible and developer error-proof.
- */
-
- Any : 13,
- Name : 14,
- Component : 15,
- Certificate : 16,
- Collection : 17,
- CompleteName : 18,
- Content : 19,
- SignedInfo : 20,
- ContentDigest : 21,
- ContentHash : 22,
- Count : 24,
- Header : 25,
- Interest : 26, /* 20090915 */
- Key : 27,
- KeyLocator : 28,
- KeyName : 29,
- Length : 30,
- Link : 31,
- LinkAuthenticator : 32,
- NameComponentCount : 33, /* DeprecatedInInterest */
- RootDigest : 36,
- Signature : 37,
- Start : 38,
- Timestamp : 39,
- Type : 40,
- Nonce : 41,
- Scope : 42,
- Exclude : 43,
- Bloom : 44,
- BloomSeed : 45,
- AnswerOriginKind : 47,
- InterestLifetime : 48,
- Witness : 53,
- SignatureBits : 54,
- DigestAlgorithm : 55,
- BlockSize : 56,
- FreshnessSeconds : 58,
- FinalBlockID : 59,
- PublisherPublicKeyDigest : 60,
- PublisherCertificateDigest : 61,
- PublisherIssuerKeyDigest : 62,
- PublisherIssuerCertificateDigest : 63,
- ContentObject : 64, /* 20090915 */
- WrappedKey : 65,
- WrappingKeyIdentifier : 66,
- WrapAlgorithm : 67,
- KeyAlgorithm : 68,
- Label : 69,
- EncryptedKey : 70,
- EncryptedNonceKey : 71,
- WrappingKeyName : 72,
- Action : 73,
- FaceID : 74,
- IPProto : 75,
- Host : 76,
- Port : 77,
- MulticastInterface : 78,
- ForwardingFlags : 79,
- FaceInstance : 80,
- ForwardingEntry : 81,
- MulticastTTL : 82,
- MinSuffixComponents : 83,
- MaxSuffixComponents : 84,
- ChildSelector : 85,
- RepositoryInfo : 86,
- Version : 87,
- RepositoryVersion : 88,
- GlobalPrefix : 89,
- LocalName : 90,
- Policy : 91,
- Namespace : 92,
- GlobalPrefixName : 93,
- PolicyVersion : 94,
- KeyValueSet : 95,
- KeyValuePair : 96,
- IntegerValue : 97,
- DecimalValue : 98,
- StringValue : 99,
- BinaryValue : 100,
- NameValue : 101,
- Entry : 102,
- ACL : 103,
- ParameterizedName : 104,
- Prefix : 105,
- Suffix : 106,
- Root : 107,
- ProfileName : 108,
- Parameters : 109,
- InfoString : 110,
- // 111 unallocated
- StatusResponse : 112,
- StatusCode : 113,
- StatusText : 114,
-
- // Sync protocol
- SyncNode : 115,
- SyncNodeKind : 116,
- SyncNodeElement : 117,
- SyncVersion : 118,
- SyncNodeElements : 119,
- SyncContentHash : 120,
- SyncLeafCount : 121,
- SyncTreeDepth : 122,
- SyncByteCount : 123,
- ConfigSlice : 124,
- ConfigSliceList : 125,
- ConfigSliceOp : 126,
-
- // Remember to keep in sync with schema/tagnames.csvsdict
- CCNProtocolDataUnit : 17702112,
- CCNPROTOCOL_DATA_UNIT : "CCNProtocolDataUnit"
-};
-
-
diff --git a/src/ContentName.js b/src/ContentName.js
deleted file mode 100644
index 54d70f9..0000000
--- a/src/ContentName.js
+++ /dev/null
@@ -1,46 +0,0 @@
-
-var CCNProtocolDTags = require('./CCNProtocolDTags').CCNProtocolDTags;
-
-var ContentName = function ContentName(_Components){
-
-
- this.SCHEME = "ccnx:";
-
- this.ORIGINAL_SCHEME = "ccn:";
-
- this.SEPARATOR = "/";
- this.ROOT = null;
-
- this.Components = _Components;
-};
-
-exports.ContentName = ContentName;
-
-ContentName.prototype.decode = function(/*XMLDecoder*/ decoder) {
- decoder.readStartElement(this.getElementLabel());
-
- this.Components = new Array(); //new ArrayList<byte []>();
-
- while (decoder.peekStartElement(CCNProtocolDTags.Component)) {
- this.Components.add(decoder.readBinaryElement(CCNProtocolDTags.Component));
- }
-
- decoder.readEndElement();
-};
-
-ContentName.prototype.encode = function(/*XMLEncoder*/ encoder) {
- //if (!validate()) {
- //throw new ContentEncodingException("Cannot encode " + this.getClass().getName() + ": field values missing.");
- //}
-
- encoder.writeStartElement(this.getElementLabel());
- var count = this.Components.length;
- for (var i=0; i < count; ++i) {
- encoder.writeElement(CCNProtocolDTags.Component, this.Components.get(i));
- }
- encoder.writeEndElement();
-};
-
-ContentName.prototype.getElementLabel = function(){
- return CCNProtocolDTags.Name;
-};
diff --git a/src/ContentObject.js b/src/ContentObject.js
deleted file mode 100644
index fb1ff09..0000000
--- a/src/ContentObject.js
+++ /dev/null
@@ -1,61 +0,0 @@
-
-var CCNProtocolDTags = require('./CCNProtocolDTags').CCNProtocolDTags;
-
-var ContentObject = function ContentObject(_Name,_SignedInfo,_Content,_Signature){
-
-
- this.Name = _Name;
- this.SignedInfo = _SignedInfo;
- this.Content=_Content;
- this.Signature = _Signature;
-
-};
-
-exports.ContentObject = ContentObject;
-
-
-ContentObject.prototype.decode = function(/*XMLDecoder*/ decoder) {
-
- decoder.readStartElement(this.getElementLabel());
-
- this.Signature = new Signature();
- this.Signature.decode(decoder);
-
- this.Name = new ContentName();
- this.Name.decode(decoder);
-
- this.SignedInfo = new SignedInfo();
- this.SignedInfo.decode(decoder);
-
- this.Content = decoder.readBinaryElement(CCNProtocolDTags.Content);
-
- decoder.readEndElement();
-
-};
-
-
-ContentObject.prototype.encode = function(/*XMLEncoder*/ encoder) {
-
- if((null == this.Name) && (null==this.SignedInfo) && (null ==this.Signature)){
-
- throw "Illegal input inside encode of Content Object";
- }
- /*
- * if (!validate()) {
- throw new ContentEncodingException("Cannot encode " + this.getClass().getName() + ": field values missing.");
- }*/
-
- encoder.writeStartElement(this.getElementLabel());
-
- this.Signature.encode(encoder);
- this.Name.encode(encoder);
- this.SignedInfo.encode(encoder);
-
- encoder.writeElement(CCNProtocolDTags.Content, this.Content);
-
- encoder.writeEndElement();
-
-};
-
-
-ContentObject.prototype.getElementLabel= function(){returnCCNProtocolDTags.ContentObject;};
\ No newline at end of file
diff --git a/src/Exclude.js b/src/Exclude.js
deleted file mode 100644
index 667c8cf..0000000
--- a/src/Exclude.js
+++ /dev/null
@@ -1,54 +0,0 @@
-
-var CCNProtocolDTags = require('./CCNProtocolDTags').CCNProtocolDTags;
-
-var Exclude = function Exclude(_Values){
-
- this.OPTIMUM_FILTER_SIZE = 100;
-
-
- this.Values = _Values; //array of elements
-
-}
-exports.Exclude = Exclude;
-
-Exclude.prototype.decode = function(/*XMLDecoder*/ decoder) {
-
-
-
- decoder.readStartElement(this.getElementLabel());
-
- //TODO BUGS
- /*var component;
- var any = false;
- while ((component = decoder.peekStartElement(CCNProtocolDTags.Component)) ||
- (any = decoder.peekStartElement(CCNProtocolDTags.Any)) ||
- decoder.peekStartElement(CCNProtocolDTags.Bloom)) {
- var ee = component?new ExcludeComponent(): any ? new ExcludeAny() : new BloomFilter();
- ee.decode(decoder);
- _values.add(ee);
- }*/
-
- decoder.readEndElement();
-
-};
-
-Exclude.prototype.encode=function(/*XMLEncoder*/ encoder) {
- if (!validate()) {
- throw new ContentEncodingException("Cannot encode " + this.getClass().getName() + ": field values missing.");
- }
- // if everything is null, output nothing
- if (empty())
- return;
-
- encoder.writeStartElement(getElementLabel());
-
- /*
- for (Element element : _values)
- element.encode(encoder);
- */
-
- encoder.writeEndElement();
- };
-
-Exclude.prototype.getElementLabel = function() { return CCNProtocolDTags.Exclude; };
-
diff --git a/src/ExcludeAny.js b/src/ExcludeAny.js
deleted file mode 100644
index 4fbeb14..0000000
--- a/src/ExcludeAny.js
+++ /dev/null
@@ -1,21 +0,0 @@
-
-var CCNProtocolDTags = require('./CCNProtocolDTags').CCNProtocolDTags;
-
-var ExcludeAny = function ExcludeAny() {
-
-};
-
-exports.ExcludeAny= ExcludeAny;
-
-ExcludeAny.prototype.decode = function(decoder) {
- decoder.readStartElement(this.getElementLabel());
- decoder.readEndElement();
-};
-
-
-ExcludeAny.prototype.encode = function( encoder) {
- encoder.writeStartElement(this.getElementLabel());
- encoder.writeEndElement();
-};
-
-ExcludeAny.prototype.getElementLabel=function() { return CCNProtocolDTags.Any; };
diff --git a/src/ExcludeComponent.js b/src/ExcludeComponent.js
deleted file mode 100644
index 91d6cae..0000000
--- a/src/ExcludeComponent.js
+++ /dev/null
@@ -1,23 +0,0 @@
-var CCNProtocolDTags = require('./CCNProtocolDTags').CCNProtocolDTags;
-
-/*
- * _Body is an array of componenets
- */
-var ExcludeComponent = function ExcludeComponent(_Body) {
-
- //TODO Check BODY is an Array of componenets.
-
- this.Body = _Body
-};
-exports.ExcludeComponent = ExcludeComponent;
-
-ExcludeComponent.prototype.decode = function( decoder) {
- body = decoder.readBinaryElement(this.getElementLabel());
-};
-
-ExcludeComponent.prototype.encode = function(encoder) {
- encoder.writeElement(this.getElementLabel(), body);
-};
-
-ExcludeComponent.prototype.getElementLabel = function() { return CCNProtocolDTags.Component; };
-
diff --git a/src/Interest.js b/src/Interest.js
deleted file mode 100644
index 1fd2585..0000000
--- a/src/Interest.js
+++ /dev/null
@@ -1,128 +0,0 @@
-var CCNProtocolDTags = require('./CCNProtocolDTags').CCNProtocolDTags;
-
-var Interest = function Interest(_Name,_MinSuffixComponents,_MaxSuffixComponents,_PublisherPublicKeyDigest, _Exclude, _ChildSelector,_AnswerOriginKind,_Scope,_InterestLifetime,_Nonce){
-
-
- this.Name = _Name;
- this.MaxSuffixComponents = _MaxSuffixComponents;
- this.MinSuffixComponents = _MinSuffixComponents;
-
- this.PublisherKeyDigest = _PublisherPublicKeyDigest;
- this.Exclude = _Exclude;
- this.ChildSelector = _ChildSelector;
- this.AnswerOriginKind = _AnswerOriginKind;
- this.Scope = _Scope;
- this.InterestLifetime = null; // For now we don't have the ability to set an interest lifetime
- this.Nonce = _Nonce;
-
- /*Not sure if the rest is needed*/
- this.Publisher = _Publisher;
-
- this.UserTime=_UserTime;
-
- this.RECURSIVE_POSTFIX = "*";
-
- this.CHILD_SELECTOR_LEFT = 0;
- this.CHILD_SELECTOR_RIGHT = 1;
- this.ANSWER_CONTENT_STORE = 1;
- this.ANSWER_GENERATED = 2;
- this.ANSWER_STALE = 4; // Stale answer OK
- this.MARK_STALE = 16; // Must have Scope 0. Michael calls this a "hack"
-
- this.DEFAULT_ANSWER_ORIGIN_KIND = ANSWER_CONTENT_STORE | ANSWER_GENERATED;
-
-
-};
-exports.Interest = Interest;
-
-Interest.prototype.decode(/*XMLDecoder*/ decoder) {
-
- decoder.readStartElement(CCNProtocolDTags.Interest);
-
- this.Name = new ContentName();
- this.Name.decode(decoder);
-
- if (decoder.peekStartElement(CCNProtocolDTags.MinSuffixComponents)) {
- this.MinSuffixComponents = decoder.readIntegerElement(CCNProtocolDTags.MinSuffixComponents);
- }
-
- if (decoder.peekStartElement(CCNProtocolDTags.MaxSuffixComponents)) {
- this.MaxSuffixComponents = decoder.readIntegerElement(CCNProtocolDTags.MaxSuffixComponents);
- }
-
- //TODO something about that guy
- /*if (PublisherID.peek(decoder)) {
- this.Publisher = new PublisherID();
- this.Publisher.decode(decoder);
- }*/
-
- if (decoder.peekStartElement(CCNProtocolDTags.Exclude)) {
- this.Exclude = new Exclude();
- this.Exclude.decode(decoder);
- }
-
- if (decoder.peekStartElement(CCNProtocolDTags.ChildSelector)) {
- this.ChildSelector = decoder.readIntegerElement(CCNProtocolDTags.ChildSelector);
- }
-
- if (decoder.peekStartElement(CCNProtocolDTags.AnswerOriginKind)) {
- // call setter to handle defaulting
- this.AnswerOriginKind = decoder.readIntegerElement(CCNProtocolDTags.AnswerOriginKind);
- }
-
- if (decoder.peekStartElement(CCNProtocolDTags.Scope)) {
- this.Scope = decoder.readIntegerElement(CCNProtocolDTags.Scope);
- }
-
- if (decoder.peekStartElement(CCNProtocolDTags.InterestLifetime)) {
- this.InterestLifetime = decoder.readBinaryElement(CCNProtocolDTags.InterestLifetime);
- }
-
- if (decoder.peekStartElement(CCNProtocolDTags.Nonce)) {
- this.Nonce = decoder.readBinaryElement(CCNProtocolDTags.Nonce);
- }
-
- decoder.readEndElement();
-};
-
-
-Interest.prototype.encode = function(/*XMLEncoder*/ encoder){
- if (!validate()) {
- throw new ContentEncodingException("Cannot encode " + this.getClass().getName() + ": field values missing.");
- }
-
- encoder.writeStartElement(CCNProtocolDTags.Interest);
-
- this.Name.encode(encoder);
-
- if (null != this.MinSuffixComponents)
- encoder.writeElement(CCNProtocolDTags.MinSuffixComponents, this.MinSuffixComponents);
-
- if (null != this.MaxSuffixComponents)
- encoder.writeElement(CCNProtocolDTags.MaxSuffixComponents, this.MaxSuffixComponents);
-
- //TODO
-
- /*if (null != this.PublisherID)
- publisherID().encode(encoder);*/
-
- //if (null != this.Exclude)
- //exclude().encode(encoder);
-
- if (null != this.ChildSelector)
- encoder.writeElement(CCNProtocolDTags.ChildSelector, this.ChildSelector);
-
- if (this.DEFAULT_ANSWER_ORIGIN_KIND != this.AnswerOriginKind)
- encoder.writeElement(CCNProtocolDTags.AnswerOriginKind, this.AnswerOriginKind);
-
- if (null != this.Scope)
- encoder.writeElement(CCNProtocolDTags.Scope, this.Scope);
-
- if (null != this.Nonce)
- encoder.writeElement(CCNProtocolDTags.Nonce, this.Nonce);
-
- encoder.writeEndElement();
-};
-
-
-
diff --git a/src/KeyLocator.js b/src/KeyLocator.js
deleted file mode 100644
index 7d230da..0000000
--- a/src/KeyLocator.js
+++ /dev/null
@@ -1,119 +0,0 @@
-var CCNProtocolDTags = require('./CCNProtocolDTags').CCNProtocolDTags;
-
-var KeyLocatorType = function(){
-
-};
-
-
-exports.KeyLocatorType = {
- NAME:1,
- KEY:2,
- CERTIFICATE:3
-};
-
-exports.KeyLocatorType = KeyLocatorType;
-
-var KeyLocator = function KeyLocator(_Input,_Type){
-
- //this.KeyName = _KeyName;
- //this.PublicKey = _PublicKey;
- //this.Certificate = _Certificate;
-
- this.Type=_Type;
-
- if (_Type==KeyLocatorType.NAME){
- this.KeyName = _Input;
- }
- else if(_Type==KeyLocatorType.KEY){
- this.PublicKey = _Input;
- }
- else if(_Type==KeyLocatorType.CERTIFICATE){
- this.Certificate = _Input;
- }
-
-};
-
-exports.KeyLocator = KeyLocator;
-
-KeyLocator.prototype.decode = function(decoder) {
-
- decoder.readStartElement(this.getElementLabel());
-
- if (decoder.peekStartElement(CCNProtocolDTags.Key)) {
- try {
- encodedKey = decoder.readBinaryElement(CCNProtocolDTags.Key);
- // This is a DER-encoded SubjectPublicKeyInfo.
-
- //TODO FIX THIS, SHOULDN'T be like that
- //this.Key = CryptoUtil.getPublicKey(encodedKey);
-
- this.PublicKey = encodedKey;
-
-
- } catch (e) {
- console.log("Cannot parse stored key: error: " + e);
- throw new ContentDecodingException("Cannot parse key: ", e);
- }
-
- if (null == Key) {
- throw new Exception("Cannot parse key: ");
- }
-
- } else if ( decoder.peekStartElement(CCNProtocolDTags.Certificate)) {
- try {
- encodedCert = decoder.readBinaryElement(CCNProtocolDTags.Certificate);
- /*
- * Certificates not yet working
- */
-
- //CertificateFactory factory = CertificateFactory.getInstance("X.509");
- //this.Certificate = (X509Certificate) factory.generateCertificate(new ByteArrayInputStream(encodedCert));
-
- } catch ( e) {
- throw new Exception("Cannot decode certificate: " + e);
- }
- if (null == this.Certificate) {
- throw new Exception("Cannot parse certificate! ");
- }
- } else {
- this.KeyName = new KeyName();
- this.KeyName.decode(decoder);
- }
- decoder.readEndElement();
- }
-
-
- KeyLocator.prototype.encode = function( encoder) {
- /*if (!validate()) {
- throw new ContentEncodingException("Cannot encode " + this.getClass().getName() + ": field values missing.");
- }*/
-
-
- //TODO FIX THIS TOO
- encoder.writeStartElement(this.getElementLabel());
- if (this._Type == KeyLocatorType.KEY) {
- encoder.writeElement(CCNProtocolDTags.Key, this.PublicKey.getEncoded() );
-
- } else if (this.Type == KeyLocatorType.CERTIFICATE) {
- try {
- encoder.writeElement(CCNProtocolDTags.Certificate, this.Certificate.getEncoded());
- } catch ( e) {
-
- throw new Exception("CertificateEncodingException attempting to write key locator: " + e);
- }
-
- } else if (this.Type == KeyLocatorType.NAME) {
- this.KeyName.encode(encoder);
- }
- encoder.writeEndElement();
-
-};
-
-KeyLocator.prototype.getElementLabel = function() {
- return CCNProtocolDTags.KeyLocator;
-};
-
-KeyLocator.prototype.validate = function() {
- return ( (null != this.keyName) || (null != this.PublicKey) || (null != this.Certificate) );
-};
-
\ No newline at end of file
diff --git a/src/KeyName.js b/src/KeyName.js
deleted file mode 100644
index d534944..0000000
--- a/src/KeyName.js
+++ /dev/null
@@ -1,50 +0,0 @@
-var CCNProtocolDTags = require('./CCNProtocolDTags').CCNProtocolDTags;
-
-
-var KeyName = function KeyName() {
-
-
- this.ContentName = this.ContentName;//ContentName
- this.PublisherID =this.PublisherID;//PublisherID
-
-};
-
-exports.KeyName = KeyName;
-
-KeyName.prototype.decode=function( decoder){
-
-
- decoder.readStartElement(this.getElementLabel());
-
- this.ContentName = new ContentName();
- this.ContentName.decode(decoder);
-
- if (PublisherID.peek(decoder)) {
- this.PublisherID = new PublisherID();
- this.PublisherID.decode(decoder);
- }
-
- decoder.readEndElement();
-};
-
-KeyName.prototype.encode = function( encoder) {
- if (!this.validate()) {
- throw new Exception("Cannot encode : field values missing.");
- }
-
- encoder.writeStartElement(this.getElementLabel());
-
- this.ContentName.encode(encoder);
- if (null != this.PublisherID)
- this.PublisherID.encode(encoder);
-
- encoder.writeEndElement();
-};
-
-KeyName.prototype.getElementLabel = function() { return CCNProtocolDTags.KeyName; };
-
-KeyName.prototype.validate = function() {
- // DKS -- do we do recursive validation?
- // null signedInfo ok
- return (null != this.ContentName);
-};
diff --git a/src/PublisherID.js b/src/PublisherID.js
deleted file mode 100644
index 26009da..0000000
--- a/src/PublisherID.js
+++ /dev/null
@@ -1,76 +0,0 @@
-var CCNProtocolDTags = require('./CCNProtocolDTags').CCNProtocolDTags;
-
-
-var PublisherType = function PublisherType(_tag){
- this.KEY =(CCNProtocolDTags.PublisherPublicKeyDigest);
- this.CERTIFICATE= (CCNProtocolDTags.PublisherCertificateDigest);
- this.ISSUER_KEY= (CCNProtocolDTags.PublisherIssuerKeyDigest);
- this.ISSUER_CERTIFICATE =(CCNProtocolDTags.PublisherIssuerCertificateDigest);
-
- this.Tag = _tag;
-}; exports.PublisherType = PublisherType;
-
-PublisherType.prototype.isTypeTagVal = function(tagVal) {
- if ((tagVal == CCNProtocolDTags.PublisherPublicKeyDigest) ||
- (tagVal == CCNProtocolDTags.PublisherCertificateDigest) ||
- (tagVal == CCNProtocolDTags.PublisherIssuerKeyDigest) ||
- (tagVal == CCNProtocolDTags.PublisherIssuerCertificateDigest)) {
- return true;
- }
- return false;
-};
-
-
-var PublisherID = function PublisherID() {
-
- this.PUBLISHER_ID_DIGEST_ALGORITHM = "SHA-256";
- this.PUBLISHER_ID_LEN = 256/8;
-
-
- this.PublisherID = generatePublicKeyDigest(key);//ByteArray
- //CryptoUtil.generateKeyID(PUBLISHER_ID_DIGEST_ALGORITHM, key);
- this.PublisherType = isIssuer ? PublisherType.ISSUER_KEY : PublisherType.KEY;//publisher Type
-
-};
-
-exports.PublisherID = PublisherID;
-
-PublisherID.prototype.decode = function(decoder) {
-
- // We have a choice here of one of 4 binary element types.
- var nextTag = decoder.peekStartElementAsLong();
-
- if (null == nextTag) {
- throw new Exception("Cannot parse publisher ID.");
- }
-
- this.PublisherType = new PublisherType(nextTag);
-
- if (!this.PublisherType.isTypeTagVal(nextTag)) {
- throw new Exception("Invalid publisher ID, got unexpected type: " + nextTag);
- }
- this.PublisherID = decoder.readBinaryElement(nextTag);
- if (null == _publisherID) {
- throw new ContentDecodingException("Cannot parse publisher ID of type : " + nextTag + ".");
- }
-};
-
-PublisherID.prototype.encode = function(encoder) {
- if (!this.validate()) {
- throw new Exception("Cannot encode " + this.getClass().getName() + ": field values missing.");
- }
-
- encoder.writeElement(this.getElementLabel(), this.PublisherID);
-};
-
-PublisherID.prototype.getElementLabel = function() {
- return this.PublisherType.Tag;
-};
-
-
-PublisherID.prototype.validate = function(){
- return ((null != id() && (null != type())));
-};
-
-
-
diff --git a/src/PublisherPublicKeyDigest.js b/src/PublisherPublicKeyDigest.js
deleted file mode 100644
index 3d3987a..0000000
--- a/src/PublisherPublicKeyDigest.js
+++ /dev/null
@@ -1,38 +0,0 @@
-
-var PublisherID = require('./PublisherID').PublisherID;
-var CCNProtocolDTags = require('./CCNProtocolDTags').CCNProtocolDTags;
-
-var PublisherPublicKeyDigest = function PublisherPublicKeyDigest(_pkd){
-
- if( typeof _pkd == "ByteArray") this.PublisherPublicKeyDigest = _pkd; // Byte Array
- else if( typeof _pkd == "PublicKey") ;//TODO...
-
-};
-
-exports.PublisherPublicKeyDigest = PublisherPublicKeyDigest;
-
-
-PublisherPublicKeyDigest.prototype.decode = function( decoder) {
-
- this.PublisherPublicKeyDigest = decoder.readBinaryElement(this.getElementLabel());
- if (null == this.PublisherPublicKeyDigest) {
- throw new Exception("Cannot parse publisher key digest.");
- }
- if (this.PublisherPublicKeyDigest.length != PublisherID.PUBLISHER_ID_LEN) {
-
- this.PublisherPublicKeyDigest = new PublisherPublicKeyDigest(this.PublisherPublicKeyDigest).PublisherKeyDigest;
- }
- };
-
-PublisherPublicKeyDigest.prototype.encode= function( encoder) {
- if (!this.validate()) {
- throw new Exception("Cannot encode : field values missing.");
- }
- this.encoder.writeElement(this.getElementLabel(), this.PublisherKeyDigest);
-};
-
-PublisherPublicKeyDigest.prototype.getElementLabel = function() { return CCNProtocolDTags.PublisherPublicKeyDigest; };
-
-PublisherPublicKeyDigest.prototype.validate =function() {
- return (null != this.PublisherKeyDigest);
-};
diff --git a/src/Signature.js b/src/Signature.js
deleted file mode 100644
index d4c3fa4..0000000
--- a/src/Signature.js
+++ /dev/null
@@ -1,58 +0,0 @@
-var CCNProtocolDTags = require('./CCNProtocolDTags').CCNProtocolDTags;
-
-
-var Signature = function Signature(_Witness,_Signature,_DigestAlgorithm) {
-
- this.Witness = _Witness;//byte [] _witness;
- this.Signature = _Signature;//byte [] _signature;
- this.DigestAlgorithm = _DigestAlgorithm//String _digestAlgorithm;
-};
-
-exports.Signature = Signature;
-
-
-Signature.prototype.decode =function( decoder) {
- decoder.readStartElement(this.getElementLabel());
- if (decoder.peekStartElement(CCNProtocolDTags.DigestAlgorithm)) {
- this.DigestAlgorithm = decoder.readUTF8Element(CCNProtocolDTags.DigestAlgorithm);
- }
- if (decoder.peekStartElement(CCNProtocolDTags.Witness)) {
- this.Witness = decoder.readBinaryElement(CCNProtocolDTags.Witness);
- }
- this.Signature = decoder.readBinaryElement(CCNProtocolDTags.SignatureBits);
- decoder.readEndElement();
-
-};
-
-
-exports.Signature = Signature;
-
-Signature.prototype.encode= function( encoder){
-
- if (!this.validate()) {
- throw new Exception("Cannot encode: field values missing.");
- }
-
- encoder.writeStartElement(this.getElementLabel());
-
- if ((null != this.DigestAlgorithm) && (!this.DigestAlgorithm.equals(CCNDigestHelper.DEFAULT_DIGEST_ALGORITHM))) {
- encoder.writeElement(CCNProtocolDTags.DigestAlgorithm, OIDLookup.getDigestOID(this.DigestAlgorithm));
- }
-
- if (null != this.Witness) {
- // needs to handle null witness
- encoder.writeElement(CCNProtocolDTags.Witness, this.Witness);
- }
-
- encoder.writeElement(CCNProtocolDTags.SignatureBits, this.Signature);
-
- encoder.writeEndElement();
-};
-
-Signature.prototype.getElementLabel = function() { return CCNProtocolDTags.Signature; };
-
-
-Signature.prototype.validate = function() {
- return null != this.Signature;
-};
-
diff --git a/src/SignedInfo.js b/src/SignedInfo.js
deleted file mode 100644
index 14b72ef..0000000
--- a/src/SignedInfo.js
+++ /dev/null
@@ -1,106 +0,0 @@
-var CCNProtocolDTags = require('./CCNProtocolDTags').CCNProtocolDTags;
-
-var SignedInfo = function SignedInfo(_publisher,_timestamp,_type,_locator,_freshnessSeconds,_finalBlockID){
-
- //TODO, Check types
-
- this.Publisher = _publisher; //PublisherPublicKeyDigest
- this.Timestamp=_timestamp; // CCN Time
- this.Type=_type; // ContentType
- this.Locator =_locator;//KeyLocator
- this.FreshnessSeconds =_freshnessSeconds; // Integer
- this.FinalBlockID=_finalBlockID; //byte array
-
-};
-
-//exports.SignedInfo.Working;
-
-
-SignedInfo.prototype.decode = function( decoder){
-
- decoder.readStartElement( this.getElementLabel() );
-
- if (decoder.peekStartElement(CCNProtocolDTags.PublisherPublicKeyDigest)) {
- this.Publisher = new PublisherPublicKeyDigest();
- this.Publisher.decode(decoder);
- }
-
- if (decoder.peekStartElement(CCNProtocolDTags.Timestamp)) {
- this.Timestamp = decoder.readDateTime(CCNProtocolDTags.Timestamp);
- }
-
- if (decoder.peekStartElement(CCNProtocolDTags.Type)) {
- binType = decoder.readBinaryElement(CCNProtocolDTags.Type);//byte []
- //TODO Implement valueToType
-
- this.Type = valueToType(binType);
- if (null == this.Type) {
- throw new Exception("Cannot parse signedInfo type: bytes.");
- }
-
- } else {
- this.Type = ContentType.DATA; // default
- }
-
- if (decoder.peekStartElement(CCNProtocolDTags.FreshnessSeconds)) {
- this.FreshnessSeconds = decoder.readIntegerElement(CCNProtocolDTags.FreshnessSeconds);
- }
-
- if (decoder.peekStartElement(CCNProtocolDTags.FinalBlockID)) {
- this.FinalBlockID = decoder.readBinaryElement(CCNProtocolDTags.FinalBlockID);
- }
-
- if (decoder.peekStartElement(CCNProtocolDTags.KeyLocator)) {
- this.Locator = new KeyLocator();
- this.Locator.decode(decoder);
- }
-
- decoder.readEndElement();
-};
-
-SignedInfo.prototype.encode = function( encoder) {
- if (!this.validate()) {
- throw new Exception("Cannot encode : field values missing.");
- }
- encoder.writeStartElement(this.getElementLabel());
-
- if (null!=this.Publisher) {
- this.Publisher.encode(encoder);
- }
-
- if (null!=this.Timestamp) {
- encoder.writeDateTime(CCNProtocolDTags.Timestamp, this.Timestamp);
- }
-
- if (null!=this.Type) {
-
- encoder.writeElement(CCNProtocolDTags.Type, this.Type);
- }
-
- if (null!=this.FreshnessSeconds) {
- encoder.writeElement(CCNProtocolDTags.FreshnessSeconds, this.FreshnessSeconds);
- }
-
- if (null!=this.FinalBlockID) {
- encoder.writeElement(CCNProtocolDTags.FinalBlockID, this.FinalBlockID);
- }
-
- if (null!=this.Locator) {
- this.Locator.encode(encoder);
- }
-
- encoder.writeEndElement();
-};
-
-SignedInfo.prototype.getElementLabel = function() {
- return CCNProtocolDTags.SignedInfo;
-};
-
-SignedInfo.prototype.validate = function() {
- // We don't do partial matches any more, even though encoder/decoder
- // is still pretty generous.
- if (null ==this.Publisher || null==this.Timestamp ||null== this.Locator)
- return false;
- return true;
- };
-
diff --git a/src/encoding/BinaryXMLCodec.js b/src/encoding/BinaryXMLCodec.js
deleted file mode 100644
index 077c7e2..0000000
--- a/src/encoding/BinaryXMLCodec.js
+++ /dev/null
@@ -1,135 +0,0 @@
-
-var XML_EXT = 0x00;
-
-var XML_TAG = 0x01;
-
-var XML_DTAG = 0x02;
-
-var XML_ATTR = 0x03;
-
-var XML_DATTR = 0x04;
-
-var XML_BLOB = 0x05;
-
-var XML_UDATA = 0x06;
-
-var XML_CLOSE = 0x0;
-
-var XML_SUBTYPE_PROCESSING_INSTRUCTIONS = 16;
-
-
-var XML_TT_BITS = 3;
-var XML_TT_MASK = ((1 << XML_TT_BITS) - 1);
-var XML_TT_VAL_BITS = XML_TT_BITS + 1;
-var XML_TT_VAL_MASK = ((1 << (XML_TT_VAL_BITS)) - 1);
-var XML_REG_VAL_BITS = 7;
-var XML_REG_VAL_MASK = ((1 << XML_REG_VAL_BITS) - 1);
-var XML_TT_NO_MORE = (1 << XML_REG_VAL_BITS); // 0x80
-var BYTE_MASK = 0xFF;
-var LONG_BYTES = 8;
-var LONG_BITS = 64;
-
-var bits_11 = 0x0000007FFL;
-var bits_18 = 0x00003FFFFL;
-var bits_32 = 0x0FFFFFFFFL;
-
-
-var TypeAndVal = function TypeAndVal(_type,_val) {
- this.type = _type;
- this.val = _val;
-
-};
-exports.TypeAndVal = TypeAndVal;
-
-var BinaryXMLCodec = function BinaryXMLCodec(){
-
- this.CODEC_NAME = "Binary";
-
-
-
-};
-
-exports.BinaryXMLCodec = BinaryXMLCodec;
-
-
-
-BinaryXMLCodec.prototype.encodeTypeAndVal = function(
- //int
- type,
- //long
- val,
- //byte []
- buf,
- //int
- offset) {
-
- if ((type > XML_UDATA) || (type < 0) || (val < 0)) {
- throw new Exception("Tag and value must be positive, and tag valid.");
- }
-
- // Encode backwards. Calculate how many bytes we need:
- int numEncodingBytes = numEncodingBytes(val);
-
- if ((offset + numEncodingBytes) > buf.length) {
- throw new Exception("Buffer space of " + (buf.length-offset) +
- " bytes insufficient to hold " +
- numEncodingBytes + " of encoded type and value.");
- }
-
-
- buf[offset + numEncodingBytes - 1] =
- (BYTE_MASK &
- (((XML_TT_MASK & type) |
- ((XML_TT_VAL_MASK & val) << XML_TT_BITS))) |
- XML_TT_NO_MORE);
- val = val >>> XML_TT_VAL_BITS;;
-
- int i = offset + numEncodingBytes - 2;
- while ((0 != val) && (i >= offset)) {
- buf[i] = (BYTE_MASK &
- (val & XML_REG_VAL_MASK));
- val = val >>> XML_REG_VAL_BITS;
- --i;
- }
-
- return numEncodingBytes;
-};
-
-BinaryXMLCodec.prototype.decodeTypeAndVal = function(
- /*InputStream*/
- istream) {
-
- int next;
- int type = -1;
- long val = 0;
- boolean more = true;
-
- do {
- next = istream.read();
-
- if (next < 0) {
- return null;
- }
-
- if ((0 == next) && (0 == val)) {
- return null;
- }
-
- more = (0 == (next & XML_TT_NO_MORE));
-
- if (more) {
- val = val << XML_REG_VAL_BITS;
- val |= (next & XML_REG_VAL_MASK);
- } else {
-
- type = next & XML_TT_MASK;
- val = val << XML_TT_VAL_BITS;
- val |= ((next >>> XML_TT_BITS) & XML_TT_VAL_MASK);
- }
-
- } while (more);
-
- return new TypeAndVal(type, val);
-};
-
-//TODO
\ No newline at end of file
diff --git a/src/encoding/BinaryXMLDecoder.js b/src/encoding/BinaryXMLDecoder.js
deleted file mode 100644
index 4a8b1c4..0000000
--- a/src/encoding/BinaryXMLDecoder.js
+++ /dev/null
@@ -1,89 +0,0 @@
-var MARK_LEN=512;
-var DEBUG_MAX_LEN = 32768;
-
-var BinaryXMLDecoder = new BinaryXMLDecoder(_Istream){
- this.Istream = _Istream;
-
-};
-
-
-BinaryXMLDecoder.prototype.readStartElement =function(
- //String
- startTag,
- //TreeMap<String, String>
- attributes) {
-
- try {
- BinaryXMLCodec.TypeAndVal tv = BinaryXMLCodec.decodeTypeAndVal(this.Istream);
-
- if (null == tv) {
- throw new Exception("Expected start element: " + startTag + " got something not a tag.");
- }
-
- String decodedTag = null;
-
- if (tv.type() == BinaryXMLCodec.XML_TAG) {
-
- decodedTag = BinaryXMLCodec.decodeUString(this.Istream, tv.val()+1);
-
- } else if (tv.type() == BinaryXMLCodec.XML_DTAG) {
- decodedTag = tagToString(tv.val());
- }
-
- if ((null == decodedTag) || (!decodedTag.equals(startTag))) {
- throw new Exception("Expected start element: " + startTag + " got: " + decodedTag + "(" + tv.val() + ")");
- }
-
- if (null != attributes) {
- readAttributes(attributes);
- }
-
- } catch (e) {
- throw new Exception("readStartElement", e);
- }
-};
-
-BinaryXMLDecoder.prototype.readAttributes = function(
- //TreeMap<String,String>
- attributes){
-
- if (null == attributes) {
- return;
- }
-
- try {
-
- BinaryXMLCodec.TypeAndVal nextTV = BinaryXMLCodec.peekTypeAndVal(_istream);
-
- while ((null != nextTV) && ((BinaryXMLCodec.XML_ATTR == nextTV.type()) ||
- (BinaryXMLCodec.XML_DATTR == nextTV.type()))) {
-
- BinaryXMLCodec.TypeAndVal thisTV = BinaryXMLCodec.decodeTypeAndVal(this.Istream);
-
- var attributeName = null;
- if (BinaryXMLCodec.XML_ATTR == thisTV.type()) {
-
- attributeName = BinaryXMLCodec.decodeUString(_istream, thisTV.val()+1);
-
- } else if (BinaryXMLCodec.XML_DATTR == thisTV.type()) {
- // DKS TODO are attributes same or different dictionary?
- attributeName = tagToString(thisTV.val());
- if (null == attributeName) {
- throw new ContentDecodingException("Unknown DATTR value" + thisTV.val());
- }
- }
-
- var attributeValue = BinaryXMLCodec.decodeUString(_istream);
-
- attributes.put(attributeName, attributeValue);
-
- nextTV = BinaryXMLCodec.peekTypeAndVal(_istream);
- }
-
- } catch ( e) {
-
- throw new ContentDecodingException("readStartElement", e);
- }
-};
-
-//TODO
\ No newline at end of file
diff --git a/src/encoding/BinaryXMLEncoder.js b/src/encoding/BinaryXMLEncoder.js
deleted file mode 100644
index 7ccf3b4..0000000
--- a/src/encoding/BinaryXMLEncoder.js
+++ /dev/null
@@ -1,31 +0,0 @@
-
-var BinaryXMLEncoder = function BinaryXMLEncoder(){
-
-BinaryXMLEncoder.prototype.writeStartElement = function(
- //String
- tag,
- //TreeMap<String,String>
- attributes){
-
-}
- try {
- var dictionaryVal = stringToTag(tag);
-
- if (null == dictionaryVal) {
- BinaryXMLCodec.encodeUString(_ostream, tag, BinaryXMLCodec.XML_TAG);
-
- } else {
- BinaryXMLCodec.encodeTypeAndVal(BinaryXMLCodec.XML_DTAG, dictionaryVal, _ostream);
- }
-
- if (null != attributes) {
- writeAttributes(attributes);
- }
-
- } catch (e) {
- throw new Exception(e);
- }
-};
-
-
-//TODO
\ No newline at end of file
diff --git a/src/encoding/TextXMLCodec.js b/src/encoding/TextXMLCodec.js
deleted file mode 100644
index ea64188..0000000
--- a/src/encoding/TextXMLCodec.js
+++ /dev/null
@@ -1 +0,0 @@
-//TODO
\ No newline at end of file
diff --git a/src/encoding/TextXMLDecoder.js b/src/encoding/TextXMLDecoder.js
deleted file mode 100644
index ea64188..0000000
--- a/src/encoding/TextXMLDecoder.js
+++ /dev/null
@@ -1 +0,0 @@
-//TODO
\ No newline at end of file
diff --git a/src/encoding/TextXMLEncoder.js b/src/encoding/TextXMLEncoder.js
deleted file mode 100644
index ea64188..0000000
--- a/src/encoding/TextXMLEncoder.js
+++ /dev/null
@@ -1 +0,0 @@
-//TODO
\ No newline at end of file
diff --git a/test/RandomTest.js b/test/RandomTest.js
deleted file mode 100644
index 5096382..0000000
--- a/test/RandomTest.js
+++ /dev/null
@@ -1,14 +0,0 @@
-console.log("HELLO");
-
-require('../src/CCNProtocolDTags');
-
-
-var RandomTest = function RandomTest(){
-
-
- this.a = 6;
-};
-
-RandomTest.prototype.d = function(){
- console.log(a);
-};
diff --git a/test/test-data/.DS_Store b/test/test-data/.DS_Store
deleted file mode 100644
index dff3c06..0000000
--- a/test/test-data/.DS_Store
+++ /dev/null
Binary files differ
diff --git a/test/test-data/ContentObject1.binary b/test/test-data/ContentObject1.binary
deleted file mode 100644
index 9377cf9..0000000
--- a/test/test-data/ContentObject1.binary
+++ /dev/null
@@ -1 +0,0 @@
-a03b2088587b7b14e1b1b04156203f92702759dda531d680816fe5708e842002ba967e14b7cfe8c19d2da1b550e18277947925deac3395d02a2d3f116b2314f1cc69aab4fab1afe71c56ad6e239b8f61ab00029bb09452895fc44b37955cf50775b349ef9883739c23aaf0b86892fcb4626df2f00e8c9edfcb83160fe9a014162a9fed5bc0000f2faad68656c6c6f000001a203e20285204874045a9fac98ebb7dfadc4bbd1ab15a6e4065349c6c83a8460844eab31850002bab504f32b9ca3a20001e201da0a9530819f300d06092a864886f70d010101050003818d0030818902818100bd9565559c1795c049a5ef4dc9d1bc8b981b66097ea253f5d0f50f1a1df908ac4e69a797dadd2c0590944a6e849e1fbb7371c53dfddbe7802656e1d5f449b8530d9c7da8d6abebd90e06124d927f2f6c5721f1d0e49e7f6a1167caf960d96ff5afaa2d2567337772a944c8e6ceb859b25a231d9eca873574ff98225c853f38ef0203010001000000019ae568656c6c6f20776f726c640a0000
\ No newline at end of file
diff --git a/test/test-data/ContentObject1.xml b/test/test-data/ContentObject1.xml
deleted file mode 100644
index 46e32b8..0000000
--- a/test/test-data/ContentObject1.xml
+++ /dev/null
@@ -1,7 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<ContentObject><Signature><SignatureBits ccnbencoding="base64Binary">h7exThsbBBViA/knAnWd2lMdaAgW/lcI6EIAK6ln4Ut8/owZ0tobVQ4YJ3lHkl3q
-wzldAqLT8RayMU8cxpqrT6sa/nHFatbiObj2GrAAKbsJRSiV/ESzeVXPUHdbNJ75
-iDc5wjqvC4aJL8tGJt8vAOjJ7fy4MWD+mgFBYqn+1bw=</SignatureBits></Signature><Name><Component ccnbencoding="text">hello</Component></Name><SignedInfo><PublisherPublicKeyDigest ccnbencoding="base64Binary">IEh0BFqfrJjrt9+txLvRqxWm5AZTScbIOoRghE6rMYU=</PublisherPublicKeyDigest><Timestamp ccnbencoding="base64Binary">BPMrnKOi</Timestamp><KeyLocator><Key ccnbencoding="base64Binary">MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC9lWVVnBeVwEml703J0byLmBtm
-CX6iU/XQ9Q8aHfkIrE5pp5fa3SwFkJRKboSeH7tzccU9/dvngCZW4dX0SbhTDZx9
-qNar69kOBhJNkn8vbFch8dDknn9qEWfK+WDZb/Wvqi0lZzN3cqlEyObOuFmyWiMd
-nsqHNXT/mCJchT847wIDAQAB</Key></KeyLocator></SignedInfo><Content ccnbencoding="base64Binary">aGVsbG8gd29ybGQK</Content></ContentObject>
diff --git a/test/test-data/ContentObject2.binary b/test/test-data/ContentObject2.binary
deleted file mode 100644
index 63865cb..0000000
--- a/test/test-data/ContentObject2.binary
+++ /dev/null
Binary files differ
diff --git a/test/test-data/ContentObject2.xml b/test/test-data/ContentObject2.xml
deleted file mode 100644
index a7b7476..0000000
--- a/test/test-data/ContentObject2.xml
+++ /dev/null
@@ -1,10 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<ContentObject><Signature><SignatureBits ccnbencoding="base64Binary">E1XOBbKmN0rqOvNFZA9+gPE491gMThGbmYGIkvkIQc+1WEIXX/li3Wnzj3s2oVlF
-txzj6j/+kNHWuV7SMhTX8mL31zGl+iyuXVjshQKBYBYk9VN1b0aFw2C8LE4OOjmR
-O8tt5fCFxJ8Hqx4/iwzpJYctQDNyOLDq68AJsIPQefg=</SignatureBits></Signature><Name><Component ccnbencoding="text">hello</Component><Component ccnbencoding="text">world</Component><Component ccnbencoding="text">ucla</Component><Component ccnbencoding="text">cs</Component></Name><SignedInfo><PublisherPublicKeyDigest ccnbencoding="base64Binary">IEh0BFqfrJjrt9+txLvRqxWm5AZTScbIOoRghE6rMYU=</PublisherPublicKeyDigest><Timestamp ccnbencoding="base64Binary">BPP0hkOL</Timestamp><KeyLocator><Key ccnbencoding="base64Binary">MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC9lWVVnBeVwEml703J0byLmBtm
-CX6iU/XQ9Q8aHfkIrE5pp5fa3SwFkJRKboSeH7tzccU9/dvngCZW4dX0SbhTDZx9
-qNar69kOBhJNkn8vbFch8dDknn9qEWfK+WDZb/Wvqi0lZzN3cqlEyObOuFmyWiMd
-nsqHNXT/mCJchT847wIDAQAB</Key></KeyLocator></SignedInfo><Content ccnbencoding="base64Binary">QUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFB
-QUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQkJC
-QkJCQkJCQkJCQkJCQkJCQkJCQkJCQkJCQkJCQkJCQkJCQkJCQkJCQkJCQkJCQkJC
-QkJCQkJCQkJCQkJCQkJCQkJCQkJCQkJCQkJCQkJDCg==</Content></ContentObject>
diff --git a/test/test-data/ContentObject3.binary b/test/test-data/ContentObject3.binary
deleted file mode 100644
index 6ea5d7c..0000000
--- a/test/test-data/ContentObject3.binary
+++ /dev/null
Binary files differ
diff --git a/test/test-data/ContentObject3.xml b/test/test-data/ContentObject3.xml
deleted file mode 100644
index 30c4bed..0000000
--- a/test/test-data/ContentObject3.xml
+++ /dev/null
@@ -1,7 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<ContentObject><Signature><SignatureBits ccnbencoding="base64Binary">HErd+7ZgsZTvR3f0pq066b1rk/GIVGJn+3CgLsjmUTAd2Zppd4TANGIM8xW5O8L2
-ToC0Jpr5HP3NkPG5jPyouinWlE8yLgmdMzpiyd9UtAoaIJtbNVknMDH/e25/PvF9
-y/OsM3r5I2IJAsnW5TIkPnTL1hUkTJxLKV8By0xZf18=</SignatureBits></Signature><Name><Component ccnbencoding="text">test3</Component><Component ccnbencoding="text">testing</Component><Component ccnbencoding="text">435b</Component></Name><SignedInfo><PublisherPublicKeyDigest ccnbencoding="base64Binary">IEh0BFqfrJjrt9+txLvRqxWm5AZTScbIOoRghE6rMYU=</PublisherPublicKeyDigest><Timestamp ccnbencoding="base64Binary">BPP0ntsw</Timestamp><KeyLocator><Key ccnbencoding="base64Binary">MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC9lWVVnBeVwEml703J0byLmBtm
-CX6iU/XQ9Q8aHfkIrE5pp5fa3SwFkJRKboSeH7tzccU9/dvngCZW4dX0SbhTDZx9
-qNar69kOBhJNkn8vbFch8dDknn9qEWfK+WDZb/Wvqi0lZzN3cqlEyObOuFmyWiMd
-nsqHNXT/mCJchT847wIDAQAB</Key></KeyLocator></SignedInfo><Content ccnbencoding="base64Binary">IAo=</Content></ContentObject>
diff --git a/test/test-data/ContentObject4.binary b/test/test-data/ContentObject4.binary
deleted file mode 100644
index 63865cb..0000000
--- a/test/test-data/ContentObject4.binary
+++ /dev/null
Binary files differ
diff --git a/test/test-data/ContentObject4.xml b/test/test-data/ContentObject4.xml
deleted file mode 100644
index a7b7476..0000000
--- a/test/test-data/ContentObject4.xml
+++ /dev/null
@@ -1,10 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<ContentObject><Signature><SignatureBits ccnbencoding="base64Binary">E1XOBbKmN0rqOvNFZA9+gPE491gMThGbmYGIkvkIQc+1WEIXX/li3Wnzj3s2oVlF
-txzj6j/+kNHWuV7SMhTX8mL31zGl+iyuXVjshQKBYBYk9VN1b0aFw2C8LE4OOjmR
-O8tt5fCFxJ8Hqx4/iwzpJYctQDNyOLDq68AJsIPQefg=</SignatureBits></Signature><Name><Component ccnbencoding="text">hello</Component><Component ccnbencoding="text">world</Component><Component ccnbencoding="text">ucla</Component><Component ccnbencoding="text">cs</Component></Name><SignedInfo><PublisherPublicKeyDigest ccnbencoding="base64Binary">IEh0BFqfrJjrt9+txLvRqxWm5AZTScbIOoRghE6rMYU=</PublisherPublicKeyDigest><Timestamp ccnbencoding="base64Binary">BPP0hkOL</Timestamp><KeyLocator><Key ccnbencoding="base64Binary">MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC9lWVVnBeVwEml703J0byLmBtm
-CX6iU/XQ9Q8aHfkIrE5pp5fa3SwFkJRKboSeH7tzccU9/dvngCZW4dX0SbhTDZx9
-qNar69kOBhJNkn8vbFch8dDknn9qEWfK+WDZb/Wvqi0lZzN3cqlEyObOuFmyWiMd
-nsqHNXT/mCJchT847wIDAQAB</Key></KeyLocator></SignedInfo><Content ccnbencoding="base64Binary">QUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFB
-QUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQkJC
-QkJCQkJCQkJCQkJCQkJCQkJCQkJCQkJCQkJCQkJCQkJCQkJCQkJCQkJCQkJCQkJC
-QkJCQkJCQkJCQkJCQkJCQkJCQkJCQkJCQkJCQkJDCg==</Content></ContentObject>
diff --git a/test/test-data/ContentObject5.binary b/test/test-data/ContentObject5.binary
deleted file mode 100644
index 0ed03a6..0000000
--- a/test/test-data/ContentObject5.binary
+++ /dev/null
Binary files differ
diff --git a/test/test-data/ContentObject5.xml b/test/test-data/ContentObject5.xml
deleted file mode 100644
index e408d40..0000000
--- a/test/test-data/ContentObject5.xml
+++ /dev/null
@@ -1,7 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<ContentObject><Signature><SignatureBits ccnbencoding="base64Binary">SLkD3PxyF38CYiAZHBMWggs357uW2JPkrLfgaKzqnn/lvBsHRq4GntKH3TveSh2O
-xModFj/MF/rmnKdvwEojg6Y0G3BIvJ01eNf97phe/gu1WPKzTkHyIfgS5krJIz4w
-N4JfbhHIO97+FExSCTdRF7276EKvoEuzjcIVZrTJTNU=</SignatureBits></Signature><Name><Component ccnbencoding="text">uri1</Component></Name><SignedInfo><PublisherPublicKeyDigest ccnbencoding="base64Binary">IEh0BFqfrJjrt9+txLvRqxWm5AZTScbIOoRghE6rMYU=</PublisherPublicKeyDigest><Timestamp ccnbencoding="base64Binary">BPP0ygle</Timestamp><KeyLocator><Key ccnbencoding="base64Binary">MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC9lWVVnBeVwEml703J0byLmBtm
-CX6iU/XQ9Q8aHfkIrE5pp5fa3SwFkJRKboSeH7tzccU9/dvngCZW4dX0SbhTDZx9
-qNar69kOBhJNkn8vbFch8dDknn9qEWfK+WDZb/Wvqi0lZzN3cqlEyObOuFmyWiMd
-nsqHNXT/mCJchT847wIDAQAB</Key></KeyLocator></SignedInfo><Content ccnbencoding="base64Binary">TWVzc2FnZQo=</Content></ContentObject>
diff --git a/test/test-data/ContentObject6.binary b/test/test-data/ContentObject6.binary
deleted file mode 100644
index c89edfb..0000000
--- a/test/test-data/ContentObject6.binary
+++ /dev/null
Binary files differ
diff --git a/test/test-data/ContentObject6.xml b/test/test-data/ContentObject6.xml
deleted file mode 100644
index 897869b..0000000
--- a/test/test-data/ContentObject6.xml
+++ /dev/null
@@ -1,7 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<ContentObject><Signature><SignatureBits ccnbencoding="base64Binary">T9vjIhsEnnw4OAX2QHe0Zx9TEHLELm51YLxPDXxQy2EMET89KuXT7fEK6r3Ignu7
-z4lgtWw39ds0NhAjZW1s2aVNntZooLiN+VzLsIlPgVCSlbASqqmCSXQO45SvuKvm
-mog24sW3heJLAg15Y1XLuPLouZJvetu5xpsG9N9TUCg=</SignatureBits></Signature><Name><Component ccnbencoding="text">uri2</Component></Name><SignedInfo><PublisherPublicKeyDigest ccnbencoding="base64Binary">IEh0BFqfrJjrt9+txLvRqxWm5AZTScbIOoRghE6rMYU=</PublisherPublicKeyDigest><Timestamp ccnbencoding="base64Binary">BPP0z9ZL</Timestamp><KeyLocator><Key ccnbencoding="base64Binary">MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC9lWVVnBeVwEml703J0byLmBtm
-CX6iU/XQ9Q8aHfkIrE5pp5fa3SwFkJRKboSeH7tzccU9/dvngCZW4dX0SbhTDZx9
-qNar69kOBhJNkn8vbFch8dDknn9qEWfK+WDZb/Wvqi0lZzN3cqlEyObOuFmyWiMd
-nsqHNXT/mCJchT847wIDAQAB</Key></KeyLocator></SignedInfo><Content ccnbencoding="base64Binary">TWVzc2FnZQo=</Content></ContentObject>
diff --git a/test/test-data/ContentObject7.binary b/test/test-data/ContentObject7.binary
deleted file mode 100644
index e69de29..0000000
--- a/test/test-data/ContentObject7.binary
+++ /dev/null
diff --git a/test/test-data/ContentObject7.xml b/test/test-data/ContentObject7.xml
deleted file mode 100644
index 12bbf74..0000000
--- a/test/test-data/ContentObject7.xml
+++ /dev/null
@@ -1 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
diff --git a/test/test-data/InterestMessage1.binary b/test/test-data/InterestMessage1.binary
deleted file mode 100644
index 7482bab..0000000
--- a/test/test-data/InterestMessage1.binary
+++ /dev/null
Binary files differ
diff --git a/test/test-data/InterestMessage1.xml b/test/test-data/InterestMessage1.xml
deleted file mode 100644
index 2708f0e..0000000
--- a/test/test-data/InterestMessage1.xml
+++ /dev/null
@@ -1,6 +0,0 @@
-<?xml version='1.0' encoding='UTF-8' standalone='yes' ?>
-<Interest xmlns:ccn="http://www.parc.com/ccn">
- <Name>
- <Component>dGVzdDE=</Component>
- </Name>
-</Interest>
\ No newline at end of file
diff --git a/test/test-data/InterestMessage2.binary b/test/test-data/InterestMessage2.binary
deleted file mode 100644
index 51b98ea..0000000
--- a/test/test-data/InterestMessage2.binary
+++ /dev/null
Binary files differ
diff --git a/test/test-data/InterestMessage2.xml b/test/test-data/InterestMessage2.xml
deleted file mode 100644
index 1d1dff5..0000000
--- a/test/test-data/InterestMessage2.xml
+++ /dev/null
@@ -1,8 +0,0 @@
-<?xml version='1.0' encoding='UTF-8' standalone='yes' ?>
-<Interest xmlns:ccn="http://www.parc.com/ccn">
- <Name>
- <Component>dGVzdDI=</Component>
- </Name>
- <MinSuffixComponents>1</MinSuffixComponents>
- <MaxSuffixComponents>3</MaxSuffixComponents>
-</Interest>
diff --git a/test/test-data/InterestMessage3.binary b/test/test-data/InterestMessage3.binary
deleted file mode 100644
index e336ca1..0000000
--- a/test/test-data/InterestMessage3.binary
+++ /dev/null
Binary files differ
diff --git a/test/test-data/InterestMessage3.xml b/test/test-data/InterestMessage3.xml
deleted file mode 100644
index 5592218..0000000
--- a/test/test-data/InterestMessage3.xml
+++ /dev/null
@@ -1,8 +0,0 @@
-<?xml version='1.0' encoding='UTF-8' standalone='yes' ?>
-<Interest xmlns:ccn="http://www.parc.com/ccn">
- <Name>
- <Component>dGVzdDM=</Component>
- <Component>dGVzdDMtbGF5ZXIy</Component>
- <Component>MTIzNDU2IUA=</Component>
- </Name>
-</Interest>