|
|||||||||||||||||||
Source file | Conditionals | Statements | Methods | TOTAL | |||||||||||||||
IndexMatch.java | - | 56.2% | 50% | 54.5% |
|
1 | /* | |
2 | * Licensed to the Apache Software Foundation (ASF) under one or more | |
3 | * contributor license agreements. See the NOTICE file distributed with | |
4 | * this work for additional information regarding copyright ownership. | |
5 | * The ASF licenses this file to You under the Apache License, Version 2.0 | |
6 | * (the "License"); you may not use this file except in compliance with | |
7 | * the License. You may obtain a copy of the License at | |
8 | * | |
9 | * http://www.apache.org/licenses/LICENSE-2.0 | |
10 | * | |
11 | * Unless required by applicable law or agreed to in writing, software | |
12 | * distributed under the License is distributed on an "AS IS" BASIS, | |
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
14 | * See the License for the specific language governing permissions and | |
15 | * limitations under the License. | |
16 | * | |
17 | * $Id: IndexMatch.java 564424 2007-08-09 23:40:03Z natalia $ | |
18 | */ | |
19 | ||
20 | package org.apache.xindice.core.indexer; | |
21 | ||
22 | import org.apache.xindice.core.data.Key; | |
23 | ||
24 | /** | |
25 | * IndexMatch is used for representing match information. IndexMatches | |
26 | * are the basic unit of information between Indexers and the IndexManager | |
27 | * for performing queries and query optimization. | |
28 | * | |
29 | * @version $Revision: 564424 $, $Date: 2007-08-09 16:40:03 -0700 (Thu, 09 Aug 2007) $ | |
30 | */ | |
31 | public final class IndexMatch implements Comparable { | |
32 | ||
33 | private Key key; // The Document Key | |
34 | private int pos; // Offset into the stream | |
35 | private int len; // Length of substream | |
36 | private short elem; // Element ID (for wildcards) | |
37 | private short attr; // Attribute ID (if any) | |
38 | ||
39 | ||
40 | 0 | public IndexMatch() { |
41 | 0 | key = null; |
42 | 0 | pos = -1; |
43 | 0 | len = -1; |
44 | 0 | elem = -1; |
45 | 0 | attr = -1; |
46 | } | |
47 | ||
48 | 171 | public IndexMatch(Key key, int pos, int len, short elem, short attr) { |
49 | 171 | this.key = key; |
50 | 171 | this.pos = pos; |
51 | 171 | this.len = len; |
52 | 171 | this.elem = elem; |
53 | 171 | this.attr = attr; |
54 | } | |
55 | ||
56 | 85 | public IndexMatch(Key key, int pos, int len) { |
57 | 85 | this.key = key; |
58 | 85 | this.pos = pos; |
59 | 85 | this.len = len; |
60 | 85 | elem = -1; |
61 | 85 | attr = -1; |
62 | } | |
63 | ||
64 | 0 | public IndexMatch(Key key, IndexPattern pattern) { |
65 | 0 | this.key = key; |
66 | 0 | pos = -1; |
67 | 0 | len = -1; |
68 | 0 | elem = pattern.getElementID(); |
69 | 0 | attr = pattern.getAttributeID(); |
70 | } | |
71 | ||
72 | 8782 | public IndexMatch(Key key, short elem, short attr) { |
73 | 8782 | this.key = key; |
74 | 8782 | pos = -1; |
75 | 8782 | len = -1; |
76 | 8782 | this.elem = elem; |
77 | 8782 | this.attr = attr; |
78 | } | |
79 | ||
80 | /** | |
81 | * getKey returns the Document Key for the IndexMatch. | |
82 | * | |
83 | * @return The Key | |
84 | */ | |
85 | 248 | public final Key getKey() { |
86 | 248 | return key; |
87 | } | |
88 | ||
89 | /** | |
90 | * getPosition returns the Document position for the Match. | |
91 | * | |
92 | * @return The Document position | |
93 | */ | |
94 | 0 | public final int getPosition() { |
95 | 0 | return pos; |
96 | } | |
97 | ||
98 | /** | |
99 | * getLength returns the Node length for the Match. | |
100 | * | |
101 | * @return The Node length | |
102 | */ | |
103 | 0 | public final int getLength() { |
104 | 0 | return len; |
105 | } | |
106 | ||
107 | /** | |
108 | * getElement returns the Element symbol ID for the Match. | |
109 | * | |
110 | * @return The Element Symbol ID | |
111 | */ | |
112 | 8705 | public final short getElement() { |
113 | 8705 | return elem; |
114 | } | |
115 | ||
116 | /** | |
117 | * getAttribute returns the Attribute symbol ID for the Match. | |
118 | * | |
119 | * @return The Attribute Symbol ID | |
120 | */ | |
121 | 8705 | public final short getAttribute() { |
122 | 8705 | return attr; |
123 | } | |
124 | ||
125 | 0 | public int compareTo(Object obj) { |
126 | 0 | return key.compareTo(obj); |
127 | } | |
128 | ||
129 | 0 | public String toString() { |
130 | 0 | return key.toString(); |
131 | } | |
132 | } | |
133 |
|