public static void writeState(Object state, DataOutputStream out) throws IOException { ((State) state).write(out); }