Major update: refactored the API of Interest and ContentObject according to the API notes:
http://sea.remap.ucla.edu:8080/attachments/download/23/lwndn_api-notes_21020830.txt
diff --git a/js/testing/test-decode-FaceInstance.html b/js/testing/test-decode-FaceInstance.html
index 7d168cc..7818e55 100644
--- a/js/testing/test-decode-FaceInstance.html
+++ b/js/testing/test-decode-FaceInstance.html
@@ -134,7 +134,7 @@
output+= "<br />";
}
- /*if(interest.Name!=null && interest.Name.Components!=null){
+ /*if(interest.name!=null && interest.name.Components!=null){
output+= "NAME: ";
for(var i=0;i<interest.Name.Components.length;i++){
diff --git a/js/testing/test-decode-Interest+Forwarding+Entry.html b/js/testing/test-decode-Interest+Forwarding+Entry.html
index adb7058..0ece80f 100644
--- a/js/testing/test-decode-Interest+Forwarding+Entry.html
+++ b/js/testing/test-decode-Interest+Forwarding+Entry.html
@@ -77,7 +77,6 @@
function decode(){
-
var input = document.getElementById('result').innerHTML;
@@ -92,136 +91,125 @@
var output ="";
- if(interest.Name!=null && interest.Name.Components!=null){
+ if(interest.name!=null && interest.name.Components!=null){
output+= "NAME: ";
- for(var i=0;i<interest.Name.Components.length;i++){
- output+= "/"+ DataUtils.toString(interest.Name.Components[i]);
+ for(var i=0;i<interest.name.Components.length;i++){
+ output+= "/"+ DataUtils.toString(interest.name.Components[i]);
}
output+= "<br />";
output+= "<br />";
}
- if(interest.FaceInstance!=null ){
+ if(interest.faceInstance!=null ){
output+= "FaceInstance: ";
- output+= interest.FaceInstance;
+ output+= interest.faceInstance;
output+= "<br />";
output+= "<br />";
}
- if(interest.Exclude!=null ){
+ if(interest.exclude!=null ){
output+= "Exclude: ";
- output+= interest.Exclude;
+ output+= interest.exclude;
output+= "<br />";
output+= "<br />";
}
- if(interest.ChildSelector!=null ){
+ if(interest.childSelector!=null ){
output+= "ChildSelector: ";
- output+= interest.ChildSelector;
+ output+= interest.childSelector;
output+= "<br />";
output+= "<br />";
}
- if(interest.AnswerOriginKind!=null ){
+ if(interest.answerOriginKind!=null ){
output+= "AnswerOriginKind: ";
- output+= interest.AnswerOriginKind;
+ output+= interest.answerOriginKind;
output+= "<br />";
output+= "<br />";
}
- if(interest.InterestLifetime!=null ){
+ if(interest.interestLifetime!=null ){
output+= "InterestLifetime: ";
- output+= interest.InterestLifetime;
+ output+= interest.interestLifetime;
output+= "<br />";
output+= "<br />";
}
- if(interest.Nonce!=null ){
+ if(interest.nonce!=null ){
output+= "Nonce: ";
- output+= interest.Nonce;
+ output+= interest.nonce;
output+= "<br />";
output+= "<br />";
}
- if(interest.Scope!=null ){
+ if(interest.scope!=null ){
output+= "SCOPE: ";
- output+= interest.Scope;
+ output+= interest.scope;
output+= "<br />";
output+= "<br />";
}
- if(interest.PublisherID!=null ){
- output+= "PUBLISHER ID: ";
+ if(interest.publisherPublicKeyDigest!=null ){
+ output+= "PUBLISHER PUBLIC KEY DIGEST: ";
- output+= interest.PublisherID.PublisherID;
-
- output+= "PUBLISHER ID TYPE: ";
- output+= interest.PublisherID.PublisherType;
+ output+= interest.publisherPublicKeyDigest.PublisherPublicKeyDigest;
+
output+= "<br />";
output+= "<br />";
}
- if(interest.MaxSuffixComponents!=null ){
+ if(interest.maxSuffixComponents!=null ){
output+= "MaxSuffixComponents : ";
- output+= interest.MaxSuffixComponents;
+ output+= interest.maxSuffixComponents;
output+= "<br />";
output+= "<br />";
}
- if(interest.MinSuffixComponents!=null ){
+ if(interest.minSuffixComponents!=null ){
output+= "MinSuffixComponents : ";
- output+= interest.MinSuffixComponents;
+ output+= interest.minSuffixComponents;
output+= "<br />";
output+= "<br />";
}
- if(interest.MinSuffixComponents!=null ){
- output+= "MinSuffixComponents : ";
-
- output+= interest.MinSuffixComponents;
-
- output+= "<br />";
- output+= "<br />";
- }
-
- if(interest.Name.Components[3] !=null){
+ if(interest.name.Components[3] !=null){
- var input = DataUtils.toHex(interest.Name.Components[3]) ;
+ var input = DataUtils.toHex(interest.name.Components[3]) ;
var contentObject = decodeHexContentObject(input);
- if(contentObject.Content!=null ){
+ if(contentObject.content!=null ){
output+= "Content of content Object: ";
- output+= DataUtils.toHex(contentObject.Content);
+ output+= DataUtils.toHex(contentObject.content);
output+= "<br />";
output+= "<br />";
}
- var content = DataUtils.toHex(contentObject.Content);
+ var content = DataUtils.toHex(contentObject.content);
var co = contentObject;
@@ -229,24 +217,24 @@
////////////////////////////////////////
- if(co.Name!=null && co.Name.Components!=null){
+ if(co.name!=null && co.name.Components!=null){
output+= "NAME: ";
- for(var i=0;i<co.Name.Components.length;i++){
- output+= "/"+ DataUtils.toString(co.Name.Components[i]);
+ for(var i=0;i<co.name.Components.length;i++){
+ output+= "/"+ DataUtils.toString(co.name.Components[i]);
}
output+= "<br />";
output+= "<br />";
}
- if(co.Content !=null){
- output += "CONTENT(ASCII): "+ DataUtils.toString(co.Content);
+ if(co.content !=null){
+ output += "CONTENT(ASCII): "+ DataUtils.toString(co.content);
output+= "<br />";
output+= "<br />";
}
- if(co.Content !=null){
- output += "CONTENT(hex): "+ DataUtils.toHex(co.Content);
+ if(co.content !=null){
+ output += "CONTENT(hex): "+ DataUtils.toHex(co.content);
output+= "<br />";
output+= "<br />";
@@ -472,7 +460,7 @@
<body >
<form>
- Please Press decode:<br />
+ Please Press Decode:<br />
</form>
diff --git a/js/testing/test-encode-decode-ContentObject-bis.html b/js/testing/test-encode-decode-ContentObject-bis.html
index 7956af3..f66cae5 100644
--- a/js/testing/test-encode-decode-ContentObject-bis.html
+++ b/js/testing/test-encode-decode-ContentObject-bis.html
@@ -116,24 +116,24 @@
else if (co==-2)
output+= "CONTENT NAME IS EMPTY"
else{
- if(co.Name!=null && co.Name.Components!=null){
+ if(co.name!=null && co.name.Components!=null){
output+= "NAME: ";
- for(var i=0;i<co.Name.Components.length;i++){
- output+= "/"+ toString(co.Name.Components[i]);
+ for(var i=0;i<co.name.Components.length;i++){
+ output+= "/"+ toString(co.name.Components[i]);
}
output+= "<br />";
output+= "<br />";
}
- if(co.Content !=null){
- output += "CONTENT(ASCII): "+ toString(co.Content);
+ if(co.content !=null){
+ output += "CONTENT(ASCII): "+ toString(co.content);
output+= "<br />";
output+= "<br />";
}
- if(co.Content !=null){
- output += "CONTENT(hex): "+ toHex(co.Content);
+ if(co.content !=null){
+ output += "CONTENT(hex): "+ toHex(co.content);
output+= "<br />";
output+= "<br />";
diff --git a/js/testing/test-encode-decode-Interest.html b/js/testing/test-encode-decode-Interest.html
index 04cbae2..dd3e3b4 100644
--- a/js/testing/test-encode-decode-Interest.html
+++ b/js/testing/test-encode-decode-Interest.html
@@ -76,7 +76,7 @@
function encode(){
var interest = new Interest( new ContentName(document.getElementById('interest').value ) );
- interest.Scope = 1;
+ interest.scope = 1;
var output = encodeToHexInterest(interest);
@@ -100,14 +100,14 @@
var output ="";
- if(interest.Name!=null && interest.Name.Components!=null){
+ if(interest.name!=null && interest.name.Components!=null){
output+= "NAME: ";
- output+= interest.Name.getName();
+ output+= interest.name.getName();
- /*for(var i=0;i<interest.Name.Components.length;i++){
- output+= "/"+ DataUtils.toString(interest.Name.Components[i]);
+ /*for(var i=0;i<interest.name.Components.length;i++){
+ output+= "/"+ DataUtils.toString(interest.name.Components[i]);
}*/
output+= "<br />";
@@ -115,48 +115,39 @@
}
- if(interest.Scope!=null ){
+ if(interest.scope!=null ){
output+= "SCOPE: ";
- output+= interest.Scope;
+ output+= interest.scope;
output+= "<br />";
output+= "<br />";
}
- if(interest.PublisherID!=null ){
+ if(interest.publisherID!=null ){
output+= "PUBLISHER ID: ";
- output+= interest.PublisherID.PublisherID;
+ output+= interest.publisherID.PublisherID;
output+= "PUBLISHER ID TYPE: ";
- output+= interest.PublisherID.PublisherType;
+ output+= interest.publisherID.PublisherType;
output+= "<br />";
output+= "<br />";
}
- if(interest.MaxSuffixComponents!=null ){
+ if(interest.maxSuffixComponents!=null ){
output+= "MaxSuffixComponents : ";
- output+= interest.MaxSuffixComponents;
+ output+= interest.maxSuffixComponents;
output+= "<br />";
output+= "<br />";
}
- if(interest.MinSuffixComponents!=null ){
+ if(interest.minSuffixComponents!=null ){
output+= "MinSuffixComponents : ";
- output+= interest.MinSuffixComponents;
-
- output+= "<br />";
- output+= "<br />";
- }
-
- if(interest.MinSuffixComponents!=null ){
- output+= "MinSuffixComponents : ";
-
- output+= interest.MinSuffixComponents;
+ output+= interest.minSuffixComponents;
output+= "<br />";
output+= "<br />";
diff --git a/js/testing/test-get.html b/js/testing/test-get.html
index ad4886c..8053655 100644
--- a/js/testing/test-get.html
+++ b/js/testing/test-get.html
@@ -75,7 +75,7 @@
function getAction(){
var interest = new Interest( new ContentName(document.getElementById('interest').value));
- interest.Scope = 1;
+ interest.scope = 1;
var received = get('127.0.0.1', 9695, encodeToHexInterest(interest));
diff --git a/js/testing/test-interest-matches-name.html b/js/testing/test-interest-matches-name.html
new file mode 100644
index 0000000..111789f
--- /dev/null
+++ b/js/testing/test-interest-matches-name.html
@@ -0,0 +1,104 @@
+<?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 Interest Matches Name</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="../PublisherPublicKeyDigest.js"></script>
+
+ <script type="text/javascript" src="../FaceInstance.js"></script>
+
+ <script type="text/javascript" src="../ForwardingEntry.js"></script>
+
+ <script type="text/javascript" src="../encoding/BinaryXMLEncoder.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" src="../encoding/EncodingUtils.js"></script>
+
+ <script language="JavaScript" type="text/javascript" src="../security/KeyManager.js"></script>
+
+ <script language="JavaScript" type="text/javascript" src="../securityLib/jsbn.js"></script>
+ <script language="JavaScript" type="text/javascript" src="../securityLib/jsbn2.js"></script>
+ <script language="JavaScript" type="text/javascript" src="../securityLib/rsa.js"></script>
+ <script language="JavaScript" type="text/javascript" src="../securityLib/rsa2.js"></script>
+
+ <script language="JavaScript" type="text/javascript" src="../securityLib/sha1.js"></script>
+ <script language="JavaScript" type="text/javascript" src="../securityLib/sha256.js"></script>
+ <script language="JavaScript" type="text/javascript" src="../securityLib/sha512.js"></script>
+ <script language="JavaScript" type="text/javascript" src="../securityLib/md5.js"></script>
+ <script language="JavaScript" type="text/javascript" src="../securityLib/ripemd160.js"></script>
+ <script language="JavaScript" type="text/javascript" src="../securityLib/base64.js"></script>
+
+ <script language="JavaScript" type="text/javascript" src="../securityLib/rsapem-1.1.js"></script>
+ <script language="JavaScript" type="text/javascript" src="../securityLib/rsasign-1.2.js"></script>
+ <script language="JavaScript" type="text/javascript" src="../securityLib/asn1hex-1.1.js"></script>
+ <script language="JavaScript" type="text/javascript" src="../securityLib/x509-1.1.js"></script>
+
+ <script type="text/javascript">
+
+ function check(){
+ var interest = new Interest( new ContentName(document.getElementById('interest').value));
+ interest.scope = 1;
+
+ var nameToCheck = new ContentName(document.getElementById('nameToCheck').value);
+
+ var output = (interest.matches_name(nameToCheck) ? "matches" : "doesn't match");
+ document.getElementById('result').innerHTML = output;
+ }
+
+ </script>
+
+</head>
+<body >
+ <form>
+
+ Please enter the name of an interest:<br />
+ <input id="interest" type="text" name="INTEREST" value="/ndn/ucla.edu" /> <br/>
+
+ Please enter a name to check if the interest matches the name:<br />
+ <input id="nameToCheck" type="text" name="NAME_TO_CHECK" value="/ndn/ucla.edu" /> <br/>
+
+ </form>
+ <button onclick="check()">Check</button>
+
+ <p id="result"></p>
+
+</body>
+</html>
diff --git a/js/testing/test-request-send-hex.html b/js/testing/test-request-send-hex.html
index f1acb20..3ed1a90 100644
--- a/js/testing/test-request-send-hex.html
+++ b/js/testing/test-request-send-hex.html
@@ -130,7 +130,7 @@
co = new ContentObject();
- co.decode(decoder);
+ co.from_ccnb(decoder);
if(LOG>2) console.log(co);