Best way to acomplish...

I currently have an application that loads from four files. These files are currently CSV files. Whats the best way to make my application load from any file format the it gets passed with making little to no changes to my current applications? Lets say there were three possiabilitys: CSV, XML, or Database. Any suggestions?

[332 byte] By [Nexeha] at [2007-11-27 11:08:07]
# 1

You mean like dynamic physic code (DPC)?

_helloWorld_a at 2007-7-29 13:26:38 > top of Java-index,Java Essentials,New To Java...
# 2

Create separate classes strictly for loading. That way, if you need to switch to a different file format type, you can just swap in a new class

tjacobs01a at 2007-7-29 13:26:38 > top of Java-index,Java Essentials,New To Java...
# 3

Write three different file reader/parsers that all implement a DataLoader interface. The interface defines the methods for "getting data" in an abstract way. The classes define how the data is actually gotten in a concrete way. Create an instance of the appropriate class depending on the source type.

hunter9000a at 2007-7-29 13:26:38 > top of Java-index,Java Essentials,New To Java...
# 4

If I understood the OP correct he was wanting "to make little or no changes" to his code, or make the code read from 3 different formats without writing 3 different parsers/readers, which is obviously not possible.

_helloWorld_a at 2007-7-29 13:26:38 > top of Java-index,Java Essentials,New To Java...
# 5

> If I understood the OP correct he was wanting "to

> make little or no changes" to his code, or make the

> code read from 3 different formats without writing 3

> different parsers/readers, which is obviously not

> possible.

Which is why we suggested a possible solution to his problem.

hunter9000a at 2007-7-29 13:26:38 > top of Java-index,Java Essentials,New To Java...
# 6

> > If I understood the OP correct he was wanting "to

> > make little or no changes" to his code, or make

> the

> > code read from 3 different formats without writing

> 3

> > different parsers/readers, which is obviously not

> > possible.

>

I wasn't posting that for anyone other than the OP, though I will raise your Italics with bold

> Which is why we suggested a possible solution

> to his problem.

Well if you were thinking also what I posted then you were suggesting a possible solution to a possible problem ;-)

_helloWorld_a at 2007-7-29 13:26:38 > top of Java-index,Java Essentials,New To Java...
# 7

> I wasn't posting that for anyone other than the OP,

> though I will raise your Italics with bold

I am left with only the inferior U. I AM UNDONE

> Well if you were thinking also what I posted then you

> were suggesting a possible solution to a possible

> problem ;-)

Whew, glad we cleared that up. :)

Crisis: Averted

hunter9000a at 2007-7-29 13:26:38 > top of Java-index,Java Essentials,New To Java...
# 8

All i have to say is, OMG.. LOL

And back to the topic...

There most be some way to do this task, because my mentor is asking me to research it. He said it would be difficult with my current expirence level. is there any way to make a dection structure on how to read the files? ... i really don't know , i'm grasping for straws here

Nexeha at 2007-7-29 13:26:38 > top of Java-index,Java Essentials,New To Java...
# 9

Er, the problem was solved in reply #3.

Hippolytea at 2007-7-29 13:26:38 > top of Java-index,Java Essentials,New To Java...