1717import java .io .IOException ;
1818import java .io .InputStreamReader ;
1919import java .net .URL ;
20- import java .nio .channels .Selector ;
2120import java .text .MessageFormat ;
2221import java .util .HashMap ;
2322
@@ -165,7 +164,7 @@ protected Locator createLocator(final Token t) {
165164 * @return a new string with the escaped values
166165 */
167166 protected String addEscapes (final String str ) {
168- StringBuilder sb = new StringBuilder ();
167+ final StringBuilder sb = new StringBuilder ();
169168 char ch ;
170169 for (int i = 0 ; i < str .length (); i ++) {
171170 ch = str .charAt (i );
@@ -210,6 +209,12 @@ protected String addEscapes(final String str) {
210209 return sb .toString ();
211210 }
212211
212+ /**
213+ *
214+ * @param key the message lookup key
215+ * @param e the parse exception
216+ * @return a new CSSParseException
217+ */
213218 protected CSSParseException toCSSParseException (final String key , final ParseException e ) {
214219 final String messagePattern1 = getParserMessage ("invalidExpectingOne" );
215220 final String messagePattern2 = getParserMessage ("invalidExpectingMore" );
@@ -450,83 +455,220 @@ private CharStream getCharStream(final InputSource source) throws IOException {
450455
451456 @ Override
452457 public abstract String getParserVersion ();
453- protected abstract String getGrammarUri ();
458+
459+ /**
460+ * Re intit the stream.
461+ * @param charStream the stream
462+ */
454463 protected abstract void ReInit (CharStream charStream );
464+
465+ /**
466+ * Process a style sheet.
467+ *
468+ * @throws CSSParseException in case of error
469+ * @throws ParseException in case of error
470+ */
455471 protected abstract void styleSheet () throws CSSParseException , ParseException ;
472+
473+ /**
474+ * Process a style sheet declaration.
475+ *
476+ * @throws ParseException in case of error
477+ */
456478 protected abstract void styleDeclaration () throws ParseException ;
479+
480+ /**
481+ * Process a style sheet rule.
482+ *
483+ * @throws ParseException in case of error
484+ */
457485 protected abstract void styleSheetRuleSingle () throws ParseException ;
486+
487+ /**
488+ * Process a selector list.
489+ *
490+ * @return the selector list
491+ * @throws ParseException in case of error
492+ */
458493 protected abstract SelectorList parseSelectorsInternal () throws ParseException ;
459- protected abstract SelectorList selectorList () throws ParseException ;
494+
495+ /**
496+ * Process an expression.
497+ *
498+ * @return the lexical unit
499+ * @throws ParseException in case of error
500+ */
460501 protected abstract LexicalUnit expr () throws ParseException ;
502+
503+ /**
504+ * Process a prio.
505+ *
506+ * @return true or false
507+ * @throws ParseException in case of error
508+ */
461509 protected abstract boolean prio () throws ParseException ;
510+
511+ /**
512+ * Process a media list.
513+ *
514+ * @param ml the media list
515+ * @throws ParseException in case of error
516+ */
462517 protected abstract void mediaList (MediaQueryList ml ) throws ParseException ;
463518
519+ /**
520+ * start document handler.
521+ */
464522 protected void handleStartDocument () {
465523 getDocumentHandler ().startDocument (getInputSource ());
466524 }
467525
526+ /**
527+ * end document handler.
528+ */
468529 protected void handleEndDocument () {
469530 getDocumentHandler ().endDocument (getInputSource ());
470531 }
471532
533+ /**
534+ * ignorable at rule handler.
535+ *
536+ * @param s the rule
537+ * @param locator the locator
538+ */
472539 protected void handleIgnorableAtRule (final String s , final Locator locator ) {
473540 getDocumentHandler ().ignorableAtRule (s , locator );
474541 }
475542
543+ /**
544+ * charset handler.
545+ *
546+ * @param characterEncoding the encoding
547+ * @param locator the locator
548+ */
476549 protected void handleCharset (final String characterEncoding , final Locator locator ) {
477550 getDocumentHandler ().charset (characterEncoding , locator );
478551 }
479552
553+ /**
554+ * import style handler.
555+ *
556+ * @param uri the uri
557+ * @param media the media query list
558+ * @param defaultNamespaceURI the namespace uri
559+ * @param locator the locator
560+ */
480561 protected void handleImportStyle (final String uri , final MediaQueryList media ,
481562 final String defaultNamespaceURI , final Locator locator ) {
482563 getDocumentHandler ().importStyle (uri , media , defaultNamespaceURI , locator );
483564 }
484565
566+ /**
567+ * start media handler.
568+ *
569+ * @param media the media query list
570+ * @param locator the locator
571+ */
485572 protected void handleStartMedia (final MediaQueryList media , final Locator locator ) {
486573 getDocumentHandler ().startMedia (media , locator );
487574 }
488575
576+ /**
577+ * medium handler.
578+ *
579+ * @param medium the medium
580+ * @param locator the locator
581+ */
489582 protected void handleMedium (final String medium , final Locator locator ) {
490583 // empty default impl
491584 }
492585
586+ /**
587+ * end media handler.
588+ *
589+ * @param media the media query list
590+ */
493591 protected void handleEndMedia (final MediaQueryList media ) {
494592 getDocumentHandler ().endMedia (media );
495593 }
496594
595+ /**
596+ * start page handler.
597+ *
598+ * @param name the name
599+ * @param pseudoPage the pseudo page
600+ * @param locator the locator
601+ */
497602 protected void handleStartPage (final String name , final String pseudoPage , final Locator locator ) {
498603 getDocumentHandler ().startPage (name , pseudoPage , locator );
499604 }
500605
606+ /**
607+ * end page handler.
608+ *
609+ * @param name the name
610+ * @param pseudoPage the pseudo page
611+ */
501612 protected void handleEndPage (final String name , final String pseudoPage ) {
502613 getDocumentHandler ().endPage (name , pseudoPage );
503614 }
504615
616+ /**
617+ * start font face handler.
618+ *
619+ * @param locator the locator
620+ */
505621 protected void handleStartFontFace (final Locator locator ) {
506622 getDocumentHandler ().startFontFace (locator );
507623 }
508624
625+ /**
626+ * end font face handler.
627+ */
509628 protected void handleEndFontFace () {
510629 getDocumentHandler ().endFontFace ();
511630 }
512631
513- protected void handleSelector (final Selector selector ) {
514- // empty default impl
515- }
516-
632+ /**
633+ * selector start handler.
634+ *
635+ * @param selectors the selector list
636+ * @param locator the locator
637+ */
517638 protected void handleStartSelector (final SelectorList selectors , final Locator locator ) {
518639 getDocumentHandler ().startSelector (selectors , locator );
519640 }
520641
642+ /**
643+ * selector end handler.
644+ *
645+ * @param selectors the selector list
646+ */
521647 protected void handleEndSelector (final SelectorList selectors ) {
522648 getDocumentHandler ().endSelector (selectors );
523649 }
524650
651+ /**
652+ * property handler.
653+ *
654+ * @param name the name
655+ * @param value the value
656+ * @param important important flag
657+ * @param locator the locator
658+ */
525659 protected void handleProperty (final String name , final LexicalUnit value ,
526660 final boolean important , final Locator locator ) {
527661 getDocumentHandler ().property (name , value , important , locator );
528662 }
529663
664+ /**
665+ * Process a function decl.
666+ *
667+ * @param prev the previous lexical unit
668+ * @param funct the function
669+ * @param params the params
670+ * @return a lexical unit
671+ */
530672 protected LexicalUnit functionInternal (final LexicalUnit prev , final String funct ,
531673 final LexicalUnit params ) {
532674
@@ -551,6 +693,13 @@ else if ("rgb(".equalsIgnoreCase(funct)) {
551693 params );
552694 }
553695
696+ /**
697+ * Processes a hexadecimal color definition.
698+ *
699+ * @param prev the previous lexical unit
700+ * @param t the token
701+ * @return a new lexical unit
702+ */
554703 protected LexicalUnit hexcolorInternal (final LexicalUnit prev , final Token t ) {
555704 // Step past the hash at the beginning
556705 final int i = 1 ;
@@ -598,6 +747,13 @@ else if (len == 6) {
598747 }
599748 }
600749
750+ /**
751+ * Parses the sting into an integer.
752+ *
753+ * @param op the sign char
754+ * @param s the string to parse
755+ * @return the int value
756+ */
601757 protected int intValue (final char op , final String s ) {
602758 final int result = Integer .parseInt (s );
603759 if (op == '-' ) {
@@ -606,6 +762,13 @@ protected int intValue(final char op, final String s) {
606762 return result ;
607763 }
608764
765+ /**
766+ * Parses the sting into an double.
767+ *
768+ * @param op the sign char
769+ * @param s the string to parse
770+ * @return the double value
771+ */
609772 protected double doubleValue (final char op , final String s ) {
610773 final double result = Double .parseDouble (s );
611774 if (op == '-' ) {
@@ -614,6 +777,12 @@ protected double doubleValue(final char op, final String s) {
614777 return result ;
615778 }
616779
780+ /**
781+ * Returns the pos of the last numeric char in the given string.
782+ *
783+ * @param s the string to parse
784+ * @return the pos
785+ */
617786 protected int getLastNumPos (final String s ) {
618787 int i = 0 ;
619788 for ( ; i < s .length (); i ++) {
0 commit comments