Nathan said: i think he's referring to the main() method at the end of the class file that appears to have been written for testing the tool.
I realize that :) Nathan said: my question is not whether println() should be used, but whether we should have a public static void main(args) method in a tool at all! and my answer is "no". :) i think that if we want to set up tests, we should get some junit type stuff going. so i'd much prefer that that method just be removed. I agree - but my question is what could be wrong with using println() in a main method used for test purposes? ... just curious. cheers, Marinó On Wed, 2 Mar 2005 11:03:04 -0000, Marinó A. Jónsson <[EMAIL PROTECTED]> wrote: > could you elaborate please? > > Marinó. > > -----Original Message----- > From: Daniel L. Rall [mailto:[EMAIL PROTECTED] > Sent: 2. mars 2005 06:20 > To: Velocity Developers List > Subject: Re: svn commit: r155328 > -jakarta/velocity-tools/trunk/src/java/org/apache/velocity/tools/view/ > tools/ > BrowserSnifferTool.java > > Should this really be using println()? > <snip> > > + private String userAgent = null; > > + private String version = null; > > + private int majorVersion = -1; > > + private int minorVersion = -1; > > + private String geckoVersion = null; > > + > > + /* testing : give a filename as argument > > + * the file is supposed to contains user agent strings, one per line > > + */ > > + public static void main(String[] args) > > + { > > + try > > + { > > + > > + /* open a reader on the input file */ > > + BufferedReader reader = new BufferedReader(new > FileReader(args[0])); > > + String ua; > > + BrowserSnifferTool browser = new BrowserSnifferTool(); > > + > > + /* build an array of all the tests */ > > + Method[] methods = > BrowserSnifferTool.class.getDeclaredMethods(); > > + List tests = new ArrayList(); > > + for(int i = 0; i < methods.length; i++) > > + { > > + Method m = methods[i]; > > + int mod = m.getModifiers(); > > + String name = m.getName(); > > + if(Modifier.isPublic(mod) && !Modifier.isStatic(mod) && > > + name.startsWith("get") && name.length() > 3 && > > + m.getReturnType().getName().equals("boolean")) > > + { > > + tests.add(m); > > + } > > + } > > + > > + while( (ua = reader.readLine()) != null) > > + { > > + browser.version = null; > > + browser.majorVersion = -1; > > + browser.minorVersion = -1; > > + browser.geckoVersion = null; > > + browser.userAgent = ua.toLowerCase(); > > + System.out.println("User Agent: " + ua); > > + System.out.print(" version=" + browser.getVersion() + > > + ", major=" + browser.getMajorVersion() + > > + ", minor=" + browser.getMinorVersion()); > > + if(browser.getGecko())System.out.print(", gecko=" + > > + browser.getGeckoVersion()); > > + System.out.println(); > > + System.out.print(" "); > > + for(Iterator mi = tests.iterator(); mi.hasNext(); ) > > + { > > + Method m = (Method)mi.next(); > > + boolean b = ( (Boolean)m.invoke(browser, new Object[] > > + {})). > > + booleanValue(); > > + if(b)System.out.print(m.getName().substring(3). > > + toLowerCase() + " "); > > + } > > + System.out.println(); > > + System.out.println(); > > + } > > + } > > + catch(Exception e) > > + { > > + e.printStackTrace(); > > + } > > + } > > +} </snip> --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]