$rootNode
$rootNode :
Walks a provided identifier to try and find one or more matching components.
__construct( $deviceData)
$deviceData |
seekComponents( $identifier)
Loop over the input string character by character and descend down a Trie structure to find matching Components.
The Trie is a shallow Trie created from token values. It expects either a full match to a token from an incoming identifier or a partial stats-with match if permitted by a found MatchCandidate.
Although the individual characters(*) are used to walk the Trie it is easier to think of the input string as a collection of tokens delimited by characters like spaces, semi-colons etc.
A given branch of the Trie may either be formed from a single token or formed from a chain of adjacent tokens.
At the end of a token, a matching Node may contain some MatchCandidates. These MatchCandidates contain a Component and some additional criteria that must be passed before the Component is added to the "found" collection.
(* in practice the codePoint is used to walk the trie and not the actual character itself)
Note1: See flow diagram in internal-docs/tokentriewalk.drawio.png
NOTE2: Some attempts were made to split the below method into multiple methods to add readability. The overall API performance dropped by around 40-50,000 detections per second with this change so it was reverted.
$identifier | string The identifier to find matching components from. |
findNextCharactersMatch( $node, $identifier, $character, $identifierCurrentPosition)
The identifier can contain more than one character in the Node, so this function tries to find a match, if found, the character matched is returned along with the additional character position.
$node | ||
$identifier | ||
$character | ||
$identifierCurrentPosition |
hasTokenStartNode( $node)
$node |
getTokenStartNode( $node)
$node |
getDirectChildNode( $node)
$node |
hasMatchCandidates( $node)
$node |
getMatchCandidates( $node)
$node |
isSwAllowedAnyMatch( $node)
$node |
addMatchCandidates( $matchResult, $candidates, $endTokenCharPosition, $tokenPosition, $atEndOfToken)
Check if any of the match candidates pass the checks and add to cFound if so
$matchResult | IdentifierMatchResult The collection to add found components to |
|
$candidates | array The possible candidates to add to cFound |
|
$endTokenCharPosition | int |
|
$tokenPosition | int The current token position from the identifier |
|
$atEndOfToken | boolean True if the Trie walk used the full token from the identifier. False otherwise. |