By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,034 Members | 819 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,034 IT Pros & Developers. It's quick & easy.

Java/Xml

P: 13
Just starting a java prog to pull info from an XML doc. Haven't written any code that actually does anything yet. Will someone please just point me in the right direction to get started...

In this assignment you will demonstrate your understanding of using the DOM to process XML documents in Java. The goal is to load in and extract content from a given XML document. The document's content will be used to populate state data for a collection of Objects.

Within the source folder you shall exactly five classes:

Movie
Music
MediaCollection
T_MediaCollection
The T_MediaCollection is the test harness and should have a main() method. The other three classes should not have a main() method. More requirements are listed below.


Details

Class Movie

The Movie class represents a Movie in a MediaCollection. It should provide the ability to set/get the movie title, rating and summary. Specifically, the class must have only have the following public operations (you may add other operations if you deem it necessary but they must all be declared private):

public Movie (String initTitle, String initRating, String initSummary)

This constructor will initialize a Movie object to contain the provided information. The class shall not provide a default constructor.
public String getTitle()

This operation will return the movie's title.
public String getRating()

This operation will return the movie's rating.
public String getSummary()

This operation will return the movie's summary.


Class Music

The Movie class represents a Movie in a MediaCollection. It should provide the ability to set/get the movie title, rating and summary. Specifically, the class must have only have the following public operations (you may add other operations if you deem it necessary but they must all be declared private):

public Music (String initTitle, String initArtist, String initFormat)

This constructor will initialize a Movie object to contain the provided information. The class shall not provide a default constructor.
public String getTitle()

This operation will return the music object's title.
public String getArtist()

This operation will return the music object's artist.
public String getFormat()

This operation will return the music object's format.


Class MediaCollection

The MediaCollection represents a collection of media elements and provides the ability to load a collection from an XML file containing the details of a music collection. The XML file must be valid with respect to the music collection schema, for example, this example document.

The class must provide only the following public operations:

public void setFileLocation(String pathToFile)

This operation will update the class to use the path specified when loading the XML document.
public boolean loadDocument()

This operation will load the XML document from the file located in the path provided by the last call to setFileLocation(). The operation will return true if the load was successful and false otherwise.
public ArrayList<Music> getMusicElements()

This operation will return all music elements that appear in the currently loaded media collection. If there are no music elements in the currently loaded collection or if there is no currently loaded media collection, the list returned will have size 0.
public ArrayList<Movie> getMovieElements()

This operation will return all movie elements that appear in the currently loaded media collection. If there are no movie elements in the currently loaded collection or if there is no currently loaded media collection, the list returned will have size 0.
The correct implementation of this class should require the user to first call setFileLocation() and then loadDocument(). Similarly, it makes no sense to call getMovieElements() or getMusicElements() until the document has been loaded.



Class T_MediaCollection

This class must reasonably exercise the various functionality of the Movie, Music and MediaCollection classes - at a minimum, demonstrating that your implementation has met the above described interfaces.

////// I think it looks like i should start with building an XML doc,that validates against the given schema, should not be a problem.

Not really sure how to even get started... Please teach me
Nov 21 '06 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.