On Thu, Aug 8, 2013 at 9:14 AM, Gary Gregory <garydgreg...@gmail.com> wrote:
> On Thu, Aug 8, 2013 at 5:30 AM, Emmanuel Bourg <ebo...@apache.org> wrote: > >> Thank you for pointing this, I didn't notice this recent addition. >> >> I'm not fond of the parseType(Type t) methods, I'd prefer parse(Type t). >> > > I'm OK with 'parse' or 'createParser'. WRT to types, the only time the > type name is really needed IMO is to distinguish a resource string, from > CSV content. I am assuming that a file would be passed in as a File, > instead of a file name. I also like consistency, so it's nice to have the > type names in all or none. To distinguish a resource path string from CSV > content, if the API has a class loader arg, then the string should be a > resource path, so we could remove all type names from the method names. > I'll experiment with that... > With types names: parseFile(File, CSVFormat) parseResource(String, Charset, ClassLoader, CSVFormat) parseResource(String, Charset, CSVFormat) [parseString(String)] parseString(String, CSVFormat) parseURL(URL, Charset, CSVFormat) Sans type names: parse(File, CSVFormat) parse(String, Charset, ClassLoader, CSVFormat) parse(String, Charset, CSVFormat) [parse(String)] parse(String, CSVFormat) parse(URL, Charset, CSVFormat) [I'd probably remove parse(String) so that all APIs take a CSVFormat.] Gary > > Gary > > >> >> Btw I would have kept these methods out of csv 1.0, this is again >> delaying the release with another discussion... >> >> Emmanuel Bourg >> >> >> Le 08/08/2013 10:24, Benedikt Ritter a écrit : >> > Hi, >> > >> > we currently have several static factory methods in CSVParser: >> > >> > - public static CSVParser parseFile(File file, final CSVFormat format) >> > throws IOException >> > - public static CSVParser parseResource(String resource, Charset >> charset, >> > ClassLoader classLoader, >> > final CSVFormat format) throws IOException >> > - public static CSVParser parseResource(String resource, Charset >> charset, >> > final CSVFormat format) throws IOException >> > - public static CSVParser parseString(String string) throws IOException >> > - public static CSVParser parseString(String string, final CSVFormat >> > format) throws IOException >> > - public static CSVParser parseURL(URL url, Charset charset, final >> > CSVFormat format) throws IOException >> > >> > and one instance factory method in CSVFormat: >> > >> > - public CSVParser parse(final Reader in) throws IOException >> > >> > One can also create a parser using the public constructors defined in >> > CSVParser: >> > >> > - public CSVParser(final Reader input) throws IOException >> > - public CSVParser(final Reader reader, final CSVFormat format) throws >> > IOException >> > >> > I'm wondering: >> > >> > 1. do we need all this different ways to create CSVParsers? For example >> it >> > may be confusing to have parse(Reader) in CSVFormat which is pretty much >> > the same as CSVParser(Reader, CSVFormat) just the other way around. >> > >> > 2. all the factory methods are named "parseXXX" but they don't actually >> > parse anything. They just create an object that is capable of parsing >> CSV >> > content. Should the factory methods be renamed? >> > >> > Benedikt >> > >> > >> >> >> --------------------------------------------------------------------- >> To unsubscribe, e-mail: dev-unsubscr...@commons.apache.org >> For additional commands, e-mail: dev-h...@commons.apache.org >> >> > > > -- > E-Mail: garydgreg...@gmail.com | ggreg...@apache.org > Java Persistence with Hibernate, Second > Edition<http://www.manning.com/bauer3/> > JUnit in Action, Second Edition <http://www.manning.com/tahchiev/> > Spring Batch in Action <http://www.manning.com/templier/> > Blog: http://garygregory.wordpress.com > Home: http://garygregory.com/ > Tweet! http://twitter.com/GaryGregory > -- E-Mail: garydgreg...@gmail.com | ggreg...@apache.org Java Persistence with Hibernate, Second Edition<http://www.manning.com/bauer3/> JUnit in Action, Second Edition <http://www.manning.com/tahchiev/> Spring Batch in Action <http://www.manning.com/templier/> Blog: http://garygregory.wordpress.com Home: http://garygregory.com/ Tweet! http://twitter.com/GaryGregory