com.sun.syndication.feed.module.georss.GeoRSSModule Java Examples

The following examples show how to use com.sun.syndication.feed.module.georss.GeoRSSModule. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: GeoRSSData.java    From sis with Apache License 2.0 5 votes vote down vote up
/**
 * Saves the GeoRSS entry to file.
 *
 * @param item
 *            the Item object from Java ROME API containing the GeoRSS entry
 * @param geoRSSModule
 *            the Java ROME API GeoRSSModule to parse geo location
 * @param directory
 *            the path of the directory in which to save the file
 */
public void saveToFile(Item item, GeoRSSModule geoRSSModule,
        String directory) {
  if (!new File(directory).exists()) new File(directory).mkdirs();
    try {
        BufferedWriter writer = new BufferedWriter(new FileWriter(directory
                + filename));
        if (item.getTitle() != null) {
            writer.write("title;" + item.getTitle().replace('\n', ' '));
            writer.newLine();
        }
        if (item.getLink() != null) {
            writer.write("link;" + item.getLink().replace('\n', ' '));
            writer.newLine();
        }
        if (item.getSource() != null) {
            writer.write("source;"
                    + item.getSource().getValue().replace('\n', ' '));
            writer.newLine();
        }
        if (item.getAuthor() != null) {
            writer.write("author;" + item.getAuthor().replace('\n', ' '));
            writer.newLine();
        }
        if (item.getDescription() != null) {
            writer.write("description;"
                    + item.getDescription().getValue().replace('\n', ' '));
            writer.newLine();
        }
        writer.write("pubDate;" + item.getPubDate().toString());
        writer.newLine();
        writer.write("lat;" + geoRSSModule.getPosition().getLatitude());
        writer.newLine();
        writer.write("lon;" + geoRSSModule.getPosition().getLongitude());
        writer.close();
    } catch (IOException e) {
        e.printStackTrace();
    }
}