http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/75b0d8ee/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/html5/Tr.java ---------------------------------------------------------------------- diff --git a/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/html5/Tr.java b/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/html5/Tr.java new file mode 100644 index 0000000..a848601 --- /dev/null +++ b/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/html5/Tr.java @@ -0,0 +1,69 @@ +// *************************************************************************************************************************** +// * 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.html5; + +import org.apache.juneau.annotation.*; + +/** + * DTO for an HTML <a class="doclink" href="https://www.w3.org/TR/html5/tabular-data.html#the-tr-element"><tr></a> + * element. + * + * <h6 class='topic'>Additional Information</h6> + * <ul class='doctree'> + * <li class='link'> + * <a class='doclink' href='../../../../../overview-summary.html#DTOs'>Juneau Data Transfer Objects + * (org.apache.juneau.dto)</a> + * <ul> + * <li class='sublink'> + * <a class='doclink' href='../../../../../overview-summary.html#DTOs.HTML5'>HTML5</a> + * </ul> + * </li> + * </ul> + */ +@Bean(typeName="tr") +public class Tr extends HtmlElementContainer { + + //-------------------------------------------------------------------------------- + // Overridden methods + //-------------------------------------------------------------------------------- + + @Override /* HtmlElement */ + public final Tr _class(String _class) { + super._class(_class); + return this; + } + + @Override /* HtmlElement */ + public final Tr id(String id) { + super.id(id); + return this; + } + + @Override /* HtmlElement */ + public final Tr style(String style) { + super.style(style); + return this; + } + + @Override /* HtmlElementContainer */ + public final Tr children(Object...children) { + super.children(children); + return this; + } + + @Override /* HtmlElementContainer */ + public final Tr child(Object child) { + super.child(child); + return this; + } +}
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/75b0d8ee/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/html5/Track.java ---------------------------------------------------------------------- diff --git a/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/html5/Track.java b/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/html5/Track.java new file mode 100644 index 0000000..668efb6 --- /dev/null +++ b/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/html5/Track.java @@ -0,0 +1,137 @@ +// *************************************************************************************************************************** +// * 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.html5; + +import java.net.*; +import java.net.URI; + +import org.apache.juneau.*; +import org.apache.juneau.annotation.*; + +/** + * DTO for an HTML <a class="doclink" href="https://www.w3.org/TR/html5/embedded-content-0.html#the-track-element"><track></a> + * element. + * + * <h6 class='topic'>Additional Information</h6> + * <ul class='doctree'> + * <li class='link'> + * <a class='doclink' href='../../../../../overview-summary.html#DTOs'>Juneau Data Transfer Objects + * (org.apache.juneau.dto)</a> + * <ul> + * <li class='sublink'> + * <a class='doclink' href='../../../../../overview-summary.html#DTOs.HTML5'>HTML5</a> + * </ul> + * </li> + * </ul> + */ +@Bean(typeName="track") +public class Track extends HtmlElementVoid { + + /** + * <a class="doclink" href="https://www.w3.org/TR/html5/embedded-content-0.html#attr-track-default">default</a> + * attribute. + * + * <p> + * Enable the track if no other text track is more suitable. + * + * @param _default The new value for this attribute. + * @return This object (for method chaining). + */ + public final Track _default(String _default) { + attr("default", _default); + return this; + } + + /** + * <a class="doclink" href="https://www.w3.org/TR/html5/embedded-content-0.html#attr-track-kind">kind</a> attribute. + * + * <p> + * The type of text track. + * + * @param kind The new value for this attribute. + * @return This object (for method chaining). + */ + public final Track kind(String kind) { + attr("kind", kind); + return this; + } + + /** + * <a class="doclink" href="https://www.w3.org/TR/html5/embedded-content-0.html#attr-track-label">label</a> attribute. + * + * <p> + * User-visible label. + * + * @param label The new value for this attribute. + * @return This object (for method chaining). + */ + public final Track label(String label) { + attr("label", label); + return this; + } + + /** + * <a class="doclink" href="https://www.w3.org/TR/html5/embedded-content-0.html#attr-track-src">src</a> attribute. + * + * <p> + * Address of the resource. + * + * <p> + * The value can be of any of the following types: {@link URI}, {@link URL}, {@link String}. + * Strings must be valid URIs. + * + * <p> + * URIs defined by {@link UriResolver} can be used for values. + * + * @param src + * The new value for this attribute. + * Typically a {@link URL} or {@link String}. + * @return This object (for method chaining). + */ + public final Track src(Object src) { + attrUri("src", src); + return this; + } + + /** + * <a class="doclink" href="https://www.w3.org/TR/html5/embedded-content-0.html#attr-track-srclang">srclang</a> + * attribute. + * + * <p> + * Language of the text track. + * + * @param srclang The new value for this attribute. + * @return This object (for method chaining). + */ + public final Track srclang(String srclang) { + attr("srclang", srclang); + return this; + } + + + //-------------------------------------------------------------------------------- + // Overridden methods + //-------------------------------------------------------------------------------- + + @Override /* HtmlElement */ + public final Track _class(String _class) { + super._class(_class); + return this; + } + + @Override /* HtmlElement */ + public final Track id(String id) { + super.id(id); + return this; + } +} http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/75b0d8ee/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/html5/U.java ---------------------------------------------------------------------- diff --git a/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/html5/U.java b/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/html5/U.java new file mode 100644 index 0000000..fbc66e2 --- /dev/null +++ b/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/html5/U.java @@ -0,0 +1,69 @@ +// *************************************************************************************************************************** +// * 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.html5; + +import org.apache.juneau.annotation.*; + +/** + * DTO for an HTML <a class="doclink" href="https://www.w3.org/TR/html5/text-level-semantics.html#the-u-element"><u></a> + * element. + * + * <h6 class='topic'>Additional Information</h6> + * <ul class='doctree'> + * <li class='link'> + * <a class='doclink' href='../../../../../overview-summary.html#DTOs'>Juneau Data Transfer Objects + * (org.apache.juneau.dto)</a> + * <ul> + * <li class='sublink'> + * <a class='doclink' href='../../../../../overview-summary.html#DTOs.HTML5'>HTML5</a> + * </ul> + * </li> + * </ul> + */ +@Bean(typeName="u") +public class U extends HtmlElementMixed { + + //-------------------------------------------------------------------------------- + // Overridden methods + //-------------------------------------------------------------------------------- + + @Override /* HtmlElement */ + public final U _class(String _class) { + super._class(_class); + return this; + } + + @Override /* HtmlElement */ + public final U id(String id) { + super.id(id); + return this; + } + + @Override /* HtmlElement */ + public final U style(String style) { + super.style(style); + return this; + } + + @Override /* HtmlElementMixed */ + public U children(Object...children) { + super.children(children); + return this; + } + + @Override /* HtmlElementMixed */ + public U child(Object child) { + super.child(child); + return this; + } +} http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/75b0d8ee/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/html5/Ul.java ---------------------------------------------------------------------- diff --git a/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/html5/Ul.java b/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/html5/Ul.java new file mode 100644 index 0000000..aca14e3 --- /dev/null +++ b/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/html5/Ul.java @@ -0,0 +1,69 @@ +// *************************************************************************************************************************** +// * 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.html5; + +import org.apache.juneau.annotation.*; + +/** + * DTO for an HTML <a class="doclink" href="https://www.w3.org/TR/html5/grouping-content.html#the-ul-element"><ul></a> + * element. + * + * <h6 class='topic'>Additional Information</h6> + * <ul class='doctree'> + * <li class='link'> + * <a class='doclink' href='../../../../../overview-summary.html#DTOs'>Juneau Data Transfer Objects + * (org.apache.juneau.dto)</a> + * <ul> + * <li class='sublink'> + * <a class='doclink' href='../../../../../overview-summary.html#DTOs.HTML5'>HTML5</a> + * </ul> + * </li> + * </ul> + */ +@Bean(typeName="ul") +public class Ul extends HtmlElementContainer { + + //-------------------------------------------------------------------------------- + // Overridden methods + //-------------------------------------------------------------------------------- + + @Override /* HtmlElement */ + public final Ul _class(String _class) { + super._class(_class); + return this; + } + + @Override /* HtmlElement */ + public final Ul id(String id) { + super.id(id); + return this; + } + + @Override /* HtmlElement */ + public final Ul style(String style) { + super.style(style); + return this; + } + + @Override /* HtmlElementContainer */ + public final Ul children(Object...children) { + super.children(children); + return this; + } + + @Override /* HtmlElementContainer */ + public final Ul child(Object child) { + super.child(child); + return this; + } +} http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/75b0d8ee/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/html5/Var.java ---------------------------------------------------------------------- diff --git a/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/html5/Var.java b/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/html5/Var.java new file mode 100644 index 0000000..eee01de --- /dev/null +++ b/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/html5/Var.java @@ -0,0 +1,69 @@ +// *************************************************************************************************************************** +// * 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.html5; + +import org.apache.juneau.annotation.*; + +/** + * DTO for an HTML <a class="doclink" href="https://www.w3.org/TR/html5/text-level-semantics.html#the-var-element"><var></a> + * element. + * + * <h6 class='topic'>Additional Information</h6> + * <ul class='doctree'> + * <li class='link'> + * <a class='doclink' href='../../../../../overview-summary.html#DTOs'>Juneau Data Transfer Objects + * (org.apache.juneau.dto)</a> + * <ul> + * <li class='sublink'> + * <a class='doclink' href='../../../../../overview-summary.html#DTOs.HTML5'>HTML5</a> + * </ul> + * </li> + * </ul> + */ +@Bean(typeName="var") +public class Var extends HtmlElementMixed { + + //-------------------------------------------------------------------------------- + // Overridden methods + //-------------------------------------------------------------------------------- + + @Override /* HtmlElement */ + public final Var _class(String _class) { + super._class(_class); + return this; + } + + @Override /* HtmlElement */ + public final Var id(String id) { + super.id(id); + return this; + } + + @Override /* HtmlElement */ + public final Var style(String style) { + super.style(style); + return this; + } + + @Override /* HtmlElementMixed */ + public Var children(Object...children) { + super.children(children); + return this; + } + + @Override /* HtmlElementMixed */ + public Var child(Object child) { + super.child(child); + return this; + } +} http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/75b0d8ee/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/html5/Video.java ---------------------------------------------------------------------- diff --git a/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/html5/Video.java b/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/html5/Video.java new file mode 100644 index 0000000..8c36fac --- /dev/null +++ b/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/html5/Video.java @@ -0,0 +1,257 @@ +// *************************************************************************************************************************** +// * 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.html5; + +import java.net.*; +import java.net.URI; + +import org.apache.juneau.*; +import org.apache.juneau.annotation.*; + +/** + * DTO for an HTML <a class="doclink" href="https://www.w3.org/TR/html5/embedded-content-0.html#the-video-element"><video></a> + * element. + * + * <h6 class='topic'>Additional Information</h6> + * <ul class='doctree'> + * <li class='link'> + * <a class='doclink' href='../../../../../overview-summary.html#DTOs'>Juneau Data Transfer Objects + * (org.apache.juneau.dto)</a> + * <ul> + * <li class='sublink'> + * <a class='doclink' href='../../../../../overview-summary.html#DTOs.HTML5'>HTML5</a> + * </ul> + * </li> + * </ul> + */ +@Bean(typeName="video") +public class Video extends HtmlElementContainer { + + /** + * <a class="doclink" href="https://www.w3.org/TR/html5/embedded-content-0.html#attr-media-autoplay">autoplay</a> + * attribute. + * + * <p> + * Hint that the media resource can be started automatically when the page is loaded. + * + * @param autoplay + * The new value for this attribute. + * Typically a {@link Boolean} or {@link String}. + * @return This object (for method chaining). + */ + public final Video autoplay(Object autoplay) { + attr("autoplay", autoplay); + return this; + } + + /** + * <a class="doclink" href="https://www.w3.org/TR/html5/embedded-content-0.html#attr-media-controls">controls</a> + * attribute. + * + * <p> + * Show user agent controls. + * + * @param controls + * The new value for this attribute. + * Typically a {@link Boolean} or {@link String}. + * @return This object (for method chaining). + */ + public final Video controls(Object controls) { + attr("controls", controls); + return this; + } + + /** + * <a class="doclink" href="https://www.w3.org/TR/html5/embedded-content-0.html#attr-media-crossorigin">crossorigin</a> + * attribute. + * + * <p> + * How the element handles cross-origin requests. + * + * @param crossorigin The new value for this attribute. + * @return This object (for method chaining). + */ + public final Video crossorigin(String crossorigin) { + attr("crossorigin", crossorigin); + return this; + } + + /** + * <a class="doclink" href="https://www.w3.org/TR/html5/embedded-content-0.html#attr-dim-height">height</a> + * attribute. + * + * <p> + * Vertical dimension. + * + * @param height + * The new value for this attribute. + * Typically a {@link Number} or {@link String}. + * @return This object (for method chaining). + */ + public final Video height(Object height) { + attr("height", height); + return this; + } + + /** + * <a class="doclink" href="https://www.w3.org/TR/html5/embedded-content-0.html#attr-media-loop">loop</a> attribute. + * + * <p> + * Whether to loop the media resource. + * + * @param loop + * The new value for this attribute. + * Typically a {@link Boolean} or {@link String}. + * @return This object (for method chaining). + */ + public final Video loop(Object loop) { + attr("loop", loop); + return this; + } + + /** + * <a class="doclink" href="https://www.w3.org/TR/html5/embedded-content-0.html#attr-media-mediagroup">mediagroup</a> + * attribute. + * + * <p> + * Groups media elements together with an implicit MediaController. + * + * @param mediagroup The new value for this attribute. + * @return This object (for method chaining). + */ + public final Video mediagroup(String mediagroup) { + attr("mediagroup", mediagroup); + return this; + } + + /** + * <a class="doclink" href="https://www.w3.org/TR/html5/embedded-content-0.html#attr-media-muted">muted</a> + * attribute. + * + * <p> + * Whether to mute the media resource by default. + * + * @param muted + * The new value for this attribute. + * Typically a {@link Boolean} or {@link String}. + * @return This object (for method chaining). + */ + public final Video muted(Object muted) { + attr("muted", muted); + return this; + } + + /** + * <a class="doclink" href="https://www.w3.org/TR/html5/embedded-content-0.html#attr-video-poster">poster</a> + * attribute. + * + * <p> + * Poster frame to show prior to video playback. + * + * @param poster The new value for this attribute. + * @return This object (for method chaining). + */ + public final Video poster(String poster) { + attr("poster", poster); + return this; + } + + /** + * <a class="doclink" href="https://www.w3.org/TR/html5/embedded-content-0.html#attr-media-preload">preload</a> + * attribute. + * + * <p> + * Hints how much buffering the media resource will likely need. + * + * @param preload The new value for this attribute. + * @return This object (for method chaining). + */ + public final Video preload(String preload) { + attr("preload", preload); + return this; + } + + /** + * <a class="doclink" href="https://www.w3.org/TR/html5/embedded-content-0.html#attr-media-src">src</a> attribute. + * + * <p> + * Address of the resource. + * + * <p> + * The value can be of any of the following types: {@link URI}, {@link URL}, {@link String}. + * Strings must be valid URIs. + * + * <p> + * URIs defined by {@link UriResolver} can be used for values. + * + * @param src + * The new value for this attribute. + * Typically a {@link URL} or {@link String}. + * @return This object (for method chaining). + */ + public final Video src(Object src) { + attrUri("src", src); + return this; + } + + /** + * <a class="doclink" href="https://www.w3.org/TR/html5/embedded-content-0.html#attr-dim-width">width</a> attribute. + * + * <p> + * Horizontal dimension. + * + * @param width + * The new value for this attribute. + * Typically a {@link Number} or {@link String}. + * @return This object (for method chaining). + */ + public final Video width(Object width) { + attr("width", width); + return this; + } + + + //-------------------------------------------------------------------------------- + // Overridden methods + //-------------------------------------------------------------------------------- + + @Override /* HtmlElement */ + public final Video _class(String _class) { + super._class(_class); + return this; + } + + @Override /* HtmlElement */ + public final Video id(String id) { + super.id(id); + return this; + } + + @Override /* HtmlElement */ + public final Video style(String style) { + super.style(style); + return this; + } + + @Override /* HtmlElementContainer */ + public final Video children(Object...children) { + super.children(children); + return this; + } + + @Override /* HtmlElementContainer */ + public final Video child(Object child) { + super.child(child); + return this; + } +} http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/75b0d8ee/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/html5/Wbr.java ---------------------------------------------------------------------- diff --git a/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/html5/Wbr.java b/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/html5/Wbr.java new file mode 100644 index 0000000..f99be21 --- /dev/null +++ b/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/html5/Wbr.java @@ -0,0 +1,57 @@ +// *************************************************************************************************************************** +// * 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.html5; + +import org.apache.juneau.annotation.*; + +/** + * DTO for an HTML <a class="doclink" href="https://www.w3.org/TR/html5/text-level-semantics.html#the-wbr-element"><wbr></a> + * element. + * + * <h6 class='topic'>Additional Information</h6> + * <ul class='doctree'> + * <li class='link'> + * <a class='doclink' href='../../../../../overview-summary.html#DTOs'>Juneau Data Transfer Objects + * (org.apache.juneau.dto)</a> + * <ul> + * <li class='sublink'> + * <a class='doclink' href='../../../../../overview-summary.html#DTOs.HTML5'>HTML5</a> + * </ul> + * </li> + * </ul> + */ +@Bean(typeName="wbr") +public class Wbr extends HtmlElementVoid { + + //-------------------------------------------------------------------------------- + // Overridden methods + //-------------------------------------------------------------------------------- + + @Override /* HtmlElement */ + public final Wbr _class(String _class) { + super._class(_class); + return this; + } + + @Override /* HtmlElement */ + public final Wbr id(String id) { + super.id(id); + return this; + } + + @Override /* HtmlElement */ + public final Wbr style(String style) { + super.style(style); + return this; + } +} http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/75b0d8ee/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/html5/package.html ---------------------------------------------------------------------- diff --git a/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/html5/package.html b/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/html5/package.html new file mode 100644 index 0000000..19cd4b5 --- /dev/null +++ b/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/html5/package.html @@ -0,0 +1,349 @@ +<!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>HTML5 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'>Generating HTML5</a></p> + <li><p><a class='doclink' href='#Parse'>Parsing HTML5</a></p> + <li><p><a class='doclink' href='#Templates'>HTML5 Templates</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 HTML5 documents and fragments through the use of DTOs (Data + Transfer Objects). + <br>It uses existing support for serializing and parsing POJOs to and from HTML to define these HTML objects. + </p> + + + <!-- ======================================================================================================== --> + <a id="Serialize"></a> + <h3 class='topic' onclick='toggle(this)'>1.1 - Generating HTML5</h3> + <div class='topic'> + <p> + The Juneau HTML5 DTOs are simply beans with fluent-style setters that allow you to quickly construct HTML + fragments as Java objects. These object can then be serialized to HTML using one of the existing HTML + serializers, or to other languages such as JSON using the JSON serializers. + </p> + <p> + The {@link org.apache.juneau.dto.html5.HtmlBuilder} class is a utility class with predefined static methods + that allow you to easily construct DTO instances in a minimal amount of code. + </p> + <p> + The following examples show how to create HTML fragments: + </p> + <table class='styled' style='width:auto'> + <tr> + <th>Java code</th> + <th>HTML</th> + </tr> + <tr> + <td class='code'> + <jk>import static</jk> org.apache.juneau.dto.html5.HtmlBuilder.*; + + Object mytable = + <jsm>table</jsm>( + <jsm>tr</jsm>(<jsm>th</jsm>(<js>"c1"</js>),<jsm>th</jsm>(<js>"c2"</js>)), + <jsm>tr</jsm>(<jsm>td</jsm>(<js>"v1"</js>),<jsm>td</jsm>(<js>"v2"</js>)) + ); + + String html = HtmlSerializer.<jsf>DEFAULT</jsf>.serialize(mytable); + </td> + <td class='code'><xt> + <table> + <tr> + <th><xv>c1</xv></th> + <th><xv>c2</xv></th> + </tr> + <tr> + <td><xv>v1</xv></td> + <td><xv>v2</xv></td> + </tr> + </table> + </xt></td> + </tr> + <tr> + <td class='code'> + <jk>import static</jk> org.apache.juneau.dto.html5.HtmlBuilder.*; + + Object mytable = + <jsm>table</jsm>( + <jsm>caption</jsm>(<js>"mytable"</js>), + <jsm>colgroup</jsm>( + <jsm>col</jsm>()._class(<js>"foo"</js>), + <jsm>col</jsm>()._class(<js>"bar"</js>) + ), + <jsm>thead</jsm>(<jsm>tr</jsm>(<jsm>th</jsm>(<js>"c1"</js>),<jsm>th</jsm>(<js>"c2"</js>))), + <jsm>tbody</jsm>(<jsm>tr</jsm>(<jsm>td</jsm>(<js>"v1"</js>),<jsm>td</jsm>(<js>"v2"</js>))), + <jsm>tfoot</jsm>(<jsm>tr</jsm>(<jsm>td</jsm>(<js>"f1"</js>),<jsm>td</jsm>(<js>"f2"</js>))) + ); + + String html = HtmlSerializer.<jsf>DEFAULT</jsf>.serialize(mytable); + </td> + <td class='code'><xt> + <table> + <caption><xv>mytable</xv></caption> + <colgroup> + <col <xa>class</xa>=<xs>'foo'</xs>/> + <col <xa>class</xa>=<xs>'bar'</xs>/> + </colgroup> + <thead> + <tr> + <th><xv>c1</xv></th> + <th><xv>c2</xv></th> + </tr> + </thead> + <tbody> + <tr> + <td><xv>v1</xv></td> + <td><xv>v2</xv></td> + </tr> + </tbody> + <tfoot> + <tr> + <td><xv>f1</xv></td> + <td><xv>f2</xv></td> + </tr> + </tfoot> + </table> + </xt></td> + </tr> + <tr> + <td class='code'> + <jk>import static</jk> org.apache.juneau.dto.html5.HtmlBuilder.*; + + Object mydiv = + <jsm>div</jsm>().align(<js>"center"</js>).onmouseover(<js>"alert(\"boo!\");"</js>) + .children( + <jsm>p</jsm>(<js>"Juneau supports "</js>, <jsm>b</jsm>(<jsm>i</jsm>(<js>"mixed"</js>)), <js>" content!"</js>) + ); + + String html = HtmlSerializer.<jsf>DEFAULT</jsf>.serialize(mydiv); + </td> + <td class='code'><xt> + <div <xa>align</xa>=<xs>'center'</xs> <xa>onmouseover</xa>=<xs>'alert("boo!");'</xs>> + <p><xv>Juneau supports </xv><b><i><xv>mixed</xv></i></b> <xv>content!</xv></p> + </table> + </xt></td> + </tr> + <tr> + <td class='code'> + <jk>import static</jk> org.apache.juneau.dto.html5.HtmlBuilder.*; + + Object myform = + <jsm>form</jsm>().action(<js>"/submit"</js>).method(<js>"POST"</js>) + .children( + <js>"Position (1-10000): "</js>, + <jsm>input</jsm>(<js>"number"</js>).name(<js>"pos"</js>).value(1), <jsm>br</jsm>(), + <js>"Limit (1-10000): "</js>, + <jsm>input</jsm>(<js>"number"</js>).name(<js>"limit"</js>).value(100), <jsm>br</jsm>(), + <jsm>button</jsm>(<js>"submit"</js>, <js>"Submit"</js>), + <jsm>button</jsm>(<js>"reset"</js>, <js>"Reset"</js>) + ); + + String html = HtmlSerializer.<jsf>DEFAULT</jsf>.serialize(myform); + </td> + <td class='code'><xt> + <form <xa>action</xa>=<xs>'/submit'</xs> <xa>method</xa>=<xs>'POST'</xs>> + <xv>Position (1-10000):</xv> <input <xa>name</xa>=<xs>'pos'</xs> + <xa>type</xa>=<xs>'number'</xs> <xa>value</xa>=<xs>'1'</xs>/><br/> + <xv>Limit (1-10000):</xv> <input <xa>name</xa>=<xs>'pos'</xs> + <xa>type</xa>=<xs>'number'</xs> <xa>value</xa>=<xs>'100'</xs>/><br/> + <button <xa>type</xa>=<xs>'submit'</xs>><xv>Submit</xv></button> + <button <xa>type</xa>=<xs>'reset'</xs>><xv>Reset</xv></button> + </form> + </xt></td> + </tr> + </table> + </div> + + <!-- ======================================================================================================== --> + <a id="Parse"></a> + <h3 class='topic' onclick='toggle(this)'>1.2 - Parsing HTML5</h3> + <div class='topic'> + <p> + Use the {@link org.apache.juneau.html.HtmlParser} to convert HTML5 documents back into their original POJOs: + </p> + <p class='bcode'> + <jc>// Get an HTML parser to convert our generated HTML5 documents back into POJOs.</jc> + HtmlParser p = HtmlParser.<jsf>DEFAULT</jsf>; + + <jc>// Convert an HTML table back into a Table object.</jc> + Table table = p.parse(tableHtml, Table.<jk>class</jk>); + </p> + <p> + HTML5 objects can also be constructed from the other media types using the appropriate parsers. + </p> + </div> + + <!-- ======================================================================================================== --> + <a id="Templates"></a> + <h3 class='topic' onclick='toggle(this)'>1.3 - HTML5 templates</h3> + <div class='topic'> + <p> + If you're finding yourself reusing the same HTML5 DTO objects over and over that only differ slightly, + you may want to consider using HTML5 templates. + Broadly speaking, a template is simply a bean that gets swapped out with another more complex bean during + serialization. + Juneau doesn't have a built-in concept of a "template", but rather has features that allow them to be + defined using existing swap support. + </p> + <p> + The following example shows how an HTML5 form template object can be created that gets serialized as a + populated HTML5 {@link org.apache.juneau.dto.html5.Form} bean. + It takes advantage of the special <code>swap(BeanSession)</code> method that serializers will use to + convert the object to a serialized form before serialization. + The return type of this method can be any serializable type. + In this case, we are defining a template for a reusable HTML form with two simple fields. + This gets serialized as an HTML form. + </p> + <p class='bcode'> + <jk>import static</jk> org.apache.juneau.dto.html5.HtmlBuilder.*; + + <jd>/** + * A simple HTML form template whose serialized form is an HTML5 Form object. + */</jd> + <jk>public class</jk> FormTemplate { + + <jk>private</jk> String <jf>action</jf>; + <jk>private int</jk> <jf>value1</jf>; + <jk>private boolean</jk> <jf>value2</jf>; + + <jc>// Some constructor that initializes our fields. </jc> + <jk>public</jk> FormTemplate(String action, <jk>int</jk> value1, <jk>boolean</jk> value2) { + <jk>this</jk>.<jf>action</jf> = action; + <jk>this</jk>.<jf>value1</jf> = value1; + <jk>this</jk>.<jf>value2</jf> = value2; + } + + <jc>// Special swap method that converts this template to a serializable bean, + // in this case an HTML5 Form bean. </jc> + <jk>public</jk> Form swap(BeanSession session) { + <jk>return</jk> <jsm>form</jsm>(<jf>action</jf>, + <jsm>input</jsm>(<js>"text"</js>).name(<js>"v1"</js>).value(<jf>value1</jf>), + <jsm>input</jsm>(<js>"text"</js>).name(<js>"v2"</js>).value(<jf>value2</jf>) + ); + } + } + </p> + <p> + When serialized using the HTML or XML serializer, it produces the following: + </p> + <p class='bcode'><xt> + <form <xa>action</xa>='myaction'> + <input <xa>type</xa>=<xs>'text'</xs> <xa>name</xa>=<xs>'v1'</xs> <xa>value</xa>=<xs>'123'</xs>/> + <input <xa>type</xa>=<xs>'text'</xs> <xa>name</xa>=<xs>'v2'</xs> <xa>value</xa>=<xs>'true'</xs>/> + </form> + </xt></p> + <p> + Support for parsing back into the template class can be accomplished by adding an unswap method or + constructor. + </p> + <p class='bcode'> + <jk>import static</jk> org.apache.juneau.dto.html5.HtmlBuilder.*; + + <jd>/** + * A simple HTML form template whose serialized form is an HTML5 Form object. + * This time with parsing support. + */</jd> + <ja>@Bean</ja>(beanDictionary=HtmlBeanDictionary.<jk>class</jk>) + <jk>public class</jk> FormTemplate { + + <jk>private</jk> String <jf>action</jf>; + <jk>private int</jk> <jf>value1</jf>; + <jk>private boolean</jk> <jf>value2</jf>; + + <jc>// Our 'unswap' constructor</jc> + <jk>public</jk> FormTemplate(Form f) { + <jk>this</jk>.<jf>action</jf> = f.getAttr(<js>"action"</js>); + <jk>this</jk>.<jf>value1</jf> = f.getChild(Input.<jk>class</jk>, 0) + .getAttr(<jk>int</jk>.<jk>class</jk>, <js>"value"</js>); + <jk>this</jk>.<jf>value2</jf> = f.getChild(Input.<jk>class</jk>, 1) + .getAttr(<jk>boolean</jk>.<jk>class</jk>, <js>"value"</js>); + } + + <jk>public</jk> FormTemplate(String action, <jk>int</jk> value1, <jk>boolean</jk> value2) { + <jk>this</jk>.<jf>action</jf> = action; + <jk>this</jk>.<jf>value1</jf> = value1; + <jk>this</jk>.<jf>value2</jf> = value2; + } + + <jk>public</jk> Form swap(BeanSession session) { + <jk>return</jk> <jsm>form</jsm>(<jf>action</jf>, + <jsm>input</jsm>(<js>"text"</js>).name(<js>"v1"</js>).value(<jf>value1</jf>), + <jsm>input</jsm>(<js>"text"</js>).name(<js>"v2"</js>).value(<jf>value2</jf>) + ); + } + } + </p> + <p> + Refer to <a class='doclink' href='../../../../../overview-summary.html#Core.SwapMethods'>Swap methods</a> + for information about defining swap methods on classes. + </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/75b0d8ee/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/jsonschema/JsonType.java ---------------------------------------------------------------------- diff --git a/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/jsonschema/JsonType.java b/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/jsonschema/JsonType.java new file mode 100644 index 0000000..805b234 --- /dev/null +++ b/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/jsonschema/JsonType.java @@ -0,0 +1,118 @@ +// *************************************************************************************************************************** +// * 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). + * + * <h5 class='section'>Example:</h5> + * <p class='bcode'> + * // Produces 'number', not 'NUMBER'. + * String json = JsonSerializer.DEFAULT.serialize(JsonType.NUMBER); + * </p> + * + * <h6 class='topic'>Additional Information</h6> + * <ul class='doctree'> + * <li class='link'> + * <a class='doclink' href='../../../../../overview-summary.html#DTOs'>Juneau Data Transfer Objects + * (org.apache.juneau.dto)</a> + * <ul> + * <li class='sublink'> + * <a class='doclink' href='../../../../../overview-summary.html#DTOs.JsonSchema'>JSON-Schema</a> + * </ul> + * </li> + * <li class='jp'> + * <a class='doclink' href='package-summary.html#TOC'>org.apache.juneau.dto.jsonschema</a> + * </li> + * </ul> + */ +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/75b0d8ee/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/jsonschema/JsonTypeArray.java ---------------------------------------------------------------------- diff --git a/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/jsonschema/JsonTypeArray.java b/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/jsonschema/JsonTypeArray.java new file mode 100644 index 0000000..8339594 --- /dev/null +++ b/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/jsonschema/JsonTypeArray.java @@ -0,0 +1,64 @@ +// *************************************************************************************************************************** +// * 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. + * + * <h6 class='topic'>Additional Information</h6> + * <ul class='doctree'> + * <li class='link'> + * <a class='doclink' href='../../../../../overview-summary.html#DTOs'>Juneau Data Transfer Objects + * (org.apache.juneau.dto)</a> + * <ul> + * <li class='sublink'> + * <a class='doclink' href='../../../../../overview-summary.html#DTOs.JsonSchema'>JSON-Schema</a> + * </ul> + * </li> + * <li class='jp'> + * <a class='doclink' href='package-summary.html#TOC'>org.apache.juneau.dto.jsonschema</a> + * </li> + * </ul> + */ +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/75b0d8ee/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/jsonschema/Sample.java ---------------------------------------------------------------------- diff --git a/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/jsonschema/Sample.java b/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/jsonschema/Sample.java new file mode 100644 index 0000000..728cf18 --- /dev/null +++ b/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/jsonschema/Sample.java @@ -0,0 +1,68 @@ +// *************************************************************************************************************************** +// * 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 static org.apache.juneau.internal.IOUtils.*; + +import java.io.*; +import java.net.*; + +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(), 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.apache.org/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" // NOT DEBUG + + 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" // NOT DEBUG + } +}
