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.needle.coherence;
18:
19: import java.io.DataInput;
20: import java.io.DataOutput;
21: import java.io.IOException;
22:
23: import com.tangosol.io.ExternalizableLite;
24:
25: /**
26: * @author kimchy
27: */
28: public class FileHeaderKey implements FileKey, ExternalizableLite {
29:
30: private String indexName;
31:
32: private String fileName;
33:
34: // just here for serialization
35: public FileHeaderKey() {
36: }
37:
38: public FileHeaderKey(String indexName, String fileName) {
39: this .indexName = indexName;
40: this .fileName = fileName;
41: }
42:
43: public String getIndexName() {
44: return this .indexName;
45: }
46:
47: public String getFileName() {
48: return this .fileName;
49: }
50:
51: public byte getType() {
52: return FILE_HEADER;
53: }
54:
55: public boolean equals(Object o) {
56: if (this == o)
57: return true;
58: if (((FileKey) o).getType() != getType())
59: return false;
60:
61: FileHeaderKey that = (FileHeaderKey) o;
62:
63: if (!fileName.equals(that.fileName))
64: return false;
65: if (!indexName.equals(that.indexName))
66: return false;
67:
68: return true;
69: }
70:
71: public int hashCode() {
72: int result = getType();
73: result = 31 * result + indexName.hashCode();
74: result = 31 * result + fileName.hashCode();
75: return result;
76: }
77:
78: public void readExternal(DataInput in) throws IOException {
79: indexName = in.readUTF();
80: fileName = in.readUTF();
81: }
82:
83: public void writeExternal(DataOutput out) throws IOException {
84: out.writeUTF(indexName);
85: out.writeUTF(fileName);
86: }
87:
88: public String toString() {
89: StringBuilder sb = new StringBuilder();
90: sb.append("fileHeaderKey: indexName[").append(indexName)
91: .append("]");
92: sb.append(" fileName[").append(fileName).append("]");
93: return sb.toString();
94: }
95: }
|