/* $Id: ParserCustom.js,v 1.1 2004/08/24 15:08:07 jane Exp $ */

function CustomParser(d, value, e)
{
	if ((typeof(d) != 'object') || (d.constructor != ElementDescriptor))
	{
		throw ('CustomParser:\n' + DefMsgErrInvalidDescriptor);
	}
	if (d.dataType != valueTypes.dtCustom)
	{
		throw ('CustomParser:\n' + DefMsgErrDataTypeUnsupported + '\n' + d.dataType);
	}

	this.descriptor = d;
	this.value = value;
	this.element = e;

	this.dataType = d.dataType;
	
	this.precision = new ParserStyle(d.extStyle).items(extStyles.precision);
	this.scale = new ParserStyle(d.extStyle).items(extStyles.scale);

	this.onValidate = d.onValidate;
	this.beforeValidate = d.beforeValidate;
	this.afterValidate = d.afterValidate;
	
	this.getRegExp = getCustomRegExp;
	this.doCheck = doCheckCustom;
}

function getCustomRegExp()
{
	return new RegExp('(\\s|\\S)*');
}

function doCheckCustom()
{
	var result = parserResults.Incorrect;
	if (this.beforeValidate) eval(this.beforeValidate);
	if (checkExp(this.value, this.getRegExp())) result = parserResults.Correct;
	if ((result == parserResults.Correct) && (this.onValidate)) eval(this.onValidate);
	if (this.afterValidate) eval(this.afterValidate);
	return result;
}

vSupportedDT[vSupportedDT.length] = valueTypes.dtCustom;
