blob: eb9640a38b86fc3d1c4015fae881e224df15cf65 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.documentapi.messagebus.protocol;
import java.util.Map;
import java.util.TreeMap;
public class MapVisitorMessage extends VisitorMessage {
private final Map<String, String> data = new TreeMap<String, String>();
MapVisitorMessage() {
// must be deserialized into
}
public MapVisitorMessage(MapVisitorMessage cmd) {
data.putAll(cmd.data);
}
public Map<String, String> getData() {
return data;
}
@Override
public DocumentReply createReply() {
return new VisitorReply(DocumentProtocol.REPLY_MAPVISITOR);
}
@Override
public int getType() {
return DocumentProtocol.MESSAGE_MAPVISITOR;
}
@Override
public int getApproxSize() {
int length = super.getApproxSize() + 4;
for (Map.Entry<String, String> pairs : data.entrySet()) {
length += 8;
length += (pairs.getKey()).length() + pairs.getValue().length();
}
return length;
}
@Override
public String toString() {
return "MapVisitorMessage(" + data.toString() + ")";
}
}
|