package com.peterhi.whiteboard;
import java.io.IOException;
import java.util.Hashtable;
import java.util.Map;
import com.peterhi.Callback;
import com.peterhi.Functions;
import com.peterhi.Protocol;
import com.peterhi.ProtocolInputStream;
import com.peterhi.ProtocolMap;
import com.peterhi.ProtocolOutputStream;
public final class MWhiteboardImpl implements MWhiteboard {
private String name;
private final Map<String, Object> metaInfos;
public MWhiteboardImpl() {
metaInfos = new Hashtable<String, Object>();
}
public MWhiteboardImpl(String name) {
this();
setName(name);
}
@Override
public String getName() {
return name;
}
@Override
public void setName(String value) {
if (value == null || value.isEmpty()) {
throw new IllegalArgumentException();
}
this.name = value;
}
@Override
public Map<String, Object> metaInfos() {
return metaInfos;
}
@Override
public Class<? extends Protocol> getType() {
return MWhiteboard.class;
}
@Override
public void buildProtocolMap(final ProtocolMap map) {
Functions.iterate(metaInfos, new Callback() {
@Override
public void callback(Object state) {
if (state instanceof Protocol) {
map.add((Protocol )state);
}
}
});
}
@Override
public void parseProtocolMap(ProtocolMap map) {
// TODO Auto-generated method stub
}
@Override
public int writeContents(ProtocolOutputStream output, ProtocolMap map)
throws IOException {
// TODO Auto-generated method stub
return 0;
}
@Override
public int readContents(ProtocolInputStream input, ProtocolMap map)
throws IOException {
// TODO Auto-generated method stub
return 0;
}
}