0
をシリアライズ私はこのオブジェクトで何をする必要があるか知っています。外側の地図をシリアル化するProtostuffは、どのように私はProtostuffを使用した例を、以下のようなオブジェクトをシリアル化することができます地図のようなオブジェクト<文字列、地図<文字列、文字列>>
をシリアライズ私はこのオブジェクトで何をする必要があるか知っています。外側の地図をシリアル化するProtostuffは、どのように私はProtostuffを使用した例を、以下のようなオブジェクトをシリアル化することができます地図のようなオブジェクト<文字列、地図<文字列、文字列>>
クラス:インナー地図をシリアル化する
public class OuterMapSchema extends MapSchema<String, Map<String, String>> {
InnerMapSchema INNER_MAP_SCHEMA = new InnerMapSchema();
public OuterMapSchema() {
super(MessageFactories.HashMap);
}
@Override
protected String readKeyFrom(Input input, MapWrapper<String, Map<String, String>> wrapper) throws IOException {
return input.readString();
}
@Override
protected void putValueFrom(Input input, MapWrapper<String, Map<String, String>> wrapper, String key) throws IOException {
wrapper.put(key, input.mergeObject(null, INNER_MAP_SCHEMA));
}
@Override
protected void writeKeyTo(Output output, int fieldNumber, String value, boolean repeated) throws IOException {
output.writeString(fieldNumber, value, repeated);
}
@Override
protected void writeValueTo(Output output, int fieldNumber, Map<String, String> value, boolean repeated) throws IOException {
output.writeObject(fieldNumber, value, INNER_MAP_SCHEMA, repeated);
}
@Override
protected void transferKey(Pipe pipe, Input input, Output output, int number, boolean repeated) throws IOException {
}
@Override
protected void transferValue(Pipe pipe, Input input, Output output, int number, boolean repeated) throws IOException {
}
}
クラス:
public class InnerMapSchema extends MapSchema<String, String> {
public InnerMapSchema() {
super(MessageFactories.HashMap);
}
@Override
protected String readKeyFrom(Input input, MapWrapper<String, String> wrapper) throws IOException {
return input.readString();
}
@Override
protected void putValueFrom(Input input, MapWrapper<String, String> wrapper, String key) throws IOException {
wrapper.put(key, input.readString());
}
@Override
protected void writeKeyTo(Output output, int fieldNumber, String value, boolean repeated) throws IOException {
output.writeString(fieldNumber, value, repeated);
}
@Override
protected void writeValueTo(Output output, int fieldNumber, String value, boolean repeated) throws IOException {
output.writeString(fieldNumber, value, repeated);
}
@Override
protected void transferKey(Pipe pipe, Input input, Output output, int number, boolean repeated) throws IOException {
}
@Override
protected void transferValue(Pipe pipe, Input input, Output output, int number, boolean repeated) throws IOException {
}
}