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