01: /*
02: * Copyright 2004-2006 the original author or authors.
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
15: */
16:
17: package org.compass.core;
18:
19: import java.io.Serializable;
20:
21: /**
22: * Wrapper that provides a lazily loaded hit from
23: * {@link CompassHitsOperations}.
24: *
25: * @author kimchy
26: */
27: public interface CompassHit extends Serializable {
28:
29: /**
30: * Returns the alias value of the hit.
31: *
32: * @return The alias.
33: * @throws CompassException
34: */
35: String getAlias() throws CompassException;
36:
37: /**
38: * Same as {@link #getAlias()}.
39: */
40: String alias() throws CompassException;
41:
42: /**
43: * Returns the object for this hit.
44: *
45: * @return The object data of the hit.
46: * @throws CompassException
47: * @see CompassHits#data(int)
48: */
49: Object getData() throws CompassException;
50:
51: /**
52: * Same as {@link #getData()} just shorter.
53: */
54: Object data() throws CompassException;
55:
56: /**
57: * Returns the {@link Resource} for this hit.
58: *
59: * @return The {@link Resource} of the hit.
60: * @throws CompassException
61: * @see CompassHits#resource(int)
62: */
63: Resource getResource() throws CompassException;
64:
65: /**
66: * Same as {@link #getResource()}.
67: */
68: Resource resource() throws CompassException;
69:
70: /**
71: * Returns the score for this hit.
72: *
73: * @return The score of the hit.
74: * @throws CompassException
75: * @see CompassHits#score(int)
76: */
77: float getScore() throws CompassException;
78:
79: /**
80: * Same as {@link #getScore()}.
81: */
82: float score() throws CompassException;
83:
84: /**
85: * Returns a cached highlighted text the maps to the hit.
86: * <p/>
87: * Highlighted text is automatically cached when using {@link CompassHighlighter}
88: * using {@link CompassHits#highlighter(int)}.
89: *
90: * @return The cached highlighted hits
91: * @throws CompassException
92: */
93: CompassHighlightedText getHighlightedText() throws CompassException;
94:
95: /**
96: * Same as {@link #getHighlightedText()}.
97: */
98: CompassHighlightedText highlightedText() throws CompassException;
99: }
|