@@ -283,7 +283,11 @@ public static void generateTypeJavadoc(
283283
284284 sb .append ('\n' )
285285 .append (indent ).append ("/**\n " )
286- .append (indent ).append (" * " ).append (description ).append ('\n' )
286+ .append (indent ).append (" * " );
287+
288+ escapeJavadoc (sb , description );
289+
290+ sb .append ('\n' )
287291 .append (indent ).append (" */\n " );
288292 }
289293
@@ -306,7 +310,11 @@ public static void generateOptionDecodeJavadoc(
306310 }
307311
308312 out .append (indent ).append ("/**\n " )
309- .append (indent ).append (" * " ).append (description ).append ('\n' )
313+ .append (indent ).append (" * " );
314+
315+ escapeJavadoc (out , description );
316+
317+ out .append ('\n' )
310318 .append (indent ).append (" *\n " )
311319 .append (indent ).append (" * @return true if " ).append (optionToken .name ()).append (" set or false if not.\n " )
312320 .append (indent ).append (" */\n " );
@@ -330,9 +338,13 @@ public static void generateOptionEncodeJavadoc(
330338 return ;
331339 }
332340
333- final String name = optionToken .name ();
334341 out .append (indent ).append ("/**\n " )
335- .append (indent ).append (" * " ).append (description ).append ('\n' )
342+ .append (indent ).append (" * " );
343+
344+ escapeJavadoc (out , description );
345+
346+ final String name = optionToken .name ();
347+ out .append ('\n' )
336348 .append (indent ).append (" *\n " )
337349 .append (indent ).append (" * @param value true if " ).append (name ).append (" is set or false if not.\n " )
338350 .append (indent ).append (" */\n " );
@@ -357,9 +369,17 @@ public static void generateFlyweightPropertyJavadoc(
357369
358370 sb .append ('\n' )
359371 .append (indent ).append ("/**\n " )
360- .append (indent ).append (" * " ).append (description ).append ('\n' )
372+ .append (indent ).append (" * " );
373+
374+ escapeJavadoc (sb , description );
375+
376+ sb .append ('\n' )
361377 .append (indent ).append (" *\n " )
362- .append (indent ).append (" * @return " ).append (typeName ).append (" : " ).append (description ).append ("\n " )
378+ .append (indent ).append (" * @return " ).append (typeName ).append (" : " );
379+
380+ escapeJavadoc (sb , description );
381+
382+ sb .append ("\n " )
363383 .append (indent ).append (" */" );
364384 }
365385
@@ -382,10 +402,62 @@ public static void generateGroupEncodePropertyJavadoc(
382402
383403 sb .append ('\n' )
384404 .append (indent ).append ("/**\n " )
385- .append (indent ).append (" * " ).append (description ).append ("\n " )
405+ .append (indent ).append (" * " );
406+
407+ escapeJavadoc (sb , description );
408+
409+ sb .append ("\n " )
386410 .append (indent ).append (" *\n " )
387411 .append (indent ).append (" * @param count of times the group will be encoded.\n " )
388412 .append (indent ).append (" * @return " ).append (typeName ).append (" : encoder for the group.\n " )
389413 .append (indent ).append (" */" );
390414 }
415+
416+ private static void escapeJavadoc (final Appendable out , final String doc ) throws IOException
417+ {
418+ for (int i = 0 , length = doc .length (); i < length ; i ++)
419+ {
420+ final char c = doc .charAt (i );
421+ switch (c )
422+ {
423+ case '<' :
424+ out .append ("<" );
425+ break ;
426+
427+ case '>' :
428+ out .append (">" );
429+ break ;
430+
431+ default :
432+ out .append (c );
433+ break ;
434+ }
435+ }
436+ }
437+
438+ private static void escapeJavadoc (final StringBuilder sb , final String doc )
439+ {
440+ for (int i = 0 , length = doc .length (); i < length ; i ++)
441+ {
442+ final char c = doc .charAt (i );
443+ switch (c )
444+ {
445+ case '<' :
446+ sb .append ("<" );
447+ break ;
448+
449+ case '>' :
450+ sb .append (">" );
451+ break ;
452+
453+ case '&' :
454+ sb .append ("&" );
455+ break ;
456+
457+ default :
458+ sb .append (c );
459+ break ;
460+ }
461+ }
462+ }
391463}
0 commit comments