Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ private static void itemTagExtensions(FeedExtensionRegistry<? extends GeoRssChan
registry.addItemExtension("georss:polygon", GeoRssItem::setGeoRssPolygon);
registry.addItemExtension("georss:box", GeoRssItem::setGeoRssBox);
registry.addItemExtension("georss:elev", (item, value) -> mapDouble(value, item::setGeoRssElevation));
registry.addItemExtension("georss:floor", (item, value) -> mapInteger(value, item::setGeoRssFloor));
registry.addItemExtension("georss:floor", (item, value) -> mapInteger(value, item::setGeoRssFloor));
registry.addItemExtension("georss:radius", (item, value) -> mapDouble(value, item::setGeoRssRadius));
registry.addItemExtension("georss:featuretypetag", GeoRssItem::setGeoRssFeatureTypeTag);
registry.addItemExtension("georss:relationshiptag", GeoRssItem::setGeoRssRelationshipTag);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.apptasticsoftware.rssreader.module.slash;

import com.apptasticsoftware.rssreader.Channel;

/**
* Slash RSS module channel interface extending the core Channel with Slash-specific metadata.
* Slash is a module for RSS feeds from Slash-based sites (like Slashdot).
*
* @see SlashItem for item-level Slash extensions
* @see <a href="http://purl.org/rss/1.0/modules/slash/">Slash RSS Module Specification</a>
*/
public interface SlashChannel extends Channel {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package com.apptasticsoftware.rssreader.module.slash;

import com.apptasticsoftware.rssreader.FeedExtensionRegistry;

import static com.apptasticsoftware.rssreader.util.Mapper.mapInteger;

/**
* Utility class for registering Slash RSS module extensions.
* Registers handlers for Slash-specific XML elements during RSS feed parsing.
*/
public class SlashExtensions {

private SlashExtensions() {
// Prevent instantiation
}

/**
* Registers all Slash module extensions with the provided feed extension registry.
*
* @param registry the feed extension registry to register handlers with
*/
public static void register(FeedExtensionRegistry<? extends SlashChannel, ? extends SlashItem> registry) {
itemTagExtensions(registry);
}

/**
* Registers Slash item-level tag extensions.
*
* @param registry the feed extension registry to register handlers with
*/
private static void itemTagExtensions(FeedExtensionRegistry<? extends SlashChannel, ? extends SlashItem> registry) {
registry.addItemExtension("slash:section", SlashItem::setSlashSection);
registry.addItemExtension("slash:department", SlashItem::setSlashDepartment);
registry.addItemExtension("slash:comments", (item, value) -> mapInteger(value, item::setSlashComments));
registry.addItemExtension("slash:hit_parade", SlashItem::setSlashHitParade);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package com.apptasticsoftware.rssreader.module.slash;

import com.apptasticsoftware.rssreader.AbstractRssReader;
import com.apptasticsoftware.rssreader.DateTimeParser;
import com.apptasticsoftware.rssreader.module.slash.internal.SlashChannelImpl;
import com.apptasticsoftware.rssreader.module.slash.internal.SlashItemImpl;

/**
* RSS feed reader with Slash module extensions.
* Provides parsing of RSS feeds that include Slash-specific metadata for items.
*
* @see SlashItem for item-level Slash properties
* @see SlashChannel for channel-level Slash properties
*/
public class SlashFeedReader extends AbstractRssReader<SlashChannel, SlashItem> {

@Override
protected SlashChannel createChannel(DateTimeParser dateTimeParser) {
return new SlashChannelImpl(dateTimeParser);
}

@Override
protected SlashItem createItem(DateTimeParser dateTimeParser) {
return new SlashItemImpl(dateTimeParser);
}

@Override
protected void registerChannelTags() {
super.registerChannelTags();
var registry = getFeedExtensionRegistry();
SlashExtensions.register(registry);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.apptasticsoftware.rssreader.module.slash;

import com.apptasticsoftware.rssreader.Item;

/**
* Slash RSS module item interface extending the core Item with Slash-specific metadata.
* Provides access to item-level Slash elements including section, department, comments count, and hit parade.
*
* @see SlashItemData for the data accessor methods
* @see <a href="http://purl.org/rss/1.0/modules/slash/">Slash RSS Module Specification</a>
*/
public interface SlashItem extends Item, SlashItemData {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
package com.apptasticsoftware.rssreader.module.slash;

import java.util.Optional;

/**
* Interface for accessing Slash RSS module item data.
* Provides methods to get and set Slash-specific metadata including section, department, comments, and hit parade.
*
* @see <a href="http://purl.org/rss/1.0/modules/slash/">Slash RSS Module Specification</a>
*/
public interface SlashItemData {

/**
* Returns the underlying Slash item data object.
*
* @return the Slash item data
*/
SlashItemData getSlashItemData();

/**
* Returns the Slash section (category) of the item.
*
* @return an Optional containing the section, or empty if not set
*/
default Optional<String> getSlashSection() {
return getSlashItemData().getSlashSection();
}

/**
* Sets the Slash section (category) of the item.
*
* @param slashSection the section to set
*/
default void setSlashSection(String slashSection) {
getSlashItemData().setSlashSection(slashSection);
}

/**
* Returns the Slash department of the item.
*
* @return an Optional containing the department, or empty if not set
*/
default Optional<String> getSlashDepartment() {
return getSlashItemData().getSlashDepartment();
}

/**
* Sets the Slash department of the item.
*
* @param slashDepartment the department to set
*/
default void setSlashDepartment(String slashDepartment) {
getSlashItemData().setSlashDepartment(slashDepartment);
}

/**
* Returns the number of comments for the item.
*
* @return an Optional containing the comment count, or empty if not set
*/
default Optional<Integer> getSlashComments() {
return getSlashItemData().getSlashComments();
}

/**
* Sets the number of comments for the item.
*
* @param slashComments the comment count to set
*/
default void setSlashComments(Integer slashComments) {
getSlashItemData().setSlashComments(slashComments);
}

/**
* Returns the Slash hit parade (comma-separated list of view counts).
*
* @return an Optional containing the hit parade, or empty if not set
*/
default Optional<String> getSlashHitParade() {
return getSlashItemData().getSlashHitParade();
}

/**
* Sets the Slash hit parade (comma-separated list of view counts).
*
* @param slashHitParade the hit parade to set
*/
default void setSlashHitParade(String slashHitParade) {
getSlashItemData().setSlashHitParade(slashHitParade);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package com.apptasticsoftware.rssreader.module.slash.internal;

import com.apptasticsoftware.rssreader.DateTimeParser;
import com.apptasticsoftware.rssreader.internal.ChannelImpl;
import com.apptasticsoftware.rssreader.module.slash.SlashChannel;

/**
* Implementation of SlashChannel extending core channel functionality.
*/
public class SlashChannelImpl extends ChannelImpl implements SlashChannel {

/**
* Constructs a SlashChannelImpl with the provided date-time parser.
*
* @param dateTimeParser the parser for parsing date-time values
*/
public SlashChannelImpl(DateTimeParser dateTimeParser) {
super(dateTimeParser);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
package com.apptasticsoftware.rssreader.module.slash.internal;

import com.apptasticsoftware.rssreader.module.slash.SlashItemData;

import java.util.Objects;
import java.util.Optional;

/**
* Implementation of SlashItemData storing Slash-specific item metadata.
*/
public class SlashItemDataImpl implements SlashItemData {
private String slashSection;
private String slashDepartment;
private Integer slashComments;
private String slashHitParade;

@Override
public SlashItemData getSlashItemData() {
return this;
}

/**
* Returns the Slash section of the item.
*
* @return an Optional containing the section, or empty if not set
*/
@Override
public Optional<String> getSlashSection() {
return Optional.ofNullable(slashSection);
}

/**
* Sets the Slash section of the item.
*
* @param slashSection the section to set
*/
@Override
public void setSlashSection(String slashSection) {
this.slashSection = slashSection;
}

/**
* Returns the Slash department of the item.
*
* @return an Optional containing the department, or empty if not set
*/
@Override
public Optional<String> getSlashDepartment() {
return Optional.ofNullable(slashDepartment);
}

/**
* Sets the Slash department of the item.
*
* @param slashDepartment the department to set
*/
@Override
public void setSlashDepartment(String slashDepartment) {
this.slashDepartment = slashDepartment;
}

/**
* Returns the number of comments for the item.
*
* @return an Optional containing the comment count, or empty if not set
*/
@Override
public Optional<Integer> getSlashComments() {
return Optional.ofNullable(slashComments);
}

/**
* Sets the number of comments for the item.
*
* @param slashComments the comment count to set
*/
@Override
public void setSlashComments(Integer slashComments) {
this.slashComments = slashComments;
}

/**
* Returns the Slash hit parade (comma-separated list of view counts).
*
* @return an Optional containing the hit parade, or empty if not set
*/
@Override
public Optional<String> getSlashHitParade() {
return Optional.ofNullable(slashHitParade);
}

/**
* Sets the Slash hit parade (comma-separated list of view counts).
*
* @param slashHitParade the hit parade to set
*/
@Override
public void setSlashHitParade(String slashHitParade) {
this.slashHitParade = slashHitParade;
}

@Override
public boolean equals(Object o) {
if (o == null || getClass() != o.getClass()) return false;
SlashItemDataImpl that = (SlashItemDataImpl) o;
return Objects.equals(getSlashSection(), that.getSlashSection()) && Objects.equals(getSlashDepartment(), that.getSlashDepartment()) && Objects.equals(getSlashComments(), that.getSlashComments()) && Objects.equals(getSlashHitParade(), that.getSlashHitParade());
}

@Override
public int hashCode() {
return Objects.hash(getSlashSection(), getSlashDepartment(), getSlashComments(), getSlashHitParade());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package com.apptasticsoftware.rssreader.module.slash.internal;

import com.apptasticsoftware.rssreader.DateTimeParser;
import com.apptasticsoftware.rssreader.internal.ItemImpl;
import com.apptasticsoftware.rssreader.module.slash.SlashItem;
import com.apptasticsoftware.rssreader.module.slash.SlashItemData;

import java.util.Objects;

/**
* Implementation of SlashItem combining core item functionality with Slash-specific metadata.
*/
public class SlashItemImpl extends ItemImpl implements SlashItem {
private final SlashItemData slashData = new SlashItemDataImpl();

/**
* Constructs a SlashItemImpl with the provided date-time parser.
*
* @param dateTimeParser the parser for parsing date-time values
*/
public SlashItemImpl(DateTimeParser dateTimeParser) {
super(dateTimeParser);
}

@Override
public SlashItemData getSlashItemData() {
return slashData;
}

@Override
public boolean equals(Object o) {
if (!(o instanceof SlashItemImpl)) return false;
if (!super.equals(o)) return false;
SlashItemImpl slashItem = (SlashItemImpl) o;
return Objects.equals(getSlashItemData(), slashItem.getSlashItemData());
}

@Override
public int hashCode() {
return Objects.hash(super.hashCode(), getSlashItemData());
}
}
1 change: 1 addition & 0 deletions src/main/java/module-info.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
exports com.apptasticsoftware.rssreader.module.opensearch;
exports com.apptasticsoftware.rssreader.module.podcast;
exports com.apptasticsoftware.rssreader.module.psc;
exports com.apptasticsoftware.rssreader.module.slash;
exports com.apptasticsoftware.rssreader.module.spotify;
exports com.apptasticsoftware.rssreader.module.wfw;
exports com.apptasticsoftware.rssreader.module.youtube;
Expand Down
Loading