private static void serializeMap ( final Map map , final ContentHandler handler ) throws SAXException { final AttributesImpl attributes = new AttributesImpl ( ) ; handler . startElement ( null , "dict" , "dict" , attributes ) ; if ( map . size ( ) > 0 ) { // // need to output with sorted keys to maintain // reproducability // final Object [ ] keys = map . keySet ( ) . toArray ( ) ; Arrays . sort ( keys ) ; for ( final Object key2 : keys ) { final String key = String . valueOf ( key2 ) ; handler . startElement ( null , "key" , "key" , attributes ) ; handler . characters ( key . toCharArray ( ) , 0 , key . length ( ) ) ; handler . endElement ( null , "key" , "key" ) ; serializeObject ( map . get ( key2 ) , handler ) ; } } handler . endElement ( null , "dict" , "dict" ) ; }
Serialize a map as a dict element .