I think the easiest way to do this is to create an NFA , such as trie, which allows you to transition into multiple states. This, of course, adds to the complexity of having a different data structure that maps to multiple states based on the character set to match. For example, in your example:
JBoss:* *:* JBoss:type=ThreadPool,* JBoss:type=Thread*,* JB*:name=http1,type=ConnectionPool
Suppose you are trying to match a JBoxx:name=*
When you map a JBo substring, you will need a data structure to store the JBo and JB* and * states, as you currently have three branches. When x arrives, you can drop the JBo route from the moment it was JBo and use JB* and * . An easy implementation is to have a set of possible matching states at any given time and try the next character for each one. You will also need a way to resolve multiple matches (as in this case) - maybe something as simple as the longest match?
Everything seems to make sense when you think of trie as an NFA, not a well-accepted DFA format. Hope this helps.
kyun
source share