Meki Cherkaoui | b0365a7 | 2012-02-18 00:59:57 -0800 | [diff] [blame] | 1 | |
| 2 | var CCNProtocolDTags = require('./CCNProtocolDTags').CCNProtocolDTags; |
| 3 | |
| 4 | var Exclude = function Exclude(_Values){ |
| 5 | |
| 6 | this.OPTIMUM_FILTER_SIZE = 100; |
| 7 | |
| 8 | |
| 9 | this.Values = _Values; //array of elements |
| 10 | |
| 11 | } |
| 12 | exports.Exclude = Exclude; |
| 13 | |
| 14 | Exclude.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 | |
| 35 | Exclude.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 | |
| 53 | Exclude.prototype.getElementLabel = function() { return CCNProtocolDTags.Exclude; }; |
| 54 | |