| <!-- |
| /*************************************************************************************************************************** |
| * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file |
| * distributed with this work for additional information regarding copyright ownership. The ASF licenses this file |
| * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance |
| * with the License. You may obtain a copy of the License at |
| * |
| * http://www.apache.org/licenses/LICENSE-2.0 |
| * |
| * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an |
| * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the |
| * specific language governing permissions and limitations under the License. |
| ***************************************************************************************************************************/ |
| --> |
| |
| Atom |
| |
| <p> |
| The Juneau ATOM feed DTOs are simply beans with fluent-style setters. |
| The following code shows a feed being created programmatically using the |
| {@link oaj.dto.atom.AtomBuilder} class. |
| </p> |
| <p class='bpcode w800'> |
| <jk>import static</jk> org.apache.juneau.dto.atom.AtomBuilder.*; |
| |
| Feed feed = |
| <jsm>feed</jsm>(<js>"tag:juneau.apache.org"</js>, <js>"Juneau ATOM specification"</js>, <js>"2016-01-02T03:04:05Z"</js>) |
| .subtitle(<jsm>text</jsm>(<js>"html"</js>).text(<js>"Describes <em>stuff</em> about Juneau"</js>)) |
| .links( |
| <jsm>link</jsm>(<js>"alternate"</js>, <js>"text/html"</js>, <js>"http://juneau.apache.org"</js>).hreflang(<js>"en"</js>), |
| <jsm>link</jsm>(<js>"self"</js>, <js>"application/atom+xml"</js>, <js>"http://juneau.apache.org/feed.atom"</js>) |
| ) |
| .rights(<js>"Copyright (c) ..."</js>) |
| .generator( |
| <jsm>generator</jsm>(<js>"Juneau"</js>).uri(<js>"http://juneau.apache.org/"</js>).version(<js>"1.0"</js>) |
| ) |
| .entries( |
| <jsm>entry</jsm>(<js>"tag:juneau.sample.com,2013:1.2345"</js>, <js>"Juneau ATOM specification snapshot"</js>, <js>"2016-01-02T03:04:05Z"</js>) |
| .links( |
| <jsm>link</jsm><js>"alternate"</js>, <js>"text/html"</js>, <js>"http://juneau.apache.org/juneau.atom"</js>), |
| <jsm>link</jsm>(<js>"enclosure"</js>, <js>"audio/mpeg"</js>, <js>"http://juneau.apache.org/audio/juneau_podcast.mp3"</js>).length(1337) |
| ) |
| .published(<js>"2016-01-02T03:04:05Z"</js>) |
| .authors( |
| <jsm>person</jsm>(<js>"Jane Smith"</js>).uri(<js>"http://juneau.apache.org/"</js>).email(<js>"janesmith@apache.org"</js>) |
| ) |
| .contributors( |
| <jsm>person</jsm>(<js>"John Smith"</js>) |
| ) |
| .content( |
| <jsm>content</jsm>(<js>"xhtml"</js>) |
| .lang(<js>"en"</js>) |
| .base(<js>"http://www.apache.org/"</js>) |
| .text(<js>"<div><p><i>[Update: Juneau supports ATOM.]</i></p></div>"</js>) |
| ) |
| ); |
| </p> |
| <p> |
| To serialize this to ATOM, use the {@link oaj.xml.XmlSerializer} class: |
| </p> |
| |
| <h5 class='figure'>Example with no namespaces</h5> |
| <p class='bpcode w800'> |
| <jc>// Create a serializer with readable output, no namespaces yet.</jc> |
| XmlSerializer s = XmlSerializer.<jsm>create</jsm>().sq().ws().build(); |
| |
| <jc>// Serialize to ATOM/XML</jc> |
| String atomXml = s.serialize(feed); |
| </p> |
| |
| <h5 class='figure'>Results</h5> |
| <p class='bpcode w800'> |
| <xt><feed></xt> |
| <xt><id></xt> |
| tag:juneau.apache.org |
| <xt></id></xt> |
| <xt><link</xt> <xa>href</xa>=<xs>'http://juneau.apache.org/'</xs> <xa>rel</xa>=<xs>'alternate'</xs> |
| <xa>type</xa>=<xs>'text/html'</xs> <xa>hreflang</xa>=<xs>'en'</xs>/<xt>></xt> |
| <xt><link</xt> <xa>href</xa>=<xs>'http://juneau.apache.org/feed.atom'</xs> <xa>rel</xa>=<xs>'self'</xs> |
| <xa>type</xa>=<xs>'application/atom+xml'</xs>/<xt>></xt> |
| <xt><rights></xt> |
| Copyright (c) ... |
| <xt></rights></xt> |
| <xt><title</xt> <xa>type</xa>=<xs>'text'</xs>></xt> |
| Juneau ATOM specification |
| <xt></title></xt> |
| <xt><updated></xt>2016-01-02T03:04:05Z<xt></updated></xt> |
| <xt><generator</xt> <xa>uri</xa>=<xs>'http://juneau.apache.org/'</xs> <xa>version</xa>=<xs>'1.0'</xs><xt>></xt> |
| Juneau |
| <xt></generator></xt> |
| <xt><subtitle</xt> <xa>type</xa>=<xs>'html'</xs><xt>></xt> |
| Describes <em>stuff</em> about Juneau |
| <xt></subtitle></xt> |
| <xt><entry></xt> |
| <xt><author></xt> |
| <xt><name></xt>Jane Smith<xt></name></xt> |
| <xt><uri></xt>http://juneau.apache.org/<xt></uri></xt> |
| <xt><email></xt>janesmith@apache.org<xt></email></xt> |
| <xt></author></xt> |
| <xt><contributor></xt> |
| <xt><name></xt>John Smith<xt></name></xt> |
| <xt></contributor></xt> |
| <xt><id></xt> |
| tag:juneau.apache.org |
| <xt></id></xt> |
| <xt><link</xt> <xa>href</xa>=<xs>'http://juneau.apache.org/juneau.atom'</xs> |
| <xa>rel</xa>=<xs>'alternate'</xs> <xa>type</xa>=<xs>'text/html'</xs>/<xt>></xt> |
| <xt><link</xt> <xa>href</xa>=<xs>'http://juneau.apache.org/audio/juneau_podcast.mp3'</xs> |
| <xa>rel</xa>=<xs>'enclosure'</xs> <xa>type</xa>=<xs>'audio/mpeg'</xs> <xa>length</xa>=<xs>'12345'</xs>/<xt>></xt> |
| <xt><title></xt> |
| Juneau ATOM specification snapshot |
| <xt></title></xt> |
| <xt><updated></xt>2016-01-02T03:04:05Z<xt></updated></xt> |
| <xt><content</xt> <xa>base</xa>=<xs>'http://www.apache.org/'</xs> <xa>lang</xa>=<xs>'en'</xs> |
| <xa>type</xa>=<xs>'xhtml'</xs><xt>></xt> |
| <xt><div</xt> <xa>xmlns</xa>=<xs>"http://www.w3.org/1999/xhtml"</xs> |
| <xt>><p><i></xt>[Update: Juneau supports ATOM.]<xt></i></p></div></xt> |
| <xt></content></xt> |
| <xt><published></xt>2016-01-02T03:04:05Z<xt></published></xt> |
| <xt></entry></xt> |
| <xt></feed></xt> |
| </p> |
| <p> |
| The {@link oaj.xml.XmlParser} class can be used convert these Atom documents back into POJOs. |
| </p> |
| <p> |
| Other serializers and parsers (e.g. {@link oaj.json.JsonSerializer}) can be used to |
| represent these POJOs in languages other than XML. |
| </p> |
| |
| <h5 class='toc'>Additional Information - org.apache.juneau.dto.atom</h5> |
| <ol class='toc'> |
| <li><p>{@doc org.apache.juneau.dto.atom#Overview Overview}</p> |
| <ol> |
| <li><p>{@doc org.apache.juneau.dto.atom#Serialize Serializing ATOM feeds}</p> |
| <ol> |
| <li><p>{@doc org.apache.juneau.dto.atom#AtomJson ATOM/JSON}</p> |
| <li><p>{@doc org.apache.juneau.dto.atom#AtomRdfXml ATOM/RDF/XML}</p> |
| <li><p>{@doc org.apache.juneau.dto.atom#AtomHtml ATOM/HTML}</p> |
| </ol> |
| <li><p>{@doc org.apache.juneau.dto.atom#Parse Parsing ATOM feeds}</p> |
| </ol> |
| </ol> |