private void processChannel(Element element, IFeed feed) { /* Interpret Attributes */ List<?> attributes = element.getAttributes(); for (Iterator<?> iter = attributes.iterator(); iter.hasNext(); ) { Attribute attribute = (Attribute) iter.next(); /* Check wether this Attribute is to be processed by a Contribution */ processAttributeExtern(attribute, feed); } /* Interpret Children */ List<?> channelChildren = element.getChildren(); for (Iterator<?> iter = channelChildren.iterator(); iter.hasNext(); ) { Element child = (Element) iter.next(); String name = child.getName().toLowerCase(); /* Check wether this Element is to be processed by a Contribution */ if (processElementExtern(child, feed)) continue; /* Item */ else if ("item".equals(name)) // $NON-NLS-1$ processItems(child, feed); /* Title */ else if ("title".equals(name)) { // $NON-NLS-1$ feed.setTitle(child.getText()); processNamespaceAttributes(child, feed); } /* Link */ else if ("link".equals(name)) { // $NON-NLS-1$ URI uri = URIUtils.createURI(child.getText()); /* * Do not use the URI if it is empty. This is a workaround for * FeedBurner feeds that use a Atom 1.0 Link Element in place of an RSS * feed which RSSOwl 2 is not yet able to handle on this scope. */ if (uri != null && StringUtils.isSet(uri.toString())) feed.setHomepage(uri); processNamespaceAttributes(child, feed); } /* Description */ else if ("description".equals(name)) { // $NON-NLS-1$ feed.setDescription(child.getText()); processNamespaceAttributes(child, feed); } /* Publish Date */ else if ("pubdate".equals(name)) { // $NON-NLS-1$ feed.setPublishDate(DateUtils.parseDate(child.getText())); processNamespaceAttributes(child, feed); } /* Image */ else if ("image".equals(name)) // $NON-NLS-1$ processImage(child, feed); /* Language */ else if ("language".equals(name)) { // $NON-NLS-1$ feed.setLanguage(child.getText()); processNamespaceAttributes(child, feed); } /* Copyright */ else if ("copyright".equals(name)) { // $NON-NLS-1$ feed.setCopyright(child.getText()); processNamespaceAttributes(child, feed); } /* Webmaster */ else if ("webmaster".equals(name)) { // $NON-NLS-1$ feed.setWebmaster(child.getText()); processNamespaceAttributes(child, feed); } /* Managing Editor */ else if ("managingeditor".equals(name)) { // $NON-NLS-1$ IPerson person = Owl.getModelFactory().createPerson(null, feed); person.setName(child.getText()); processNamespaceAttributes(child, person); } /* Last Build Date */ else if ("lastbuilddate".equals(name)) { // $NON-NLS-1$ feed.setLastBuildDate(DateUtils.parseDate(child.getText())); processNamespaceAttributes(child, feed); } /* Category */ else if ("category".equals(name)) // $NON-NLS-1$ processCategory(child, feed); /* Generator */ else if ("generator".equals(name)) { // $NON-NLS-1$ feed.setGenerator(child.getText()); processNamespaceAttributes(child, feed); } /* Docs */ else if ("docs".equals(name)) { // $NON-NLS-1$ URI uri = URIUtils.createURI(child.getText()); if (uri != null) feed.setDocs(uri); processNamespaceAttributes(child, feed); } /* Rating */ else if ("rating".equals(name)) { // $NON-NLS-1$ feed.setRating(child.getText()); processNamespaceAttributes(child, feed); } /* TTL */ else if ("ttl".equals(name)) { // $NON-NLS-1$ int ttl = StringUtils.stringToInt(child.getTextNormalize()); if (ttl >= 0) feed.setTTL(ttl); processNamespaceAttributes(child, feed); } /* Skip Hours */ else if ("skiphours".equals(name)) { // $NON-NLS-1$ processNamespaceAttributes(child, feed); List<?> skipHoursChildren = child.getChildren("hour"); // $NON-NLS-1$ /* For each <hour> Element */ for (Iterator<?> iterator = skipHoursChildren.iterator(); iterator.hasNext(); ) { Element skipHour = (Element) iterator.next(); processNamespaceAttributes(skipHour, feed); int hour = StringUtils.stringToInt(skipHour.getTextNormalize()); if (0 <= hour && hour < 24) feed.addHourToSkip(hour); } } /* Skip Days */ else if ("skipdays".equals(name)) { // $NON-NLS-1$ processNamespaceAttributes(child, feed); List<?> skipDaysChildren = child.getChildren("day"); // $NON-NLS-1$ /* For each <day> Element */ for (Iterator<?> iterator = skipDaysChildren.iterator(); iterator.hasNext(); ) { Element skipDay = (Element) iterator.next(); processNamespaceAttributes(skipDay, feed); String day = skipDay.getText().toLowerCase(); int index = IFeed.DAYS.indexOf(day); if (index >= 0) feed.addDayToSkip(index); } } /* TextInput */ else if ("textinput".equals(name)) // $NON-NLS-1$ processTextInput(child, feed); /* Cloud */ else if ("cloud".equals(name)) // $NON-NLS-1$ processCloud(child, feed); } }
private void processItems(Element element, IFeed feed) { INews news = Owl.getModelFactory() .createNews(null, feed, new Date(System.currentTimeMillis() - (fNewsCounter++ * 1))); news.setBase(feed.getBase()); /* Check wether the Attributes are to be processed by a Contribution */ processNamespaceAttributes(element, news); /* Interpret Children */ List<?> newsChilds = element.getChildren(); for (Iterator<?> iter = newsChilds.iterator(); iter.hasNext(); ) { Element child = (Element) iter.next(); String name = child.getName().toLowerCase(); /* Check wether this Element is to be processed by a Contribution */ if (processElementExtern(child, news)) continue; /* Title */ else if ("title".equals(name)) { // $NON-NLS-1$ news.setTitle(child.getText()); processNamespaceAttributes(child, news); } /* Link */ else if ("link".equals(name)) { // $NON-NLS-1$ URI uri = URIUtils.createURI(child.getText()); if (uri != null) { news.setLink(uri); itemUrl = child.getText(); } processNamespaceAttributes(child, news); } /* Description */ else if ("description".equals(name)) { // $NON-NLS-1$ if (!Owl.getPreferenceService().getGlobalScope().getBoolean(DefaultPreferences.HIDE_LIKE)) { news.setDescription(child.getText() + FacebookLikeUtil.getButtonCode(itemUrl)); processNamespaceAttributes(child, news); } else { news.setDescription(child.getText()); processNamespaceAttributes(child, news); } } /* Publish Date */ else if ("pubdate".equals(name)) { // $NON-NLS-1$ news.setPublishDate(DateUtils.parseDate(child.getText())); processNamespaceAttributes(child, news); } /* Author */ else if ("author".equals(name)) { // $NON-NLS-1$ IPerson person = Owl.getModelFactory().createPerson(null, news); person.setName(child.getText()); processNamespaceAttributes(child, person); } /* Comments */ else if ("comments".equals(name)) { // $NON-NLS-1$ news.setComments(child.getText()); processNamespaceAttributes(child, news); } /* Attachment */ else if ("enclosure".equals(name)) // $NON-NLS-1$ processEnclosure(child, news); /* Category */ else if ("category".equals(name)) // $NON-NLS-1$ processCategory(child, news); /* GUID */ else if ("guid".equals(name)) // $NON-NLS-1$ processGuid(child, news); /* Source */ else if ("source".equals(name)) // $NON-NLS-1$ processSource(child, news); } }