List of usage examples for org.jdom2 Element getChild
public Element getChild(final String cname, final Namespace ns)
From source file:com.sun.syndication.io.impl.RSS090Parser.java
License:Open Source License
/** * This method exists because RSS0.90 and RSS1.0 have the 'textinput' element under the root elemment. * And RSS0.91, RSS0.02, RSS0.93, RSS0.94 and RSS2.0 have it under the 'channel' element. * <p/>/*from ww w .ja va2 s. c o m*/ */ protected Element getTextInput(Element rssRoot) { return rssRoot.getChild("textinput", getRSSNamespace()); }
From source file:com.sun.syndication.io.impl.RSS090Parser.java
License:Open Source License
/** * Parses the root element of an RSS document looking for image information. * <p/>/* ww w .j a va 2s . c om*/ * It reads title and url out of the 'image' element. * <p/> * * @param rssRoot the root element of the RSS document to parse for image information. * @return the parsed image bean. */ protected Image parseImage(Element rssRoot) { Image image = null; Element eImage = getImage(rssRoot); if (eImage != null) { image = new Image(); Element e = eImage.getChild("title", getRSSNamespace()); if (e != null) { image.setTitle(e.getText()); } e = eImage.getChild("url", getRSSNamespace()); if (e != null) { image.setUrl(e.getText()); } e = eImage.getChild("link", getRSSNamespace()); if (e != null) { image.setLink(e.getText()); } } return image; }
From source file:com.sun.syndication.io.impl.RSS090Parser.java
License:Open Source License
/** * Parses an item element of an RSS document looking for item information. * <p/>// ww w . ja va 2 s. c o m * It reads title and link out of the 'item' element. * <p/> * * @param rssRoot the root element of the RSS document in case it's needed for context. * @param eItem the item element to parse. * @return the parsed RSSItem bean. */ protected Item parseItem(Element rssRoot, Element eItem) { Item item = new Item(); Element e = eItem.getChild("title", getRSSNamespace()); if (e != null) { item.setTitle(e.getText()); } e = eItem.getChild("link", getRSSNamespace()); if (e != null) { item.setLink(e.getText()); item.setUri(e.getText()); } item.setModules(parseItemModules(eItem)); List foreignMarkup = extractForeignMarkup(eItem, item, getRSSNamespace()); //content:encoded elements are treated special, without a module, they have to be removed from the foreign //markup to avoid duplication in case of read/write. Note that this fix will break if a content module is //used Iterator iterator = foreignMarkup.iterator(); while (iterator.hasNext()) { Element ie = (Element) iterator.next(); if (getContentNamespace().equals(ie.getNamespace()) && ie.getName().equals("encoded")) { iterator.remove(); } } if (foreignMarkup.size() > 0) { item.setForeignMarkup(foreignMarkup); } return item; }
From source file:com.sun.syndication.io.impl.RSS090Parser.java
License:Open Source License
/** * Parses the root element of an RSS document looking for text-input information. * <p/>//from w w w . j a va 2 s .c om * It reads title, description, name and link out of the 'textinput' or 'textInput' element. * <p/> * * @param rssRoot the root element of the RSS document to parse for text-input information. * @return the parsed RSSTextInput bean. */ protected TextInput parseTextInput(Element rssRoot) { TextInput textInput = null; Element eTextInput = getTextInput(rssRoot); if (eTextInput != null) { textInput = new TextInput(); Element e = eTextInput.getChild("title", getRSSNamespace()); if (e != null) { textInput.setTitle(e.getText()); } e = eTextInput.getChild("description", getRSSNamespace()); if (e != null) { textInput.setDescription(e.getText()); } e = eTextInput.getChild("name", getRSSNamespace()); if (e != null) { textInput.setName(e.getText()); } e = eTextInput.getChild("link", getRSSNamespace()); if (e != null) { textInput.setLink(e.getText()); } } return textInput; }
From source file:com.sun.syndication.io.impl.RSS091UserlandGenerator.java
License:Open Source License
protected void addChannel(Channel channel, Element parent) throws FeedException { super.addChannel(channel, parent); Element eChannel = parent.getChild("channel", getFeedNamespace()); addImage(channel, eChannel);/*www.j a va 2 s . c o m*/ addTextInput(channel, eChannel); addItems(channel, eChannel); }
From source file:com.sun.syndication.io.impl.RSS091UserlandParser.java
License:Open Source License
/** * Parses the root element of an RSS document into a Channel bean. * <p/>/*from w w w. ja v a 2s .c o m*/ * It first invokes super.parseChannel and then parses and injects the following * properties if present: language, pubDate, rating and copyright. * <p/> * * @param rssRoot the root element of the RSS document to parse. * @return the parsed Channel bean. */ protected WireFeed parseChannel(Element rssRoot) { Channel channel = (Channel) super.parseChannel(rssRoot); Element eChannel = rssRoot.getChild("channel", getRSSNamespace()); Element e = eChannel.getChild("language", getRSSNamespace()); if (e != null) { channel.setLanguage(e.getText()); } e = eChannel.getChild("rating", getRSSNamespace()); if (e != null) { channel.setRating(e.getText()); } e = eChannel.getChild("copyright", getRSSNamespace()); if (e != null) { channel.setCopyright(e.getText()); } e = eChannel.getChild("pubDate", getRSSNamespace()); if (e != null) { channel.setPubDate(DateParser.parseDate(e.getText())); } e = eChannel.getChild("lastBuildDate", getRSSNamespace()); if (e != null) { channel.setLastBuildDate(DateParser.parseDate(e.getText())); } e = eChannel.getChild("docs", getRSSNamespace()); if (e != null) { channel.setDocs(e.getText()); } e = eChannel.getChild("docs", getRSSNamespace()); if (e != null) { channel.setDocs(e.getText()); } e = eChannel.getChild("managingEditor", getRSSNamespace()); if (e != null) { channel.setManagingEditor(e.getText()); } e = eChannel.getChild("webMaster", getRSSNamespace()); if (e != null) { channel.setWebMaster(e.getText()); } e = eChannel.getChild("skipHours"); if (e != null) { List skipHours = new ArrayList(); List eHours = e.getChildren("hour", getRSSNamespace()); for (int i = 0; i < eHours.size(); i++) { Element eHour = (Element) eHours.get(i); skipHours.add(new Integer(eHour.getText().trim())); } channel.setSkipHours(skipHours); } e = eChannel.getChild("skipDays"); if (e != null) { List skipDays = new ArrayList(); List eDays = e.getChildren("day", getRSSNamespace()); for (int i = 0; i < eDays.size(); i++) { Element eDay = (Element) eDays.get(i); skipDays.add(eDay.getText().trim()); } channel.setSkipDays(skipDays); } return channel; }
From source file:com.sun.syndication.io.impl.RSS091UserlandParser.java
License:Open Source License
/** * Parses the root element of an RSS document looking for image information. * <p/>// w w w . j av a 2 s .c o m * It first invokes super.parseImage and then parses and injects the following * properties if present: url, link, width, height and description. * <p/> * * @param rssRoot the root element of the RSS document to parse for image information. * @return the parsed RSSImage bean. */ protected Image parseImage(Element rssRoot) { Image image = super.parseImage(rssRoot); if (image != null) { Element eImage = getImage(rssRoot); Element e = eImage.getChild("width", getRSSNamespace()); if (e != null) { Integer val = NumberParser.parseInt(e.getText()); if (val != null) { image.setWidth(val.intValue()); } } e = eImage.getChild("height", getRSSNamespace()); if (e != null) { Integer val = NumberParser.parseInt(e.getText()); if (val != null) { image.setHeight(val.intValue()); } } e = eImage.getChild("description", getRSSNamespace()); if (e != null) { image.setDescription(e.getText()); } } return image; }
From source file:com.sun.syndication.io.impl.RSS091UserlandParser.java
License:Open Source License
/** * It looks for the 'item' elements under the 'channel' elemment. *//* www . j av a 2 s .c o m*/ protected List getItems(Element rssRoot) { Element eChannel = rssRoot.getChild("channel", getRSSNamespace()); return (eChannel != null) ? eChannel.getChildren("item", getRSSNamespace()) : Collections.EMPTY_LIST; }
From source file:com.sun.syndication.io.impl.RSS091UserlandParser.java
License:Open Source License
/** * It looks for the 'image' elements under the 'channel' elemment. *///from w w w. j a v a2 s .c o m protected Element getImage(Element rssRoot) { Element eChannel = rssRoot.getChild("channel", getRSSNamespace()); return (eChannel != null) ? eChannel.getChild("image", getRSSNamespace()) : null; }
From source file:com.sun.syndication.io.impl.RSS091UserlandParser.java
License:Open Source License
/** * It looks for the 'textinput' elements under the 'channel' elemment. *//*from w w w . ja v a2 s . co m*/ protected Element getTextInput(Element rssRoot) { String elementName = getTextInputLabel(); Element eChannel = rssRoot.getChild("channel", getRSSNamespace()); return (eChannel != null) ? eChannel.getChild(elementName, getRSSNamespace()) : null; }