~ubuntu-branches/ubuntu/saucy/restlet/saucy

« back to all changes in this revision

Viewing changes to org.restlet.example/src/org/restlet/example/book/restlet/ch07/sec2/sub2/MailClient.java

  • Committer: Package Import Robot
  • Author(s): James Page
  • Date: 2012-06-11 16:25:45 UTC
  • Revision ID: package-import@ubuntu.com-20120611162545-5w2o0resi5y3pybc
Tags: upstream-2.0.14
ImportĀ upstreamĀ versionĀ 2.0.14

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/**
 
2
 * Copyright 2005-2012 Restlet S.A.S.
 
3
 * 
 
4
 * The contents of this file are subject to the terms of one of the following
 
5
 * open source licenses: Apache 2.0 or LGPL 3.0 or LGPL 2.1 or CDDL 1.0 or EPL
 
6
 * 1.0 (the "Licenses"). You can select the license that you prefer but you may
 
7
 * not use this file except in compliance with one of these Licenses.
 
8
 * 
 
9
 * You can obtain a copy of the Apache 2.0 license at
 
10
 * http://www.opensource.org/licenses/apache-2.0
 
11
 * 
 
12
 * You can obtain a copy of the LGPL 3.0 license at
 
13
 * http://www.opensource.org/licenses/lgpl-3.0
 
14
 * 
 
15
 * You can obtain a copy of the LGPL 2.1 license at
 
16
 * http://www.opensource.org/licenses/lgpl-2.1
 
17
 * 
 
18
 * You can obtain a copy of the CDDL 1.0 license at
 
19
 * http://www.opensource.org/licenses/cddl1
 
20
 * 
 
21
 * You can obtain a copy of the EPL 1.0 license at
 
22
 * http://www.opensource.org/licenses/eclipse-1.0
 
23
 * 
 
24
 * See the Licenses for the specific language governing permissions and
 
25
 * limitations under the Licenses.
 
26
 * 
 
27
 * Alternatively, you can obtain a royalty free commercial license with less
 
28
 * limitations, transferable or non-transferable, directly at
 
29
 * http://www.restlet.com/products/restlet-framework
 
30
 * 
 
31
 * Restlet is a registered trademark of Restlet S.A.S.
 
32
 */
 
33
 
 
34
package org.restlet.example.book.restlet.ch07.sec2.sub2;
 
35
 
 
36
import java.util.List;
 
37
 
 
38
import org.restlet.ext.atom.Entry;
 
39
import org.restlet.ext.atom.Feed;
 
40
import org.restlet.resource.ClientResource;
 
41
 
 
42
import com.sun.syndication.feed.synd.SyndEntry;
 
43
import com.sun.syndication.feed.synd.SyndFeed;
 
44
 
 
45
/**
 
46
 * Mail client updating a mail by submitting a form.
 
47
 */
 
48
public class MailClient {
 
49
 
 
50
    public static void main(String[] args) throws Exception {
 
51
        ClientResource mailClient = new ClientResource(
 
52
                "http://localhost:8111/accounts/123/feeds/xyz");
 
53
 
 
54
        // Display the retrieved Atom feed and entries
 
55
        Feed atomFeed = mailClient.get(Feed.class);
 
56
        System.out.println("\nAtom feed: " + atomFeed.getTitle() + "\n");
 
57
 
 
58
        for (Entry entry : atomFeed.getEntries()) {
 
59
            System.out.println("Title  : " + entry.getTitle());
 
60
            System.out.println("Summary: " + entry.getSummary());
 
61
        }
 
62
 
 
63
        // Display the retrieved RSS feed and entries
 
64
        SyndFeed rssFeed = mailClient.get(SyndFeed.class);
 
65
        System.out.println("\nRSS feed: " + rssFeed.getTitle() + "\n");
 
66
 
 
67
        @SuppressWarnings("unchecked")
 
68
        List<SyndEntry> entries = (List<SyndEntry>) rssFeed.getEntries();
 
69
 
 
70
        for (SyndEntry entry : entries) {
 
71
            System.out.println("Title  : " + entry.getTitle());
 
72
            System.out.println("Summary: " + entry.getDescription().getValue());
 
73
        }
 
74
    }
 
75
}