List of usage examples for org.jdom2 Element getText
public String getText()
From source file:com.sun.syndication.io.impl.RSS091UserlandParser.java
License:Open Source License
/** * Parses an item element of an RSS document looking for item information. * <p/>/*from w ww . ja v a 2s. c o m*/ * It first invokes super.parseItem and then parses and injects the description property if present. * <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 = super.parseItem(rssRoot, eItem); Element e = eItem.getChild("description", getRSSNamespace()); if (e != null) { item.setDescription(parseItemDescription(rssRoot, e)); } Element ce = eItem.getChild("encoded", getContentNamespace()); if (ce != null) { Content content = new Content(); content.setType(Content.HTML); content.setValue(ce.getText()); item.setContent(content); } return item; }
From source file:com.sun.syndication.io.impl.RSS091UserlandParser.java
License:Open Source License
protected Description parseItemDescription(Element rssRoot, Element eDesc) { Description desc = new Description(); desc.setType("text/plain"); desc.setValue(eDesc.getText()); return desc;//from w ww . j a v a2s . c om }
From source file:com.sun.syndication.io.impl.RSS092Parser.java
License:Open Source License
protected Item parseItem(Element rssRoot, Element eItem) { Item item = super.parseItem(rssRoot, eItem); Element e = eItem.getChild("source", getRSSNamespace()); if (e != null) { Source source = new Source(); String url = e.getAttributeValue("url");//getRSSNamespace()); DONT KNOW WHY DOESN'T WORK source.setUrl(url);// w ww .j ava2 s . c o m source.setValue(e.getText()); item.setSource(source); } // 0.92 allows one enclosure occurrence, 0.93 multiple // just saving to write some code. List eEnclosures = eItem.getChildren("enclosure");//getRSSNamespace()); DONT KNOW WHY DOESN'T WORK if (eEnclosures.size() > 0) { List enclosures = new ArrayList(); for (int i = 0; i < eEnclosures.size(); i++) { e = (Element) eEnclosures.get(i); Enclosure enclosure = new Enclosure(); String att = e.getAttributeValue("url");//getRSSNamespace()); DONT KNOW WHY DOESN'T WORK if (att != null) { enclosure.setUrl(att); } att = e.getAttributeValue("length");//getRSSNamespace()); DONT KNOW WHY DOESN'T WORK enclosure.setLength(NumberParser.parseLong(att, 0L)); att = e.getAttributeValue("type");//getRSSNamespace()); DONT KNOW WHY DOESN'T WORK if (att != null) { enclosure.setType(att); } enclosures.add(enclosure); } item.setEnclosures(enclosures); } List eCats = eItem.getChildren("category");//getRSSNamespace()); DONT KNOW WHY DOESN'T WORK item.setCategories(parseCategories(eCats)); return item; }
From source file:com.sun.syndication.io.impl.RSS092Parser.java
License:Open Source License
protected List parseCategories(List eCats) { List cats = null;/*from www . j av a 2 s. com*/ if (eCats.size() > 0) { cats = new ArrayList(); for (int i = 0; i < eCats.size(); i++) { Category cat = new Category(); Element e = (Element) eCats.get(i); String att = e.getAttributeValue("domain");//getRSSNamespace()); DONT KNOW WHY DOESN'T WORK if (att != null) { cat.setDomain(att); } cat.setValue(e.getText()); cats.add(cat); } } return cats; }
From source file:com.sun.syndication.io.impl.RSS093Parser.java
License:Open Source License
protected Item parseItem(Element rssRoot, Element eItem) { Item item = super.parseItem(rssRoot, eItem); Element e = eItem.getChild("pubDate", getRSSNamespace()); if (e != null) { item.setPubDate(DateParser.parseDate(e.getText())); }//from w w w . ja v a 2 s .c o m e = eItem.getChild("expirationDate", getRSSNamespace()); if (e != null) { item.setExpirationDate(DateParser.parseDate(e.getText())); } e = eItem.getChild("description", getRSSNamespace()); if (e != null) { String type = e.getAttributeValue("type"); if (type != null) { item.getDescription().setType(type); } } return item; }
From source file:com.sun.syndication.io.impl.RSS094Parser.java
License:Open Source License
protected WireFeed parseChannel(Element rssRoot) { Channel channel = (Channel) super.parseChannel(rssRoot); Element eChannel = rssRoot.getChild("channel", getRSSNamespace()); List eCats = eChannel.getChildren("category", getRSSNamespace()); channel.setCategories(parseCategories(eCats)); Element eTtl = eChannel.getChild("ttl", getRSSNamespace()); if (eTtl != null && eTtl.getText() != null) { Integer ttlValue = null;//from w ww . ja v a 2 s.c o m try { ttlValue = new Integer(eTtl.getText()); } catch (NumberFormatException nfe) { ; //let it go by } if (ttlValue != null) { channel.setTtl(ttlValue.intValue()); } } return channel; }
From source file:com.sun.syndication.io.impl.RSS094Parser.java
License:Open Source License
public Item parseItem(Element rssRoot, Element eItem) { Item item = super.parseItem(rssRoot, eItem); item.setExpirationDate(null);//from www .jav a 2s .co m Element e = eItem.getChild("author", getRSSNamespace()); if (e != null) { item.setAuthor(e.getText()); } e = eItem.getChild("guid", getRSSNamespace()); if (e != null) { Guid guid = new Guid(); String att = e.getAttributeValue("isPermaLink");//getRSSNamespace()); DONT KNOW WHY DOESN'T WORK if (att != null) { guid.setPermaLink(att.equalsIgnoreCase("true")); } guid.setValue(e.getText()); item.setGuid(guid); } e = eItem.getChild("comments", getRSSNamespace()); if (e != null) { item.setComments(e.getText()); } return item; }
From source file:com.sun.syndication.io.impl.RSS10Parser.java
License:Open Source License
/** * Parses an item element of an RSS document looking for item information. * <p/>/*from w ww . ja v a2 s. c om*/ * It first invokes super.parseItem and then parses and injects the description property if present. * <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 = super.parseItem(rssRoot, eItem); Element e = eItem.getChild("description", getRSSNamespace()); if (e != null) { item.setDescription(parseItemDescription(rssRoot, e)); } Element ce = eItem.getChild("encoded", getContentNamespace()); if (ce != null) { Content content = new Content(); content.setType(Content.HTML); content.setValue(ce.getText()); item.setContent(content); } String uri = eItem.getAttributeValue("about", getRDFNamespace()); if (uri != null) { item.setUri(uri); } return item; }
From source file:com.sun.syndication.io.impl.SyModuleParser.java
License:Open Source License
public Module parse(Element syndRoot) { boolean foundSomething = false; SyModule sm = new SyModuleImpl(); Element e = syndRoot.getChild("updatePeriod", getDCNamespace()); if (e != null) { foundSomething = true;//from ww w.ja va2s . c o m sm.setUpdatePeriod(e.getText()); } e = syndRoot.getChild("updateFrequency", getDCNamespace()); if (e != null) { foundSomething = true; sm.setUpdateFrequency(Integer.parseInt(e.getText().trim())); } e = syndRoot.getChild("updateBase", getDCNamespace()); if (e != null) { foundSomething = true; sm.setUpdateBase(DateParser.parseDate(e.getText())); } return (foundSomething) ? sm : null; }
From source file:com.swordlord.gozer.builder.Parser.java
License:Open Source License
@SuppressWarnings("unchecked") private void parseElement(Element element, ObjectBase parent) { if (!_objectTags.containsKey(element.getName())) { String msg = MessageFormat.format("Element {0} unknown, parsing aborted.", element.getName()); LOG.error(msg);//from w w w.j a v a2s .c o m return; } ObjectBase ob = instantiateClass(_objectTags.get(element.getName())); if (ob == null) { String msg = MessageFormat.format("Class for {0} could not be instantiated, parsing aborted.", element); LOG.error(msg); return; } if (element.getText() != null) { ob.setContent(element.getText()); } List attributes = element.getAttributes(); Iterator itAttributes = attributes.iterator(); while (itAttributes.hasNext()) { Attribute attr = (Attribute) itAttributes.next(); ob.putAttribute(attr.getName(), attr.getValue()); } if (parent != null) { ob.inheritParent(parent); parent.putChild(ob); } else { _objectTree.setRoot(ob); } List children = element.getChildren(); Iterator itChildren = children.iterator(); while (itChildren.hasNext()) { parseElement((Element) itChildren.next(), ob); } }