[css-validator] counting listed warnings

Hello Java gurus,

I have a small question with the CSS validator I think some of you  
may be able to enlighten me about.

Context: in recent changes to formatting and styling of CSS validator  
results, we've made the warnings (and validated stylesheet) invisible  
and toggle-able.
see: http://qa-dev.w3.org:8001/css-validator/validator?uri=http%3A%2F% 
2Fwww.w3.org%2F

I think it would be much better, in terms of UI, to have:
* _Warnings (12)_
instead of:
* _Warnings_

My problem is that the only "number of warnings" currently available  
through the Warnings class interface is the *total* number of  
warnings, and unless the validator is running in "show all warnings"  
mode, this is not the number we want to display.

I would like to get the number of warnings currently listed, i.e the  
number of warnings up to a certain level.

I have looked at a few ways this could be achieved, can you tell me  
which is the best way, or suggest better, and if possible help with  
code?

1) I first thought of just counting them within the produceWarning()  
routine in org/w3c/css/css/StyleSheetGeneratorHTML2.java, and pass  
that to the "general" properties variable, but due to how  
produceWarning() is called, it doesn't work.

2) Another idea would be to create another routine, similar to  
produceWarning(), which would just be called around line 465 in org/ 
w3c/css/css/StyleSheetGeneratorHTML2.java, and do the counting. But  
that sounds a bit daft, duplicating code like that.

3) Lastly, I thought the cleanest way would probably be to add new  
properties and methods to the Warnings class (org/w3c/css/util/ 
Warnings.java), allowing it to count no just the number of all  
warnings but also the number of warnings per level. It seems like the  
cleanest way, but perhaps overkill?

Thoughts, and help, welcome.
(and apologies in advance if what I'm saying is heretic in Java - I  
am not a Java coder... :) )

Thank you.
-- 
olivier

Received on Thursday, 14 December 2006 15:19:30 UTC