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