net/sf/jsm/table/filters/jsmRegExFilter.js
Summary
No overview generated for 'net/sf/jsm/table/filters/jsmRegExFilter.js'
Class Summary
|
JsmRegExFilter |
A filter implementation checking if the cell value matches the regular expression
|
function JsmRegExFilter(columnIdxOrName, value, ignoreCase) {
this.columnIdxOrName = columnIdxOrName;
this.value = value;
this.ignoreCase = ignoreCase;
}
JsmRegExFilter.prototype.className="JsmRegExFilter";
JsmRegExFilter.prototype.isValidRow = function(tr) {
var cellValue = tr.getCell(this.columnIdxOrName).getValue().replace(/'/g, "\\'"); // escape any '
//if it is a string put in into an array
if (typeof this.value == 'string') {
var tempValue = new Array();
tempValue.push(this.value);
this.value = tempValue;
}
for (i=0;i<this.value.length;i++) {
var value = this.value[i].replace(/\//g, "\\/"); //escape any /
if (this.ignoreCase) {
regEx = "'" + cellValue + "'.search(/" + value + "/i)";
} else {
regEx = "'" + cellValue + "'.search(/" + value + "/)";
}
if (eval(regEx) != -1) {return true;}
}
return false;
}
JsmRegExFilter.prototype.setColumn = function(columnIdxOrName) {
this.columnIdxOrName = columnIdxOrName;
return this;
}
JsmRegExFilter.prototype.setValue = function(value) {
this.value = value;
return this;
}
JsmRegExFilter.prototype.setIgnoreCase = function(ignoreCase) {
this.ignoreCase = ignoreCase;
return this;
}
JsmRegExFilter.prototype.clone = function() {
var clonedObject = new JsmRegExFilter();
clonedObject._attributes = this._attributes;
clonedObject._metaData = this._metaData;
clonedObject.value = this.value;
clonedObject.ignoreCase = this.ignoreCase;
clonedObject.columnIdxOrName = this.columnIdxOrName;
return clonedObject;
}
Documentation generated by
JSDoc on Tue Sep 26 08:42:57 2006