NorMatchExpression.js 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. "use strict";
  2. var ListOfMatchExpression = require("./ListOfMatchExpression");
  3. var NorMatchExpression = module.exports = function NorMatchExpression(){
  4. base.call(this);
  5. this._matchType = "NOR";
  6. }, klass = NorMatchExpression, base = ListOfMatchExpression, proto = klass.prototype = Object.create(base.prototype, {constructor:{value:klass}}); //jshint ignore:line
  7. /**
  8. *
  9. * Writes a debug string for this object
  10. * @method debugString
  11. * @param level
  12. *
  13. */
  14. proto.debugString = function debugString(level) {
  15. return this._debugAddSpace(level) +
  16. "$nor\n" +
  17. this._debugList(level);
  18. };
  19. /**
  20. *
  21. * matches checks the input doc against the internal element path to see if it is a match
  22. * @method matches
  23. * @param doc
  24. * @param details
  25. *
  26. */
  27. proto.matches = function matches(doc,detail) {
  28. for (var i = 0; i < this.numChildren(); i++) {
  29. if( this.getChild(i).matches( doc, null )) {
  30. return false;
  31. }
  32. }
  33. return true;
  34. };
  35. /**
  36. *
  37. * Check if the input element matches
  38. * @method matchesSingleElement
  39. * @param e
  40. *
  41. */
  42. proto.matchesSingleElement = function matchesSingleElement(e) {
  43. for (var i = 0; i < this.numChildren(); i++) {
  44. if( this.getChild(i).matchesSingleElement( e )) {
  45. return false;
  46. }
  47. }
  48. return true;
  49. };
  50. /**
  51. *
  52. * clone this instance to a new one
  53. * @method shallowClone
  54. *
  55. */
  56. proto.shallowClone = function shallowClone(){
  57. // virtual MatchExpression* shallowClone() const {
  58. // NorMatchExpression* self = new NorMatchExpression();
  59. // for (size_t i = 0; i < numChildren(); ++i) {
  60. // self->add(getChild(i)->shallowClone());
  61. // }
  62. // return self;
  63. // }
  64. var e = new NorMatchExpression();
  65. for (var i = 0; i < this.numChildren(); i++) {
  66. e.add(this.getChild(i).shallowClone());
  67. }
  68. if (this.getTag()) {
  69. e.setTag(this.getTag().clone());
  70. }
  71. return e;
  72. };