diff --git a/src/main/java/com/rometools/rome/feed/synd/SyndImage.java b/src/main/java/com/rometools/rome/feed/synd/SyndImage.java index a44d781..80ce393 100644 --- a/src/main/java/com/rometools/rome/feed/synd/SyndImage.java +++ b/src/main/java/com/rometools/rome/feed/synd/SyndImage.java @@ -63,6 +63,42 @@ public interface SyndImage extends Cloneable, CopyFrom { */ void setUrl(String url); + /** + * Returns the image width. + *

+ * + * @return the image width, null if none. + * + */ + public Integer getWidth(); + + /** + * Sets the image width. + *

+ * + * @param width the image width to set, null if none. + * + */ + public void setWidth(Integer width); + + /** + * Returns the image height. + *

+ * + * @return the image height, null if none. + * + */ + public Integer getHeight(); + + /** + * Sets the image height. + *

+ * + * @param height the image height to set, null if none. + * + */ + public void setHeight(Integer height); + /** * Returns the image link. *

diff --git a/src/main/java/com/rometools/rome/feed/synd/SyndImageImpl.java b/src/main/java/com/rometools/rome/feed/synd/SyndImageImpl.java index 419a174..ace4d71 100644 --- a/src/main/java/com/rometools/rome/feed/synd/SyndImageImpl.java +++ b/src/main/java/com/rometools/rome/feed/synd/SyndImageImpl.java @@ -42,6 +42,8 @@ public class SyndImageImpl implements Serializable, SyndImage { private String title; private String url; + private Integer width; + private Integer height; private String link; private String description; @@ -50,6 +52,8 @@ public class SyndImageImpl implements Serializable, SyndImage { basePropInterfaceMap.put("title", String.class); basePropInterfaceMap.put("url", String.class); basePropInterfaceMap.put("link", String.class); + basePropInterfaceMap.put("width", Integer.class); + basePropInterfaceMap.put("height", Integer.class); basePropInterfaceMap.put("description", String.class); final Map, Class> basePropClassImplMap = Collections., Class> emptyMap(); @@ -143,6 +147,7 @@ public class SyndImageImpl implements Serializable, SyndImage { this.title = title; } + /** * Returns the image URL. *

@@ -167,6 +172,54 @@ public class SyndImageImpl implements Serializable, SyndImage { this.url = url; } + /** + * Returns the image width. + *

+ * + * @return the image width, null if none. + * + */ + @Override + public Integer getWidth() { + return width; + } + + /** + * Sets the image width. + *

+ * + * @param width the image width to set, null if none. + * + */ + @Override + public void setWidth(Integer width) { + this.width = width; + } + + /** + * Returns the image height. + *

+ * + * @return the image height, null if none. + * + */ + @Override + public Integer getHeight() { + return height; + } + + /** + * Sets the image height. + *

+ * + * @param height the image height to set, null if none. + * + */ + @Override + public void setHeight(Integer height) { + this.height = height; + } + /** * Returns the image link. *

diff --git a/src/main/java/com/rometools/rome/feed/synd/impl/ConverterForRSS090.java b/src/main/java/com/rometools/rome/feed/synd/impl/ConverterForRSS090.java index cf9aed1..d5a6fc3 100644 --- a/src/main/java/com/rometools/rome/feed/synd/impl/ConverterForRSS090.java +++ b/src/main/java/com/rometools/rome/feed/synd/impl/ConverterForRSS090.java @@ -90,6 +90,8 @@ public class ConverterForRSS090 implements Converter { syndImage.setTitle(rssImage.getTitle()); syndImage.setUrl(rssImage.getUrl()); syndImage.setLink(rssImage.getLink()); + syndImage.setWidth(rssImage.getWidth()); + syndImage.setHeight(rssImage.getHeight()); return syndImage; } diff --git a/src/main/java/com/rometools/rome/io/impl/RSS20Generator.java b/src/main/java/com/rometools/rome/io/impl/RSS20Generator.java index 1485812..1d2839b 100644 --- a/src/main/java/com/rometools/rome/io/impl/RSS20Generator.java +++ b/src/main/java/com/rometools/rome/io/impl/RSS20Generator.java @@ -62,6 +62,8 @@ public class RSS20Generator extends RSS094Generator { eChannel.addContent(generateCategoryElement(category)); } + generateForeignMarkup(eChannel, channel.getForeignMarkup()); + } @Override diff --git a/src/test/java/com/rometools/rome/unittest/SyndFeedTest.java b/src/test/java/com/rometools/rome/unittest/SyndFeedTest.java index 2453268..c9c2741 100644 --- a/src/test/java/com/rometools/rome/unittest/SyndFeedTest.java +++ b/src/test/java/com/rometools/rome/unittest/SyndFeedTest.java @@ -7,6 +7,7 @@ import java.util.Locale; import com.rometools.rome.feed.synd.SyndEntry; import com.rometools.rome.feed.synd.SyndImage; import com.rometools.rome.io.impl.DateParser; +import org.junit.Assert; /** * @author pat @@ -34,6 +35,9 @@ public abstract class SyndFeedTest extends FeedTest { protected void assertEqualsStr(final String expected, final String actual) { assertEquals(prefix + "." + expected, actual); } + protected void assertEqualsInt(final int expected, final int actual) { + Assert.assertEquals(expected, actual); + } public void testPreserveWireFeed() throws Exception { assertNotNull(this.getCachedSyndFeed(true).originalWireFeed()); @@ -73,13 +77,14 @@ public abstract class SyndFeedTest extends FeedTest { assertEquals(DateParser.parseRFC822("Mon, 01 Jan 2001 00:00:00 GMT", Locale.US), this.getCachedSyndFeed().getPublishedDate()); } - // how do i get height and width? public void testImage() throws Exception { final SyndImage img = this.getCachedSyndFeed().getImage(); assertEqualsStr("channel.image.description", img.getDescription()); assertEqualsStr("channel.image.link", img.getLink()); assertEqualsStr("channel.image.title", img.getTitle()); assertEqualsStr("channel.image.url", img.getUrl()); + assertEqualsInt(100, img.getWidth()); + assertEqualsInt(200, img.getHeight()); } public void testEntries() throws Exception {