text:
/* ----------------------------------------------------------------------------------
 * Hint: This is a derived (generated) file. Changes should be done in the underlying
 * source files only (*.control, *.js) or they will be lost after the next generation.
 * ---------------------------------------------------------------------------------- */

// Provides control sap.m.ActionSheet.
jQuery.sap.declare("sap.m.ActionSheet");
jQuery.sap.require("sap.m.library");
jQuery.sap.require("sap.ui.core.Control");

/**
 * Constructor for a new ActionSheet.
 *
 * Accepts an object literal mSettings that defines initial
 * property values, aggregated and associated objects as well as event handlers.
 *
 * If the name of a setting is ambiguous (e.g. a property has the same name as an event),
 * then the framework assumes property, aggregation, association, event in that order.
 * To override this automatic resolution, one of the prefixes "aggregation:", "association:"
 * or "event:" can be added to the name of the setting (such a prefixed name must be
 * enclosed in single or double quotes).
 *
 * The supported settings are:
 *

 *
Properties
 *

 *
{@link #getPlacement placement} : sap.m.PlacementType (default: sap.m.PlacementType.Bottom)

 *
{@link #getShowCancelButton showCancelButton} : boolean (default: true)

 *
{@link #getCancelButtonText cancelButtonText} : string

 *
{@link #getTitle title} : string

 *

 *
Aggregations
 *

 *
{@link #getButtons buttons} : sap.m.Button[]

 *

 *
Associations
 *

 *

 *
Events
 *

 *
{@link sap.m.ActionSheet#event:cancelButtonTap cancelButtonTap} : fnListenerFunction or [fnListenerFunction, oListenerObject] or [oData, fnListenerFunction, oListenerObject]

 *
{@link sap.m.ActionSheet#event:beforeOpen beforeOpen} : fnListenerFunction or [fnListenerFunction, oListenerObject] or [oData, fnListenerFunction, oListenerObject]

 *
{@link sap.m.ActionSheet#event:afterOpen afterOpen} : fnListenerFunction or [fnListenerFunction, oListenerObject] or [oData, fnListenerFunction, oListenerObject]

 *
{@link sap.m.ActionSheet#event:beforeClose beforeClose} : fnListenerFunction or [fnListenerFunction, oListenerObject] or [oData, fnListenerFunction, oListenerObject]

 *
{@link sap.m.ActionSheet#event:afterClose afterClose} : fnListenerFunction or [fnListenerFunction, oListenerObject] or [oData, fnListenerFunction, oListenerObject]

 *
{@link sap.m.ActionSheet#event:cancelButtonPress cancelButtonPress} : fnListenerFunction or [fnListenerFunction, oListenerObject] or [oData, fnListenerFunction, oListenerObject]

 *

 *

 *
 * @param {string} [sId] id for the new control, generated automatically if no id is given
 * @param {object} [mSettings] initial settings for the new control
 *
 * @class
 * ActionSheet is a special kind of control which contains one or more sap.m.Button(s) and the ActionSheet will be closed when one of the buttons is tapped. It looks similar as a sap.m.Dialog in iPhone and Android while as a sap.m.Popover in iPad.
 * @extends sap.ui.core.Control
 *
 * @author SAP AG
 * @version 1.22.5
 *
 * @constructor
 * @public
 * @since 1.9.1
 * @name sap.m.ActionSheet
 */
sap.ui.core.Control.extend("sap.m.ActionSheet", { metadata : {

	// ---- object ----
	publicMethods : [
		// methods
		"openBy", "close", "isOpen"
	],

	// ---- control specific ----
	library : "sap.m",
	properties : {
		"placement" : {type : "sap.m.PlacementType", group : "Appearance", defaultValue : sap.m.PlacementType.Bottom},
		"showCancelButton" : {type : "boolean", group : "Appearance", defaultValue : true},
		"cancelButtonText" : {type : "string", group : "Appearance", defaultValue : null},
		"title" : {type : "string", group : "Appearance", defaultValue : null}
	},
	aggregations : {
    	"buttons" : {type : "sap.m.Button", multiple : true, singularName : "button"},
    	"_cancelButton" : {type : "sap.m.Button", multiple : false, visibility : "hidden"}
	},
	events : {
		"cancelButtonTap" : {deprecated: true},
		"beforeOpen" : {},
		"afterOpen" : {},
		"beforeClose" : {},
		"afterClose" : {},
		"cancelButtonPress" : {}
	}
}});

/**
 * Creates a new subclass of class sap.m.ActionSheet with name sClassName
 * and enriches it with the information contained in oClassInfo.
 *
 * oClassInfo might contain the same kind of informations as described in {@link sap.ui.core.Element.extend Element.extend}.
 *
 * @param {string} sClassName name of the class to be created
 * @param {object} [oClassInfo] object literal with informations about the class
 * @param {function} [FNMetaImpl] constructor function for the metadata object. If not given, it defaults to sap.ui.core.ElementMetadata.
 * @return {function} the created class / constructor function
 * @public
 * @static
 * @name sap.m.ActionSheet.extend
 * @function
 */

sap.m.ActionSheet.M_EVENTS = {'cancelButtonTap':'cancelButtonTap','beforeOpen':'beforeOpen','afterOpen':'afterOpen','beforeClose':'beforeClose','afterClose':'afterClose','cancelButtonPress':'cancelButtonPress'};

/**
 * Getter for property placement.
 * The ActionSheet behaves as a sap.m.Popover in iPad and this property is the information about on which side will the popover be placed at. Possible values are sap.m.PlacementType.Left, sap.m.PlacementType.Right, sap.m.PlacementType.Top, sap.m.PlacementType.Bottom. The default value is sap.m.PlacementType.Bottom.
 *
 * Default value is Bottom
 *
 * @return {sap.m.PlacementType} the value of property placement
 * @public
 * @name sap.m.ActionSheet#getPlacement
 * @function
 */

/**
 * Setter for property placement.
 *
 * Default value is Bottom
 *
 * @param {sap.m.PlacementType} oPlacement  new value for property placement
 * @return {sap.m.ActionSheet} this to allow method chaining
 * @public
 * @name sap.m.ActionSheet#setPlacement
 * @function
 */

/**
 * Getter for property showCancelButton.
 * If this is set to true, there will be a cancel button shown below the action buttons. There won't be any cancel button shown in iPad regardless of this property. The default value is set to true.
 *
 * Default value is true
 *
 * @return {boolean} the value of property showCancelButton
 * @public
 * @name sap.m.ActionSheet#getShowCancelButton
 * @function
 */

/**
 * Setter for property showCancelButton.
 *
 * Default value is true
 *
 * @param {boolean} bShowCancelButton  new value for property showCancelButton
 * @return {sap.m.ActionSheet} this to allow method chaining
 * @public
 * @name sap.m.ActionSheet#setShowCancelButton
 * @function
 */

/**
 * Getter for property cancelButtonText.
 * This is the text displayed in the cancelButton. Default value is "Cancel", and it's translated according to the current locale setting. This property will be ignored when running either in iPad or showCancelButton is set to false.
 *
 * Default value is empty/undefined
 *
 * @return {string} the value of property cancelButtonText
 * @public
 * @name sap.m.ActionSheet#getCancelButtonText
 * @function
 */

/**
 * Setter for property cancelButtonText.
 *
 * Default value is empty/undefined
 *
 * @param {string} sCancelButtonText  new value for property cancelButtonText
 * @return {sap.m.ActionSheet} this to allow method chaining
 * @public
 * @name sap.m.ActionSheet#setCancelButtonText
 * @function
 */

/**
 * Getter for property title.
 * Title will be shown in the header area in iPhone and every Android
 * devices. This property will be ignored in tablets and desktop browser.
 *
 * Default value is empty/undefined
 *
 * @return {string} the value of property title
 * @public
 * @name sap.m.ActionSheet#getTitle
 * @function
 */

/**
 * Setter for property title.
 *
 * Default value is empty/undefined
 *
 * @param {string} sTitle  new value for property title
 * @return {sap.m.ActionSheet} this to allow method chaining
 * @public
 * @name sap.m.ActionSheet#setTitle
 * @function
 */

/**
 * Getter for aggregation buttons.

 * These buttons are added to the content area in ActionSheet control. When button is tapped, the ActionSheet is closed before the tap event listener is called.
 *
 * @return {sap.m.Button[]}
 * @public
 * @name sap.m.ActionSheet#getButtons
 * @function
 */

/**
 * Inserts a button into the aggregation named buttons.
 *
 * @param {sap.m.Button}
 *          oButton the button to insert; if empty, nothing is inserted
 * @param {int}
 *             iIndex the 0-based index the button should be inserted at; for
 *             a negative value of iIndex, the button is inserted at position 0; for a value
 *             greater than the current size of the aggregation, the button is inserted at
 *             the last position
 * @return {sap.m.ActionSheet} this to allow method chaining
 * @public
 * @name sap.m.ActionSheet#insertButton
 * @function
 */

/**
 * Adds some button oButton
 * to the aggregation named buttons.
 *
 * @param {sap.m.Button}
 *            oButton the button to add; if empty, nothing is inserted
 * @return {sap.m.ActionSheet} this to allow method chaining
 * @public
 * @name sap.m.ActionSheet#addButton
 * @function
 */

/**
 * Removes an button from the aggregation named buttons.
 *
 * @param {int | string | sap.m.Button} vButton the button to remove or its index or id
 * @return {sap.m.Button} the removed button or null
 * @public
 * @name sap.m.ActionSheet#removeButton
 * @function
 */

/**
 * Removes all the controls in the aggregation named buttons.

 * Additionally unregisters them from the hosting UIArea.
 * @return {sap.m.Button[]} an array of the removed elements (might be empty)
 * @public
 * @name sap.m.ActionSheet#removeAllButtons
 * @function
 */

/**
 * Checks for the provided sap.m.Button in the aggregation named buttons
 * and returns its index if found or -1 otherwise.
 *
 * @param {sap.m.Button}
 *            oButton the button whose index is looked for.
 * @return {int} the index of the provided control in the aggregation if found, or -1 otherwise
 * @public
 * @name sap.m.ActionSheet#indexOfButton
 * @function
 */

/**
 * Destroys all the buttons in the aggregation
 * named buttons.
 * @return {sap.m.ActionSheet} this to allow method chaining
 * @public
 * @name sap.m.ActionSheet#destroyButtons
 * @function
 */

/**
 * This event is fired when the cancelButton is tapped. For iPad, this event is also fired when showCancelButton is set to true, and Popover is closed by tapping outside.
 *
 * @name sap.m.ActionSheet#cancelButtonTap
 * @event
 * @deprecated Since version 1.20.0.
 * This event is deprecated, use the cancelButtonPress event instead.
 * @param {sap.ui.base.Event} oControlEvent
 * @param {sap.ui.base.EventProvider} oControlEvent.getSource
 * @param {object} oControlEvent.getParameters

 * @public
 */

/**
 * Attach event handler fnFunction to the 'cancelButtonTap' event of this sap.m.ActionSheet.
.
 * When called, the context of the event handler (its this) will be bound to oListener if specified
 * otherwise to this sap.m.ActionSheet.
 itself.
 *
 * This event is fired when the cancelButton is tapped. For iPad, this event is also fired when showCancelButton is set to true, and Popover is closed by tapping outside.
 *
 * @param {object}
 *            [oData] An application specific payload object, that will be passed to the event handler along with the event object when firing the event.
 * @param {function}
 *            fnFunction The function to call, when the event occurs.
 * @param {object}
 *            [oListener] Context object to call the event handler with. Defaults to this sap.m.ActionSheet.
 itself.
 *
 * @return {sap.m.ActionSheet} this to allow method chaining
 * @public
 * @deprecated Since version 1.20.0.
 * This event is deprecated, use the cancelButtonPress event instead.
 * @name sap.m.ActionSheet#attachCancelButtonTap
 * @function
 */

/**
 * Detach event handler fnFunction from the 'cancelButtonTap' event of this sap.m.ActionSheet.

 *
 * The passed function and listener object must match the ones used for event registration.
 *
 * @param {function}
 *            fnFunction The function to call, when the event occurs.
 * @param {object}
 *            oListener Context object on which the given function had to be called.
 * @return {sap.m.ActionSheet} this to allow method chaining
 * @public
 * @deprecated Since version 1.20.0.
 * This event is deprecated, use the cancelButtonPress event instead.
 * @name sap.m.ActionSheet#detachCancelButtonTap
 * @function
 */

/**
 * Fire event cancelButtonTap to attached listeners.
 *
 * @param {Map} [mArguments] the arguments to pass along with the event.
 * @return {sap.m.ActionSheet} this to allow method chaining
 * @protected
 * @deprecated Since version 1.20.0.
 * This event is deprecated, use the cancelButtonPress event instead.
 * @name sap.m.ActionSheet#fireCancelButtonTap
 * @function
 */

/**
 * This event will be fired before the ActionSheet is opened.
 *
 * @name sap.m.ActionSheet#beforeOpen
 * @event
 * @param {sap.ui.base.Event} oControlEvent
 * @param {sap.ui.base.EventProvider} oControlEvent.getSource
 * @param {object} oControlEvent.getParameters

 * @public
 */

/**
 * Attach event handler fnFunction to the 'beforeOpen' event of this sap.m.ActionSheet.
.
 * When called, the context of the event handler (its this) will be bound to oListener if specified
 * otherwise to this sap.m.ActionSheet.
 itself.
 *
 * This event will be fired before the ActionSheet is opened.
 *
 * @param {object}
 *            [oData] An application specific payload object, that will be passed to the event handler along with the event object when firing the event.
 * @param {function}
 *            fnFunction The function to call, when the event occurs.
 * @param {object}
 *            [oListener] Context object to call the event handler with. Defaults to this sap.m.ActionSheet.
 itself.
 *
 * @return {sap.m.ActionSheet} this to allow method chaining
 * @public
 * @name sap.m.ActionSheet#attachBeforeOpen
 * @function
 */

/**
 * Detach event handler fnFunction from the 'beforeOpen' event of this sap.m.ActionSheet.

 *
 * The passed function and listener object must match the ones used for event registration.
 *
 * @param {function}
 *            fnFunction The function to call, when the event occurs.
 * @param {object}
 *            oListener Context object on which the given function had to be called.
 * @return {sap.m.ActionSheet} this to allow method chaining
 * @public
 * @name sap.m.ActionSheet#detachBeforeOpen
 * @function
 */

/**
 * Fire event beforeOpen to attached listeners.
 *
 * @param {Map} [mArguments] the arguments to pass along with the event.
 * @return {sap.m.ActionSheet} this to allow method chaining
 * @protected
 * @name sap.m.ActionSheet#fireBeforeOpen
 * @function
 */

/**
 * This event will be fired after the ActionSheet is opened.
 *
 * @name sap.m.ActionSheet#afterOpen
 * @event
 * @param {sap.ui.base.Event} oControlEvent
 * @param {sap.ui.base.EventProvider} oControlEvent.getSource
 * @param {object} oControlEvent.getParameters

 * @public
 */

/**
 * Attach event handler fnFunction to the 'afterOpen' event of this sap.m.ActionSheet.
.
 * When called, the context of the event handler (its this) will be bound to oListener if specified
 * otherwise to this sap.m.ActionSheet.
 itself.
 *
 * This event will be fired after the ActionSheet is opened.
 *
 * @param {object}
 *            [oData] An application specific payload object, that will be passed to the event handler along with the event object when firing the event.
 * @param {function}
 *            fnFunction The function to call, when the event occurs.
 * @param {object}
 *            [oListener] Context object to call the event handler with. Defaults to this sap.m.ActionSheet.
 itself.
 *
 * @return {sap.m.ActionSheet} this to allow method chaining
 * @public
 * @name sap.m.ActionSheet#attachAfterOpen
 * @function
 */

/**
 * Detach event handler fnFunction from the 'afterOpen' event of this sap.m.ActionSheet.

 *
 * The passed function and listener object must match the ones used for event registration.
 *
 * @param {function}
 *            fnFunction The function to call, when the event occurs.
 * @param {object}
 *            oListener Context object on which the given function had to be called.
 * @return {sap.m.ActionSheet} this to allow method chaining
 * @public
 * @name sap.m.ActionSheet#detachAfterOpen
 * @function
 */

/**
 * Fire event afterOpen to attached listeners.
 *
 * @param {Map} [mArguments] the arguments to pass along with the event.
 * @return {sap.m.ActionSheet} this to allow method chaining
 * @protected
 * @name sap.m.ActionSheet#fireAfterOpen
 * @function
 */

/**
 * This event will be fired before the ActionSheet is closed.
 *
 * @name sap.m.ActionSheet#beforeClose
 * @event
 * @param {sap.ui.base.Event} oControlEvent
 * @param {sap.ui.base.EventProvider} oControlEvent.getSource
 * @param {object} oControlEvent.getParameters

 * @public
 */

/**
 * Attach event handler fnFunction to the 'beforeClose' event of this sap.m.ActionSheet.
.
 * When called, the context of the event handler (its this) will be bound to oListener if specified
 * otherwise to this sap.m.ActionSheet.
 itself.
 *
 * This event will be fired before the ActionSheet is closed.
 *
 * @param {object}
 *            [oData] An application specific payload object, that will be passed to the event handler along with the event object when firing the event.
 * @param {function}
 *            fnFunction The function to call, when the event occurs.
 * @param {object}
 *            [oListener] Context object to call the event handler with. Defaults to this sap.m.ActionSheet.
 itself.
 *
 * @return {sap.m.ActionSheet} this to allow method chaining
 * @public
 * @name sap.m.ActionSheet#attachBeforeClose
 * @function
 */

/**
 * Detach event handler fnFunction from the 'beforeClose' event of this sap.m.ActionSheet.

 *
 * The passed function and listener object must match the ones used for event registration.
 *
 * @param {function}
 *            fnFunction The function to call, when the event occurs.
 * @param {object}
 *            oListener Context object on which the given function had to be called.
 * @return {sap.m.ActionSheet} this to allow method chaining
 * @public
 * @name sap.m.ActionSheet#detachBeforeClose
 * @function
 */

/**
 * Fire event beforeClose to attached listeners.
 *
 * @param {Map} [mArguments] the arguments to pass along with the event.
 * @return {sap.m.ActionSheet} this to allow method chaining
 * @protected
 * @name sap.m.ActionSheet#fireBeforeClose
 * @function
 */

/**
 * This event will be fired after the ActionSheet is closed.
 *
 * @name sap.m.ActionSheet#afterClose
 * @event
 * @param {sap.ui.base.Event} oControlEvent
 * @param {sap.ui.base.EventProvider} oControlEvent.getSource
 * @param {object} oControlEvent.getParameters

 * @public
 */

/**
 * Attach event handler fnFunction to the 'afterClose' event of this sap.m.ActionSheet.
.
 * When called, the context of the event handler (its this) will be bound to oListener if specified
 * otherwise to this sap.m.ActionSheet.
 itself.
 *
 * This event will be fired after the ActionSheet is closed.
 *
 * @param {object}
 *            [oData] An application specific payload object, that will be passed to the event handler along with the event object when firing the event.
 * @param {function}
 *            fnFunction The function to call, when the event occurs.
 * @param {object}
 *            [oListener] Context object to call the event handler with. Defaults to this sap.m.ActionSheet.
 itself.
 *
 * @return {sap.m.ActionSheet} this to allow method chaining
 * @public
 * @name sap.m.ActionSheet#attachAfterClose
 * @function
 */

/**
 * Detach event handler fnFunction from the 'afterClose' event of this sap.m.ActionSheet.

 *
 * The passed function and listener object must match the ones used for event registration.
 *
 * @param {function}
 *            fnFunction The function to call, when the event occurs.
 * @param {object}
 *            oListener Context object on which the given function had to be called.
 * @return {sap.m.ActionSheet} this to allow method chaining
 * @public
 * @name sap.m.ActionSheet#detachAfterClose
 * @function
 */

/**
 * Fire event afterClose to attached listeners.
 *
 * @param {Map} [mArguments] the arguments to pass along with the event.
 * @return {sap.m.ActionSheet} this to allow method chaining
 * @protected
 * @name sap.m.ActionSheet#fireAfterClose
 * @function
 */

/**
 * This event is fired when the cancelButton is clicked. For iPad, this event is also fired when showCancelButton is set to true, and Popover is closed by clicking outside.
 *
 * @name sap.m.ActionSheet#cancelButtonPress
 * @event
 * @param {sap.ui.base.Event} oControlEvent
 * @param {sap.ui.base.EventProvider} oControlEvent.getSource
 * @param {object} oControlEvent.getParameters

 * @public
 */

/**
 * Attach event handler fnFunction to the 'cancelButtonPress' event of this sap.m.ActionSheet.
.
 * When called, the context of the event handler (its this) will be bound to oListener if specified
 * otherwise to this sap.m.ActionSheet.
 itself.
 *
 * This event is fired when the cancelButton is clicked. For iPad, this event is also fired when showCancelButton is set to true, and Popover is closed by clicking outside.
 *
 * @param {object}
 *            [oData] An application specific payload object, that will be passed to the event handler along with the event object when firing the event.
 * @param {function}
 *            fnFunction The function to call, when the event occurs.
 * @param {object}
 *            [oListener] Context object to call the event handler with. Defaults to this sap.m.ActionSheet.
 itself.
 *
 * @return {sap.m.ActionSheet} this to allow method chaining
 * @public
 * @name sap.m.ActionSheet#attachCancelButtonPress
 * @function
 */

/**
 * Detach event handler fnFunction from the 'cancelButtonPress' event of this sap.m.ActionSheet.

 *
 * The passed function and listener object must match the ones used for event registration.
 *
 * @param {function}
 *            fnFunction The function to call, when the event occurs.
 * @param {object}
 *            oListener Context object on which the given function had to be called.
 * @return {sap.m.ActionSheet} this to allow method chaining
 * @public
 * @name sap.m.ActionSheet#detachCancelButtonPress
 * @function
 */

/**
 * Fire event cancelButtonPress to attached listeners.
 *
 * @param {Map} [mArguments] the arguments to pass along with the event.
 * @return {sap.m.ActionSheet} this to allow method chaining
 * @protected
 * @name sap.m.ActionSheet#fireCancelButtonPress
 * @function
 */

/**
 * Calling this method will make the ActionSheet visible on the screen.
 *
 * @name sap.m.ActionSheet.prototype.openBy
 * @function
 * @param {object}
 *         oControl
 *         The ActionSheet behaves as a sap.m.Popover in iPad and the control parameter is the object to which the popover will be placed. It can be not only a UI5 control, but also an existing dom reference. The side of the placement depends on the placement property set in the popover. In other platforms, ActionSheet behaves as a standard dialog and this parameter is ignored because dialog is aligned to the screen.

 * @type void
 * @public
 */

/**
 * Calling this method will make the ActionSheet disappear from the screen.
 *
 * @name sap.m.ActionSheet.prototype.close
 * @function

 * @type void
 * @public
 */

/**
 * The method checks if the ActionSheet is open. It returns true when the ActionSheet is currently open (this includes opening and closing animations), otherwise it returns false.
 *
 * @name sap.m.ActionSheet.prototype.isOpen
 * @function

 * @type boolean
 * @public
 */

// Start of sap\m\ActionSheet.js
jQuery.sap.require("sap.m.Dialog");
jQuery.sap.require("sap.m.Popover");
jQuery.sap.require("sap.ui.core.delegate.ItemNavigation");

sap.m.ActionSheet.prototype.init = function() {
	// Delegate keyboard processing to ItemNavigation, see commons.SegmentedButton
	this._oItemNavigation = new sap.ui.core.delegate.ItemNavigation();
	this._oItemNavigation.setCycling(false);
	this.addDelegate(this._oItemNavigation);
};

sap.m.ActionSheet.prototype.exit = function(){
	if(this._parent){
		this._parent.destroy();
		this._parent = null;
	}
	if(this._oCancelButton){
		this._oCancelButton.destroy();
		this._oCancelButton = null;
	}

	if (this._oItemNavigation) {
		this.removeDelegate(this._oItemNavigation);
		this._oItemNavigation.destroy();
		delete this._oItemNavigation;
	}
};

// keyboard navigation
sap.m.ActionSheet.prototype._setItemNavigation = function() {
	var aButtons = this.getButtons(),
		aDomRefs = [],
		oDomRef = this.getDomRef();

	if (oDomRef) {
		this._oItemNavigation.setRootDomRef(oDomRef);
		for(var i = 0; i < aButtons.length; i++){
			if(aButtons[i].getEnabled()){
				aDomRefs.push(aButtons[i].getFocusDomRef());
			}
		}
		if(this._oCancelButton){
			aDomRefs.push(this._oCancelButton.getFocusDomRef());
		}
		this._oItemNavigation.setItemDomRefs(aDomRefs);
		this._oItemNavigation.setSelectedIndex(0);
		this._oItemNavigation.setPageSize(aDomRefs.length);
	}
};
sap.m.ActionSheet.prototype.onAfterRendering = function() {
	this._setItemNavigation();
	this.$().on("keyup.ActionSheet", jQuery.proxy(this.onKeyUp, this));
};
sap.m.ActionSheet.prototype.onBeforeRendering = function() {
	if(this.getDomRef()){
		this.$().off("keyup.ActionSheet");
	}
};
sap.m.ActionSheet.prototype.onKeyUp = function(event) {
	if( event.which == jQuery.sap.KeyCodes.ESCAPE){
		this.close();
		event.stopPropagation();
		event.preventDefault();
	}
};
sap.m.ActionSheet.prototype.sapfocusleave = function() {
	this.close();
};

sap.m.ActionSheet.prototype.openBy = function(oControl){
	var that = this;
	if(!this._parent){
		var oOldParent = this.getParent();

		// ActionSheet may already have a parent for dependent aggregation.
		// This parent must be cleared before adding it to the popup instance, otherwise ActionSheet closes immediately after opening for the first time.
		// TODO: after ManagedObject.prototype._removeChild function is fixed for removing control from dependents aggregation, remove this.
		if(oOldParent){
			this.setParent(null);
		}

		if(jQuery.device.is.ipad || (sap.m.Dialog._bOneDesign && !sap.ui.Device.system.phone)){
		//create a Popover instance for iPad
			this._parent = new sap.m.Popover({
				placement: this.getPlacement(),
				showHeader: false,
				content: [this],
				beforeOpen: function(){
					that.fireBeforeOpen();
				},
				afterOpen: function(){
					that.focus();
					that.fireAfterOpen();
				},
				beforeClose: function(){
					that.fireBeforeClose();
				},
				afterClose: function(){
					if(that.getShowCancelButton()){
						that.fireCancelButtonTap(); // (This event is deprecated, use the "cancelButtonPress" event instead)
						that.fireCancelButtonPress();
					}
					that.fireAfterClose();
				}
			}).addStyleClass("sapMActionSheetPopover");

			if(sap.ui.Device.browser.internet_explorer){
				this._parent._fnSetArrowPosition = jQuery.proxy(function(){
					sap.m.Popover.prototype._setArrowPosition.apply(this);

					var $this = this.$(),
						fContentWidth = $this.children(".sapMPopoverCont")[0].getBoundingClientRect().width;
					jQuery.each($this.find(".sapMActionSheet > .sapMBtn"), function(index, oButtonDom){
						var $button = jQuery(oButtonDom),
							fButtonWidth;
						$button.css("width", "");
						fButtonWidth = oButtonDom.getBoundingClientRect().width;
						if(fButtonWidth <= fContentWidth){
							$button.css("width", "100%");
						}
					});
				}, this._parent);
			}
		}else{
			//create a Dialog instance for the rest
			this._parent = new sap.m.Dialog({
				title: this.getTitle(),
				type: sap.m.DialogType.Standard,
				content: [this],
				beforeOpen: function(){
					that.fireBeforeOpen();
				},
				afterOpen: function(){
					that.focus();
					that.fireAfterOpen();
				},
				beforeClose: function(oEvent){
					that.fireBeforeClose({
						origin: oEvent.getParameter("origin")
					});
				},
				afterClose: function(oEvent){
					that.fireAfterClose({
						origin: oEvent.getParameter("origin")
					});
				}
			}).addStyleClass("sapMActionSheetDialog");

			if(this.getTitle()){
				this._parent.addStyleClass("sapMActionSheetDialogWithTitle");
			}

			if(!(jQuery.device.is.iphone || (sap.m.Dialog._bOneDesign && sap.ui.Device.system.phone))){
				this._parent.setBeginButton(this._getCancelButton());
			}

			//need to modify some internal methods of Dialog for iPhone, because
			//the actionsheet won't be sized full screen if the content is smaller than the whole screen.
			//Then the transform animation need to be set at runtime with some height calculation.
			if(jQuery.device.is.iphone || (sap.m.Dialog._bOneDesign && sap.ui.Device.system.phone)){
				//remove the transparent property from blocklayer
				this._parent.oPopup.setModal(true);
				this._parent._setDimensions = function(){
					var $this = this.$(),
						$content = this.$("cont");
					//CSS reset
					$this.css({
						"width": "100%",
						"max-height": "100%",
						"left": "0px",
						"right": "",
						"bottom": "",
					});
					$content.css("max-height", "");
				};

				//Generate a translate3d string with the given y offset
				function genTransformCSS(y){
					return "translate3d(0px, " + (y > 0 ? y : 0) +"px, 0px)";
				}

				this._parent._openAnimation = function($this, iRealDuration, fnOpened){
					var $window = jQuery(window),
						iWindowHeight = $window.height(),
						sStartTransform = genTransformCSS(iWindowHeight);

					//need to set the transform css before its visible, in order to trigger the animation properly.
					$this.css({
						"top": "0px",
						"-webkit-transform": sStartTransform,
						"-moz-transform": sStartTransform,
						"transform": sStartTransform,
						"display": "block"
					});

					$this.bind("webkitTransitionEnd transitionend", function(){
						jQuery(this).unbind("webkitTransitionEnd transitionend");
						$this.removeClass("sapMDialogSliding");
						fnOpened();
					});

					//need a timeout to trigger the animation
					setTimeout(function(){
						var iTop = iWindowHeight - $this.outerHeight(),
							//calculation for the end point of the animation
							sEndTransform = genTransformCSS(iTop);
						$this.css({
							"-webkit-transform": sEndTransform,
							"-moz-transform": sEndTransform,
							"transform": sEndTransform
						}).addClass("sapMDialogSliding").removeClass("sapMDialogHidden");
					}, 0);
				};

				this._parent._closeAnimation = function($this, iRealDuration, fnClosed){
					var $window = jQuery(window),
						sTransform = genTransformCSS($window.height());
					$this.bind("webkitTransitionEnd transitionend", function(){
						jQuery(this).unbind("webkitTransitionEnd transitionend");
						$this.removeClass("sapMDialogSliding");
						fnClosed();
					});
					$this.css({
						"-webkit-transform": sTransform,
						"-moz-transform": sTransform,
						"transform": sTransform
					}).addClass("sapMDialogSliding");
				};

				//set the animation to the interal oPopup instance on Dialog
				this._parent.oPopup.setAnimations(jQuery.proxy(this._parent._openAnimation, this._parent), jQuery.proxy(this._parent._closeAnimation, this._parent));

				//also need to change the logic for adjusting scrollable area.
				this._parent._adjustScrollingPane = function(){
					var $this = this.$(),
						iHeight = $this.height(),
						iHeaderHeight = $this.children("header.sapMIBar").outerHeight(true),
						$content = this.$("cont");

					$content.css("max-height", iHeight - iHeaderHeight);
					if (this._oScroller) {
						this._oScroller.refresh();
					}
				};

				//only need to recalculate the transform offset when window resizes, doesn't need to reposition using Popup.js again for iPhone.
				this._parent._fnOrientationChange = jQuery.proxy(function(){
					this._setDimensions();

					var $window = jQuery(window),
						iWindowHeight = $window.height(),
						$this = this.$(),
						iTop = iWindowHeight - $this.outerHeight(),
						sTransform = genTransformCSS(iTop),
						$content = this.$("cont");

					$this.css({
						"-webkit-transform": sTransform,
						"-moz-transform": sTransform,
						"transform": sTransform
					});

					this._adjustScrollingPane();
				}, this._parent);
			}
		}

		// Check if this control has already a parent. If yes, add the _parent control into the dependents aggregation
		// to enable model propagation and lifecycle management.
		if(oOldParent){
			oOldParent.addDependent(this._parent);
		}
	}

	//open the ActionSheet
	if(jQuery.device.is.ipad || (sap.m.Dialog._bOneDesign && !sap.ui.Device.system.phone)){
		this._parent.openBy(oControl);
	}else{
		this._parent.open();
	}
};

sap.m.ActionSheet.prototype.close = function(oControl){
	if(this._parent){
		this._parent.close();
	}
};

sap.m.ActionSheet.prototype.isOpen = function(oControl){
	return !!this._parent && this._parent.isOpen();
};

sap.m.ActionSheet.prototype._createCancelButton = function(){
	if(!this._oCancelButton){
		var sCancelButtonText = (this.getCancelButtonText()) ? this.getCancelButtonText() : sap.ui.getCore().getLibraryResourceBundle("sap.m").getText("ACTIONSHEET_CANCELBUTTON_TEXT"),
			that = this;
//			var sButtonStyle = (sap.ui.Device.os.ios) ? sap.m.ButtonType.Unstyled : sap.m.ButtonType.Default;
		this._oCancelButton = new sap.m.Button(this.getId() + '-cancelBtn', {
			text: sCancelButtonText,
			type: sap.m.ButtonType.Reject,
			press : function() {
				if(!(jQuery.device.is.ipad || (sap.m.Dialog._bOneDesign && !sap.ui.Device.system.phone)) && that._parent){
					that._parent._oCloseTrigger = this;
				}
				that.close();
				that.fireCancelButtonTap(); // (This event is deprecated, use the "cancelButtonPress" event instead)
				that.fireCancelButtonPress();
			}
		}).addStyleClass("sapMActionSheetButton sapMActionSheetCancelButton sapMBtnTransparent sapMBtnInverted");

		if(jQuery.device.is.iphone || (sap.m.Dialog._bOneDesign && sap.ui.Device.system.phone)){
			this.setAggregation("_cancelButton", this._oCancelButton, true);
		}
	}
	return this;
};

sap.m.ActionSheet.prototype._getCancelButton = function(){
	if(!(jQuery.device.is.ipad || (sap.m.Dialog._bOneDesign && !sap.ui.Device.system.phone)) && this.getShowCancelButton()){
		this._createCancelButton();
		return this._oCancelButton;
	}
	return null;
};

sap.m.ActionSheet.prototype.setCancelButtonText = function(sText) {
	this.setProperty("cancelButtonText", sText, true);
	if(this._oCancelButton) {
		this._oCancelButton.setText(sText);
	}
	return this;
};

sap.m.ActionSheet.prototype._preProcessActionButton = function(oButton){
	var sType = oButton.getType();

	if(sap.m.Dialog._bOneDesign){
		if(sType !== sap.m.ButtonType.Accept && sType !== sap.m.ButtonType.Reject){
			oButton.setType(sap.m.ButtonType.Transparent);
		}
	}
	oButton.addStyleClass("sapMBtnInverted"); // dark background
	return this;
};

sap.m.ActionSheet.prototype.setShowCancelButton = function(bValue){
	if(this._parent){
		if(jQuery.device.is.iphone || (sap.m.Dialog._bOneDesign && sap.ui.Device.system.phone)){
			//if iPhone, we need to rerender to show or hide the cancel button
			this.setProperty("showCancelButton", bValue, false);
		}else if(!sap.m.Dialog._bOneDesign && !sap.ui.Device.os.ios){
			this.setProperty("showCancelButton", bValue, true);
			this._parent.setBeginButton(this._getCancelButton());
		}
	}else{
		this.setProperty("showCancelButton", bValue, true);
	}
	return this;
};

sap.m.ActionSheet.prototype.setTitle = function(sTitle){
	this.setProperty("title", sTitle, true);
	if(this._parent && !(jQuery.device.is.ipad || (sap.m.Dialog._bOneDesign && !sap.ui.Device.system.phone))){
		this._parent.setTitle(sTitle);
	}

	if(this._parent){
		if(sTitle){
			this._parent.addStyleClass("sapMActionSheetDialogWithTitle");
		}else{
			this._parent.removeStyleClass("sapMActionSheetDialogWithTitle");
		}
	}
	return this;
};

sap.m.ActionSheet.prototype.setPlacement = function(sPlacement){
	this.setProperty("placement", sPlacement, true);

	if(jQuery.device.is.ipad || (sap.m.Dialog._bOneDesign && !sap.ui.Device.system.phone)){
		if(this._parent){
			this._parent.setPlacement(sPlacement);
		}
	}
	return this;
};

sap.m.ActionSheet.prototype._buttonSelected = function(){
	if(!(jQuery.device.is.ipad || (sap.m.Dialog._bOneDesign && !sap.ui.Device.system.phone)) && this._parent){
		this._parent._oCloseTrigger = this;
	}
	this.close();
};

/* Override API methods */
sap.m.ActionSheet.prototype.addButton = function(oButton) {
	this.addAggregation("buttons",oButton, false);
	this._preProcessActionButton(oButton);
	oButton.attachPress(this._buttonSelected, this);
	return this;
};
sap.m.ActionSheet.prototype.insertButton = function(oButton, iIndex) {
	this.insertAggregation("buttons",oButton, iIndex, false);
	this._preProcessActionButton(oButton);
	oButton.attachPress(this._buttonSelected, this);
	return this;
};
sap.m.ActionSheet.prototype.removeButton = function(oButton) {
	var result = this.removeAggregation("buttons",oButton, false);
	if (result) {
		result.detachPress(this._buttonSelected, this);
	}
	return result;
};
sap.m.ActionSheet.prototype.removeAllButtons = function() {
	var result = this.removeAllAggregation("buttons", false),
		that = this;
	jQuery.each(result, function(i, oButton) {
		oButton.detachPress(that._buttonSelected, that);
	});
	return result;
};
sap.m.ActionSheet.prototype.clone = function() {

	var aButtons = this.getButtons();
	for ( var i = 0; i < aButtons.length; i++) {
		var oButton = aButtons[i];
		oButton.detachPress(this._buttonSelected, this);
	}

	var oClone = sap.ui.core.Control.prototype.clone.apply(this, arguments);

	for ( var i = 0; i < aButtons.length; i++) {
		var oButton = aButtons[i];
		oButton.attachPress(this._buttonSelected, this);
	}

	return oClone;
};


text:
package armmysql_test

import (
	"context"
	"log"

	"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
	"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/mysql/armmysql"
)

// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/mysql/resource-manager/Microsoft.DBforMySQL/stable/2017-12-01/examples/PerformanceTiersListByServer.json
func ExampleServerBasedPerformanceTierClient_NewListPager() {
	cred, err := azidentity.NewDefaultAzureCredential(nil)
	if err != nil {
		log.Fatalf("failed to obtain a credential: %v", err)
	}
	ctx := context.Background()
	client, err := armmysql.NewServerBasedPerformanceTierClient("ffffffff-ffff-ffff-ffff-ffffffffffff", cred, nil)
	if err != nil {
		log.Fatalf("failed to create client: %v", err)
	}
	pager := client.NewListPager("testrg",
		"mysqltestsvc1",
		nil)
	for pager.More() {
		nextResult, err := pager.NextPage(ctx)
		if err != nil {
			log.Fatalf("failed to advance page: %v", err)
		}
		for _, v := range nextResult.Value {
			// TODO: use page item
			_ = v
		}
	}
}

redpajama_set_name: RedPajamaGithub


text:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Untitled Document</title>
</head>

<body>

<form action="sqltest.php">
zipcode:<input type=text name="zipcode" />
<input type=submit value="submit" />
</form>
</body>
</html>


text:
Movable.js
========

#### presentation ####

A micro library to allow html element to have a "Movable" behavior.
Use CSS3 transform3d to have smooth trasitions.

### Usage ###

Simple as ...

```html
var s = {};
movable.apply( s );
```

By default, Movable will attach a new div element to the body.
You can change that with the options:

```html
movable.set({
    add_data_to: 'sprite',          // to add the Movable properties & methods to another object
    container: ''                   // the container of all movable objects
});
```

After that, you have a bunch of methods to move your element around:

`position( x, y )`

To set the 2d position (no animation)

`rotation( r )`

To set the rotation in degree (no animation)

`scale( s )`

To scale the element. Original size is 1 (no animation)

`move_to( x, y, duration, easing )`

To move to the 2d position.
Duration is in milliseconds
Easing is in ['linear', 'ease-in', 'ease-out', 'ease-in-out'];

`transform( rotation, scale, duration, easing )`

To transform the angle and/or the scale

`animation( x, y, rotation, scale, duration, easing)`

To move and transform (equal move_to and transform in sync)

`direction_to( x, y, speed )`

To go to a direction. Only stop when direction_stop() occure.

`direction_stop()`

To stop the direction animation.

**All methods are chainables **


text:
using System;
using NUnit.Framework.Interfaces;
using NUnit.Framework.Internal;

namespace NUnit.Framework
{
    /// <summary>
    /// SingleThreadedAttribute applies to a test fixture and indicates
    /// that all the child tests must be run on the same thread as the
    /// OneTimeSetUp and OneTimeTearDown. It sets a flag in the
    /// TestExecutionContext and forces all tests to be run sequentially
    /// on the current thread. Any ParallelScope setting is ignored.
    /// </summary>
    [AttributeUsage(AttributeTargets.Class, AllowMultiple=false, Inherited=true)]
    public class SingleThreadedAttribute : NUnitAttribute, IApplyToContext
    {
        #region IApplyToContext Members

        /// <summary>
        /// Apply changes to the TestExecutionContext
        /// </summary>
        /// <param name="context">The TestExecutionContext</param>
        public void ApplyToContext(TestExecutionContext context)
        {
            context.IsSingleThreaded = true;
        }

        #endregion
    }
}


text:
namespace sim {

bool MazeChecker::isValidMaze(const std::vector<std::vector<BasicTile>>& maze) {

    if (!isNonempty(maze)) {
        L()->warn("The maze is empty.");
        return false;
    }

    if (!isRectangular(maze)) {
        L()->warn("The maze is not rectangular.");
        return false;
    }

    if (!isEnclosed(maze)) {
        L()->warn("The maze is not enclosed by walls.");
        return false;
    }

    if (!hasConsistentWalls(maze)) {
        L()->warn("The maze does not have consistent walls.");
        return false;
    }

    return true;
}

bool MazeChecker::isNonempty(const std::vector<std::vector<BasicTile>>& maze) {
    return (maze.size() == 0 ? false : 0 < maze.at(0).size());
}

bool MazeChecker::isRectangular(const std::vector<std::vector<BasicTile>>& maze) {
    for (int i = 0; i < maze.size() - 1; i += 1) {
        if (maze.at(i).size() != maze.at(i + 1).size()) {
            return false;
        }
    }
    return true;
}

bool MazeChecker::isEnclosed(const std::vector<std::vector<BasicTile>>& maze) {
    for (int x = 0; x < maze.size(); x += 1) {
        for (int y = 0; y < maze.at(x).size(); y += 1) {
            if (x == 0 && !maze.at(x).at(y).walls.at(Direction::WEST)) {
                return false;
            }
            if (y == 0 && !maze.at(x).at(y).walls.at(Direction::SOUTH)) {
                return false;
            }
            if (x == maze.size() - 1 && !maze.at(x).at(y).walls.at(Direction::EAST)) {
                return false;
            }
            if (y == maze.at(x).size() - 1 && !maze.at(x).at(y).walls.at(Direction::NORTH)) {
                return false;
            }
        }
    }
    return true;
}

bool MazeChecker::hasConsistentWalls(const std::vector<std::vector<BasicTile>>& maze) {
    SIM_ASSERT_TR(isEnclosed(maze));
    for (int x = 0; x < maze.size(); x += 1) {
        for (int y = 0; y < maze.at(x).size(); y += 1) {
            if (0 < x) {
                if (maze.at(x).at(y).walls.at(Direction::WEST) != maze.at(x - 1).at(y).walls.at(Direction::EAST)) {
                    return false;
                }
            }
            if (0 < y) {
                if (maze.at(x).at(y).walls.at(Direction::SOUTH) != maze.at(x).at(y - 1).walls.at(Direction::NORTH)) {
                    return false;
                }
            }
            if (x < maze.size() - 1) {
                if (maze.at(x).at(y).walls.at(Direction::EAST) != maze.at(x + 1).at(y).walls.at(Direction::WEST)) {
                    return false;
                }
            }
            if (y < maze.at(x).size() - 1) {
                if (maze.at(x).at(y).walls.at(Direction::NORTH) != maze.at(x).at(y + 1).walls.at(Direction::SOUTH)) {
                    return false;
                }
            }
        }
    }
    return true;
}

bool MazeChecker::isOfficialMaze(const std::vector<std::vector<BasicTile>>& maze) {

    SIM_ASSERT_TR(isValidMaze(maze));

    bool success = true;

    if (!hasNoInaccessibleLocations(maze)) {
        L()->warn("There are inaccessible locations in the maze.");
        success = false;
    }

    if (!hasHollowCenter(maze)) {
        L()->warn("The maze does not have a hollow center.");
        success = false;
    }

    if (!hasOneEntranceToCenter(maze)) {
        L()->warn("The center of the maze has more than one entrance.");
        success = false;
    }

    if (!hasWallAttachedToEachNonCenterPost(maze)) {
        L()->warn("There is at least one non-center post with no walls connected to it.");
        success = false;
    }

    if (!hasThreeStartingWalls(maze)) {
        L()->warn("There are not exactly three starting walls.");
        success = false;
    }

    if (!isUnsolvableByWallFollower(maze)) {
        L()->warn("The maze is solvable by a maze-following robot.");
        success = false;
    }

    return success;
}

std::vector<std::pair<int, int>> MazeChecker::getCenterTiles(int width, int height) {
    std::vector<std::pair<int, int>> centerTiles;
            centerTiles.push_back(std::make_pair((width - 1) / 2, (height - 1) / 2));
    if (width % 2 == 0) {
            centerTiles.push_back(std::make_pair( width      / 2, (height - 1) / 2));
        if (height % 2 == 0) {
            centerTiles.push_back(std::make_pair((width - 1) / 2,  height      / 2));
            centerTiles.push_back(std::make_pair( width      / 2,  height      / 2));
        }
    }
    else if (height % 2 == 0) {
            centerTiles.push_back(std::make_pair((width - 1) / 2,  height      / 2));
    }
    return centerTiles;
}

bool MazeChecker::hasNoInaccessibleLocations(const std::vector<std::vector<BasicTile>>& maze) {

    std::set<std::pair<int, int>> discovered;
    std::queue<std::pair<int, int>> queue;

    for (std::pair<int, int> tile : getCenterTiles(maze.size(), maze.at(0).size())) {
        discovered.insert(tile);
        queue.push(tile);
    }

    while (!queue.empty()) {
        std::pair<int, int> tile = queue.front();
        queue.pop();
        for (Direction direction : DIRECTIONS) {
            if (maze.at(tile.first).at(tile.second).walls.at(direction)) {
                continue;
            }
            std::pair<int, int> neighbor = positionAfterMovingForward(tile, direction);
            if (!ContainerUtilities::setContains(discovered, neighbor)) {
                discovered.insert(neighbor);
                queue.push(neighbor);
            }
        }
    }

    for (int x = 0; x < maze.size(); x += 1) {
        for (int y = 0; y < maze.at(x).size(); y += 1) {
            if (!ContainerUtilities::setContains(discovered, std::make_pair(x, y))) {
                return false;
            }
        }
    }

    return true;
}

bool MazeChecker::hasThreeStartingWalls(const std::vector<std::vector<BasicTile>>& maze) {
    std::map<Direction, bool> walls = maze.at(0).at(0).walls;
    return walls.at(Direction::NORTH) != walls.at(Direction::EAST);
}

bool MazeChecker::hasOneEntranceToCenter(const std::vector<std::vector<BasicTile>>& maze) {
    std::vector<std::pair<int, int>> centerTiles = getCenterTiles(maze.size(), maze.at(0).size());
    int numberOfEntrances = 0;
    for (std::pair<int, int> tile : centerTiles) {
        for (Direction direction : DIRECTIONS) {
            if (ContainerUtilities::vectorContains(centerTiles, positionAfterMovingForward(tile, direction))) {
                continue;
            }
            if (!maze.at(tile.first).at(tile.second).walls.at(direction)) {
                numberOfEntrances += 1;
            }
        }
    }
    return numberOfEntrances == 1;
}

bool MazeChecker::hasHollowCenter(const std::vector<std::vector<BasicTile>>& maze) {
    std::vector<std::pair<int, int>> centerTiles = getCenterTiles(maze.size(), maze.at(0).size());
    for (std::pair<int, int> tile : centerTiles) {
        for (std::pair<int, int> otherTile : centerTiles) {
            for (Direction direction : DIRECTIONS) {
                if (positionAfterMovingForward(tile, direction) != otherTile) {
                    continue;
                }
                if (maze.at(tile.first).at(tile.second).walls.at(direction)) {
                    return false;
                }
            }
        }
    }
    return true;
}

bool MazeChecker::hasWallAttachedToEachNonCenterPost(const std::vector<std::vector<BasicTile>>& maze) {
    std::vector<std::pair<int, int>> centerTiles = getCenterTiles(maze.size(), maze.at(0).size());
    auto upperRightPostIsCenterPost = [&](int x, int y) {
        return centerTiles.size() == 4 && std::make_pair(x, y) == SimUtilities::min(centerTiles);
    };
    for (int x = 0; x < maze.size() - 1; x += 1) {
        for (int y = 0; y < maze.at(x).size() - 1; y += 1) {
            std::vector<bool> conditions {
                maze.at(x).at(y).walls.at(Direction::NORTH),
                maze.at(x).at(y).walls.at(Direction::EAST),
                maze.at(x + 1).at(y + 1).walls.at(Direction::SOUTH),
                maze.at(x + 1).at(y + 1).walls.at(Direction::WEST),
                upperRightPostIsCenterPost(x, y)
            };
            if (std::none_of(conditions.begin(), conditions.end(), [](bool b){return b;})) {
                return false;
            }
        }
    }
    return true;
}

bool MazeChecker::isUnsolvableByWallFollower(const std::vector<std::vector<BasicTile>>& maze) {

    std::set<std::pair<int, int>> reachableByWallFollower;

    std::pair<int, int> position = std::make_pair(0, 0);
    Direction direction = Direction::NORTH;

    while (!ContainerUtilities::setContains(reachableByWallFollower, position)) {
        Direction oldDirection = direction;
        Direction newDirection = directionAfterRightTurn(direction);
        if (!maze.at(position.first).at(position.second).walls.at(newDirection)) {
            direction = newDirection;
        }
        while (maze.at(position.first).at(position.second).walls.at(direction)) {
            direction = directionAfterLeftTurn(direction);
            if (direction == oldDirection) {
                break;
            }
        }
        position = positionAfterMovingForward(position, direction);
        reachableByWallFollower.insert(position);
    }

    for (std::pair<int, int> tile : getCenterTiles(maze.size(), maze.at(0).size())) {
        if (ContainerUtilities::setContains(reachableByWallFollower, tile)) {
            return false;
        }
    }

    return true;
}

Direction MazeChecker::directionAfterLeftTurn(Direction direction) {
    return DIRECTION_ROTATE_LEFT.at(direction);
}

Direction MazeChecker::directionAfterRightTurn(Direction direction) {
    return DIRECTION_ROTATE_RIGHT.at(direction);
}

std::pair<int, int> MazeChecker::positionAfterMovingForward(std::pair<int, int> position, Direction direction) {
    return {
        (direction == Direction::EAST ?
            position.first + 1 :
        (direction == Direction::WEST ?
            position.first - 1 :
        position.first)),
        (direction == Direction::NORTH ?
            position.second + 1 :
        (direction == Direction::SOUTH ?
            position.second - 1 :
        position.second))
    };
}

} // namespace sim


text:
package org.apache.derbyTesting.functionTests.tests.jdbcapi;

import java.io.File;
import java.sql.CallableStatement;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.Hashtable;
import javax.sql.DataSource;
import junit.framework.Test;
import org.apache.derbyTesting.junit.BaseTestSuite;
import org.apache.derby.jdbc.ClientDataSourceInterface;
import org.apache.derby.jdbc.BasicEmbeddedDataSource40;
import org.apache.derbyTesting.functionTests.util.PrivilegedFileOpsForTests;
import org.apache.derbyTesting.functionTests.util.SecurityCheck;
import org.apache.derbyTesting.junit.BaseJDBCTestCase;
import org.apache.derbyTesting.junit.CleanDatabaseTestSetup;
import org.apache.derbyTesting.junit.JDBC;
import org.apache.derbyTesting.junit.JDBCClient;
import org.apache.derbyTesting.junit.JDBCDataSource;
import org.apache.derbyTesting.junit.TestConfiguration;

/**
 * Test the various DataSource implementations of Derby, but not
 * ConnectionPoolDataSource or XADataSource; those are tested in
 * J2EEDataSourceTest.
 *
 * Performs SecurityCheck analysis on the JDBC objects returned.
 * This is because this test returns to the client a number of
 * different implementations of Connection, Statement etc.
 *
 * @see org.apache.derbyTesting.functionTests.util.SecurityCheck
 *
 */
public class DataSourceTest extends BaseJDBCTestCase {

    private static final String dbName =
        TestConfiguration.getCurrent().getDefaultDatabaseName();

    /**
     * A hashtable of opened connections.  This is used when checking to
     * make sure connection strings are unique; we need to make sure all
     * the connections are closed when we are done, so they are stored
     * in this hashtable
     */
    protected static Hashtable<String, Connection> conns =
            new Hashtable<String, Connection>();

    /** The expected format of a connection string. In English:
     * "<classname>@<hashcode> (XID=<xid>), (SESSION = <sessionid>),
     *  (DATABASE=<dbname>), (DRDAID = <drdaid>)"
     */
    private static final String CONNSTRING_FORMAT =
        "\\S+@\\-?[0-9]+.* \\(XID = .*\\), \\(SESSIONID = [0-9]+\\), " +
        "\\(DATABASE = [A-Za-z]+\\), \\(DRDAID = .*\\) ";

    /**
     * Hang onto the SecurityCheck class while running the
     * tests so that it is not garbage collected during the
     * test and lose the information it has collected,
     * in case it should get printed out.
     */
    private final Object nogc = SecurityCheck.class;

    public DataSourceTest(String name) {
        super(name);
    }

    /**
     * Return a suite of tests that are run with both client and embedded
     *
     * @param postfix suite name postfix
     * @return A suite of tests to be run with client and/or embedded
     */
    private static Test baseSuite(String postfix) {
        BaseTestSuite
            suite = new BaseTestSuite("ClientAndEmbedded" + postfix);

        suite.addTest(new DataSourceTest("testBadConnectionAttributeSyntax"));
        suite.addTest(new DataSourceTest("testDescriptionProperty"));
        suite.addTest(new DataSourceTest("testAllDataSources"));
        suite.addTest(new DataSourceTest("testJira95ds"));
        return suite;
    }

    /**
     * Return a suite of tests that are run with client only
     *
     * @return A suite of tests being run with client only
     */
    private static Test getClientSuite() {
        BaseTestSuite suite = new BaseTestSuite("Client/Server");
        suite.addTest(new DataSourceTest("testClientDSConnectionAttributes"));
        suite.addTest(new DataSourceTest(
                "testClientTraceFileDSConnectionAttribute"));
        suite.addTest(new DataSourceTest(
                "testClientMessageTextConnectionAttribute"));
        return suite;
    }

    /**
     * Return a suite of tests that are run with embedded only
     *
     * @param postfix suite name postfix
     * @return A suite of tests being run with embedded only
     */
    private static Test getEmbeddedSuite(String postfix) {
        BaseTestSuite suite = new BaseTestSuite("Embedded" + postfix);
        suite.addTest(new DataSourceTest("testDSRequestAuthentication"));
        return suite;
    }

    public static Test suite() {
        BaseTestSuite suite = new BaseTestSuite("DataSourceTest suite");
        // Add the tests that only run with embedded
        suite.addTest(getEmbeddedSuite("embedded"));
        // Add tests that will run with embedded
        suite.addTest(baseSuite(":embedded"));
        if (!JDBC.vmSupportsJSR169()) {
            //  and network server/client
            suite.addTest(TestConfiguration.clientServerDecorator(
                    baseSuite(":client")));
            // Add the tests that only run with client
            suite.addTest(TestConfiguration.clientServerDecorator(
                    getClientSuite()));
        }
        // wrap all in CleanDatabaseTestSetup that creates all database
        // objects any fixture might need.
        // Note that not all fixtures need (all of) these.
        return new CleanDatabaseTestSetup(suite) {
            /**
             * Create and populate database objects
             *
             * @see org.apache.derbyTesting.junit.CleanDatabaseTestSetup#decorateSQL(java.sql.Statement)
             */
            protected void decorateSQL(Statement s) throws SQLException {
                s.executeUpdate("create table intTable(i int)");
            }
        };
    }

    public void tearDown() throws Exception {
        // attempt to get rid of any left-over trace files
        for (int i = 0; i < 6; i++) {
            String traceFileName = "trace" + (i + 1) + ".out";
            File traceFile = new File(traceFileName);
            if (PrivilegedFileOpsForTests.exists(traceFile)) {
                // if it exists, attempt to get rid of it
                PrivilegedFileOpsForTests.delete(traceFile);
            }
        }
        super.tearDown();
    }

    // the J2EEDataSourceTest version of this includes testing for
    // setTypeMap, which is supported for both EmbeddedDataSource and
    // ClientDataSource
    public void testAllDataSources() throws SQLException, Exception
    {
        //Connection dmc = getConnection();

        Object[] expectedValues = {
            new Integer(ResultSet.HOLD_CURSORS_OVER_COMMIT), "XJ010",
            new Integer(2), new Boolean(true), new Boolean(false)};

        if (usingEmbedded())
            assertTenConnectionsUnique();

        DataSource dscs = JDBCDataSource.getDataSource();
        if (usingEmbedded())
                assertToString(dscs);

        DataSource ds = dscs;
        assertConnectionOK(expectedValues, "DataSource", ds.getConnection());

        if (JDBC.vmSupportsJDBC4()) {
            BasicEmbeddedDataSource40 nds = new BasicEmbeddedDataSource40();
            nds.setDatabaseName(dbName);
            assertConnectionOK(
                    expectedValues, "BasicDataSource", nds.getConnection());
        }
    }

    // test jira-derby 95 - a NullPointerException was returned when passing
    // an incorrect database name, should now give error:
    // XCY00 - invalid valid for property ...
    // with DataSource
    public void testJira95ds() throws SQLException {
        try {
            DataSource ds = JDBCDataSource.getDataSource();
            // non-existent database
            JDBCDataSource.setBeanProperty(ds, "databaseName", "jdbc:derby:wombat");
            ds.getConnection();
            fail ("expected an SQLException!");
        } catch (SQLException sqle) {
            assertSQLState("XCY00", sqle);
        } catch (Exception e) {
            fail ("unexpected exception: " + e.toString());
        }
    }

    // this fixture has a counterpart for Pooled and XA DataSources in
    // J2EEDataSourceTest
    public void testBadConnectionAttributeSyntax() throws SQLException {

        // DataSource - bad connattr syntax
        DataSource ds = JDBCDataSource.getDataSource();
        JDBCDataSource.setBeanProperty(ds, "ConnectionAttributes", "bad");
        try {
            ds.getConnection();
            fail ("should have seen an error");
        } catch (SQLException e) {
            assertSQLState("XJ028", e);
        }
    } // End testBadConnectionAttributeSyntax

    /**
     * Check that database name set using setConnectionAttributes is not used
     * by ClientDataSource. This method tests DERBY-1130.
     * this fixture has a counterpart for Pooled and XA DataSources in
     * J2EEDataSourceTest
     *
     * @throws SQLException
     */
    public void testClientDSConnectionAttributes() throws Exception {
        if (usingEmbedded())
            return;

        ClientDataSourceInterface ds = null;

        if (JDBC.vmSupportsJNDI()) {
            // Use reflection to avoid class not found in non-JNDI context
            ds = (ClientDataSourceInterface)Class.forName(
                    "org.apache.derby.jdbc.ClientDataSource").newInstance();
        } else {
            ds = (ClientDataSourceInterface)Class.forName(
                    "org.apache.derby.jdbc.BasicClientDataSource40").
                    newInstance();
        }

        ds.setPortNumber(TestConfiguration.getCurrent().getPort());

        // DataSource - EMPTY; expect error 08001 in all cases
        // 08001: Required Derby DataSource property databaseName not set.
        dsConnectionRequests(new String[]
            {"08001","08001","08001","08001",
             "08001","08001","08001","08001","08001"}, ds);

        // DataSource - connectionAttributes=databaseName=<valid name>
        ds.setConnectionAttributes("databaseName=" + dbName);
        dsConnectionRequests(new String[]
            {"08001","08001","08001","08001",
             "08001","08001","08001","08001","08001"}, ds);
        ds.setConnectionAttributes(null);

        // Test that (invalid) database name specified in connection
        // attributes is not used
        // DataSource - databaseName=<valid db> and
        // connectionAttributes=databaseName=kangaroo
        ds.setConnectionAttributes("databaseName=kangaroo");
        ds.setDatabaseName(dbName);
        dsConnectionRequests(new String[]
            {"OK","08001","OK","OK",
             "08001","08001","OK","OK","OK"}, ds);
        ds.setConnectionAttributes(null);
        ds.setDatabaseName(null);

    } // End testClientDSConnectionAttributes

    // Following test is similar to testClientDSConnectionAttributes, but
    // for embedded datasources.
    // This fixture has a counterpart for Pooled and XA DataSources in
    // J2EEDataSourceTest. In that test, the corresponding fixture
    // also includes testing for setAttributesAsPassword.
    // Note that in this simple shape, there is no authentication done
    // but the fixture name is kept the same for reference to the J2EE one.
    public void testDSRequestAuthentication() throws SQLException {

        // Create an empty datasource of the type befitting the jvm/client/server
        JDBCClient dsclient = getTestConfiguration().getJDBCClient();
        String dsName = dsclient.getDataSourceClassName();
        DataSource ds = null;
        try {
            ds = (javax.sql.DataSource) Class.forName(dsName).newInstance();
        } catch (Exception e) {
            fail("unable to complete test because unable to create new instance of datasource");
        }

        // DataSource - EMPTY
        dsConnectionRequests(new String[] {
             "XJ004","XJ004","XJ004","XJ004",
             "XJ004","XJ004","XJ004","XJ004","XJ004"}, ds);

        // DataSource - connectionAttributes=databaseName=wombat");
        JDBCDataSource.setBeanProperty(ds, "connectionAttributes", "databaseName=" + dbName);
        dsConnectionRequests(new String[] {
            "XJ004","XJ004","XJ004","XJ004",
            "XJ004","XJ004","XJ004","XJ004","XJ004"}, ds);
        JDBCDataSource.clearStringBeanProperty(ds, "connectionAttributes");
        ds = null;

        TestConfiguration.getCurrent().shutdownDatabase();
    }

    /**
     * Check that traceFile connection attribute functions correctly.
     * tracefile was tested in checkDriver, but not for DataSources.
     * tracefile= was used in datasourcepermissions_net, but that's
     * incorrect syntax. Note that we're not checking the contents of
     * the tracefile.
     *
     * This fixture has a counterpart for Pooled and XA DataSources in
     * J2EEDataSourceTest
     *
     * Note also that this test cannot run against a remote server.
     *
     * @throws SQLException
     */
    public void testClientTraceFileDSConnectionAttribute() throws SQLException
    {
        if (usingEmbedded())
            return;

        String traceFile;

        // DataSource
        DataSource ds = JDBCDataSource.getDataSource();

        // DataSource - setTransationAttributes
        traceFile = "trace1.out";
        JDBCDataSource.setBeanProperty(ds, "connectionAttributes",
        		"traceFile="+traceFile);

        // In this scenario, we *only* get a tracefile, if we first get a
        // successful connection, followed by an unsuccessful connection.
        // So, we cannot just use ds.getConnection()
        dsGetBadConnection(ds);
        JDBCDataSource.clearStringBeanProperty(ds, "connectionAttributes");

        // DataSource - setTraceFile
        traceFile = "trace2.out";
        JDBCDataSource.setBeanProperty(ds, "traceFile", traceFile);
        ds.getConnection();
        ds = null;

        assertTraceFilesExist();
    }

    /* -- Helper Methods for testClientTraceFileDSConnectionAttribute -- */

    private static void dsGetBadConnection(DataSource ds) {
        // first get a good connection, or we don't get a
        // traceFile when using connectionattributes.
        // also, we do not get a tracefile that way unless
        // we see an error.
        // with setTraceFile, we *always* get a file, even
        // with just a successful connection.
        try {
            ds.getConnection();
            ds.getConnection(null, null);
            fail("expected an sqlException");
        } catch (SQLException sqle) {
            assertSQLState("08001", sqle);
        }
    }

    /**
     * Check that trace file exists in <framework> directory
     */
    private static void assertTraceFilesExist()
    {
        for (int i = 0; i < 2; i++) {
            String traceFileName = "trace" + (i + 1) + ".out";
            File traceFile = new File(traceFileName);
            assertTrue(PrivilegedFileOpsForTests.exists(traceFile));
        }
    }

    /**
     * Check that messageText connection attribute functions correctly.
     * retrievemessagetext was tested in checkdriver, and derbynet/testij,
     * but not tested for datasources, and in datasourcepermissions_net,
     * but as it has nothing to do with permissions/authentication,
     * this test seems a better place for it.
     *
     * This fixture has a counterpart for Pooled and XA DataSources in
     * J2EEDataSourceTest
     *
     * @throws SQLException
     */
    public void testClientMessageTextConnectionAttribute() throws Exception
    {
        if (usingEmbedded())
            return;

        String retrieveMessageTextProperty = "retrieveMessageText";
        Connection conn;

        // DataSource
        // DataSource - retrieveMessageTextProperty
        ClientDataSourceInterface ds = null;

        if (JDBC.vmSupportsJNDI()) {
            // Use reflection to avoid class not found in non-JNDI context
            ds = (ClientDataSourceInterface)Class.forName(
              "org.apache.derby.jdbc.ClientDataSource").newInstance();
        } else {
            ds = (ClientDataSourceInterface)Class.forName(
              "org.apache.derby.jdbc.BasicClientDataSource40").newInstance();
        }

        ds.setPortNumber(TestConfiguration.getCurrent().getPort());
        ds.setDatabaseName(dbName);
        ds.setConnectionAttributes(retrieveMessageTextProperty + "=false");
        conn = ds.getConnection();
        assertMessageText(conn,"false");
        conn.close();
        // now try with retrieveMessageText = true
        ds.setConnectionAttributes(retrieveMessageTextProperty + "=true");
        conn = ds.getConnection();
        assertMessageText(conn,"true");
        ds.setConnectionAttributes(null);
        conn.close();
    }

    /* -- Helper Method for testClientMessageTextDSConnectionAttribute -- */

    private static void assertMessageText(
            Connection conn, String retrieveMessageTextValue)
    throws SQLException
    {
        try {
            conn.createStatement().executeQuery("SELECT * FROM APP.NOTTHERE");
        }
        catch (SQLException e)
        {
            assertSQLState("42X05", e);
            if (retrieveMessageTextValue.equals("true") )
            {
                assertTrue(e.getMessage().indexOf("does not exist") >= 0);
            }
            else
            {
                // retrieveMessageTextValue is false
                assertTrue(e.getMessage().indexOf("does not exist") == -1);
            }
        }
    }

    /**
     * Check that messageText connection attribute functions correctly.
     * retrievemessagetext was tested in checkdriver, and derbynet/testij
     * (but not tested for datasources), and in datasourcepermissions_net,
     * but as it has nothing to do with permissions/authentication,
     * this test seems a better place for it.
     *
     * This fixture has a counterpart for Pooled and XA DataSources in
     * J2EEDataSourceTest
     *
     * @throws SQLException
     */
    public void testDescriptionProperty()
    throws SQLException, Exception {

        // DataSource - setDescription
        subTestDataSourceDescription(JDBCDataSource.getDataSource());
    }

    /**
     * Utility method for testing setting and fetching the description
     * property on a data source.
     */
    private void subTestDataSourceDescription(DataSource ds) throws Exception
    {
        String setDescription =
            "Everything you ever wanted to know about this datasource";

        JDBCDataSource.setBeanProperty(ds, "description", setDescription);
        ds.getConnection();
        assertEquals(setDescription, JDBCDataSource.getBeanProperty(ds, "description"));
        JDBCDataSource.clearStringBeanProperty(ds, "description");
        assertNull(JDBCDataSource.getBeanProperty(ds, "description"));
    }

    private static void setDatabaseProperty(String property, String value)
    throws SQLException
    {
        DataSource ds = JDBCDataSource.getDataSource();
        Connection cadmin = ds.getConnection();
        CallableStatement cs = cadmin.prepareCall(
            "CALL SYSCS_UTIL.SYSCS_SET_DATABASE_PROPERTY(?, ?)");
        cs.setString(1, property);
        cs.setString(2, value);
        cs.execute();

        cs.close();
        cadmin.close();
    }

    private static void dsConnectionRequests(
        String[] expectedValues, DataSource ds) {

        // checks currently only implemented for embedded
        if (usingEmbedded())
        {
            SecurityCheck.assertSourceSecurity(ds, "javax.sql.DataSource");
        }

        try {
            ds.getConnection();
            if (!expectedValues[0].equals("OK"))
                fail (" expected connection to fail, but was OK");
        } catch (SQLException sqle) {
            assertSQLState(expectedValues[0], sqle);
        }
        dsConnectionRequest(expectedValues[1], ds, null, null);
        dsConnectionRequest(expectedValues[2], ds, "fred", null);
        dsConnectionRequest(expectedValues[3], ds, "fred", "wilma");
        dsConnectionRequest(expectedValues[4], ds, null, "wilma");
        dsConnectionRequest(
            expectedValues[5], ds, null, "databaseName=wombat");
        dsConnectionRequest(
            expectedValues[6], ds, "fred", "databaseName=wombat");
        dsConnectionRequest(expectedValues[7],
            ds, "fred", "databaseName=wombat;password=wilma");
        dsConnectionRequest(expectedValues[8],
            ds, "fred", "databaseName=wombat;password=betty");
    }

    private static void dsConnectionRequest(
        String expectedValue, DataSource ds, String user, String ConnAttr)
    {
        try {
            ds.getConnection(user, ConnAttr);
            if (!expectedValue.equals("OK"))
                fail (" expected connection to fail, but was OK");
        } catch (SQLException sqle) {
            assertSQLState(expectedValue, sqle);
        }
    }

    private void assertConnectionOK(
        Object[] expectedValues, String dsName, Connection conn)
    throws SQLException {

        assertEquals(
            ((Integer)expectedValues[0]).intValue(), conn.getHoldability());

        // check it's a 3.0 connection object by checking if
        // set & release Savepoint is ok.
        try {
            conn.releaseSavepoint(conn.setSavepoint());
            if (conn.getAutoCommit())
                fail("expected a SQLExpection (savepoint with autocommit on");
            if (!((String)expectedValues[1]).equals("OK"))
                fail("expected a SQLExpection (savepoint with autocommit on");
        } catch (SQLException sqle) {
            // we expect savepoints exceptions because either
            // it's a global transaction, or it's in auto commit mode.
            if (conn.getAutoCommit())
                assertSQLState("XJ010", sqle);
            else if (((String)expectedValues[1]).equals("OK"))
                fail ("unexpected JDBC 3.0 savepoint SQL Exception");
            else
                assertSQLState((String)expectedValues[1], sqle);
        }

        // Running connection checks
        // connection checks currently only implemented for Embedded
        if (usingEmbedded())
        {
            SecurityCheck.assertSourceSecurity(conn, "java.sql.Connection");
            SecurityCheck.assertSourceSecurity(
                conn.getMetaData(), "java.sql.DatabaseMetaData");
        }

        assertEquals(((Integer)expectedValues[2]).intValue(),
            conn.getTransactionIsolation());
        assertEquals(((Boolean)expectedValues[3]).booleanValue(),
            conn.getAutoCommit());
        assertEquals(((Boolean)expectedValues[4]).booleanValue(),
            conn.isReadOnly());

        // if this fixture runs without the default db being created,
        // there will not be a warning. Otherwise,  the warning will be,
        // cannot create db, connecting to existing db
        if (conn.getWarnings() != null)
            assertSQLState("01J01", conn.getWarnings());

        Statement s1 = conn.createStatement();
        assertStatementOK(dsName, conn, s1);
        assertStatementOK(dsName, conn, conn.createStatement
            (ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY));

        Connection c1 = conn.getMetaData().getConnection();
        // c1 and conn should be the same connection object.
        if (!usingDerbyNetClient() && dsName.indexOf("DataSource")>=0)
            assertEquals(c1, conn);

        assertConnectionPreClose(dsName, conn);
        conn.close();

        // method calls on a closed connection
        try {
            conn.close(); // expect no error
        } catch (SQLException sqle) {
            fail(" unexpected exception on <closedconn>.close() ");
        }
        try {
            conn.createStatement();
            fail (dsName + " <closedconn>.createStatement(), " +
                "expected 08003 - No current connection");
        } catch (SQLException sqle) {
            assertSQLState("08003", sqle);
        }
        try {
            s1.execute("values 1");
            fail(dsName + " <closedstmt>.execute(), " +
                "expected 08003 - No current connection");
        } catch (SQLException sqle) {
            assertSQLState("08003", sqle);
        }
    }

    private void assertConnectionPreClose(String dsName, Connection conn)
    throws SQLException {

        // before closing the connection, attempt to change holdability
        // and readOnly
        conn.setHoldability(ResultSet.CLOSE_CURSORS_AT_COMMIT);

        if (!dsName.equals("Nested2"))
        {
            try {
                conn.setReadOnly(true);
            } catch (SQLException sqle) {
                // cannot set read-only in an active transaction, & sometimes
                // connections are active at this point.
                assertSQLState("25501", sqle);
            }
        }
    }

    private void assertStatementOK(String dsName, Connection conn, Statement s)
    throws SQLException {

        // checks currently only implemented for embedded
        if (usingEmbedded())
        {
            SecurityCheck.assertSourceSecurity(s, "java.sql.Statement");
        }

        Connection c1 = s.getConnection();
        if (c1 != conn)
        {
            // with DerbyNetClient and any kind of DataSource, this goes wrong
            if (!usingDerbyNetClient() && (dsName.indexOf("DataSource") >= 0))
                fail ("incorrect connection object returned for Statement.getConnection()");
        }

        s.addBatch("insert into intTable values 1");
        s.addBatch("insert into intTable values 2,3");
        int[] states = s.executeBatch();
        if (states[0] != 1)
            fail ("invalid update count for first batch statement");
        if (states[1] != 2)
            fail ("invalid update count for second batch statement");

        ResultSet rs = s.executeQuery("VALUES 1");
        if (rs.getStatement() != s)
            fail ("incorrect Statement object returned for ResultSet.getStatement for " + dsName);
        rs.close();
        s.close();
    }

    /**
     * Make sure this connection's string is unique (DERBY-243)
     */
    private static void assertToString(Connection conn) throws Exception
    {
        assertStringFormat(conn);
        String str = conn.toString();

        if ( conns.containsKey(str))
        {
            throw new Exception("ERROR: Connection toString() is not unique: "
                    + str);
        }
        conns.put(str, conn);
    }

    /**
     * Check the format of the connection string.  This is the default test
     * to run if this is not a BrokeredConnection class
     */
    private static void assertStringFormat(Connection conn) //throws Exception
    {
        assertStringPrefix(conn);
        String str = conn.toString();
        // matches is not a supported method with JSR169
        if (!JDBC.vmSupportsJSR169())
            assertTrue("\nexpected format:\n " + CONNSTRING_FORMAT + "\nactual value:\n " + str,
                    str.matches(CONNSTRING_FORMAT));
    }

    /**
     * Make sure the connection string starts with the right prefix, which
     * is the classname@hashcode.
     *
     * @return the expected prefix string, this is used in further string
     *   format checking
     */
    private static String assertStringPrefix(Object conn) //throws Exception
    {
        String connstr = conn.toString();
        String prefix = conn.getClass().getName() + "@" + conn.hashCode();
        // Connection class and has code for connection string should
        // match prefix
        assertTrue(connstr.startsWith(prefix));

        return prefix;
    }

    /**
     * Check uniqueness of connection strings coming from a
     * DataSouce
     */
    private static void assertToString(DataSource ds) throws Exception
    {
        clearConnections();

        int numConnections = 10;
        for ( int i = 0 ; i < numConnections ; i++ )
        {
            Connection conn = ds.getConnection();
            assertToString(conn);
        }

        clearConnections();
    }

    /**
     * Clear out and close connections in the connections
     * hashtable.
     */
    private static void clearConnections() throws SQLException
    {
        for (Connection conn : conns.values()) {
            conn.close();
        }
        conns.clear();
    }

    /**
     * Get connections  using getConnection() and make sure
     * they're unique
     */
    private void assertTenConnectionsUnique() throws Exception
    {
        clearConnections();
        // Open ten connections rather than just two to
        // try and catch any odd uniqueness bugs.  Still
        // no guarantee but is better than just two.
        int numConnections = 10;
        for ( int i = 0 ; i < numConnections ; i++ )
        {
            Connection conn = openDefaultConnection();
            assertToString(conn);
        }

        // Now close the connections
        clearConnections();
    }
}


text:
require 'spec_helper'

describe Projectdependency do

  let(:user)    { UserFactory.create_new }
  let(:project) { ProjectFactory.create_new user }

  describe "find_or_init_product" do
    it "returns the right product" do
      project.project_type = Project::A_TYPE_BOWER
      project.save

      bootstrap_css = ProductFactory.create_for_bower 'bootstrap', '3.1.1'
      bootstrap_css.prod_key = 'twbs/bootstrap'
      bootstrap_css.language = 'CSS'
      bootstrap_css.save

      bootstrap = ProductFactory.create_for_bower 'bootstrap', '3.1.1'
      bootstrap.prod_key = 'bootstrap'
      bootstrap.language = 'CSS'
      bootstrap.prod_type = Project::A_TYPE_GITHUB
      bootstrap.save

      dep_1 = ProjectdependencyFactory.create_new project, bootstrap_css, {:version_requested => '3.1.1'}
      dep_1.prod_key = nil
      dep_1.save
      project.dependencies.count.should eq(1)

      prod = dep_1.find_or_init_product
      prod.should_not be_nil
      prod.prod_key.should eq('twbs/bootstrap')

      project.project_type = Project::A_TYPE_GITHUB
      project.save
      dep = project.dependencies.first
      dep.prod_key = 'bootstrap'
      prod = dep.find_or_init_product
      prod.prod_key.should eq('bootstrap')
    end

    it "returns the right Maven product by group_id and artifact_id" do
      project.project_type = Project::A_TYPE_MAVEN2
      project.save

      junit = ProductFactory.create_for_maven 'org.junit', 'junit', '3.2.1'
      junit.save

      dep_1 = ProjectdependencyFactory.create_new project, junit
      dep_1.prod_key = ''
      dep_1.save
      project.dependencies.count.should eq(1)

      prod = dep_1.find_or_init_product
      prod.should_not be_nil
      prod.prod_key.should eq('org.junit/junit')
    end

    it "returns the right Ruby product" do
      project.project_type = Project::A_TYPE_RUBYGEMS
      project.save

      log4r = ProductFactory.create_for_gemfile 'log4r', '3.2.1'
      log4r.save

      dep_1 = ProjectdependencyFactory.create_new project, log4r
      dep_1.save
      project.dependencies.count.should eq(1)

      prod = dep_1.find_or_init_product
      prod.should_not be_nil
      prod.prod_key.should eq('log4r')
    end

    it "inits the product" do
      dep_1 = ProjectdependencyFactory.create_new project, nil
      dep_1.save
      project.dependencies.count.should eq(1)

      prod = dep_1.find_or_init_product
      prod.should_not be_nil
      prod.prod_key.should be_nil
      prod.name.should eq(dep_1.name)
    end
  end

  describe 'possible_prod_key' do
    it 'returns the name' do
      dep = Projectdependency.new
      dep.name = "AhA"
      dep.possible_prod_key.should eql("aha")
    end
    it 'returns the group_id/artifact_id' do
      dep = Projectdependency.new
      dep.name = "AhA"
      dep.group_id = "org.junit"
      dep.artifact_id = "testng"
      dep.possible_prod_key.should eql("org.junit/testng")
    end
  end

  describe 'cwl_key' do
    it 'returns gav' do
      dep = Projectdependency.new(:group_id => "org.spring", :artifact_id => "sponk-core", :version_requested => "1.0.0")
      expect( dep.cwl_key ).to eql("org.spring:sponk-core:1.0.0")
    end
    it 'returns language prod_key and version' do
      dep = Projectdependency.new(:language => "Ruby", :prod_key => "rails", :version_requested => "1.0.0")
      expect( dep.cwl_key ).to eql("ruby:rails:1.0.0")
    end
  end

  describe 'find_by_id' do
    it 'returns the dep' do
      dep = Projectdependency.new(:language => "Java", :prod_key => 'org.spring/sponk-core', :group_id => "org.spring", :artifact_id => "sponk-core", :version_requested => "1.0.0")
      expect( dep.save ).to be_truthy
      expect( Projectdependency.find_by_id(dep.ids) ).to_not be_nil
    end
    it 'returns nil' do
      expect( Projectdependency.find_by_id( 'faf' ) ).to be_nil
    end
  end

  describe 'version' do
    it 'returns version_requested' do
      dep = Projectdependency.new( :version_requested => "1.0.0" )
      expect( dep.version ).to eql( dep.version_requested )
    end
  end

  describe 'language_esc' do
    it 'returns encoded language' do
      dep = Projectdependency.new( :language => "Node.JS" )
      expect( dep.language_esc ).to eql( 'nodejs' )
    end
  end

  describe 'unmuted_security_vulnerabilities' do
    it 'returns an empty list' do
      dep = Projectdependency.new( :language => "Node.JS" )
      expect( dep.unmuted_security_vulnerabilities ).to be_empty
    end
    it 'returns an empty list' do
      dep = Projectdependency.new( :language => "Node.JS" )
      dep.sv_ids = [22]
      expect( dep.unmuted_security_vulnerabilities ).to_not be_empty
    end
    it 'returns an empty list' do
      project.muted_svs = {'22' => 'not important.'}
      dep = Projectdependency.new( :language => "Node.JS" )
      dep.sv_ids = [22]
      dep.project = project
      expect( dep.unmuted_security_vulnerabilities ).to be_empty
    end
  end

  describe 'product' do

    it 'returns the right product' do
      project.project_type = Project::A_TYPE_RUBYGEMS
      project.save

      log4r = ProductFactory.create_for_gemfile 'log4r', '3.2.1'
      log4r.save

      dep_1 = ProjectdependencyFactory.create_new project, log4r
      dep_1.version_label = '3.2.1'
      dep_1.version_current = '3.2.1'
      dep_1.save
      project.dependencies.count.should eq(1)

      dep_1.known?().should be_truthy
      pr = dep_1.product
      pr.should_not be_nil
      pr.prod_key.should eq('log4r')
      dep_1.to_s.should eq("<Projectdependency: #{project} depends on log4r (3.2.1/) current: 3.2.1 >")
    end

    it 'returns the right product for bower' do
      project.project_type = Project::A_TYPE_BOWER
      project.save

      log4r = ProductFactory.create_for_bower 'log4r', '3.2.1'
      log4r.save

      dep_1 = ProjectdependencyFactory.create_new project, log4r
      dep_1.version_label = '3.2.1'
      dep_1.version_current = '3.2.1'
      dep_1.save
      project.dependencies.count.should eq(1)

      dep_1.known?().should be_truthy
      pr = dep_1.product
      expect( pr ).to_not be_nil
      expect( pr.prod_key).to eq('log4r')
      expect( dep_1.to_s ).to eq("<Projectdependency: #{project} depends on log4r (3.2.1/) current: 3.2.1 >")
    end

    it 'returns the right product for maven' do
      project.project_type = Project::A_TYPE_MAVEN2
      project.save

      log4r = ProductFactory.create_for_maven 'org.spring', 'spring-core', '3.2.1'
      log4r.save

      dep_1 = ProjectdependencyFactory.create_new project, log4r
      dep_1.version_label = '3.2.1'
      dep_1.version_current = '3.2.1'
      dep_1.save
      project.dependencies.count.should eq(1)

      dep_1.known?().should be_truthy
      pr = dep_1.product
      expect( pr ).to_not be_nil
      expect( pr.prod_key).to eq('org.spring/spring-core')
      expect( pr.group_id).to eq('org.spring')
      expect( pr.artifact_id).to eq('spring-core')
    end
  end

end


text:
FactoryGirl.define do
  factory :domain do
    domain 'example.com'
  end
end


text:
Object.defineProperty(exports,"__esModule",{value:true});

var _ObjectManager=require('../../../../units/urb-base-server/graphql/ObjectManager');var _ObjectManager2=_interopRequireDefault(_ObjectManager);function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj};}function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function");}}var

ToDo=

function ToDo(fields)

{_classCallCheck(this,ToDo);
this.id=fields.id;
this.ToDo_User_id=fields.ToDo_User_id;
this.ToDo_Text=fields.ToDo_Text;
this.ToDo_Complete=fields.ToDo_Complete;
};exports.default=ToDo;

_ObjectManager2.default.registerEntity('ToDo',ToDo);
//# sourceMappingURL=ToDo.js.map


text:
<?php
/**
 * WatermarkedImageExtension
 * @notee decorates Image, provides some resize methods
 */
class WatermarkedImageExtension extends DataExtension {

	private function getWatermarkedImage() {
		if($this->owner instanceof Image) {
			//return a watermarkable Image object, extending Image
			return new WatermarkedImage($this->owner->getAllFields());
		}
		return FALSE;
	}

	private function applyResize($method, $width = 0, $height = 0) {
		if($image = $this->getWatermarkedImage()) {
			switch($method) {
				case 'SetWidth':
				case 'SetHeight':
				case 'PaddedImage':
				case 'SetSize':
				case 'CroppedImage':
					return $image->getFormattedImage($method, $width, $height);
					break;
				default:
					return FALSE;
					break;
			}
		}
		return FALSE;
	}

	public function WatermarkSetWidth($width) {
		return $this->applyResize('SetWidth',$width);
	}

	public function WatermarkSetHeight($height) {
		return $this->applyResize('SetHeight',$height);
	}

	public function WatermarkPaddedImage($width, $height) {
		return $this->applyResize('PaddedImage',$width, $height);
	}

	public function WatermarkCroppedImage($width, $height) {
		return $this->applyResize('CroppedImage',$width, $height);
	}

	public function WatermarkSetSize($width, $height) {
		return $this->applyResize('SetSize',$width, $height);
	}

	public function WatermarkLink() {
		$wm = $this->getWatermarkedImage();
		$copy = $wm->SetSize($wm->getWidth(), $wm->getHeight());
		if($copy) {
			unset($wm);
			return $copy->Link();
		}
		return $this->owner->Link();
	}
}
?>


text:
#     # def test_index_exist(self):
#     #     self.apimock.do_request.side_effect = [responses_group.group_existing_one]

#     #     grp = zabbixmgm.zbxgroup(self.apimock, 'myhosts')

#     #     self.apimock.assert_has_calls([call.do_request('hostgroup.get', {'filter': {'name': 'myhosts'}, 'output': 'extend'})])
#     #     self.assertEqual(int(grp.get_id()), 8, 'GroupID does not match')
#     #     self.assertEqual(len(self.apimock.mock_calls), 1)

#     # def test_create_nonexist(self):
#     #     self.apimock.do_request.side_effect = [responses_group.empty, responses_group.group_created_success, responses_group.group_existing_one]

#     #     grp = zabbixmgm.zbxgroup(self.apimock, 'myhosts')
#     #     grp.create()
#     #     self.apimock.assert_has_calls(
#     #             [
#     #                 call.do_request('hostgroup.get', {'filter': {'name': 'myhosts'}, 'output': 'extend'}),
#     #                 call.do_request('hostgroup.create', {'name': 'myhosts'}),
#     #                 call.do_request('hostgroup.get', {'filter': {'name': 'myhosts'}, 'output': 'extend'})
#     #             ]
#     #         )

#     #     self.assertEqual(len(self.apimock.mock_calls), 3)
#     #     self.assertEqual(int(grp.get_id()), 8)

#     # def test_create_exist(self):
#     #     self.apimock.do_request.side_effect = [responses_group.group_existing_one, responses_group.group_created_success, responses_group.group_existing_one]

#     #     grp = zabbixmgm.zbxgroup(self.apimock, 'myhosts')
#     #     grp.create()
#     #     self.apimock.assert_has_calls(
#     #             [
#     #                 call.do_request('hostgroup.get', {'filter': {'name': 'myhosts'}, 'output': 'extend'})
#     #             ]
#     #         )
#     #     self.assertEqual(len(self.apimock.mock_calls), 1)
#     #     self.assertEqual(int(grp.get_id()), 8)

#     # def test_delete_exist(self):
#     #     self.apimock.do_request.side_effect = [responses_group.group_existing_one, responses_group.group_delete_success, responses_group.empty]#,, responses_group.group_existing_one]

#     #     grp = zabbixmgm.zbxgroup(self.apimock, 'myhosts')
#     #     self.assertEqual(int(grp.get_id()), 8)
#     #     grp.delete()
#     #     self.apimock.assert_has_calls(
#     #             [
#     #                 call.do_request('hostgroup.get', {'filter': {'name': 'myhosts'}, 'output': 'extend'})
#     #             ]
#     #         )
#     #     self.assertEqual(len(self.apimock.mock_calls), 3)
#     #     self.assertEqual(int(grp.get_id()), 0)


text:
package org.apache.river.concurrent;

/**
 *
 * @param <T>
 * @author peter
 */
class TimedReferrerDecorator<T> extends ReferrerDecorator<T> implements TimeBomb {

    TimedReferrerDecorator(Referrer<T> r){
        super(r);
        if (!(r instanceof TimeBomb)) throw new IllegalStateException("Must be instance of TimeBomb");
    }

    public void updateClock(long time) {
        Referrer<T> r = getReference();
        ((TimeBomb)r).updateClock(time);
    }

}