A helper method to convert a Show object into a JDOM Element. Element e = new Element("show"); e.addContent(new Element("channel").setText( Integer.toString(show.getChannel()))); e.addContent(new Element("from").setText( this.dateFmt.format(show.getStartTime()))); e.addContent(new Element("to").setText( this.dateFmt.format(show.getEndTime()))); e.addContent(new Element("title").setText(show.getTitle())); return e;
Element e = new Element("show"); e.addContent(new Element("channel").setText( Integer.toString(show.getChannel()))); e.addContent(new Element("from").setText( this.dateFmt.format(show.getStartTime()))); e.addContent(new Element("to").setText( this.dateFmt.format(show.getEndTime()))); e.addContent(new Element("title").setText(show.getTitle())); return e;
returna new JDOM Document for all TV shows scheduled for today. Schedule sched = Schedule.getInstance(); Show[] shows = sched.getTodaysShows(); Element rootElem = new Element("schedule"); for (int i=0; i<shows.length; i++) { rootElem.addContent(createShowElement(shows[i])); } return new Document(rootElem);
Schedule sched = Schedule.getInstance(); Show[] shows = sched.getTodaysShows(); Element rootElem = new Element("schedule"); for (int i=0; i<shows.length; i++) { rootElem.addContent(createShowElement(shows[i])); } return new Document(rootElem);
Simple main() method for printing the XML document to System.out, useful for testing. Document doc = new ScheduleJDOM().getTodaysShows(); new XMLOutputter(" ", true, "UTF-8").output(doc, System.out);
Document doc = new ScheduleJDOM().getTodaysShows(); new XMLOutputter(" ", true, "UTF-8").output(doc, System.out);