First Commit after cleanup
Socket Bridge in java now works with UDP
Now connecting to remote ccnd nodes ( unless there is a firewall on the
way) currently connecting to borges on port 9695
Cleaned up the code and added authors to all files since new people are
joining the project.
Separated java from javascript code.
diff --git a/js/encoding/TextXMLEncoder.js b/js/encoding/TextXMLEncoder.js
new file mode 100644
index 0000000..495984b
--- /dev/null
+++ b/js/encoding/TextXMLEncoder.js
@@ -0,0 +1,109 @@
+//TODO INCOMPLETE
+/*
+ * @author: ucla-cs
+ *
+ * Encodes CCN object into xml
+ */
+
+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.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.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;
+ }
+ }
+ }
+
+
+ if (XMLDictionaryStack.isUnknownTag(tagName)) {
+ return XMLDictionaryStack.decodeUnknownTag(tagName);
+ }
+ return null;
+};
+