Merge pull request #34 from mishako/itunes-order-and-cc

Support for itunes:order and itunes:isClosedCaptioned (fixed). Thanks Misha!
This commit is contained in:
David M. Johnson 2015-11-25 09:30:08 -05:00
commit 07b071e07d
6 changed files with 71 additions and 1 deletions

View file

@ -66,4 +66,11 @@ public interface EntryInformation extends ITunes {
*/
public void setDuration(Duration duration);
public boolean getClosedCaptioned();
public void setClosedCaptioned(boolean closedCaptioned);
public Integer getOrder();
public void setOrder(Integer order);
}

View file

@ -55,6 +55,8 @@ public class EntryInformationImpl extends AbstractITunesObject implements EntryI
*/
private static final long serialVersionUID = 1L;
private Duration duration;
private boolean closedCaptioned;
private Integer order;
/**
* Creates a new instance of EntryInformationImpl
@ -82,6 +84,26 @@ public class EntryInformationImpl extends AbstractITunesObject implements EntryI
this.duration = duration;
}
@Override
public boolean getClosedCaptioned() {
return closedCaptioned;
}
@Override
public void setClosedCaptioned(boolean closedCaptioned) {
this.closedCaptioned = closedCaptioned;
}
@Override
public Integer getOrder() {
return order;
}
@Override
public void setOrder(Integer order) {
this.order = order;
}
/**
* Defined by the ROME module API
*
@ -105,6 +127,8 @@ public class EntryInformationImpl extends AbstractITunesObject implements EntryI
setSubtitle(info.getSubtitle());
setSummary(info.getSummary());
setClosedCaptioned(info.getClosedCaptioned());
setOrder(info.getOrder());
}
/**
@ -123,8 +147,12 @@ public class EntryInformationImpl extends AbstractITunesObject implements EntryI
@Override
public String toString() {
final StringBuffer sb = new StringBuffer("[");
sb.append(" Duration: ");
sb.append(" duration: ");
sb.append(getDuration());
sb.append(" closedCaptioned: ");
sb.append(getClosedCaptioned());
sb.append(" order: ");
sb.append(getOrder());
sb.append("]");
sb.append(super.toString());

View file

@ -124,6 +124,12 @@ public class ITunesGenerator implements ModuleGenerator {
if (info.getDuration() != null) {
element.addContent(generateSimpleElement("duration", info.getDuration().toString()));
}
if (info.getClosedCaptioned()) {
element.addContent(generateSimpleElement("isClosedCaptioned", "yes"));
}
if (info.getOrder() != null) {
element.addContent(generateSimpleElement("order", info.getOrder().toString()));
}
}
if (itunes.getAuthor() != null) {

View file

@ -151,6 +151,19 @@ public class ITunesParser implements ModuleParser {
final Duration dur = new Duration(duration.getValue().trim());
entryInfo.setDuration(dur);
}
final Element closedCaptioned = element.getChild("isClosedCaptioned", ns);
if (closedCaptioned != null && closedCaptioned.getValue() != null && closedCaptioned.getValue().trim().equalsIgnoreCase("yes")) {
entryInfo.setClosedCaptioned(true);
}
final Element order = element.getChild("order", ns);
if (order != null && order.getValue() != null) {
final Integer o = Integer.valueOf(order.getValue().trim());
entryInfo.setOrder(o);
}
}
if (module != null) {
// All these are common to both Channel and Item

View file

@ -103,4 +103,18 @@ public class ITunesParserTest extends AbstractTestCase {
}
}
/**
* Test of parse method, of class com.rometools.modules.itunes.io.ITunesParser.
*/
public void testParseItem() throws Exception {
File feed = new File(getTestFile("xml/leshow.xml"));
final SyndFeedInput input = new SyndFeedInput();
SyndFeed syndfeed = input.build(new XmlReader(feed.toURI().toURL()));
SyndEntry entry = syndfeed.getEntries().get(0);
EntryInformationImpl entryInfo = (EntryInformationImpl) entry.getModule(AbstractITunesObject.URI);
assertEquals(true, entryInfo.getClosedCaptioned());
assertEquals(Integer.valueOf(2), entryInfo.getOrder());
}
}

View file

@ -66,6 +66,8 @@
<itunes:duration>46:34</itunes:duration>
<itunes:keywords></itunes:keywords>
<itunes:isClosedCaptioned>yes</itunes:isClosedCaptioned>
<itunes:order>2</itunes:order>
</item>