commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Benedikt Ritter <brit...@apache.org>
Subject Re: [CSV] Creating CSVParser instances
Date Thu, 08 Aug 2013 12:25:03 GMT
2013/8/8 Emmanuel Bourg <ebourg@apache.org>

> 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).
>

Different method names make sense for parseResource(String, Charset,
ClassLoader, CSVFormat) and parseString(String). One can see the difference
just from looking at it.
This is not true for parse(String, Charset, ClassLoader, CSVFormat)
compared to parse(String)

Anyway we would still have the problems I outline:
- the same CSVParser can be created in different ways (via contructor and
via CSVFormat.parse(Reader)).
- parse methods don't actually parse. They just create parser objects,
which may be confusing.


>
> 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-unsubscribe@commons.apache.org
> For additional commands, e-mail: dev-help@commons.apache.org
>
>


-- 
http://people.apache.org/~britter/
http://www.systemoutprintln.de/
http://twitter.com/BenediktRitter
http://github.com/britter

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message