text:
/**
 * All Definitions of fields.. In our client MVC design, field represents a
 * control whose value changes at run time. Represents a control that
 * receives/sends data at run time. Concrete classes are defined with methods.
 * Stored in P2.fields collection Refer to corresponding classes in Java under
 * fields folder.
 */
var AbstractField = function() {
	this.value = '';
	/**
	 * index into the array that the table holds, in case this field is part of
	 * a table. -1 implies that this field is not in a table.
	 */
	this.columnIdx = -1;

	this.defaultValue = '';
	this.isEditable = true;
};

/**
 * we use a simple technique to put separators for amounts in Indian, US and
 * European styles
 */
AbstractField.inrPrefixes = [ '', '', '', ',', '', ',', '', ',', '', ',', '',
		',', '', ',', '', ',', '', ',', '', '', '' ];
AbstractField.usdPrefixes = [ '', '', '', ',', '', '', ',', '', '', ',', '',
		'', ',', '', '', ',', '', '', ',', '', '', '', ',', '' ];
/**
 * format the value for output. formatters are added in formatter.js. refer that
 * field for details.
 */
var a = AbstractField.prototype;
a.format = function(val) {
	if (!this.formatter || this.formatter == 'none')
		return val;

	var f = window.fieldFormatters && window.fieldFormatters[this.formatter];
	if (f)
		return f(val);

	debug('Design error: either formatter.js is not included in index page. or '
			+ this.formatter + ' is not a valid formatter.');
	return val;
};

/**
 * this is a half-hearted attempt to remove the separator character from a
 * number that is formatted
 *
 * @param val
 *            to be formatted
 * @returns formatted value
 */
a.deformat = function(val) {
	formatter = this.formatter;
	if (!formatter || formatter == 'none')
		return val;
	if (formatter.indexOf('eur') != -1)
		return val.replace(/\./g, '');

	return val.replace(/,/g, '');
};

/**
 * set value to this field. This is the controller, and hence it has to do three
 * things. Set value to model, push value the view, and trigger any events
 * associated with this change of value. This method is same as calling
 * saveValue(), setValueToObject() and triggerFieldChangedEvents() in succession
 *
 * @param val -
 *            value to be set
 * @param ele -
 *            dom element associated with this field. If null, we get the
 *            default dom element associated with this field
 * @param idx -
 *            if this field is part of a table, then the row number to be used.
 *            Defaults to currentRow of teh table
 * @param suppressDesc -
 *            do not trigger descriotion service. This is used to avoid a
 *            perpetual call to description service on return of a descriotion
 *            service.
 * @param formatValue -
 *            value is formatted using the associated data type before settig
 *            teh value
 * @param forceChangedEvents -
 *            force changed events even if the value has actually not changed.
 *            This looks vierd, but we got into this situation because of
 *            historic reasons and to provide backward compatibility
 * @param listServiceOnLoad -
 *            this method is invoked when the listServices fired on load return
 *            with data. This is passed around to avoid triggering fieldChanged
 *            events on teh associated fields
 */
a.setValue = function(val, ele, idx, suppressDesc, formatValue,
		forceChangedEvents, listServiceOnLoad) {
	if (val && formatValue && this.dataType) {
		var dt = dataTypes[this.dataType];
		if (dt)
			val = dt.formatIn(val);
	}
	var oldVal = val;
	/*
	 * if this is inside table, save value in table, and get the element
	 */
	if (this.table) {
		/*
		 * TODO: We have to investigate following statement and document
		 * accordingly. looks like suppressDesc is called ONLY when we are
		 * trying to assign desc fields. rowChanged() may get invoked sevral
		 * times
		 */
		if (suppressDesc) {
			this.table.rowChanged(ele, this.unqualifiedName, idx);
		}

		/*
		 * there are different scenarios. we have to get element and idx in all
		 * cases
		 */
		if (!ele && !idx) {
			/*
			 * if nothing is known, use current row
			 */
			idx = this.table.currentRow;
		}
		if (!idx) {
			/*
			 * Means, ele is given, but not idx. we get idx from the ele.
			 */
			idx = this.table.getRowNumber(ele);
		}
		if (!ele) {
			// note that we definitely have idx now.
			ele = this.P2.doc.getElementById(this.table.getObjectId(this.name,
					idx));
		}
		/*
		 * we have both ele and idx now
		 */
		oldVal = this.table.saveValue(val, this.columnIdx, idx);

		/*
		 * Trigger Aggregate function if user calls setValue explicitly
		 */
		if (this.table.hasAggregates) {
			this.table.aggregateAField(this, ele, idx);
		}
	} else {
		// non-table
		oldVal = this.value;
		this.value = val;

		if (!ele) {
			ele = this.P2.doc.getElementById(this.name);
		}
	}
	if (oldVal != val || forceChangedEvents) {
		if (!ele) {
			debug('Dom element for ' + this.name + ' not found');
			return;
		}

		if (val && formatValue) {
			var newFormattedValue = val;
			if (this.formatter) {
				newFormattedValue = this.format(val);
			}
			this.setValueToObject(ele, newFormattedValue);
		} else if (oldVal != val) {
			this.setValueToObject(ele, val);
		}

		if (this.triggerFieldChangedEvents) {
			this.triggerFieldChangedEvents(val, ele, idx, suppressDesc, true,
					listServiceOnLoad);
		}
	}
};

/**
 * save value into model, and not trigger anything else
 *
 * @param val
 *            value to be saved
 * @param ele
 *            dom element that triggered this. Used to get row number if
 *            required
 * @param idx
 *            row number in the table to which this value is to be saved
 * @param internalChange
 *            if true, this vaue is set by a script, and not changed by user
 */
a.saveValue = function(val, ele, idx, internalChange) {
	var table = this.table;
	if (!table) {
		this.value = val;
		return;
	}
	if (ele && !idx)
		idx = table.getRowNumber(ele);
	/*
	 * we have an issue with radio buttons in the grid
	 */
	if (ele && ele.type == 'radio' && val == '')
		val = ele.value;
	/*
	 * special case of repeated-column
	 */
	if (table.repeatedField && table.repeatedField === this)
		table.saveRepeatedColumnValue(val,
				ele ? ele.getAttribute('key') : null, idx);
	else
		table.saveValue(val, this.columnIdx, idx, internalChange);
};

/**
 * get value from model
 *
 * @param idx -
 *            row number if this is inside a table
 * @param toFormat -
 *            get formatted value
 * @param fromDeletedRowAsWell -
 *            special case where a caller wants a value from a grid row that is
 *            marked as deleted. By default we would return null
 * @returns value in the model
 */
a.getValue = function(idx, toFormat, fromDeletedRowAsWell) {
	var val;
	if (this.table)
		val = this.table.getValue(this.columnIdx, idx, fromDeletedRowAsWell);
	else
		val = this.value;
	if (val && toFormat) {
		var dt = dataTypes[this.dataType];
		if (dt)
			val = dt.formatOut(val);
	}
	return val;
};

/**
 * has this field got some value?
 *
 * @returns true if this field has non-default value
 */
a.hasValue = function() {
	/* value is always in text form */
	if (this.value != null && this.value.length > 0)
		return true;
	return false;
};

/**
 * validate and retturn false in case teh field fails validation. COncrete
 * classes have to implement this methid if required
 *
 * @param isFinalValidation
 *            if this is the final validation before sending values to server
 *            (false means validatiing when a user changes the value)
 * @return validated (possibly formatted or cleand) value
 * @throws error
 *             object that must be caught an dused for flashing message to user
 */
a.validate = function(isFinalValidation) {
	return this.getValue();
};

/**
 * validate the value and return validated value. returned value could be
 * cleaned-up, and hence it must be used by the caller. Any validation error is
 * handled by this routine before returning
 *
 * @param val
 *            value to be validated
 * @param ele
 *            dom element that the user used to change this value
 * @param isFinalValidation
 *            is this the final validation that is done before we send it to
 *            server? (else means this is the validation whenuser chnages value)
 * @return formatted or cleaned-up value to be used
 * @throws exception
 *             if validaiton fails
 */
a.validateValue = function(val, ele, isFinalValidation) {
	return val;
};

/**
 * add this field and its value to dc. In case of filter-field etc.. it is the
 * job of this method to add other assoaited values, as the others do not have a
 * field object associated with them
 *
 * @param dc
 *            to which to add the value
 */
a.fillDc = function(dc) {
	var val = this.getValue(0, true);
	var fieldName = this.unqualifiedName || this.name;
	dc.addValue(fieldName, val);
	this.fillDcWithRelatives(dc);
};

/**
 * add related fields to dc.
 *
 * @param dc
 *            to which to add the value
 */
a.fillDcWithRelatives = function(dc) {
	if (this.aliasName) {
		dc.addValue(this.aliasName, val);
		dc.addValue(this.aliasName + 'DataType', this.dataType);
	}
	if (this.isFilterField) {
		/*
		 * operator and to fields are associated with filter field
		 */
		var nam = this.name + 'Operator';
		var field = this.P2.fields[nam];
		var val = field.getValue(0, true);
		dc.addValue(nam, val);
		if (this.aliasName) {
			dc.addValue(this.aliasName + 'Operator', val);
		}
		nam = this.name + 'To';
		field = this.P2.fields[nam];
		if (field) {
			val = field.getValue(0, true);
			dc.addValue(nam, val);
			if (this.aliasName) {
				dc.addValue(this.aliasName + 'To', val);
			}
		}
	}
};

/**
 * has this field value in teh view changed from its model? TO be overridden by
 * specialized field if this is not as abvious as checking with ele.value
 *
 * @param ele
 *            dom element.
 * @returns {Boolean} whether the value in the view has changed
 */
a.isChanged = function(ele) {
	return (this.getValue() != ele.value);
};

/**
 * class that represents an out put field. It's view is typically the innerHTMl
 * of the dom element with this id
 */
var OutputField = function() {
	AbstractField.call(this);
	this.maxCharacters = 0;
	this.isEditable = false;
};

a = OutputField.prototype = new AbstractField;
/**
 * we clip value to max chars as of now. With strict html5, we should be able to
 * use css to create elipses
 *
 * @param ele
 *            dom alement to be used for rendering value
 * @param val
 *            value to be rendered using the dom element
 */
a.setValueToObject = function(ele, val) {
	if (!ele) {
		debug('ERROR: null object passed to set value to field ' + this.name
				+ ' and val = ' + val);
		return;
	}
	/*
	 * we have the concept of internal value and display value, similar to a
	 * selection field
	 */
	if (this.valueList) {
		/*
		 * we cache the collection indexed by internal value
		 */
		if (!this.valueListCollection) {
			this.valueListCollection = {};
			var vl = this.valueList.split(';');
			for ( var i = 0; i < vl.length; i++) {
				var pair = vl[i].split(',');
				this.valueListCollection[pair[0]] = pair[1];
			}
		}
		var v = this.valueListCollection[val];
		if (v)
			val = v;
		ele.innerHTML = val;
		return;
	}

	/*
	 * we did not have ellipses as an option in css, and hence we have a max
	 * limit to ensure that this field will not run-off. we put the whoel text
	 * as help-text*title)
	 */
	var maxChars = this.maxCharacters == 0 ? 9999 : this.maxCharacters;
	/*
	 * -ve max chars means retain last chars rather than trimming them
	 */
	if (maxChars < 0) {
		maxChars = -maxChars;
	}
	val = new String(val);
	if (val && val.length > maxChars) {
		maxChars -= 3; // for the tree dots
		ele.title = val;
		if (this.maxCharacters < 0)
			val = '...' + val.substring(val.length - maxChars);
		else
			val = val.substring(0, maxChars) + '...';
	} else {
		ele.removeAttribute('title');
	}
	if (val == '') {
		val = ' ';
	} else {
		if (!this.allowHtmlFormattedText) {
			val = val.replace(/&/g, '&').replace(/</g, '<');
		}
		val = val.replace(/\n/g, '<br />');
	}

	ele.innerHTML = val;
};

/**
 * special case of boolean output fields that require display support
 */
var BooleanOutputField = function() {
	AbstractField.call(this);
	this.trueValue = 'Yes';
	this.falseValue = 'No';
	this.isEditable = false;
};

a = BooleanOutputField.prototype = new AbstractField;
/**
 * render true/false value in this ele
 *
 * @param ele
 *            dom element to be rendered
 * @param val
 *            value to be rendered
 */
a.setValueToObject = function(ele, val) {
	if (val == '1' || val === 1)
		ele.innerHTML = this.trueValue;
	else
		ele.innerHTML = this.falseValue;
};

/**
 * base class for all input fields
 */
var AbstractInputField = function() {
	AbstractField.call(this);

	this.toBeSentToServer = true;
};

a = AbstractInputField.prototype = new AbstractField;

/**
 * validate the value ins this model, and return current value if it is valid.
 * Throws exception in case of validaiton error, with all required info in the
 * trown object for P2 to manage the error
 *
 * @param isFinalValidation
 *            false if this is validation after a field chage, true if this is
 *            the validaiton before sending a request to server
 * @returns current value
 * @throws error
 *             object in case of validation error
 */
a.validate = function(isFinalValidation) {
	if (this.doNotValidate) {
		return this.value;
	}
	var doc = this.P2.doc;
	var val = this.value;
	var validatedValue = val;
	var ele;

	/*
	 * validateValue will throw exception in case validaiton fails
	 */
	try {
		validatedValue = this.validateValue(val, null, isFinalValidation);
	} catch (e) {
		ele = doc.getElementById(this.name);
		if (ele)
			ele.isValid = false;
		e.ele = ele;
		e.field = this;
		// hand-over to P2 to render
		throw e;
	}

	/*
	 * If validator returned a different value, let us deal with that
	 */
	if (validatedValue != val) {
		/*
		 * TODO: following statement is useless, as val is this.vale at this
		 * time. Looks like it should be validatedValue. However, we can not fix
		 * it, becauase projects would have used the current behaviour as
		 * feature, and their logic will break if we "fix" this issue. We have
		 * to decide whether there is a need for the intended feature, in which
		 * case, we will have to introduce anotehr keyword for the same
		 */
		this.value = val;
		ele = doc.getElementById(this.name);
		if (ele)
			this.setValueToObject(ele, validatedValue);
	}
	return val;
};

/**
 * validate the value and return validated value. returned value could be
 * cleaned-up, and hence it must be used by the caller. Any validation error is
 * handled by this routine before returning
 *
 * @param val
 *            value to be validated
 * @param dt
 *            data type to be used. If not passed, data type associated with
 *            this field
 * @param isFinalValidation
 *            is this the final validation that is done before we send it to
 *            server? (else means this is the validation whenuser chnages value)
 * @param linkedTable
 *            in case this is coming from a linked-table
 * @return formatted or cleaned-up value to be used
 * @throws exception
 *             if validaiton fails
 */
a.validateValue = function(val, dt, isFinalValidation, linkedTable) {

	if (this.multipleSelection && this.selectionValueType != 'text')
		return this.specialValidateValue(val);

	var otherFieldName, otherField, otherValue;

	if (!dt && this.dataType)
		dt = dataTypes[this.dataType];
	/*
	 * this logic is quite convoluted, and made for a specific case in some
	 * product. Looks like this feature is not used any more.
	 */
	if (exilParms.validateDatesForBetween && PM.pageValidation && dt
			&& dt.basicType == 'DATE' && (this.isFilterField || this.fromField)) {
		this.filterToFieldExists();
	}

	if (!this.requiresValidation || this.doNotValidate)
		return val;

	val = trim(val);
	/*
	 * let us start with the case when value is not entered
	 */
	if (!val) {
		this.validateOnEmpty(linkedTable);
		return val;
	}

	/*
	 * next, ask dataType if this value is OK.
	 */
	if (!dt) {
		debug(this.name
				+ " is not validated because it does not have a valid data type");
		return val;
	}

	val = dt.validate(val, this.messageName);

	/*
	 * is there an additional validaiton function?
	 */
	if (this.validationFunction) {
		var errText = this.P2.win[this.validationFunction](val);
		if (errText)
			throw new ExilityError(errText, val);
	}

	/*
	 * descipiton service based validation may be pending!
	 */
	if (isFinalValidation && this.descServiceId) {
		// see if the object is validated already
		otherFieldName = this.name;
		if (this.table)
			otherFieldName = this.table.getObjectId(this.name);
		var ele = this.P2.doc.getElementById(otherFieldName);
		if (!ele) {
			message("Design Error: Object for " + otherFieldName
					+ " is not available during final validation", "Error",
					"Ok", null, null, null);
			return val;
		}
		if (ele.pendingServiceRequest) {
			throw new ExilityError(
					"A call to server is still pending. Please submit again.");
		}
		if (ele.isValid === false) {
			throw new ExilityError("Invalid value");
		}
	}

	/*
	 * inter-field validation. Note that the other field may have to be
	 * picked-up from the linked table.
	 */

	otherFieldName = this.fromField;
	if (otherFieldName) {
		if (linkedTable) {
			otherFieldName = otherFieldName.replace(this.table.name,
					linkedTable.name);
		}
		otherField = this.P2.getField(otherFieldName);
		otherValue = otherField && otherField.getValue();
		if (otherValue) {
			dt.validateFromTo(otherValue, val, otherField.label, this.label);
		}
	}
	// to field?
	otherFieldName = this.toField;
	if (otherFieldName) {
		if (linkedTable) {
			otherFieldName = otherFieldName.replace(this.table.name,
					linkedTable.name);
		}
		otherField = this.P2.getField(otherFieldName);
		otherValue = otherField && otherField.getValue();
		if (otherValue) {
			dt
					.validateFromTo(val, otherValue, this.label,
							otherFieldName.label);
		}
	}

	// other field?
	otherFieldName = this.otherField;
	if (otherFieldName) {
		if (linkedTable) {
			otherFieldName = otherFieldName.replace(this.table.name,
					linkedTable.name);
		}

		otherField = this.P2.getField(otherFieldName);
		otherValue = otherField && otherField.getValue();
		if (otherValue && val == val1) {
			throw new ExilityError(this.label + ' and ' + otherField.label
					+ ' should have different values.');
		}
	}

	return val;
};

/**
 * if either this field is a filter field, or the fromField of this field is a
 * filter field (I can't think of how that can be, but the logic is there :-)
 * )then ensure tha either both values are there, or both fields are empty. Note
 * that we DO NOT validate the value, but simply check whether the fields have
 * value. As per our standard design, to and operator fields are never
 * generated. Looks like some one had tweaked something in between
 *
 * @throws exception
 *             in case tehvalues are not consistent
 */
a.filterToFieldExists = function() {
	var otherField = null;
	var operatorField = null;

	if (this.isFilterField) {
		otherField = this.P2.getField(this.name + 'To');
		operatorField = this.P2.getField(this.name + 'Operator');
	} else if (this.fromField) {
		otherField = this.P2.getField(this.fromField);
		if (!otherField.isFilterField) {
			return;
		}
		operatorField = this.P2.getField(this.fromField + 'Operator');
	} else { // it is fine.
		return;
	}

	if (!otherField || !operatorField) {
		debug('Other field for special filter validation could not be found in dom. Validation dropped');
		return;
	}
	var val = operatorField.getValue();
	if (val != 6) {
		return;
	}
	if ((this.vale && !otherField.value) || (!this.value && otherField.value)) {
		throw new ExilityError("exilBetweenError");
	}
};

/**
 * validate this field when there is nno value. Throw exception if it is an
 * error
 *
 * @param linkedTable -
 *            if this field is in a linked table, null if not.
 * @throws exception
 *             in case this field requires value at this time
 */
a.validateOnEmpty = function(linkedTable) {
	if (this.isRequired) {
		throw new ExilityError("exilValueRequired");
	}
	/*
	 * is it mandatory based on onother field?
	 */
	var otherFieldName = this.basedOnField;
	if (!otherFieldName) {
		return;
	}
	if (linkedTable) {
		/*
		 * remember, if there is a linked table, we have to get the value from
		 * that table, and not this panel
		 */
		otherFieldName = this.basedOnField.replace(this.table.name,
				linkedTable.name);
	}
	var val = this.P2.getFieldValue(otherFieldName);
	if (!val) {
		return;
	}
	/*
	 * does it further depend on specific value in the other field?
	 */
	if (!this.basedOnFieldValue || val == this.basedOnFieldValue)
		throw new ExilityError("exilValueRequired");
};

/**
 * carry out inter-field validations
 *
 * @param val
 *            value to be validated
 * @param dt
 *            data type of this field
 * @param linkedTable -
 *            if this was from a linked table, null if not
 * @throws exception
 *             in case of any validation error
 *
 */
a.interFieldValidate = function(val, dt, linkedTable) {
	var otherFieldName, otherValue;

	otherFieldName = this.fromField;
	if (otherFieldName) {
		if (linkedTable) {
			otherFieldName = otherFieldName(this.table.name, linkedTable.name);
		}
		otherValue = this.P2.getFieldValue(otherFieldName);
		if (otherValue)
			dt
					.validateFromTo(otherValue, val, this.fromField.label,
							this.label);
	}
	// to field?
	otherFieldName = this.toField;
	if (otherFieldName) {
		if (linkedTable) {
			otherFieldName = otherFieldName(this.table.name, linkedTable.name);
		}
		otherValue = this.P2.getFieldValue(otherFieldName);
		if (otherValue)
			dt.validateFromTo(val, otherValue, this.label, this.toField.label);
	}

	// other field?
	otherFieldName = this.otherField;
	if (otherFieldName) {
		if (linkedTable) {
			otherFieldName = otherFieldName.replace(this.table.name,
					linkedTable.name);
		}

		otherValue = this.P2.getFieldValue(otherFieldName);
		if (otherValue && val == otherValue) {
			throw new ExilityError(this.label + ' and '
					+ this.P2.fields[this.otherField].label
					+ ' should have different values.');
		}
	}
};

/**
 * call descriotion service for this field. This is called on change of this
 * field value.
 *
 * @param ele
 *            doem element that triggered this event. This is used when the
 *            field is inside a table
 * @param idx -
 *            row number in the table if this field is inside a table
 */
a.callDescService = function(ele, idx) {
	/*
	 * If user changes a field with desc, and then directly clicks on submit
	 * field without tabbing out of the field,we get to a loop, because of which
	 * we use a timer to handle this crisis
	 */
	if (this.P2.pendingDescTimer) {
		ele = this.descObj;
		ele.internalChange = false;
		this.descObj = null;
		idx = this.descIdx;
		this.descIdx = 0;
		this.P2.pendingDescTimer = null;
	} else {
		ele.internalChange = true;
	}
	var dc = new DataCollection();
	var allOK = this.P2.fillDcFromQueryFields(dc, this.descQueryFields,
			this.descQueryFieldSources, idx, this.validateQueryFields);
	if (allOK) {
		var se = new ServiceEntry(this.descServiceId, dc, false, descReturned,
				ele, this.name, ServerAction.NONE, null, null,
				this.fieldToFocusAfterExecution);
		this.P2.win.serverStub.callService(se);
		ele.pendingServiceRequest = true;
	}
};

/**
 * trigger all events meant for value-changes for this field
 *
 * @param val -
 *            new value of this field
 * @param ele -
 *            dom element that triggered this change
 * @param idx -
 *            row number of this element if this fields is in table
 * @param supressDesc -
 *            if true, we shoudl not trigger description service again. This is
 *            to avoid
 * @param internalChange
 *            if true, this is an internal change, else user has changed the
 *            value of this field
 * @param listServiceOnLoad
 *            is this triggered becaue of listservice that returned a value on
 *            load?
 */
a.triggerFieldChangedEvents = function(val, ele, idx, supressDesc,
		internalChange, listServiceOnLoad) {
	if (!supressDesc && this.descServiceId) {
		if (val == '') {
			this.setDescFields(ele, null, true, internalChange,
					listServiceOnLoad);

		} else if (!this.isUniqueField || this.P2.pageMode != 'modify') {
			ele.pendingServiceRequest = true;
			ele.internalChange = internalChange;
			var dc = new DataCollection();
			/*
			 * Passing the value to fillDcFromQueryFields for repeating columns.
			 */
			var allOK = this.P2.fillDcFromQueryFields(dc, this.descQueryFields,
					this.descQueryFieldSources, idx, this.validateQueryFields,
					val);
			if (allOK) {
				var se = new ServiceEntry(this.descServiceId, dc, false,
						descReturned, ele, this.name, ServerAction.NONE, null,
						null, this.fieldToFocusAfterExecution,
						listServiceOnLoad);
				this.P2.win.serverStub.callService(se);
			}
			/*
			 * rest of the processing will continue after the descservice return
			 */
			return;
		}
	}

	if (this.dependentSelectionField)
		this.manageDependentLists(val, idx, listServiceOnLoad);

	/*
	 * very special case. Is this from/to field, and has it now made that field
	 * valid? TODO: this has two issues. 1. it is possible that a field may have
	 * both fromField and toField
	 *
	 * 2. fn.dependentSelectionField is wrong because fn is field name.
	 *
	 * However, existing projects are working fine with this bug, and if we fix
	 * this, they will have issue. Hence we leave it as it is
	 */
	var fn = this.fromField || this.toField;
	if (fn && fn.dependentSelectionField) {
		var f = this.P2.fields[fn];
		var fval = f.getValue(idx);
		if (fval)
			f.manageDependentLists(val, idx, listServiceOnLoad);
	}

	/*
	 * do we have a copyTo field?
	 */
	if (val && this.copyTo) {
		var copyToField = this.P2.getField(this.copyTo);
		if (copyToField) {
			var existingValue = copyToField.getValue(idx);
			/*
			 * we are not supposed to over-ride existing value in that field
			 */
			if (!existingValue) {
				copyToField.setValue(val, null, idx,
						copyToField.supressDescOnLoad, false);
			}
		}
	}

	if (this.onChangeActionName) {
		debug('on change triggered for ' + this.name + ' onchange = '
				+ this.onChangeActionName);
		this.P2.act(ele, this.name, this.onChangeActionName, val);
	}

	if (this.onUserChangeActionName && !internalChange) {
		debug('on user change triggered for ' + this.name + ' onchange = '
				+ this.onUserChangeActionName);
		this.P2.act(ele, this.name, this.onUserChangeActionName, val);
	}

	if (this.isFilterOperator)
		this.filterSelectionChanged(ele, val);
};

/**
 * manage dpendent selection fields when this field value changes
 *
 * @param val
 *            new value
 * @param idx
 *            row number in the table if relevant
 * @param listServiceOnLoad
 */
a.manageDependentLists = function(val, idx, listServiceOnLoad) {
	var fieldNames = this.dependentSelectionField;
	for ( var i = 0; i < fieldNames.length; i++) {
		var field = this.P2.fields[fieldNames[i]];
		if (!field) {
			debug(' field '
					+ fieldNames[i]
					+ ' is not found when it is tried as a dependent selection field for '
					+ this.name);
			continue;
		}
		if (!field.listServiceId) {
			debug(field.name
					+ ' is defined as a dependent selection field for '
					+ this.name + '. But ' + field.name
					+ ' does not have a listServiceId.');
			continue;
		}
		var newObjId = field.name;
		if (field.table)
			newObjId = field.table.getObjectId(newObjId, idx);
		var newObj = this.P2.doc.getElementById(newObjId);
		if (newObj) {
			if (newObj.keyValue == val) // it has the same value..
				return;
			newObj.keyValue = val;
		}
		if (val) {
			/*
			 * any value that may get changed now is an internal chnage
			 */
			field.callListService(val, newObj, idx, true);
		} else {
			field.fillList(null, newObj);
			if (field.getValue())
				field.saveValue('', newObj, idx, true);
		}
	}
};

/**
 * this is a function and not a method. this funciton is attached as call-back
 * function for serverAgent
 *
 * @param ele -
 *            dom element that had trigegred this call to server
 * @param fieldName
 *            name of the field that had requested this service
 * @param se
 *            service entry that has all details about the call to server. We
 *            will get the dc from this
 */
var descReturned = function(ele, fieldName, se) {
	ele.pendingServiceRequest = null;
	/*
	 * se has serviceId and dc. dc has a grid with the name = serviceId, in
	 * which data is returned..
	 */
	var data = se.dc.grids[se.serviceId];
	se.win.P2.fields[fieldName].setDescFields(ele, data, false,
			ele.internalChange, se.listServiceOnLoad);
};
/**
 * Look at the data returned from description service, and assin values from the
 * data to corresponding fields. This method is also called toreset description
 * fields when this field value is changed (before requesting a desciption
 * service)
 *
 * @param ele
 *            dom element that triggered this event
 * @param data
 *            returned from server, or null if this is called to reset
 *            description fields
 * @param toReset
 *            reset desc fields
 * @param internalChange
 *            true if this is triggered when the value is changed internally,and
 *            not by user
 * @param listServiceOnLoad
 *            true if this is triggered because of list service on load
 */
a.setDescFields = function(ele, data, toReset, internalChange,
		listServiceOnLoad) {
	var fieldNames = this.descFields;
	if (!fieldNames) {
		debug('descFields property is not set for ' + this.name
				+ '. Code picker will not show any values');
		return;
	}

	/*
	 * fieldNames would be qualified (tableName_fieldName) but column heading in
	 * data is unqualified. So, let us get unqualified names for mathching
	 */
	var namesToMatch = this.P2.getUnqualifiedNames(fieldNames);
	var idx = 0;
	/*
	 * we do not use currentRow of table because th euser might have clicked on
	 * a different row when the description service returns asynchronously from
	 * the server
	 */
	if (this.table)
		idx = this.table.getRowNumber(ele);

	/*
	 * isUniqueField means that the desc service is used to cheque uniqueness of
	 * this field. And hence we do not expect data.
	 */
	if (this.isUniqueField && this.P2.pageMode == 'add') {
		if (data && data.length > 1 && !this.doNotValidate) {
			ele.isValid = false;
			var e = new ExilityError(this.descMessageId
					|| 'Value already exists');
			e.field = this;
			e.obj = ele;
			this.P2.catchError(e);
		} else
			ele.isValid = true;
		return;
	}

	var namesInTable = null; // header row from table
	var n = 0; // nbr names above
	var fieldName = null; // in the header of data
	var nameToMatch = null; // corresponding name on the client
	var vals = null; // data row from server to be used
	var val = null;
	var dataFound = false; // did we find a data row that matches the value?

	var isCombo = (this.comboDisplayFields && exilComboWin);

	if (data && data.length > 1) // data exists
	{
		ele.isValid = true;
		dataFound = true;
		namesInTable = data[0];
		n = namesInTable.length;
		vals = data[1];

		/**
		 * programmers tend to reuse the combo-service as description service as
		 * well. While this is not a good design, this has been working for them
		 * in general. We had assumed that there will be exactly one row coming
		 * back from the server, and, in case of more than one rows, we simply
		 * picked-up the first one. This needs to be refined for combo. We do
		 * not take anything for granted. We check again whether there is a row
		 * with the desired value.
		 */
		if (isCombo && data.length > 2) {
			var dataRowIdx = findRowIndex(data, ele.value);
			if (dataRowIdx > 0) {
				vals = data[dataRowIdx];
			} else {
				/*
				 * this is the case when the value is not valid, but it is
				 * "contained" in other valid values. just simulate as no rows
				 * in data
				 */
				dataFound = false;
				vals = null;
				if (!this.doNotValidate) {
					ele.isValid = false;
				}
			}
		}

	} else {
		if (data && !this.doNotValidate) {
			ele.isValid = false;
			dataFound = false;
		}
	}

	var thisFieldValue = null;
	var m = fieldNames.length;
	for ( var i = 0; i < m; i++) {
		fieldName = fieldNames[i];
		if (!fieldName)
			continue;
		nameToMatch = namesToMatch[i];
		val = '';
		if (dataFound) {
			if (this.doNotMatchDescNames) {
				if (i <= n)
					val = vals[i];
			} else {
				for ( var j = 0; j < n; j++) {
					if (nameToMatch == namesInTable[j]) {
						val = vals[j];
						break;
					}
				}
			}
		}

		if (fieldName == this.name) {
			/*
			 * it is this field. We will handle it outside the loop
			 */
			thisFieldValue = val;
		} else {
			this.P2.setFieldValue(fieldName, val, null, idx, false, true,
					listServiceOnLoad);
		}
	}

	if (dataFound) {
		if (!thisFieldValue)
			thisFieldValue = this.getValueFromObject(ele);
		/*
		 * If this desc is a combo service then it should trigger change events
		 * after setting the data
		 */
		if (!(this.doNotValidate && exilParms.donotSetFirstDescValue)
				|| isCombo) {
			/*
			 * we need to set this value and continue to trigger other field
			 * changed events
			 */
			this.saveValue(thisFieldValue, ele, idx);
			this.setValueToObject(ele, thisFieldValue);
			if (this.table)
				this.table.rowChanged(ele, this.unqualifiedName, idx,
						internalChange);
			this.triggerFieldChangedEvents(thisFieldValue, ele, idx, true,
					internalChange, listServiceOnLoad);
		}
	} else if (!toReset) {
		/*
		 * we have to continue with triggering field changed events other than
		 * description service
		 */
		this.triggerFieldChangedEvents('', ele, idx, true, internalChange,
				listServiceOnLoad);
		if (!this.doNotValidate) {
			val = 'invalid ' + this.label;
			message(val, "Warning", "Ok", null, null, null);
			try {
				if (ele.select)
					ele.select();
				if (ele.focus)
					ele.focus();
			} catch (ex) {
				/*
				 * we just try to focus the field. If the field is shy, let us
				 * not loose our sleep on that :-)
				 */
			}
		}
	}
};

/**
 * set min and max date for this field, if it happens to be a date field. These
 * values over-ride the ones set by the underlying data type. Leave either min
 * or max null if you do not want to over-ride, or if you want to reset a value
 * that was set earlier
 *
 * @param min
 *            minimum date optional
 * @param max
 *            maximum date optional
 */
a.setMinMax = function(min, max) {
	this.minDate = min;
	this.maxDate = max;
};

/**
 * when operator field in filter field changed. Note that this dom element is
 * not associated directly with a field. Hence we have to striggle with this a
 * bit
 *
 * @param ele
 *            dom element that changed
 * @param val
 *            changed value
 */
a.filterSelectionChanged = function(ele, val) {
	var id = ele.id;
	/*
	 * knock-off 'Operator' from that rememebr substr(start, length) while
	 * substring(start, end)
	 */
	id = id.substr(0, id.length - 8);
	var toEle = this.P2.doc.getElementById(id + 'ToDiv');
	if (val == 6) {
		toEle.style.display = '';
	} else if (toEle) {
		toEle.style.display = 'none';
		// reset value in the to-field, so that from-to validation is disabled
		this.P2.setFieldValue(id + 'To', '');
	}
};

/**
 *
 */
var TextInputField = function() {
	AbstractInputField.call(this);

	this.requiresValidation = true;
	this.minCharsToTriggerService = 0;
	// for the time being server side always return matching grid of max 5 rows.
	this.maxRowsToDisplay = 7;

};
a = TextInputField.prototype = new AbstractInputField;

/**
 * set value to dom element
 *
 * @param ele
 *            dom element
 * @param val
 *            value to be set
 */
a.setValueToObject = function(ele, val) {
	var dt = dataTypes[this.dataType];
	if (!dt || !dt.includesTime) {
		ele.value = val;
		return;
	}

	var values = getDateTimeParts(val); // defined in utils.js
	var eles = this.getTimeObjects(ele);
	if (eles.dt) {
		eles.dt.value = values.dt;
	}
	if (eles.hr) {
		eles.hr.value = values.hr;
	}
	if (eles.mn) {
		eles.mn.value = values.mn;
	}
	if (eles.sc) {
		eles.sc.value = values.sc;
	}
	if (eles.am) {
		eles.am.selectedIndex = values.am;
	}
};

/**
 * get value from dom element
 *
 * @param ele
 *            dom element
 * @returns value from dom element, or null in case of error
 */
a.getValueFromObject = function(ele) {
	var dataType = dataTypes[this.dataType];
	if (!dataType || !dataType.includesTime) {
		return ele.value = trim(ele.value);
	}
	// tricky job of picking-up pieces from date and time fields.
	var eles = this.getTimeObjects(ele);

	var dt = eles.dt.value;
	/*
	 * if date field is not entered, we ignore time fields....
	 */
	if (!dt) {
		return '';
	}

	var hr = (eles.hr && eles.hr.value) || '0';
	hr = parseInt(hr, 10) || 0;
	if (eles.am && eles.am.selectedIndex) {
		hr += 12;
	} else if (hr < 10) {
		hr = '0' + hr;
	}
	var mn = (eles.mn && eles.mn.value) || '00';
	var sc = (eles.sc && eles.sc.value) || '00';
	return dt + ' ' + hr + ':' + mn + ':' + sc;
};

/**
 * returns an object that has all html elements corresponding to time fields
 *
 * @param ele
 *            dom element of main field
 * @returns object with attrbutes dt, mn, sc, and am as other dom elements for
 *          showing time
 */
a.getTimeObjects = function(ele) {
	var nam = this.name;
	if (this.table && ele.rowIdx)
		nam = nam + '__' + ele.rowIdx;
	var doc = this.P2.doc;
	return {
		dt : doc.getElementById(nam + 'Hr'),
		mn : doc.getElementById(nam + 'Mn'),
		sc : doc.getElementById(nam + 'Sc'),
		am : doc.getElementById(nam + 'Am')
	};
};

/**
 * class that represents a check-box in dom
 */
var CheckBoxField = function() {
	AbstractInputField.call(this);
	this.isChecked = false;
	/*
	 * default value of checked-unchecked. This may be over-ridden by attribute
	 * set in meta.js
	 */
	this.checkedValue = exilParms.checkedValue;
	this.uncheckedValue = exilParms.uncheckedValue;
};

a = CheckBoxField.prototype = new AbstractInputField;
/**
 * notion of value is different from that in HTML. Hence we keep track of its
 * checked status as well
 */
a.initialize = function() {
	if (this.isChecked)
		this.value = this.checkedValue;
	else
		this.value = this.uncheckedValue;
};

/**
 * get value from dom element
 *
 * @param ele
 *            dom element to get the value from
 * @returns text value of teh dom element
 */
a.getValueFromObject = function(ele) {
	if (ele.checked) {
		return this.checkedValue;
	}
	return this.uncheckedValue;
};

/**
 * has this field a value? We condier checked as value, and unchecked as no
 * value
 *
 * @returns true if this field is checked, false otherwise
 */
a.hasValue = function() {
	return this.isChecked;
};

/**
 * set value to object
 *
 * @param ele
 *            dom element to which valoue is to be set to
 * @param val
 *            value to be set
 */
a.setValueToObject = function(ele, val) {
	var uval = val.toUpperCase();
	if (val == ele.value || val == this.checkedValue || val == '1'
			|| uval == 'Y' || uval == 'YES' || uval == "TRUE") {
		ele.checked = this.isChecked = true;
	} else {
		ele.checked = this.isChecked = false;
	}
};

/**
 * as per MVC principles, we do not need a view for hidden field. with html5
 * version, we have decided nnot to render hiddenFields. They are part of P2,
 * but not DOM
 */
var HiddenField = function() {
	AbstractInputField.call(this);
	this.isEditable = false;
};

a = HiddenField.prototype = new AbstractInputField;

/**
 * set value, but only if dom ele exists
 *
 * @param ele
 *            do element
 * @param val
 *            value to be set
 */
a.setValueToObject = function(ele, val) {
	if (ele) {
		ele.value = val;
	}
};

/**
 * get the value from dom element. deprecated, but kept for backward
 * compatibility
 *
 * @param ele
 *            domelement to get value from
 * @returns value from dom
 */
a.getValueFromObject = function(ele) {
	if (ele) {
		return ele.value;
	}
	debug("Hidden field shoudl not be used as a dom element. use P2.getFieldValue(fieldName) instead.");
	return null;
};

/**
 * class for a radio button
 */
var RadioButtonField = function() {
	AbstractInputField.call(this);
	this.isRadio = true;
};

a = RadioButtonField.prototype = new AbstractInputField;

/**
 * get the inupt elements of this radio group. two schemes are possible
 *
 * new way : <div id="name"....><div class="radio"><input type="radio" ..></div><div
 * class="radioLabel">label</div> etc... </div>
 *
 * old way : <span id="name" ...><input ..><span>label</label>etc..</span>
 *
 * @param ele
 *            dom element that is associated with this event.
 * @returns array of input elements associated with this radio group. null if we
 *          can not find them.
 */
a.getInpuElements = function(ele) {
	if (ele.type) {
		ele = ele.parentNode;
	}
	if (!ele.id) {
		ele = ele.parentNode;
	}
	var eles = ele.getElementsByTagName('input');
	if (!eles || !eles.length) {
		debug('Design error: Radio buttons for field ' + this.name
				+ ' not found in the dom');
		return null;
	}
	return eles;
};

/**
 * set value to the dom element
 *
 * @param ele
 *            dom element
 * @param val
 *            value to be set
 */
a.setValueToObject = function(ele, val) {
	var eles = this.getInpuElements(ele);
	if (!eles) {
		return;
	}
	var gotChecked = false;
	for ( var i = 0; i < eles.length; i++) {
		ele = eles[i];

		if (!gotChecked && ele.value == val) {
			ele.checked = true;
			gotChecked = true;
		} else
			ele.checked = false;
	}
	/*
	 * if we have checked a radio, we are done
	 */
	if (gotChecked)
		return;

	/*
	 * let us check the button for default value
	 */
	if (!this.defaultValue)
		return;

	for ( var i = 0; i < eles.length; i++) {
		ele = eles[i];
		if (ele.value == this.defaultValue) {
			ele.checked = true;
			return;
		}
	}
};

/**
 * get value from dom element
 *
 * @param ele
 *            dom element
 * @returns value from teh dom element, null if value cannot be fetched
 */
a.getValueFromObject = function(ele) {
	var eles = this.getInpuElements(ele);
	if (!eles) {
		debug('Design error: Radio buttons for field ' + this.name
				+ ' not found in the dom');
		return null;
	}

	for ( var i = 0; i < eles.length; i++) {
		ele = eles[i];
		if (ele.checked)
			return ele.value;
	}
	/*
	 * no element selected.
	 */
	return '';
};

/**
 * call the list service associated with this field
 *
 * @param val
 *            value of the key that triggered this call.
 * @param ele
 *            dom element that this field is currently associated, in a table
 *            context - optional
 * @param idx
 *            row number if this is inside a table context - optional
 * @param listServiceOnLoad
 *            if this is triggered as part of autoload
 */
a.callListService = function(val, ele, idx, listServiceOnLoad) {
	if (!ele) {
		var id = this.name;
		if (this.table)
			id = this.table.getObjectId(this.name, idx);
		ele = this.P2.doc.getElementById(id);
	}

	/*
	 * if field values change, dependent field may trigger list service in quick
	 * seccession. AND, if they do not come back in the same order, we will be
	 * in trouble. Let us remember the last key, so that the object can detect
	 * and reject old obsolete lists
	 */
	if (ele) {
		if (val)
			ele.listServiceKey = val;
		else if (ele.listServiceKey)
			delete ele.listServiceKey;
		debug(this.name + ' will expect a list service key value of '
				+ ele.listServiceKey);
	}

	var grid;
	grid = [ [ 'serviceId', 'keyValue' ], [ this.listServiceId, val ] ];

	this.P2.callListService(grid, ele, this.name,
			this.listServiceQueryFieldNames, this.listServiceQueryFieldSources,
			idx, listServiceOnLoad);
};

/**
 * render the value list into dom
 *
 * @param grid
 *            rows of valid values, with first row as header, first column as
 *            internal value, and second column as display value
 * @param ele
 *            dom element
 * @param doNotSelect
 *            if true, then no value is selected. This parameter is checking for
 *            negative, as it got added later during a refactoring process
 * @param listServiceOnLoad
 *            true if this is triggered onLoad
 */
a.fillListToObject = function(grid, ele, doNotSelect, listServiceOnLoad) {
	this.grid = grid;
	var txt = '';
	var n = grid && grid.length;
	if (n && n > 1) {
		if (!this.htmlParts) {
			if (!this.init()) {
				debug("Error while initializing " + this.name
						+ " radio button field. ");
				return false;
			}
		}
		/*
		 * get all radio options as inner html. remember htmlParts has three
		 * parts. we have to do part1 + innerValue + part2 + displayValue +
		 * part3 for each row
		 */
		var t = [];
		for ( var i = 1; i < n; i++) {
			var row = grid[i];
			t.push(this.htmlParts[0]);
			t.push(row[0]);
			t.push(this.htmlParts[1]);
			t.push(row[1] || row[0]);
			t.push(this.htmlParts[2]);
		}
		txt = t.join('');
	}
	ele.innerHTML = txt;
	// set the value to this
	if (!doNotSelect)
		this.setValueToObject(ele, this.value);
};

/**
 * assign list of values to this field.
 *
 * @param grid
 *            data with a header row that has the list of values for this field.
 *            First column is internal value and second column is display value
 * @param ele
 *            dom element associated with this field. passed if this is inside a
 *            table. Otherwise we use default one
 * @param keyValue
 *            if the list of valid values depends on a key (like countryCode for
 *            list of states) then the key value that is associated with the
 *            grid that is received
 * @param listServiceOnLoad
 *            true if this is triggered onLoad, false if it is triggered later
 */
a.fillList = function(grid, ele, keyValue, listServiceOnLoad) {
	/*
	 * non-able case is simpler..
	 */
	if (!this.table) {
		if (!ele)
			ele = this.obj;
		this.fillListToObject(grid, ele, false, listServiceOnLoad);
		return;
	}

	var id = null;
	var doc = this.P2.doc;
	/*
	 * is it for a specific row of a grid?
	 */
	if (!this.sameListForAllRows) {
		if (!ele) {
			id = this.table.getObjectId(this.name);
			ele = doc.getElementById(id);
			if (!ele) {
				debug("Unable to get the dom object for field " + this.name
						+ " for assigning the value list we got from server.");
				return;
			}
		}
		this.fillListToObject(grid, ele, false, listServiceOnLoad);
		return;
	}
	/*
	 * this is the case of a table in which the valid values are same across all
	 * rows. This MUST be called onLoad, or at least before the table receives
	 * data
	 */
	this.fillListToObject(grid, this.obj, true, listServiceOnLoad);

	var table = this.table;

	/*
	 * we have to push it to fields in all rows first into the row that is
	 * cashed
	 */
	var n = table.nbrRows;
	var tableData = table.grid;
	for ( var i = 1; i <= n; i++) {
		var row = tableData[i];
		if (!row)
			continue;
		id = table.getObjectId(this.name, i);
		ele = doc.getElementById(id);
		if (ele)
			this.fillListToObject(grid, ele, false, listServiceOnLoad);
		else
			debug(id + ' is not a DOM element for field name ' + this.name
					+ ' when we tried it to push a radio list to it');
	}
};

/**
 * page has <div id="name"...> with its innerHTML having two instances of '---' :
 * first one for internal value, and second one for display value. We can
 * recreate the inner html with repeating this pattern for each values in the
 * value list
 *
 */
a.init = function() {
	var ele = this.P2.doc.getElementById(this.name);
	if (!ele) {
		debug('Design Error: dom element with id=' + this.name
				+ ' as a radio group is not found');
		return false;
	}
	/*
	 * innerHTML is the meant for one value, with '---' as place holder for
	 * value and label. We strip this and keep into an array for a convenient
	 * way of creating innerHTML for all values.
	 */
	this.htmlParts = ele.innerHTML.split('---');
	ele.innerHTML = '';
	/*
	 * generater hides it to ensure that '---' are not visible by default
	 */
	ele.style.visibility = 'visible';
	return true;
};

/**
 * class for a Text area element of html
 */
var TextAreaField = function() {
	AbstractInputField.call(this);

	this.requiresValidation = true;
	this.numberOfRows = 3;
	this.numberOfCharactersPerRow = 40;
};
a = TextAreaField.prototype = new AbstractInputField;

/**
 * get value from domelement
 *
 * @param ele
 *            domelement to get value from
 * @returns value from dom element
 */
a.getValueFromObject = function(ele) {
	return ele.value = trim(ele.value);
};

/**
 * set value to dom element
 *
 * @param ele
 *            dom element to set value to
 * @param val
 *            value to be assigned to dom
 */
a.setValueToObject = function(ele, val) {
	ele.value = val;
};

/**
 * represents a FileField in the browser. NOt fully supported end-to end as of
 * now. Needs some standardization
 */
var FileField = function() {
	AbstractInputField.call(this);
	/*
	 * some logic in fileUpload routine iterates thrua ll fields and looks for
	 * fiel field
	 */
	this.isFileField = true;
};

a = FileField.prototype = new AbstractInputField;

/**
 * interesting issue with Safari with a hard coded c:\fakepath!!!
 *
 * @param ele
 *            file dom element from which to get value
 * @returns file name
 */
a.getValueFromObject = function(ele) {
	return ele.value.replace(/^C:\\fakepath\\/i, '');
};

/**
 * TODO : this obviously does not work. file field value MUST be selected by th
 * euser as per browser security standard
 *
 * @param ele
 *            dom element
 * @param val
 *            value to be set to dom
 */
a.setValueToObject = function(ele, val) {
	ele.value = val;
};

/**
 * password field is same as text field as far as we are concerned. Just the
 * rendering dom element is different
 */
var PasswordField = function() {
	TextInputField.call(this);
};


text:
module WmiLite
  class Wmi
    class Instance

      attr_reader :wmi_ole_object

      def initialize(wmi_ole_object)
        @wmi_ole_object = wmi_ole_object
        @property_map = wmi_ole_object_to_hash(wmi_ole_object)
      end

      def [](key)
        @property_map[key.downcase]
      end

      private

      def wmi_ole_object_to_hash(wmi_object)
        property_map = {}
        wmi_object.properties_.each do |property|
          property_map[property.name.downcase] = wmi_object.invoke(property.name)
        end

        @wmi_ole_object = wmi_object

        property_map.freeze
      end

    end
  end
end

redpajama_set_name: RedPajamaGithub


text:
c3bottles is compatible with Python 3.5 or newer. Please see `requirements.txt`
for the Python dependencies. c3bottles can run behind any WSGI compatible
webserver, be it Gunicorn, uWSGI or Apache. The usual deployment as shown in
the `Dockerfile` and `docker-compose.yml` uses Gunicorn behind an nginx reverse
proxy.

The state of all the drop points is maintained in a database, so you will need
a database that is supported by SQLAlchemy, e.g. SQLite or PostgreSQL. The
author uses PostgreSQL, therefore Psycopg2 is already included in
`requirements.txt` but most databases that are supported by SQLAlchemy should
work without any problem.

To build the frontend dependencies, you will need Node.js and yarn.

## Installation

1.  Clone the repository from Github:

        git clone https://github.com/c3bottles/c3bottles.git
        cd c3bottles

2.  Make sure all the dependencies are installed. The easiest way is to
    install them using `pip`:

        pip install -r requirements.txt

    If the installation fails, you are probably missing `libpython3-dev`,
    `libpq-dev` or `libffi-dev`.

    If you would like to use a virtualenv, a Makefile has already been
    prepared, just type `make` to create it and install all dependencies.

3.  Fetch the frontend dependencies and build everything:

        yarn
        yarn build

4.  Create a configuriation file `config.py`. You will find a template for
    the configuration in the file `config.default.py`. Although c3bottles will
    work if no `config.py` with the required settings is present, it is
    recommended to set at least `SECRET_KEY` and `SQLALCHEMY_DATABASE_URI`.

5.  Configure your database accordingly. The user for c3bottles needs full
    access to the database. If you use SQLite, the web server needs write
    access to the directory containing the `*.db` file and to the file itself.

6.  Initialize the database:

        ./manage.py initdb

7.  In order to use c3bottles, you need to create at least one admin user:

        ./manage.py user create

    User management can be done via the admin web interface but most user
    management tasks are available via the command line interface as well.
    `./manage.py user --help` provides the details.

8.  For testing purposes, you can run c3bottles with the development web
    server included in Flask:

        ./manage.py run

    However, if you want to use c3bottles in a production environment, it is
    strongly advised to use a proper web server like lined out below.

## Web server configuration

c3bottles can be used behind any WSGI compatible web server. Some options and
configuration examples are described here. If you encounter problems with
modules not being found, please have a look in `wsgi.py` end uncomment the
modifications to the module search path.

### Gunicorn (+nginx)

Install Gunicorn and then simply run `gunicorn --bind 127.0.0.1:5000 wsgi` or
similar from the c3bottles base directory. It is recommended to use nginx
as a reverse proxy together with Gunicorn handling the dynamic part whereas
nginx serves the static content. This can be achieved with an nginx server
configuration like this:

    server {
      root /path/to/c3bottles;
      location / {
        try_files $uri @proxy_to_app;
      }
      location @proxy_to_app {
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_set_header Host $http_host;
        proxy_redirect off;
        proxy_pass http://127.0.0.1:5000;
      }
    }

### Apache

To use c3bottles with Apache, you need `mod_wsgi` for Python 3 (in Debian:
`libapache2-mod-wsgi-py3`) and in your virtual host, you need to add a
configuration like this:

    WSGIScriptAlias / /path/to/c3bottles/wsgi.py
    WSGIApplicationGroup %{GLOBAL}
    Alias /static /path/to/c3bottles/static

If your Python libraries are installed inside a virtualenv, `WSGIPythonHome`
has to be set accordingly. Please keep in mind that this is a global setting
of Apache.

### uWSGI

A sample uWSGI configuration file could look like this:

    [uwsgi]
    socket = /tmp/c3bottles.sock
    venv = /srv/c3bottles/venv
    chdir = /srv/c3bottles/
    wsgi-file = wsgi.py
    callable = c3bottles

## Prometheus

If you use Prometheus to collect service metrics, just uncomment
`PROMETHEUS_ENABLED` in the configuration. This will start a Prometheus
exporter together with the WSGI server. By defaults, metrics are available
at [http://127.0.0.1:9567/](http://127.0.0.1:9567/).

## Map

c3bottles is only useful if a map has been configured. To do this, you have to
set a `MAP_SOURCE` in `config.py`. The different sources available are
implemented in `c3bottles/config/map.py`. If you do not want to redefine one of
the sources directly in the Python code, you can override single parameters of
the current source in `config.py`.

In general, c3bottles is able to use any map that can be configured as a layer
in [Leaflet](https://leafletjs.com/). Please see [MAP.md](MAP.md) for all
documentation regarding map sources, their parameters and how to define your
own.


text:
SoftUniAdsClient
================

Client application for the SoftUni Ads Web Services, using AngularJS


text:
import Transform from 'ember-data/transform';

export default Transform.extend({
    deserialize(serialized) {
        let _serialized = serialized === '' ? null : serialized;
        return JSON.parse(_serialized);
    },
    serialize(deserialized) {
        return deserialized ? JSON.stringify(deserialized) : null;
    }
});


text:
<!DOCTYPE html>

	<link href="js/bootstrap.min.css" rel="stylesheet"type="text/css">
	<link href="css/moncss.css" rel="stylesheet"type="text/css">

	<title>Comparison of database tools - Features - visual design and reverse engineering</title>
	<meta charset="utf-8">

Comparison of database tools - Features - visual design and reverse engineering

			<fieldset>

					<form action="" method="post">
						<legend style="color:red;font-weight: bold;font-style:italic;text-align: center;" >Formulaire</legend>

								Visual query builder :

 <input type="radio" name="FeatureVisual query builder" value="oui">Yes <input type="radio" name="FeatureVisual query builder" value = "non">No <input type="radio" name="FeatureVisual query builder" value = "non">Partial

											<input  style="display:none;" id ="id2Visual query builder"type="text"/>
										    <button class="btn btn-primary btn-xs" type="button" onClick="switchFunction('id1Visual query builder','id2Visual query builder');">Changer type</button>

								Visual schema/model/E-R diagram design :

 <input type="radio" name="FeatureVisual schema/model/E-R diagram design" value="oui">Yes <input type="radio" name="FeatureVisual schema/model/E-R diagram design" value = "non">No <input type="radio" name="FeatureVisual schema/model/E-R diagram design" value = "non">Partial

											<input  style="display:none;" id ="id2Visual schema/model/E-R diagram design"type="text"/>
										    <button class="btn btn-primary btn-xs" type="button" onClick="switchFunction('id1Visual schema/model/E-R diagram design','id2Visual schema/model/E-R diagram design');">Changer type</button>

								Forward engineering :

 <input type="radio" name="FeatureForward engineering" value="oui">Yes <input type="radio" name="FeatureForward engineering" value = "non">No <input type="radio" name="FeatureForward engineering" value = "non">Partial

											<input  style="display:none;" id ="id2Forward engineering"type="text"/>
										    <button class="btn btn-primary btn-xs" type="button" onClick="switchFunction('id1Forward engineering','id2Forward engineering');">Changer type</button>

								Reverse engineering :

 <input type="radio" name="FeatureReverse engineering" value="oui">Yes <input type="radio" name="FeatureReverse engineering" value = "non">No <input type="radio" name="FeatureReverse engineering" value = "non">Partial

											<input  style="display:none;" id ="id2Reverse engineering"type="text"/>
										    <button class="btn btn-primary btn-xs" type="button" onClick="switchFunction('id1Reverse engineering','id2Reverse engineering');">Changer type</button>

								ER diagram groupboxes :

 <input type="radio" name="FeatureER diagram groupboxes" value="oui">Yes <input type="radio" name="FeatureER diagram groupboxes" value = "non">No <input type="radio" name="FeatureER diagram groupboxes" value = "non">Partial

											<input  style="display:none;" id ="id2ER diagram groupboxes"type="text"/>
										    <button class="btn btn-primary btn-xs" type="button" onClick="switchFunction('id1ER diagram groupboxes','id2ER diagram groupboxes');">Changer type</button>

<input type="submit" class="btn btn-info" value="Ajouter un produit" />
					</form>

			</fieldset>


text:
```
This plugin was written to get it a slave redis is really connected properly to master server.
```

### Usage
```
python check_redis_slave.py -h
Usage: check_redis_slave.py [options]

Options:
  -h, --help  show this help message and exit
  -H HOST     Slave redis host address
  -P PORT     Redis tcp port, default 6379

```

### Sample Plugin Output
```
[ugur@test]# python check_redis_slave.py -H <slave-redis-host> -P 6383
OK: slave redis is connected properly to master|master_last_io_seconds_ago=4;0;0;0

If slave connectivty was broken due to some reasons that it raised an alert.

[ugur@test]# python check_redis_slave.py -H <slave-redis-host> -P 6383
Critical: slave redis server is failed to connect master.It is down!
```

### Tested with
```
Icinga2 + Redis 2.8.19 - Redis 3.2.1 Cluster
I think that it should be fine with the nagios based software.
```


text:
Preprocessing
=======================

This is a work in progress. However, the library has already implementations a few of the most used preprocessing techniques.

.. contents::
   :local:
   :backlinks: none

A preprocessor can be constructed by combining any number of these techniques, and is intended allow maximum configurability.

Usage
**************

First, we need to import ``construct_preprocessor``. This will take care of combining our preprocessors:

.. code:: python

    from nimblenet.preprocessing import construct_preprocessor

Next, we import the preprocessors we'd like to apply:

.. code:: python

    from nimblenet.preprocessing import replace_nan, standarize

Then, we combine the preprocessors. This is done by sending a list of preprocessors in addition to the dataset which we would like to fit the preprocessors againts. Note: this dataset should be the combined set of training, test and validation data.

.. code:: python

    preprocess = construct_preprocessor( dataset, [
                    ( replace_nan, {"replace_with": 0 }),
                    standardize
                ])

This constructed preprocessor can now be applied to your datasets. Let's take a look at how we can apply this to the XOR dataset:

.. code:: python

    from nimblenet.data_structures import Instance
    dataset              = [ Instance( [0,0], [0] ), Instance( [1,0], [1] ), Instance( [0,1], [1] ), Instance( [1,1], [0] ) ]
    preprocess           = construct_preprocessor( dataset, [
                                ( replace_nan, {"replace_with": 0 }),
                                standardize
                            ])
    preprocessed_dataset = preprocess( dataset )

Remember that if using a preprocessor before training the network, you will have to use the same preprocessor before using the network to predict based on new input signals.

.. important::

    The dataset given to ``construct_preprocessor`` should be the combined set of training, test and validation data.

Available preprocessors
************************

Standardize
^^^^^^^^^^^^^^^^^^^^^^

.. code:: python

    from nimblenet.preprocessing import standarize

Has no parameters.

Replace *NaN*
^^^^^^^^^^^^^^^^^^^^^^

.. code:: python

    from nimblenet.preprocessing import replace_nan

Takes an optional parameter ``replace_with``. By default, it replaces *NaN* with the mean of the given input signal.

In order to replace *NaN* with zero:

.. code:: python

    from nimblenet.preprocessing import construct_preprocessor, replace_nan
    from nimblenet.data_structures import Instance

    dataset    = [ Instance( [0,0], [0] ), Instance( [1,0], [1] ), Instance( [0,1], [1] ), Instance( [1,1], [0] ) ]
    preprocess = construct_preprocessor( dataset, [
                    ( replace_nan, {"replace_with": 0 }),
                ])

Subtract Mean
^^^^^^^^^^^^^^^^^^^^^^

.. code:: python

    from nimblenet.preprocessing import subtract_mean

Has no parameters.

Normalize
^^^^^^^^^^^^^^^^^^^^^^

.. code:: python

    from nimblenet.preprocessing import normalize

Has no parameters.

Whiten
^^^^^^^^^^^^^^^^^^^^^^

.. code:: python

    from nimblenet.preprocessing import whiten

Takes an optional parameter ``epsilon``. By default, epsilon equals ``1e-5``.

In order to redefine epsilon to e.g 0.5:

.. code:: python

    from nimblenet.preprocessing import construct_preprocessor, whiten
    from nimblenet.data_structures import Instance

    dataset    = [ Instance( [0,0], [0] ), Instance( [1,0], [1] ), Instance( [0,1], [1] ), Instance( [1,1], [0] ) ]
    preprocess = construct_preprocessor( dataset, [
                    ( whiten, {"epsilon": 0.5 }),
                ])


text:
Bartender
=========

This is a library to simplify coding with [go-kit](https://github.com/go-kit/kit),
especially with [endpoint](https://github.com/go-kit/kit/blob/master/endpoint/endpoint.go).

Currently only working on Endpoint related helper functions / types.
May add something else in the future.


text:
package com.moilioncircle.mysql.parser;

import com.moilioncircle.mysql.tokenizer.MysqlScanner;
import com.moilioncircle.mysql.tokenizer.Token;

import static com.moilioncircle.mysql.tokenizer.TokenTag.*;

/**
 * Operator Precedence
 * INTERVAL
 * BINARY, COLLATE
 * !
 * - (unary minus), ~ (unary bit inversion)
 * ^
 * *, /, DIV, %, MOD
 * -, +
 * <<, >>
 * &
 * |
 * = (comparison), <=>, >=, >, <=, <, <>, !=, IS, LIKE, REGEXP, IN
 * BETWEEN, CASE, WHEN, THEN, ELSE
 * NOT
 * AND, &&
 * XOR
 * OR, ||
 * = (assignment), :=
 *
 * The shunting yard algorithm
 * [href = http://www.engr.mun.ca/~theo/Misc/exp_parsing.htm ]
 */
public class ExprParser extends AbstractParser {

    public ExprParser(MysqlScanner scanner) {
        super(scanner);
    }
    /**
     * expr =
     *                         NOT expr expr'
     *                       | ! expr expr'
     *                       | boolean_primary IS [NOT] {TRUE | FALSE | UNKNOWN} expr'
     *                       | boolean_primary expr'
     */
    public void parseExpr() {
        switch (token().tag){
            case NOT:
                accept(NOT);
                parseExpr();
                break;
            case BIT_OR:
                accept(BIT_OR);
                parseExpr();
                break;
            default:
                parseBooleanPrimary();
                if(token().tag == IS){
                    accept(IS);
                    acceptIf(NOT);
                    Token tok = acceptOr(TRUE,FALSE, UNKNOWN);
                }
                break;
        }
        parseExprRest();
    }

    /**
     * expr'=
     *                         OR expr expr'
     *                       | '||' expr expr'
     *                       | XOR expr expr'
     *                       | AND expr expr'
     *                       | && expr expr'
     *                       | ε
     */
    public void parseExprRest(){
        switch (token().tag){
            case OR:
                accept(OR);
                parseExpr();
                parseExprRest();
                break;
            case BOBO:
                accept(BOBO);
                parseExpr();
                parseExprRest();
                break;
            case XOR:
                accept(XOR);
                parseExpr();
                parseExprRest();
                break;
            case AND:
                accept(AND);
                parseExpr();
                parseExprRest();
                break;
            case BABA:
                accept(BABA);
                parseExpr();
                parseExprRest();
                break;
            default:
                break;
        }
    }

    /**
     * boolean_primary=
     *                         predicate boolean_primary'
     *
     */
    public void parseBooleanPrimary(){
        parsePredicate();
        parseBooleanPrimaryRest();
    }

    /**
     * boolean_primary'=
     *                         IS [NOT] NULL boolean_primary'
     *                       | <=> predicate boolean_primary'
     *                       | comparison_operator predicate boolean_primary'
     *                       | comparison_operator {ALL | ANY} (subquery) boolean_primary'
     *                       | ε
     *
     */
    public void parseBooleanPrimaryRest(){
        switch (token().tag) {
            case IS:
                accept(IS);
                acceptIf(NOT);
                accept(NULL);
                parseBooleanPrimaryRest();
                break;
            case LTEQGT:
                accept(LTEQGT);
                parsePredicate();
                parseBooleanPrimaryRest();
                break;
            default:
                if (isComparisonOperator()) {
                    parseComparisonOperator();
                    if(token().tag == ALL || token().tag == ANY){
                        acceptOr(ALL,ANY);
                        accept(LPAREN);
                        parseSubQuery();
                        accept(RPAREN);
                        parseBooleanPrimaryRest();
                    }else{
                        parsePredicate();
                        parseBooleanPrimaryRest();
                    }
                }
                break;
        }
    }

    /**
     * comparison_operator=
     *                         =
     *                       | >=
     *                       | >
     *                       | <=
     *                       | <
     *                       | <>
     *                       | !=
     */
    public Token parseComparisonOperator(){
        switch (token().tag){
            case EQUAL:
                return accept(EQUAL);
            case GE:
                return accept(GE);
            case GT:
                return accept(GT);
            case LE:
                return accept(LE);
            case LT:
                return accept(LT);
            case LTGT:
                return accept(LTGT);
            case NOT_EQ:
                return accept(NOT_EQ);
            default:
                reportSyntaxError("Expected but"+token().tag);
                return null;
        }
    }

    private boolean isComparisonOperator() {
        switch (token().tag) {
            case EQUAL:
            case GE:
            case GT:
            case LE:
            case LT:
            case LTGT:
            case NOT_EQ:
                return true;
            default:
                return false;
        }
    }

    /**
     * predicate=
     *                         bit_expr [NOT] IN (subquery)
     *                       | bit_expr [NOT] IN (expr [, expr] ...)
     *                       | bit_expr [NOT] BETWEEN bit_expr AND predicate
     *                       | bit_expr SOUNDS LIKE bit_expr
     *                       | bit_expr [NOT] LIKE simple_expr [ESCAPE simple_expr]
     *                       | bit_expr [NOT] REGEXP bit_expr
     *                       | bit_expr
     */
    public void parsePredicate(){
        parseBitExpr();
        loop:
        while (true) {
            switch (token().tag) {
                case NOT:
                    accept(NOT);
                    if (token().tag == IN || token().tag == BETWEEN || token().tag == LIKE || token().tag == REGEXP) {
                        continue loop;
                    } else {
                        reportSyntaxError("Expected but" + token().tag);
                    }
                case IN:
                    accept(IN);
                    accept(LPAREN);
                    if (token().tag == SELECT) {
                        parseSubQuery();
                    } else {
                        do {
                            parseExpr();
                        } while (tokenIs(COMMA));
                    }
                    accept(RPAREN);
                    break loop;
                case BETWEEN:
                    accept(BETWEEN);
                    parseBitExpr();
                    accept(AND);
                    parsePredicate();
                    break loop;
                case SOUNDS:
                    acceptN(SOUNDS,LIKE);
                    parseBitExpr();
                    break loop;
                case LIKE:
                    //LIKE simple_expr [ESCAPE simple_expr]
                    accept(LIKE);
                    parseSimpleExpr();
                    if(token().tag == ESCAPE){
                        accept(ESCAPE);
                        parseSimpleExpr();
                    }
                    break loop;
                case REGEXP:
                    //REGEXP bit_expr
                    accept(REGEXP);
                    parseBitExpr();
                    break loop;
                default:
                    break loop;
            }
        }

    }

    /**
     * bit_expr=
     *                         simple_expr bit_expr'
     */
    public void parseBitExpr(){
        parseSimpleExpr();
        parseBitExprRest();
    }

    /**
     * bit_expr'=
     *                         '|' bit_expr bit_expr'
     *                       | & bit_expr bit_expr'
     *                       | << bit_expr bit_expr'
     *                       | >> bit_expr bit_expr'
     *                       | + bit_expr bit_expr'
     *                       | - bit_expr bit_expr'
     *                       | * bit_expr bit_expr'
     *                       | / bit_expr bit_expr'
     *                       | DIV bit_expr bit_expr'
     *                       | MOD bit_expr bit_expr'
     *                       | % bit_expr bit_expr'
     *                       | ^ bit_expr bit_expr'
     *                       | ε
     *
     *
     *                       | + interval_expr bit_expr' // DON'T SUPPORT
     *                       | - interval_expr bit_expr' // DON'T SUPPORT
     *
     */
    public void parseBitExprRest(){
        switch (token().tag){
            case BIT_OR:
                accept(BIT_OR);
                parseBitExpr();
                parseBitExprRest();
                break;
            case BIT_AND:
                accept(BIT_AND);
                parseBitExpr();
                parseBitExprRest();
                break;
            case LTLT:
                accept(LTLT);
                parseBitExpr();
                parseBitExprRest();
                break;
            case PLUS:
                accept(PLUS);
                parseBitExpr();
                parseBitExprRest();
                break;
            case MINUS:
                accept(MINUS);
                parseBitExpr();
                parseBitExprRest();
                break;
            case STAR:
                accept(STAR);
                parseBitExpr();
                parseBitExprRest();
                break;
            case SLASH:
                accept(SLASH);
                parseBitExpr();
                parseBitExprRest();
                break;
            case DIV:
                accept(DIV);
                parseBitExpr();
                parseBitExprRest();
                break;
            case MOD:
                accept(MOD);
                parseBitExpr();
                parseBitExprRest();
                break;
            case REMAINDER:
                accept(REMAINDER);
                parseBitExpr();
                parseBitExprRest();
                break;
            case EOR:
                accept(EOR);
                parseBitExpr();
                parseBitExprRest();
                break;
            default:
                break;
        }
    }

    /**
     * simple_expr=
     *                         literal simple_expr'
     *                       | identifier simple_expr'
     *                       | function_call simple_expr'
     *                       | param_marker simple_expr'
     *                       | + simple_expr simple_expr'
     *                       | - simple_expr simple_expr'
     *                       | ~ simple_expr simple_expr'
     *                       | ! simple_expr simple_expr'
     *                       | BINARY simple_expr simple_expr'
     *                       | (expr [, expr] ...) simple_expr'
     *                       | ROW (expr, expr [, expr] ...) simple_expr'
     *                       | (subquery) simple_expr'
     *                       | EXISTS (subquery) simple_expr'
     *
     *
     *                       | case_expr simple_expr' // DON'T SUPPORT for now
     *                       | match_expr simple_expr' // DON'T SUPPORT
     *                       | interval_expr simple_expr' // DON'T SUPPORT
     *                       | {identifier expr} simple_expr' // DON'T SUPPORT
     *                       | variable simple_expr' // DON'T SUPPORT
     */
    public void parseSimpleExpr() {
        switch (token().tag) {
            case IDENT:
                if (lookahead(LPAREN)) {
                    parseFunctionCall();
                } else {
                    String identifier = accept(IDENT).value;
                }
                break;
            case STRING:
            case NUMBER:
            case TRUE:
            case FALSE:
            case BIT_VALUE:
            case HEX_VALUE:
            case NULL:
                parseLiteral();
                break;
            case PARAM_MARKER:
                accept(PARAM_MARKER);
                break;
            case MINUS:
                accept(MINUS);
                //实际上是UNARY_MINUS
                parseSimpleExpr();
                break;
            case PLUS:
                accept(PLUS);
                //实际上是UNARY_PLUS
                parseSimpleExpr();
                break;
            case NOT_OPERATOR:
                accept(NOT_OPERATOR);
                //实际上是UNARY_NOT_OPERATOR
                parseSimpleExpr();
                break;
            case UNARY_BIT:
                accept(UNARY_BIT);
                //实际上是UNARY_BIT
                parseSimpleExpr();
                break;
            case BINARY:
                accept(BINARY);
                parseSimpleExpr();
                break;
            case LPAREN:
                if(lookahead(SELECT)){
                    accept(LPAREN);
                    parseSubQuery();
                    accept(RPAREN);
                }else{
                    accept(LPAREN);
                    do{
                        parseExpr();
                    }while(tokenIs(COMMA));
                    accept(RPAREN);
                }
                break;
            case ROW:
                accept(ROW);
                accept(LPAREN);
                do{
                    parseExpr();
                }while(tokenIs(COMMA));
                accept(RPAREN);
                break;
            case EXISTS:
                accept(EXISTS);
                accept(LPAREN);
                parseSubQuery();
                accept(RPAREN);
                break;
            default:
                reportSyntaxError("Expected but "+token().tag);

        }
        parseSimpleExprRest();
    }

    /**
     * simple_expr'=
     *                         COLLATE collation_name simple_expr'
     *                       | '||' simple_expr simple_expr'
     *                       | ε
     *
     */
    public void parseSimpleExprRest(){
        switch (token().tag){
            case COLLATE:
                accept(COLLATE);
                String collationName = accept(IDENT).value;
                parseSimpleExprRest();
                break;
            case BOBO:
                accept(BOBO);
                parseSimpleExpr();
                parseSimpleExprRest();
                break;
            default:
                break;
        }
    }

    private void parseSubQuery() {
        //TODO
    }

    private void parseLiteral(){
        switch (token().tag){
            case STRING:
                accept(STRING);
                break;
            case NUMBER:
                accept(NUMBER);
                break;
            case HEX_VALUE:
                accept(HEX_VALUE);
                break;
            case BIT_VALUE:
                accept(BIT_VALUE);
                break;
            case TRUE:
                accept(TRUE);
                break;
            case FALSE:
                accept(FALSE);
                break;
            case NULL:
                accept(NULL);
                break;
            default:
                reportSyntaxError("Expected but "+token().tag);
        }
    }

    private void parseFunctionCall(){
        // identifier(expr,expr....)
        String functionName = accept(IDENT).value;
        accept(LPAREN);
        do{
            parseExpr();
        }while(tokenIs(COMMA));
        accept(RPAREN);
    }

    public static void main(String[] args) {
        String expr = "abc is not null";
        MysqlScanner scanner = new MysqlScanner(expr.toCharArray());
        ExprParser parser = new ExprParser(scanner);
        parser.parseExpr();
    }
}


text:
<?php

namespace Sylius\Bundle\ProductBundle\Controller;

use Sylius\Bundle\ResourceBundle\Controller\ResourceController;
use Sylius\Component\Product\Builder\PrototypeBuilderInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;

/**
 * Prototype controller.
 *
 * @author Paweł Jędrzejewski <pjedrzejewski@sylius.pl>
 */
class PrototypeController extends ResourceController
{
    /**
     * Build a product from the given prototype.
     * Everything else works exactly like in product
     * creation action.
     *
     * @param Request $request
     * @param mixed   $id
     *
     * @return Response
     */
    public function buildAction(Request $request, $id)
    {
        $prototype = $this->findOr404($request, array('id' => $id));
        $productController = $this->getProductController();

        $product = $productController->createNew();

        $this
            ->getBuilder()
            ->build($prototype, $product)
        ;

        $form = $productController->getForm($product);

        if ($request->isMethod('POST') && $form->submit($request)->isValid()) {
            $manager = $this->get('doctrine')->getManager();
            $manager->persist($product);
            $manager->flush();

            $this->flashHelper->setFlash('success', 'Product has been successfully created.');

            return $this->redirectHandler->redirectTo($product);
        }

        return $productController->render($this->config->getTemplate('build.html'), array(
            'product_prototype' => $prototype,
            'product'           => $product,
            'form'              => $form->createView()
        ));
    }

    /**
     * Get product controller.
     *
     * @return Controller
     */
    protected function getProductController()
    {
        return $this->get('sylius.controller.product');
    }

    /**
     * Get prototype builder.
     *
     * @return PrototypeBuilderInterface
     */
    protected function getBuilder()
    {
        return $this->get('sylius.builder.product_prototype');
    }
}


text:
package redis.commands

import redis.{ByteStringDeserializer, Request}
import scala.concurrent.Future
import scala.concurrent.duration._
import redis.api.blists._

/**
 * Blocking commands on the Lists
 */
trait BLists extends Request {

  // TODO Future[Option[(KK, ByteString)]]
  def blpop[R: ByteStringDeserializer](keys: Seq[String], timeout: FiniteDuration = Duration.Zero): Future[Option[(String, R)]] =
    send(Blpop(keys, timeout))

  def brpop[R: ByteStringDeserializer](keys: Seq[String], timeout: FiniteDuration = Duration.Zero): Future[Option[(String, R)]] =
    send(Brpop(keys, timeout))

  def brpopplush[R: ByteStringDeserializer](source: String, destination: String, timeout: FiniteDuration = Duration.Zero): Future[Option[R]] =
    send(Brpopplush(source, destination, timeout))
}


text:
<?php
namespace fizk\DirectoryHash;

use fizk\DirectoryHash\Hash;
use fizk\DirectoryHash\FileHash;

class PHPHash implements Hash, FileHash {
    protected $algo;

    public function __construct($algo) {
        $this->algo = $algo;
    }

    public function hash($data) {
        return hash($this->algo, $data);
    }

    public function hash_file($filename) {
        return hash_file($this->algo, $filename);
    }
}


text:
<?xml version="1.0" encoding="UTF-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements.  See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License.  You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed  under the  License is distributed on an "AS IS" BASIS,
WITHOUT  WARRANTIES OR CONDITIONS  OF ANY KIND, either  express  or
implied.

See the License for the specific language governing permissions and
limitations under the License.
-->
<portlet-app version="1.0" xmlns="http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd">

    <portlet>
        <description>AboutPortletDescription</description>
        <portlet-name>AboutPortlet</portlet-name>
        <display-name>About Portlet</display-name>

        <portlet-class>org.apache.pluto.driver.portlets.AboutPortlet</portlet-class>
        <supports>
            <mime-type>text/html</mime-type>
            <portlet-mode>VIEW</portlet-mode>
            <portlet-mode>EDIT</portlet-mode>
            <portlet-mode>HELP</portlet-mode>
        </supports>
        <portlet-info>
            <title>About Apache Pluto</title>
        </portlet-info>
    </portlet>

    <portlet>
        <description>AdminPortletDescription</description>
        <portlet-name>AdminPortlet</portlet-name>
        <display-name>Admin Portlet</display-name>
        <portlet-class>org.apache.pluto.driver.portlets.AdminPortlet</portlet-class>
        <supports>
            <mime-type>text/html</mime-type>
            <portlet-mode>VIEW</portlet-mode>
            <portlet-mode>EDIT</portlet-mode>
            <portlet-mode>HELP</portlet-mode>
        </supports>
        <portlet-info>
            <title>Apache Pluto Portal Admin</title>
        </portlet-info>
    </portlet>

    <portlet>
        <description>Used to administer pluto pages</description>
        <portlet-name>PlutoPageAdmin</portlet-name>
        <display-name>Pluto Page Administration Portlet</display-name>
        <portlet-class>org.apache.pluto.driver.portlets.PageAdminPortlet</portlet-class>
        <supports>
            <mime-type>text/html</mime-type>
            <portlet-mode>VIEW</portlet-mode>
            <portlet-mode>EDIT</portlet-mode>
            <portlet-mode>HELP</portlet-mode>
        </supports>
        <portlet-info>
            <title>Pluto Page Administrator</title>
        </portlet-info>
    </portlet>
</portlet-app>


text:
package org.micro.neural.circuitbreaker;

/**
 * The Circuit Breaker State
 *
 * @author lry
 */
public enum CircuitBreakerState {

    /**
     * working normally, calls are transparently passing through
     */
    CLOSED,

    /**
     * method calls are being intercepted and CircuitBreakerExceptions are being thrown instead
     */
    OPEN,

    /**
     * method calls are passing through;
     * if another blacklisted exception is thrown, reverts back to OPEN
     */
    HALF_OPEN;

}


text:
#region Header
using System;
using System.Windows.Forms;
using System.Drawing;

using Fairweather.Service;

using Colors = Standardization.Colors;
using IOPair = Fairweather.Service.Pair<System.Action<string>, System.Func<string>>;

#endregion
/*       All future control standardization efforts go here        */
namespace Standardization
{
    static partial class Standard
    {
        /*       Todo:        */

        // also take care of the maximum length of the various text fields

        const string cst_decimal_format = "F2";
        const int cst_decimal_precision = 2;

        static public string Standard_String(this decimal dec) {

            var ret = dec.ToString(cst_decimal_format);
            return ret;

        }

        static public decimal Standard_Parse(this string to_dec) {

            var ret = to_dec.DecimalOrZero(cst_decimal_precision);
            return ret;

        }
    }
}


text:
/*
 * @test
 * @bug 6256805
 * @summary Tests invalid XML characters encoding
 * @author Sergey Malenkov
 */

public final class Test6256805 extends AbstractTest {
    public static void main(String[] args) {
        new Test6256805().test(true);
    }

    protected CharacterBean getObject() {
        CharacterBean bean = new CharacterBean();
        bean.setString("\u0000\ud800\udc00\uFFFF");
        return bean;
    }

    protected CharacterBean getAnotherObject() {
        CharacterBean bean = new CharacterBean();
        bean.setPrimitive('\uD800');
        bean.setChar(Character.valueOf('\u001F'));
        return bean;
    }

    public static final class CharacterBean {
        private char primitive;
        private Character character;
        private String string;

        public char getPrimitive() {
            return this.primitive;
        }

        public void setPrimitive( char primitive ) {
            this.primitive = primitive;
        }

        public Character getChar() {
            return this.character;
        }

        public void setChar( Character character ) {
            this.character = character;
        }

        public String getString() {
            return this.string;
        }

        public void setString( String string ) {
            this.string = string;
        }
    }
}


text:
using namespace filesystem;
using namespace chrono;
using std::cout;
using std::endl;

int main(int argc, char** argv) {
#if defined(WIN32)
    path path1("C:\\dir 1\\dir 2\\");
#else
    path path1("/dir 1/dir 2/");
#endif

    path path2("dir 3");

    cout << path1.exists() << endl;
    cout << path1 << endl;
    cout << (path1 / path2) << endl;
    cout << (path1 / path2).parent_path() << endl;
    cout << (path1 / path2).parent_path().parent_path() << endl;
    cout << (path1 / path2).parent_path().parent_path().parent_path() << endl;
    cout << (path1 / path2).parent_path().parent_path().parent_path().parent_path() << endl;
    cout << path().parent_path() << endl;
    cout << endl;

    // Absolute path of current directory
    cout << "Current directory = " << path(".").make_absolute() << endl;
    cout << endl;

    // Create output directory and output file
    std::string out_dir = GetChronoOutputPath() + "DEMO_FILESYSTEM";
    std::string out_file = out_dir + "/foo.txt";

    cout << "Create output directory;  out_dir = " << out_dir << endl;
    cout << "  out_dir exists? " << path(out_dir).exists() << endl;
    if (create_directory(path(out_dir))) {
        cout << "  ...Created output directory" << endl;
    } else {
        cout << "  ...Error creating output directory" << endl;
        return 1;
    }
    cout << "  out_dir exists? " << path(out_dir).exists() << endl;
    cout << "  out_dir is directory? " << path(out_dir).is_directory() << endl;
    cout << "  path of out_dir: " << path(out_dir) << endl;
    cout << "  abs. path of out_dir: " << path(out_dir).make_absolute() << endl;
    cout << endl;

    cout << "Create output file;  out_file = " << out_file << endl;
    cout << "  out_file exists? " << path(out_file).exists() << endl;
    utils::CSV_writer csv(",");
    csv << ChVector<>(1, 2, 3) << ChQuaternion<>(1, 0, 0, 0) << endl;
    csv.write_to_file(out_file);
    cout << "  ...Created output file" << endl;
    cout << "  out_file exists? " << path(out_file).exists() << endl;
    cout << "  out_file is file? " << path(out_file).is_file() << endl;
    cout << "  path of out_file: " << path(out_file) << endl;
    cout << "  abs. path of out_file: " << path(out_file).make_absolute() << endl;
    cout << endl;

    // Create hierarchy of nested directories
#if defined(WIN32)
    std::string nested = out_dir + "\\child\\grandchild";
#else
    std::string nested = out_dir + "/child/grandchild";
#endif
    cout << "Create nested directories;  nested = " << nested << endl;
    cout << "  nested (as path)   = " << path(nested) << endl;
    cout << "  length of nested   = " << path(nested).length() << endl;
    cout << "  nested exists? " << path(nested).exists() << endl;
    if (create_subdirectory(path(nested))) {
        cout << "  ...Created nested subdirectories" << endl;
    } else {
        cout << "  ...Error creating subdirectories" << endl;
        return 1;
    }
    cout << "  nested exists? " << path(nested).exists() << endl;
    cout << "  nested is directory? " << path(nested).is_directory() << endl;
    cout << "  path of nested: " << path(nested) << endl;
    cout << "  abs. path of nested: " << path(nested).make_absolute() << endl;
    cout << endl;

    // Other tests

    cout << "some/path.ext:operator==() = " << (path("some/path.ext") == path("some/path.ext")) << endl;
    cout << "some/path.ext:operator==() (unequal) = " << (path("some/path.ext") == path("another/path.ext")) << endl;

    cout << "nonexistant:exists = " << path("nonexistant").exists() << endl;
    cout << "nonexistant:is_file = " << path("nonexistant").is_file() << endl;
    cout << "nonexistant:is_directory = " << path("nonexistant").is_directory() << endl;
    cout << "nonexistant:filename = " << path("nonexistant").filename() << endl;
    cout << "nonexistant:extension = " << path("nonexistant").extension() << endl;
    cout << endl;

    cout << "out_file:exists = " << path(out_file).exists() << endl;
    cout << "out_file:is_file = " << path(out_file).is_file() << endl;
    cout << "out_file:is_directory = " << path(out_file).is_directory() << endl;
    cout << "out_file:filename = " << path(out_file).filename() << endl;
    cout << "out_file:stem = " << path(out_file).stem() << endl;
    cout << "out_file:extension = " << path(out_file).extension() << endl;
    cout << "out_file:make_absolute = " << path(out_file).make_absolute() << endl;
    cout << endl;

    cout << "out_dir:exists = " << path(out_dir).exists() << endl;
    cout << "out_dir:is_file = " << path(out_dir).is_file() << endl;
    cout << "out_dir:is_directory = " << path(out_dir).is_directory() << endl;
    cout << "out_dir:filename = " << path(out_dir).filename() << endl;
    cout << "out_dir:stem = " << path(out_dir).stem() << endl;
    cout << "out_dir:extension = " << path(out_dir).extension() << endl;
    cout << "out_dir:make_absolute = " << path(out_dir).make_absolute() << endl;
    cout << endl;

    cout << "resolve(out_file) = " << resolver().resolve(out_file) << endl;
    cout << "resolve(nonexistant) = " << resolver().resolve("nonexistant") << endl;
    return 0;
}


text:
@implementation UISearchBar (LYXShowsCancelButton)

+ (void)load {
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        Class class = [self class];

        SEL sel1 = NSSelectorFromString(@"setShowsCancelButton:");
        SEL sel2 = NSSelectorFromString(@"mrc_setShowsCancelButton:");

        Method m1 = class_getInstanceMethod(class, sel1);
        Method m2 = class_getInstanceMethod(class, sel2);

        IMP imp1 = class_getMethodImplementation(class, sel1);
        if (imp1 != NULL) {
            method_exchangeImplementations(m1, m2);
        }

        SEL sel3 = NSSelectorFromString(@"setShowsCancelButton:animated:");
        SEL sel4 = NSSelectorFromString(@"mrc_setShowsCancelButton:animated:");

        Method m3 = class_getInstanceMethod(class, sel3);
        Method m4 = class_getInstanceMethod(class, sel4);

        IMP imp3 = class_getMethodImplementation(class, sel3);
        if (imp3 != NULL) {
            method_exchangeImplementations(m3, m4);
        }
    });
}

- (void)mrc_setShowsCancelButton:(BOOL)showsCancelButton {}

- (void)mrc_setShowsCancelButton:(BOOL)showsCancelButton animated:(BOOL)animated {}

@end


text:
import * as recipeCalculation from '../src/index'

describe('recipeCalculation', () => {
  it('exports the correct functions', () => {
    expect(Object.keys(recipeCalculation)).toEqual([
      'cheapestTree',
      'craftingSteps',
      'dailyCooldowns',
      'recipeItems',
      'useVendorPrices',
      'updateTree',
      'usedItems',
      'staticItems',
    ])

    expect(Object.keys(recipeCalculation.staticItems)).toEqual([
      'dailyCooldowns',
      'buyableDailyCooldowns',
      'vendorItems',
    ])

    expect(recipeCalculation.staticItems.dailyCooldowns).toBeDefined()
    expect(recipeCalculation.staticItems.buyableDailyCooldowns).toBeDefined()
    expect(recipeCalculation.staticItems.vendorItems).toBeDefined()
  })
})


text:
location: 'Sé Nova - Coimbra '
title: 'Orquestra Clássica do Centro '
description: 'Orquestra Clássica do Centro ; Quarteto Vintage ; Direção: Sergio Alapont '
descriptionEn: 'Orquestra Clássica do Centro ; Vintage Quartet ; Direction: Sergio Alapont '
url: >-
  https://www.orquestraclassicadocentro.org/events/concerto-250-anos-musica-portuguesa/
dateTime: '11/13/2022 16:30 PM'
---