http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/2c3a7cb5/com.ibm.team.juno/src/main/java/org/apache/juneau/dto/atom/package.html ---------------------------------------------------------------------- diff --git a/com.ibm.team.juno/src/main/java/org/apache/juneau/dto/atom/package.html b/com.ibm.team.juno/src/main/java/org/apache/juneau/dto/atom/package.html deleted file mode 100644 index 3fbcf3b..0000000 --- a/com.ibm.team.juno/src/main/java/org/apache/juneau/dto/atom/package.html +++ /dev/null @@ -1,585 +0,0 @@ -<!DOCTYPE HTML> -<!-- -/*************************************************************************************************************************** - * 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. - * - ***************************************************************************************************************************/ - --> -<html> -<head> - <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> - <style type="text/css"> - /* For viewing in Page Designer */ - @IMPORT url("../../../../../../../javadoc.css"); - - /* For viewing in REST interface */ - @IMPORT url("../htdocs/javadoc.css"); - body { - margin: 20px; - } - </style> - <script> - /* Replace all @code and @link tags. */ - window.onload = function() { - document.body.innerHTML = document.body.innerHTML.replace(/\{\@code ([^\}]+)\}/g, '<code>$1</code>'); - document.body.innerHTML = document.body.innerHTML.replace(/\{\@link (([^\}]+)\.)?([^\.\}]+)\}/g, '<code>$3</code>'); - } - </script> -</head> -<body> -<p>ATOM Data Transfer Objects</p> -<script> - function toggle(x) { - var div = x.nextSibling; - while (div != null && div.nodeType != 1) - div = div.nextSibling; - if (div != null) { - var d = div.style.display; - if (d == 'block' || d == '') { - div.style.display = 'none'; - x.className += " closed"; - } else { - div.style.display = 'block'; - x.className = x.className.replace(/(?:^|\s)closed(?!\S)/g , '' ); - } - } - } -</script> -<a id='TOC'></a><h5 class='toc'>Table of Contents</h5> -<ol class='toc'> - <li><p><a class='doclink' href='#Overview'>Overview</a></p> - <ol> - <li><p><a class='doclink' href='#Serialize'>Serializing ATOM feeds</a></p> - <ol> - <li><p><a class='doclink' href='#AtomJson'>ATOM/JSON</a></p> - <li><p><a class='doclink' href='#AtomRdfXml'>ATOM/RDF/XML</a></p> - <li><p><a class='doclink' href='#AtomHtml'>ATOM/HTML</a></p> - </ol> - <li><p><a class='doclink' href='#Parse'>Parsing ATOM feeds</a></p> - </ol> -</ol> - - -<!-- ======================================================================================================== --> -<a id="Overview"></a> -<h2 class='topic' onclick='toggle(this)'>1 - Overview</h2> -<div class='topic'> - <p> - Juneau supports generation and consumption of ATOM feeds through the use of DTOs (Data Transfer Objects).<br> - It uses existing support for serializing and parsing POJOs to and from XML to define these ATOM objects. - </p> - <p> - The examples shown here are pulled from the <code>AtomFeedResource</code> class in the <code>org.apache.juneau.sample.war</code> project. - </p> - - - <!-- ======================================================================================================== --> - <a id="Serialize"></a> - <h3 class='topic' onclick='toggle(this)'>1.1 - Serializing ATOM feeds</h3> - <div class='topic'> - <p> - The Juneau ATOM feed DTOs are simply beans with fluent-style setters.<br> - The following code shows a feed being created programmatically: - </p> - <p class='bcode'> - Feed feed = <jk>new</jk> Feed() - .setTitle(<jk>new</jk> Text(<js>"text"</js>, <js>"Juneau ATOM specification"</js>)) - .setSubTitle(<jk>new</jk> Text(<js>"html"</js>, <js>"A <em>lot</em> of effort went into making this effortless"</js>)) - .setUpdated(<jsm>parseDateTime</jsm>(<js>"2013-05-08T12:29:29Z"</js>)) - .setId(<jk>new</jk> Id(<js>"tag:juneau.sample.com,2013:1"</js>)) - .addLinks( - <jk>new</jk> Link(<js>"alternate"</js>, <js>"text/html"</js>, <js>"http://www.sample.com/"</js>).setHreflang(<js>"en"</js>), - <jk>new</jk> Link(<js>"self"</js>, <js>"application/atom+xml"</js>, <js>"http://www.sample.com/feed.atom"</js>) - ) - .setRights(<jk>new</jk> Text(<js>"Copyright (c) 2013, IBM"</js>)) - .setGenerator(<jk>new</jk> Generator(<js>"Juneau"</js>).setUri(<jk>new</jk> URI(<js>"http://juneau.ibm..com/"</js>)).setVersion(<js>"1.0"</js>)) - .addEntries( - <jk>new</jk> Entry() - .setTitle(<jk>new</jk> Text(<js>"Juneau ATOM specification snapshot"</js>)) - .addLinks( - <jk>new</jk> Link(<js>"alternate"</js>, <js>"text/html"</js>, <js>"http://www.sample.com/2012/05/08/juneau.atom"</js>), - <jk>new</jk> Link(<js>"enclosure"</js>, <js>"audio/mpeg"</js>, <js>""http://www.sample.com/audio/juneau_podcast.mp3"</js>).setLength(12345) - ) - .setId(<jk>new</jk> Id(<js>"tag:juneau.sample.com,2013:1.2345"</js>)) - .setUpdated(<jsm>parseDateTime</jsm>(<js>"2013-05-08T12:29:29Z"</js>)) - .setPublished(<jsm>parseDateTime</jsm>(<js>"2013-05-08T12:29:29Z"</js>)) - .addAuthors(<jk>new</jk> Person(<js>"James Bognar"</js>).setUri(<jk>new</jk> URI(<js>"http://www.sample.com/"</js>)).setEmail(<js>"[email protected]"</js>)) - .addContributors( - <jk>new</jk> Person(<js>"Barry M. Caceres"</js>) - ) - .setContent( - <jk>new</jk> Content() - .setLang(<js>"en"</js>) - .setBase(<jk>new</jk> URI(<js>"http://www.ibm.com/"</js>)) - .setType(<js>"xhtml"</js>) - .setText(<js>"<div xmlns=\"http://www.w3.org/1999/xhtml\"><p>*lt;i>[Update: Juneau supports ATOM.]</i></p></div>"</js>) - ) - ) - ; - </p> - <p> - To serialize this to ATOM, use the {@link org.apache.juneau.xml.XmlSerializer} class: - </p> - - <h6 class='figure'>Example with no namespaces</h6> - <p class='bcode'> - <jc>// Create a serializer with readable output, no namespaces yet.</jc> - XmlSerializer s = <jk>new</jk> XmlSerializer.SqReadable().setProperty(XmlSerializerContext.<jsf>XML_enableNamespaces</jsf>, <jk>false</jk>); - - <jc>// Serialize to ATOM/XML</jc> - String atomXml = s.serialize(feed); - </p> - - <h6 class='figure'>Results</h6> - <p class='bcode'> - <xt><feed></xt> - <xt><id></xt> - tag:juneau.sample.com,2013:1 - <xt></id></xt> - <xt><link</xt> <xa>href</xa>=<xs>'http://www.sample.com/'</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://www.sample.com/feed.atom'</xs> <xa>rel</xa>=<xs>'self'</xs> <xa>type</xa>=<xs>'application/atom+xml'</xs>/<xt>></xt> - <xt><rights></xt> - Copyright (c) 2013, IBM - <xt></rights></xt> - <xt><title</xt> <xa>type</xa>=<xs>'text'</xs>></xt> - Juneau ATOM specification - <xt></title></xt> - <xt><updated></xt>2013-05-08T12:29:29Z<xt></updated></xt> - <xt><generator</xt> <xa>uri</xa>=<xs>'http://juneau.ibm.com/'</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> - A &lt;em&gt;lot&lt;/em&gt; of effort went into making this effortless - <xt></subtitle></xt> - <xt><entry></xt> - <xt><author></xt> - <xt><name></xt>James Bognar<xt></name></xt> - <xt><uri></xt>http://www.sample.com/<xt></uri></xt> - <xt><email></xt>[email protected]<xt></email></xt> - <xt></author></xt> - <xt><contributor></xt> - <xt><name></xt>Barry M. Caceres<xt></name></xt> - <xt></contributor></xt> - <xt><id></xt> - tag:juneau.sample.com,2013:1.2345 - <xt></id></xt> - <xt><link</xt> <xa>href</xa>=<xs>'http://www.sample.com/2012/05/08/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://www.sample.com/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>2013-05-08T12:29:29Z<xt></updated></xt> - <xt><content</xt> <xa>base</xa>=<xs>'http://www.ibm.com/'</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>2013-05-08T12:29:29Z<xt></published></xt> - <xt></entry></xt> - <xt></feed></xt> - </p> - - <p> - The following is the same, except with XML namespaces enabled: - </p> - - <h6 class='figure'>Example with namespaces</h6> - <p class='bcode'> - <jc>// Create a serializer with readable output with namespaces.</jc> - XmlSerializer s = <jk>new</jk> XmlSerializer.SqReadable(); - - <jc>// Serialize to ATOM/XML</jc> - String atomXml = s.serialize(feed); - </p> - - <h6 class='figure'>Results</h6> - <p class='bcode'> - <xt><atom:feed</xt> - <xa>xmlns</xa>=<xs>'http://www.ibm.com/2013/Juneau'</xs> - <xa>xmlns:atom</xa>=<xs>'http://www.w3.org/2005/Atom/'</xs> - <xa>xmlns:xml</xa>=<xs>'http://www.w3.org/XML/1998/namespace'</xs> - <xa>xmlns:xsi</xa>=<xs>'http://www.w3.org/2001/XMLSchema-instance'</xs><xt>></xt> - <xt><atom:id></xt> - tag:juneau.sample.com,2013:1 - <xt></atom:id></xt> - <xt><atom:link</xt> <xa>href</xa>=<xs>'http://www.sample.com/'</xs> <xa>rel</xa>=<xs>'alternate'</xs> <xa>type</xa>=<xs>'text/html'</xs> <xa>hreflang</xa>=<xs>'en'</xs><xt>/></xt> - <xt><atom:link</xt> <xa>href</xa>=<xs>'http://www.sample.com/feed.atom'</xs> <xa>rel</xa>=<xs>'self'</xs> <xa>type</xa>=<xs>'application/atom+xml'</xs><xt>/></xt> - <xt><atom:rights></xt> - Copyright (c) 2013, IBM - <xt></atom:rights></xt> - <xt><atom:title</xt> <xa>type</xa>=<xs>'text'</xs><xt>></xt> - Juneau ATOM specification - <xt></atom:title></xt> - <xt><atom:updated></xt>2013-05-08T12:29:29Z<xt></atom:updated></xt> - <xt><atom:generator</xt> <xa>uri</xa>=<xs>'http://juneau.ibm.com/'</xs> <xa>version</xa>=<xs>'1.0'</xs><xt>></xt> - Juneau - <xt></atom:generator></xt> - <xt><atom:subtitle</xt> <xa>type</xa>=<xs>'html'</xs><xt>></xt> - A &lt;em&gt;lot&lt;/em&gt; of effort went into making this effortless - <xt></atom:subtitle></xt> - <xt><atom:entry></xt> - <xt><atom:author></xt> - <xt><atom:name></xt>James Bognar<xt></atom:name></xt> - <xt><atom:uri></xt>http://www.sample.com/<xt></atom:uri></xt> - <xt><atom:email></xt>[email protected]<xt></atom:email></xt> - <xt></atom:author></xt> - <xt><atom:contributor></xt> - <xt><atom:name></xt>Barry M. Caceres<xt></atom:name></xt> - <xt></atom:contributor></xt> - <xt><atom:id></xt> - tag:juneau.sample.com,2013:1.2345 - <xt></atom:id></xt> - <xt><atom:link</xt> <xa>href</xa>=<xs>'http://www.sample.com/2012/05/08/juneau.atom'</xs> <xa>rel</xa>=<xs>'alternate'</xs> <xa>type</xa>=<xs>'text/html'</xs><xt>/></xt> - <xt><atom:link</xt> <xa>href</xa>=<xs>'http://www.sample.com/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><atom:title></xt> - Juneau ATOM specification snapshot - <xt></atom:title></xt> - <xt><atom:updated></xt>2013-05-08T12:29:29Z<xt></atom:updated></xt> - <xt><atom:content</xt> <xa>xml:base</xa>=<xs>'http://www.ibm.com/'</xs> <xa>xml: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>></xt><xt><p></xt><xt><i></xt>[Update: Juneau supports ATOM.]<xt></i></xt><xt></p></xt><xt></div></xt> - <xt></atom:content></xt> - <xt><atom:published></xt>2013-05-08T12:29:29Z<xt></atom:published></xt> - <xt></atom:entry></xt> - <xt></atom:feed></xt> - </p> - - <p> - The following is the same, except with XML namespaces enabled and the ATOM namespace as the default namespace: - </p> - - <h6 class='figure'>Example with namespaces with ATOM as the default namespace</h6> - <p class='bcode'> - <jc>// Create a serializer with readable output with namespaces.</jc> - XmlSerializer s = <jk>new</jk> XmlSerializer.SqReadable().setProperty(XmlSerializerContext.<jsf>XML_defaultNamespaceUri</jsf>, <js>"atom"</js>); - - <jc>// Serialize to ATOM/XML</jc> - String atomXml = s.serialize(feed); - </p> - - <h6 class='figure'>Results</h6> - <p class='bcode'> - <xt><feed</xt> - <xa>xmlns</xa>=<xs>'http://www.w3.org/2005/Atom/'</xs> - <xa>xmlns:xml</xa>=<xs>'http://www.w3.org/XML/1998/namespace'</xs> - <xa>xmlns:xsi</xa>=<xs>'http://www.w3.org/2001/XMLSchema-instance'</xs><xt>></xt> - <xt><id></xt> - tag:juneau.sample.com,2013:1 - <xt></id></xt> - <xt><link</xt> <xa>href</xa>=<xs>'http://www.sample.com/'</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://www.sample.com/feed.atom'</xs> <xa>rel</xa>=<xs>'self'</xs> <xa>type</xa>=<xs>'application/atom+xml'</xs><xt>/></xt> - <xt><rights></xt> - Copyright (c) 2013, IBM - <xt></rights></xt> - <xt><title</xt> <xa>type</xa>=<xs>'text'</xs><xt>></xt> - Juneau ATOM specification - <xt></title></xt> - <xt><updated></xt>2013-05-08T12:29:29Z<xt></updated></xt> - <xt><generator</xt> <xa>uri</xa>=<xs>'http://juneau.ibm.com/'</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> - A &lt;em&gt;lot&lt;/em&gt; of effort went into making this effortless - <xt></subtitle></xt> - <xt><entry></xt> - <xt><author></xt> - <xt><name></xt>James Bognar<xt></name></xt> - <xt><uri></xt>http://www.sample.com/<xt></uri></xt> - <xt><email></xt>[email protected]<xt></email></xt> - <xt></author></xt> - <xt><contributor></xt> - <xt><name></xt>Barry M. Caceres<xt></name></xt> - <xt></contributor></xt> - <xt><id></xt> - tag:juneau.sample.com,2013:1.2345 - <xt></id></xt> - <xt><link</xt> <xa>href</xa>=<xs>'http://www.sample.com/2012/05/08/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://www.sample.com/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>2013-05-08T12:29:29Z<xt></updated></xt> - <xt><content</xt> <xa>xml:base</xa>=<xs>'http://www.ibm.com/'</xs> <xa>xml: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>></xt><xt><p></xt><xt><i></xt>[Update: Juneau supports ATOM.]<xt></i></xt><xt></p></xt><xt></div></xt> - <xt></content></xt> - <xt><published></xt>2013-05-08T12:29:29Z<xt></published></xt> - <xt></entry></xt> - <xt></feed></xt> - </p> - - - <!-- ======================================================================================================== --> - <a id="AtomJson"></a> - <h4 class='topic' onclick='toggle(this)'>1.1.1 - ATOM/JSON</h4> - <div class='topic'> - <p> - The {@link org.apache.juneau.json.JsonSerializer} class can also be used to produce ATOM in JSON format. - </p> - - <h6 class='figure'>ATOM/JSON example</h6> - <p class='bcode'> - <jc>// Get JSON serializer with readable output.</jc> - JsonSerializer s = JsonSerializer.<jsf>DEFAULT_LAX_READABLE</jsf>; - - <jc>// Serialize to ATOM/JSON</jc> - String atomJson = s.serialize(feed); - </p> - - <h6 class='figure'>Results</h6> - <p class='bcode'> - { - id: { - text: <js>'tag:juneau.sample.com,2013:1'</js> - }, - links: [ - { - href: <js>'http://www.sample.com/'</js>, - rel: <js>'alternate'</js>, - type: <js>'text/html'</js>, - hreflang: <js>'en'</js> - }, - { - href: <js>'http://www.sample.com/feed.atom'</js>, - rel: <js>'self'</js>, - type: <js>'application/atom+xml'</js> - } - ], - rights: { - text: <js>'Copyright (c) 2013, IBM'</js> - }, - title: { - type: <js>'text'</js>, - text: <js>'Juneau ATOM specification'</js> - }, - updated: <js>'2013-05-08T12:29:29Z'</js>, - generator: { - uri: <js>'http://juneau.ibm.com/'</js>, - version: <js>'1.0'</js>, - text: <js>'Juneau'</js> - }, - subtitle: { - type: <js>'html'</js>, - text: <js>'A <em>lot</em> of effort went into making this effortless'</js> - }, - entries: [ - { - authors: [ - { - name: <js>'James Bognar'</js>, - uri: <js>'http://www.sample.com/'</js>, - email: <js>'[email protected]'</js> - } - ], - contributors: [ - { - name: <js>'Barry M. Caceres'</js> - } - ], - id: { - text: <js>'tag:juneau.sample.com,2013:1.2345'</js> - }, - links: [ - { - href: <js>'http://www.sample.com/2012/05/08/juneau.atom'</js>, - rel: <js>'alternate'</js>, - type: <js>'text/html'</js> - }, - { - href: <js>'http://www.sample.com/audio/juneau_podcast.mp3'</js>, - rel: <js>'enclosure'</js>, - type: <js>'audio/mpeg'</js>, - length: <jk>12345</jk> - } - ], - title: { - text: <js>'Juneau ATOM specification snapshot'</js> - }, - updated: <js>'2013-05-08T12:29:29Z'</js>, - content: { - base: <js>'http://www.ibm.com/'</js>, - lang: <js>'en'</js>, - type: <js>'xhtml'</js>, - text: <js>'<div xmlns="http://www.w3.org/1999/xhtml"><p><i>[Update: Juneau supports ATOM.]</i></p></div>'</js> - }, - published: <js>'2013-05-08T12:29:29Z'</js> - } - ] - } - </p> - </div> - - - <!-- ======================================================================================================== --> - <a id="AtomRdfXml"></a> - <h4 class='topic' onclick='toggle(this)'>1.1.2 - ATOM/RDF/XML</h4> - <div class='topic'> - <p> - The {@link org.apache.juneau.jena.RdfSerializer} class and subclasses can also be used to produce ATOM in various RDF formats. - </p> - - <h6 class='figure'>ATOM/RDF/XML example</h6> - <p class='bcode'> - <jc>// Get RDF/XML serializer with readable output.</jc> - RdfSerializer s = <jk>new</jk> RdfSerializer.XmlAbbrev() - .setProperty(SerializerContext.<jsf>SERIALIZER_useIndentation</jsf>, <jk>true</jk>) - .setProperty(SerializerContext.<jsf>SERIALIZER_quoteChar</jsf>, <js>'\''</js>) - .setProperty(RdfProperties.<jsf>RDF_rdfxml_tab</jsf>, 3); - - <jc>// Serialize to ATOM/RDF/XML</jc> - String atomRdfXml = s.serialize(feed); - </p> - - <h6 class='figure'>Results</h6> - <p class='bcode'> - <xt><rdf:RDF</xt> - <xa>xmlns:rdf</xa>=<xs>'http://www.w3.org/1999/02/22-rdf-syntax-ns#'</xs> - <xa>xmlns:j</xa>=<xs>'http://www.ibm.com/juneau/'</xs> - <xa>xmlns:jp</xa>=<xs>'http://www.ibm.com/juneaubp/'</xs> - <xa>xmlns:atom</xa>=<xs>'http://www.w3.org/2005/Atom/'</xs> - <xa>xmlns:j.0</xa>=<xs>'http://www.w3.org/XML/1998/'</xs><xt>></xt> - <xt><rdf:Description></xt> - <xt><atom:id</xt> <xa>rdf:parseType</xa>=<xs>'Resource'</xs><xt>></xt> - <xt><atom:text></xt>tag:juneau.sample.com,2013:1<xt></atom:text></xt> - <xt></atom:id></xt> - <xt><atom:links></xt> - <xt><rdf:Seq></xt> - <xt><rdf:li</xt> <xa>rdf:parseType</xa>=<xs>'Resource'</xs><xt>></xt> - <xt><atom:href></xt>http://www.sample.com/<xt></atom:href></xt> - <xt><atom:rel></xt>alternate<xt></atom:rel></xt> - <xt><atom:type></xt>text/html<xt></atom:type></xt> - <xt><atom:hreflang></xt>en<xt></atom:hreflang></xt> - <xt></rdf:li></xt> - <xt><rdf:li</xt> <xa>rdf:parseType</xa>=<xs>'Resource'</xs><xt>></xt> - <xt><atom:href></xt>http://www.sample.com/feed.atom<xt></atom:href></xt> - <xt><atom:rel></xt>self<xt></atom:rel></xt> - <xt><atom:type></xt>application/atom+xml<xt></atom:type></xt> - <xt></rdf:li></xt> - <xt></rdf:Seq></xt> - <xt></atom:links></xt> - <xt><atom:rights</xt> <xa>rdf:parseType</xa>=<xs>'Resource'</xs><xt>></xt> - <xt><atom:text></xt>Copyright (c) 2013, IBM<xt></atom:text></xt> - <xt></atom:rights></xt> - <xt><atom:title</xt> <xa>rdf:parseType</xa>=<xs>'Resource'</xs><xt>></xt> - <xt><atom:type></xt>text<xt></atom:type></xt> - <xt><atom:text></xt>Juneau ATOM specification<xt></atom:text></xt> - <xt></atom:title></xt> - <xt><atom:updated></xt>2013-05-08T12:29:29Z<xt></atom:updated></xt> - <xt><atom:generator</xt> <xa>rdf:parseType</xa>=<xs>'Resource'</xs><xt>></xt> - <xt><atom:uri</xt> <xa>rdf:resource</xa>=<xs>'http://juneau.ibm.com/'</xs><xt>/></xt> - <xt><atom:version></xt>1.0<xt></atom:version></xt> - <xt><atom:text></xt>Juneau<xt></atom:text></xt> - <xt></atom:generator></xt> - <xt><atom:subtitle</xt> <xa>rdf:parseType</xa>=<xs>'Resource'</xs><xt>></xt> - <xt><atom:type></xt>html<xt></atom:type></xt> - <xt><atom:text></xt>A &lt;em&gt;lot&lt;/em&gt; of effort went into making this effortless<xt></atom:text></xt> - <xt></atom:subtitle></xt> - <xt><atom:entries></xt> - <xt><rdf:Seq></xt> - <xt><rdf:li</xt> <xa>rdf:parseType</xa>=<xs>'Resource'</xs><xt>></xt> - <xt><atom:authors></xt> - <xt><rdf:Seq></xt> - <xt><rdf:li</xt> <xa>rdf:parseType</xa>=<xs>'Resource'</xs><xt>></xt> - <xt><atom:name></xt>James Bognar<xt></atom:name></xt> - <xt><atom:uri</xt> <xa>rdf:resource</xa>=<xs>'http://www.sample.com/'</xs><xt>/></xt> - <xt><atom:email></xt>[email protected]<xt></atom:email></xt> - <xt></rdf:li></xt> - <xt></rdf:Seq></xt> - <xt></atom:authors></xt> - <xt><atom:contributors></xt> - <xt><rdf:Seq></xt> - <xt><rdf:li</xt> <xa>rdf:parseType</xa>=<xs>'Resource'</xs><xt>></xt> - <xt><atom:name></xt>Barry M. Caceres<xt></atom:name></xt> - <xt></rdf:li></xt> - <xt></rdf:Seq></xt> - <xt></atom:contributors></xt> - <xt><atom:id</xt> <xa>rdf:parseType</xa>=<xs>'Resource'</xs><xt>></xt> - <xt><atom:text></xt>tag:juneau.sample.com,2013:1.2345<xt></atom:text></xt> - <xt></atom:id></xt> - <xt><atom:links></xt> - <xt><rdf:Seq></xt> - <xt><rdf:li</xt> <xa>rdf:parseType</xa>=<xs>'Resource'</xs><xt>></xt> - <xt><atom:href></xt>http://www.sample.com/2012/05/08/juneau.atom<xt></atom:href></xt> - <xt><atom:rel></xt>alternate<xt></atom:rel></xt> - <xt><atom:type></xt>text/html<xt></atom:type></xt> - <xt></rdf:li></xt> - <xt><rdf:li</xt> <xa>rdf:parseType</xa>=<xs>'Resource'</xs><xt>></xt> - <xt><atom:href></xt>http://www.sample.com/audio/juneau_podcast.mp3<xt></atom:href></xt> - <xt><atom:rel></xt>enclosure<xt></atom:rel></xt> - <xt><atom:type></xt>audio/mpeg<xt></atom:type></xt> - <xt><atom:length></xt>12345<xt></atom:length></xt> - <xt></rdf:li></xt> - <xt></rdf:Seq></xt> - <xt></atom:links></xt> - <xt><atom:title</xt> <xa>rdf:parseType</xa>=<xs>'Resource'</xs><xt>></xt> - <xt><atom:text></xt>Juneau ATOM specification snapshot<xt></atom:text></xt> - <xt></atom:title></xt> - <xt><atom:updated></xt>2013-05-08T12:29:29Z<xt></atom:updated></xt> - <xt><atom:content</xt> <xa>rdf:parseType</xa>=<xs>'Resource'</xs><xt>></xt> - <xt><j.0:namespacebase</xt> <xa>rdf:resource</xa>=<xs>'http://www.ibm.com/'</xs><xt>/></xt> - <xt><j.0:namespacelang></xt>en<xt></j.0:namespacelang></xt> - <xt><atom:type></xt>xhtml<xt></atom:type></xt> - <xt><atom:text></xt>&lt;div xmlns="http://www.w3.org/1999/xhtml"&gt;&lt;p&gt;&lt;i&gt;[Update: Juneau supports ATOM.]&lt;/i&gt;&lt;/p&gt;&lt;/div&gt;<xt></atom:text></xt> - <xt></atom:content></xt> - <xt><atom:published></xt>2013-05-08T12:29:29Z<xt></atom:published></xt> - <xt></rdf:li></xt> - <xt></rdf:Seq></xt> - <xt></atom:entries></xt> - <xt></rdf:Description></xt> - <xt></rdf:RDF></xt> - </p> - </div> - - - <!-- ======================================================================================================== --> - <a id="AtomHtml"></a> - <h4 class='topic' onclick='toggle(this)'>1.1.3 - ATOM/HTML</h4> - <div class='topic'> - <p> - The {@link org.apache.juneau.html.HtmlSerializer} class can be used to produce ATOM in HTML format. - </p> - <p> - The following is the output produced by the <code>AtomFeedResource</code> in the <code>org.apache.juneau.sample.war</code> project: - </p> - - <h6 class='figure'>Example ATOM/HTML results</h6> - <img class='bordered' src='doc-files/Example_HTML.png'> - </div> - </div> - - - <!-- ======================================================================================================== --> - <a id="Parse"></a> - <h3 class='topic' onclick='toggle(this)'>1.2 - Parsing ATOM feeds</h3> - <div class='topic'> - <p> - Use the {@link org.apache.juneau.xml.XmlParser} to convert ATOM/XML feeds back into their original POJOs: - </p> - <p class='bcode'> - <jc>// Create a serializer with readable output with namespaces</jc> - XmlSerializer s = XmlSerializer.<jsf>DEFAULT_SQ_READABLE</jsf>; - - <jc>// Serialize to ATOM/XML</jc> - String atomXml = s.serialize(feed); - - <jc>// Get an XML parser to convert it back into a POJO</jc> - XmlParser p = XmlParser.<jsf>DEFAULT</jsf>; - - <jc>// Convert the XML back into a POJO</jc> - Feed feed2 = p.parse(atomXml, Feed.<jk>class</jk>); - </p> - <p> - ATOM Feed objects can also be constructed from the other media types using the appropriate parsers. - </p> - </div> - -</div> -<p align="center"><i><b>*** fÃn ***</b></i></p> - -</body> -</html> \ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/2c3a7cb5/com.ibm.team.juno/src/main/java/org/apache/juneau/dto/cognos/Column.java ---------------------------------------------------------------------- diff --git a/com.ibm.team.juno/src/main/java/org/apache/juneau/dto/cognos/Column.java b/com.ibm.team.juno/src/main/java/org/apache/juneau/dto/cognos/Column.java deleted file mode 100644 index 020a71b..0000000 --- a/com.ibm.team.juno/src/main/java/org/apache/juneau/dto/cognos/Column.java +++ /dev/null @@ -1,160 +0,0 @@ -/*************************************************************************************************************************** - * 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. - ***************************************************************************************************************************/ -package org.apache.juneau.dto.cognos; - -import org.apache.juneau.annotation.*; -import org.apache.juneau.transform.*; -import org.apache.juneau.xml.annotation.*; - -/** - * Represents a meta-data column in a Cognos dataset. - * <p> - * When serialized to XML, creates the following construct: - * <p class='bcode'> - * <xt><item</xt> <xa>name</xa>=<xs>'name'</xs> <xa>type</xa>=<xs>'xs:String'</xs> <xa>length</xa>=<xs>'255'</xs>/> - * </p> - * - * @author James Bognar ([email protected]) - */ -@Xml(name="item") -@SuppressWarnings({"rawtypes","hiding"}) -@Bean(properties={"name","type","length"}) -public class Column { - - private String name, type; - private Integer length; - PojoTransform transform; - - /** Bean constructor. */ - public Column() {} - - /** - * Constructor. - * - * @param name The column name. - * @param type The column type (e.g. <js>"xs:String"</js>). - */ - public Column(String name, String type) { - this(name, type, null); - } - - /** - * Constructor. - * - * @param name The column name. - * @param type The column type (e.g. <js>"xs:String"</js>). - * @param length The column length (e.g. <code>255</code>). - */ - public Column(String name, String type, Integer length) { - this.name = name; - this.type = type; - this.length = length; - } - - /** - * Associates a POJO transform with this column. - * <p> - * Typically used to define columns that don't exist on the underlying beans being serialized. - * <p> - * For example, the <code>AddressBookResource</code> sample defined the following transform - * to define an additional <js>"numAddresses"</js> column even though no such property exists - * on the serialized beans. - * <p class='bcode'> - * Column c = <jk>new</jk> Column(<js>"numAddresses"</js>, <js>"xs:int"</js>) - * .addTransform( - * <jk>new</jk> PojoTransform<Person,Integer>() { - * <ja>@Override</ja> - * <jk>public</jk> Integer transform(Person p) { - * <jk>return</jk> p.<jf>addresses</jf>.size(); - * } - * } - * ); - * </p> - * - * @param transform The transform to associate with the column. - * @return This object (for method chaining). - */ - public Column addTransform(PojoTransform transform) { - this.transform = transform; - return this; - } - - //-------------------------------------------------------------------------------- - // Bean properties - //-------------------------------------------------------------------------------- - - /** - * Bean property getter: <property>name</property>. - * - * @return The value of the <property>name</property> property on this bean, or <jk>null</jk> if it is not set. - */ - @Xml(format=XmlFormat.ATTR) - public String getName() { - return name; - } - - /** - * Bean property setter: <property>name</property>. - * - * @param name The new value for the <property>name</property> property on this bean. - * @return This object (for method chaining). - */ - public Column setName(String name) { - this.name = name; - return this; - } - - /** - * Bean property getter: <property>type</property>. - * - * @return The value of the <property>type</property> property on this bean, or <jk>null</jk> if it is not set. - */ - @Xml(format=XmlFormat.ATTR) - public String getType() { - return type; - } - - /** - * Bean property setter: <property>type</property>. - * - * @param type The new value for the <property>type</property> property on this bean. - * @return This object (for method chaining). - */ - public Column setType(String type) { - this.type = type; - return this; - } - - /** - * Bean property getter: <property>length</property>. - * - * @return The value of the <property>length</property> property on this bean, or <jk>null</jk> if length is not applicable for the specified type. - */ - @Xml(format=XmlFormat.ATTR) - public Integer getLength() { - return length; - } - - /** - * Bean property setter: <property>length</property>. - * - * @param length The new value for the <property>length</property> property on this bean. - * Can be <jk>null</jk> if length is not applicable for the specified type. - * @return This object (for method chaining). - */ - public Column setLength(Integer length) { - this.length = length; - return this; - } -} - http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/2c3a7cb5/com.ibm.team.juno/src/main/java/org/apache/juneau/dto/cognos/DataSet.java ---------------------------------------------------------------------- diff --git a/com.ibm.team.juno/src/main/java/org/apache/juneau/dto/cognos/DataSet.java b/com.ibm.team.juno/src/main/java/org/apache/juneau/dto/cognos/DataSet.java deleted file mode 100644 index d4a70f2..0000000 --- a/com.ibm.team.juno/src/main/java/org/apache/juneau/dto/cognos/DataSet.java +++ /dev/null @@ -1,193 +0,0 @@ -/*************************************************************************************************************************** - * 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. - ***************************************************************************************************************************/ -package org.apache.juneau.dto.cognos; - -import java.util.*; - -import org.apache.juneau.*; -import org.apache.juneau.annotation.*; -import org.apache.juneau.xml.annotation.*; - -/** - * Represents a Cognos dataset. - * <p> - * When serialized to XML, creates the following construct (example pulled from <code>AddressBookResource</code>): - * <p class='bcode'> - * <xt><?xml</xt> <xa>version</xa>=<xs>'1.0'</xs> <xa>encoding</xa>=<xs>'UTF-8'</xs><xt>?></xt> - * <xt><c:dataset <xa>xmlns:c</xa>=<xs>'http://developer.cognos.com/schemas/xmldata/1/'</xs>></xt> - * <xt><c:metadata></xt> - * <xt><c:item</xt> <xa>name</xa>=<xs>'name'</xs> <xa>type</xa>=<xs>'xs:String'</xs> <xa>length</xa>=<xs>'255'</xs><xt>/></xt> - * <xt><c:item</xt> <xa>name</xa>=<xs>'age'</xs> <xa>type</xa>=<xs>'xs:int'</xs><xt>/></xt> - * <xt><c:item</xt> <xa>name</xa>=<xs>'numAddresses'</xs> <xa>type</xa>=<xs>'xs:int'</xs><xt>/></xt> - * <xt></c:metadata></xt> - * <xt><c:data></xt> - * <xt><c:row></xt> - * <xt><c:value></xt>Barack Obama<xt></c:value></xt> - * <xt><c:value></xt>52<xt></c:value></xt> - * <xt><c:value></xt>2<xt></c:value></xt> - * <xt></c:row></xt> - * <xt><c:row></xt> - * <xt><c:value></xt>George Walker Bush<xt></c:value></xt> - * <xt><c:value></xt>67<xt></c:value></xt> - * <xt><c:value></xt>2<xt></c:value></xt> - * <xt></c:row></xt> - * <xt></c:data></xt> - * <xt></c:dataset></xt> - * </p> - * <p> - * Only 2-dimentional POJOs (arrays or collections of maps or beans) can be serialized to Cognos. - * - * <h6 class='topic'>Example</h6> - * <p> - * The construct shown above is a serialized <code>AddressBook</code> object which is a subclass of <code>LinkedList<Person></code>. - * The code for generating the XML is as follows... - * </p> - * <p class='bcode'> - * Column[] items = { - * <jk>new</jk> Column(<js>"name"</js>, <js>"xs:String"</js>, 255), - * <jk>new</jk> Column(<js>"age"</js>, <js>"xs:int"</js>), - * <jk>new</jk> Column(<js>"numAddresses"</js>, <js>"xs:int"</js>) - * .addTransform( - * <jk>new</jk> PojoTransform<Person,Integer>() { - * <ja>@Override</ja> - * <jk>public</jk> Integer transform(Person p) { - * <jk>return</jk> p.<jf>addresses</jf>.size(); - * } - * } - * ) - * }; - * - * DataSet ds = <jk>new</jk> DataSet(items, <jsf>addressBook</jsf>, BeanContext.<jsf>DEFAULT</jsf>); - * - * String xml = XmlSerializer.<jsf>DEFAULT_SQ</jsf>.serialize(ds); - * </p> - * - * @author James Bognar ([email protected]) - */ -@Xml(name="dataset") -@SuppressWarnings("unchecked") -@Bean(properties={"metadata","data"}) -public class DataSet { - - private Column[] metaData; - private List<Row> data; - - /** Bean constructor. */ - public DataSet() {} - - /** - * Constructor. - * - * @param columns The meta-data that represents the columns in the dataset. - * @param o The POJO being serialized to Cognos. - * Must be an array/collection of beans/maps. - * @param beanContext The bean context used to convert POJOs to strings. - * @throws Exception An error occurred trying to serialize the POJO. - */ - public DataSet(Column[] columns, Object o, BeanContext beanContext) throws Exception { - metaData = columns; - data = new LinkedList<Row>(); - if (o != null) { - if (o.getClass().isArray()) - o = Arrays.asList((Object[])o); - if (o instanceof Collection) { - Collection<?> c = (Collection<?>)o; - for (Object o2 : c) { - Row r = new Row(); - Map<?,?> m = null; - if (o2 instanceof Map) - m = (Map<?,?>)o2; - else - m = beanContext.forBean(o2); - for (Column col : columns) { - Object v; - if (col.transform != null) - v = col.transform.transform(o2); - else - v = m.get(col.getName()); - r.add(v == null ? null : v.toString()); - } - data.add(r); - } - } - } - } - - /** - * Represents a row of data. - * <p> - * When serialized to XML, creates the following construct (example pulled from <code>AddressBookResource</code>): - * <p class='bcode'> - * <xt><row></xt> - * <xt><value></xt>Barack Obama<xt></value></xt> - * <xt><value></xt>52<xt></value></xt> - * <xt><value></xt>2<xt></value></xt> - * <xt></row></xt> - * </p> - * - * @author James Bognar ([email protected]) - */ - @Xml(name="row", childName="value") - public static class Row extends LinkedList<String> { - private static final long serialVersionUID = 1L; - } - - - //-------------------------------------------------------------------------------- - // Bean properties - //-------------------------------------------------------------------------------- - - /** - * Bean property getter: <property>metadata</property>. - * - * @return The value of the <property>metadata</property> property on this bean, or <jk>null</jk> if it is not set. - */ - @BeanProperty(name="metadata") - public Column[] getMetaData() { - return metaData; - } - - /** - * Bean property setter: <property>metadata</property>. - * - * @param metaData The new value for the <property>metadata</property> property on this bean. - * @return This object (for method chaining). - */ - @BeanProperty(name="metadata") - public DataSet setMetaData(Column[] metaData) { - this.metaData = metaData; - return this; - } - - /** - * Bean property getter: <property>data</property>. - * - * @return The value of the <property>data</property> property on this bean, or <jk>null</jk> if it is not set. - */ - @BeanProperty(name="data") - public List<Row> getData() { - return data; - } - - /** - * Bean property setter: <property>data</property>. - * - * @param data The new value for the <property>data</property> property on this bean. - * @return This object (for method chaining). - */ - @BeanProperty(name="data") - public DataSet setData(List<Row> data) { - this.data = data; - return this; - } -} http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/2c3a7cb5/com.ibm.team.juno/src/main/java/org/apache/juneau/dto/cognos/doc-files/HTML.png ---------------------------------------------------------------------- diff --git a/com.ibm.team.juno/src/main/java/org/apache/juneau/dto/cognos/doc-files/HTML.png b/com.ibm.team.juno/src/main/java/org/apache/juneau/dto/cognos/doc-files/HTML.png deleted file mode 100644 index fd63c23..0000000 Binary files a/com.ibm.team.juno/src/main/java/org/apache/juneau/dto/cognos/doc-files/HTML.png and /dev/null differ http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/2c3a7cb5/com.ibm.team.juno/src/main/java/org/apache/juneau/dto/cognos/doc-files/JSON.png ---------------------------------------------------------------------- diff --git a/com.ibm.team.juno/src/main/java/org/apache/juneau/dto/cognos/doc-files/JSON.png b/com.ibm.team.juno/src/main/java/org/apache/juneau/dto/cognos/doc-files/JSON.png deleted file mode 100644 index 44785ad..0000000 Binary files a/com.ibm.team.juno/src/main/java/org/apache/juneau/dto/cognos/doc-files/JSON.png and /dev/null differ http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/2c3a7cb5/com.ibm.team.juno/src/main/java/org/apache/juneau/dto/cognos/doc-files/RDFXML.png ---------------------------------------------------------------------- diff --git a/com.ibm.team.juno/src/main/java/org/apache/juneau/dto/cognos/doc-files/RDFXML.png b/com.ibm.team.juno/src/main/java/org/apache/juneau/dto/cognos/doc-files/RDFXML.png deleted file mode 100644 index 081e949..0000000 Binary files a/com.ibm.team.juno/src/main/java/org/apache/juneau/dto/cognos/doc-files/RDFXML.png and /dev/null differ http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/2c3a7cb5/com.ibm.team.juno/src/main/java/org/apache/juneau/dto/cognos/package-info.java ---------------------------------------------------------------------- diff --git a/com.ibm.team.juno/src/main/java/org/apache/juneau/dto/cognos/package-info.java b/com.ibm.team.juno/src/main/java/org/apache/juneau/dto/cognos/package-info.java deleted file mode 100644 index f6d1b4d..0000000 --- a/com.ibm.team.juno/src/main/java/org/apache/juneau/dto/cognos/package-info.java +++ /dev/null @@ -1,17 +0,0 @@ -//*************************************************************************************************************************** -//* 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. -//*************************************************************************************************************************** -// XML namespaces used in this package -@XmlSchema(prefix="cognos", namespace="http://developer.cognos.com/schemas/xmldata/1/") -package org.apache.juneau.dto.cognos; -import org.apache.juneau.xml.annotation.*; - http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/2c3a7cb5/com.ibm.team.juno/src/main/java/org/apache/juneau/dto/cognos/package.html ---------------------------------------------------------------------- diff --git a/com.ibm.team.juno/src/main/java/org/apache/juneau/dto/cognos/package.html b/com.ibm.team.juno/src/main/java/org/apache/juneau/dto/cognos/package.html deleted file mode 100644 index b0c9e83..0000000 --- a/com.ibm.team.juno/src/main/java/org/apache/juneau/dto/cognos/package.html +++ /dev/null @@ -1,177 +0,0 @@ -<!DOCTYPE HTML> -<!-- -/*************************************************************************************************************************** - * 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. - * - ***************************************************************************************************************************/ - --> -<html> -<head> - <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> - <style type="text/css"> - /* For viewing in Page Designer */ - @IMPORT url("../../../../../../javadoc.css"); - - /* For viewing in REST interface */ - @IMPORT url("../htdocs/javadoc.css"); - body { - margin: 20px; - } - </style> - <script> - /* Replace all @code and @link tags. */ - window.onload = function() { - document.body.innerHTML = document.body.innerHTML.replace(/\{\@code ([^\}]+)\}/g, '<code>$1</code>'); - document.body.innerHTML = document.body.innerHTML.replace(/\{\@link (([^\}]+)\.)?([^\.\}]+)\}/g, '<code>$3</code>'); - } - </script> -</head> -<body> -<p>Cognos Data Transfer Objects</p> -<script> - function toggle(x) { - var div = x.nextSibling; - while (div != null && div.nodeType != 1) - div = div.nextSibling; - if (div != null) { - var d = div.style.display; - if (d == 'block' || d == '') { - div.style.display = 'none'; - x.className += " closed"; - } else { - div.style.display = 'block'; - x.className = x.className.replace(/(?:^|\s)closed(?!\S)/g , '' ); - } - } - } -</script> -<a id='TOC'></a><h5 class='toc'>Table of Contents</h5> -<ol class='toc'> - <li><p><a class='doclink' href='#CognosSerializer'>Cognos serialization support</a></p> - <li><p><a class='doclink' href='#CognosParser'>Cognos parsing support</a></p> -</ol> - -<!-- ======================================================================================================== --> -<a id="CognosSerializer"></a> -<h2 class='topic' onclick='toggle(this)'>1 - Cognos serialization support</h2> -<div class='topic'> - <p> - The {@link org.apache.juneau.dto.cognos.DataSet} class is a DTO used to convert POJO models directly to Cognos-XML. - </p> - <p> - Because of the nature of the Cognos XML syntax, only <i>2-dimensional</i> POJO data structures can be serialized to Cognos-XML. - </p> - <p> - For example... - </p> - <ul class='normal'> - <li><code>Collection<Bean></code> - <li><code>Collection<Map></code> - <li>{@code MyBean[]} - <li>{@code HashMap[]} - </ul> - <h6 class='topic'>Example</h6> - <p> - The following example shows how to generate Cognos-XML from a POJO. - The example uses the <a class='doclink' href='../../doc-files/AddressBook.html'>AddressBook</a> sample POJO. - It should be noted that since the {@code AddressBook} class is a subclass of {@code LinkedList}, it fulfills - the requirement of being a tabular data structure. - </p> - <p class='bcode'> - <jc>// Create our POJO with some entries.</jc> - AddressBook addressBook = <jk>new</jk> AddressBook(); - addressBook.add( - <jk>new</jk> Person(<js>"Barack Obama"</js>, <js>"Aug 4, 1961"</js>, - <jk>new</jk> Address(<js>"1600 Pennsylvania Ave"</js>, <js>"Washington"</js>, <js>"DC"</js>, 20500, <jk>true</jk>), - <jk>new</jk> Address(<js>"5046 S Greenwood Ave"</js>, <js>"Chicago"</js>, <js>"IL"</js>, 60615, <jk>false</jk>) - ) - ); - addressBook.add( - <jk>new</jk> Person(<js>"George Walker Bush"</js>, <js>"Jul 6, 1946"</js>, - <jk>new</jk> Address(<js>"43 Prairie Chapel Rd"</js>, <js>"Crawford"</js>, <js>"TX"</js>, 76638, <jk>true</jk>), - <jk>new</jk> Address(<js>"1600 Pennsylvania Ave"</js>, <js>"Washington"</js>, <js>"DC"</js>, 20500, <jk>false</jk>) - ) - ); - - <jc>// Define the Cognos metadata</jc> - Column[] items = { - <jk>new</jk> Column(<js>"name"</js>, <js>"xs:String"</js>, 255), - <jk>new</jk> Column(<js>"age"</js>, <js>"xs:int"</js>), - <jk>new</jk> Column(<js>"numAddresses"</js>, <js>"xs:int"</js>) - .addTransform( - <jk>new</jk> PojoTransform<Person,Integer>() { - <ja>@Override</ja> - <jk>public</jk> Integer transform(Person p) { - <jk>return</jk> p.<jf>addresses</jf>.size(); - } - } - ) - }; - - <jc>// Create the Cognos DataSet object</jc> - DataSet ds = <jk>new</jk> DataSet(items, <jsf>addressBook</jsf>, BeanContext.<jsf>DEFAULT</jsf>); - - <jc>// Serialize it to XML</jc> - String xml = XmlSerializer.<jsf>DEFAULT_SQ</jsf>.serialize(ds); - </p> - <p> - When run, this code produces the following XML... - </p> - <p class='bcode'> - <xt><?xml</xt> <xa>version</xa>=<xs>'1.0'</xs> <xa>encoding</xa>=<xs>'UTF-8'</xs><xt>?></xt> - <xt><c:dataset <xa>xmlns:c</xa>=<xs>'http://developer.cognos.com/schemas/xmldata/1/'</xs>></xt> - <xt><c:metadata></xt> - <xt><c:item</xt> <xa>name</xa>=<xs>'name'</xs> <xa>type</xa>=<xs>'xs:String'</xs> <xa>length</xa>=<xs>'255'</xs><xt>/></xt> - <xt><c:item</xt> <xa>name</xa>=<xs>'age'</xs> <xa>type</xa>=<xs>'xs:int'</xs><xt>/></xt> - <xt><c:item</xt> <xa>name</xa>=<xs>'numAddresses'</xs> <xa>type</xa>=<xs>'xs:int'</xs><xt>/></xt> - <xt></c:metadata></xt> - <xt><c:data></xt> - <xt><c:row></xt> - <xt><c:value></xt>Barack Obama<xt></c:value></xt> - <xt><c:value></xt>52<xt></c:value></xt> - <xt><c:value></xt>2<xt></c:value></xt> - <xt></c:row></xt> - <xt><c:row></xt> - <xt><c:value></xt>George Walker Bush<xt></c:value></xt> - <xt><c:value></xt>67<xt></c:value></xt> - <xt><c:value></xt>2<xt></c:value></xt> - <xt></c:row></xt> - <xt></c:data></xt> - <xt></c:dataset></xt> - </p> - <h6 class='topic'>Other data formats</h6> - <p> - The following shows examples of what this data structure looks like when serialized to other formats: - </p> - <h6 class='figure'>HTML</h6> - <img class='bordered' src='doc-files/HTML.png'> - <h6 class='figure'>JSON</h6> - <img class='bordered' src='doc-files/JSON.png'> - <h6 class='figure'>RDF/XML</h6> - <img class='bordered' src='doc-files/RDFXML.png'> -</div> - -<!-- ======================================================================================================== --> -<a id="CognosParser"></a> -<h2 class='topic' onclick='toggle(this)'>2 - Cognos parsing support</h2> -<div class='topic'> - <p> - The {@link org.apache.juneau.dto.cognos.DataSet} class can be reconstructed from Cognos/XML using one of the standard XML parsers. - </p> - <h6 class='topic'>Example</h6> - <p class='bcode'> - <jc>// Parse XML back into original DataSet</jc> - DataSet ds = XmlParser.<jsf>DEFAULT</jsf>.parse(xml, DataSet.<jk>class</jk>); - </p> -</div> -</body> -</html> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/2c3a7cb5/com.ibm.team.juno/src/main/java/org/apache/juneau/dto/jsonschema/JsonType.java ---------------------------------------------------------------------- diff --git a/com.ibm.team.juno/src/main/java/org/apache/juneau/dto/jsonschema/JsonType.java b/com.ibm.team.juno/src/main/java/org/apache/juneau/dto/jsonschema/JsonType.java deleted file mode 100644 index f189a15..0000000 --- a/com.ibm.team.juno/src/main/java/org/apache/juneau/dto/jsonschema/JsonType.java +++ /dev/null @@ -1,107 +0,0 @@ -/*************************************************************************************************************************** - * 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. - ***************************************************************************************************************************/ -package org.apache.juneau.dto.jsonschema; - -/** - * Represents possible JSON types in the JSON-Schema core specification. - * <p> - * Implements custom <code>toString()</code> and <code>fromString(String)</code> methods - * that override the default serialization/parsing behavior of <code>Enum</code> types - * so that they are represented in lowercase form (as per the specification). - * - * <h6 class='figure'>Example</h6> - * <p class='bcode'> - * // Produces 'number', not 'NUMBER'. - * String json = JsonSerializer.DEFAULT.serialize(JsonType.NUMBER); - * </p> - * - * <p> - * Refer to {@link org.apache.juneau.dto.jsonschema} for usage information. - * - * @author James Bognar ([email protected]) - */ -public enum JsonType { - - /** array */ - ARRAY("array"), - - /** boolean */ - BOOLEAN("boolean"), - - /** integer */ - INTEGER("integer"), - - /** null */ - NULL("null"), - - /** number */ - NUMBER("number"), - - /** object */ - OBJECT("object"), - - /** string */ - STRING("string"), - - /** any */ - ANY("any"); - - private final String value; // The serialized format of the enum. - - private JsonType(String value) { - this.value = value; - } - - /** - * Returns the lowercase form of this enum that's compatible with the JSON-Schema specification. - */ - @Override /* Object */ - public String toString() { - return value; - } - - /** - * Converts the specified lowercase form of the enum back into an <code>Enum</code>. - * - * @param value The lowercase form of the enum (e.g. <js>"array"</js>). - * @return The matching <code>Enum</code>, or <jk>null</jk> if no match found. - */ - public static JsonType fromString(String value) { - if (value == null || value.length() < 4) - return null; - char c = value.charAt(0); - if (c == 'a') { - if (value.equals("array")) - return ARRAY; - if (value.equals("any")) - return ANY; - } - if (c == 'b' && value.equals("boolean")) - return BOOLEAN; - if (c == 'i' && value.equals("integer")) - return INTEGER; - if (c == 'n') { - c = value.charAt(2); - if (c == 'l' && value.equals("null")) - return NULL; - if (c == 'm' && value.equals("number")) - return NUMBER; - return null; - } - if (c == 'o' && value.equals("object")) - return OBJECT; - if (c == 's' && value.equals("string")) - return STRING; - return null; - } -} http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/2c3a7cb5/com.ibm.team.juno/src/main/java/org/apache/juneau/dto/jsonschema/JsonTypeArray.java ---------------------------------------------------------------------- diff --git a/com.ibm.team.juno/src/main/java/org/apache/juneau/dto/jsonschema/JsonTypeArray.java b/com.ibm.team.juno/src/main/java/org/apache/juneau/dto/jsonschema/JsonTypeArray.java deleted file mode 100644 index 9ec00c0..0000000 --- a/com.ibm.team.juno/src/main/java/org/apache/juneau/dto/jsonschema/JsonTypeArray.java +++ /dev/null @@ -1,54 +0,0 @@ -/*************************************************************************************************************************** - * 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. - ***************************************************************************************************************************/ -package org.apache.juneau.dto.jsonschema; - -import java.util.*; - -/** - * Represents a list of {@link JsonType} objects. - * <p> - * Refer to {@link org.apache.juneau.dto.jsonschema} for usage information. - * - * @author James Bognar ([email protected]) - */ -public final class JsonTypeArray extends LinkedList<JsonType> { - - private static final long serialVersionUID = 1L; - - /** - * Default constructor. - */ - public JsonTypeArray() {} - - /** - * Constructor with predefined types to add to this list. - * - * @param types The list of types to add to the list. - */ - public JsonTypeArray(JsonType...types) { - addAll(types); - } - - /** - * Convenience method for adding one or more {@link JsonType} objects to - * this array. - * - * @param types The {@link JsonType} objects to add to this array. - * @return This object (for method chaining). - */ - public JsonTypeArray addAll(JsonType...types) { - for (JsonType t : types) - add(t); - return this; - } -} http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/2c3a7cb5/com.ibm.team.juno/src/main/java/org/apache/juneau/dto/jsonschema/Sample.java ---------------------------------------------------------------------- diff --git a/com.ibm.team.juno/src/main/java/org/apache/juneau/dto/jsonschema/Sample.java b/com.ibm.team.juno/src/main/java/org/apache/juneau/dto/jsonschema/Sample.java deleted file mode 100644 index 43d99fc..0000000 --- a/com.ibm.team.juno/src/main/java/org/apache/juneau/dto/jsonschema/Sample.java +++ /dev/null @@ -1,67 +0,0 @@ -/*************************************************************************************************************************** - * 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. - ***************************************************************************************************************************/ -package org.apache.juneau.dto.jsonschema; - -import java.io.*; -import java.net.*; - -import org.apache.juneau.internal.*; -import org.apache.juneau.json.*; - -@SuppressWarnings("serial") -class Sample { - - public static void main(String[] args) { - - // Create a SchemaMap for looking up schemas. - SchemaMap schemaMap = new SchemaMap() { - - @Override /* SchemaMap */ - public Schema load(URI uri) { - Reader r = null; - try { - r = new InputStreamReader(uri.toURL().openStream(), IOUtils.UTF8); - Schema s = JsonParser.DEFAULT.parse(r, Schema.class); - return s; - } catch (Exception e) { - throw new RuntimeException(e); - } finally { - if (r != null) { - try { - r.close(); - } catch (IOException e) { - } - } - } - } - }; - - // Get schema from the schema map. - Schema purchaseOrderSchema = schemaMap.get("http://www.ibm.com/purchase-order/PurchaseOrder#"); - - JsonType streetType = purchaseOrderSchema - .getProperty("address",true) // Get "address" property, resolved to Address schema. - .getProperty("street") // Get "street" property. - .getTypeAsJsonType(); // Get data type. - System.err.println("streetType=" + streetType); // Prints "streetType=string" - - JsonType productIdType = purchaseOrderSchema - .getProperty("product") // Get "product" property - .getItemsAsSchemaArray() // Get "items". - .get(0) // Get first entry. - .resolve() // Resolve to Product schema. - .getProperty("productId") // Get "productId" property. - .getTypeAsJsonType(); // Get data type. - System.err.println("productIdType=" + productIdType); // Prints "productIdType=number" - } -}
