import components.simplereader.SimpleReader; import components.simplereader.SimpleReader1L; import components.simplewriter.SimpleWriter; import components.simplewriter.SimpleWriter1L; import components.xmltree.XMLTree; import components.xmltree.XMLTree1; /** * This program inputs an XML RSS (version 2.0) feed from a given URL and * outputs various elements of the feed to the console. * * @author Put your name here * */ public final class RSSProcessing { /** * Private constructor so this utility class cannot be instantiated. */ private RSSProcessing() { } /** * Finds the first occurrence of the given tag among the children of the * given {@code XMLTree} and return its index; returns -1 if not found. * * @param xml * the {@code XMLTree} to search * @param tag * the tag to look for * @return the index of the first child of the {@code XMLTree} matching the * given tag or -1 if not found * @requires [the label of the root of xml is a tag] * @ensures
* getChildElement =
* [the index of the first tag child of the {@code XMLTree} matching the
* given tag or -1 if not found]
*
*/
private static int getChildElement(XMLTree xml, String tag) {
assert xml != null : "Violation of: xml is not null";
assert tag != null : "Violation of: tag is not null";
assert xml.isTag() : "Violation of: the label root of xml is a tag";
/*
* TODO: #1 - fill in body
*/
/*
* This line added just to make the program compilable. Should be
* replaced with appropriate return statement.
*/
return 0;
}
/**
* Processes one news item and outputs the title, or the description if the
* title is not present, and the link (if available) with appropriate
* labels.
*
* @param item
* the news item
* @param out
* the output stream
* @requires [the label of the root of item is an
* out.content = #out.content * [the title (or description) and link]
*
*/
private static void processItem(XMLTree item, SimpleWriter out) {
assert item != null : "Violation of: item is not null";
assert out != null : "Violation of: out is not null";
assert item.isTag() && item.label().equals("item") : ""
+ "Violation of: the label root of item is an