You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@juneau.apache.org by ja...@apache.org on 2017/01/21 22:25:20 UTC
[21/21] incubator-juneau git commit: HTML and XML serialization
support improvements.
HTML and XML serialization support improvements.
Project: http://git-wip-us.apache.org/repos/asf/incubator-juneau/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-juneau/commit/4fb01038
Tree: http://git-wip-us.apache.org/repos/asf/incubator-juneau/tree/4fb01038
Diff: http://git-wip-us.apache.org/repos/asf/incubator-juneau/diff/4fb01038
Branch: refs/heads/master
Commit: 4fb01038a29a86539bf8ea4ca1bbba4ec8c76175
Parents: 615190a
Author: JamesBognar <ja...@apache.org>
Authored: Sat Jan 21 17:24:51 2017 -0500
Committer: JamesBognar <ja...@apache.org>
Committed: Sat Jan 21 17:24:51 2017 -0500
----------------------------------------------------------------------
.../java/org/apache/juneau/client/package.html | 2 +-
.../java/org/apache/juneau/BeanContext.java | 20 +-
.../java/org/apache/juneau/BeanDictionary.java | 88 +-
.../apache/juneau/BeanDictionaryBuilder.java | 73 -
.../main/java/org/apache/juneau/BeanMeta.java | 55 +-
.../org/apache/juneau/BeanPropertyMeta.java | 163 +-
.../java/org/apache/juneau/BeanRegistry.java | 144 ++
.../java/org/apache/juneau/BeanSession.java | 36 +-
.../main/java/org/apache/juneau/ClassMeta.java | 63 +-
.../main/java/org/apache/juneau/ObjectMap.java | 12 +-
.../java/org/apache/juneau/annotation/Bean.java | 15 +
.../apache/juneau/annotation/BeanProperty.java | 3 +-
.../org/apache/juneau/dto/atom/AtomBuilder.java | 224 +++
.../org/apache/juneau/dto/atom/Category.java | 23 +-
.../java/org/apache/juneau/dto/atom/Common.java | 25 +-
.../org/apache/juneau/dto/atom/CommonEntry.java | 155 +-
.../org/apache/juneau/dto/atom/Content.java | 47 +-
.../java/org/apache/juneau/dto/atom/Entry.java | 109 +-
.../java/org/apache/juneau/dto/atom/Feed.java | 114 +-
.../org/apache/juneau/dto/atom/Generator.java | 36 +-
.../java/org/apache/juneau/dto/atom/Icon.java | 40 +-
.../java/org/apache/juneau/dto/atom/Id.java | 19 +-
.../java/org/apache/juneau/dto/atom/Link.java | 34 +-
.../java/org/apache/juneau/dto/atom/Logo.java | 41 +-
.../java/org/apache/juneau/dto/atom/Person.java | 40 +-
.../java/org/apache/juneau/dto/atom/Source.java | 89 +-
.../java/org/apache/juneau/dto/atom/Text.java | 76 +-
.../java/org/apache/juneau/dto/atom/Utils.java | 49 +
.../org/apache/juneau/dto/atom/package.html | 83 +-
.../java/org/apache/juneau/dto/html5/A.java | 118 ++
.../java/org/apache/juneau/dto/html5/Abbr.java | 58 +
.../org/apache/juneau/dto/html5/Address.java | 52 +
.../java/org/apache/juneau/dto/html5/Area.java | 138 ++
.../org/apache/juneau/dto/html5/Article.java | 96 +
.../java/org/apache/juneau/dto/html5/Aside.java | 52 +
.../java/org/apache/juneau/dto/html5/Audio.java | 127 ++
.../java/org/apache/juneau/dto/html5/B.java | 52 +
.../java/org/apache/juneau/dto/html5/Base.java | 61 +
.../java/org/apache/juneau/dto/html5/Bdi.java | 45 +
.../java/org/apache/juneau/dto/html5/Bdo.java | 58 +
.../org/apache/juneau/dto/html5/Blockquote.java | 63 +
.../java/org/apache/juneau/dto/html5/Body.java | 118 ++
.../java/org/apache/juneau/dto/html5/Br.java | 39 +
.../org/apache/juneau/dto/html5/Button.java | 184 ++
.../org/apache/juneau/dto/html5/Canvas.java | 61 +
.../org/apache/juneau/dto/html5/Caption.java | 52 +
.../java/org/apache/juneau/dto/html5/Cite.java | 52 +
.../java/org/apache/juneau/dto/html5/Code.java | 52 +
.../java/org/apache/juneau/dto/html5/Col.java | 50 +
.../org/apache/juneau/dto/html5/Colgroup.java | 57 +
.../java/org/apache/juneau/dto/html5/Data.java | 63 +
.../org/apache/juneau/dto/html5/Datalist.java | 46 +
.../java/org/apache/juneau/dto/html5/Dd.java | 52 +
.../java/org/apache/juneau/dto/html5/Del.java | 74 +
.../java/org/apache/juneau/dto/html5/Dfn.java | 52 +
.../java/org/apache/juneau/dto/html5/Div.java | 52 +
.../java/org/apache/juneau/dto/html5/Dl.java | 46 +
.../java/org/apache/juneau/dto/html5/Dt.java | 52 +
.../java/org/apache/juneau/dto/html5/Em.java | 52 +
.../java/org/apache/juneau/dto/html5/Embed.java | 83 +
.../org/apache/juneau/dto/html5/Fieldset.java | 85 +
.../org/apache/juneau/dto/html5/Figcaption.java | 52 +
.../org/apache/juneau/dto/html5/Figure.java | 46 +
.../org/apache/juneau/dto/html5/Footer.java | 52 +
.../java/org/apache/juneau/dto/html5/Form.java | 141 ++
.../java/org/apache/juneau/dto/html5/H1.java | 52 +
.../java/org/apache/juneau/dto/html5/H2.java | 52 +
.../java/org/apache/juneau/dto/html5/H3.java | 52 +
.../java/org/apache/juneau/dto/html5/H4.java | 52 +
.../java/org/apache/juneau/dto/html5/H5.java | 52 +
.../java/org/apache/juneau/dto/html5/H6.java | 52 +
.../java/org/apache/juneau/dto/html5/Head.java | 46 +
.../org/apache/juneau/dto/html5/Header.java | 52 +
.../java/org/apache/juneau/dto/html5/Hr.java | 39 +
.../java/org/apache/juneau/dto/html5/Html.java | 57 +
.../juneau/dto/html5/HtmlBeanDictionary.java | 139 ++
.../apache/juneau/dto/html5/HtmlBuilder.java | 1845 +++++++++++++++++
.../apache/juneau/dto/html5/HtmlElement.java | 673 +++++++
.../juneau/dto/html5/HtmlElementContainer.java | 59 +
.../juneau/dto/html5/HtmlElementEmpty.java | 19 +
.../juneau/dto/html5/HtmlElementMixed.java | 62 +
.../juneau/dto/html5/HtmlElementText.java | 45 +
.../java/org/apache/juneau/dto/html5/I.java | 52 +
.../org/apache/juneau/dto/html5/Iframe.java | 118 ++
.../java/org/apache/juneau/dto/html5/Img.java | 115 ++
.../java/org/apache/juneau/dto/html5/Input.java | 391 ++++
.../java/org/apache/juneau/dto/html5/Ins.java | 74 +
.../java/org/apache/juneau/dto/html5/Kbd.java | 52 +
.../org/apache/juneau/dto/html5/Keygen.java | 105 +
.../java/org/apache/juneau/dto/html5/Label.java | 74 +
.../org/apache/juneau/dto/html5/Legend.java | 52 +
.../java/org/apache/juneau/dto/html5/Li.java | 52 +
.../java/org/apache/juneau/dto/html5/Link.java | 116 ++
.../java/org/apache/juneau/dto/html5/Main.java | 46 +
.../java/org/apache/juneau/dto/html5/Map.java | 57 +
.../java/org/apache/juneau/dto/html5/Mark.java | 52 +
.../java/org/apache/juneau/dto/html5/Meta.java | 83 +
.../java/org/apache/juneau/dto/html5/Meter.java | 118 ++
.../java/org/apache/juneau/dto/html5/Nav.java | 52 +
.../org/apache/juneau/dto/html5/Noscript.java | 53 +
.../org/apache/juneau/dto/html5/Object2.java | 140 ++
.../java/org/apache/juneau/dto/html5/Ol.java | 79 +
.../org/apache/juneau/dto/html5/Optgroup.java | 68 +
.../org/apache/juneau/dto/html5/Option.java | 89 +
.../org/apache/juneau/dto/html5/Output.java | 85 +
.../java/org/apache/juneau/dto/html5/P.java | 52 +
.../java/org/apache/juneau/dto/html5/Param.java | 61 +
.../java/org/apache/juneau/dto/html5/Pre.java | 52 +
.../org/apache/juneau/dto/html5/Progress.java | 74 +
.../java/org/apache/juneau/dto/html5/Q.java | 63 +
.../java/org/apache/juneau/dto/html5/Rb.java | 52 +
.../java/org/apache/juneau/dto/html5/Rp.java | 52 +
.../java/org/apache/juneau/dto/html5/Rt.java | 52 +
.../java/org/apache/juneau/dto/html5/Rtc.java | 52 +
.../java/org/apache/juneau/dto/html5/Ruby.java | 52 +
.../java/org/apache/juneau/dto/html5/S.java | 52 +
.../java/org/apache/juneau/dto/html5/Samp.java | 52 +
.../org/apache/juneau/dto/html5/Script.java | 118 ++
.../org/apache/juneau/dto/html5/Section.java | 52 +
.../org/apache/juneau/dto/html5/Select.java | 123 ++
.../java/org/apache/juneau/dto/html5/Small.java | 52 +
.../org/apache/juneau/dto/html5/Source.java | 61 +
.../java/org/apache/juneau/dto/html5/Span.java | 52 +
.../org/apache/juneau/dto/html5/Strong.java | 52 +
.../java/org/apache/juneau/dto/html5/Style.java | 74 +
.../java/org/apache/juneau/dto/html5/Sub.java | 52 +
.../java/org/apache/juneau/dto/html5/Sup.java | 52 +
.../java/org/apache/juneau/dto/html5/Table.java | 57 +
.../java/org/apache/juneau/dto/html5/Tbody.java | 46 +
.../java/org/apache/juneau/dto/html5/Td.java | 85 +
.../org/apache/juneau/dto/html5/Template.java | 52 +
.../org/apache/juneau/dto/html5/Textarea.java | 210 ++
.../java/org/apache/juneau/dto/html5/Tfoot.java | 46 +
.../java/org/apache/juneau/dto/html5/Th.java | 118 ++
.../java/org/apache/juneau/dto/html5/Thead.java | 46 +
.../java/org/apache/juneau/dto/html5/Time.java | 63 +
.../java/org/apache/juneau/dto/html5/Title.java | 45 +
.../java/org/apache/juneau/dto/html5/Tr.java | 46 +
.../java/org/apache/juneau/dto/html5/Track.java | 94 +
.../java/org/apache/juneau/dto/html5/U.java | 52 +
.../java/org/apache/juneau/dto/html5/Ul.java | 52 +
.../java/org/apache/juneau/dto/html5/Var.java | 52 +
.../java/org/apache/juneau/dto/html5/Video.java | 160 ++
.../java/org/apache/juneau/dto/html5/Wbr.java | 39 +
.../org/apache/juneau/dto/html5/package.html | 41 +
.../apache/juneau/dto/jsonschema/Schema.java | 1 +
.../java/org/apache/juneau/html/HtmlParser.java | 522 ++---
.../apache/juneau/html/HtmlParserContext.java | 4 +-
.../apache/juneau/html/HtmlParserSession.java | 22 +-
.../juneau/html/HtmlSchemaDocSerializer.java | 6 +-
.../org/apache/juneau/html/HtmlSerializer.java | 269 ++-
.../java/org/apache/juneau/html/HtmlWriter.java | 7 +-
.../org/apache/juneau/html/dto/proto/A.java | 54 -
.../org/apache/juneau/html/dto/proto/Abbr.java | 23 -
.../apache/juneau/html/dto/proto/Address.java | 23 -
.../org/apache/juneau/html/dto/proto/Area.java | 23 -
.../apache/juneau/html/dto/proto/Article.java | 23 -
.../org/apache/juneau/html/dto/proto/Aside.java | 23 -
.../org/apache/juneau/html/dto/proto/Audio.java | 23 -
.../org/apache/juneau/html/dto/proto/B.java | 23 -
.../org/apache/juneau/html/dto/proto/Base.java | 23 -
.../org/apache/juneau/html/dto/proto/Bdi.java | 23 -
.../org/apache/juneau/html/dto/proto/Bdo.java | 23 -
.../juneau/html/dto/proto/Blockquote.java | 23 -
.../org/apache/juneau/html/dto/proto/Body.java | 23 -
.../org/apache/juneau/html/dto/proto/Br.java | 23 -
.../apache/juneau/html/dto/proto/Button.java | 23 -
.../apache/juneau/html/dto/proto/Canvas.java | 23 -
.../apache/juneau/html/dto/proto/Caption.java | 23 -
.../org/apache/juneau/html/dto/proto/Cite.java | 23 -
.../org/apache/juneau/html/dto/proto/Code.java | 23 -
.../org/apache/juneau/html/dto/proto/Col.java | 23 -
.../apache/juneau/html/dto/proto/Colgroup.java | 23 -
.../apache/juneau/html/dto/proto/Command.java | 23 -
.../org/apache/juneau/html/dto/proto/Data.java | 23 -
.../apache/juneau/html/dto/proto/Datalist.java | 23 -
.../org/apache/juneau/html/dto/proto/Dd.java | 23 -
.../org/apache/juneau/html/dto/proto/Del.java | 23 -
.../apache/juneau/html/dto/proto/Details.java | 23 -
.../org/apache/juneau/html/dto/proto/Dfn.java | 23 -
.../org/apache/juneau/html/dto/proto/Div.java | 23 -
.../org/apache/juneau/html/dto/proto/Dl.java | 23 -
.../org/apache/juneau/html/dto/proto/Dt.java | 23 -
.../org/apache/juneau/html/dto/proto/Em.java | 23 -
.../org/apache/juneau/html/dto/proto/Embed.java | 23 -
.../apache/juneau/html/dto/proto/Fieldset.java | 23 -
.../juneau/html/dto/proto/Figcaption.java | 23 -
.../apache/juneau/html/dto/proto/Figure.java | 23 -
.../apache/juneau/html/dto/proto/Footer.java | 23 -
.../org/apache/juneau/html/dto/proto/Form.java | 23 -
.../org/apache/juneau/html/dto/proto/H1.java | 23 -
.../org/apache/juneau/html/dto/proto/H2.java | 23 -
.../org/apache/juneau/html/dto/proto/H3.java | 23 -
.../org/apache/juneau/html/dto/proto/H4.java | 23 -
.../org/apache/juneau/html/dto/proto/H5.java | 23 -
.../org/apache/juneau/html/dto/proto/H6.java | 23 -
.../org/apache/juneau/html/dto/proto/Head.java | 23 -
.../apache/juneau/html/dto/proto/Header.java | 23 -
.../apache/juneau/html/dto/proto/Hgroup.java | 23 -
.../org/apache/juneau/html/dto/proto/Hr.java | 23 -
.../org/apache/juneau/html/dto/proto/Html.java | 23 -
.../juneau/html/dto/proto/HtmlElement.java | 1298 ------------
.../juneau/html/dto/proto/HtmlSchema.java | 27 -
.../org/apache/juneau/html/dto/proto/I.java | 23 -
.../apache/juneau/html/dto/proto/IFrame.java | 23 -
.../org/apache/juneau/html/dto/proto/Img.java | 38 -
.../org/apache/juneau/html/dto/proto/Input.java | 23 -
.../org/apache/juneau/html/dto/proto/Ins.java | 23 -
.../org/apache/juneau/html/dto/proto/Kbd.java | 23 -
.../apache/juneau/html/dto/proto/Keygen.java | 23 -
.../org/apache/juneau/html/dto/proto/Label.java | 23 -
.../apache/juneau/html/dto/proto/Legend.java | 23 -
.../org/apache/juneau/html/dto/proto/Li.java | 23 -
.../org/apache/juneau/html/dto/proto/Link.java | 23 -
.../org/apache/juneau/html/dto/proto/Main.java | 23 -
.../org/apache/juneau/html/dto/proto/Map.java | 23 -
.../org/apache/juneau/html/dto/proto/Mark.java | 23 -
.../org/apache/juneau/html/dto/proto/Menu.java | 23 -
.../org/apache/juneau/html/dto/proto/Meta.java | 23 -
.../org/apache/juneau/html/dto/proto/Meter.java | 23 -
.../org/apache/juneau/html/dto/proto/Nav.java | 23 -
.../apache/juneau/html/dto/proto/Noscript.java | 23 -
.../apache/juneau/html/dto/proto/Object.java | 23 -
.../org/apache/juneau/html/dto/proto/Ol.java | 23 -
.../apache/juneau/html/dto/proto/Optgroup.java | 23 -
.../apache/juneau/html/dto/proto/Option.java | 23 -
.../apache/juneau/html/dto/proto/Output.java | 23 -
.../org/apache/juneau/html/dto/proto/P.java | 23 -
.../org/apache/juneau/html/dto/proto/Param.java | 23 -
.../org/apache/juneau/html/dto/proto/Pre.java | 23 -
.../apache/juneau/html/dto/proto/Progress.java | 23 -
.../org/apache/juneau/html/dto/proto/Q.java | 23 -
.../org/apache/juneau/html/dto/proto/Rb.java | 23 -
.../org/apache/juneau/html/dto/proto/Rp.java | 23 -
.../org/apache/juneau/html/dto/proto/Rt.java | 23 -
.../org/apache/juneau/html/dto/proto/Rtc.java | 23 -
.../org/apache/juneau/html/dto/proto/Ruby.java | 23 -
.../org/apache/juneau/html/dto/proto/S.java | 23 -
.../org/apache/juneau/html/dto/proto/Samp.java | 23 -
.../apache/juneau/html/dto/proto/Script.java | 23 -
.../apache/juneau/html/dto/proto/Section.java | 23 -
.../apache/juneau/html/dto/proto/Select.java | 23 -
.../org/apache/juneau/html/dto/proto/Small.java | 23 -
.../apache/juneau/html/dto/proto/Source.java | 23 -
.../org/apache/juneau/html/dto/proto/Span.java | 23 -
.../apache/juneau/html/dto/proto/Strong.java | 23 -
.../org/apache/juneau/html/dto/proto/Style.java | 23 -
.../org/apache/juneau/html/dto/proto/Sub.java | 23 -
.../apache/juneau/html/dto/proto/Summary.java | 23 -
.../org/apache/juneau/html/dto/proto/Sup.java | 23 -
.../org/apache/juneau/html/dto/proto/Table.java | 23 -
.../org/apache/juneau/html/dto/proto/Tbody.java | 23 -
.../org/apache/juneau/html/dto/proto/Td.java | 23 -
.../apache/juneau/html/dto/proto/Template.java | 23 -
.../apache/juneau/html/dto/proto/Textarea.java | 23 -
.../org/apache/juneau/html/dto/proto/Tfoot.java | 23 -
.../org/apache/juneau/html/dto/proto/Th.java | 23 -
.../org/apache/juneau/html/dto/proto/Thead.java | 23 -
.../org/apache/juneau/html/dto/proto/Time.java | 23 -
.../org/apache/juneau/html/dto/proto/Title.java | 23 -
.../org/apache/juneau/html/dto/proto/Tr.java | 23 -
.../org/apache/juneau/html/dto/proto/Track.java | 23 -
.../org/apache/juneau/html/dto/proto/U.java | 23 -
.../org/apache/juneau/html/dto/proto/Ul.java | 23 -
.../org/apache/juneau/html/dto/proto/Var.java | 23 -
.../org/apache/juneau/html/dto/proto/Video.java | 23 -
.../org/apache/juneau/html/dto/proto/Wbr.java | 23 -
.../apache/juneau/html/dto/proto/package.html | 41 -
.../org/apache/juneau/html/dto/proto/temp.txt | 154 --
.../java/org/apache/juneau/html/package.html | 518 ++++-
.../org/apache/juneau/internal/ClassUtils.java | 88 +
.../apache/juneau/internal/DelegateList.java | 7 +-
.../org/apache/juneau/internal/FilteredMap.java | 16 +-
.../java/org/apache/juneau/jena/RdfParser.java | 6 +-
.../apache/juneau/jena/RdfParserSession.java | 2 +-
.../org/apache/juneau/jena/RdfSerializer.java | 4 +-
.../java/org/apache/juneau/jena/package.html | 2 +-
.../java/org/apache/juneau/json/JsonParser.java | 10 +-
.../juneau/json/JsonSchemaSerializer.java | 6 +-
.../org/apache/juneau/json/JsonSerializer.java | 2 +-
.../java/org/apache/juneau/json/package.html | 2 +-
.../apache/juneau/msgpack/MsgPackParser.java | 10 +-
.../main/java/org/apache/juneau/package.html | 2 -
.../java/org/apache/juneau/parser/Parser.java | 2 +-
.../juneau/plaintext/PlainTextParser.java | 2 +-
.../juneau/serializer/SerializerSession.java | 11 +-
.../juneau/serializer/SerializerWriter.java | 13 +
.../org/apache/juneau/transform/MapSwap.java | 35 +
.../org/apache/juneau/transform/PojoSwap.java | 53 +-
.../org/apache/juneau/transform/StringSwap.java | 35 +
.../org/apache/juneau/transform/package.html | 11 +-
.../juneau/transforms/BeanStringSwap.java | 4 +-
.../juneau/transforms/ByteArrayBase64Swap.java | 2 +-
.../apache/juneau/transforms/CalendarSwap.java | 2 +-
.../org/apache/juneau/transforms/DateSwap.java | 2 +-
.../transforms/XMLGregorianCalendarSwap.java | 2 +-
.../apache/juneau/urlencoding/UonParser.java | 12 +-
.../juneau/urlencoding/UrlEncodingParser.java | 6 +-
.../urlencoding/UrlEncodingParserSession.java | 2 +-
.../UrlEncodingSerializerSession.java | 4 +-
.../org/apache/juneau/urlencoding/package.html | 2 +-
.../java/org/apache/juneau/utils/PojoQuery.java | 8 +-
.../java/org/apache/juneau/xml/XmlBeanMeta.java | 204 +-
.../apache/juneau/xml/XmlBeanPropertyMeta.java | 25 +-
.../org/apache/juneau/xml/XmlClassMeta.java | 4 +-
.../apache/juneau/xml/XmlContentHandler.java | 137 --
.../java/org/apache/juneau/xml/XmlParser.java | 178 +-
.../org/apache/juneau/xml/XmlParserContext.java | 52 +-
.../org/apache/juneau/xml/XmlParserSession.java | 64 +-
.../apache/juneau/xml/XmlSchemaSerializer.java | 149 +-
.../org/apache/juneau/xml/XmlSerializer.java | 411 ++--
.../apache/juneau/xml/XmlSerializerContext.java | 103 +-
.../apache/juneau/xml/XmlSerializerSession.java | 42 +-
.../java/org/apache/juneau/xml/XmlUtils.java | 47 +-
.../org/apache/juneau/xml/annotation/Xml.java | 11 +-
.../apache/juneau/xml/annotation/XmlFormat.java | 87 +-
.../java/org/apache/juneau/xml/package.html | 1849 +++++++++++++-----
juneau-core/src/main/javadoc/overview.html | 59 +-
.../src/main/javadoc/resources/juneau-code.css | 2 +
.../java/org/apache/juneau/BeanConfigTest.java | 6 +-
.../java/org/apache/juneau/JacocoDummyTest.java | 2 +-
.../java/org/apache/juneau/PojoSwapTest.java | 2 +-
.../test/java/org/apache/juneau/TestUtils.java | 2 +-
.../a/rttests/RoundTripAddClassAttrsTest.java | 2 +-
.../a/rttests/RoundTripLargeObjectsTest.java | 4 +-
.../juneau/a/rttests/RoundTripMapsTest.java | 6 +-
.../apache/juneau/a/rttests/RoundTripTest.java | 4 +-
.../a/rttests/RoundTripTransformBeansTest.java | 2 +-
.../org/apache/juneau/dto/atom/AtomTest.java | 205 +-
.../apache/juneau/dto/cognos/CognosXmlTest.java | 9 +-
.../juneau/dto/html/BasicHtmlSchemaTest.java | 156 ++
.../juneau/dto/jsonschema/JsonSchemaTest.java | 106 +-
.../org/apache/juneau/html/BasicHtmlTest.java | 1614 +++++++++++++++
.../java/org/apache/juneau/html/CommonTest.java | 148 +-
.../java/org/apache/juneau/html/HtmlTest.java | 24 +-
.../org/apache/juneau/json/JsonParserTest.java | 6 -
.../apache/juneau/transforms/BeanMapTest.java | 4 +-
.../juneau/transforms/CalendarSwapTest.java | 18 +-
.../apache/juneau/utils/FilteredMapTest.java | 11 +-
.../org/apache/juneau/xml/BasicXmlTest.java | 1505 ++++++++++++++
.../org/apache/juneau/xml/CommonParserTest.java | 4 +-
.../java/org/apache/juneau/xml/CommonTest.java | 33 +-
.../org/apache/juneau/xml/CommonXmlTest.java | 2 +-
.../apache/juneau/xml/InvalidXmlBeansTest.java | 230 +++
.../org/apache/juneau/xml/XmlCollapsedTest.java | 44 +-
.../org/apache/juneau/xml/XmlContentTest.java | 84 +-
.../java/org/apache/juneau/xml/XmlTest.java | 229 ++-
.../src/test/resources/dto/atom/test1.xml | 61 -
.../src/test/resources/dto/atom/test2.xml | 61 -
.../src/test/resources/dto/atom/test3.xml | 61 -
.../test/resources/dto/jsonschema/test1.json | 89 -
.../test/resources/dto/jsonschema/test2.json | 32 -
.../test/resources/json/BrokenCognosOutput.json | 13 -
juneau-core/src/test/resources/log4j.properties | 40 -
.../resources/xml/testComparisonWithJson.json | 29 -
.../resources/xml/testComparisonWithJson.xml | 32 -
.../src/test/resources/xml/testNamespaces.xml | 32 -
.../juneau/server/samples/AtomFeedResource.java | 64 +-
.../server/samples/TumblrParserResource.java | 4 +-
.../server/samples/addressbook/ClientTest.java | 2 +-
.../apache/juneau/server/samples/TestUtils.java | 2 +-
.../juneau/server/test/InheritanceResource.java | 6 +-
.../juneau/server/test/MessagesResource.java | 2 +-
.../juneau/server/test/TransformsResource.java | 6 +-
.../org/apache/juneau/server/RestRequest.java | 2 +-
.../org/apache/juneau/server/RestResponse.java | 2 +-
.../org/apache/juneau/server/RestServlet.java | 2 +-
.../juneau/server/remoteable/package.html | 2 +-
368 files changed, 19604 insertions(+), 7245 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/4fb01038/juneau-client/src/main/java/org/apache/juneau/client/package.html
----------------------------------------------------------------------
diff --git a/juneau-client/src/main/java/org/apache/juneau/client/package.html b/juneau-client/src/main/java/org/apache/juneau/client/package.html
index aa4a893..54067df 100755
--- a/juneau-client/src/main/java/org/apache/juneau/client/package.html
+++ b/juneau-client/src/main/java/org/apache/juneau/client/package.html
@@ -799,7 +799,7 @@
</p>
<ul class='spaced-list'>
<li>The method must be public.
- <li>The parameter and return types must be <a href='../../../../org/apache/juneau/package-summary.html#PojoCategories'>serializable and parsable</a>.
+ <li>The parameter and return types must be <a href='../../../../overview-summary.html#Core.PojoCategories'>serializable and parsable</a>.
</ul>
<p>
One significant feature is that the remoteable services servlet is a full-blown REST interface.
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/4fb01038/juneau-core/src/main/java/org/apache/juneau/BeanContext.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/BeanContext.java b/juneau-core/src/main/java/org/apache/juneau/BeanContext.java
index 0a6f3d3..69d7542 100644
--- a/juneau-core/src/main/java/org/apache/juneau/BeanContext.java
+++ b/juneau-core/src/main/java/org/apache/juneau/BeanContext.java
@@ -855,9 +855,8 @@ public class BeanContext extends Context {
* <p>
* This list can consist of the following class types:
* <ul>
- * <li>Any bean class that specifies a value for {@link Bean#typeName() @Bean.typeName()};
- * <li>Any subclass of {@link BeanDictionaryBuilder} that defines an entire subset of mappings.
- * Note that the subclass MUST implement a no-arg constructor so that it can be instantiated.
+ * <li>Any bean class that specifies a value for {@link Bean#typeName() @Bean.typeName()}.
+ * <li>Any collection of bean classes above.
* </ul>
*/
public static final String BEAN_beanDictionary = "BeanContext.beanDictionary.list";
@@ -1023,11 +1022,11 @@ public class BeanContext extends Context {
beanMethodVisibility,
beanFieldVisibility;
- final Class<?>[] notBeanClasses;
+ final Class<?>[] notBeanClasses, beanDictionaryClasses;
final String[] notBeanPackageNames, notBeanPackagePrefixes;
final BeanFilter[] beanFilters;
final PojoSwap<?,?>[] pojoSwaps;
- final BeanDictionary beanDictionary;
+ final BeanRegistry beanRegistry;
final Map<Class<?>,Class<?>> implClasses;
final Class<?>[] implKeyClasses, implValueClasses;
final ClassLoader classLoader;
@@ -1148,7 +1147,8 @@ public class BeanContext extends Context {
this.cmObject = cmCache.get(Object.class);
this.cmClass = cmCache.get(Class.class);
- beanDictionary = new BeanDictionaryBuilder().add(pm.get(BEAN_beanDictionary, Class[].class, new Class[0])).setBeanContext(this).build();
+ this.beanDictionaryClasses = pm.get(BEAN_beanDictionary, Class[].class, new Class[0]);
+ this.beanRegistry = new BeanRegistry(this, null);
}
/**
@@ -1794,12 +1794,12 @@ public class BeanContext extends Context {
}
/**
- * Returns the bean dictionary defined in this bean context defined by {@link BeanContext#BEAN_beanDictionary}.
+ * Returns the bean registry defined in this bean context defined by {@link BeanContext#BEAN_beanDictionary}.
*
- * @return The bean dictionary defined in this bean context. Never <jk>null</jk>.
+ * @return The bean registry defined in this bean context. Never <jk>null</jk>.
*/
- protected final BeanDictionary getBeanDictionary() {
- return beanDictionary;
+ protected final BeanRegistry getBeanRegistry() {
+ return beanRegistry;
}
/**
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/4fb01038/juneau-core/src/main/java/org/apache/juneau/BeanDictionary.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/BeanDictionary.java b/juneau-core/src/main/java/org/apache/juneau/BeanDictionary.java
index 053e021..333ef6d 100644
--- a/juneau-core/src/main/java/org/apache/juneau/BeanDictionary.java
+++ b/juneau-core/src/main/java/org/apache/juneau/BeanDictionary.java
@@ -17,87 +17,31 @@ import java.util.*;
import org.apache.juneau.annotation.*;
/**
- * A lookup table for resolving bean types by name.
- * <p>
- * In a nutshell, provides a simple mapping of bean class objects to identifying names.
- * <p>
- * Class names are defined through the {@link Bean#typeName()} annotation.
- * <p>
- * The dictionary is used by the framework in the following ways:
- * <ul>
- * <li>If a class type cannot be inferred through reflection during parsing, then a helper <js>"_type"</js> is added to the serialized output
- * using the name defined for that class in this dictionary. This helps determine the real class at parse time.
- * <li>The dictionary name is used as element names when serialized to XML.
- * </ul>
+ * Represents a collection of bean classes that make up a bean dictionary.
*/
-public class BeanDictionary {
-
- private final Map<String,ClassMeta<?>> map;
- private final BeanContext beanContext;
- private final String beanTypePropertyName;
-
- BeanDictionary(BeanDictionaryBuilder builder) {
- this.beanContext = builder.beanContext;
- this.beanTypePropertyName = beanContext.getBeanTypePropertyName();
- Map<String,ClassMeta<?>> m1 = new HashMap<String,ClassMeta<?>>();
- for (Map.Entry<String,Class<?>> e : builder.map.entrySet()) {
- ClassMeta<?> cm = beanContext.getClassMeta(e.getValue());
- if (! cm.isBean())
- throw new BeanRuntimeException("Invalid class type passed to dictionary. ''{0}'' is not a bean.", cm);
- m1.put(e.getKey(), cm);
- }
- this.map = Collections.unmodifiableMap(m1);
- }
-
- /**
- * Converts the specified object map into a bean if it contains a <js>"_type"</js> entry in it.
- *
- * @param m The object map to convert to a bean if possible.
- * @return The new bean, or the original <code>ObjectMap</code> if no <js>"_type"</js> entry was found.
- */
- public Object cast(ObjectMap m) {
- Object o = m.get(beanTypePropertyName);
- if (o == null)
- return m;
- String typeName = o.toString();
- ClassMeta<?> cm = getClassMeta(typeName);
- BeanMap<?> bm = m.getBeanSession().newBeanMap(cm.getInnerClass());
-
- // Iterate through all the entries in the map and set the individual field values.
- for (Map.Entry<String,Object> e : m.entrySet()) {
- String k = e.getKey();
- Object v = e.getValue();
- if (! k.equals(beanTypePropertyName)) {
- // Attempt to recursively cast child maps.
- if (v instanceof ObjectMap)
- v = cast((ObjectMap)v);
- bm.put(k, v);
- }
- }
- return bm.getBean();
- }
+public class BeanDictionary extends ArrayList<Class<?>> {
+ private static final long serialVersionUID = 1L;
/**
- * Gets the class metadata for the specified bean type name.
+ * Constructor.
*
- * @param typeName The bean type name as defined by {@link Bean#typeName()}.
- * @return The class metadata for the bean.
- * @throws BeanRuntimeException If name wasn't found in this dictionary.
+ * @param c The list of bean classes to add to this dictionary.
+ * Classes must either specify a {@link Bean#typeName()} value or be another subclass of <code>BeanDictionary</code>.
*/
- public ClassMeta<?> getClassMeta(String typeName) {
- ClassMeta<?> cm = map.get(typeName);
- if (cm == null)
- throw new BeanRuntimeException("Could not find bean type ''{0}'' in dictionary.", typeName);
- return cm;
+ public BeanDictionary(Class<?>...c) {
+ append(c);
}
/**
- * Returns <jk>true</jk> if this dictionary has an entry for the specified type name.
+ * Append one or more bean classes to this bean dictionary.
*
- * @param typeName The bean type name.
- * @return <jk>true</jk> if this dictionary has an entry for the specified type name.
+ * @param c The list of bean classes to add to this dictionary.
+ * Classes must either specify a {@link Bean#typeName()} value or be another subclass of <code>BeanDictionary</code>.
+ * @return This object (for method chaining).
*/
- public boolean hasName(String typeName) {
- return map.containsKey(typeName);
+ public BeanDictionary append(Class<?>...c) {
+ for (Class<?> cc : c)
+ add(cc);
+ return this;
}
}
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/4fb01038/juneau-core/src/main/java/org/apache/juneau/BeanDictionaryBuilder.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/BeanDictionaryBuilder.java b/juneau-core/src/main/java/org/apache/juneau/BeanDictionaryBuilder.java
deleted file mode 100644
index 349ca80..0000000
--- a/juneau-core/src/main/java/org/apache/juneau/BeanDictionaryBuilder.java
+++ /dev/null
@@ -1,73 +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;
-
-import java.util.*;
-
-import org.apache.juneau.annotation.*;
-import org.apache.juneau.internal.*;
-
-/**
- * Utility class for creating {@link BeanDictionary} objects.
- * <p>
- * This class is a programmatic equivalent to the {@link BeanProperty#beanDictionary()} annotation and {@link BeanContext#BEAN_beanDictionary} property.
- * It allows bean dictionaries to be constructed
- */
-public class BeanDictionaryBuilder {
-
- Map<String,Class<?>> map = new HashMap<String,Class<?>>();
- BeanContext beanContext;
-
- /**
- * Add the specified classes to this type dictionary.
- * <p>
- * Classes can be of the following types:
- * <ul>
- * <li>Bean classes.
- * <li>Subclasses of {@link BeanDictionaryBuilder} that identify an entire set of mappings.
- * </ul>
- *
- * @param classes The classes to add to this dictionary builder.
- * @return This object (for method chaining).
- */
- public BeanDictionaryBuilder add(Class<?>...classes) {
- for (Class<?> c : classes) {
- if (c != null) {
- if (ClassUtils.isParentClass(BeanDictionaryBuilder.class, c)) {
- try {
- BeanDictionaryBuilder l2 = (BeanDictionaryBuilder)c.newInstance();
- for (Map.Entry<String,Class<?>> e : l2.map.entrySet())
- map.put(e.getKey(), e.getValue());
- } catch (Exception e) {
- throw new BeanRuntimeException(e);
- }
- } else {
- Bean b = c.getAnnotation(Bean.class);
- if (b == null || b.typeName().isEmpty())
- throw new BeanRuntimeException("Class ''{0}'' was passed to TypeDictionaryBuilder but it doesn't have a @Bean.typeName() annotation defined.", c.getName());
- map.put(b.typeName(), c);
- }
- }
- }
- return this;
- }
-
- BeanDictionaryBuilder setBeanContext(BeanContext beanContext) {
- this.beanContext = beanContext;
- return this;
- }
-
- BeanDictionary build() {
- return new BeanDictionary(this);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/4fb01038/juneau-core/src/main/java/org/apache/juneau/BeanMeta.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/BeanMeta.java b/juneau-core/src/main/java/org/apache/juneau/BeanMeta.java
index 6ab27a5..6b1b63d 100644
--- a/juneau-core/src/main/java/org/apache/juneau/BeanMeta.java
+++ b/juneau-core/src/main/java/org/apache/juneau/BeanMeta.java
@@ -92,6 +92,7 @@ public class BeanMeta<T> {
private final BeanPropertyMeta typeProperty; // "_type" mock bean property.
private final String dictionaryName; // The @Bean.typeName() annotation defined on this bean class.
final String notABeanReason; // Readable string explaining why this class wasn't a bean.
+ final BeanRegistry beanRegistry;
/**
* Constructor.
@@ -119,10 +120,10 @@ public class BeanMeta<T> {
this.constructorArgs = b.constructorArgs;
this.extMeta = b.extMeta;
this.subTypeProperty = b.subTypeIdProperty;
- this.typeProperty = new BeanPropertyMeta(this, ctx.getBeanTypePropertyName(), ctx.string());
+ this.beanRegistry = b.beanRegistry;
+ this.typeProperty = new BeanPropertyMeta(this, ctx.getBeanTypePropertyName(), ctx.string(), beanRegistry);
}
-
private static final class Builder<T> {
ClassMeta<T> classMeta;
BeanContext ctx;
@@ -137,6 +138,7 @@ public class BeanMeta<T> {
MetadataMap extMeta = new MetadataMap();
BeanPropertyMeta subTypeIdProperty;
PropertyNamer propertyNamer;
+ BeanRegistry beanRegistry;
private Builder(ClassMeta<T> classMeta, BeanContext ctx, BeanFilter beanFilter, String[] pNames) {
this.classMeta = classMeta;
@@ -156,6 +158,15 @@ public class BeanMeta<T> {
mVis = ctx.beanMethodVisibility,
fVis = ctx.beanFieldVisibility;
+ List<Class<?>> bdClasses = new ArrayList<Class<?>>();
+ Bean bean = classMeta.innerClass.getAnnotation(Bean.class);
+ if (bean != null) {
+ bdClasses.addAll(Arrays.asList(bean.beanDictionary()));
+ if (! bean.typeName().isEmpty())
+ bdClasses.add(classMeta.innerClass);
+ }
+ this.beanRegistry = new BeanRegistry(ctx, null, bdClasses.toArray(new Class<?>[bdClasses.size()]));
+
// If @Bean.interfaceClass is specified on the parent class, then we want
// to use the properties defined on that class, not the subclass.
Class<?> c2 = (beanFilter != null && beanFilter.getInterfaceClass() != null ? beanFilter.getInterfaceClass() : c);
@@ -287,7 +298,7 @@ public class BeanMeta<T> {
for (Iterator<BeanPropertyMeta> i = normalProps.values().iterator(); i.hasNext();) {
BeanPropertyMeta p = i.next();
try {
- if (p.validate(ctx, typeVarImpls)) {
+ if (p.validate(ctx, beanRegistry, typeVarImpls)) {
if (p.getGetter() != null)
getterProps.put(p.getGetter(), p.getName());
@@ -326,7 +337,7 @@ public class BeanMeta<T> {
if (beanFilter != null && beanFilter.getSubTypeProperty() != null) {
String subTypeProperty = beanFilter.getSubTypeProperty();
- this.subTypeIdProperty = new SubTypePropertyMeta(beanMeta, subTypeProperty, beanFilter.getSubTypes(), normalProps.remove(subTypeProperty));
+ this.subTypeIdProperty = new SubTypePropertyMeta(beanMeta, subTypeProperty, beanFilter.getSubTypes(), normalProps.remove(subTypeProperty), beanRegistry);
properties.put(subTypeProperty, this.subTypeIdProperty);
}
@@ -518,7 +529,7 @@ public class BeanMeta<T> {
for (Class<?> c2 : findClasses(c, stopClass)) {
for (Method m : c2.getDeclaredMethods()) {
int mod = m.getModifiers();
- if (Modifier.isStatic(mod) || Modifier.isTransient(mod))
+ if (Modifier.isStatic(mod))
continue;
if (m.isAnnotationPresent(BeanIgnore.class))
continue;
@@ -530,19 +541,29 @@ public class BeanMeta<T> {
Class<?>[] pt = m.getParameterTypes();
Class<?> rt = m.getReturnType();
boolean isGetter = false, isSetter = false;
- if (pt.length == 1 && n.startsWith("set") && (isParentClass(rt, c) || rt.equals(Void.TYPE))) {
- isSetter = true;
- n = n.substring(3);
- } else if (pt.length == 0 && n.startsWith("get") && (! rt.equals(Void.TYPE))) {
- isGetter = true;
- n = n.substring(3);
- } else if (pt.length == 0 && n.startsWith("is") && (rt.equals(Boolean.TYPE) || rt.equals(Boolean.class))) {
- isGetter = true;
- n = n.substring(2);
+ BeanProperty bp = m.getAnnotation(BeanProperty.class);
+ if (pt.length == 0) {
+ if (n.startsWith("get") && (! rt.equals(Void.TYPE))) {
+ isGetter = true;
+ n = n.substring(3);
+ } else if (n.startsWith("is") && (rt.equals(Boolean.TYPE) || rt.equals(Boolean.class))) {
+ isGetter = true;
+ n = n.substring(2);
+ } else if (bp != null && ! bp.name().isEmpty()) {
+ isGetter = true;
+ n = bp.name();
+ }
+ } else if (pt.length == 1) {
+ if (n.startsWith("set") && (isParentClass(rt, c) || rt.equals(Void.TYPE))) {
+ isSetter = true;
+ n = n.substring(3);
+ } else if (bp != null && ! bp.name().isEmpty()) {
+ isSetter = true;
+ n = bp.name();
+ }
}
n = pn.getPropertyName(n);
if (isGetter || isSetter) {
- BeanProperty bp = m.getAnnotation(BeanProperty.class);
if (bp != null && ! bp.name().equals("")) {
n = bp.name();
if (! fixedBeanProps.isEmpty())
@@ -728,8 +749,8 @@ public class BeanMeta<T> {
private BeanPropertyMeta realProperty; // Bean property if bean actually has a real subtype field.
private BeanMeta<?> beanMeta;
- SubTypePropertyMeta(BeanMeta beanMeta, String subTypeAttr, Map<Class<?>,String> subTypes, BeanPropertyMeta realProperty) {
- super(beanMeta, subTypeAttr, beanMeta.ctx.string());
+ SubTypePropertyMeta(BeanMeta beanMeta, String subTypeAttr, Map<Class<?>,String> subTypes, BeanPropertyMeta realProperty, BeanRegistry beanRegistry) {
+ super(beanMeta, subTypeAttr, beanMeta.ctx.string(), beanRegistry);
this.subTypes = subTypes;
this.realProperty = realProperty;
this.beanMeta = beanMeta;
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/4fb01038/juneau-core/src/main/java/org/apache/juneau/BeanPropertyMeta.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/BeanPropertyMeta.java b/juneau-core/src/main/java/org/apache/juneau/BeanPropertyMeta.java
index 6d3a8cd..ce7fdb5 100644
--- a/juneau-core/src/main/java/org/apache/juneau/BeanPropertyMeta.java
+++ b/juneau-core/src/main/java/org/apache/juneau/BeanPropertyMeta.java
@@ -57,7 +57,7 @@ public class BeanPropertyMeta {
private PojoSwap swap; // PojoSwap defined only via @BeanProperty annotation.
private MetadataMap extMeta = new MetadataMap(); // Extended metadata
- private BeanDictionary beanDictionary;
+ BeanRegistry beanRegistry;
/**
* Constructor.
@@ -71,9 +71,10 @@ public class BeanPropertyMeta {
this.name = name;
}
- BeanPropertyMeta(BeanMeta<?> beanMeta, String name, ClassMeta<?> rawTypeMeta) {
+ BeanPropertyMeta(BeanMeta<?> beanMeta, String name, ClassMeta<?> rawTypeMeta, BeanRegistry beanRegistry) {
this(beanMeta, name);
this.rawTypeMeta = rawTypeMeta;
+ this.beanRegistry = beanRegistry;
}
BeanPropertyMeta(BeanMeta<?> beanMeta, String name, Method getter, Method setter) {
@@ -150,11 +151,10 @@ public class BeanPropertyMeta {
* <li>Dictionary defined via {@link BeanProperty#beanDictionary()}.
* <li>Dictionary defined via {@link BeanContext#BEAN_beanDictionary} context property.
* </ol>
- *
* @return The bean dictionary in use for this bean property. Never <jk>null</jk>.
*/
- public BeanDictionary getBeanDictionary() {
- return beanDictionary == null ? beanContext.getBeanDictionary() : beanDictionary;
+ public BeanRegistry getBeanRegistry() {
+ return beanRegistry;
}
/**
@@ -239,7 +239,9 @@ public class BeanPropertyMeta {
return extMeta.get(c, this);
}
- boolean validate(BeanContext f, Map<Class<?>,Class<?>[]> typeVarImpls) throws Exception {
+ boolean validate(BeanContext f, BeanRegistry parentBeanRegistry, Map<Class<?>,Class<?>[]> typeVarImpls) throws Exception {
+
+ List<Class<?>> bdClasses = new ArrayList<Class<?>>();
if (field == null && getter == null)
return false;
@@ -255,8 +257,7 @@ public class BeanPropertyMeta {
swap = getPropertyPojoSwap(p);
if (! p.properties().isEmpty())
properties = StringUtils.split(p.properties(), ',');
- if (p.beanDictionary().length > 0)
- this.beanDictionary = new BeanDictionaryBuilder().add(p.beanDictionary()).setBeanContext(beanContext).build();
+ bdClasses.addAll(Arrays.asList(p.beanDictionary()));
}
}
@@ -270,8 +271,7 @@ public class BeanPropertyMeta {
swap = getPropertyPojoSwap(p);
if (properties != null && ! p.properties().isEmpty())
properties = StringUtils.split(p.properties(), ',');
- if (p.beanDictionary().length > 0)
- this.beanDictionary = new BeanDictionaryBuilder().add(p.beanDictionary()).setBeanContext(beanContext).build();
+ bdClasses.addAll(Arrays.asList(p.beanDictionary()));
}
}
@@ -285,14 +285,15 @@ public class BeanPropertyMeta {
swap = getPropertyPojoSwap(p);
if (properties != null && ! p.properties().isEmpty())
properties = StringUtils.split(p.properties(), ',');
- if (p.beanDictionary().length > 0)
- this.beanDictionary = new BeanDictionaryBuilder().add(p.beanDictionary()).setBeanContext(beanContext).build();
+ bdClasses.addAll(Arrays.asList(p.beanDictionary()));
}
}
if (rawTypeMeta == null)
return false;
+ this.beanRegistry = new BeanRegistry(beanContext, parentBeanRegistry, bdClasses.toArray(new Class<?>[0]));
+
// Do some annotation validation.
Class<?> c = rawTypeMeta.getInnerClass();
if (getter != null && ! isParentClass(getter.getReturnType(), c))
@@ -327,9 +328,6 @@ public class BeanPropertyMeta {
*/
public Object get(BeanMap<?> m) {
try {
-
- BeanSession session = m.getBeanSession();
-
// Read-only beans have their properties stored in a cache until getBean() is called.
Object bean = m.bean;
if (bean == null)
@@ -346,13 +344,31 @@ public class BeanPropertyMeta {
else if (field != null)
o = field.get(bean);
+ return toSerializedForm(m.getBeanSession(), o);
+
+ } catch (Throwable e) {
+ if (beanContext.ignoreInvocationExceptionsOnGetters) {
+ if (rawTypeMeta.isPrimitive())
+ return rawTypeMeta.getPrimitiveDefault();
+ return null;
+ }
+ throw new BeanRuntimeException(beanMeta.c, "Exception occurred while getting property ''{0}''", name).initCause(e);
+ }
+ }
+
+ /**
+ * Converts a raw bean property value to serialized form.
+ * Applies transforms and child property filters.
+ */
+ final Object toSerializedForm(BeanSession session, Object o) {
+ try {
o = transform(session, o);
if (o == null)
return null;
if (properties != null) {
if (rawTypeMeta.isArray()) {
Object[] a = (Object[])o;
- List l = new ArrayList(a.length);
+ List l = new DelegateList(rawTypeMeta);
ClassMeta childType = rawTypeMeta.getElementType();
for (Object c : a)
l.add(applyChildPropertiesFilter(session, childType, c));
@@ -371,13 +387,6 @@ public class BeanPropertyMeta {
return o;
} catch (SerializeException e) {
throw new BeanRuntimeException(e);
- } catch (Throwable e) {
- if (beanContext.ignoreInvocationExceptionsOnGetters) {
- if (rawTypeMeta.isPrimitive())
- return rawTypeMeta.getPrimitiveDefault();
- return null;
- }
- throw new BeanRuntimeException(beanMeta.c, "Exception occurred while getting property ''{0}''", name).initCause(e);
}
}
@@ -685,9 +694,9 @@ public class BeanPropertyMeta {
// Copy any existing array values into the temporary list.
Object oldArray;
if (getter != null)
- oldArray = getter.invoke(bean, (Object[])null);
+ oldArray = getter.invoke(bean, (Object[])null);
else if (field != null)
- oldArray = field.get(bean);
+ oldArray = field.get(bean);
else
throw new BeanRuntimeException(beanMeta.c, "Attempt to append to array property ''{0}'', but no getter or field defined.", name);
ArrayUtils.copyToList(oldArray, l);
@@ -705,6 +714,106 @@ public class BeanPropertyMeta {
}
/**
+ * Adds a value to a {@link Map} or bean property.
+ *
+ * @param m The bean of the field being set.
+ * @param key The key to add to the field.
+ * @param value The value to add to the field.
+ * @throws BeanRuntimeException If field is not a map or array.
+ */
+ public void add(BeanMap<?> m, String key, Object value) throws BeanRuntimeException {
+
+ // Read-only beans get their properties stored in a cache.
+ if (m.bean == null) {
+ if (! m.propertyCache.containsKey(name))
+ m.propertyCache.put(name, new ObjectMap(m.getBeanSession()));
+ ((ObjectMap)m.propertyCache.get(name)).append(key.toString(), value);
+ return;
+ }
+
+ BeanSession session = m.getBeanSession();
+
+ boolean isMap = rawTypeMeta.isMap();
+ boolean isBean = rawTypeMeta.isBean();
+
+ if (! (isBean || isMap))
+ throw new BeanRuntimeException(beanMeta.c, "Attempt to add key/value to property ''{0}'' which is not a map or bean", name);
+
+ Object bean = m.getBean(true);
+
+ ClassMeta<?> elementType = rawTypeMeta.getElementType();
+
+ try {
+ Object v = session.convertToType(value, elementType);
+
+ if (isMap) {
+ Map map = null;
+ if (getter != null) {
+ map = (Map)getter.invoke(bean, (Object[])null);
+ } else if (field != null) {
+ map = (Map)field.get(bean);
+ } else {
+ throw new BeanRuntimeException(beanMeta.c, "Attempt to append to map property ''{0}'', but no getter or field defined.", name);
+ }
+
+ if (map != null) {
+ map.put(key, v);
+ return;
+ }
+
+ if (rawTypeMeta.canCreateNewInstance())
+ map = (Map)rawTypeMeta.newInstance();
+ else
+ map = new ObjectMap(session);
+
+ map.put(key, v);
+
+ if (setter != null)
+ setter.invoke(bean, map);
+ else if (field != null)
+ field.set(bean, map);
+ else
+ throw new BeanRuntimeException(beanMeta.c, "Attempt to initialize map property ''{0}'', but no setter or field defined.", name);
+
+ } else /* isBean() */ {
+
+ Object b = null;
+ if (getter != null) {
+ b = getter.invoke(bean, (Object[])null);
+ } else if (field != null) {
+ b = field.get(bean);
+ } else {
+ throw new BeanRuntimeException(beanMeta.c, "Attempt to append to bean property ''{0}'', but no getter or field defined.", name);
+ }
+
+ if (b != null) {
+ BeanMap bm = session.toBeanMap(b);
+ bm.put(key, v);
+ return;
+ }
+
+ if (rawTypeMeta.canCreateNewInstance(m.getBean(false))) {
+ b = rawTypeMeta.newInstance();
+ BeanMap bm = session.toBeanMap(b);
+ bm.put(key, v);
+ }
+
+ if (setter != null)
+ setter.invoke(bean, b);
+ else if (field != null)
+ field.set(bean, b);
+ else
+ throw new BeanRuntimeException(beanMeta.c, "Attempt to initialize bean property ''{0}'', but no setter or field defined.", name);
+ }
+
+ } catch (BeanRuntimeException e) {
+ throw e;
+ } catch (Exception e) {
+ throw new BeanRuntimeException(e);
+ }
+ }
+
+ /**
* Returns all instances of the specified annotation in the hierarchy of this bean property.
* <p>
* Searches through the class hierarchy (e.g. superclasses, interfaces, packages) for all
@@ -769,10 +878,10 @@ public class BeanPropertyMeta {
if (cm.isBean())
return new BeanMap(session, o, new BeanMetaFiltered(cm.getBeanMeta(), properties));
if (cm.isMap())
- return new FilteredMap((Map)o, properties);
+ return new FilteredMap(cm, (Map)o, properties);
if (cm.isObject()) {
if (o instanceof Map)
- return new FilteredMap((Map)o, properties);
+ return new FilteredMap(cm, (Map)o, properties);
BeanMeta bm = beanContext.getBeanMeta(o.getClass());
if (bm != null)
return new BeanMap(session, o, new BeanMetaFiltered(cm.getBeanMeta(), properties));
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/4fb01038/juneau-core/src/main/java/org/apache/juneau/BeanRegistry.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/BeanRegistry.java b/juneau-core/src/main/java/org/apache/juneau/BeanRegistry.java
new file mode 100644
index 0000000..679a3e5
--- /dev/null
+++ b/juneau-core/src/main/java/org/apache/juneau/BeanRegistry.java
@@ -0,0 +1,144 @@
+// ***************************************************************************************************************************
+// * 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;
+
+import java.lang.reflect.*;
+import java.util.*;
+import java.util.concurrent.*;
+
+import org.apache.juneau.annotation.*;
+import org.apache.juneau.internal.*;
+
+/**
+ * A lookup table for resolving bean types by name.
+ * <p>
+ * In a nutshell, provides a simple mapping of bean class objects to identifying names.
+ * <p>
+ * Class names are defined through the {@link Bean#typeName()} annotation.
+ * <p>
+ * The dictionary is used by the framework in the following ways:
+ * <ul>
+ * <li>If a class type cannot be inferred through reflection during parsing, then a helper <js>"_type"</js> is added to the serialized output
+ * using the name defined for that class in this dictionary. This helps determine the real class at parse time.
+ * <li>The dictionary name is used as element names when serialized to XML.
+ * </ul>
+ */
+public class BeanRegistry {
+
+ private final Map<String,ClassMeta<?>> map;
+ private final BeanContext beanContext;
+ private final String beanTypePropertyName;
+ private final boolean isEmpty;
+
+ BeanRegistry(BeanContext beanContext, BeanRegistry parent, Class<?>...classes) {
+ this.beanContext = beanContext;
+ this.beanTypePropertyName = beanContext.getBeanTypePropertyName();
+ this.map = new ConcurrentHashMap<String,ClassMeta<?>>();
+ for (Class<?> c : beanContext.beanDictionaryClasses)
+ addClass(c);
+ if (parent != null)
+ this.map.putAll(parent.map);
+ for (Class<?> c : classes)
+ addClass(c);
+ isEmpty = map.isEmpty();
+ }
+
+ private void addClass(Class<?> c) {
+ if (c != null) {
+ if (ClassUtils.isParentClass(Collection.class, c)) {
+ try {
+ @SuppressWarnings("rawtypes")
+ Collection cc = (Collection)c.newInstance();
+ for (Object o : cc) {
+ if (o instanceof Class)
+ addClass((Class<?>)o);
+ else
+ throw new BeanRuntimeException("Collection class passed to BeanRegistry does not contain Class objects.", c.getName());
+ }
+ } catch (Exception e) {
+ throw new BeanRuntimeException(e);
+ }
+ } else {
+ Bean b = c.getAnnotation(Bean.class);
+ if (b == null || b.typeName().isEmpty())
+ throw new BeanRuntimeException("Class ''{0}'' was passed to BeanRegistry but it doesn't have a @Bean.typeName() annotation defined.", c.getName());
+ map.put(b.typeName(), beanContext.getClassMeta(c));
+ }
+ }
+ }
+
+ /**
+ * Converts the specified object map into a bean if it contains a <js>"_type"</js> entry in it.
+ *
+ * @param m The object map to convert to a bean if possible.
+ * @return The new bean, or the original <code>ObjectMap</code> if no <js>"_type"</js> entry was found.
+ */
+ public Object cast(ObjectMap m) {
+ if (isEmpty)
+ return m;
+ Object o = m.get(beanTypePropertyName);
+ if (o == null)
+ return m;
+ String typeName = o.toString();
+ ClassMeta<?> cm = getClassMeta(typeName);
+ BeanMap<?> bm = m.getBeanSession().newBeanMap(cm.getInnerClass());
+
+ // Iterate through all the entries in the map and set the individual field values.
+ for (Map.Entry<String,Object> e : m.entrySet()) {
+ String k = e.getKey();
+ Object v = e.getValue();
+ if (! k.equals(beanTypePropertyName)) {
+ // Attempt to recursively cast child maps.
+ if (v instanceof ObjectMap)
+ v = cast((ObjectMap)v);
+ bm.put(k, v);
+ }
+ }
+ return bm.getBean();
+ }
+
+ /**
+ * Gets the class metadata for the specified bean type name.
+ *
+ * @param typeName The bean type name as defined by {@link Bean#typeName()}.
+ * Can include multi-dimensional array type names (e.g. <js>"X^^"</js>).
+ * @return The class metadata for the bean.
+ */
+ public ClassMeta<?> getClassMeta(String typeName) {
+ if (isEmpty)
+ return null;
+ if (typeName == null)
+ return null;
+ ClassMeta<?> cm = map.get(typeName);
+ if (cm != null)
+ return cm;
+ if (typeName.charAt(typeName.length()-1) == '^') {
+ cm = getClassMeta(typeName.substring(0, typeName.length()-1));
+ if (cm != null)
+ cm = beanContext.getClassMeta(Array.newInstance(cm.innerClass, 1).getClass());
+ map.put(typeName, cm);
+ return cm;
+ }
+ return null;
+ }
+
+ /**
+ * Returns <jk>true</jk> if this dictionary has an entry for the specified type name.
+ *
+ * @param typeName The bean type name.
+ * @return <jk>true</jk> if this dictionary has an entry for the specified type name.
+ */
+ public boolean hasName(String typeName) {
+ return getClassMeta(typeName) != null;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/4fb01038/juneau-core/src/main/java/org/apache/juneau/BeanSession.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/BeanSession.java b/juneau-core/src/main/java/org/apache/juneau/BeanSession.java
index 3f01b95..e22f028 100644
--- a/juneau-core/src/main/java/org/apache/juneau/BeanSession.java
+++ b/juneau-core/src/main/java/org/apache/juneau/BeanSession.java
@@ -39,6 +39,7 @@ public class BeanSession extends Session {
private final Locale locale;
private final TimeZone timeZone;
private final boolean debug;
+ private Stack<StringBuilder> sbStack = new Stack<StringBuilder>();
/**
* Create a new session using properties specified in the context.
@@ -515,7 +516,7 @@ public class BeanSession extends Session {
}
if (type.isString()) {
- if (vt.isArray() || vt.isMap() || vt.isCollection() || vt.isBean()) {
+ if (vt.isMapOrBean() || vt.isCollectionOrArray()) {
if (JsonSerializer.DEFAULT_LAX != null)
return (T)JsonSerializer.DEFAULT_LAX.serialize(value);
} else if (vt.isClass()) {
@@ -985,12 +986,37 @@ public class BeanSession extends Session {
}
/**
- * Returns the bean dictionary defined in this bean context defined by {@link BeanContext#BEAN_beanDictionary}.
+ * Returns the bean registry defined in this bean context defined by {@link BeanContext#BEAN_beanDictionary}.
*
- * @return The bean dictionary defined in this bean context. Never <jk>null</jk>.
+ * @return The bean registry defined in this bean context. Never <jk>null</jk>.
*/
- public final BeanDictionary getBeanDictionary() {
- return ctx.beanDictionary;
+ public final BeanRegistry getBeanRegistry() {
+ return ctx.beanRegistry;
+ }
+
+ /**
+ * Creates a reusable {@link StringBuilder} object from an internal pool.
+ * <p>
+ * String builders are returned to the pool by calling {@link #returnStringBuilder(StringBuilder)}.
+ *
+ * @return A new or previously returned string builder.
+ */
+ public final StringBuilder getStringBuilder() {
+ if (sbStack.isEmpty())
+ return new StringBuilder();
+ return sbStack.pop();
+ }
+
+ /**
+ * Returns a {@link StringBuilder} object back into the internal reuse pool.
+ *
+ * @param sb The string builder to return to the pool. No-op if <jk>null</jk>.
+ */
+ public final void returnStringBuilder(StringBuilder sb) {
+ if (sb == null)
+ return;
+ sb.setLength(0);
+ sbStack.push(sb);
}
/**
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/4fb01038/juneau-core/src/main/java/org/apache/juneau/ClassMeta.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/ClassMeta.java b/juneau-core/src/main/java/org/apache/juneau/ClassMeta.java
index 3461af4..38ee551 100644
--- a/juneau-core/src/main/java/org/apache/juneau/ClassMeta.java
+++ b/juneau-core/src/main/java/org/apache/juneau/ClassMeta.java
@@ -63,7 +63,8 @@ public final class ClassMeta<T> implements Type {
keyType = null, // If MAP, the key class type.
valueType = null; // If MAP, the value class type.
InvocationHandler invocationHandler; // The invocation handler for this class (if it has one).
- volatile BeanMeta<T> beanMeta; // The bean meta for this bean class (if it's a bean).
+ BeanMeta<T> beanMeta; // The bean meta for this bean class (if it's a bean).
+ String dictionaryName, resolvedDictionaryName; // The dictionary name of this class if it has one.
Method fromStringMethod; // The static valueOf(String) or fromString(String) method (if it has one).
Constructor<? extends T> noArgConstructor; // The no-arg constructor for this class (if it has one).
Constructor<T> stringConstructor; // The X(String) constructor (if it has one).
@@ -226,8 +227,8 @@ public final class ClassMeta<T> implements Type {
try {
if (c == TimeZone.class)
this.fromStringMethod = c.getMethod("getTimeZone", String.class);
- else if (c == Locale.class)
- this.fromStringMethod = LocaleAsString.class.getMethod("fromString", String.class);
+ else if (c == Locale.class)
+ this.fromStringMethod = LocaleAsString.class.getMethod("fromString", String.class);
} catch (NoSuchMethodException e1) {}
// Find toObjectMap() method if present.
@@ -378,6 +379,15 @@ public final class ClassMeta<T> implements Type {
if (remoteableMethods != null)
remoteableMethods = Collections.unmodifiableMap(remoteableMethods);
+ if (isBean())
+ dictionaryName = resolvedDictionaryName = getBeanMeta().getDictionaryName();
+
+ if (isArray()) {
+ resolvedDictionaryName = getElementType().getResolvedDictionaryName();
+ if (resolvedDictionaryName != null)
+ resolvedDictionaryName += "^";
+ }
+
return this;
}
@@ -389,9 +399,19 @@ public final class ClassMeta<T> implements Type {
* @return The type name associated with this bean class, or <jk>null</jk> if there is no type name defined or this isn't a bean.
*/
public String getDictionaryName() {
- if (beanMeta != null)
- return beanMeta.getDictionaryName();
- return null;
+ return dictionaryName;
+ }
+
+ /**
+ * Returns the resolved bean dictionary name associated with this class.
+ * <p>
+ * Unlike {@link #getDictionaryName()}, this method automatically resolves multidimensional arrays
+ * (e.g. <js>"X^^"</js> and returns array class metas accordingly if the base class has a type name.
+ *
+ * @return The type name associated with this bean class, or <jk>null</jk> if there is no type name defined or this isn't a bean.
+ */
+ public String getResolvedDictionaryName() {
+ return resolvedDictionaryName;
}
/**
@@ -604,6 +624,15 @@ public final class ClassMeta<T> implements Type {
}
/**
+ * Returns <jk>true</jk> if this class is a subclass of {@link Map} or it's a bean.
+ *
+ * @return <jk>true</jk> if this class is a subclass of {@link Map} or it's a bean.
+ */
+ public boolean isMapOrBean() {
+ return classCategory == MAP || classCategory == BEANMAP || classCategory == BEAN;
+ }
+
+ /**
* Returns <jk>true</jk> if this class is a subclass of {@link BeanMap}.
*
* @return <jk>true</jk> if this class is a subclass of {@link BeanMap}.
@@ -622,6 +651,15 @@ public final class ClassMeta<T> implements Type {
}
/**
+ * Returns <jk>true</jk> if this class is a subclass of {@link Collection} or is an array.
+ *
+ * @return <jk>true</jk> if this class is a subclass of {@link Collection} or is an array.
+ */
+ public boolean isCollectionOrArray() {
+ return classCategory == COLLECTION || classCategory == ARRAY;
+ }
+
+ /**
* Returns <jk>true</jk> if this class is {@link Class}.
*
* @return <jk>true</jk> if this class is {@link Class}.
@@ -1228,6 +1266,19 @@ public final class ClassMeta<T> implements Type {
return t2.getInnerClass() == this.getInnerClass();
}
+ /**
+ * Similar to {@link #equals(Object)} except primitive and Object types that are similar
+ * are considered the same. (e.g. <jk>boolean</jk> == <code>Boolean</code>).
+ *
+ * @param cm The class meta to compare to.
+ * @return <jk>true</jk> if the specified class-meta is equivalent to this one.
+ */
+ public boolean same(ClassMeta<?> cm) {
+ if (equals(cm))
+ return true;
+ return (isPrimitive() && classCategory == cm.classCategory);
+ }
+
@Override /* Object */
public String toString() {
return toString(false);
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/4fb01038/juneau-core/src/main/java/org/apache/juneau/ObjectMap.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/ObjectMap.java b/juneau-core/src/main/java/org/apache/juneau/ObjectMap.java
index c8af10e..b090829 100644
--- a/juneau-core/src/main/java/org/apache/juneau/ObjectMap.java
+++ b/juneau-core/src/main/java/org/apache/juneau/ObjectMap.java
@@ -1157,18 +1157,18 @@ public class ObjectMap extends LinkedHashMap<String,Object> {
* same object if entry does not exist.
*/
public Object cast() {
- return cast((BeanDictionary)null);
+ return cast((BeanRegistry)null);
}
/**
* Same as {@link #cast()}, but first do a lookup for the name in the specified dictionary.
*
- * @param typeDictionary
+ * @param beanRegistry
* The class lexicon to resolve the name. Can be <jk>null</jk>.
* @return The new Java object of type specified by the <js>"_type"</js> entry value, or this
* same object if entry does not exist.
*/
- public Object cast(BeanDictionary typeDictionary) {
+ public Object cast(BeanRegistry beanRegistry) {
String c = (String)get(session.getBeanTypePropertyName());
if (c == null) {
return this;
@@ -1266,7 +1266,7 @@ public class ObjectMap extends LinkedHashMap<String,Object> {
// Attempt to recursively cast child maps.
if (v instanceof ObjectMap)
- v = ((ObjectMap)v).cast(session.getBeanDictionary());
+ v = ((ObjectMap)v).cast(session.getBeanRegistry());
k = (kType.isString() ? k : session.convertToType(k, kType));
v = (vType.isObject() ? v : session.convertToType(v, vType));
@@ -1287,7 +1287,7 @@ public class ObjectMap extends LinkedHashMap<String,Object> {
// Attempt to recursively cast child maps.
if (v instanceof ObjectMap)
- v = ((ObjectMap)v).cast(session.getBeanDictionary());
+ v = ((ObjectMap)v).cast(session.getBeanRegistry());
bm.put(k, v);
}
@@ -1295,7 +1295,7 @@ public class ObjectMap extends LinkedHashMap<String,Object> {
return bm.getBean();
- } else if (cm.isArray() || cm.isCollection()) {
+ } else if (cm.isCollectionOrArray()) {
List items = (List)get("items");
return session.convertToType(items, cm);
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/4fb01038/juneau-core/src/main/java/org/apache/juneau/annotation/Bean.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/annotation/Bean.java b/juneau-core/src/main/java/org/apache/juneau/annotation/Bean.java
index b769ddf..b6c6d8f 100644
--- a/juneau-core/src/main/java/org/apache/juneau/annotation/Bean.java
+++ b/juneau-core/src/main/java/org/apache/juneau/annotation/Bean.java
@@ -270,4 +270,19 @@ public @interface Bean {
* </p>
*/
Class<?> stopClass() default Object.class;
+
+
+ /**
+ * The list of classes that make up the bean dictionary for all properties of this bean.
+ * <p>
+ * This is a shorthand for setting the {@link BeanProperty#beanDictionary()} on all properties of the bean.
+ * <p>
+ * This list can consist of the following class types:
+ * <ul>
+ * <li>Any bean class that specifies a value for {@link Bean#typeName() @Bean.name()};
+ * <li>Any subclass of {@link BeanDictionary} that defines an entire set of mappings.
+ * Note that the subclass MUST implement a no-arg constructor so that it can be instantiated.
+ * </ul>
+ */
+ Class<?>[] beanDictionary() default {};
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/4fb01038/juneau-core/src/main/java/org/apache/juneau/annotation/BeanProperty.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/annotation/BeanProperty.java b/juneau-core/src/main/java/org/apache/juneau/annotation/BeanProperty.java
index 55922d6..bd68408 100644
--- a/juneau-core/src/main/java/org/apache/juneau/annotation/BeanProperty.java
+++ b/juneau-core/src/main/java/org/apache/juneau/annotation/BeanProperty.java
@@ -158,10 +158,9 @@ public @interface BeanProperty {
* This list can consist of the following class types:
* <ul>
* <li>Any bean class that specifies a value for {@link Bean#typeName() @Bean.name()};
- * <li>Any subclass of {@link BeanDictionaryBuilder} that defines an entire set of mappings.
+ * <li>Any subclass of {@link BeanDictionary} that defines an entire set of mappings.
* Note that the subclass MUST implement a no-arg constructor so that it can be instantiated.
* </ul>
*/
Class<?>[] beanDictionary() default {};
}
-
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/4fb01038/juneau-core/src/main/java/org/apache/juneau/dto/atom/AtomBuilder.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/dto/atom/AtomBuilder.java b/juneau-core/src/main/java/org/apache/juneau/dto/atom/AtomBuilder.java
new file mode 100644
index 0000000..f51eb45
--- /dev/null
+++ b/juneau-core/src/main/java/org/apache/juneau/dto/atom/AtomBuilder.java
@@ -0,0 +1,224 @@
+// ***************************************************************************************************************************
+// * 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.atom;
+
+import java.net.*;
+import java.util.*;
+
+/**
+ * Various useful static methods for creating ATOM elements.
+ * <p>
+ * Typically, you'll want to do a static import on this class and then call the methods like so...
+ * <p class='bcode'>
+ * <jk>import static</jk> org.apache.juneau.dto.atom.AtomBuilder.*;
+ *
+ * Feed feed =
+ * feed(<js>"tag:juneau.sample.com,2013:1"</js>, <js>"Juneau ATOM specification"</js>, <js>"2013-05-08T12:29:29Z"</js>)
+ * .subtitle(text(<js>"html"</js>).children(<js>"A <em>lot</em> of effort went into making this effortless"</js>))
+ * .links(
+ * link(<js>"alternate"</js>, <js>"text/html"</js>, <js>"http://www.sample.com/"</js>).hreflang(<js>"en"</js>),
+ * link(<js>"self"</js>, <js>"application/atom+xml"</js>, <js>"http://www.sample.com/feed.atom"</js>)
+ * );
+ * </p>
+ * <p>
+ * Refer to {@link org.apache.juneau.dto.atom} for further information about ATOM support.
+ */
+public class AtomBuilder {
+
+ /**
+ * Creates a {@link Category} element with the specified {@link Category#term(String)} attribute.
+ *
+ * @param term The {@link Category#term(String)} attribute.
+ * @return The new element.
+ */
+ public static final Category category(String term) {
+ return new Category(term);
+ }
+
+ /**
+ * Creates a {@link Content} element with the specified {@link Content#type(String)} attribute.
+ *
+ * @return The new element.
+ */
+ public static final Content content() {
+ return new Content();
+ }
+
+ /**
+ * Creates a {@link Content} element.
+ *
+ * @param type The {@link Content#type(String)} attribute.
+ * @return The new element.
+ */
+ public static final Content content(String type) {
+ return new Content(type);
+ }
+
+ /**
+ * Creates an {@link Entry} element with the specified {@link Entry#id(Id)}, {@link Entry#title(Text)}, and {@link Entry#updated(Calendar)} attributes.
+ *
+ * @param id The {@link Entry#id(Id)} attribute.
+ * @param title The {@link Entry#title(Text)} attribute.
+ * @param updated The {@link Entry#updated(Calendar)} attribute.
+ * @return The new element.
+ */
+ public static final Entry entry(Id id, Text title, Calendar updated) {
+ return new Entry(id, title, updated);
+ }
+
+ /**
+ * Creates an {@link Entry} element with the specified {@link Entry#id(Id)}, {@link Entry#title(Text)}, and {@link Entry#updated(Calendar)} attributes.
+ *
+ * @param id The {@link Entry#id(Id)} attribute.
+ * @param title The {@link Entry#title(Text)} attribute.
+ * @param updated The {@link Entry#updated(Calendar)} attribute.
+ * @return The new element.
+ */
+ public static final Entry entry(String id, String title, String updated) {
+ return new Entry(id, title, updated);
+ }
+
+ /**
+ * Creates a {@link Feed} element with the specified {@link Feed#id(Id)}, {@link Entry#title(Text)}, and {@link Feed#updated(Calendar)} attributes.
+ *
+ * @param id The {@link Feed#id(Id)} attribute.
+ * @param title The {@link Feed#title(Text)} attribute.
+ * @param updated The {@link Feed#updated(Calendar)} attribute.
+ * @return The new element.
+ */
+ public static final Feed feed(Id id, Text title, Calendar updated) {
+ return new Feed(id, title, updated);
+ }
+
+ /**
+ * Creates a {@link Feed} element with the specified {@link Feed#id(Id)}, {@link Entry#title(Text)}, and {@link Feed#updated(Calendar)} attributes.
+ *
+ * @param id The {@link Feed#id(Id)} attribute.
+ * @param title The {@link Feed#title(Text)} attribute.
+ * @param updated The {@link Feed#updated(Calendar)} attribute.
+ * @return The new element.
+ */
+ public static final Feed feed(String id, String title, String updated) {
+ return new Feed(id, title, updated);
+ }
+
+ /**
+ * Creates a {@link Generator} element with the specified {@link Generator#text(String)} child node.
+ *
+ * @param text The {@link Generator#text(String)} child node.
+ * @return The new element.
+ */
+ public static final Generator generator(String text) {
+ return new Generator(text);
+ }
+
+ /**
+ * Creates an {@link Icon} element with the specified {@link Icon#uri(URI)} attribute.
+ *
+ * @param uri The {@link Icon#uri(URI)} attribute.
+ * @return The new element.
+ */
+ public static final Icon icon(String uri) {
+ return icon(uri);
+ }
+
+ /**
+ * Creates an {@link Icon} element with the specified {@link Icon#uri(URI)} attribute.
+ *
+ * @param uri The {@link Icon#uri(URI)} attribute.
+ * @return The new element.
+ */
+ public static final Icon icon(URI uri) {
+ return new Icon(uri);
+ }
+
+ /**
+ * Creates an {@link Id} element with the specified {@link Id#text(String)} child node.
+ *
+ * @param text The {@link Id#text(String)} child node.
+ * @return The new element.
+ */
+ public static final Id id(String text) {
+ return new Id(text);
+ }
+
+ /**
+ * Creates a {@link Link} element with the specified {@link Link#rel(String)}, {@link Link#type(String)}, and {@link Link#href(String)} attributes.
+ *
+ * @param rel The {@link Link#rel(String)} attribute.
+ * @param type The {@link Link#type(String)} attribute.
+ * @param href The {@link Link#href(String)} attribute.
+ * @return The new element.
+ */
+ public static final Link link(String rel, String type, String href) {
+ return new Link(rel, type, href);
+ }
+
+ /**
+ * Creates a {@link Logo} element with the specified {@link Logo#uri(URI)} attribute.
+ *
+ * @param uri The {@link Logo#uri(URI)} attribute.
+ * @return The new element.
+ */
+ public static final Logo logo(String uri) {
+ return logo(uri);
+ }
+
+ /**
+ * Creates a {@link Logo} element with the specified {@link Logo#uri(URI)} attribute.
+ *
+ * @param uri The {@link Logo#uri(URI)} attribute.
+ * @return The new element.
+ */
+ public static final Logo logo(URI uri) {
+ return logo(uri);
+ }
+
+ /**
+ * Creates a {@link Person} element with the specified {@link Person#name(String)} attribute.
+ *
+ * @param name The {@link Person#name(String)} attribute.
+ * @return The new element.
+ */
+ public static final Person person(String name) {
+ return new Person(name);
+ }
+
+ /**
+ * Creates a {@link Source} element.
+ *
+ * @return The new element.
+ */
+ public static final Source source() {
+ return new Source();
+ }
+
+ /**
+ * Creates a {@link Text} element.
+ *
+ * @return The new element.
+ */
+ public static final Text text() {
+ return new Text();
+ }
+
+ /**
+ * Creates a {@link Text} element with the specified {@link Text#type(String)} attribute.
+ *
+ * @param type The {@link Text#type(String)} attribute.
+ * @return The new element.
+ */
+ public static final Text text(String type) {
+ return new Text(type);
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/4fb01038/juneau-core/src/main/java/org/apache/juneau/dto/atom/Category.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/dto/atom/Category.java b/juneau-core/src/main/java/org/apache/juneau/dto/atom/Category.java
index 0d8060b..37b45d6 100644
--- a/juneau-core/src/main/java/org/apache/juneau/dto/atom/Category.java
+++ b/juneau-core/src/main/java/org/apache/juneau/dto/atom/Category.java
@@ -34,10 +34,10 @@ import org.apache.juneau.xml.annotation.*;
* }
* </p>
* <p>
- * Refer to {@link org.apache.juneau.dto.atom} for further information about ATOM support.
- * </p>
+ * Refer to {@link org.apache.juneau.dto.atom} for further information about ATOM support.
*/
@Bean(typeName="category")
+@SuppressWarnings("hiding")
public class Category extends Common {
private String term;
@@ -49,7 +49,7 @@ public class Category extends Common {
* @param term The category term.
*/
public Category(String term) {
- this.term = term;
+ term(term);
}
/** Bean constructor. */
@@ -74,7 +74,8 @@ public class Category extends Common {
* @param term The category term.
* @return This object (for method chaining).
*/
- public Category setTerm(String term) {
+ @BeanProperty(name="term")
+ public Category term(String term) {
this.term = term;
return this;
}
@@ -95,7 +96,8 @@ public class Category extends Common {
* @param scheme The category scheme.
* @return This object (for method chaining).
*/
- public Category setScheme(URI scheme) {
+ @BeanProperty(name="scheme")
+ public Category scheme(URI scheme) {
this.scheme = scheme;
return this;
}
@@ -116,7 +118,8 @@ public class Category extends Common {
* @param label The category label.
* @return This object (for method chaining).
*/
- public Category setLabel(String label) {
+ @BeanProperty(name="label")
+ public Category label(String label) {
this.label = label;
return this;
}
@@ -127,14 +130,14 @@ public class Category extends Common {
//--------------------------------------------------------------------------------
@Override /* Common */
- public Category setBase(URI base) {
- super.setBase(base);
+ public Category base(URI base) {
+ super.base(base);
return this;
}
@Override /* Common */
- public Category setLang(String lang) {
- super.setLang(lang);
+ public Category lang(String lang) {
+ super.lang(lang);
return this;
}
}
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/4fb01038/juneau-core/src/main/java/org/apache/juneau/dto/atom/Common.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/dto/atom/Common.java b/juneau-core/src/main/java/org/apache/juneau/dto/atom/Common.java
index ef27722..c3a57ec 100644
--- a/juneau-core/src/main/java/org/apache/juneau/dto/atom/Common.java
+++ b/juneau-core/src/main/java/org/apache/juneau/dto/atom/Common.java
@@ -14,9 +14,11 @@ package org.apache.juneau.dto.atom;
import static org.apache.juneau.xml.annotation.XmlFormat.*;
-import java.net.*;
+import java.net.URI;
+import org.apache.juneau.annotation.*;
import org.apache.juneau.xml.annotation.*;
+import static org.apache.juneau.dto.atom.Utils.*;
/**
* Represents an <code>atomCommonAttributes</code> construct in the RFC4287 specification.
@@ -29,9 +31,9 @@ import org.apache.juneau.xml.annotation.*;
* undefinedAttribute*
* </p>
* <p>
- * Refer to {@link org.apache.juneau.dto.atom} for further information about ATOM support.
- * </p>
+ * Refer to {@link org.apache.juneau.dto.atom} for further information about ATOM support.
*/
+@SuppressWarnings("hiding")
public abstract class Common {
private URI base;
@@ -58,12 +60,24 @@ public abstract class Common {
* @param base The URI base of this object.
* @return This object (for method chaining).
*/
- public Common setBase(URI base) {
+ @BeanProperty(name="base")
+ public Common base(URI base) {
this.base = base;
return this;
}
/**
+ * Sets the URI base of this object.
+ *
+ * @param base The URI base of this object.
+ * @return This object (for method chaining).
+ */
+ public Common base(String base) {
+ this.base = toURI(base);
+ return this;
+ }
+
+ /**
* Returns the language of this object.
*
* @return The language of this object.
@@ -79,7 +93,8 @@ public abstract class Common {
* @param lang The language of this object.
* @return This object (for method chaining).
*/
- public Common setLang(String lang) {
+ @BeanProperty(name="lang")
+ public Common lang(String lang) {
this.lang = lang;
return this;
}