Skip to content

Commit a59bf9b

Browse files
authored
Atom module support (#347)
1 parent 3b73068 commit a59bf9b

22 files changed

Lines changed: 974 additions & 4 deletions

src/main/java/com/apptasticsoftware/rssreader/FeedChannel.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.apptasticsoftware.rssreader;
22

3+
import com.apptasticsoftware.rssreader.module.atom.AtomChannel;
34
import com.apptasticsoftware.rssreader.module.dc.DcChannel;
45
import com.apptasticsoftware.rssreader.module.georss.GeoRssChannel;
56
import com.apptasticsoftware.rssreader.module.itunes.ItunesChannel;
@@ -12,5 +13,5 @@
1213
import com.apptasticsoftware.rssreader.module.wfw.WfwChannel;
1314
import com.apptasticsoftware.rssreader.module.youtube.YoutubeChannel;
1415

15-
public interface FeedChannel extends Channel, DcChannel, GeoRssChannel, ItunesChannel, MediaRssChannel, OpenSearchChannel, PodcastChannel, PscChannel, SlashChannel, SpotifyChannel, WfwChannel, YoutubeChannel {
16+
public interface FeedChannel extends Channel, AtomChannel, DcChannel, GeoRssChannel, ItunesChannel, MediaRssChannel, OpenSearchChannel, PodcastChannel, PscChannel, SlashChannel, SpotifyChannel, WfwChannel, YoutubeChannel {
1617
}

src/main/java/com/apptasticsoftware/rssreader/FeedItem.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.apptasticsoftware.rssreader;
22

3+
import com.apptasticsoftware.rssreader.module.atom.AtomItem;
34
import com.apptasticsoftware.rssreader.module.dc.DcItem;
45
import com.apptasticsoftware.rssreader.module.georss.GeoRssItem;
56
import com.apptasticsoftware.rssreader.module.itunes.ItunesItem;
@@ -12,6 +13,6 @@
1213
import com.apptasticsoftware.rssreader.module.wfw.WfwItem;
1314
import com.apptasticsoftware.rssreader.module.youtube.YoutubeItem;
1415

15-
public interface FeedItem extends Item, DcItem, GeoRssItem, ItunesItem, MediaRssItem, OpenSearchItem, PodcastItem, PscItem, SlashItem, SpotifyItem, WfwItem, YoutubeItem {
16+
public interface FeedItem extends Item, AtomItem, DcItem, GeoRssItem, ItunesItem, MediaRssItem, OpenSearchItem, PodcastItem, PscItem, SlashItem, SpotifyItem, WfwItem, YoutubeItem {
1617

1718
}

src/main/java/com/apptasticsoftware/rssreader/FeedReader.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import com.apptasticsoftware.rssreader.internal.FeedChannelImpl;
44
import com.apptasticsoftware.rssreader.internal.FeedItemImpl;
5+
import com.apptasticsoftware.rssreader.module.atom.AtomExtensions;
56
import com.apptasticsoftware.rssreader.module.dc.DcExtensions;
67
import com.apptasticsoftware.rssreader.module.georss.GeoRssExtensions;
78
import com.apptasticsoftware.rssreader.module.itunes.ItunesExtensions;
@@ -30,6 +31,7 @@ protected FeedItem createItem(DateTimeParser dateTimeParser) {
3031
protected void registerChannelTags() {
3132
super.registerChannelTags();
3233
var registry = getFeedExtensionRegistry();
34+
AtomExtensions.register(registry);
3335
DcExtensions.register(registry);
3436
GeoRssExtensions.register(registry);
3537
ItunesExtensions.register(registry);

src/main/java/com/apptasticsoftware/rssreader/internal/FeedChannelImpl.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
import com.apptasticsoftware.rssreader.DateTimeParser;
44
import com.apptasticsoftware.rssreader.FeedChannel;
5+
import com.apptasticsoftware.rssreader.module.atom.AtomChannelData;
6+
import com.apptasticsoftware.rssreader.module.atom.internal.AtomChannelDataImpl;
57
import com.apptasticsoftware.rssreader.module.dc.DcChannelData;
68
import com.apptasticsoftware.rssreader.module.dc.internal.DcChannelDataImpl;
79
import com.apptasticsoftware.rssreader.module.georss.GeoRssChannelData;
@@ -22,6 +24,7 @@
2224
import java.util.Objects;
2325

2426
public class FeedChannelImpl extends ChannelImpl implements FeedChannel {
27+
private final AtomChannelData atomChannelData = new AtomChannelDataImpl();
2528
private final DcChannelData dcChannelData = new DcChannelDataImpl();
2629
private final GeoRssChannelData geoRssChannelData = new GeoRssChannelDataImpl();
2730
private final ItunesChannelData itunesChannelData = new ItunesChannelDataImpl();
@@ -40,6 +43,11 @@ public FeedChannelImpl(DateTimeParser dateTimeParser) {
4043
super(dateTimeParser);
4144
}
4245

46+
@Override
47+
public AtomChannelData getAtomChannelData() {
48+
return atomChannelData;
49+
}
50+
4351
@Override
4452
public DcChannelData getDcChannelData() {
4553
return dcChannelData;

src/main/java/com/apptasticsoftware/rssreader/internal/FeedItemImpl.java

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
import com.apptasticsoftware.rssreader.DateTimeParser;
44
import com.apptasticsoftware.rssreader.FeedItem;
5+
import com.apptasticsoftware.rssreader.module.atom.AtomItemData;
6+
import com.apptasticsoftware.rssreader.module.atom.internal.AtomItemDataImpl;
57
import com.apptasticsoftware.rssreader.module.dc.DcItemData;
68
import com.apptasticsoftware.rssreader.module.dc.internal.DcItemDataImpl;
79
import com.apptasticsoftware.rssreader.module.georss.GeoRssItemData;
@@ -24,7 +26,8 @@
2426
import java.util.Objects;
2527

2628
public class FeedItemImpl extends ItemImpl implements FeedItem {
27-
private final DcItemData dcChannelData = new DcItemDataImpl();
29+
private final AtomItemData atomItemData = new AtomItemDataImpl();
30+
private final DcItemData dcItemData = new DcItemDataImpl();
2831
private final GeoRssItemData geoRssItemData = new GeoRssItemDataImpl();
2932
private final ItunesItemData itunesItemData = new ItunesItemDataImpl();
3033
private final MediaRssItemData mediaRssItemData = new MediaRssItemDataImpl();
@@ -44,9 +47,14 @@ public FeedItemImpl(DateTimeParser dateTimeParser) {
4447
podcastItemData = new PodcastItemDataImpl(dateTimeParser);
4548
}
4649

50+
@Override
51+
public AtomItemData getAtomItemData() {
52+
return atomItemData;
53+
}
54+
4755
@Override
4856
public DcItemData getDcItemData() {
49-
return dcChannelData;
57+
return dcItemData;
5058
}
5159

5260
@Override
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
package com.apptasticsoftware.rssreader.module.atom;
2+
3+
/**
4+
* Represents an Atom author element describing a person, corporation, or similar entity.
5+
* Contains one required element (name) and two optional elements (uri, email).
6+
*/
7+
public class AtomAuthor {
8+
String name;
9+
String uri;
10+
String email;
11+
12+
/**
13+
* Gets the human-readable name for the person.
14+
*
15+
* @return the name
16+
*/
17+
public String getName() {
18+
return name;
19+
}
20+
21+
/**
22+
* Sets the human-readable name for the person.
23+
*
24+
* @param name the name
25+
*/
26+
public void setName(String name) {
27+
this.name = name;
28+
}
29+
30+
/**
31+
* Gets the home page for the person.
32+
*
33+
* @return the URI
34+
*/
35+
public String getUri() {
36+
return uri;
37+
}
38+
39+
/**
40+
* Sets the home page for the person.
41+
*
42+
* @param uri the URI
43+
*/
44+
public void setUri(String uri) {
45+
this.uri = uri;
46+
}
47+
48+
/**
49+
* Gets the email address for the person.
50+
*
51+
* @return the email address
52+
*/
53+
public String getEmail() {
54+
return email;
55+
}
56+
57+
/**
58+
* Sets the email address for the person.
59+
*
60+
* @param email the email address
61+
*/
62+
public void setEmail(String email) {
63+
this.email = email;
64+
}
65+
66+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package com.apptasticsoftware.rssreader.module.atom;
2+
3+
import com.apptasticsoftware.rssreader.Channel;
4+
5+
/**
6+
* Represents an Atom feed channel, combining standard RSS channel fields with Atom-specific data.
7+
*/
8+
public interface AtomChannel extends Channel, AtomChannelData {
9+
10+
/**
11+
* Returns the Atom channel data.
12+
*
13+
* @return the Atom channel data
14+
*/
15+
AtomChannelData getAtomChannelData();
16+
}
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
package com.apptasticsoftware.rssreader.module.atom;
2+
3+
import java.util.List;
4+
5+
/**
6+
* Provides access to Atom-specific data for a feed channel, including links, authors, and contributors.
7+
*/
8+
public interface AtomChannelData {
9+
10+
/**
11+
* Returns the underlying Atom channel data.
12+
* @return the Atom channel data
13+
*/
14+
AtomChannelData getAtomChannelData();
15+
16+
/**
17+
* Returns the list of Atom links.
18+
* @return the list of Atom links
19+
*/
20+
default List<AtomLink> getAtomLinks() {
21+
return getAtomChannelData().getAtomLinks();
22+
}
23+
24+
/**
25+
* Adds an Atom link.
26+
* @param atomLink the Atom link to add
27+
*/
28+
default void addAtomLink(AtomLink atomLink) {
29+
getAtomChannelData().addAtomLink(atomLink);
30+
}
31+
32+
/**
33+
* Returns the list of Atom authors.
34+
* @return the list of Atom authors
35+
*/
36+
default List<AtomAuthor> getAtomAuthors() {
37+
return getAtomChannelData().getAtomAuthors();
38+
}
39+
40+
/**
41+
* Adds an Atom author.
42+
* @param atomAuthor the Atom author to add
43+
*/
44+
default void addAtomAuthor(AtomAuthor atomAuthor) {
45+
getAtomChannelData().addAtomAuthor(atomAuthor);
46+
}
47+
48+
/**
49+
* Returns the list of Atom contributors.
50+
* @return the list of Atom contributors
51+
*/
52+
default List<AtomContributor> getAtomContributors() {
53+
return getAtomChannelData().getAtomContributors();
54+
}
55+
56+
/**
57+
* Adds an Atom contributor.
58+
* @param atomContributor the Atom contributor to add
59+
*/
60+
default void addAtomContributor(AtomContributor atomContributor) {
61+
getAtomChannelData().addAtomContributor(atomContributor);
62+
}
63+
}
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
package com.apptasticsoftware.rssreader.module.atom;
2+
3+
/**
4+
* Represents an Atom author element describing a person, corporation, or similar entity.
5+
* Contains one required element (name) and two optional elements (uri, email).
6+
*/
7+
public class AtomContributor {
8+
String name;
9+
String uri;
10+
String email;
11+
12+
/**
13+
* Gets the human-readable name for the person.
14+
*
15+
* @return the name
16+
*/
17+
public String getName() {
18+
return name;
19+
}
20+
21+
/**
22+
* Sets the human-readable name for the person.
23+
*
24+
* @param name the name
25+
*/
26+
public void setName(String name) {
27+
this.name = name;
28+
}
29+
30+
/**
31+
* Gets the home page for the person.
32+
*
33+
* @return the URI
34+
*/
35+
public String getUri() {
36+
return uri;
37+
}
38+
39+
/**
40+
* Sets the home page for the person.
41+
*
42+
* @param uri the URI
43+
*/
44+
public void setUri(String uri) {
45+
this.uri = uri;
46+
}
47+
48+
/**
49+
* Gets the email address for the person.
50+
*
51+
* @return the email address
52+
*/
53+
public String getEmail() {
54+
return email;
55+
}
56+
57+
/**
58+
* Sets the email address for the person.
59+
*
60+
* @param email the email address
61+
*/
62+
public void setEmail(String email) {
63+
this.email = email;
64+
}
65+
66+
}

0 commit comments

Comments
 (0)