Save a `Map` object to a mapfile string
Calling the toString() method on Map objects should return the mapfile representation of the object as a string. This is possible in Mapserver 6.4 now that mapserver/mapserver#4563 has been implemented.
Implementing it would involve an #ifdef check on the mapserver version and then wrapping the new msWriteMapToString() mapserver function as a synchronous javascript toString() function. It can be synchronous as no IO is performed on the mapserver side.
As the final (accepted) solution convertToString has been implemented so I don't think it would interfere with the toString method. Java bindings should be compiled along with mapserver core which would provide the methods to stay in sync.