private void processFile(String file) throws IOException {
  assert file != null;
  String fileContent=readFileToString(file,Charset.forName("UTF-8"));
  if (verify) {
    Jerry doc=Jerry.jerry(fileContent);
    if (file.endsWith("overview-summary.html")) {
      Jerry otherPackages=doc.find("div.contentContainer table.overviewSummary caption span:contains('Other Packages')");
      if (otherPackages.size() > 0)       throw new IllegalArgumentException("'Other Packages' section should not be present, " + "all packages should have corresponding documentation groups: " + file);
    }
 else     if (!isViewHtml(file)) {
      Jerry descBlock=doc.find("div.contentContainer div.description ul.blockList li.blockList div.block");
      if (descBlock.size() == 0)       throw new IllegalArgumentException("Class doesn't have description in file: " + file);
    }
  }
  GridJavadocCharArrayLexReader lexer=new GridJavadocCharArrayLexReader(fileContent.toCharArray());
  Collection<GridJavadocToken> toks=new ArrayList<>();
  StringBuilder tokBuf=new StringBuilder();
  int ch;
  while ((ch=lexer.read()) != GridJavadocCharArrayLexReader.EOF) {
    if (ch == '<') {
      if (tokBuf.length() > 0) {
        toks.add(new GridJavadocToken(GridJavadocTokenType.TOKEN_TEXT,tokBuf.toString()));
        tokBuf.setLength(0);
      }
      tokBuf.append('<');
      ch=lexer.read();
      if (ch == GridJavadocCharArrayLexReader.EOF)       throw new IOException("Unexpected EOF: " + file);
      if (ch == '!') {
        for (; ch != GridJavadocCharArrayLexReader.EOF && ch != '>'; ch=lexer.read())         tokBuf.append((char)ch);
        if (ch == GridJavadocCharArrayLexReader.EOF)         throw new IOException("Unexpected EOF: " + file);
        assert ch == '>';
        tokBuf.append('>');
        String val=tokBuf.toString();
        toks.add(new GridJavadocToken(val.startsWith("<!--") ? GridJavadocTokenType.TOKEN_COMM : GridJavadocTokenType.TOKEN_INSTR,val));
        tokBuf.setLength(0);
      }
 else {
        for (; ch != GridJavadocCharArrayLexReader.EOF && ch != '>'; ch=lexer.read())         tokBuf.append((char)ch);
        if (ch == GridJavadocCharArrayLexReader.EOF)         throw new IOException("Unexpected EOF: " + file);
        assert ch == '>';
        tokBuf.append('>');
        if (tokBuf.length() <= 2)         throw new IOException("Invalid HTML in [file=" + file + ", html="+ tokBuf+ ']');
        String val=tokBuf.toString();
        toks.add(new GridJavadocToken(val.startsWith("</") ? GridJavadocTokenType.TOKEN_CLOSE_TAG : GridJavadocTokenType.TOKEN_OPEN_TAG,val));
        tokBuf.setLength(0);
      }
    }
 else     tokBuf.append((char)ch);
  }
  if (tokBuf.length() > 0)   toks.add(new GridJavadocToken(GridJavadocTokenType.TOKEN_TEXT,tokBuf.toString()));
  for (  GridJavadocToken tok : toks) {
    String val=tok.value();
switch (tok.type()) {
case TOKEN_COMM:
{
        break;
      }
case TOKEN_OPEN_TAG:
{
      tok.update(fixColors(tok.value()));
      break;
    }
case TOKEN_CLOSE_TAG:
{
    if ("</head>".equalsIgnoreCase(val))     tok.update("<link rel='shortcut icon' href='https://ignite.apache.org/favicon.ico'/>\n" + "<link type='text/css' rel='stylesheet' href='" + SH_URL + "/styles/shCore.css'/>\n"+ "<link type='text/css' rel='stylesheet' href='"+ SH_URL+ "/styles/shThemeDefault.css'/>\n"+ "<script type='text/javascript' src='"+ SH_URL+ "/scripts/shCore.js'></script>\n"+ "<script type='text/javascript' src='"+ SH_URL+ "/scripts/shLegacy.js'></script>\n"+ "<script type='text/javascript' src='"+ SH_URL+ "/scripts/shBrushJava.js'></script>\n"+ "<script type='text/javascript' src='"+ SH_URL+ "/scripts/shBrushPlain.js'></script>\n"+ "<script type='text/javascript' src='"+ SH_URL+ "/scripts/shBrushJScript.js'></script>\n"+ "<script type='text/javascript' src='"+ SH_URL+ "/scripts/shBrushBash.js'></script>\n"+ "<script type='text/javascript' src='"+ SH_URL+ "/scripts/shBrushXml.js'></script>\n"+ "<script type='text/javascript' src='"+ SH_URL+ "/scripts/shBrushScala.js'></script>\n"+ "<script type='text/javascript' src='"+ SH_URL+ "/scripts/shBrushGroovy.js'></script>\n"+ "</head>\n");
 else     if ("</body>".equalsIgnoreCase(val))     tok.update("<!--FOOTER-->" + "<script type='text/javascript'>" + "SyntaxHighlighter.all();"+ "dp.SyntaxHighlighter.HighlightAll('code');"+ "</script>\n"+ "</body>\n");
    break;
  }
case TOKEN_INSTR:
{
  break;
}
case TOKEN_TEXT:
{
tok.update(fixColors(val));
break;
}
default :
assert false;
}
}
StringBuilder buf=new StringBuilder();
StringBuilder tmp=new StringBuilder();
boolean inPre=false;
for (GridJavadocToken tok : toks) {
String val=tok.value();
switch (tok.type()) {
case TOKEN_INSTR:
case TOKEN_TEXT:
case TOKEN_COMM:
{
tmp.append(val);
break;
}
case TOKEN_OPEN_TAG:
{
if (val.toLowerCase().startsWith("<pre name=")) {
inPre=true;
buf.append(fixBrackets(tmp.toString()));
tmp.setLength(0);
}
tmp.append(val);
break;
}
case TOKEN_CLOSE_TAG:
{
if (val.toLowerCase().startsWith("</pre") && inPre) {
inPre=false;
buf.append(tmp.toString());
tmp.setLength(0);
}
tmp.append(val);
break;
}
default :
assert false;
}
}
String s=buf.append(fixBrackets(tmp.toString())).toString();
s=fixExternalLinks(s);
s=fixDeprecated(s);
s=fixNullable(s);
s=fixTodo(s);
replaceFile(file,s);
}

private void processFile ( String file ) throws IOException { assert file != null ; String fileContent = readFileToString ( file , Charset . forName ( "UTF-8" ) ) ; if ( verify ) { Jerry doc = Jerry . jerry ( fileContent ) ; if ( file . endsWith ( "overview-summary.html" ) ) { Jerry otherPackages = doc . find ( "div.contentContainer table.overviewSummary caption span:contains('Other Packages')" ) ; if ( otherPackages . size ( ) > 0 ) throw new IllegalArgumentException ( "'Other Packages' section should not be present, " + "all packages should have corresponding documentation groups: " + file ) ; } else if ( ! isViewHtml ( file ) ) { Jerry descBlock = doc . find ( "div.contentContainer div.description ul.blockList li.blockList div.block" ) ; if ( descBlock . size ( ) == 0 ) throw new IllegalArgumentException ( "Class doesn't have description in file: " + file ) ; } } GridJavadocCharArrayLexReader lexer = new GridJavadocCharArrayLexReader ( fileContent . toCharArray ( ) ) ; Collection < GridJavadocToken > toks = new ArrayList < > ( ) ; StringBuilder tokBuf = new StringBuilder ( ) ; int ch ; while ( ( ch = lexer . read ( ) ) != GridJavadocCharArrayLexReader . EOF ) { if ( ch == '<' ) { if ( tokBuf . length ( ) > 0 ) { toks . add ( new GridJavadocToken ( GridJavadocTokenType . TOKEN_TEXT , tokBuf . toString ( ) ) ) ; tokBuf . setLength ( 0 ) ; } tokBuf . append ( '<' ) ; ch = lexer . read ( ) ; if ( ch == GridJavadocCharArrayLexReader . EOF ) throw new IOException ( "Unexpected EOF: " + file ) ; if ( ch == '!' ) { for ( ; ch != GridJavadocCharArrayLexReader . EOF && ch != '>' ; ch = lexer . read ( ) ) tokBuf . append ( ( char ) ch ) ; if ( ch == GridJavadocCharArrayLexReader . EOF ) throw new IOException ( "Unexpected EOF: " + file ) ; assert ch == '>' ; tokBuf . append ( '>' ) ; String val = tokBuf . toString ( ) ; toks . add ( new GridJavadocToken ( val . startsWith ( "<!--" ) ? GridJavadocTokenType . TOKEN_COMM : GridJavadocTokenType . TOKEN_INSTR , val ) ) ; tokBuf . setLength ( 0 ) ; } else { for ( ; ch != GridJavadocCharArrayLexReader . EOF && ch != '>' ; ch = lexer . read ( ) ) tokBuf . append ( ( char ) ch ) ; if ( ch == GridJavadocCharArrayLexReader . EOF ) throw new IOException ( "Unexpected EOF: " + file ) ; assert ch == '>' ; tokBuf . append ( '>' ) ; if ( tokBuf . length ( ) <= 2 ) throw new IOException ( "Invalid HTML in [file=" + file + ", html=" + tokBuf + ']' ) ; String val = tokBuf . toString ( ) ; toks . add ( new GridJavadocToken ( val . startsWith ( "</" ) ? GridJavadocTokenType . TOKEN_CLOSE_TAG : GridJavadocTokenType . TOKEN_OPEN_TAG , val ) ) ; tokBuf . setLength ( 0 ) ; } } else tokBuf . append ( ( char ) ch ) ; } if ( tokBuf . length ( ) > 0 ) toks . add ( new GridJavadocToken ( GridJavadocTokenType . TOKEN_TEXT , tokBuf . toString ( ) ) ) ; for ( GridJavadocToken tok : toks ) { String val = tok . value ( ) ; switch ( tok . type ( ) ) { case TOKEN_COMM : { break ; } case TOKEN_OPEN_TAG : { tok . update ( fixColors ( tok . value ( ) ) ) ; break ; } case TOKEN_CLOSE_TAG : { if ( "</head>" . equalsIgnoreCase ( val ) ) tok . update ( "<link rel='shortcut icon' href='https://ignite.apache.org/favicon.ico'/>\n" + "<link type='text/css' rel='stylesheet' href='" + SH_URL + "/styles/shCore.css'/>\n" + "<link type='text/css' rel='stylesheet' href='" + SH_URL + "/styles/shThemeDefault.css'/>\n" + "<script type='text/javascript' src='" + SH_URL + "/scripts/shCore.js'></script>\n" + "<script type='text/javascript' src='" + SH_URL + "/scripts/shLegacy.js'></script>\n" + "<script type='text/javascript' src='" + SH_URL + "/scripts/shBrushJava.js'></script>\n" + "<script type='text/javascript' src='" + SH_URL + "/scripts/shBrushPlain.js'></script>\n" + "<script type='text/javascript' src='" + SH_URL + "/scripts/shBrushJScript.js'></script>\n" + "<script type='text/javascript' src='" + SH_URL + "/scripts/shBrushBash.js'></script>\n" + "<script type='text/javascript' src='" + SH_URL + "/scripts/shBrushXml.js'></script>\n" + "<script type='text/javascript' src='" + SH_URL + "/scripts/shBrushScala.js'></script>\n" + "<script type='text/javascript' src='" + SH_URL + "/scripts/shBrushGroovy.js'></script>\n" + "</head>\n" ) ; else if ( "</body>" . equalsIgnoreCase ( val ) ) tok . update ( "<!--FOOTER-->" + "<script type='text/javascript'>" + "SyntaxHighlighter.all();" + "dp.SyntaxHighlighter.HighlightAll('code');" + "</script>\n" + "</body>\n" ) ; break ; } case TOKEN_INSTR : { break ; } case TOKEN_TEXT : { tok . update ( fixColors ( val ) ) ; break ; } default : assert false ; } } StringBuilder buf = new StringBuilder ( ) ; StringBuilder tmp = new StringBuilder ( ) ; boolean inPre = false ; for ( GridJavadocToken tok : toks ) { String val = tok . value ( ) ; switch ( tok . type ( ) ) { case TOKEN_INSTR : case TOKEN_TEXT : case TOKEN_COMM : { tmp . append ( val ) ; break ; } case TOKEN_OPEN_TAG : { if ( val . toLowerCase ( ) . startsWith ( "<pre name=" ) ) { inPre = true ; buf . append ( fixBrackets ( tmp . toString ( ) ) ) ; tmp . setLength ( 0 ) ; } tmp . append ( val ) ; break ; } case TOKEN_CLOSE_TAG : { if ( val . toLowerCase ( ) . startsWith ( "</pre" ) && inPre ) { inPre = false ; buf . append ( tmp . toString ( ) ) ; tmp . setLength ( 0 ) ; } tmp . append ( val ) ; break ; } default : assert false ; } } String s = buf . append ( fixBrackets ( tmp . toString ( ) ) ) . toString ( ) ; s = fixExternalLinks ( s ) ; s = fixDeprecated ( s ) ; s = fixNullable ( s ) ; s = fixTodo ( s ) ; replaceFile ( file , s ) ; }
processes file ( validating and cleaning up javadoc ' s html ) .
