001// ***************************************************************************************************************************
002// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements.  See the NOTICE file *
003// * distributed with this work for additional information regarding copyright ownership.  The ASF licenses this file        *
004// * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance            *
005// * with the License.  You may obtain a copy of the License at                                                              *
006// *                                                                                                                         *
007// *  http://www.apache.org/licenses/LICENSE-2.0                                                                             *
008// *                                                                                                                         *
009// * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an  *
010// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the License for the        *
011// * specific language governing permissions and limitations under the License.                                              *
012// ***************************************************************************************************************************
013package org.apache.juneau.examples.core.dto.atom;
014
015import org.apache.juneau.dto.atom.Feed;
016
017import static org.apache.juneau.dto.atom.AtomBuilder.*;
018
019import java.net.*;
020
021/**
022 * Atom feed example.
023 *
024 * <h5 class='section'>See Also:</h5><ul>
025 * </ul>
026 */
027public class AtomFeed {
028
029   /**
030    * @return A sample Atom feed.
031    * @throws URISyntaxException Won't happen
032    */
033   public static Feed getAtomFeed() throws URISyntaxException{
034
035      Feed feed =
036         feed("tag:foo.org", "Title", "2016-12-31T05:02:03Z")
037         .setSubtitle(text("html").setText("Subtitle"))
038         .setLinks(
039            link("alternate", "text/html", "http://foo.org/").setHreflang("en"),
040            link("self", "application/atom+xml", "http://foo.org/feed.atom")
041         )
042         .setGenerator(
043            generator("Example Toolkit").setUri("http://www.foo.org/").setVersion("1.0")
044         )
045         .setEntries(
046            entry("tag:foo.org", "Title", "2016-12-31T05:02:03Z")
047            .setLinks(
048               link("alternate", "text/html", "http://foo.org/2005/04/02/atom"),
049               link("enclosure", "audio/mpeg", "http://foo.org/audio/foobar.mp3").setLength(1337)
050            )
051            .setPublished("2016-12-31T05:02:03Z")
052            .setAuthors(
053               person("John Smith").setUri(new URI("http://foo.org/")).setEmail("foo@foo.org")
054            )
055            .setContributors(
056               person("John Smith"),
057               person("Jane Smith")
058            )
059            .setContent(
060               content("xhtml")
061               .setLang("en")
062               .setBase("http://foo.org/")
063               .setText("<div><p><i>[Sample content]</i></p></div>")
064            )
065         );
066
067      return feed;
068
069   }
070}