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 org.apache.juneau.bean.atom.*;
020import org.apache.juneau.xml.*;
021
022/**
023 * Atom feed XML example.
024 *
025 * <h5 class='section'>See Also:</h5><ul>
026 * </ul>
027 */
028public class AtomXmlExample {
029
030   /**
031    * XML Atom feed example.
032    *
033    * @param args Unused.
034    * @throws Exception Unused.
035    */
036   @SuppressWarnings("unused")
037   public static void main(String[] args) throws Exception {
038
039
040      Feed feed = AtomFeed.getAtomFeed();
041
042      // Example with no namespaces
043      // Create a serializer with readable output, no namespaces yet.
044      XmlSerializer s = XmlSerializer.create().sq().ws().build();
045
046      //Produces
047      /**
048       *<feed>
049       *<id> tag:juneau.apache.org</id>
050       *<link href='http://juneau.apache.org/' rel='alternate' type='text/html' hreflang='en'/>
051       *<link href='http://juneau.apache.org/feed.atom' rel='self' type='application/atom+xml'/>
052       *<title type='text'>Juneau ATOM specification</title>
053       *<updated>2016-01-02T03:04:05Z</updated>
054       *<generator uri='http://juneau.apache.org/' version='1.0'>Juneau</generator>
055       *<subtitle type='html'>Describes <em>stuff</em> about Juneau</subtitle>
056       *<entry>
057       *  <author>
058       *      <name>Jane Smith</name>
059       *      <uri>http://juneau.apache.org/</uri>
060       *      <email>janesmith@apache.org</email>
061       *  </author>
062       *  <contributor>
063       *      <name>John Smith</name>
064       *  </contributor>
065       *  <id>tag:juneau.apache.org</id>
066       *  <link href='http://juneau.apache.org/juneau.atom' rel='alternate' type='text/html'/>
067       *  <link href='http://juneau.apache.org/audio/juneau_podcast.mp3' rel='enclosure' type='audio/mpeg' length='12345'/>
068       *  <title>Juneau ATOM specification snapshot</title>
069       *  <updated>2016-01-02T03:04:05Z</updated>
070       *  <content base='http://www.apache.org/' lang='en' type='xhtml'>
071       *      <div xmlns="http://www.w3.org/1999/xhtml"><p><i>[Update: Juneau supports ATOM.]</i></p></div>
072       *  </content>
073       *  <published>2016-01-02T03:04:05Z</published>
074       *</entry>
075       *</feed>
076       */
077      //Serialize to ATOM/XML
078      String atomXml = s.serialize(feed);
079
080      /**
081       * Produces
082       * <feed>
083       * <link hreflang='en' rel='alternate' href='http://juneau.apache.org' type='text/html'/>
084       * <link rel='self' href='http://juneau.apache.org/feed.atom' type='application/atom+xml'/>
085       * <title>Juneau ATOM specification</title>
086       * <updated>2016-01-02T03:04:05Z</updated>
087       * <id>tag:juneau.apache.org</id>
088       * <subtitle type='html'>Describes <em>stuff</em> about Juneau</subtitle>
089       * <generator version='1.0' uri='http://juneau.apache.org'>Juneau</generator>
090       * <entry>
091       *  <link rel='alternate' href='http://juneau.apache.org/juneau.atom' type='text/html'/>
092       *  <link rel='enclosure' href='http://juneau.apache.org/audio/juneau_podcast.mp3' type='audio/mpeg' length='1337'/>
093       *  <author>
094       *      <uri>http://juneau.apache.org</uri>
095       *      <email>janesmith@apache.org</email>
096       *      <name>Jane Smith</name>
097       *  </author>
098       *  <contributor>
099       *      <name>John Smith</name>
100       *  </contributor>
101       *  <title>Juneau ATOM specification snapshot</title>
102       *  <updated>2016-01-02T03:04:05Z</updated>
103       *  <id>tag:juneau.sample.com,2013:1.2345</id>
104       *  <published>2016-01-02T03:04:05Z</published>
105       *  <content lang='en' base='http://www.apache.org/' type='xhtml'><div><p><i>[Update: Juneau supports ATOM.]</i></p></div></content>
106       * </entry>
107       * </feed>
108       */
109      // Create a serializer with readable output, no namespaces yet.
110      XmlSerializer ns = XmlSerializer.create().sq().ws().build();
111
112      // Serialize to ATOM/XML
113      atomXml = ns.serialize(feed);
114   }
115}