#3 Add metadata for a column

closed
nobody
None
5
2006-12-09
2006-10-03
No

Hi

I was looking for something to parse a flat file with
fixed width records... This seems to be perfect!

I noticed the ability to getDate/getDouble etc but I
think that it would be great if the XML file could
define a couple of attribute to provide some basic
transformation, eg:

<!ATTLIST COLUMN name CDATA #REQUIRED
length CDATA #IMPLIED
targetClass CDATA #IMPLIED
format CDATA #IMPLIED
>

Where targetClass would be say a java.util.Date and the
format would describe a SimpleDateFormat.

When I request DataSet.getObject("columnName"); I would
get the object i.e. the date if it was a date, a Double
if it was a double, etc

Support for BigDecimal would also be great for me
(getBigDecimal())

What do you think?

Many thanks for this great tool!

Benoit

Discussion

  • Paul Zepernick

    Paul Zepernick - 2006-10-04

    Logged In: YES
    user_id=1028753

    Benoit,

    Thanks again for another great suggestion. I am thinking
    that there could be another attribute for convertClass.
    This way if the target class is not supported, you can write
    your own convert class for it. I will make up an interface
    to handle conversions. How does that sound? convertClass
    would not be required.

    If there is no convert class specified, and the target class
    is not recognized, should an exception be thrown or just
    return as a String?

    Thanks Again,

    Paul

     
  • Benoit Xhenseval

    Logged In: YES
    user_id=358115

    Hi Paul

    Thanks for considering my 2 suggestions, can't wait for the
    next release now! :-)

    With regards to your comment on this feature request, I'd
    say that the default behaviour should stay the same. At the
    moment, you do not throw exceptions but records errors, may
    be that could stay the same...or ultimate flexibility, one
    could switch the Parser to throw exception if they want
    this... or a "stopIfError" which could be useful if there
    is no point in carrying on if an error is encountered?

    Another suggestion (may be you want to track this
    separately...). The interface is very much tailored towards
    files (InputStream and File), in one case I may receive a
    message from a queue, i.e. a simple String. May be you
    could transform your interface to only use Reader (they can
    be created from File/InputStream or String... e.g.
    FileReader and StringReader).

    All the best!

    Benoit

     
  • Paul Zepernick

    Paul Zepernick - 2006-12-09
    • status: open --> closed
     
  • Paul Zepernick

    Paul Zepernick - 2006-12-09

    Logged In: YES
    user_id=1028753
    Originator: NO

    getObject() method was added in SVN. Implemented a little bit differently then described here. Method is implemented like so

    getObject(ColumnName, ClassToGet.class)

    Conversions are mapped in a properties file.

     

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.





No, thanks