Ext.data.JsonP.Ext_util_Inflector({"mixins":[],"code_type":"ext_define","inheritable":false,"component":false,"meta":{},"mixedInto":[],"uses":[],"aliases":{},"parentMixins":[],"superclasses":["Ext.Base"],"members":{"event":[],"property":[{"meta":{"private":true},"owner":"Ext.Base","tagname":"property","name":"$className","id":"property-S-className"},{"meta":{"private":true},"owner":"Ext.Base","tagname":"property","name":"configMap","id":"property-configMap"},{"meta":{"private":true},"owner":"Ext.Base","tagname":"property","name":"initConfigList","id":"property-initConfigList"},{"meta":{"private":true},"owner":"Ext.Base","tagname":"property","name":"initConfigMap","id":"property-initConfigMap"},{"meta":{"private":true},"owner":"Ext.Base","tagname":"property","name":"isInstance","id":"property-isInstance"},{"meta":{"private":true},"owner":"Ext.util.Inflector","tagname":"property","name":"plurals","id":"property-plurals"},{"meta":{"protected":true},"owner":"Ext.Base","tagname":"property","name":"self","id":"property-self"},{"meta":{"private":true},"owner":"Ext.util.Inflector","tagname":"property","name":"singulars","id":"property-singulars"},{"meta":{"private":true},"owner":"Ext.util.Inflector","tagname":"property","name":"uncountable","id":"property-uncountable"}],"css_var":[],"method":[{"meta":{"deprecated":{"text":"as of 4.1. Use {@link #callParent} instead."},"protected":true},"owner":"Ext.Base","tagname":"method","name":"callOverridden","id":"method-callOverridden"},{"meta":{"protected":true},"owner":"Ext.Base","tagname":"method","name":"callParent","id":"method-callParent"},{"meta":{},"owner":"Ext.util.Inflector","tagname":"method","name":"classify","id":"method-classify"},{"meta":{},"owner":"Ext.util.Inflector","tagname":"method","name":"clearPlurals","id":"method-clearPlurals"},{"meta":{},"owner":"Ext.util.Inflector","tagname":"method","name":"clearSingulars","id":"method-clearSingulars"},{"meta":{"private":true},"owner":"Ext.Base","tagname":"method","name":"configClass","id":"method-configClass"},{"meta":{"private":true},"owner":"Ext.Base","tagname":"method","name":"destroy","id":"method-destroy"},{"meta":{"private":true},"owner":"Ext.Base","tagname":"method","name":"getConfig","id":"method-getConfig"},{"meta":{},"owner":"Ext.Base","tagname":"method","name":"getInitialConfig","id":"method-getInitialConfig"},{"meta":{"private":true},"owner":"Ext.Base","tagname":"method","name":"hasConfig","id":"method-hasConfig"},{"meta":{"protected":true},"owner":"Ext.Base","tagname":"method","name":"initConfig","id":"method-initConfig"},{"meta":{},"owner":"Ext.util.Inflector","tagname":"method","name":"isTransnumeral","id":"method-isTransnumeral"},{"meta":{"private":true},"owner":"Ext.Base","tagname":"method","name":"onConfigUpdate","id":"method-onConfigUpdate"},{"meta":{},"owner":"Ext.util.Inflector","tagname":"method","name":"ordinalize","id":"method-ordinalize"},{"meta":{},"owner":"Ext.util.Inflector","tagname":"method","name":"plural","id":"method-plural"},{"meta":{},"owner":"Ext.util.Inflector","tagname":"method","name":"pluralize","id":"method-pluralize"},{"meta":{"private":true},"owner":"Ext.Base","tagname":"method","name":"setConfig","id":"method-setConfig"},{"meta":{},"owner":"Ext.util.Inflector","tagname":"method","name":"singular","id":"method-singular"},{"meta":{},"owner":"Ext.util.Inflector","tagname":"method","name":"singularize","id":"method-singularize"},{"meta":{"protected":true},"owner":"Ext.Base","tagname":"method","name":"statics","id":"method-statics"}],"css_mixin":[],"cfg":[]},"tagname":"class","extends":"Ext.Base","html":"

Hierarchy

Ext.Base
Ext.util.Inflector

Files

General purpose inflector class that pluralizes, singularizes and\nordinalizes words. Sample usage:

\n\n
//turning singular words into plurals\nExt.util.Inflector.pluralize('word'); //'words'\nExt.util.Inflector.pluralize('person'); //'people'\nExt.util.Inflector.pluralize('sheep'); //'sheep'\n\n//turning plurals into singulars\nExt.util.Inflector.singularize('words'); //'word'\nExt.util.Inflector.singularize('people'); //'person'\nExt.util.Inflector.singularize('sheep'); //'sheep'\n\n//ordinalizing numbers\nExt.util.Inflector.ordinalize(11); //\"11th\"\nExt.util.Inflector.ordinalize(21); //\"21st\"\nExt.util.Inflector.ordinalize(1043); //\"1043rd\"\n
\n\n

Customization

\n\n

The Inflector comes with a default set of US English pluralization rules. These can be augmented with additional\nrules if the default rules do not meet your application's requirements, or swapped out entirely for other languages.\nHere is how we might add a rule that pluralizes \"ox\" to \"oxen\":

\n\n
Ext.util.Inflector.plural(/^(ox)$/i, \"$1en\");\n
\n\n

Each rule consists of two items - a regular expression that matches one or more rules, and a replacement string. In\nthis case, the regular expression will only match the string \"ox\", and will replace that match with \"oxen\". Here's\nhow we could add the inverse rule:

\n\n
Ext.util.Inflector.singular(/^(ox)en$/i, \"$1\");\n
\n\n

Note that the ox/oxen rules are present by default.

\n
Defined By

Properties

...
\n

Defaults to: "Ext.Base"

...
\n

Defaults to: {}

...
\n

Defaults to: []

...
\n

Defaults to: {}

...
\n

Defaults to: true

Ext.util.Inflector
view source
: Arrayprivate
The registered plural tuples. ...

The registered plural tuples. Each item in the array should contain two items - the first must be a regular\nexpression that matchers the singular form of a word, the second must be a String that replaces the matched\npart of the regular expression. This is managed by the plural method.

\n
Get the reference to the current class from which this object was instantiated. ...

Get the reference to the current class from which this object was instantiated. Unlike statics,\nthis.self is scope-dependent and it's meant to be used for dynamic inheritance. See statics\nfor a detailed comparison

\n\n
Ext.define('My.Cat', {\n    statics: {\n        speciesName: 'Cat' // My.Cat.speciesName = 'Cat'\n    },\n\n    constructor: function() {\n        alert(this.self.speciesName); // dependent on 'this'\n    },\n\n    clone: function() {\n        return new this.self();\n    }\n});\n\n\nExt.define('My.SnowLeopard', {\n    extend: 'My.Cat',\n    statics: {\n        speciesName: 'Snow Leopard'         // My.SnowLeopard.speciesName = 'Snow Leopard'\n    }\n});\n\nvar cat = new My.Cat();                     // alerts 'Cat'\nvar snowLeopard = new My.SnowLeopard();     // alerts 'Snow Leopard'\n\nvar clone = snowLeopard.clone();\nalert(Ext.getClassName(clone));             // alerts 'My.SnowLeopard'\n
\n
Ext.util.Inflector
view source
: Arrayprivate
The set of registered singular matchers. ...

The set of registered singular matchers. Each item in the array should contain two items - the first must be a\nregular expression that matches the plural form of a word, the second must be a String that replaces the\nmatched part of the regular expression. This is managed by the singular method.

\n
Ext.util.Inflector
view source
: String[]private
The registered uncountable words ...

The registered uncountable words

\n

Defaults to: ["sheep", "fish", "series", "species", "money", "rice", "information", "equipment", "grass", "mud", "offspring", "deer", "means"]

Defined By

Methods

( Array/Arguments args ) : Objectdeprecatedprotected
Call the original method that was previously overridden with override\n\nExt.define('My.Cat', {\n constructor: functi...

Call the original method that was previously overridden with override

\n\n
Ext.define('My.Cat', {\n    constructor: function() {\n        alert(\"I'm a cat!\");\n    }\n});\n\nMy.Cat.override({\n    constructor: function() {\n        alert(\"I'm going to be a cat!\");\n\n        this.callOverridden();\n\n        alert(\"Meeeeoooowwww\");\n    }\n});\n\nvar kitty = new My.Cat(); // alerts \"I'm going to be a cat!\"\n                          // alerts \"I'm a cat!\"\n                          // alerts \"Meeeeoooowwww\"\n
\n
\n

This method has been deprecated

\n

as of 4.1. Use callParent instead.

\n\n
\n

Parameters

  • args : Array/Arguments

    The arguments, either an array or the arguments object\nfrom the current method, for example: this.callOverridden(arguments)

    \n

Returns

  • Object

    Returns the result of calling the overridden method

    \n
( Array/Arguments args ) : Objectprotected
Call the \"parent\" method of the current method. ...

Call the \"parent\" method of the current method. That is the method previously\noverridden by derivation or by an override (see Ext.define).

\n\n
 Ext.define('My.Base', {\n     constructor: function (x) {\n         this.x = x;\n     },\n\n     statics: {\n         method: function (x) {\n             return x;\n         }\n     }\n });\n\n Ext.define('My.Derived', {\n     extend: 'My.Base',\n\n     constructor: function () {\n         this.callParent([21]);\n     }\n });\n\n var obj = new My.Derived();\n\n alert(obj.x);  // alerts 21\n
\n\n

This can be used with an override as follows:

\n\n
 Ext.define('My.DerivedOverride', {\n     override: 'My.Derived',\n\n     constructor: function (x) {\n         this.callParent([x*2]); // calls original My.Derived constructor\n     }\n });\n\n var obj = new My.Derived();\n\n alert(obj.x);  // now alerts 42\n
\n\n

This also works with static methods.

\n\n
 Ext.define('My.Derived2', {\n     extend: 'My.Base',\n\n     statics: {\n         method: function (x) {\n             return this.callParent([x*2]); // calls My.Base.method\n         }\n     }\n });\n\n alert(My.Base.method(10);     // alerts 10\n alert(My.Derived2.method(10); // alerts 20\n
\n\n

Lastly, it also works with overridden static methods.

\n\n
 Ext.define('My.Derived2Override', {\n     override: 'My.Derived2',\n\n     statics: {\n         method: function (x) {\n             return this.callParent([x*2]); // calls My.Derived2.method\n         }\n     }\n });\n\n alert(My.Derived2.method(10); // now alerts 40\n
\n

Parameters

  • args : Array/Arguments

    The arguments, either an array or the arguments object\nfrom the current method, for example: this.callParent(arguments)

    \n

Returns

  • Object

    Returns the result of calling the parent method

    \n
Ext.util.Inflector
view source
( String word ) : String
Returns the correct Model name for a given string. ...

Returns the correct Model name for a given string. Mostly used internally by the data\npackage

\n

Parameters

  • word : String

    The word to classify

    \n

Returns

  • String

    The classified version of the word

    \n
Ext.util.Inflector
view source
( )
Removes all registered pluralization rules ...

Removes all registered pluralization rules

\n
Ext.util.Inflector
view source
( )
Removes all registered singularization rules ...

Removes all registered singularization rules

\n
...
\n

Parameters

Returns the initial configuration passed to constructor when instantiating\nthis class. ...

Returns the initial configuration passed to constructor when instantiating\nthis class.

\n

Parameters

  • name : String (optional)

    Name of the config option to return.

    \n

Returns

  • Object/Mixed

    The full config object or a single config value\nwhen name parameter specified.

    \n
...
\n

Parameters

Initialize configuration for this class. ...

Initialize configuration for this class. a typical example:

\n\n
Ext.define('My.awesome.Class', {\n    // The default config\n    config: {\n        name: 'Awesome',\n        isAwesome: true\n    },\n\n    constructor: function(config) {\n        this.initConfig(config);\n    }\n});\n\nvar awesome = new My.awesome.Class({\n    name: 'Super Awesome'\n});\n\nalert(awesome.getName()); // 'Super Awesome'\n
\n

Parameters

Returns

Ext.util.Inflector
view source
( String word ) : Boolean
Returns true if the given word is transnumeral (the word is its own singular and plural form - e.g. ...

Returns true if the given word is transnumeral (the word is its own singular and plural form - e.g. sheep, fish)

\n

Parameters

  • word : String

    The word to test

    \n

Returns

  • Boolean

    True if the word is transnumeral

    \n
( Object names, Object callback, Object scope )private
...
\n

Parameters

Ext.util.Inflector
view source
( Number number ) : String
Ordinalizes a given number by adding a prefix such as 'st', 'nd', 'rd' or 'th' based on the last digit of the\nnumber. ...

Ordinalizes a given number by adding a prefix such as 'st', 'nd', 'rd' or 'th' based on the last digit of the\nnumber. 21 -> 21st, 22 -> 22nd, 23 -> 23rd, 24 -> 24th etc

\n

Parameters

  • number : Number

    The number to ordinalize

    \n

Returns

  • String

    The ordinalized number

    \n
Ext.util.Inflector
view source
( RegExp matcher, String replacer )
Adds a new pluralization rule to the Inflector. ...

Adds a new pluralization rule to the Inflector. See the intro docs for more information

\n

Parameters

  • matcher : RegExp

    The matcher regex

    \n
  • replacer : String

    The replacement string, which can reference matches from the matcher argument

    \n
Ext.util.Inflector
view source
( String word ) : String
Returns the pluralized form of a word (e.g. ...

Returns the pluralized form of a word (e.g. Ext.util.Inflector.pluralize('word') returns 'words')

\n

Parameters

  • word : String

    The word to pluralize

    \n

Returns

  • String

    The pluralized form of the word

    \n
( Object config, Object applyIfNotSet )private
...
\n

Parameters

Ext.util.Inflector
view source
( RegExp matcher, String replacer )
Adds a new singularization rule to the Inflector. ...

Adds a new singularization rule to the Inflector. See the intro docs for more information

\n

Parameters

  • matcher : RegExp

    The matcher regex

    \n
  • replacer : String

    The replacement string, which can reference matches from the matcher argument

    \n
Ext.util.Inflector
view source
( String word ) : String
Returns the singularized form of a word (e.g. ...

Returns the singularized form of a word (e.g. Ext.util.Inflector.singularize('words') returns 'word')

\n

Parameters

  • word : String

    The word to singularize

    \n

Returns

  • String

    The singularized form of the word

    \n
Get the reference to the class from which this object was instantiated. ...

Get the reference to the class from which this object was instantiated. Note that unlike self,\nthis.statics() is scope-independent and it always returns the class from which it was called, regardless of what\nthis points to during run-time

\n\n
Ext.define('My.Cat', {\n    statics: {\n        totalCreated: 0,\n        speciesName: 'Cat' // My.Cat.speciesName = 'Cat'\n    },\n\n    constructor: function() {\n        var statics = this.statics();\n\n        alert(statics.speciesName);     // always equals to 'Cat' no matter what 'this' refers to\n                                        // equivalent to: My.Cat.speciesName\n\n        alert(this.self.speciesName);   // dependent on 'this'\n\n        statics.totalCreated++;\n    },\n\n    clone: function() {\n        var cloned = new this.self;                      // dependent on 'this'\n\n        cloned.groupName = this.statics().speciesName;   // equivalent to: My.Cat.speciesName\n\n        return cloned;\n    }\n});\n\n\nExt.define('My.SnowLeopard', {\n    extend: 'My.Cat',\n\n    statics: {\n        speciesName: 'Snow Leopard'     // My.SnowLeopard.speciesName = 'Snow Leopard'\n    },\n\n    constructor: function() {\n        this.callParent();\n    }\n});\n\nvar cat = new My.Cat();                 // alerts 'Cat', then alerts 'Cat'\n\nvar snowLeopard = new My.SnowLeopard(); // alerts 'Cat', then alerts 'Snow Leopard'\n\nvar clone = snowLeopard.clone();\nalert(Ext.getClassName(clone));         // alerts 'My.SnowLeopard'\nalert(clone.groupName);                 // alerts 'Cat'\n\nalert(My.Cat.totalCreated);             // alerts 3\n
\n

Returns

","subclasses":[],"name":"Ext.util.Inflector","alternateClassNames":[],"inheritdoc":null,"files":[{"href":"Inflector.html#Ext-util-Inflector","filename":"Inflector.js"}],"html_meta":{},"singleton":true,"id":"class-Ext.util.Inflector","statics":{"property":[],"event":[],"css_var":[],"method":[],"css_mixin":[],"cfg":[]},"requires":[]});