tags:

views:

59

answers:

2

I have created a class with 3 sub classes in Java. The 3 sub classes contain variables to store information from my XML document. I am able to store in the first two for there are only single instances of the data in the XML. The third class contains variables that repeat multiple times. I want to store an object of "third class" objects. I also have a SAX parser class. I am doing this within an Android environment (1.6).

Does this make enough sense without displaying any code?

A: 

Does this make enough sense without displaying any code?

Barely.

My guess is that your third class really needs to have variables that hold single instance datum, and that you then need to create multiple instances of that class; i.e. one for each XML containing element.

If that makes no sense, you need to show us the code and a sample of the XML you are trying to parse.

Stephen C
A: 

Could you try to explain your model a bit more? it's kind of hard to understand what you're trying to do without a more concrete example. What are the three sub-classes called, and how do they relate to each other? An XML snippet or two might help, as well.

From what I understood from your question, though, my guess is that you should use some sort of Factory pattern to create "third-class" objects. So, when your SAX parser hits the appropriate tag, call the factory method with the attributes you've just parsed to create the object.

Kris
Hola! Thanks all for your input to help me with this situation. I did get it figured out. Within my super class I created an ArrayList for one of my subclasses to store the repeating data from my xml. From my parser class I called this and stored the objects in the ArrayList object. Thanks again.
taraloca