public synchronized static void toXML ( AFPChain afpChain , StringWriter swriter , Atom [ ] ca1 , Atom [ ] ca2 ) throws IOException { PrintWriter writer = new PrintWriter ( swriter ) ; PrettyXMLWriter xml = new PrettyXMLWriter ( writer ) ; xml . openTag ( "AFPChain" ) ; printXMLHeader ( xml , afpChain ) ; // that is the initial alignment... // we don't serialize that at the present. //int[] blockResSize = afpChain.getBlockResSize(); //int[][][] blockResList = afpChain.getBlockResList(); // get the alignment blocks int blockNum = afpChain . getBlockNum ( ) ; //int[] optLen = afpChain.getOptLen(); //int[] blockSize = afpChain.getBlockSize(); for ( int bk = 0 ; bk < blockNum ; bk ++ ) { xml . openTag ( "block" ) ; printXMLBlockHeader ( xml , afpChain , bk ) ; if ( ca1 == null || ca2 == null ) { try { printXMLEQRKnownPositions ( xml , afpChain , bk ) ; } catch ( StructureException ex ) { throw new IOException ( ex . getMessage ( ) ) ; } } else printXMLEQRInferPositions ( xml , afpChain , bk , ca1 , ca2 ) ; printXMLMatrixShift ( xml , afpChain , bk ) ; xml . closeTag ( "block" ) ; } xml . closeTag ( "AFPChain" ) ; writer . close ( ) ; }
Write the XML representation to a StringWriter