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