66import java .nio .charset .StandardCharsets ;
77import java .text .SimpleDateFormat ;
88import java .util .*;
9- import java .util .stream .Collectors ;
109
1110/**
1211 * Graph Intelligence Advisor — proactively analyzes a graph's structural
@@ -573,7 +572,7 @@ public void exportHtml(File outputFile) throws IOException {
573572 html .append ("<div class=\" header\" >\n " );
574573 html .append (" <h1>🧠 Graph Intelligence Advisor</h1>\n " );
575574 html .append (" <p class=\" subtitle\" >Proactive analysis recommendations based on structural fingerprinting</p>\n " );
576- html .append (" <p class=\" meta\" >Generated: " ).append (escapeHtml (timestamp )).append (" • " );
575+ html .append (" <p class=\" meta\" >Generated: " ).append (ExportUtils . escapeHtml (timestamp )).append (" • " );
577576 html .append (fingerprint .nodeCount ).append (" nodes • " );
578577 html .append (fingerprint .edgeCount ).append (" edges</p>\n " );
579578 html .append ("</div>\n \n " );
@@ -621,7 +620,7 @@ public void exportHtml(File outputFile) throws IOException {
621620 double pct = 100.0 * entry .getValue () / maxCount ;
622621 String color = barColors [ci % barColors .length ];
623622 html .append (" <div class=\" bar-row\" >\n " );
624- html .append (" <span class=\" bar-label\" >" ).append (escapeHtml (entry .getKey ())).append ("</span>\n " );
623+ html .append (" <span class=\" bar-label\" >" ).append (ExportUtils . escapeHtml (entry .getKey ())).append ("</span>\n " );
625624 html .append (" <div class=\" bar-track\" ><div class=\" bar-fill\" style=\" width:" )
626625 .append (String .format ("%.1f" , pct )).append ("%;background:" ).append (color ).append ("\" ></div></div>\n " );
627626 html .append (" <span class=\" bar-count\" >" ).append (entry .getValue ()).append ("</span>\n " );
@@ -644,18 +643,18 @@ public void exportHtml(File outputFile) throws IOException {
644643 html .append (" <div class=\" rec-card\" >\n " );
645644 html .append (" <div class=\" rec-header\" >\n " );
646645 html .append (" <span class=\" rec-rank\" >#" ).append (rank ++).append ("</span>\n " );
647- html .append (" <span class=\" rec-name\" >" ).append (escapeHtml (r .getAnalysisName ())).append ("</span>\n " );
648- html .append (" <span class=\" rec-category\" >" ).append (escapeHtml (r .getCategory ())).append ("</span>\n " );
646+ html .append (" <span class=\" rec-name\" >" ).append (ExportUtils . escapeHtml (r .getAnalysisName ())).append ("</span>\n " );
647+ html .append (" <span class=\" rec-category\" >" ).append (ExportUtils . escapeHtml (r .getCategory ())).append ("</span>\n " );
649648 html .append (" <span class=\" rec-conf " ).append (confClass ).append ("\" >" )
650649 .append (String .format ("%.0f%%" , r .getConfidence () * 100 )).append ("</span>\n " );
651650 html .append (" <span class=\" rec-diff diff-" ).append (r .getDifficulty ()).append ("\" >" )
652- .append (escapeHtml (r .getDifficulty ())).append ("</span>\n " );
651+ .append (ExportUtils . escapeHtml (r .getDifficulty ())).append ("</span>\n " );
653652 html .append (" </div>\n " );
654653 html .append (" <div class=\" rec-body\" >\n " );
655654 html .append (" <p class=\" rec-reason\" ><strong>Why:</strong> " )
656- .append (escapeHtml (r .getReasoning ())).append ("</p>\n " );
655+ .append (ExportUtils . escapeHtml (r .getReasoning ())).append ("</p>\n " );
657656 html .append (" <p class=\" rec-insight\" ><strong>Expected insight:</strong> " )
658- .append (escapeHtml (r .getExpectedInsight ())).append ("</p>\n " );
657+ .append (ExportUtils . escapeHtml (r .getExpectedInsight ())).append ("</p>\n " );
659658 html .append (" </div>\n " );
660659 html .append (" </div>\n " );
661660 }
@@ -674,17 +673,11 @@ public void exportHtml(File outputFile) throws IOException {
674673
675674 private void appendMetricCard (StringBuilder html , String label , String value , String level ) {
676675 html .append (" <div class=\" metric-card " ).append (level ).append ("\" >\n " );
677- html .append (" <div class=\" metric-value\" >" ).append (escapeHtml (value )).append ("</div>\n " );
678- html .append (" <div class=\" metric-label\" >" ).append (escapeHtml (label )).append ("</div>\n " );
676+ html .append (" <div class=\" metric-value\" >" ).append (ExportUtils . escapeHtml (value )).append ("</div>\n " );
677+ html .append (" <div class=\" metric-label\" >" ).append (ExportUtils . escapeHtml (label )).append ("</div>\n " );
679678 html .append (" </div>\n " );
680679 }
681680
682- private static String escapeHtml (String s ) {
683- if (s == null ) return "" ;
684- return s .replace ("&" , "&" ).replace ("<" , "<" )
685- .replace (">" , ">" ).replace ("\" " , """ );
686- }
687-
688681 private String getCSS () {
689682 return "* { margin: 0; padding: 0; box-sizing: border-box; }\n "
690683 + "body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;\n "
0 commit comments