01: package org.apache.lucene.search;
02:
03: /**
04: * Licensed to the Apache Software Foundation (ASF) under one or more
05: * contributor license agreements. See the NOTICE file distributed with
06: * this work for additional information regarding copyright ownership.
07: * The ASF licenses this file to You under the Apache License, Version 2.0
08: * (the "License"); you may not use this file except in compliance with
09: * the License. You may obtain a copy of the License at
10: *
11: * http://www.apache.org/licenses/LICENSE-2.0
12: *
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.
18: */
19:
20: /** Expert: Describes the score computation for document and query, andcan distinguish a match independent of a positive value. */
21: public class ComplexExplanation extends Explanation {
22: private Boolean match;
23:
24: public ComplexExplanation() {
25: super ();
26: }
27:
28: public ComplexExplanation(boolean match, float value,
29: String description) {
30: // NOTE: use of "boolean" instead of "Boolean" in params is concious
31: // choice to encourage clients to be specific.
32: super (value, description);
33: this .match = Boolean.valueOf(match);
34: }
35:
36: /**
37: * The match status of this explanation node.
38: * @return May be null if match status is unknown
39: */
40: public Boolean getMatch() {
41: return match;
42: }
43:
44: /**
45: * Sets the match status assigned to this explanation node.
46: * @param match May be null if match status is unknown
47: */
48: public void setMatch(Boolean match) {
49: this .match = match;
50: }
51:
52: /**
53: * Indicates wether or not this Explanation models a good match.
54: *
55: * <p>
56: * If the match statis is explicitly set (ie: not null) this method
57: * uses it; otherwise it defers to the superclass.
58: * </p>
59: * @see #getMatch
60: */
61: public boolean isMatch() {
62: Boolean m = getMatch();
63: return (null != m ? m.booleanValue() : super .isMatch());
64: }
65:
66: protected String getSummary() {
67: if (null == getMatch())
68: return super .getSummary();
69:
70: return getValue() + " = "
71: + (isMatch() ? "(MATCH) " : "(NON-MATCH) ")
72: + getDescription();
73: }
74:
75: }
|