xref: /OpenGrok/opengrok-indexer/src/main/java/org/opengrok/indexer/analysis/TextMatchedEvent.java (revision 5d9f3aa0ca3da3a714233f987fa732f62c0965f6)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * See LICENSE.txt included in this distribution for the specific
9  * language governing permissions and limitations under the License.
10  *
11  * When distributing Covered Code, include this CDDL HEADER in each
12  * file and include the License file at LICENSE.txt.
13  * If applicable, add the following below this CDDL HEADER, with the
14  * fields enclosed by brackets "[]" replaced with your own identifying
15  * information: Portions Copyright [yyyy] [name of copyright owner]
16  *
17  * CDDL HEADER END
18  */
19 
20 /*
21  * Copyright (c) 2017, 2020, Chris Fraire <cfraire@me.com>.
22  */
23 package org.opengrok.indexer.analysis;
24 
25 /**
26  * Represents an event raised when a symbol matcher matches a string that
27  * would not be published as a symbol.
28  */
29 public class TextMatchedEvent {
30 
31     private final Object source;
32     private final String str;
33     private final EmphasisHint hint;
34     private final long start;
35     private final long end;
36 
37     /**
38      * Initializes an immutable instance of {@link TextMatchedEvent}.
39      * @param source the event source
40      * @param str the text string
41      * @param start the text start position
42      * @param end the text end position
43      */
TextMatchedEvent(Object source, String str, long start, long end)44     public TextMatchedEvent(Object source, String str, long start, long end) {
45         this(source, str, EmphasisHint.NONE, start, end);
46     }
47 
48     /**
49      * Initializes an immutable instance of {@link TextMatchedEvent}.
50      * @param source the event source
51      * @param str the text string
52      * @param hint the text hint
53      * @param start the text start position
54      * @param end the text end position
55      */
TextMatchedEvent(Object source, String str, EmphasisHint hint, long start, long end)56     public TextMatchedEvent(Object source, String str, EmphasisHint hint, long start, long end) {
57         this.source = source;
58         this.str = str;
59         this.hint = hint;
60         this.start = start;
61         this.end = end;
62     }
63 
64     /**
65      * Gets the event source.
66      * @return the initial value
67      */
getSource()68     public Object getSource() {
69         return source;
70     }
71 
72     /**
73      * Gets the text string.
74      * @return the initial value
75      */
getStr()76     public String getStr() {
77         return str;
78     }
79 
80     /**
81      * Gets the text start position.
82      * @return the initial value
83      */
getStart()84     public long getStart() {
85         return start;
86     }
87 
88     /**
89      * Gets the text end position.
90      * @return the initial value
91      */
getEnd()92     public long getEnd() {
93         return end;
94     }
95 
96     /**
97      * Gets the text hint.
98      * @return the initial value
99      */
getHint()100     public EmphasisHint getHint() {
101         return hint;
102     }
103 }
104