• Post Reply Bookmark Topic Watch Topic
  • New Topic

Sorting Field Order?  RSS feed

 
James Dekker
Ranch Hand
Posts: 222
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Let's say you have 3 different files delimted by a space, comma, and pipe (|)...

And also, let's suppose you have different field orders in these files,

for example (please see the following as 3 different files contents):



So far, I have created the following classes:

The Person class:



The PersonFactory:



The StringUtil class:



My question is, how do I deal with the different field orders in the 3 different types of text files (which I displayed in a single [ CODE ] block above)?

The reason I ask is because the output has to be in this order:



Should I create a final field called FIELD_ORDER or use enums in the PersonFactory class? Let's forget about the File I / O part for now...

Thank you,

JD
[ July 13, 2007: Message edited by: James Dekker ]
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
See if a high level picture like this makes sense:

I've implied a common Parser abstract class with an implementation for each file format. Some parts of the job like reading the file are the same for all formats, so the abstract superclass might do that. Some parts like splitting the lines and understanding the dates would be different for each parser.

Have you learned enough about extending and polymorphism to be comfortable with that?
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!