1b5840353SAdam Hornáček /* 2b5840353SAdam Hornáček * CDDL HEADER START 3b5840353SAdam Hornáček * 4b5840353SAdam Hornáček * The contents of this file are subject to the terms of the 5b5840353SAdam Hornáček * Common Development and Distribution License (the "License"). 6b5840353SAdam Hornáček * You may not use this file except in compliance with the License. 7b5840353SAdam Hornáček * 8b5840353SAdam Hornáček * See LICENSE.txt included in this distribution for the specific 9b5840353SAdam Hornáček * language governing permissions and limitations under the License. 10b5840353SAdam Hornáček * 11b5840353SAdam Hornáček * When distributing Covered Code, include this CDDL HEADER in each 12b5840353SAdam Hornáček * file and include the License file at LICENSE.txt. 13b5840353SAdam Hornáček * If applicable, add the following below this CDDL HEADER, with the 14b5840353SAdam Hornáček * fields enclosed by brackets "[]" replaced with your own identifying 15b5840353SAdam Hornáček * information: Portions Copyright [yyyy] [name of copyright owner] 16b5840353SAdam Hornáček * 17b5840353SAdam Hornáček * CDDL HEADER END 18b5840353SAdam Hornáček */ 19b5840353SAdam Hornáček 20b5840353SAdam Hornáček /* 21*d051e170SChris Fraire * Copyright (c) 2017, 2020, Chris Fraire <cfraire@me.com>. 22b5840353SAdam Hornáček */ 239805b761SAdam Hornáček package org.opengrok.indexer.analysis; 24b5840353SAdam Hornáček 25b5840353SAdam Hornáček /** 26b5840353SAdam Hornáček * Represents an event raised when a symbol matcher matches a string that 27b5840353SAdam Hornáček * would not be published as a symbol and that can be linked within OpenGrok or 28b5840353SAdam Hornáček * linked externally. 29b5840353SAdam Hornáček */ 30b5840353SAdam Hornáček public class LinkageMatchedEvent { 31b5840353SAdam Hornáček 32b5840353SAdam Hornáček private final Object source; 33b5840353SAdam Hornáček private final String str; 34b5840353SAdam Hornáček private final LinkageType linkageType; 35*d051e170SChris Fraire private final long start; 36*d051e170SChris Fraire private final long end; 37b5840353SAdam Hornáček private final String lstr; 38b5840353SAdam Hornáček 39b5840353SAdam Hornáček /** 40b5840353SAdam Hornáček * Initializes an immutable instance of {@link LinkageMatchedEvent} with 41b5840353SAdam Hornáček * {@link #getLinkStr()} equal to {@link #getStr()}. 42b5840353SAdam Hornáček * @param source the event source 43b5840353SAdam Hornáček * @param str the text string (literal capture) 44b5840353SAdam Hornáček * @param linkageType the text linkage type 45b5840353SAdam Hornáček * @param start the text start position 46b5840353SAdam Hornáček * @param end the text end position 47b5840353SAdam Hornáček */ LinkageMatchedEvent(Object source, String str, LinkageType linkageType, long start, long end)48*d051e170SChris Fraire public LinkageMatchedEvent(Object source, String str, LinkageType linkageType, 49*d051e170SChris Fraire long start, long end) { 50b5840353SAdam Hornáček this.source = source; 51b5840353SAdam Hornáček this.str = str; 52b5840353SAdam Hornáček this.linkageType = linkageType; 53b5840353SAdam Hornáček this.start = start; 54b5840353SAdam Hornáček this.end = end; 55b5840353SAdam Hornáček this.lstr = str; 56b5840353SAdam Hornáček } 57b5840353SAdam Hornáček 58b5840353SAdam Hornáček /** 59b5840353SAdam Hornáček * Initializes an immutable instance of {@link LinkageMatchedEvent}. 60b5840353SAdam Hornáček * @param source the event source 61b5840353SAdam Hornáček * @param str the text string (literal capture) 62b5840353SAdam Hornáček * @param linkageType the text linkage type 63b5840353SAdam Hornáček * @param start the text start position 64b5840353SAdam Hornáček * @param end the text end position 65b5840353SAdam Hornáček * @param lstr the text link string 66b5840353SAdam Hornáček */ LinkageMatchedEvent(Object source, String str, LinkageType linkageType, long start, long end, String lstr)67*d051e170SChris Fraire public LinkageMatchedEvent(Object source, String str, LinkageType linkageType, 68*d051e170SChris Fraire long start, long end, String lstr) { 69b5840353SAdam Hornáček this.source = source; 70b5840353SAdam Hornáček this.str = str; 71b5840353SAdam Hornáček this.linkageType = linkageType; 72b5840353SAdam Hornáček this.start = start; 73b5840353SAdam Hornáček this.end = end; 74b5840353SAdam Hornáček this.lstr = lstr; 75b5840353SAdam Hornáček } 76b5840353SAdam Hornáček 77b5840353SAdam Hornáček /** 78b5840353SAdam Hornáček * Gets the event source. 79b5840353SAdam Hornáček * @return the event source 80b5840353SAdam Hornáček */ getSource()81b5840353SAdam Hornáček public Object getSource() { 82b5840353SAdam Hornáček return source; 83b5840353SAdam Hornáček } 84b5840353SAdam Hornáček 85b5840353SAdam Hornáček /** 86b5840353SAdam Hornáček * Gets the text string (literal capture). 87b5840353SAdam Hornáček * @return the initial value 88b5840353SAdam Hornáček */ getStr()89b5840353SAdam Hornáček public String getStr() { 90b5840353SAdam Hornáček return str; 91b5840353SAdam Hornáček } 92b5840353SAdam Hornáček 93b5840353SAdam Hornáček /** 94b5840353SAdam Hornáček * Gets the text end position, likely equal to {@link #getStr()} but 95b5840353SAdam Hornáček * depending on {@link #getLinkageType()}. 96b5840353SAdam Hornáček * @return the initial value 97b5840353SAdam Hornáček */ getLinkStr()98b5840353SAdam Hornáček public String getLinkStr() { 99b5840353SAdam Hornáček return lstr; 100b5840353SAdam Hornáček } 101b5840353SAdam Hornáček 102b5840353SAdam Hornáček /** 103b5840353SAdam Hornáček * Gets the text linkage type. 104b5840353SAdam Hornáček * @return the initial value 105b5840353SAdam Hornáček */ getLinkageType()106b5840353SAdam Hornáček public LinkageType getLinkageType() { 107b5840353SAdam Hornáček return linkageType; 108b5840353SAdam Hornáček } 109b5840353SAdam Hornáček 110b5840353SAdam Hornáček /** 111b5840353SAdam Hornáček * Gets the text start position. 112b5840353SAdam Hornáček * @return the initial value 113b5840353SAdam Hornáček */ getStart()114*d051e170SChris Fraire public long getStart() { 115b5840353SAdam Hornáček return start; 116b5840353SAdam Hornáček } 117b5840353SAdam Hornáček 118b5840353SAdam Hornáček /** 119b5840353SAdam Hornáček * Gets the text end position. 120b5840353SAdam Hornáček * @return the initial value 121b5840353SAdam Hornáček */ getEnd()122*d051e170SChris Fraire public long getEnd() { 123b5840353SAdam Hornáček return end; 124b5840353SAdam Hornáček } 125b5840353SAdam Hornáček } 126