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*68076d3cSVladimir Kotal * Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved. 225d9f3aa0SAdam Hornáček * Copyright (c) 2011, Jens Elkner. 23b5840353SAdam Hornáček */ 249805b761SAdam Hornáček package org.opengrok.indexer.web; 25b5840353SAdam Hornáček 26b5840353SAdam Hornáček /** 27b5840353SAdam Hornáček * A simple container for search suggestions. 28b5840353SAdam Hornáček * @author Jens Elkner 29b5840353SAdam Hornáček * @version $Revision$ 30b5840353SAdam Hornáček */ 31b5840353SAdam Hornáček public class Suggestion { 32b5840353SAdam Hornáček 33ff44f24aSAdam Hornáček /** index name. */ 34*68076d3cSVladimir Kotal private final String name; 35ff44f24aSAdam Hornáček /** freetext search suggestions. */ 36*68076d3cSVladimir Kotal private String[] freetext; 37ff44f24aSAdam Hornáček /** references search suggestions. */ 38*68076d3cSVladimir Kotal private String[] refs; 39ff44f24aSAdam Hornáček /** definitions search suggestions. */ 40*68076d3cSVladimir Kotal private String[] defs; 41b5840353SAdam Hornáček 42b5840353SAdam Hornáček /** 43b5840353SAdam Hornáček * Create a new suggestion. 44b5840353SAdam Hornáček * @param name index name. 45b5840353SAdam Hornáček */ Suggestion(String name)46b5840353SAdam Hornáček public Suggestion(String name) { 47b5840353SAdam Hornáček this.name = name; 48b5840353SAdam Hornáček } 49*68076d3cSVladimir Kotal getName()50*68076d3cSVladimir Kotal public String getName() { 51*68076d3cSVladimir Kotal return name; 52*68076d3cSVladimir Kotal } 53*68076d3cSVladimir Kotal getFreetext()54*68076d3cSVladimir Kotal public String[] getFreetext() { 55*68076d3cSVladimir Kotal return freetext; 56*68076d3cSVladimir Kotal } 57*68076d3cSVladimir Kotal getRefs()58*68076d3cSVladimir Kotal public String[] getRefs() { 59*68076d3cSVladimir Kotal return refs; 60*68076d3cSVladimir Kotal } 61*68076d3cSVladimir Kotal getDefs()62*68076d3cSVladimir Kotal public String[] getDefs() { 63*68076d3cSVladimir Kotal return defs; 64*68076d3cSVladimir Kotal } 65*68076d3cSVladimir Kotal setFreetext(String[] freetext)66*68076d3cSVladimir Kotal public void setFreetext(String[] freetext) { 67*68076d3cSVladimir Kotal this.freetext = freetext; 68*68076d3cSVladimir Kotal } 69*68076d3cSVladimir Kotal setRefs(String[] refs)70*68076d3cSVladimir Kotal public void setRefs(String[] refs) { 71*68076d3cSVladimir Kotal this.refs = refs; 72*68076d3cSVladimir Kotal } 73*68076d3cSVladimir Kotal setDefs(String[] defs)74*68076d3cSVladimir Kotal public void setDefs(String[] defs) { 75*68076d3cSVladimir Kotal this.defs = defs; 76*68076d3cSVladimir Kotal } 77*68076d3cSVladimir Kotal 78*68076d3cSVladimir Kotal /** 79*68076d3cSVladimir Kotal * @return true if at least one of the properties has some content, false otherwise 80*68076d3cSVladimir Kotal */ isUsable()81*68076d3cSVladimir Kotal public boolean isUsable() { 82*68076d3cSVladimir Kotal return (freetext != null && freetext.length > 0) 83*68076d3cSVladimir Kotal || (defs != null && defs.length > 0) 84*68076d3cSVladimir Kotal || (refs != null && refs.length > 0); 85*68076d3cSVladimir Kotal } 86b5840353SAdam Hornáček } 87