text:
/**
 * @class Ext.Toolbar
 * @extends Ext.Container
 *
Basic Toolbar class. Although the <tt>{@link Ext.Container#defaultType defaultType}</tt> for Toolbar
 * is <tt>{@link Ext.Button button}</tt>, Toolbar elements (child items for the Toolbar container) may
 * be virtually any type of Component. Toolbar elements can be created explicitly via their constructors,
 * or implicitly via their xtypes, and can be <tt>{@link #add}</tt>ed dynamically.

 *
Some items have shortcut strings for creation:

 *

Shortcut  xtype          Class                  Description
'->'      'tbfill'       {@link Ext.Toolbar.Fill}       begin using the right-justified button container
'-'       'tbseparator'  {@link Ext.Toolbar.Separator}  add a vertical separator bar between toolbar items
' '       'tbspacer'     {@link Ext.Toolbar.Spacer}     add horiztonal space between elements
 *

 *
 * Example usage of various elements:
 *

var tb = new Ext.Toolbar({
    renderTo: document.body,
    width: 600,
    height: 100,
    items: [
        {
            // xtype: 'button', // default for Toolbars, same as 'tbbutton'
            text: 'Button'
        },
        {
            xtype: 'splitbutton', // same as 'tbsplitbutton'
            text: 'Split Button'
        },
        // begin using the right-justified button container
        '->', // same as {xtype: 'tbfill'}, // Ext.Toolbar.Fill
        {
            xtype: 'textfield',
            name: 'field1',
            emptyText: 'enter search term'
        },
        // add a vertical separator bar between toolbar items
        '-', // same as {xtype: 'tbseparator'} to create Ext.Toolbar.Separator
        'text 1', // same as {xtype: 'tbtext', text: 'text1'} to create Ext.Toolbar.TextItem
        {xtype: 'tbspacer'},// same as ' ' to create Ext.Toolbar.Spacer
        'text 2',
        {xtype: 'tbspacer', width: 50}, // add a 50px space
        'text 3'
    ]
});
 *

 * Example adding a ComboBox within a menu of a button:
 *

// ComboBox creation
var combo = new Ext.form.ComboBox({
    store: new Ext.data.ArrayStore({
        autoDestroy: true,
        fields: ['initials', 'fullname'],
        data : [
            ['FF', 'Fred Flintstone'],
            ['BR', 'Barney Rubble']
        ]
    }),
    displayField: 'fullname',
    typeAhead: true,
    mode: 'local',
    forceSelection: true,
    triggerAction: 'all',
    emptyText: 'Select a name...',
    selectOnFocus: true,
    width: 135,
    getListParent: function() {
        return this.el.up('.x-menu');
    },
    iconCls: 'no-icon' //use iconCls if placing within menu to shift to right side of menu
});

// put ComboBox in a Menu
var menu = new Ext.menu.Menu({
    id: 'mainMenu',
    items: [
        combo // A Field in a Menu
    ]
});

// add a Button with the menu
tb.add({
        text:'Button w/ Menu',
        menu: menu  // assign menu by instance
    });
tb.doLayout();
 *

 * @constructor
 * Creates a new Toolbar
 * @param {Object/Array} config A config object or an array of buttons to <tt>{@link #add}</tt>
 * @xtype toolbar
 */
Ext.Toolbar = function(config){
    if(Ext.isArray(config)){
        config = {items: config, layout: 'toolbar'};
    } else {
        config = Ext.apply({
            layout: 'toolbar'
        }, config);
        if(config.buttons) {
            config.items = config.buttons;
        }
    }
    Ext.Toolbar.superclass.constructor.call(this, config);
};

(function(){

var T = Ext.Toolbar;

Ext.extend(T, Ext.Container, {

    defaultType: 'button',

    /**
     * @cfg {String/Object} layout
     * This class assigns a default layout (layout:'toolbar').
     * Developers may override this configuration option if another layout
     * is required (the constructor must be passed a configuration object in this
     * case instead of an array).
     * See {@link Ext.Container#layout} for additional information.
     */

    enableOverflow : false,

    /**
     * @cfg {Boolean} enableOverflow
     * Defaults to false. Configure <tt>true</tt> to make the toolbar provide a button
     * which activates a dropdown Menu to show items which overflow the Toolbar's width.
     */
    /**
     * @cfg {String} buttonAlign
     *
The default position at which to align child items. Defaults to "left"

     *
May be specified as "center" to cause items added before a Fill (A "->") item
     * to be centered in the Toolbar. Items added after a Fill are still right-aligned.

     *
Specify as "right" to right align all child items.

     */

    trackMenus : true,
    internalDefaults: {removeMode: 'container', hideParent: true},
    toolbarCls: 'x-toolbar',

    initComponent : function(){
        T.superclass.initComponent.call(this);

        /**
         * @event overflowchange
         * Fires after the overflow state has changed.
         * @param {Object} c The Container
         * @param {Boolean} lastOverflow overflow state
         */
        this.addEvents('overflowchange');
    },

    // private
    onRender : function(ct, position){
        if(!this.el){
            if(!this.autoCreate){
                this.autoCreate = {
                    cls: this.toolbarCls + ' x-small-editor'
                };
            }
            this.el = ct.createChild(Ext.apply({ id: this.id },this.autoCreate), position);
            Ext.Toolbar.superclass.onRender.apply(this, arguments);
        }
    },

    /**
     *
Adds element(s) to the toolbar -- this function takes a variable number of
     * arguments of mixed type and adds them to the toolbar.

     *

Note: See the notes within {@link Ext.Container#add}.

     * @param {Mixed} arg1 The following types of arguments are all valid:

     *

     *
{@link Ext.Button} config: A valid button config object (equivalent to {@link #addButton})

     *
HtmlElement: Any standard HTML element (equivalent to {@link #addElement})

     *
Field: Any form field (equivalent to {@link #addField})

     *
Item: Any subclass of {@link Ext.Toolbar.Item} (equivalent to {@link #addItem})

     *
String: Any generic string (gets wrapped in a {@link Ext.Toolbar.TextItem}, equivalent to {@link #addText}).
     * Note that there are a few special strings that are treated differently as explained next.

     *
'-': Creates a separator element (equivalent to {@link #addSeparator})

     *
' ': Creates a spacer element (equivalent to {@link #addSpacer})

     *
'->': Creates a fill element (equivalent to {@link #addFill})

     *

     * @param {Mixed} arg2
     * @param {Mixed} etc.
     * @method add
     */

    // private
    lookupComponent : function(c){
        if(Ext.isString(c)){
            if(c == '-'){
                c = new T.Separator();
            }else if(c == ' '){
                c = new T.Spacer();
            }else if(c == '->'){
                c = new T.Fill();
            }else{
                c = new T.TextItem(c);
            }
            this.applyDefaults(c);
        }else{
            if(c.isFormField || c.render){ // some kind of form field, some kind of Toolbar.Item
                c = this.createComponent(c);
            }else if(c.tag){ // DomHelper spec
                c = new T.Item({autoEl: c});
            }else if(c.tagName){ // element
                c = new T.Item({el:c});
            }else if(Ext.isObject(c)){ // must be button config?
                c = c.xtype ? this.createComponent(c) : this.constructButton(c);
            }
        }
        return c;
    },

    // private
    applyDefaults : function(c){
        if(!Ext.isString(c)){
            c = Ext.Toolbar.superclass.applyDefaults.call(this, c);
            var d = this.internalDefaults;
            if(c.events){
                Ext.applyIf(c.initialConfig, d);
                Ext.apply(c, d);
            }else{
                Ext.applyIf(c, d);
            }
        }
        return c;
    },

    /**
     * Adds a separator
     *

Note: See the notes within {@link Ext.Container#add}.

     * @return {Ext.Toolbar.Item} The separator {@link Ext.Toolbar.Item item}
     */
    addSeparator : function(){
        return this.add(new T.Separator());
    },

    /**
     * Adds a spacer element
     *

Note: See the notes within {@link Ext.Container#add}.

     * @return {Ext.Toolbar.Spacer} The spacer item
     */
    addSpacer : function(){
        return this.add(new T.Spacer());
    },

    /**
     * Forces subsequent additions into the float:right toolbar
     *

Note: See the notes within {@link Ext.Container#add}.

     */
    addFill : function(){
        this.add(new T.Fill());
    },

    /**
     * Adds any standard HTML element to the toolbar
     *

Note: See the notes within {@link Ext.Container#add}.

     * @param {Mixed} el The element or id of the element to add
     * @return {Ext.Toolbar.Item} The element's item
     */
    addElement : function(el){
        return this.addItem(new T.Item({el:el}));
    },

    /**
     * Adds any Toolbar.Item or subclass
     *

Note: See the notes within {@link Ext.Container#add}.

     * @param {Ext.Toolbar.Item} item
     * @return {Ext.Toolbar.Item} The item
     */
    addItem : function(item){
        return this.add.apply(this, arguments);
    },

    /**
     * Adds a button (or buttons). See {@link Ext.Button} for more info on the config.
     *

Note: See the notes within {@link Ext.Container#add}.

     * @param {Object/Array} config A button config or array of configs
     * @return {Ext.Button/Array}
     */
    addButton : function(config){
        if(Ext.isArray(config)){
            var buttons = [];
            for(var i = 0, len = config.length; i < len; i++) {
                buttons.push(this.addButton(config[i]));
            }
            return buttons;
        }
        return this.add(this.constructButton(config));
    },

    /**
     * Adds text to the toolbar
     *

Note: See the notes within {@link Ext.Container#add}.

     * @param {String} text The text to add
     * @return {Ext.Toolbar.Item} The element's item
     */
    addText : function(text){
        return this.addItem(new T.TextItem(text));
    },

    /**
     * Adds a new element to the toolbar from the passed {@link Ext.DomHelper} config
     *

Note: See the notes within {@link Ext.Container#add}.

     * @param {Object} config
     * @return {Ext.Toolbar.Item} The element's item
     */
    addDom : function(config){
        return this.add(new T.Item({autoEl: config}));
    },

    /**
     * Adds a dynamically rendered Ext.form field (TextField, ComboBox, etc). Note: the field should not have
     * been rendered yet. For a field that has already been rendered, use {@link #addElement}.
     *

Note: See the notes within {@link Ext.Container#add}.

     * @param {Ext.form.Field} field
     * @return {Ext.Toolbar.Item}
     */
    addField : function(field){
        return this.add(field);
    },

    /**
     * Inserts any {@link Ext.Toolbar.Item}/{@link Ext.Button} at the specified index.
     *

Note: See the notes within {@link Ext.Container#add}.

     * @param {Number} index The index where the item is to be inserted
     * @param {Object/Ext.Toolbar.Item/Ext.Button/Array} item The button, or button config object to be
     * inserted, or an array of buttons/configs.
     * @return {Ext.Button/Item}
     */
    insertButton : function(index, item){
        if(Ext.isArray(item)){
            var buttons = [];
            for(var i = 0, len = item.length; i < len; i++) {
               buttons.push(this.insertButton(index + i, item[i]));
            }
            return buttons;
        }
        return Ext.Toolbar.superclass.insert.call(this, index, item);
    },

    // private
    trackMenu : function(item, remove){
        if(this.trackMenus && item.menu){
            var method = remove ? 'mun' : 'mon';
            this[method](item, 'menutriggerover', this.onButtonTriggerOver, this);
            this[method](item, 'menushow', this.onButtonMenuShow, this);
            this[method](item, 'menuhide', this.onButtonMenuHide, this);
        }
    },

    // private
    constructButton : function(item){
        var b = item.events ? item : this.createComponent(item, item.split ? 'splitbutton' : this.defaultType);
        return b;
    },

    // private
    onAdd : function(c){
        Ext.Toolbar.superclass.onAdd.call(this);
        this.trackMenu(c);
        if(this.disabled){
            c.disable();
        }
    },

    // private
    onRemove : function(c){
        Ext.Toolbar.superclass.onRemove.call(this);
        if (c == this.activeMenuBtn) {
            delete this.activeMenuBtn;
        }
        this.trackMenu(c, true);
    },

    // private
    onDisable : function(){
        this.items.each(function(item){
             if(item.disable){
                 item.disable();
             }
        });
    },

    // private
    onEnable : function(){
        this.items.each(function(item){
             if(item.enable){
                 item.enable();
             }
        });
    },

    // private
    onButtonTriggerOver : function(btn){
        if(this.activeMenuBtn && this.activeMenuBtn != btn){
            this.activeMenuBtn.hideMenu();
            btn.showMenu();
            this.activeMenuBtn = btn;
        }
    },

    // private
    onButtonMenuShow : function(btn){
        this.activeMenuBtn = btn;
    },

    // private
    onButtonMenuHide : function(btn){
        delete this.activeMenuBtn;
    }
});
Ext.reg('toolbar', Ext.Toolbar);

/**
 * @class Ext.Toolbar.Item
 * @extends Ext.BoxComponent
 * The base class that other non-interacting Toolbar Item classes should extend in order to
 * get some basic common toolbar item functionality.
 * @constructor
 * Creates a new Item
 * @param {HTMLElement} el
 * @xtype tbitem
 */
T.Item = Ext.extend(Ext.BoxComponent, {
    hideParent: true, //  Hiding a Toolbar.Item hides its containing TD
    enable:Ext.emptyFn,
    disable:Ext.emptyFn,
    focus:Ext.emptyFn
    /**
     * @cfg {String} overflowText Text to be used for the menu if the item is overflowed.
     */
});
Ext.reg('tbitem', T.Item);

/**
 * @class Ext.Toolbar.Separator
 * @extends Ext.Toolbar.Item
 * A simple class that adds a vertical separator bar between toolbar items
 * (css class:<tt>'xtb-sep'</tt>). Example usage:
 *

new Ext.Panel({
    tbar : [
        'Item 1',
        {xtype: 'tbseparator'}, // or '-'
        'Item 2'
    ]
});

 * @constructor
 * Creates a new Separator
 * @xtype tbseparator
 */
T.Separator = Ext.extend(T.Item, {
    onRender : function(ct, position){
        this.el = ct.createChild({tag:'span', cls:'xtb-sep'}, position);
    }
});
Ext.reg('tbseparator', T.Separator);

/**
 * @class Ext.Toolbar.Spacer
 * @extends Ext.Toolbar.Item
 * A simple element that adds extra horizontal space between items in a toolbar.
 * By default a 2px wide space is added via css specification:

.x-toolbar .xtb-spacer {
    width:2px;
}
 *

 *
Example usage:

 *

new Ext.Panel({
    tbar : [
        'Item 1',
        {xtype: 'tbspacer'}, // or ' '
        'Item 2',
        // space width is also configurable via javascript
        {xtype: 'tbspacer', width: 50}, // add a 50px space
        'Item 3'
    ]
});

 * @constructor
 * Creates a new Spacer
 * @xtype tbspacer
 */
T.Spacer = Ext.extend(T.Item, {
    /**
     * @cfg {Number} width
     * The width of the spacer in pixels (defaults to 2px via css style <tt>.x-toolbar .xtb-spacer</tt>).
     */

    onRender : function(ct, position){
        this.el = ct.createChild({tag:'div', cls:'xtb-spacer', style: this.width?'width:'+this.width+'px':''}, position);
    }
});
Ext.reg('tbspacer', T.Spacer);

/**
 * @class Ext.Toolbar.Fill
 * @extends Ext.Toolbar.Spacer
 * A non-rendering placeholder item which instructs the Toolbar's Layout to begin using
 * the right-justified button container.
 *

new Ext.Panel({
    tbar : [
        'Item 1',
        {xtype: 'tbfill'}, // or '->'
        'Item 2'
    ]
});

 * @constructor
 * Creates a new Fill
 * @xtype tbfill
 */
T.Fill = Ext.extend(T.Item, {
    // private
    render : Ext.emptyFn,
    isFill : true
});
Ext.reg('tbfill', T.Fill);

/**
 * @class Ext.Toolbar.TextItem
 * @extends Ext.Toolbar.Item
 * A simple class that renders text directly into a toolbar
 * (with css class:<tt>'xtb-text'</tt>). Example usage:
 *

new Ext.Panel({
    tbar : [
        {xtype: 'tbtext', text: 'Item 1'} // or simply 'Item 1'
    ]
});

 * @constructor
 * Creates a new TextItem
 * @param {String/Object} text A text string, or a config object containing a <tt>text</tt> property
 * @xtype tbtext
 */
T.TextItem = Ext.extend(T.Item, {
    /**
     * @cfg {String} text The text to be used as innerHTML (html tags are accepted)
     */

    constructor: function(config){
        T.TextItem.superclass.constructor.call(this, Ext.isString(config) ? {text: config} : config);
    },

    // private
    onRender : function(ct, position) {
        this.autoEl = {cls: 'xtb-text', html: this.text || ''};
        T.TextItem.superclass.onRender.call(this, ct, position);
    },

    /**
     * Updates this item's text, setting the text to be used as innerHTML.
     * @param {String} t The text to display (html accepted).
     */
    setText : function(t) {
        if(this.rendered){
            this.el.update(t);
        }else{
            this.text = t;
        }
    }
});
Ext.reg('tbtext', T.TextItem);

// backwards compat
T.Button = Ext.extend(Ext.Button, {});
T.SplitButton = Ext.extend(Ext.SplitButton, {});
Ext.reg('tbbutton', T.Button);
Ext.reg('tbsplit', T.SplitButton);

})();
/**
 * @class Ext.ButtonGroup
 * @extends Ext.Panel
 * Container for a group of buttons. Example usage:
 *

var p = new Ext.Panel({
    title: 'Panel with Button Group',
    width: 300,
    height:200,
    renderTo: document.body,
    html: 'whatever',
    tbar: [{
        xtype: 'buttongroup',
        {@link #columns}: 3,
        title: 'Clipboard',
        items: [{
            text: 'Paste',
            scale: 'large',
            rowspan: 3, iconCls: 'add',
            iconAlign: 'top',
            cls: 'x-btn-as-arrow'
        },{
            xtype:'splitbutton',
            text: 'Menu Button',
            scale: 'large',
            rowspan: 3,
            iconCls: 'add',
            iconAlign: 'top',
            arrowAlign:'bottom',
            menu: [{text: 'Menu Item 1'}]
        },{
            xtype:'splitbutton', text: 'Cut', iconCls: 'add16', menu: [{text: 'Cut Menu Item'}]
        },{
            text: 'Copy', iconCls: 'add16'
        },{
            text: 'Format', iconCls: 'add16'
        }]
    }]
});
 *

 * @constructor
 * Create a new ButtonGroup.
 * @param {Object} config The config object
 * @xtype buttongroup
 */
Ext.ButtonGroup = Ext.extend(Ext.Panel, {
    /**
     * @cfg {Number} columns The <tt>columns</tt> configuration property passed to the
     * {@link #layout configured layout manager}. See {@link Ext.layout.TableLayout#columns}.
     */
    /**
     * @cfg {String} baseCls  Defaults to <tt>'x-btn-group'</tt>.  See {@link Ext.Panel#baseCls}.
     */
    baseCls: 'x-btn-group',
    /**
     * @cfg {String} layout  Defaults to <tt>'table'</tt>.  See {@link Ext.Container#layout}.
     */
    layout:'table',
    defaultType: 'button',
    /**
     * @cfg {Boolean} frame  Defaults to <tt>true</tt>.  See {@link Ext.Panel#frame}.
     */
    frame: true,
    internalDefaults: {removeMode: 'container', hideParent: true},

    initComponent : function(){
        this.layoutConfig = this.layoutConfig || {};
        Ext.applyIf(this.layoutConfig, {
            columns : this.columns
        });
        if(!this.title){
            this.addClass('x-btn-group-notitle');
        }
        this.on('afterlayout', this.onAfterLayout, this);
        Ext.ButtonGroup.superclass.initComponent.call(this);
    },

    applyDefaults : function(c){
        c = Ext.ButtonGroup.superclass.applyDefaults.call(this, c);
        var d = this.internalDefaults;
        if(c.events){
            Ext.applyIf(c.initialConfig, d);
            Ext.apply(c, d);
        }else{
            Ext.applyIf(c, d);
        }
        return c;
    },

    onAfterLayout : function(){
        var bodyWidth = this.body.getFrameWidth('lr') + this.body.dom.firstChild.offsetWidth;
        this.body.setWidth(bodyWidth);
        this.el.setWidth(bodyWidth + this.getFrameWidth());
    }
    /**
     * @cfg {Array} tools  @hide
     */
});

Ext.reg('buttongroup', Ext.ButtonGroup);
/**
 * @class Ext.PagingToolbar
 * @extends Ext.Toolbar
 *
As the amount of records increases, the time required for the browser to render
 * them increases. Paging is used to reduce the amount of data exchanged with the client.
 * Note: if there are more records/rows than can be viewed in the available screen area, vertical
 * scrollbars will be added.

 *
Paging is typically handled on the server side (see exception below). The client sends
 * parameters to the server side, which the server needs to interpret and then respond with the
 * approprate data.

 *
Ext.PagingToolbar is a specialized toolbar that is bound to a {@link Ext.data.Store}
 * and provides automatic paging control. This Component {@link Ext.data.Store#load load}s blocks
 * of data into the <tt>{@link #store}</tt> by passing {@link Ext.data.Store#paramNames paramNames} used for
 * paging criteria.

 *
PagingToolbar is typically used as one of the Grid's toolbars:

 *

Ext.QuickTips.init(); // to display button quicktips

var myStore = new Ext.data.Store({
    reader: new Ext.data.JsonReader({
        {@link Ext.data.JsonReader#totalProperty totalProperty}: 'results',
        ...
    }),
    ...
});

var myPageSize = 25;  // server script should only send back 25 items at a time

var grid = new Ext.grid.GridPanel({
    ...
    store: myStore,
    bbar: new Ext.PagingToolbar({
        {@link #store}: myStore,       // grid and PagingToolbar using same store
        {@link #displayInfo}: true,
        {@link #pageSize}: myPageSize,
        {@link #prependButtons}: true,
        items: [
            'text 1'
        ]
    })
});
 *

 *
 *
To use paging, pass the paging requirements to the server when the store is first loaded.

 *

store.load({
    params: {
        // specify params for the first page load if using paging
        start: 0,
        limit: myPageSize,
        // other params
        foo:   'bar'
    }
});
 *

 *
 *
If using {@link Ext.data.Store#autoLoad store's autoLoad} configuration:

 *

var myStore = new Ext.data.Store({
    {@link Ext.data.Store#autoLoad autoLoad}: {params:{start: 0, limit: 25}},
    ...
});
 *

 *
 *
The packet sent back from the server would have this form:

 *

{
    "success": true,
    "results": 2000,
    "rows": [ // *Note: this must be an Array
        { "id":  1, "name": "Bill", "occupation": "Gardener" },
        { "id":  2, "name":  "Ben", "occupation": "Horticulturalist" },
        ...
        { "id": 25, "name":  "Sue", "occupation": "Botanist" }
    ]
}
 *

 *
Paging with Local Data

 *
Paging can also be accomplished with local data using extensions:

 *

 *
Ext.ux.data.PagingStore

 *
Paging Memory Proxy (examples/ux/PagingMemoryProxy.js)

 *

 * @constructor Create a new PagingToolbar
 * @param {Object} config The config object
 * @xtype paging
 */
(function() {

var T = Ext.Toolbar;

Ext.PagingToolbar = Ext.extend(Ext.Toolbar, {
    /**
     * @cfg {Ext.data.Store} store
     * The {@link Ext.data.Store} the paging toolbar should use as its data source (required).
     */
    /**
     * @cfg {Boolean} displayInfo
     * <tt>true</tt> to display the displayMsg (defaults to <tt>false</tt>)
     */
    /**
     * @cfg {Number} pageSize
     * The number of records to display per page (defaults to <tt>20</tt>)
     */
    pageSize : 20,
    /**
     * @cfg {Boolean} prependButtons
     * <tt>true</tt> to insert any configured <tt>items</tt> before the paging buttons.
     * Defaults to <tt>false</tt>.
     */
    /**
     * @cfg {String} displayMsg
     * The paging status message to display (defaults to <tt>'Displaying {0} - {1} of {2}'</tt>).
     * Note that this string is formatted using the braced numbers <tt>{0}-{2}</tt> as tokens
     * that are replaced by the values for start, end and total respectively. These tokens should
     * be preserved when overriding this string if showing those values is desired.
     */
    displayMsg : 'Displaying {0} - {1} of {2}',
    /**
     * @cfg {String} emptyMsg
     * The message to display when no records are found (defaults to 'No data to display')
     */
    emptyMsg : 'No data to display',
    /**
     * @cfg {String} beforePageText
     * The text displayed before the input item (defaults to <tt>'Page'</tt>).
     */
    beforePageText : 'Page',
    /**
     * @cfg {String} afterPageText
     * Customizable piece of the default paging text (defaults to <tt>'of {0}'</tt>). Note that
     * this string is formatted using <tt>{0}</tt> as a token that is replaced by the number of
     * total pages. This token should be preserved when overriding this string if showing the
     * total page count is desired.
     */
    afterPageText : 'of {0}',
    /**
     * @cfg {String} firstText
     * The quicktip text displayed for the first page button (defaults to <tt>'First Page'</tt>).
     * Note: quick tips must be initialized for the quicktip to show.
     */
    firstText : 'First Page',
    /**
     * @cfg {String} prevText
     * The quicktip text displayed for the previous page button (defaults to <tt>'Previous Page'</tt>).
     * Note: quick tips must be initialized for the quicktip to show.
     */
    prevText : 'Previous Page',
    /**
     * @cfg {String} nextText
     * The quicktip text displayed for the next page button (defaults to <tt>'Next Page'</tt>).
     * Note: quick tips must be initialized for the quicktip to show.
     */
    nextText : 'Next Page',
    /**
     * @cfg {String} lastText
     * The quicktip text displayed for the last page button (defaults to <tt>'Last Page'</tt>).
     * Note: quick tips must be initialized for the quicktip to show.
     */
    lastText : 'Last Page',
    /**
     * @cfg {String} refreshText
     * The quicktip text displayed for the Refresh button (defaults to <tt>'Refresh'</tt>).
     * Note: quick tips must be initialized for the quicktip to show.
     */
    refreshText : 'Refresh',

    /**
     *
Deprecated. paramNames should be set in the data store
     * (see {@link Ext.data.Store#paramNames}).

     *

Object mapping of parameter names used for load calls, initially set to:

     *
{start: 'start', limit: 'limit'}

     * @type Object
     * @property paramNames
     * @deprecated
     */

    /**
     * The number of records to display per page.  See also <tt>{@link #cursor}</tt>.
     * @type Number
     * @property pageSize
     */

    /**
     * Indicator for the record position.  This property might be used to get the active page
     * number for example:

     * // t is reference to the paging toolbar instance
     * var activePage = Math.ceil((t.cursor + t.pageSize) / t.pageSize);
     *

     * @type Number
     * @property cursor
     */

    initComponent : function(){
        var pagingItems = [this.first = new T.Button({
            tooltip: this.firstText,
            overflowText: this.firstText,
            iconCls: 'x-tbar-page-first',
            disabled: true,
            handler: this.moveFirst,
            scope: this
        }), this.prev = new T.Button({
            tooltip: this.prevText,
            overflowText: this.prevText,
            iconCls: 'x-tbar-page-prev',
            disabled: true,
            handler: this.movePrevious,
            scope: this
        }), '-', this.beforePageText,
        this.inputItem = new Ext.form.NumberField({
            cls: 'x-tbar-page-number',
            allowDecimals: false,
            allowNegative: false,
            enableKeyEvents: true,
            selectOnFocus: true,
            submitValue: false,
            listeners: {
                scope: this,
                keydown: this.onPagingKeyDown,
                blur: this.onPagingBlur
            }
        }), this.afterTextItem = new T.TextItem({
            text: String.format(this.afterPageText, 1)
        }), '-', this.next = new T.Button({
            tooltip: this.nextText,
            overflowText: this.nextText,
            iconCls: 'x-tbar-page-next',
            disabled: true,
            handler: this.moveNext,
            scope: this
        }), this.last = new T.Button({
            tooltip: this.lastText,
            overflowText: this.lastText,
            iconCls: 'x-tbar-page-last',
            disabled: true,
            handler: this.moveLast,
            scope: this
        }), '-', this.refresh = new T.Button({
            tooltip: this.refreshText,
            overflowText: this.refreshText,
            iconCls: 'x-tbar-loading',
            handler: this.doRefresh,
            scope: this
        })];

        var userItems = this.items || this.buttons || [];
        if (this.prependButtons) {
            this.items = userItems.concat(pagingItems);
        }else{
            this.items = pagingItems.concat(userItems);
        }
        delete this.buttons;
        if(this.displayInfo){
            this.items.push('->');
            this.items.push(this.displayItem = new T.TextItem({}));
        }
        Ext.PagingToolbar.superclass.initComponent.call(this);
        this.addEvents(
            /**
             * @event change
             * Fires after the active page has been changed.
             * @param {Ext.PagingToolbar} this
             * @param {Object} pageData An object that has these properties:

             *
total : Number
The total number of records in the dataset as
             * returned by the server

             *
activePage : Number
The current page number

             *
pages : Number
The total number of pages (calculated from
             * the total number of records in the dataset as returned by the server and the current {@link #pageSize})

             *

             */
            'change',
            /**
             * @event beforechange
             * Fires just before the active page is changed.
             * Return false to prevent the active page from being changed.
             * @param {Ext.PagingToolbar} this
             * @param {Object} params An object hash of the parameters which the PagingToolbar will send when
             * loading the required page. This will contain:

             *
start : Number
The starting row number for the next page of records to
             * be retrieved from the server

             *
limit : Number
The number of records to be retrieved from the server

             *

             *
(note: the names of the start and limit properties are determined
             * by the store's {@link Ext.data.Store#paramNames paramNames} property.)

             *
Parameters may be added as required in the event handler.

             */
            'beforechange'
        );
        this.on('afterlayout', this.onFirstLayout, this, {single: true});
        this.cursor = 0;
        this.bindStore(this.store, true);
    },

    // private
    onFirstLayout : function(){
        if(this.dsLoaded){
            this.onLoad.apply(this, this.dsLoaded);
        }
    },

    // private
    updateInfo : function(){
        if(this.displayItem){
            var count = this.store.getCount();
            var msg = count == 0 ?
                this.emptyMsg :
                String.format(
                    this.displayMsg,
                    this.cursor+1, this.cursor+count, this.store.getTotalCount()
                );
            this.displayItem.setText(msg);
        }
    },

    // private
    onLoad : function(store, r, o){
        if(!this.rendered){
            this.dsLoaded = [store, r, o];
            return;
        }
        var p = this.getParams();
        this.cursor = (o.params && o.params[p.start]) ? o.params[p.start] : 0;
        var d = this.getPageData(), ap = d.activePage, ps = d.pages;

        this.afterTextItem.setText(String.format(this.afterPageText, d.pages));
        this.inputItem.setValue(ap);
        this.first.setDisabled(ap == 1);
        this.prev.setDisabled(ap == 1);
        this.next.setDisabled(ap == ps);
        this.last.setDisabled(ap == ps);
        this.refresh.enable();
        this.updateInfo();
        this.fireEvent('change', this, d);
    },

    // private
    getPageData : function(){
        var total = this.store.getTotalCount();
        return {
            total : total,
            activePage : Math.ceil((this.cursor+this.pageSize)/this.pageSize),
            pages :  total < this.pageSize ? 1 : Math.ceil(total/this.pageSize)
        };
    },

    /**
     * Change the active page
     * @param {Integer} page The page to display
     */
    changePage : function(page){
        this.doLoad(((page-1) * this.pageSize).constrain(0, this.store.getTotalCount()));
    },

    // private
    onLoadError : function(){
        if(!this.rendered){
            return;
        }
        this.refresh.enable();
    },

    // private
    readPage : function(d){
        var v = this.inputItem.getValue(), pageNum;
        if (!v || isNaN(pageNum = parseInt(v, 10))) {
            this.inputItem.setValue(d.activePage);
            return false;
        }
        return pageNum;
    },

    onPagingFocus : function(){
        this.inputItem.select();
    },

    //private
    onPagingBlur : function(e){
        this.inputItem.setValue(this.getPageData().activePage);
    },

    // private
    onPagingKeyDown : function(field, e){
        var k = e.getKey(), d = this.getPageData(), pageNum;
        if (k == e.RETURN) {
            e.stopEvent();
            pageNum = this.readPage(d);
            if(pageNum !== false){
                pageNum = Math.min(Math.max(1, pageNum), d.pages) - 1;
                this.doLoad(pageNum * this.pageSize);
            }
        }else if (k == e.HOME || k == e.END){
            e.stopEvent();
            pageNum = k == e.HOME ? 1 : d.pages;
            field.setValue(pageNum);
        }else if (k == e.UP || k == e.PAGEUP || k == e.DOWN || k == e.PAGEDOWN){
            e.stopEvent();
            if((pageNum = this.readPage(d))){
                var increment = e.shiftKey ? 10 : 1;
                if(k == e.DOWN || k == e.PAGEDOWN){
                    increment *= -1;
                }
                pageNum += increment;
                if(pageNum >= 1 & pageNum <= d.pages){
                    field.setValue(pageNum);
                }
            }
        }
    },

    // private
    getParams : function(){
        //retain backwards compat, allow params on the toolbar itself, if they exist.
        return this.paramNames || this.store.paramNames;
    },

    // private
    beforeLoad : function(){
        if(this.rendered && this.refresh){
            this.refresh.disable();
        }
    },

    // private
    doLoad : function(start){
        var o = {}, pn = this.getParams();
        o[pn.start] = start;
        o[pn.limit] = this.pageSize;
        if(this.fireEvent('beforechange', this, o) !== false){
            this.store.load({params:o});
        }
    },

    /**
     * Move to the first page, has the same effect as clicking the 'first' button.
     */
    moveFirst : function(){
        this.doLoad(0);
    },

    /**
     * Move to the previous page, has the same effect as clicking the 'previous' button.
     */
    movePrevious : function(){
        this.doLoad(Math.max(0, this.cursor-this.pageSize));
    },

    /**
     * Move to the next page, has the same effect as clicking the 'next' button.
     */
    moveNext : function(){
        this.doLoad(this.cursor+this.pageSize);
    },

    /**
     * Move to the last page, has the same effect as clicking the 'last' button.
     */
    moveLast : function(){
        var total = this.store.getTotalCount(),
            extra = total % this.pageSize;

        this.doLoad(extra ? (total - extra) : total - this.pageSize);
    },

    /**
     * Refresh the current page, has the same effect as clicking the 'refresh' button.
     */
    doRefresh : function(){
        this.doLoad(this.cursor);
    },

    /**
     * Binds the paging toolbar to the specified {@link Ext.data.Store}
     * @param {Store} store The store to bind to this toolbar
     * @param {Boolean} initial (Optional) true to not remove listeners
     */
    bindStore : function(store, initial){
        var doLoad;
        if(!initial && this.store){
            if(store !== this.store && this.store.autoDestroy){
                this.store.destroy();
            }else{
                this.store.un('beforeload', this.beforeLoad, this);
                this.store.un('load', this.onLoad, this);
                this.store.un('exception', this.onLoadError, this);
            }
            if(!store){
                this.store = null;
            }
        }
        if(store){
            store = Ext.StoreMgr.lookup(store);
            store.on({
                scope: this,
                beforeload: this.beforeLoad,
                load: this.onLoad,
                exception: this.onLoadError
            });
            doLoad = true;
        }
        this.store = store;
        if(doLoad){
            this.onLoad(store, null, {});
        }
    },

    /**
     * Unbinds the paging toolbar from the specified {@link Ext.data.Store} (deprecated)
     * @param {Ext.data.Store} store The data store to unbind
     */
    unbind : function(store){
        this.bindStore(null);
    },

    /**
     * Binds the paging toolbar to the specified {@link Ext.data.Store} (deprecated)
     * @param {Ext.data.Store} store The data store to bind
     */
    bind : function(store){
        this.bindStore(store);
    },

    // private
    onDestroy : function(){
        this.bindStore(null);
        Ext.PagingToolbar.superclass.onDestroy.call(this);
    }
});

})();
Ext.reg('paging', Ext.PagingToolbar);


text:
package org.smslib.examples;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.smslib.callback.IMessageSentCallback;
import org.smslib.callback.events.MessageSentCallbackEvent;

public class MessageSentCallback implements IMessageSentCallback
{
	final Logger logger = LoggerFactory.getLogger(MessageSentCallback.class);

	@Override
	public boolean process(MessageSentCallbackEvent event)
	{
		logger.info("[MessageSentCallback] " + event.getMessage().toShortString());
		return true;
	}
}

redpajama_set_name: RedPajamaGithub


text:
/**
 * clock/scheduledJobs/sampleTimeout.js
 *
 * Executes the sample timeout process. If worker process is enabled, enqueues
 * a job, otherwise just executes work directly in this process.
 */
const dbSubject = require('../../db/index').Subject;
const publisher = require('../../realtime/redisPublisher');
const sampleEvent = require('../../realtime/constants').events.sample;
const sampleStoreTimeout = require('../../cache/sampleStoreTimeout');
/**
 * Execute the call to check for sample timeouts.
 *
 * @returns {Promise}
 */
function execute() {
  return sampleStoreTimeout.doTimeout()
  .then((dbRes) => ({
    recordCount: dbRes.numberTimedOut,
    errorCount: dbRes.numberEvaluated - dbRes.numberTimedOut,
  }));
} // execute

module.exports = {
  execute,
};


text:
package org.apache.druid.segment.vector;

public abstract class BaseDoubleVectorValueSelector implements VectorValueSelector
{
  protected final ReadableVectorOffset offset;

  private int longId = ReadableVectorOffset.NULL_ID;
  private int floatId = ReadableVectorOffset.NULL_ID;

  private long[] longVector;
  private float[] floatVector;

  public BaseDoubleVectorValueSelector(final ReadableVectorOffset offset)
  {
    this.offset = offset;
  }

  @Override
  public int getCurrentVectorSize()
  {
    return offset.getCurrentVectorSize();
  }

  @Override
  public int getMaxVectorSize()
  {
    return offset.getMaxVectorSize();
  }

  @Override
  public long[] getLongVector()
  {
    if (longId == offset.getId()) {
      return longVector;
    }

    if (longVector == null) {
      longVector = new long[offset.getMaxVectorSize()];
    }

    final double[] doubleVector = getDoubleVector();
    for (int i = 0; i < getCurrentVectorSize(); i++) {
      longVector[i] = (long) doubleVector[i];
    }

    longId = offset.getId();
    return longVector;
  }

  @Override
  public float[] getFloatVector()
  {
    if (floatId == offset.getId()) {
      return floatVector;
    }

    if (floatVector == null) {
      floatVector = new float[offset.getMaxVectorSize()];
    }

    final double[] doubleVector = getDoubleVector();
    for (int i = 0; i < getCurrentVectorSize(); i++) {
      floatVector[i] = (float) doubleVector[i];
    }

    floatId = offset.getId();
    return floatVector;
  }
}


text:
package nl.uu.trafficmas.norm;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import nl.uu.trafficmas.roadnetwork.Sensor;
import nl.uu.trafficmas.simulationmodel.AgentData;

public class SimpleMergeNormInstantiation extends NormInstantiation {

	private int laneIndex;
	private double speed;
	List<AgentData> goals;

	public SimpleMergeNormInstantiation(NormScheme ns, String agentID) {
		super(ns, agentID);
		this.speed = 0;
		goals = new ArrayList<AgentData>();
	}

	@Override
	public boolean violated(AgentData ad) {
		//TODO: some leeway, i.e. 3% deviation from the target speed?
		// Agent can only receive a violation while on sensor 3.
		Sensor mergeSensor = ((SimpleMergeNormScheme)this.ns).mergeSensor;
		if(!mergeSensor.readSensor().contains(ad) || ad.roadID.equals(mergeSensor.lane.getRoadID()))
			return false;

		return (Math.abs(ad.velocity - speed) > 0.009 || (ad.laneIndex != laneIndex)) ;
	}

	@Override
	public boolean deadline(Map<String, AgentData> currentOrgKnowledge,
			int currentTime) {

		AgentData agentData = currentOrgKnowledge.get(agentID);
		if(agentData == null)
			return false;
		SimpleMergeNormScheme simpleMergeNormScheme = (SimpleMergeNormScheme)ns;
		Sensor mergeSensor = simpleMergeNormScheme.mergeSensor;
		boolean onMergeSensor = mergeSensor.readSensor().contains(agentData);
		boolean onMergeSensorRoad = agentData.roadID.equals(mergeSensor.lane.getRoadID());
		return onMergeSensor || onMergeSensorRoad;
	}

	public void setLaneIndex(int laneIndex){
		this.laneIndex = laneIndex;
		goals.add(new AgentData(null, null, -1, -1, null, laneIndex, -1, -1));
	}

	public int getLaneIndex(){
		return laneIndex;
	}

	public void setSpeed(double speed) {
		this.speed = speed;
		goals.add(new AgentData(null, null, -1, speed, null, -1, -1, -1));
	}

	public double getSpeed() {
		return speed;
	}

	public List<AgentData> getGoals() {
		return goals;
	}

	public void setSpeedAndLane(double correctedLastSpeed, int laneIndex) {
		this.speed = correctedLastSpeed;
		this.laneIndex = laneIndex;
		goals.add(new AgentData(null, null, -1, correctedLastSpeed, null, laneIndex, -1, -1));
	}
}


text:
import { isBuffer } from "lodash";
export = isBuffer;


text:
#include "Edb.h"

extern EDB_DISASM_INSTRUCTION mEdbDisasmInstructionTable[];

typedef struct {
  CHAR16    Name[EDB_INSTRUCTION_NAME_MAX_LENGTH];
  CHAR16    Content[EDB_INSTRUCTION_CONTENT_MAX_LENGTH];
  CHAR16    Tail;
} EDB_INSTRUCTION_STRING;

EDB_INSTRUCTION_STRING mInstructionString;
UINTN                  mInstructionNameOffset;
UINTN                  mInstructionContentOffset;

/**

  Set offset for Instruction name and content.

  @param  InstructionNameOffset     - Instruction name offset
  @param  InstructionContentOffset  - Instruction content offset

**/
VOID
EdbSetOffset (
  IN UINTN InstructionNameOffset,
  IN UINTN InstructionContentOffset
  )
{
  mInstructionNameOffset = InstructionNameOffset;
  mInstructionContentOffset = InstructionContentOffset;

  return ;
}

/**

  Pre instruction string construction.

  @return Instruction string

**/
CHAR16 *
EdbPreInstructionString (
  VOID
  )
{
  ZeroMem (&mInstructionString, sizeof(mInstructionString));
  mInstructionNameOffset    = 0;
  mInstructionContentOffset = 0;

  return (CHAR16 *)&mInstructionString;
}

/**

  Post instruction string construction.

  @return Instruction string

**/
CHAR16 *
EdbPostInstructionString (
  VOID
  )
{
  CHAR16 *Char;

  for (Char = (CHAR16 *)&mInstructionString; Char < &mInstructionString.Tail; Char++) {
    if (*Char == 0) {
      *Char = L' ';
    }
  }
  mInstructionString.Tail = 0;

  mInstructionNameOffset    = 0;
  mInstructionContentOffset = 0;

  return (CHAR16 *)&mInstructionString;
}

/**

  Get Sign, NaturalUnits, and ConstantUnits of the WORD data.

  @param  Data16        - WORD data
  @param  NaturalUnits  - Natural Units of the WORD
  @param  ConstantUnits - Constant Units of the WORD

  @return Sign value of WORD

**/
BOOLEAN
EdbGetNaturalIndex16 (
  IN  UINT16  Data16,
  OUT UINTN   *NaturalUnits,
  OUT UINTN   *ConstantUnits
  )
{
  BOOLEAN Sign;
  UINTN   NaturalUnitBit;

  Sign = (BOOLEAN)(Data16 >> 15);
  NaturalUnitBit = (UINTN)((Data16 >> 12) & 0x7);
  NaturalUnitBit *= 2;
  Data16 = Data16 & 0xFFF;
  *NaturalUnits = (UINTN)(Data16 & ((1 << NaturalUnitBit) - 1));
  *ConstantUnits = (UINTN)((Data16 >> NaturalUnitBit) & ((1 << (12 - NaturalUnitBit)) - 1));

  return Sign;
}

/**

  Get Sign, NaturalUnits, and ConstantUnits of the DWORD data.

  @param  Data32        - DWORD data
  @param  NaturalUnits  - Natural Units of the DWORD
  @param  ConstantUnits - Constant Units of the DWORD

  @return Sign value of DWORD

**/
BOOLEAN
EdbGetNaturalIndex32 (
  IN  UINT32  Data32,
  OUT UINTN   *NaturalUnits,
  OUT UINTN   *ConstantUnits
  )
{
  BOOLEAN Sign;
  UINTN   NaturalUnitBit;

  Sign = (BOOLEAN)(Data32 >> 31);
  NaturalUnitBit = (UINTN)((Data32 >> 28) & 0x7);
  NaturalUnitBit *= 4;
  Data32 = Data32 & 0xFFFFFFF;
  *NaturalUnits = (UINTN)(Data32 & ((1 << NaturalUnitBit) - 1));
  *ConstantUnits = (UINTN)((Data32 >> NaturalUnitBit) & ((1 << (28 - NaturalUnitBit)) - 1));

  return Sign;
}

/**

  Get Sign, NaturalUnits, and ConstantUnits of the QWORD data.

  @param  Data64        - QWORD data
  @param  NaturalUnits  - Natural Units of the QWORD
  @param  ConstantUnits - Constant Units of the QWORD

  @return Sign value of QWORD

**/
BOOLEAN
EdbGetNaturalIndex64 (
  IN  UINT64  Data64,
  OUT UINT64  *NaturalUnits,
  OUT UINT64  *ConstantUnits
  )
{
  BOOLEAN Sign;
  UINTN   NaturalUnitBit;

  Sign = (BOOLEAN)RShiftU64 (Data64, 63);
  NaturalUnitBit = (UINTN)(RShiftU64 (Data64, 60) & 0x7);
  NaturalUnitBit *= 8;
  Data64 = RShiftU64 (LShiftU64 (Data64, 4), 4);
  *NaturalUnits = (UINT64)(Data64 & (LShiftU64 (1, NaturalUnitBit) - 1));
  *ConstantUnits = (UINT64)(RShiftU64 (Data64, NaturalUnitBit) & (LShiftU64 (1, (60 - NaturalUnitBit)) - 1));

  return Sign;
}

/**

  Get Bit Width of the value.

  @param  Value - data

  @return Bit width

**/
UINT8
EdbGetBitWidth (
  IN UINT64  Value
  )
{
  if (Value >= 10000000000000) {
    return 14;
  } else if (Value >= 1000000000000) {
    return 13;
  } else if (Value >= 100000000000) {
    return 12;
  } else if (Value >= 10000000000) {
    return 11;
  } else if (Value >= 1000000000) {
    return 10;
  } else if (Value >= 100000000) {
    return 9;
  } else if (Value >= 10000000) {
    return 8;
  } else if (Value >= 1000000) {
    return 7;
  } else if (Value >= 100000) {
    return 6;
  } else if (Value >= 10000) {
    return 5;
  } else if (Value >= 1000) {
    return 4;
  } else if (Value >= 100) {
    return 3;
  } else if (Value >= 10) {
    return 2;
  } else {
    return 1;
  }
}

/**

  Print the instruction name.

  @param  Name - instruction name

  @return Instruction name offset

**/
UINTN
EdbPrintInstructionName (
  IN CHAR16                 *Name
  )
{
  EDBSPrintWithOffset (
    mInstructionString.Name,
    EDB_INSTRUCTION_NAME_MAX_SIZE,
    mInstructionNameOffset,
    L"%s",
    Name
    );
  mInstructionNameOffset += StrLen (Name);

  return mInstructionNameOffset;
}

/**

  Print register 1 in operands.

  @param  Operands - instruction operands

  @return Instruction content offset

**/
UINTN
EdbPrintRegister1 (
  IN UINT8                  Operands
  )
{
  if ((Operands & OPERAND_M_INDIRECT1) != 0) {
    EDBSPrintWithOffset (
      mInstructionString.Content,
      EDB_INSTRUCTION_CONTENT_MAX_SIZE,
      mInstructionContentOffset,
      L"@"
      );
    mInstructionContentOffset += 1;
  }
  EDBSPrintWithOffset (
    mInstructionString.Content,
    EDB_INSTRUCTION_CONTENT_MAX_SIZE,
    mInstructionContentOffset,
    L"R%d",
    (UINTN)(Operands & OPERAND_M_OP1)
    );
  mInstructionContentOffset += 2;

  return mInstructionContentOffset;
}

/**

  Print register 2 in operands.

  @param  Operands - instruction operands

  @return Instruction content offset

**/
UINTN
EdbPrintRegister2 (
  IN UINT8                  Operands
  )
{
  if ((Operands & OPERAND_M_INDIRECT2) != 0) {
    EDBSPrintWithOffset (
      mInstructionString.Content,
      EDB_INSTRUCTION_CONTENT_MAX_SIZE,
      mInstructionContentOffset,
      L"@"
      );
    mInstructionContentOffset += 1;
  }
  EDBSPrintWithOffset (
    mInstructionString.Content,
    EDB_INSTRUCTION_CONTENT_MAX_SIZE,
    mInstructionContentOffset,
    L"R%d",
    (UINTN)((Operands & OPERAND_M_OP2) >> 4)
    );
  mInstructionContentOffset += 2;

  return mInstructionContentOffset;
}

/**

  Print dedicated register 1 in operands.

  @param Operands - instruction operands

  @return Instruction content offset

**/
UINTN
EdbPrintDedicatedRegister1 (
  IN UINT8                  Operands
  )
{
  switch (Operands & OPERAND_M_OP1) {
  case 0:
    EDBSPrintWithOffset (
      mInstructionString.Content,
      EDB_INSTRUCTION_CONTENT_MAX_SIZE,
      mInstructionContentOffset,
      L"[FLAGS]"
      );
    mInstructionContentOffset += 7;
    break;
  case 1:
    EDBSPrintWithOffset (
      mInstructionString.Content,
      EDB_INSTRUCTION_CONTENT_MAX_SIZE,
      mInstructionContentOffset,
      L"[IP]"
      );
    mInstructionContentOffset += 4;
    break;
  }

  return mInstructionContentOffset;
}

/**

  Print dedicated register 2 in operands.

  @param  Operands - instruction operands

  @return Instruction content offset

**/
UINTN
EdbPrintDedicatedRegister2 (
  IN UINT8                  Operands
  )
{
  switch ((Operands & OPERAND_M_OP2) >> 4) {
  case 0:
    EDBSPrintWithOffset (
      mInstructionString.Content,
      EDB_INSTRUCTION_CONTENT_MAX_SIZE,
      mInstructionContentOffset,
      L"[FLAGS]"
      );
    mInstructionContentOffset += 7;
    break;
  case 1:
    EDBSPrintWithOffset (
      mInstructionString.Content,
      EDB_INSTRUCTION_CONTENT_MAX_SIZE,
      mInstructionContentOffset,
      L"[IP]"
      );
    mInstructionContentOffset += 4;
    break;
  }

  return mInstructionContentOffset;
}

/**

  Print the hexical UINTN index data to instruction content.

  @param  Sign          - Signed bit of UINTN data
  @param  NaturalUnits  - natural units of UINTN data
  @param  ConstantUnits - natural units of UINTN data

  @return Instruction content offset

**/
UINTN
EdbPrintIndexData (
  IN BOOLEAN                Sign,
  IN UINTN                  NaturalUnits,
  IN UINTN                  ConstantUnits
  )
{
  EDBSPrintWithOffset (
    mInstructionString.Content,
    EDB_INSTRUCTION_CONTENT_MAX_SIZE,
    mInstructionContentOffset,
    L"(%s%d,%s%d)",
    Sign ? L"-" : L"+",
    NaturalUnits,
    Sign ? L"-" : L"+",
    ConstantUnits
    );
  mInstructionContentOffset  = mInstructionContentOffset + 5 + EdbGetBitWidth (NaturalUnits) + EdbGetBitWidth (ConstantUnits);

  return mInstructionContentOffset;
}

/**

  Print the hexical QWORD index data to instruction content.

  @param  Sign          - Signed bit of QWORD data
  @param  NaturalUnits  - natural units of QWORD data
  @param  ConstantUnits - natural units of QWORD data

  @return Instruction content offset

**/
UINTN
EdbPrintIndexData64 (
  IN BOOLEAN                Sign,
  IN UINT64                 NaturalUnits,
  IN UINT64                 ConstantUnits
  )
{
  EDBSPrintWithOffset (
    mInstructionString.Content,
    EDB_INSTRUCTION_CONTENT_MAX_SIZE,
    mInstructionContentOffset,
    L"(%s%ld,%s%ld)",
    Sign ? L"-" : L"+",
    NaturalUnits,
    Sign ? L"-" : L"+",
    ConstantUnits
    );
  mInstructionContentOffset  = mInstructionContentOffset + 5 + EdbGetBitWidth (NaturalUnits) + EdbGetBitWidth (ConstantUnits);

  return mInstructionContentOffset;
}

/**

  Print the hexical WORD raw index data to instruction content.

  @param  Data16 - WORD data

  @return Instruction content offset

**/
UINTN
EdbPrintRawIndexData16 (
  IN UINT16                 Data16
  )
{
  BOOLEAN Sign;
  UINTN   NaturalUnits;
  UINTN   ConstantUnits;
  UINTN   Offset;

  Sign = EdbGetNaturalIndex16 (Data16, &NaturalUnits, &ConstantUnits);
  Offset = EdbPrintIndexData (Sign, NaturalUnits, ConstantUnits);

  return Offset;
}

/**

  Print the hexical DWORD raw index data to instruction content.

  @param  Data32 - DWORD data

  @return Instruction content offset

**/
UINTN
EdbPrintRawIndexData32 (
  IN UINT32                 Data32
  )
{
  BOOLEAN Sign;
  UINTN   NaturalUnits;
  UINTN   ConstantUnits;
  UINTN   Offset;

  Sign = EdbGetNaturalIndex32 (Data32, &NaturalUnits, &ConstantUnits);
  Offset = EdbPrintIndexData (Sign, NaturalUnits, ConstantUnits);

  return Offset;
}

/**

  Print the hexical QWORD raw index data to instruction content.

  @param  Data64 - QWORD data

  @return Instruction content offset

**/
UINTN
EdbPrintRawIndexData64 (
  IN UINT64                 Data64
  )
{
  BOOLEAN Sign;
  UINT64  NaturalUnits;
  UINT64  ConstantUnits;
  UINTN   Offset;

  Sign = EdbGetNaturalIndex64 (Data64, &NaturalUnits, &ConstantUnits);
  Offset = EdbPrintIndexData64 (Sign, NaturalUnits, ConstantUnits);

  return Offset;
}

/**

  Print the hexical BYTE immediate data to instruction content.

  @param  Data - BYTE data

  @return Instruction content offset

**/
UINTN
EdbPrintImmData8 (
  IN UINT8                  Data
  )
{
  EDBSPrintWithOffset (
    mInstructionString.Content,
    EDB_INSTRUCTION_CONTENT_MAX_SIZE,
    mInstructionContentOffset,
    L"(0x%02x)",
    (UINTN)Data
    );
  mInstructionContentOffset  += 6;

  return mInstructionContentOffset;
}

/**

  Print the hexical WORD immediate data to instruction content.

  @param  Data - WORD data

  @return Instruction content offset

**/
UINTN
EdbPrintImmData16 (
  IN UINT16                 Data
  )
{
  EDBSPrintWithOffset (
    mInstructionString.Content,
    EDB_INSTRUCTION_CONTENT_MAX_SIZE,
    mInstructionContentOffset,
    L"(0x%04x)",
    (UINTN)Data
    );
  mInstructionContentOffset  += 8;

  return mInstructionContentOffset;
}

/**

  Print the hexical DWORD immediate data to instruction content.

  @param  Data - DWORD data

  @return Instruction content offset

**/
UINTN
EdbPrintImmData32 (
  IN UINT32                 Data
  )
{
  EDBSPrintWithOffset (
    mInstructionString.Content,
    EDB_INSTRUCTION_CONTENT_MAX_SIZE,
    mInstructionContentOffset,
    L"(0x%08x)",
    (UINTN)Data
    );
  mInstructionContentOffset  += 12;

  return mInstructionContentOffset;
}

/**

  Print the hexical QWORD immediate data to instruction content.

  @param  Data - QWORD data

  @return Instruction content offset

**/
UINTN
EdbPrintImmData64 (
  IN UINT64                 Data
  )
{
  EDBSPrintWithOffset (
    mInstructionString.Content,
    EDB_INSTRUCTION_CONTENT_MAX_SIZE,
    mInstructionContentOffset,
    L"(0x%016lx)",
    Data
    );
  mInstructionContentOffset  += 20;

  return mInstructionContentOffset;
}

/**

  Print the decimal UINTN immediate data to instruction content.

  @param  Data - UINTN data

  @return Instruction content offset

**/
UINTN
EdbPrintImmDatan (
  IN UINTN                  Data
  )
{
  EDBSPrintWithOffset (
    mInstructionString.Content,
    EDB_INSTRUCTION_CONTENT_MAX_SIZE,
    mInstructionContentOffset,
    L"(%d)",
    (UINTN)Data
    );
  mInstructionContentOffset  = mInstructionContentOffset + 2 + EdbGetBitWidth (Data);

  return mInstructionContentOffset;
}

/**

  Print the decimal QWORD immediate data to instruction content.

  @param  Data64 - QWORD data

  @return Instruction content offset

**/
UINTN
EdbPrintImmData64n (
  IN UINT64                 Data64
  )
{
  EDBSPrintWithOffset (
    mInstructionString.Content,
    EDB_INSTRUCTION_CONTENT_MAX_SIZE,
    mInstructionContentOffset,
    L"(%ld)",
    Data64
    );
  mInstructionContentOffset  = mInstructionContentOffset + 2 + EdbGetBitWidth (Data64);

  return mInstructionContentOffset;
}

/**

  Print the hexical BYTE to instruction content.

  @param  Data8 - BYTE data

  @return Instruction content offset

**/
UINTN
EdbPrintData8 (
  IN UINT8                  Data8
  )
{
  EDBSPrintWithOffset (
    mInstructionString.Content,
    EDB_INSTRUCTION_CONTENT_MAX_SIZE,
    mInstructionContentOffset,
    L"0x%02x",
    (UINTN)Data8
    );
  mInstructionContentOffset += 4;

  return mInstructionContentOffset;
}

/**

  Print the hexical WORD to instruction content.

  @param  Data16 - WORD data

  @return Instruction content offset

**/
UINTN
EdbPrintData16 (
  IN UINT16                 Data16
  )
{
  EDBSPrintWithOffset (
    mInstructionString.Content,
    EDB_INSTRUCTION_CONTENT_MAX_SIZE,
    mInstructionContentOffset,
    L"0x%04x",
    (UINTN)Data16
    );
  mInstructionContentOffset += 6;

  return mInstructionContentOffset;
}

/**

  Print the hexical DWORD to instruction content.

  @param  Data32 - DWORD data

  @return Instruction content offset

**/
UINTN
EdbPrintData32 (
  IN UINT32                 Data32
  )
{
  EDBSPrintWithOffset (
    mInstructionString.Content,
    EDB_INSTRUCTION_CONTENT_MAX_SIZE,
    mInstructionContentOffset,
    L"0x%08x",
    (UINTN)Data32
    );
  mInstructionContentOffset += 10;

  return mInstructionContentOffset;
}

/**

  Print the hexical QWORD to instruction content.

  @param  Data64 - QWORD data

  @return Instruction content offset

**/
UINTN
EdbPrintData64 (
  IN UINT64                 Data64
  )
{
  EDBSPrintWithOffset (
    mInstructionString.Content,
    EDB_INSTRUCTION_CONTENT_MAX_SIZE,
    mInstructionContentOffset,
    L"0x%016lx",
    (UINT64)Data64
    );
  mInstructionContentOffset += 18;

  return mInstructionContentOffset;
}

/**

  Print the decimal unsigned UINTN to instruction content.

  @param  Data - unsigned UINTN data

  @return Instruction content offset

**/
UINTN
EdbPrintDatan (
  IN UINTN                  Data
  )
{
  EDBSPrintWithOffset (
    mInstructionString.Content,
    EDB_INSTRUCTION_CONTENT_MAX_SIZE,
    mInstructionContentOffset,
    L"%d",
    (UINTN)Data
    );
  mInstructionContentOffset = mInstructionContentOffset + EdbGetBitWidth (Data);

  return mInstructionContentOffset;
}

/**

  Print the decimal unsigned QWORD to instruction content.

  @param  Data64 - unsigned QWORD data

  @return Instruction content offset

**/
UINTN
EdbPrintData64n (
  IN UINT64                 Data64
  )
{
  EDBSPrintWithOffset (
    mInstructionString.Content,
    EDB_INSTRUCTION_CONTENT_MAX_SIZE,
    mInstructionContentOffset,
    L"%ld",
    Data64
    );
  mInstructionContentOffset = mInstructionContentOffset + EdbGetBitWidth (Data64);

  return mInstructionContentOffset;
}

/**

  Print the decimal signed BYTE to instruction content.

  @param  Data8 - signed BYTE data

  @return Instruction content offset

**/
UINTN
EdbPrintData8s (
  IN UINT8                  Data8
  )
{
  BOOLEAN Sign;

  Sign = (BOOLEAN)(Data8 >> 7);

  EDBSPrintWithOffset (
    mInstructionString.Content,
    EDB_INSTRUCTION_CONTENT_MAX_SIZE,
    mInstructionContentOffset,
    L"%s%d",
    Sign ? L"-" : L"+",
    (UINTN)(Data8 & 0x7F)
    );
  mInstructionContentOffset = mInstructionContentOffset + 1 + EdbGetBitWidth (Data8 & 0x7F);

  return mInstructionContentOffset;
}

/**

  Print the decimal signed WORD to instruction content.

  @param  Data16 - signed WORD data

  @return Instruction content offset

**/
UINTN
EdbPrintData16s (
  IN UINT16                 Data16
  )
{
  BOOLEAN Sign;

  Sign = (BOOLEAN)(Data16 >> 15);

  EDBSPrintWithOffset (
    mInstructionString.Content,
    EDB_INSTRUCTION_CONTENT_MAX_SIZE,
    mInstructionContentOffset,
    L"%s%d",
    Sign ? L"-" : L"+",
    (UINTN)(Data16 & 0x7FFF)
    );
  mInstructionContentOffset = mInstructionContentOffset + 1 + EdbGetBitWidth (Data16 & 0x7FFF);

  return mInstructionContentOffset;
}

/**

  Print the decimal signed DWORD to instruction content.

  @param  Data32 - signed DWORD data

  @return Instruction content offset

**/
UINTN
EdbPrintData32s (
  IN UINT32                 Data32
  )
{
  BOOLEAN Sign;

  Sign = (BOOLEAN)(Data32 >> 31);

  EDBSPrintWithOffset (
    mInstructionString.Content,
    EDB_INSTRUCTION_CONTENT_MAX_SIZE,
    mInstructionContentOffset,
    L"%s%d",
    Sign ? L"-" : L"+",
    (UINTN)(Data32 & 0x7FFFFFFF)
    );
  mInstructionContentOffset = mInstructionContentOffset + 1 + EdbGetBitWidth (Data32 & 0x7FFFFFFF);

  return mInstructionContentOffset;
}

/**

  Print the decimal signed QWORD to instruction content.

  @param  Data64 - signed QWORD data

  @return Instruction content offset

**/
UINTN
EdbPrintData64s (
  IN UINT64                 Data64
  )
{
  BOOLEAN Sign;
  INT64   Data64s;

  Sign = (BOOLEAN)RShiftU64 (Data64, 63);
  Data64s = (INT64)RShiftU64 (LShiftU64 (Data64, 1), 1);

  EDBSPrintWithOffset (
    mInstructionString.Content,
    EDB_INSTRUCTION_CONTENT_MAX_SIZE,
    mInstructionContentOffset,
    L"%s%ld",
    Sign ? L"-" : L"+",
    (UINT64)Data64s
    );
  mInstructionContentOffset = mInstructionContentOffset + 1 + EdbGetBitWidth (Data64s);

  return mInstructionContentOffset;
}

/**

  Print the comma to instruction content.

  @return Instruction content offset

**/
UINTN
EdbPrintComma (
  VOID
  )
{
  EDBSPrintWithOffset (
    mInstructionString.Content,
    EDB_INSTRUCTION_CONTENT_MAX_SIZE,
    mInstructionContentOffset,
    L", "
    );
  mInstructionContentOffset += 2;

  return mInstructionContentOffset;
}

/**

  Find the symbol string according to address, then print it.

  @param  Address - instruction address

  @retval 1 - symbol string is found and printed
  @retval 0 - symbol string not found

**/
UINTN
EdbFindAndPrintSymbol (
  IN UINTN                  Address
  )
{
  CHAR8 *SymbolStr;

  SymbolStr = FindSymbolStr (Address);
  if (SymbolStr != NULL) {
    EDBSPrintWithOffset (
      mInstructionString.Content,
      EDB_INSTRUCTION_CONTENT_MAX_SIZE,
      mInstructionContentOffset,
      L"[%a]",
      SymbolStr
      );
    return 1;
  }

  return 0;
}

/**

  Print the EBC byte code.

  @param  InstructionAddress - instruction address
  @param  InstructionNumber  - instruction number

**/
VOID
EdbPrintRaw (
  IN EFI_PHYSICAL_ADDRESS   InstructionAddress,
  IN UINTN                  InstructionNumber
  )
{
  UINTN  LineNumber;
  UINTN  ByteNumber;
  UINTN  LineIndex;
  UINTN  ByteIndex;
  CHAR8  *SymbolStr;

  if (InstructionNumber == 0) {
    return ;
  }

  LineNumber = InstructionNumber / EDB_BYTECODE_NUMBER_IN_LINE;
  ByteNumber = InstructionNumber % EDB_BYTECODE_NUMBER_IN_LINE;
  if (ByteNumber == 0) {
    LineNumber -= 1;
    ByteNumber  = EDB_BYTECODE_NUMBER_IN_LINE;
  }

  //
  // Print Symbol
  //
  SymbolStr = FindSymbolStr ((UINTN)InstructionAddress);
  if (SymbolStr != NULL) {
    EDBPrint (L"[%a]:\n", SymbolStr);
  }

  for (LineIndex = 0; LineIndex < LineNumber; LineIndex++) {
    EDBPrint (EDB_PRINT_ADDRESS_FORMAT, (UINTN)InstructionAddress);
    for (ByteIndex = 0; ByteIndex < EDB_BYTECODE_NUMBER_IN_LINE; ByteIndex++) {
      EDBPrint (L"%02x ", *(UINT8 *)(UINTN)InstructionAddress);
      InstructionAddress += 1;
    }
    EDBPrint (L"\n");
  }

  EDBPrint (EDB_PRINT_ADDRESS_FORMAT, (UINTN)InstructionAddress);
  for (ByteIndex = 0; ByteIndex < ByteNumber; ByteIndex++) {
    EDBPrint (L"%02x ", *(UINT8 *)(UINTN)InstructionAddress);
    InstructionAddress += 1;
  }
  for (ByteIndex = 0; ByteIndex < EDB_BYTECODE_NUMBER_IN_LINE - ByteNumber; ByteIndex++) {
    EDBPrint (L"   ");
  }

  return ;
}

/**

  Print the EBC asm code.

  @param  DebuggerPrivate - EBC Debugger private data structure
  @param  SystemContext   - EBC system context.

  @retval EFI_SUCCESS - show disasm successfully

**/
EFI_STATUS
EdbShowDisasm (
  IN     EFI_DEBUGGER_PRIVATE_DATA *DebuggerPrivate,
  IN     EFI_SYSTEM_CONTEXT        SystemContext
  )
{
  EFI_PHYSICAL_ADDRESS    InstructionAddress;
  UINTN                   InstructionNumber;
  UINTN                   InstructionLength;
  UINT8                   Opcode;
  CHAR16                  *InstructionString;
//  UINTN                   Result;

  InstructionAddress = DebuggerPrivate->InstructionScope;
  for (InstructionNumber = 0; InstructionNumber < DebuggerPrivate->InstructionNumber; InstructionNumber++) {

    //
    // Break each 0x10 instruction
    //
    if (((InstructionNumber % EFI_DEBUGGER_LINE_NUMBER_IN_PAGE) == 0) &&
        (InstructionNumber != 0)) {
      if (SetPageBreak ()) {
        break;
      }
    }

    Opcode = GET_OPCODE(InstructionAddress);
    if ((Opcode < OPCODE_MAX) && (mEdbDisasmInstructionTable[Opcode] != NULL)) {
      InstructionLength = mEdbDisasmInstructionTable [Opcode] (InstructionAddress, SystemContext, &InstructionString);
      if (InstructionLength != 0) {

        //
        // Print Source
        //
//        Result = EdbPrintSource ((UINTN)InstructionAddress, FALSE);

        if (!DebuggerPrivate->DebuggerSymbolContext.DisplayCodeOnly) {

          EdbPrintRaw (InstructionAddress, InstructionLength);
          if (InstructionString != NULL) {
            EDBPrint (L"%s\n", InstructionString);
          } else {
            EDBPrint (L"%s\n", L"<Unknown Instruction>");
          }
        }

        EdbPrintSource ((UINTN)InstructionAddress, TRUE);

        InstructionAddress += InstructionLength;
      } else {
        //
        // Something wrong with OPCODE
        //
        EdbPrintRaw (InstructionAddress, EDB_BYTECODE_NUMBER_IN_LINE);
        EDBPrint (L"%s\n", L"<Bad Instruction>");
        break;
      }
    } else {
      //
      // Something wrong with OPCODE
      //
      EdbPrintRaw (InstructionAddress, EDB_BYTECODE_NUMBER_IN_LINE);
      EDBPrint (L"%s\n", L"<Bad Instruction>");
      break;
    }
  }

  return EFI_SUCCESS;
}

/**

  Get register value accroding to the system context, and register index.

  @param  SystemContext   - EBC system context.
  @param  Index           - EBC register index

  @return register value

**/
UINT64
GetRegisterValue (
  IN     EFI_SYSTEM_CONTEXT        SystemContext,
  IN     UINT8                     Index
  )
{
  switch (Index) {
  case 0:
    return SystemContext.SystemContextEbc->R0;
  case 1:
    return SystemContext.SystemContextEbc->R1;
  case 2:
    return SystemContext.SystemContextEbc->R2;
  case 3:
    return SystemContext.SystemContextEbc->R3;
  case 4:
    return SystemContext.SystemContextEbc->R4;
  case 5:
    return SystemContext.SystemContextEbc->R5;
  case 6:
    return SystemContext.SystemContextEbc->R6;
  case 7:
    return SystemContext.SystemContextEbc->R7;
  default:
    ASSERT (FALSE);
    break;
  }
  return 0;
}


text:
<?php

namespace League\Fractal\Serializer;

class DataArraySerializer extends ArraySerializer
{
    /**
     * Serialize a collection.
     *
     * @param string $resourceKey
     * @param array  $data
     *
     * @return array
     */
    public function collection($resourceKey, array $data)
    {
        return array('data' => $data);
    }

    /**
     * Serialize an item.
     *
     * @param string $resourceKey
     * @param array  $data
     *
     * @return array
     */
    public function item($resourceKey, array $data)
    {
        return array('data' => $data);
    }
}


text:
<?php

namespace NarratioWeb\OeuvresBundle\Form;

use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolverInterface;

class OeuvreType extends AbstractType
{
    /**
     * @param FormBuilderInterface $builder
     * @param array $options
     */
    public function buildForm(FormBuilderInterface $builder, array $options)
    {
        $builder
            ->add('nom', 'text', array('label' => 'Nom de l\'oeuvre'))
            ->add('concept', 'text', array('label' => 'Concept de l\'oeuvre'))
            ->add('prodDer', 'text', array('label' => 'Produits dérivés'))
            ->add('image', 'text', array('label' => 'Image de l\'oeuvre'), new ImageType())
            -> add('TrancheAge', 'entity',
            array('label' => 'Tranche d\'Âge de l\'oeuvre',
            'class' => 'NarratioWebOeuvresBundle:TrancheAge',
            'property' => 'intitule',
            'multiple' => false,
            'expanded' => false))
            -> add('Epoque', 'entity',
            array('label' => 'Epoque de l\'oeuvre',
            'class' => 'NarratioWebOeuvresBundle:Epoque',
            'property' => 'intitule',
            'multiple' => false,
            'expanded' => false))
            -> add('Genre', 'entity',
            array('label' => 'Genre de l\'oeuvre',
            'class' => 'NarratioWebOeuvresBundle:Genre',
            'property' => 'intitule',
            'multiple' => false,
            'expanded' => false))
            -> add('Thematique', 'entity',
            array('label' => 'Thématique de l\'oeuvre',
            'class' => 'NarratioWebOeuvresBundle:Thematique',
            'property' => 'intitule',
            'multiple' => false,
            'expanded' => false))
        ;
    }

    /**
     * @param OptionsResolverInterface $resolver
     */
    public function setDefaultOptions(OptionsResolverInterface $resolver)
    {
        $resolver->setDefaults(array(
            'data_class' => 'NarratioWeb\OeuvresBundle\Entity\Oeuvre'
        ));
    }

    /**
     * @return string
     */
    public function getName()
    {
        return 'narratioweb_oeuvresbundle_oeuvre';
    }
}


text:
package net.ontrack.backend;

import net.ontrack.backend.dao.AccountDao;
import net.ontrack.backend.dao.EntityDao;
import net.ontrack.backend.dao.SubscriptionDao;
import net.ontrack.backend.dao.model.TAccount;
import net.ontrack.core.config.CoreConfig;
import net.ontrack.core.model.*;
import net.ontrack.core.security.SecurityRoles;
import net.ontrack.core.security.SecurityUtils;
import net.ontrack.core.support.MapBuilder;
import net.ontrack.service.GUIEventService;
import net.ontrack.service.GUIService;
import net.ontrack.service.MessageService;
import net.ontrack.service.TemplateService;
import net.ontrack.service.model.MessageChannel;
import net.ontrack.service.model.MessageDestination;
import net.ontrack.service.model.TemplateModel;
import org.joda.time.DateTime;
import org.junit.Before;
import org.junit.Test;

import java.util.Arrays;
import java.util.Collections;
import java.util.Locale;

import static org.junit.Assert.assertEquals;
import static org.mockito.Mockito.*;

public class DefaultSubscriptionServiceTest {

    private SubscriptionDao subscriptionDao;
    private AccountDao accountDao;
    private GUIEventService guiEventService;
    private MessageService messageService;
    private TemplateService templateService;
    private DefaultSubscriptionService service;

    @Before
    public void before() {
        // Mocks
        subscriptionDao = mock(SubscriptionDao.class);
        accountDao = mock(AccountDao.class);
        guiEventService = mock(GUIEventService.class);
        messageService = mock(MessageService.class);
        templateService = mock(TemplateService.class);
        // Service to test
        service = new DefaultSubscriptionService(
                mock(SecurityUtils.class),
                mock(ConfigurationService.class),
                subscriptionDao,
                accountDao,
                mock(EntityDao.class),
                guiEventService,
                mock(GUIService.class),
                messageService,
                templateService,
                new CoreConfig().strings()
        );
    }

    @Test
    public void getMessageAbstract() {
        String html = "The message content with html and a link.";
        String text = service.getMessageAbstract(html);
        assertEquals("The message content with html and a link.", text);
    }

    @Test
    public void publish_with_status() {
        // Event to send
        ExpandedEvent event = new ExpandedEvent(
                100,
                "The Author",
                EventType.VALIDATION_RUN_CREATED,
                new DateTime(),
                MapBuilder
                        .of(Entity.PROJECT, new EntityStub(Entity.PROJECT, 1, "PRJ"))
                        .with(Entity.BRANCH, new EntityStub(Entity.BRANCH, 1, "BRCH"))
                        .get(),
                MapBuilder.
                        of("status", Status.FAILED.name())
                        .get()
        );
        // List of accounts
        when(subscriptionDao.findAccountIds(
                MapBuilder.of(Entity.PROJECT, 1).with(Entity.BRANCH, 1).get()
        )).thenReturn(Arrays.asList(1));
        // Account access
        when(accountDao.getByID(1)).thenReturn(new TAccount(
                22,
                "the_author",
                "The Author",
                "the_author@test.com",
                SecurityRoles.USER,
                "builtin",
                Locale.ENGLISH
        ));
        // GUI event
        when(guiEventService.toGUIEvent(
                eq(event),
                eq(Locale.ENGLISH),
                any(DateTime.class)
        )).thenReturn(
                new GUIEvent(
                        100,
                        "The Author",
                        EventType.VALIDATION_RUN_CREATED,
                        "The timestamp",
                        "The elapsed time",
                        "The message content with html and a link.",
                        "icon-class",
                        Status.FAILED.name()
                )
        );
        // Template
        when(templateService.generate(
                eq("event.html"),
                eq(Locale.ENGLISH),
                any(TemplateModel.class)
        )).thenReturn("The message content with html and a link.");
        // Publishes an event
        service.publish(event);
        // Checks the reception
        verify(messageService, times(1)).sendMessage(
                new Message(
                        "ontrack - Failed - The message content with html and a link.",
                        new MessageContent(
                                MessageContentType.HTML,
                                "The message content with html and a link.",
                                Collections.<String, String>emptyMap()
                        )
                ),
                new MessageDestination(
                        MessageChannel.EMAIL,
                        Arrays.asList("the_author@test.com")
                )
        );
    }

}


text:
Create an iterable function that assigns a default value to given property name

## Installation
  `npm install default-prop --save`

## Usage
```javascript
var defaultProp = require('default-prop')

var accounts = [{
    name: 'alice',
    inUse: true
  },{
    name: 'bob'
  },{
    name: 'charlie'
  }]

accounts.forEach(defaultProp('inUse', false))

console.log(accounts)
// =>
// accounts = [{
//     name: 'alice',
//     inUse: true
//   },{
//     name: 'bob',
//     inUse: false
//   },{
//     name: 'charlie',
//     inUse: false
//   }]
```

# License
MIT


text:
//package com.siu.android.volleyball.local;
//
//import com.android.volley.Response;
//import com.siu.android.volleyball.BallRequest;
//import com.siu.android.volleyball.BallResponse;
//
///**
// * Created by lukas on 8/29/13.
// */
//public abstract class LocalRequest<T> extends BallRequest<T> {
//
//    public LocalRequest(int method, String url, Response.ErrorListener errorListener) {
//        super(method, url, errorListener);
//    }
//
//    public LocalRequest(int method, String url, BallResponse.ListenerWithLocalProcessing<T> listener, Response.ErrorListener errorListener) {
//        super(method, url, listener, errorListener);
//    }
//
//    @Override
//    public boolean shouldProcessLocal() {
//        return true;
//    }
//
//    @Override
//    protected LocalRequestProcessor<T> createLocalRequestProcessor() {
//        return new LocalRequestProcessor<T>() {
//            @Override
//            public T getLocalResponse() {
//                return LocalRequest.this.getLocalResponseContent();
//            }
//
//            @Override
//            public void saveLocalResponse(T response) {
//                LocalRequest.this.saveLocalResponse(response);
//            }
//
//            @Override
//            public void deliverLocalResponse(T response) {
//                LocalRequest.this.deliverLocalResponse(response);
//            }
//        };
//    }
//
//    protected abstract T getLocalResponseContent();
//
//    public abstract void saveLocalResponse(T response);
//
//    private void deliverLocalResponse(T response) {
//        if (mListenerWithLocalProcessing == null) {
//            throw new RuntimeException("Local request listener is null, you need to supply one or override this method");
//        }
//
//        mListenerWithLocalProcessing.onLocalResponse(response);
//    }
//}


text:
<?php global $data; echo $data['textarea_footer_text']; ?>  handcrafted with  in NYC

<?php echo $data['google_analytics']; ?>

<?php wp_footer(); ?>


text:
import Backbone from "backbone"
import $ from "jquery"
import { fabricate } from "@artsy/antigravity"
import { logoutEventHandler } from "desktop/lib/global_client_setup"

const CurrentUser = require("../../../models/current_user")
const { UserSettingsView } = require("../client/view.coffee")
jest.mock("desktop/lib/global_client_setup", () => ({
  logoutEventHandler: jest.fn(),
}))

describe("UserSettingsView", () => {
  let view
  beforeEach(() => {
    Backbone.sync = jest.fn()
    new CurrentUser(fabricate("user"))
    view = new UserSettingsView({
      el: $(
        `
 \

 \

 \

`
      ),
    })
  })

  describe("#logout", () => {
    it("logs out a user who was signed in", () => {
      view.$(".js--settings-logout").click()
      expect(logoutEventHandler).toBeCalled()
    })
  })
})