1 package org.apache.lucene.search;
4 * Licensed to the Apache Software Foundation (ASF) under one or more
5 * contributor license agreements. See the NOTICE file distributed with
6 * this work for additional information regarding copyright ownership.
7 * The ASF licenses this file to You under the Apache License, Version 2.0
8 * (the "License"); you may not use this file except in compliance with
9 * the License. You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
20 /** Expert: Describes the score computation for document and query, and
21 * can distinguish a match independent of a positive value. */
22 public class ComplexExplanation extends Explanation {
23 private Boolean match;
25 public ComplexExplanation() {
29 public ComplexExplanation(boolean match, float value, String description) {
30 // NOTE: use of "boolean" instead of "Boolean" in params is conscious
31 // choice to encourage clients to be specific.
32 super(value, description);
33 this.match = Boolean.valueOf(match);
37 * The match status of this explanation node.
38 * @return May be null if match status is unknown
40 public Boolean getMatch() { return match; }
42 * Sets the match status assigned to this explanation node.
43 * @param match May be null if match status is unknown
45 public void setMatch(Boolean match) { this.match = match; }
47 * Indicates whether or not this Explanation models a good match.
50 * If the match status is explicitly set (i.e.: not null) this method
51 * uses it; otherwise it defers to the superclass.
56 public boolean isMatch() {
57 Boolean m = getMatch();
58 return (null != m ? m.booleanValue() : super.isMatch());
62 protected String getSummary() {
63 if (null == getMatch())
64 return super.getSummary();
66 return getValue() + " = "
67 + (isMatch() ? "(MATCH) " : "(NON-MATCH) ")