diff --git a/src/main/java/com/rometools/modules/itunes/EntryInformation.java b/src/main/java/com/rometools/modules/itunes/EntryInformation.java index d578179..4710a1e 100644 --- a/src/main/java/com/rometools/modules/itunes/EntryInformation.java +++ b/src/main/java/com/rometools/modules/itunes/EntryInformation.java @@ -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); } diff --git a/src/main/java/com/rometools/modules/itunes/EntryInformationImpl.java b/src/main/java/com/rometools/modules/itunes/EntryInformationImpl.java index b38da1f..d6e16d6 100644 --- a/src/main/java/com/rometools/modules/itunes/EntryInformationImpl.java +++ b/src/main/java/com/rometools/modules/itunes/EntryInformationImpl.java @@ -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()); diff --git a/src/main/java/com/rometools/modules/itunes/io/ITunesGenerator.java b/src/main/java/com/rometools/modules/itunes/io/ITunesGenerator.java index a62e671..aa83fb6 100644 --- a/src/main/java/com/rometools/modules/itunes/io/ITunesGenerator.java +++ b/src/main/java/com/rometools/modules/itunes/io/ITunesGenerator.java @@ -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) { diff --git a/src/main/java/com/rometools/modules/itunes/io/ITunesParser.java b/src/main/java/com/rometools/modules/itunes/io/ITunesParser.java index a01b3a9..2cf2a54 100644 --- a/src/main/java/com/rometools/modules/itunes/io/ITunesParser.java +++ b/src/main/java/com/rometools/modules/itunes/io/ITunesParser.java @@ -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 diff --git a/src/test/java/com/rometools/modules/itunes/ITunesParserTest.java b/src/test/java/com/rometools/modules/itunes/ITunesParserTest.java index 57945c7..9278990 100644 --- a/src/test/java/com/rometools/modules/itunes/ITunesParserTest.java +++ b/src/test/java/com/rometools/modules/itunes/ITunesParserTest.java @@ -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()); + } } diff --git a/src/test/resources/xml/leshow.xml b/src/test/resources/xml/leshow.xml index c5044de..058be86 100644 --- a/src/test/resources/xml/leshow.xml +++ b/src/test/resources/xml/leshow.xml @@ -66,6 +66,8 @@ 46:34 + yes + 2