@@ -283,7 +283,11 @@ public static void generateTypeJavadoc(
283
283
284
284
sb .append ('\n' )
285
285
.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' )
287
291
.append (indent ).append (" */\n " );
288
292
}
289
293
@@ -306,7 +310,11 @@ public static void generateOptionDecodeJavadoc(
306
310
}
307
311
308
312
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' )
310
318
.append (indent ).append (" *\n " )
311
319
.append (indent ).append (" * @return true if " ).append (optionToken .name ()).append (" set or false if not.\n " )
312
320
.append (indent ).append (" */\n " );
@@ -330,9 +338,13 @@ public static void generateOptionEncodeJavadoc(
330
338
return ;
331
339
}
332
340
333
- final String name = optionToken .name ();
334
341
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' )
336
348
.append (indent ).append (" *\n " )
337
349
.append (indent ).append (" * @param value true if " ).append (name ).append (" is set or false if not.\n " )
338
350
.append (indent ).append (" */\n " );
@@ -357,9 +369,17 @@ public static void generateFlyweightPropertyJavadoc(
357
369
358
370
sb .append ('\n' )
359
371
.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' )
361
377
.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 " )
363
383
.append (indent ).append (" */" );
364
384
}
365
385
@@ -382,10 +402,62 @@ public static void generateGroupEncodePropertyJavadoc(
382
402
383
403
sb .append ('\n' )
384
404
.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 " )
386
410
.append (indent ).append (" *\n " )
387
411
.append (indent ).append (" * @param count of times the group will be encoded.\n " )
388
412
.append (indent ).append (" * @return " ).append (typeName ).append (" : encoder for the group.\n " )
389
413
.append (indent ).append (" */" );
390
414
}
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
+ }
391
463
}
0 commit comments