blob: 1ee9112a8c3804db2f5b328d4ba1b92d070875ff [file] [log] [blame]
Meki Cherkaouif441d3a2012-04-22 15:17:52 -07001/*
2 * @author: ucla-cs
3 * This class represents Exclude objects
4 */
5
Jeff Thompsone85ff1d2012-09-29 21:21:57 -07006var Exclude = function Exclude(_values){
Meki Cherkaouif441d3a2012-04-22 15:17:52 -07007
8 this.OPTIMUM_FILTER_SIZE = 100;
9
10
Jeff Thompsone85ff1d2012-09-29 21:21:57 -070011 this.values = _values; //array of elements
Meki Cherkaouif441d3a2012-04-22 15:17:52 -070012
13}
14
Jeff Thompsone85ff1d2012-09-29 21:21:57 -070015Exclude.prototype.from_ccnb = function(/*XMLDecoder*/ decoder) {
Meki Cherkaouif441d3a2012-04-22 15:17:52 -070016
17
18
19 decoder.readStartElement(this.getElementLabel());
20
21 //TODO APPLY FILTERS/EXCLUDE
22
23 //TODO
24 /*var component;
25 var any = false;
26 while ((component = decoder.peekStartElement(CCNProtocolDTags.Component)) ||
27 (any = decoder.peekStartElement(CCNProtocolDTags.Any)) ||
28 decoder.peekStartElement(CCNProtocolDTags.Bloom)) {
29 var ee = component?new ExcludeComponent(): any ? new ExcludeAny() : new BloomFilter();
30 ee.decode(decoder);
31 _values.add(ee);
32 }*/
33
34 decoder.readEndElement();
35
36};
37
Jeff Thompsone85ff1d2012-09-29 21:21:57 -070038Exclude.prototype.to_ccnb=function(/*XMLEncoder*/ encoder) {
Meki Cherkaouif441d3a2012-04-22 15:17:52 -070039 if (!validate()) {
40 throw new ContentEncodingException("Cannot encode " + this.getClass().getName() + ": field values missing.");
41 }
42
43 if (empty())
44 return;
45
46 encoder.writeStartElement(getElementLabel());
47
48 encoder.writeEndElement();
49
50 };
51
52Exclude.prototype.getElementLabel = function() { return CCNProtocolDTags.Exclude; };
53