private static void serialize ( Map < String , AbstractDataMarshaller < ? > > marshallerMap , DataOutputStream dOut , DataNode primaryNode , boolean ignoreMissingMarshallers , ProgressListener progressListener ) throws IOException { //a map containing all serialized objects. This is used //to make sure that we store each deSerializedObject only once. final Map < SerializedObject , SerializedObject > serializedObjects = new HashMap <> ( ) ; final Deque < SerializationFrame > stack = new LinkedList <> ( ) ; final DataNodeSerializationFrame primaryDataNodeFrame = new DataNodeSerializationFrame ( null , primaryNode ) ; progressListener . onTotalSteps ( primaryDataNodeFrame . entries . size ( ) ) ; stack . add ( primaryDataNodeFrame ) ; final SerializedObject testSerializedObject = new SerializedObject ( ) ; while ( ! stack . isEmpty ( ) ) { final SerializationFrame frame = stack . peek ( ) ; //writes the header for that frame (if needed) frame . writeHeader ( dOut ) ; if ( frame . hasNext ( ) ) { while ( frame . hasNext ( ) ) { if ( frame . next ( stack , dOut , marshallerMap , serializedObjects , testSerializedObject , ignoreMissingMarshallers ) ) { if ( frame == primaryDataNodeFrame ) { progressListener . onStep ( ) ; } break ; } if ( frame == primaryDataNodeFrame ) { progressListener . onStep ( ) ; } } } else { stack . pop ( ) ; //remember serialized deSerializedObject's addresses if ( frame instanceof DataNodeSerializationFrame ) { DataNodeSerializationFrame dataNodeFrame = ( DataNodeSerializationFrame ) frame ; SerializedObject newSerializedObject = new SerializedObject ( ) ; newSerializedObject . object = frame . object ; newSerializedObject . positionInStream = dataNodeFrame . positionInStream ; serializedObjects . put ( newSerializedObject , newSerializedObject ) ; } } } }
actually serializes the data