new CachingObjectMatcher(uri, opt_xhrIo, opt_xmlHttpFactory, opt_multi, opt_noSimilar)
This class is based on goog.ui.ac.CachingMatcher. It differs
in the following ways:
- it disposes of cached objects (i.e. calls
plana.ui.ac.RemoteObject#dispose)
- it defines three states the cache is in:
* fetching server matches
* server returned matches
* no matches found
Parameters:
Name | Type | Argument | Description |
---|---|---|---|
uri |
goog.Uri | The uri which generates the auto complete matches. The search term is passed to the server as the 'token' query param | |
opt_xhrIo |
goog.net.XhrIo |
<optional> |
Optional XhrIo object to use. By default we create a new instance |
opt_xmlHttpFactory |
goog.net.XmlHttpFactory |
<optional> |
Optional factory to use when creating XMLHttpRequest objects |
opt_multi |
boolean |
<optional> |
Whether to allow multiple entries |
opt_noSimilar |
boolean |
<optional> |
If true, request that the server does not do similarity matches for the input token against the dictionary The value is sent to the server as the 'use_similar' query param which is either "1" (opt_noSimilar==false) or "0" (opt_noSimilar==true) |
- Source:
Extends
- goog.events.EventHandler
Members
-
<static> State :number
-
List of events dispatched by the cache manager
Type:
- number
- Source:
Properties:
Name Type Default Description FETCHING
number 0 This state indicates that the remote matcher is fetching results from the server NO_MATCH
number 1 This state indicates that the server could not find matches for a token READY
number 2 This state indicates that matches have been returned by the server ERROR
number 3 This state indicates that the remote matcher encountered an error trying to get matches
Methods
-
clearCache()
-
This function clears the cache
- Source:
-
disableLocalCache(disable)
-
Setter to disable the local cache. If disabled, matches returned by the server will not be stored locally
Parameters:
Name Type Description disable
boolean The value to set - Source:
-
disposeInternal()
-
- Source:
-
getCachedMatches(token, maxMatches) → {!Array.<plana.ui.ac.RemoteObject>}
-
This function is taken from goog.ui.ac.ArrayMatcher. It matches the token against the specified rows, first looking for prefix matches and if that fails, then looking for similar matches
Parameters:
Name Type Description token
string Token to match maxMatches
number Max number of matches to return - Source:
Returns:
Rows that match- Type
- !Array.<plana.ui.ac.RemoteObject>
-
getPrefixMatchesForRows(token, maxMatches) → {!Array.<plana.ui.ac.RemoteObject>}
-
This function is taken from goog.ui.ac.ArrayMatcher. It matches the token against the start of words in the row
Parameters:
Name Type Description token
string Token to match maxMatches
number Max number of matches to return - Source:
Returns:
Rows that match- Type
- !Array.<plana.ui.ac.RemoteObject>
-
getRemoteMatcher() → {plana.ui.ac.RemoteObjectMatcher}
-
This function returns the matcher used to fetch matches via ajax
- Source:
Returns:
-
getSimilarMatchesForRows(token, maxMatches) → {!Array.<plana.ui.ac.RemoteObject>}
-
This function is taken from goog.ui.ac.ArrayMatcher. It matches the token against similar rows, by calculating "distance" between the terms
Parameters:
Name Type Description token
string Token to match maxMatches
number Max number of matches to return - Source:
Returns:
The best maxMatches rows- Type
- !Array.<plana.ui.ac.RemoteObject>
-
getState() → {number}
-
This function returns the current state of the cache manager and its base matcher
- Source:
Returns:
- Type
- number
-
requestMatchingRows(token, maxMatches, matchHandler, opt_fullstring)
-
This function is taken from goog.ui.ac.CachingMatcher. It passes matches to the autocomplete
Parameters:
Name Type Argument Description token
string Token to match maxMatches
number Max number of matches to return matchHandler
function <nullable>
callback to execute after matching opt_fullstring
string <optional>
The complete string in the input textbox - Source:
-
sendEmptyToken(sendEmpty)
-
Setter for flag if we should send an empty token to the server to request matches.
Parameters:
Name Type Description sendEmpty
boolean - Source:
-
setMaxCacheSize(maxCacheSize)
-
Sets the maximum size of the local cache. If the local cache grows larger than this size, it will be emptied Default value: 1000
Parameters:
Name Type Description maxCacheSize
number The value to set - Source:
-
setRemoteMatcherMaxMatches(maxMatches)
-
Sets the maxMatches to use for the remote matcher Default value: 100
Parameters:
Name Type Description maxMatches
number The value to set - Source:
-
setThrottleTime(throttleTime)
-
Sets the number of milliseconds with which to throttle the match requests on the underlying matcher Default value: 150
Parameters:
Name Type Description throttleTime
number The value to set - Source:
-
shouldRequestMatches(token, fullstring) → {boolean}
-
This function returns true on non-empty strings and if fullstring isn't empty, but token might be. Otherwise returns false
Parameters:
Name Type Description token
string Current token in autocomplete fullstring
string The complete value of the autocomplete input - Source:
Returns:
Whether new matches be requested- Type
- boolean