Javascript MatchingItem

From Yate Documentation
(Difference between revisions)
Jump to: navigation, search
(Constructor)
Line 4: Line 4:
 
May be set as filter in [[Javascript Message|Message]] handler and post hook install (match one or more message parameter(s)).
 
May be set as filter in [[Javascript Message|Message]] handler and post hook install (match one or more message parameter(s)).
 
May be used for matching individual values
 
May be used for matching individual values
 +
 +
== Description ==
  
 
== Constructor ==
 
== Constructor ==
Line 10: Line 12:
 
Build a new MatchingItem object.<br/>
 
Build a new MatchingItem object.<br/>
 
Parameters:<br/>
 
Parameters:<br/>
'''value''': Value to match. May be another MatchingItem object (all other parameters will be ignored), RegExp, string.<br/>
+
'''value''': Value to match. May be another MatchingItem object (all other parameters will be ignored). <br/>
 
'''name''': Parameter name.<br/>
 
'''name''': Parameter name.<br/>
 
'''params''': Build parameters.<br/>
 
'''params''': Build parameters.<br/>
 +
 +
If ''value'' is a MatchingItem builds a copy of it.<br/>
 +
 +
Otherwise build a MatchingItem from received parameters.<br/>
 +
See validate() method for processing.<br/>
 +
Constructor will fail if validate() would not return an object.<br/>
 +
If you are not sure of parameters call validate and then pass the result to constructor:
 +
var obj = Engine.MatchingItem.validate(some_value,some_name,params);
 +
if (obj && "string" != typeof obj)
 +
    obj = new Engine.MatchingItem(obj);
 +
else if (undefined === obj) {
 +
    // Empty ...
 +
}
 +
else {
 +
    // Invalid. obj is an error string
 +
}
 +
  
 
== Static methods ==
 
== Static methods ==
Line 18: Line 37:
 
* '''validate(value[,name[,params]])'''
 
* '''validate(value[,name[,params]])'''
 
Parameters:<br/>
 
Parameters:<br/>
'''value''': <br/>
+
'''value''': Value to match.<br/>
'''name''': <br/>
+
'''name''': Parameter name.<br/>
'''params''': <br/>
+
'''params''': Build parameters.<br/>
 
Return:<br/>
 
Return:<br/>
Success: Object with matching properties<br/>
+
Success: Object with matching properties. See the description section.<br/>
Success with empty optimized matching: null/undefined<br/>
+
Success with empty optimized matching: undefined<br/>
 
Error: string describing the error<br/>
 
Error: string describing the error<br/>
 +
  
  

Revision as of 10:04, 4 September 2024

Contents

General

Object implementing complex matching.
May be set as filter in Message handler and post hook install (match one or more message parameter(s)). May be used for matching individual values

Description

Constructor

  • new Engine.MatchingItem(value[,name[,params])

Build a new MatchingItem object.
Parameters:
value: Value to match. May be another MatchingItem object (all other parameters will be ignored).
name: Parameter name.
params: Build parameters.

If value is a MatchingItem builds a copy of it.

Otherwise build a MatchingItem from received parameters.
See validate() method for processing.
Constructor will fail if validate() would not return an object.
If you are not sure of parameters call validate and then pass the result to constructor:

var obj = Engine.MatchingItem.validate(some_value,some_name,params);
if (obj && "string" != typeof obj)
    obj = new Engine.MatchingItem(obj);
else if (undefined === obj) {
    // Empty ...
}
else {
    // Invalid. obj is an error string
}

Static methods

  • validate(value[,name[,params]])

Parameters:
value: Value to match.
name: Parameter name.
params: Build parameters.
Return:
Success: Object with matching properties. See the description section.
Success with empty optimized matching: undefined
Error: string describing the error


Methods

  • matches(value)


  • getDesc([params])


  • dump([params[,indent,origIndent]])
Personal tools
Namespaces

Variants
Actions
Preface
Configuration
Administrators
Developers