blob: 667c8cfb5f867bee62688b2346d68e54e3aad172 [file] [log] [blame]
Meki Cherkaouib0365a72012-02-18 00:59:57 -08001
2var CCNProtocolDTags = require('./CCNProtocolDTags').CCNProtocolDTags;
3
4var Exclude = function Exclude(_Values){
5
6 this.OPTIMUM_FILTER_SIZE = 100;
7
8
9 this.Values = _Values; //array of elements
10
11}
12exports.Exclude = Exclude;
13
14Exclude.prototype.decode = function(/*XMLDecoder*/ decoder) {
15
16
17
18 decoder.readStartElement(this.getElementLabel());
19
20 //TODO BUGS
21 /*var component;
22 var any = false;
23 while ((component = decoder.peekStartElement(CCNProtocolDTags.Component)) ||
24 (any = decoder.peekStartElement(CCNProtocolDTags.Any)) ||
25 decoder.peekStartElement(CCNProtocolDTags.Bloom)) {
26 var ee = component?new ExcludeComponent(): any ? new ExcludeAny() : new BloomFilter();
27 ee.decode(decoder);
28 _values.add(ee);
29 }*/
30
31 decoder.readEndElement();
32
33};
34
35Exclude.prototype.encode=function(/*XMLEncoder*/ encoder) {
36 if (!validate()) {
37 throw new ContentEncodingException("Cannot encode " + this.getClass().getName() + ": field values missing.");
38 }
39 // if everything is null, output nothing
40 if (empty())
41 return;
42
43 encoder.writeStartElement(getElementLabel());
44
45 /*
46 for (Element element : _values)
47 element.encode(encoder);
48 */
49
50 encoder.writeEndElement();
51 };
52
53Exclude.prototype.getElementLabel = function() { return CCNProtocolDTags.Exclude; };
54