表示一次词典匹配的命中
| 29 | * 表示一次词典匹配的命中 |
| 30 | */ |
| 31 | public class Hit { |
| 32 | //Hit不匹配 |
| 33 | private static final int UNMATCH = 0x00000000; |
| 34 | //Hit完全匹配 |
| 35 | private static final int MATCH = 0x00000001; |
| 36 | //Hit前缀匹配 |
| 37 | private static final int PREFIX = 0x00000010; |
| 38 | |
| 39 | |
| 40 | //该HIT当前状态,默认未匹配 |
| 41 | private int hitState = UNMATCH; |
| 42 | |
| 43 | //记录词典匹配过程中,当前匹配到的词典分支节点 |
| 44 | private DictSegment matchedDictSegment; |
| 45 | /* |
| 46 | * 词段开始位置 |
| 47 | */ |
| 48 | private int begin; |
| 49 | /* |
| 50 | * 词段的结束位置 |
| 51 | */ |
| 52 | private int end; |
| 53 | |
| 54 | |
| 55 | /** |
| 56 | * 判断是否完全匹配 |
| 57 | */ |
| 58 | public boolean isMatch() { |
| 59 | return (this.hitState & MATCH) > 0; |
| 60 | } |
| 61 | /** |
| 62 | * |
| 63 | */ |
| 64 | public void setMatch() { |
| 65 | this.hitState = this.hitState | MATCH; |
| 66 | } |
| 67 | |
| 68 | /** |
| 69 | * 判断是否是词的前缀 |
| 70 | */ |
| 71 | public boolean isPrefix() { |
| 72 | return (this.hitState & PREFIX) > 0; |
| 73 | } |
| 74 | /** |
| 75 | * |
| 76 | */ |
| 77 | public void setPrefix() { |
| 78 | this.hitState = this.hitState | PREFIX; |
| 79 | } |
| 80 | /** |
| 81 | * 判断是否是不匹配 |
| 82 | */ |
| 83 | public boolean isUnmatch() { |
| 84 | return this.hitState == UNMATCH ; |
| 85 | } |
| 86 | /** |
| 87 | * |
| 88 | */ |
nothing calls this directly
no outgoing calls
no test coverage detected