1
2
3
4
5
6 package org.galagosearch.core.index;
7
8 import java.io.IOException;
9 import java.io.OutputStream;
10 import org.galagosearch.tupleflow.Utility;
11
12 /***
13 *
14 * @author trevor
15 */
16 public class GenericElement implements IndexElement {
17 byte[] key;
18 byte[] data;
19
20 public GenericElement(byte[] key, byte[] data) {
21 this.key = key;
22 this.data = data;
23 }
24
25 public GenericElement(String key, byte[] data) {
26 this.key = Utility.makeBytes(key);
27 this.data = data;
28 }
29
30 public GenericElement(String key, String value) {
31 this.key = Utility.makeBytes(key);
32 this.data = Utility.makeBytes(value);
33 }
34
35 public byte[] key() {
36 return key;
37 }
38
39 public long dataLength() {
40 return data.length;
41 }
42
43 public void write(OutputStream stream) throws IOException {
44 stream.write(data);
45 }
46 }