22 |
|
|
23 |
public class Java2xhtml |
public class Java2xhtml |
24 |
{ |
{ |
25 |
|
//--- define CSS classes for individual output elements |
26 |
|
|
27 |
|
private static final String sourceCodeStyle = "source"; |
28 |
|
private static final String lineNumberStyle = "line-number even"; |
29 |
|
private static final String modulusLineNumberStyle = "line-number odd"; |
30 |
|
|
31 |
|
private static final String keywordStyle = "keyword"; |
32 |
|
private static final String methodStyle = "method member"; |
33 |
|
private static final String variableStyle = "variable member"; |
34 |
|
private static final String singleLineCommentStyle = "line comment"; |
35 |
|
private static final String traditionalCommentStyle = "c comment"; |
36 |
|
private static final String javadocCommentStyle = "javadoc comment"; |
37 |
|
private static final String javadocTagStyle = "javadoc tag"; |
38 |
|
private static final String importNameStyle = "import header type"; |
39 |
|
private static final String packageNameStyle = "package header type"; |
40 |
|
private static final String primitiveTypeStyle = "primitive type"; |
41 |
|
private static final String nonPrimitiveTypeStyle = "non-primitive type"; |
42 |
|
private static final String constructorStyle = "constructor member"; |
43 |
|
private static final String constantStyle = "constant member"; |
44 |
|
private static final String doubleQuoteStyle = "double quote"; |
45 |
|
private static final String singleQuoteStyle = "single quote"; |
46 |
|
private static final String numericalLiteralStyle = "numerical literal"; |
47 |
|
private static final String primitiveLiteralStyle = "primitive literal"; |
48 |
|
|
49 |
|
private static final String iconStyle = "icon"; |
50 |
|
|
51 |
|
|
52 |
|
|
53 |
// parse the command line arguments |
// parse the command line arguments |
54 |
// give a decent responce for bad input |
// give a decent responce for bad input |
55 |
// call the HTMLifier on good input |
// call the HTMLifier on good input |
464 |
{ |
{ |
465 |
bufferOut.append(" <style type=\"text/css\">\r\n"); |
bufferOut.append(" <style type=\"text/css\">\r\n"); |
466 |
bufferOut.append(" <!-- /* <![CDATA[ */\r\n"); |
bufferOut.append(" <!-- /* <![CDATA[ */\r\n"); |
467 |
bufferOut.append(" .sourceCodeStyle\r\n"); |
bufferOut.append(" ." + sourceCodeStyle + "\r\n"); |
468 |
bufferOut.append(" {\r\n"); |
bufferOut.append(" {\r\n"); |
469 |
bufferOut.append(" color: #000000;\r\n"); |
bufferOut.append(" color: #000000;\r\n"); |
470 |
bufferOut.append(" background-color: #FFFFFF;\r\n"); |
bufferOut.append(" background-color: #FFFFFF;\r\n"); |
473 |
bufferOut.append(" font-weight: bold;\r\n"); |
bufferOut.append(" font-weight: bold;\r\n"); |
474 |
} |
} |
475 |
bufferOut.append(" }\r\n"); |
bufferOut.append(" }\r\n"); |
476 |
bufferOut.append(" .lineNumberStyle\r\n"); |
bufferOut.append(" ." + lineNumberStyle + "\r\n"); |
477 |
bufferOut.append(" {\r\n"); |
bufferOut.append(" {\r\n"); |
478 |
bufferOut.append(" font-weight: normal;\r\n"); |
bufferOut.append(" font-weight: normal;\r\n"); |
479 |
bufferOut.append(" color: #000000;\r\n"); |
bufferOut.append(" color: #000000;\r\n"); |
481 |
bufferOut.append(" }\r\n"); |
bufferOut.append(" }\r\n"); |
482 |
if (lineModulus > 0) |
if (lineModulus > 0) |
483 |
{ |
{ |
484 |
bufferOut.append(" .modulusLineNumberStyle\r\n"); |
bufferOut.append(" ." + modulusLineNumberStyle + "\r\n"); |
485 |
bufferOut.append(" {\r\n"); |
bufferOut.append(" {\r\n"); |
486 |
bufferOut.append(" font-weight: bold;\r\n"); |
bufferOut.append(" font-weight: bold;\r\n"); |
487 |
bufferOut.append(" color: #000000;\r\n"); |
bufferOut.append(" color: #000000;\r\n"); |
513 |
bufferOut.append(" }\r\n"); |
bufferOut.append(" }\r\n"); |
514 |
} |
} |
515 |
} |
} |
516 |
bufferOut.append(" .keywordStyle\r\n"); |
bufferOut.append(" ." + keywordStyle + "\r\n"); |
517 |
bufferOut.append(" {\r\n"); |
bufferOut.append(" {\r\n"); |
518 |
bufferOut.append(" color: #9900FF;\r\n"); |
bufferOut.append(" color: #9900FF;\r\n"); |
519 |
bufferOut.append(" background-color: transparent;\r\n"); |
bufferOut.append(" background-color: transparent;\r\n"); |
520 |
bufferOut.append(" }\r\n"); |
bufferOut.append(" }\r\n"); |
521 |
bufferOut.append(" .methodStyle\r\n"); |
bufferOut.append(" ." + methodStyle + "\r\n"); |
522 |
bufferOut.append(" {\r\n"); |
bufferOut.append(" {\r\n"); |
523 |
bufferOut.append(" color: #0000FF;\r\n"); |
bufferOut.append(" color: #0000FF;\r\n"); |
524 |
bufferOut.append(" background-color: transparent;\r\n"); |
bufferOut.append(" background-color: transparent;\r\n"); |
525 |
bufferOut.append(" }\r\n"); |
bufferOut.append(" }\r\n"); |
526 |
bufferOut.append(" .variableStyle\r\n"); |
bufferOut.append(" ." + variableStyle + "\r\n"); |
527 |
bufferOut.append(" {\r\n"); |
bufferOut.append(" {\r\n"); |
528 |
bufferOut.append(" color: #CC9933;\r\n"); |
bufferOut.append(" color: #CC9933;\r\n"); |
529 |
bufferOut.append(" background-color: transparent;\r\n"); |
bufferOut.append(" background-color: transparent;\r\n"); |
530 |
bufferOut.append(" }\r\n"); |
bufferOut.append(" }\r\n"); |
531 |
bufferOut.append(" .singleLineCommentStyle\r\n"); |
bufferOut.append(" ." + singleLineCommentStyle + "\r\n"); |
532 |
bufferOut.append(" {\r\n"); |
bufferOut.append(" {\r\n"); |
533 |
bufferOut.append(" color: #CC3333;\r\n"); |
bufferOut.append(" color: #CC3333;\r\n"); |
534 |
bufferOut.append(" background-color: transparent;\r\n"); |
bufferOut.append(" background-color: transparent;\r\n"); |
535 |
bufferOut.append(" }\r\n"); |
bufferOut.append(" }\r\n"); |
536 |
bufferOut.append(" .traditionalCommentStyle\r\n"); |
bufferOut.append(" ." + traditionalCommentStyle + "\r\n"); |
537 |
bufferOut.append(" {\r\n"); |
bufferOut.append(" {\r\n"); |
538 |
bufferOut.append(" color: #FF0000;\r\n"); |
bufferOut.append(" color: #FF0000;\r\n"); |
539 |
bufferOut.append(" background-color: transparent;\r\n"); |
bufferOut.append(" background-color: transparent;\r\n"); |
540 |
bufferOut.append(" }\r\n"); |
bufferOut.append(" }\r\n"); |
541 |
bufferOut.append(" .javadocCommentStyle\r\n"); |
bufferOut.append(" ." + javadocCommentStyle + "\r\n"); |
542 |
bufferOut.append(" {\r\n"); |
bufferOut.append(" {\r\n"); |
543 |
bufferOut.append(" color: #CC0033;\r\n"); |
bufferOut.append(" color: #CC0033;\r\n"); |
544 |
bufferOut.append(" background-color: transparent;\r\n"); |
bufferOut.append(" background-color: transparent;\r\n"); |
545 |
bufferOut.append(" }\r\n"); |
bufferOut.append(" }\r\n"); |
546 |
bufferOut.append(" .javadocTagStyle\r\n"); |
bufferOut.append(" ." + javadocTagStyle + "\r\n"); |
547 |
bufferOut.append(" {\r\n"); |
bufferOut.append(" {\r\n"); |
548 |
bufferOut.append(" color: #0099CC;\r\n"); |
bufferOut.append(" color: #0099CC;\r\n"); |
549 |
bufferOut.append(" background-color: transparent;\r\n"); |
bufferOut.append(" background-color: transparent;\r\n"); |
550 |
bufferOut.append(" }\r\n"); |
bufferOut.append(" }\r\n"); |
551 |
bufferOut.append(" .importNameStyle\r\n"); |
bufferOut.append(" ." + importNameStyle + "\r\n"); |
552 |
bufferOut.append(" {\r\n"); |
bufferOut.append(" {\r\n"); |
553 |
bufferOut.append(" color: #33CCCC;\r\n"); |
bufferOut.append(" color: #33CCCC;\r\n"); |
554 |
bufferOut.append(" background-color: transparent;\r\n"); |
bufferOut.append(" background-color: transparent;\r\n"); |
555 |
bufferOut.append(" }\r\n"); |
bufferOut.append(" }\r\n"); |
556 |
bufferOut.append(" .packageNameStyle\r\n"); |
bufferOut.append(" ." + packageNameStyle + "\r\n"); |
557 |
bufferOut.append(" {\r\n"); |
bufferOut.append(" {\r\n"); |
558 |
bufferOut.append(" color: #339999;\r\n"); |
bufferOut.append(" color: #339999;\r\n"); |
559 |
bufferOut.append(" background-color: transparent;\r\n"); |
bufferOut.append(" background-color: transparent;\r\n"); |
560 |
bufferOut.append(" }\r\n"); |
bufferOut.append(" }\r\n"); |
561 |
bufferOut.append(" .primitiveTypeStyle\r\n"); |
bufferOut.append(" ." + primitiveTypeStyle + "\r\n"); |
562 |
bufferOut.append(" {\r\n"); |
bufferOut.append(" {\r\n"); |
563 |
bufferOut.append(" color: #009900;\r\n"); |
bufferOut.append(" color: #009900;\r\n"); |
564 |
bufferOut.append(" background-color: transparent;\r\n"); |
bufferOut.append(" background-color: transparent;\r\n"); |
565 |
bufferOut.append(" }\r\n"); |
bufferOut.append(" }\r\n"); |
566 |
bufferOut.append(" .nonPrimitiveTypeStyle\r\n"); |
bufferOut.append(" ." + nonPrimitiveTypeStyle + "\r\n"); |
567 |
bufferOut.append(" {\r\n"); |
bufferOut.append(" {\r\n"); |
568 |
bufferOut.append(" color: #009966;\r\n"); |
bufferOut.append(" color: #009966;\r\n"); |
569 |
bufferOut.append(" background-color: transparent;\r\n"); |
bufferOut.append(" background-color: transparent;\r\n"); |
570 |
bufferOut.append(" }\r\n"); |
bufferOut.append(" }\r\n"); |
571 |
bufferOut.append(" .constructorStyle\r\n"); |
bufferOut.append(" ." + constructorStyle + "\r\n"); |
572 |
bufferOut.append(" {\r\n"); |
bufferOut.append(" {\r\n"); |
573 |
bufferOut.append(" color: #3300CC;\r\n"); |
bufferOut.append(" color: #3300CC;\r\n"); |
574 |
bufferOut.append(" background-color: transparent;\r\n"); |
bufferOut.append(" background-color: transparent;\r\n"); |
575 |
bufferOut.append(" }\r\n"); |
bufferOut.append(" }\r\n"); |
576 |
bufferOut.append(" .constantStyle\r\n"); |
bufferOut.append(" ." + constantStyle + "\r\n"); |
577 |
bufferOut.append(" {\r\n"); |
bufferOut.append(" {\r\n"); |
578 |
bufferOut.append(" color: #666666;\r\n"); |
bufferOut.append(" color: #666666;\r\n"); |
579 |
bufferOut.append(" background-color: transparent;\r\n"); |
bufferOut.append(" background-color: transparent;\r\n"); |
580 |
bufferOut.append(" }\r\n"); |
bufferOut.append(" }\r\n"); |
581 |
bufferOut.append(" .doubleQuoteStyle\r\n"); |
bufferOut.append(" ." + doubleQuoteStyle + "\r\n"); |
582 |
bufferOut.append(" {\r\n"); |
bufferOut.append(" {\r\n"); |
583 |
bufferOut.append(" color: #996633;\r\n"); |
bufferOut.append(" color: #996633;\r\n"); |
584 |
bufferOut.append(" background-color: transparent;\r\n"); |
bufferOut.append(" background-color: transparent;\r\n"); |
585 |
bufferOut.append(" font-style: italic;\r\n"); |
bufferOut.append(" font-style: italic;\r\n"); |
586 |
bufferOut.append(" }\r\n"); |
bufferOut.append(" }\r\n"); |
587 |
bufferOut.append(" .singleQuoteStyle\r\n"); |
bufferOut.append(" ." + singleQuoteStyle + "\r\n"); |
588 |
bufferOut.append(" {\r\n"); |
bufferOut.append(" {\r\n"); |
589 |
bufferOut.append(" color: #663333;\r\n"); |
bufferOut.append(" color: #663333;\r\n"); |
590 |
bufferOut.append(" background-color: transparent;\r\n"); |
bufferOut.append(" background-color: transparent;\r\n"); |
591 |
bufferOut.append(" font-style: oblique;\r\n"); |
bufferOut.append(" font-style: oblique;\r\n"); |
592 |
bufferOut.append(" }\r\n"); |
bufferOut.append(" }\r\n"); |
593 |
bufferOut.append(" .numericalLiteralStyle\r\n"); |
bufferOut.append(" ." + numericalLiteralStyle + "\r\n"); |
594 |
bufferOut.append(" {\r\n"); |
bufferOut.append(" {\r\n"); |
595 |
bufferOut.append(" color: #333300;\r\n"); |
bufferOut.append(" color: #333300;\r\n"); |
596 |
bufferOut.append(" background-color: transparent;\r\n"); |
bufferOut.append(" background-color: transparent;\r\n"); |
597 |
bufferOut.append(" }\r\n"); |
bufferOut.append(" }\r\n"); |
598 |
bufferOut.append(" .primitiveLiteralStyle\r\n"); |
bufferOut.append(" ." + primitiveLiteralStyle + "\r\n"); |
599 |
bufferOut.append(" {\r\n"); |
bufferOut.append(" {\r\n"); |
600 |
bufferOut.append(" color: #006600;\r\n"); |
bufferOut.append(" color: #006600;\r\n"); |
601 |
bufferOut.append(" background-color: transparent;\r\n"); |
bufferOut.append(" background-color: transparent;\r\n"); |
602 |
bufferOut.append(" }\r\n"); |
bufferOut.append(" }\r\n"); |
603 |
if (hasFooterIcons) |
if (hasFooterIcons) |
604 |
{ |
{ |
605 |
bufferOut.append(" .iconStyle\r\n"); |
bufferOut.append(" ." + iconStyle + "\r\n"); |
606 |
bufferOut.append(" {\r\n"); |
bufferOut.append(" {\r\n"); |
607 |
bufferOut.append(" border-style: none;\r\n"); |
bufferOut.append(" border-style: none;\r\n"); |
608 |
bufferOut.append(" }\r\n"); |
bufferOut.append(" }\r\n"); |
660 |
bufferOut.append(" <div id=\"legendTitle\">\r\n"); |
bufferOut.append(" <div id=\"legendTitle\">\r\n"); |
661 |
bufferOut.append(" Legend\r\n"); |
bufferOut.append(" Legend\r\n"); |
662 |
bufferOut.append(" </div>\r\n"); |
bufferOut.append(" </div>\r\n"); |
663 |
bufferOut.append(" <div class=\"sourceCodeStyle\">\r\n"); |
bufferOut.append(" <div class=\"" + sourceCodeStyle + "\">\r\n"); |
664 |
bufferOut.append(" <div id=\"legend\">\r\n"); |
bufferOut.append(" <div id=\"legend\">\r\n"); |
665 |
bufferOut.append(" <span class=\"keywordStyle\">"); |
bufferOut.append(" <span class=\"" + keywordStyle + "\">"); |
666 |
bufferOut.append("keyword</span>\r\n"); |
bufferOut.append("keyword</span>\r\n"); |
667 |
bufferOut.append(" <span class=\"methodStyle\">"); |
bufferOut.append(" <span class=\"" + methodStyle + "\">"); |
668 |
bufferOut.append("method</span>\r\n"); |
bufferOut.append("method</span>\r\n"); |
669 |
bufferOut.append(" <span class=\"variableStyle\">variable" + |
bufferOut.append(" <span class=\"" + variableStyle + "\">variable" + |
670 |
"</span>\r\n"); |
"</span>\r\n"); |
671 |
bufferOut.append(" <span class=\"singleLineCommentStyle\">" + |
bufferOut.append(" <span class=\"" + singleLineCommentStyle + "\">" + |
672 |
"singleLineComment</span>\r\n"); |
"singleLineComment</span>\r\n"); |
673 |
bufferOut.append(" <span class=\"traditionalCommentStyle\">" + |
bufferOut.append(" <span class=\"" + traditionalCommentStyle + "\">" + |
674 |
"traditionalComment</span>\r\n"); |
"traditionalComment</span>\r\n"); |
675 |
bufferOut.append(" <span class=\"javadocCommentStyle\">" + |
bufferOut.append(" <span class=\"" + javadocCommentStyle + "\">" + |
676 |
"javadocComment</span>\r\n"); |
"javadocComment</span>\r\n"); |
677 |
bufferOut.append(" <span class=\"javadocTagStyle\">javadocTag" + |
bufferOut.append(" <span class=\"" + javadocTagStyle + "\">javadocTag" + |
678 |
"</span>\r\n"); |
"</span>\r\n"); |
679 |
bufferOut.append(" <span class=\"importNameStyle\">" + |
bufferOut.append(" <span class=\"" + importNameStyle + "\">" + |
680 |
"importName</span>\r\n"); |
"importName</span>\r\n"); |
681 |
bufferOut.append(" <span class=\"packageNameStyle\">" + |
bufferOut.append(" <span class=\"" + packageNameStyle + "\">" + |
682 |
"packageName</span>\r\n"); |
"packageName</span>\r\n"); |
683 |
bufferOut.append(" <span class=\"primitiveTypeStyle\">" + |
bufferOut.append(" <span class=\"" + primitiveTypeStyle + "\">" + |
684 |
"primitiveType</span>\r\n"); |
"primitiveType</span>\r\n"); |
685 |
bufferOut.append(" <span class=\"nonPrimitiveTypeStyle\">" + |
bufferOut.append(" <span class=\"" + nonPrimitiveTypeStyle + "\">" + |
686 |
"nonPrimitiveType</span>\r\n"); |
"nonPrimitiveType</span>\r\n"); |
687 |
bufferOut.append(" <span class=\"constructorStyle\">" + |
bufferOut.append(" <span class=\"" + constructorStyle + "\">" + |
688 |
"constructor</span>\r\n"); |
"constructor</span>\r\n"); |
689 |
bufferOut.append(" <span class=\"constantStyle\">" + |
bufferOut.append(" <span class=\"" + constantStyle + "\">" + |
690 |
"constant</span>\r\n"); |
"constant</span>\r\n"); |
691 |
bufferOut.append(" <span class=\"doubleQuoteStyle\">" + |
bufferOut.append(" <span class=\"" + doubleQuoteStyle + "\">" + |
692 |
"doubleQuote</span>\r\n"); |
"doubleQuote</span>\r\n"); |
693 |
bufferOut.append(" <span class=\"singleQuoteStyle\">" + |
bufferOut.append(" <span class=\"" + singleQuoteStyle + "\">" + |
694 |
"singleQuote</span>\r\n"); |
"singleQuote</span>\r\n"); |
695 |
bufferOut.append(" <span class=\"numericalLiteralStyle\">" + |
bufferOut.append(" <span class=\"" + numericalLiteralStyle + "\">" + |
696 |
"numericalLiteral</span>\r\n"); |
"numericalLiteral</span>\r\n"); |
697 |
bufferOut.append(" <span class=\"primitiveLiteralStyle\">" + |
bufferOut.append(" <span class=\"" + primitiveLiteralStyle + "\">" + |
698 |
"primitiveLiteral</span>\r\n"); |
"primitiveLiteral</span>\r\n"); |
699 |
bufferOut.append(" </div>\r\n"); |
bufferOut.append(" </div>\r\n"); |
700 |
bufferOut.append(" </div>\r\n"); |
bufferOut.append(" </div>\r\n"); |
701 |
bufferOut.append(" <hr />\r\n"); |
bufferOut.append(" <hr />\r\n"); |
702 |
} |
} |
703 |
bufferOut.append(" <div class=\"sourceCodeStyle\">\r\n"); |
bufferOut.append(" <div class=\"" + sourceCodeStyle + "\">\r\n"); |
704 |
if (hasLineModulusCodeBlocks) |
if (hasLineModulusCodeBlocks) |
705 |
{ |
{ |
706 |
bufferOut.append("<pre class=\"modulusBlockPREStyle\">\r\n"); |
bufferOut.append("<pre class=\"modulusBlockPREStyle\">\r\n"); |
742 |
if (State.TRADITIONAL_COMMENT == presentState) |
if (State.TRADITIONAL_COMMENT == presentState) |
743 |
{ |
{ |
744 |
bufferOut.append("<span class=" + |
bufferOut.append("<span class=" + |
745 |
"\"traditionalCommentStyle\">"); |
"\"" + traditionalCommentStyle + "\">"); |
746 |
} |
} |
747 |
if (State.JAVADOC == presentState) |
if (State.JAVADOC == presentState) |
748 |
{ |
{ |
749 |
bufferOut.append("<span class=" + |
bufferOut.append("<span class=" + |
750 |
"\"javadocCommentStyle\">"); |
"\"" + javadocCommentStyle + "\">"); |
751 |
} |
} |
752 |
} |
} |
753 |
isNewBlock = !isNewBlock; |
isNewBlock = !isNewBlock; |
774 |
if ((lineModulus > 0) && (codeLineNumber%lineModulus == 0)) |
if ((lineModulus > 0) && (codeLineNumber%lineModulus == 0)) |
775 |
{ |
{ |
776 |
bufferOut.append("<span class=" + |
bufferOut.append("<span class=" + |
777 |
"\"modulusLineNumberStyle\">"); |
"\"" + modulusLineNumberStyle + "\">"); |
778 |
bufferOut.append(codeLineNumber); |
bufferOut.append(codeLineNumber); |
779 |
bufferOut.append(": </span>"); |
bufferOut.append(": </span>"); |
780 |
if (hasLineModulusDrawnLines) |
if (hasLineModulusDrawnLines) |
833 |
else |
else |
834 |
{ |
{ |
835 |
// line numbers are in lineNumberColor |
// line numbers are in lineNumberColor |
836 |
bufferOut.append("<span class=\"lineNumberStyle\">"); |
bufferOut.append("<span class=\"" + lineNumberStyle + "\">"); |
837 |
bufferOut.append(codeLineNumber); |
bufferOut.append(codeLineNumber); |
838 |
bufferOut.append(":</span> "); |
bufferOut.append(":</span> "); |
839 |
} |
} |
874 |
// be a variable |
// be a variable |
875 |
bufferOut.insert(bufferOut.length() - |
bufferOut.insert(bufferOut.length() - |
876 |
qualifiedIdentifierLength, |
qualifiedIdentifierLength, |
877 |
"<span class=\"variableStyle\">"); |
"<span class=\"" + variableStyle + "\">"); |
878 |
bufferOut.append("</span>"); |
bufferOut.append("</span>"); |
879 |
presentState = State.JAVADOC; |
presentState = State.JAVADOC; |
880 |
} |
} |
887 |
{ |
{ |
888 |
// identifier is a javadocTag |
// identifier is a javadocTag |
889 |
bufferOut.insert(bufferOut.length() - identifierLength, |
bufferOut.insert(bufferOut.length() - identifierLength, |
890 |
"<span class=\"javadocTagStyle\">"); |
"<span class=\"" + javadocTagStyle + "\">"); |
891 |
bufferOut.append("</span>"); |
bufferOut.append("</span>"); |
892 |
if (("param").equals(identifier)) |
if (("param").equals(identifier)) |
893 |
{ |
{ |
902 |
// import identifier |
// import identifier |
903 |
bufferOut.insert(bufferOut.length() - |
bufferOut.insert(bufferOut.length() - |
904 |
qualifiedIdentifierLength, |
qualifiedIdentifierLength, |
905 |
"<span class=\"importNameStyle\">"); |
"<span class=\"" + importNameStyle + "\">"); |
906 |
bufferOut.append("</span>"); |
bufferOut.append("</span>"); |
907 |
presentState = State.TEXT; |
presentState = State.TEXT; |
908 |
} |
} |
911 |
// package identifier |
// package identifier |
912 |
bufferOut.insert(bufferOut.length() - |
bufferOut.insert(bufferOut.length() - |
913 |
qualifiedIdentifierLength, |
qualifiedIdentifierLength, |
914 |
"<span class=\"packageNameStyle\">"); |
"<span class=\"" + packageNameStyle + "\">"); |
915 |
bufferOut.append("</span>"); |
bufferOut.append("</span>"); |
916 |
presentState = State.TEXT; |
presentState = State.TEXT; |
917 |
} |
} |
922 |
// identifier is a keyword |
// identifier is a keyword |
923 |
bufferOut.insert(bufferOut.length() - |
bufferOut.insert(bufferOut.length() - |
924 |
qualifiedIdentifierLength, |
qualifiedIdentifierLength, |
925 |
"<span class=\"keywordStyle\">"); |
"<span class=\"" + keywordStyle + "\">"); |
926 |
bufferOut.append("</span>"); |
bufferOut.append("</span>"); |
927 |
if (("import").equals(identifier)) |
if (("import").equals(identifier)) |
928 |
{ |
{ |
942 |
// identifier is a primitive type |
// identifier is a primitive type |
943 |
bufferOut.insert(bufferOut.length() - |
bufferOut.insert(bufferOut.length() - |
944 |
qualifiedIdentifierLength, |
qualifiedIdentifierLength, |
945 |
"<span class=\"primitiveTypeStyle\">"); |
"<span class=\"" + primitiveTypeStyle + "\">"); |
946 |
bufferOut.append("</span>"); |
bufferOut.append("</span>"); |
947 |
} |
} |
948 |
else if ((identifier.equals(identifier.toUpperCase())) && |
else if ((identifier.equals(identifier.toUpperCase())) && |
951 |
// identifier is a constant |
// identifier is a constant |
952 |
bufferOut.insert(bufferOut.length() - |
bufferOut.insert(bufferOut.length() - |
953 |
qualifiedIdentifierLength, |
qualifiedIdentifierLength, |
954 |
"<span class=\"constantStyle\">"); |
"<span class=\"" + constantStyle + "\">"); |
955 |
bufferOut.append("</span>"); |
bufferOut.append("</span>"); |
956 |
} |
} |
957 |
else if (Character.isUpperCase(identifier.charAt(0))) |
else if (Character.isUpperCase(identifier.charAt(0))) |
969 |
bufferOut.insert(bufferOut.length() - |
bufferOut.insert(bufferOut.length() - |
970 |
qualifiedIdentifierLength, |
qualifiedIdentifierLength, |
971 |
"<span class=" + |
"<span class=" + |
972 |
"\"constructorStyle\">"); |
"\"" + constructorStyle + "\">"); |
973 |
bufferOut.append("</span>"); |
bufferOut.append("</span>"); |
974 |
} |
} |
975 |
else |
else |
978 |
bufferOut.insert(bufferOut.length() - |
bufferOut.insert(bufferOut.length() - |
979 |
qualifiedIdentifierLength, |
qualifiedIdentifierLength, |
980 |
"<span class=" + |
"<span class=" + |
981 |
"\"nonPrimitiveTypeStyle\">"); |
"\"" + nonPrimitiveTypeStyle + "\">"); |
982 |
bufferOut.append("</span>"); |
bufferOut.append("</span>"); |
983 |
} |
} |
984 |
} |
} |
999 |
{ |
{ |
1000 |
bufferOut.insert(bufferOut.length() - |
bufferOut.insert(bufferOut.length() - |
1001 |
qualifiedIdentifierLength, |
qualifiedIdentifierLength, |
1002 |
"<span class=\"methodStyle\">"); |
"<span class=\"" + methodStyle + "\">"); |
1003 |
bufferOut.append("</span>"); |
bufferOut.append("</span>"); |
1004 |
} |
} |
1005 |
else if (bufferIn.charAt(saveIndex) == ',') |
else if (bufferIn.charAt(saveIndex) == ',') |
1007 |
// comma seperated variables |
// comma seperated variables |
1008 |
bufferOut.insert(bufferOut.length() - |
bufferOut.insert(bufferOut.length() - |
1009 |
qualifiedIdentifierLength, |
qualifiedIdentifierLength, |
1010 |
"<span class=\"variableStyle\">"); |
"<span class=\"" + variableStyle + "\">"); |
1011 |
bufferOut.append("</span>"); |
bufferOut.append("</span>"); |
1012 |
} |
} |
1013 |
else |
else |
1022 |
} |
} |
1023 |
bufferOut.insert(bufferOut.length() - |
bufferOut.insert(bufferOut.length() - |
1024 |
qualifiedIdentifierLength, |
qualifiedIdentifierLength, |
1025 |
"<span class=\"variableStyle\">"); |
"<span class=\"" + variableStyle + "\">"); |
1026 |
bufferOut.append("</span>"); |
bufferOut.append("</span>"); |
1027 |
} |
} |
1028 |
} |
} |
1033 |
// primitiveLiteral (boolean or null) |
// primitiveLiteral (boolean or null) |
1034 |
bufferOut.insert(bufferOut.length() - |
bufferOut.insert(bufferOut.length() - |
1035 |
identifierLength, "<span class=" + |
identifierLength, "<span class=" + |
1036 |
"\"primitiveLiteralStyle\">"); |
"\"" + primitiveLiteralStyle + "\">"); |
1037 |
bufferOut.append("</span>"); |
bufferOut.append("</span>"); |
1038 |
} |
} |
1039 |
// a numerical literal |
// a numerical literal |
1049 |
bufferOut.insert(bufferOut.length() - |
bufferOut.insert(bufferOut.length() - |
1050 |
qualifiedIdentifierLength, |
qualifiedIdentifierLength, |
1051 |
"<span class=" + |
"<span class=" + |
1052 |
"\"numericalLiteralStyle\">"); |
"\"" + numericalLiteralStyle + "\">"); |
1053 |
bufferOut.append("</span>"); |
bufferOut.append("</span>"); |
1054 |
} |
} |
1055 |
} |
} |
1075 |
{ |
{ |
1076 |
presentState = State.DOUBLE_QUOTE; |
presentState = State.DOUBLE_QUOTE; |
1077 |
bufferOut.insert(bufferOut.length()-(""").length(), |
bufferOut.insert(bufferOut.length()-(""").length(), |
1078 |
"<span class=\"doubleQuoteStyle\">"); |
"<span class=\"" + doubleQuoteStyle + "\">"); |
1079 |
} |
} |
1080 |
else if (State.DOUBLE_QUOTE == presentState) |
else if (State.DOUBLE_QUOTE == presentState) |
1081 |
{ |
{ |
1089 |
{ |
{ |
1090 |
presentState = State.SINGLE_QUOTE; |
presentState = State.SINGLE_QUOTE; |
1091 |
bufferOut.insert(bufferOut.length() - ("\'").length(), |
bufferOut.insert(bufferOut.length() - ("\'").length(), |
1092 |
"<span class=\"singleQuoteStyle\">"); |
"<span class=\"" + singleQuoteStyle + "\">"); |
1093 |
} |
} |
1094 |
else if (State.SINGLE_QUOTE == presentState) |
else if (State.SINGLE_QUOTE == presentState) |
1095 |
{ |
{ |
1124 |
presentState = State.JAVADOC; |
presentState = State.JAVADOC; |
1125 |
bufferOut.insert(bufferOut.length() - |
bufferOut.insert(bufferOut.length() - |
1126 |
("/*").length(), "<span class=" + |
("/*").length(), "<span class=" + |
1127 |
"\"javadocCommentStyle\">"); |
"\"" + javadocCommentStyle + "\">"); |
1128 |
} |
} |
1129 |
else |
else |
1130 |
{ |
{ |
1131 |
presentState = State.TRADITIONAL_COMMENT; |
presentState = State.TRADITIONAL_COMMENT; |
1132 |
bufferOut.insert(bufferOut.length() - |
bufferOut.insert(bufferOut.length() - |
1133 |
("/*").length(), "<span class=" + |
("/*").length(), "<span class=" + |
1134 |
"\"traditionalCommentStyle\">"); |
"\"" + traditionalCommentStyle + "\">"); |
1135 |
} |
} |
1136 |
} |
} |
1137 |
break; |
break; |
1150 |
{ |
{ |
1151 |
bufferOut.insert(bufferOut.length() - ("//").length(), |
bufferOut.insert(bufferOut.length() - ("//").length(), |
1152 |
"<span class=" + |
"<span class=" + |
1153 |
"\"singleLineCommentStyle\">"); |
"\"" + singleLineCommentStyle + "\">"); |
1154 |
presentState = State.LINE_COMMENT; |
presentState = State.LINE_COMMENT; |
1155 |
} |
} |
1156 |
break; |
break; |
1189 |
if (State.TRADITIONAL_COMMENT == presentState) |
if (State.TRADITIONAL_COMMENT == presentState) |
1190 |
{ |
{ |
1191 |
bufferOut.append("<span class=" + |
bufferOut.append("<span class=" + |
1192 |
"\"traditionalCommentStyle\">"); |
"\"" + traditionalCommentStyle + "\">"); |
1193 |
} |
} |
1194 |
if (State.JAVADOC == presentState) |
if (State.JAVADOC == presentState) |
1195 |
{ |
{ |
1196 |
bufferOut.append("<span class=" + |
bufferOut.append("<span class=" + |
1197 |
"\"javadocCommentStyle\">"); |
"\"" + javadocCommentStyle + "\">"); |
1198 |
} |
} |
1199 |
} |
} |
1200 |
else |
else |
1227 |
{ |
{ |
1228 |
bufferOut.append(" </div>\r\n"); |
bufferOut.append(" </div>\r\n"); |
1229 |
} |
} |
1230 |
bufferOut.append(" </div>\r\n"); // end div of sourceCodeStyle |
bufferOut.append(" </div>\r\n"); // end div of sourceCodeStyle |
1231 |
// if code snippet then don't add ending tags of xhtml page |
// if code snippet then don't add ending tags of xhtml page |
1232 |
if (!isCodeSnippet) |
if (!isCodeSnippet) |
1233 |
{ |
{ |
1253 |
bufferOut.append(" <a href=\""); |
bufferOut.append(" <a href=\""); |
1254 |
bufferOut.append("http://validator.w3.org/check/referer"); |
bufferOut.append("http://validator.w3.org/check/referer"); |
1255 |
bufferOut.append("\">\r\n"); |
bufferOut.append("\">\r\n"); |
1256 |
bufferOut.append(" <img class=\"iconStyle\" src=\""); |
bufferOut.append(" <img class=\"" + iconStyle + "\" src=\""); |
1257 |
bufferOut.append("http://www.w3.org/Icons/"); |
bufferOut.append("http://www.w3.org/Icons/"); |
1258 |
if (isXHTML_1_1) |
if (isXHTML_1_1) |
1259 |
{ |
{ |
1273 |
bufferOut.append("http://jigsaw.w3.org"); |
bufferOut.append("http://jigsaw.w3.org"); |
1274 |
bufferOut.append("/css-validator/check/referer"); |
bufferOut.append("/css-validator/check/referer"); |
1275 |
bufferOut.append("\">\r\n"); |
bufferOut.append("\">\r\n"); |
1276 |
bufferOut.append(" <img class=\"iconStyle\" src=\""); |
bufferOut.append(" <img class=\"" + iconStyle + "\" src=\""); |
1277 |
bufferOut.append("http://jigsaw.w3.org/"); |
bufferOut.append("http://jigsaw.w3.org/"); |
1278 |
bufferOut.append("css-validator/images/vcss"); |
bufferOut.append("css-validator/images/vcss"); |
1279 |
bufferOut.append("\"\r\n"); |
bufferOut.append("\"\r\n"); |