| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119 |
- "use strict";
- var LeafMatchExpression = require('./LeafMatchExpression');
- // Autogenerated by cport.py on 2013-09-17 14:37
- var RegexMatchExpression = module.exports = function RegexMatchExpression(){
- base.call(this);
- this._matchType = 'REGEX';
- }, klass = RegexMatchExpression, base = LeafMatchExpression, proto = klass.prototype = Object.create(base.prototype, {constructor:{value:klass}});
- // File: expression_leaf.h lines: 160-160
- klass.MaxPatternSize = 32764;
- // File: expression_leaf.h lines: 184-184
- proto._flags = undefined;
- // File: expression_leaf.h lines: 185-185
- proto._re = undefined;
- // File: expression_leaf.h lines: 183-183
- proto._regex = undefined;
- /**
- *
- * Writes a debug string for this object
- * @method debugString
- * @param level
- *
- */
- proto.debugString = function debugString(level) {
- // File: expression_leaf.cpp lines: 225-234
- return this._debugAddSpace( level ) + this.path() + " regex /" + this._regex + "/" + this._flags + (this.getTag() ? ' ' + this.getTag().debugString : '') + "\n";
- };
- /**
- *
- * checks if this expression is == to the other
- * @method equivalent
- * @param other
- *
- */
- proto.equivalent = function equivalent(other) {
- // File: expression_leaf.cpp lines: 177-185
- return other._matchType == 'REGEX' && this.path() == other.path() && this._regex == other._regex && this._flags == other._flags;
- };
- /**
- *
- * Return the _flags property
- * @method getFlags
- *
- */
- proto.getFlags = function getFlags(){
- // File: expression_leaf.h lines: 180-179
- return this._flags;
- };
- /**
- *
- * Return the _regex property
- * @method getString
- * @param
- *
- */
- proto.getString = function getString(){
- // File: expression_leaf.h lines: 179-178
- return this._regex;
- };
- /**
- *
- * Initialize the necessary items
- * @method init
- * @param path
- * @param type
- *
- */
- proto.init = function init(path,regex,flags) {
- // File: expression_leaf.cpp lines: 196-205
- if(regex.toString().length > klass.MaxPatternSize){
- return {'code':'BAD_VALUE', 'desc':'Regular Expression too long.'};
- }
- this._regex = regex;
- this._flags = flags;
- this._re = new RegExp(regex,flags);
- return this.initPath( path );
- };
- /**
- *
- * Check if the input element matches
- * @method matchesSingleElement
- * @param e
- *
- */
- proto.matchesSingleElement = function matchesSingleElement(e) {
- // File: expression_leaf.cpp lines: 208-222
- if(e instanceof RegExp){
- return e.toString() === this._re.toString();
- }
- return e && (e.match) && e.match(this._re);
- // No support for SYMBOLS currently
- };
- /**
- *
- * clone this instance to a new one
- * @method shallowClone
- *
- */
- proto.shallowClone = function shallowClone(){
- // File: expression_leaf.h lines: 167-170
- var e = new RegexMatchExpression();
- e.init( this.path(), this._regex, this._flags );
- return e;
- };
|