http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/75b0d8ee/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/atom/Generator.java ---------------------------------------------------------------------- diff --git a/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/atom/Generator.java b/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/atom/Generator.java new file mode 100644 index 0000000..2abcc0d --- /dev/null +++ b/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/atom/Generator.java @@ -0,0 +1,168 @@ +// *************************************************************************************************************************** +// * 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 static org.apache.juneau.internal.StringUtils.*; +import static org.apache.juneau.xml.annotation.XmlFormat.*; + +import java.net.*; +import java.net.URI; + +import org.apache.juneau.*; +import org.apache.juneau.annotation.*; +import org.apache.juneau.xml.annotation.*; + +/** + * Represents an <code>atomGenerator</code> construct in the RFC4287 specification. + * + * <h6 class='figure'>Schema</h6> + * <p class='bcode'> + * atomGenerator = element atom:generator { + * atomCommonAttributes, + * attribute uri { atomUri }?, + * attribute version { text }?, + * text + * } + * </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.Atom'>Atom</a> + * </ul> + * </li> + * <li class='jp'> + * <a class='doclink' href='package-summary.html#TOC'>org.apache.juneau.dto.atom</a> + * </li> + * </ul> + */ +@Bean(typeName="generator") +@SuppressWarnings("hiding") +public class Generator extends Common { + + private URI uri; + private String version; + private String text; + + + /** + * Normal constructor. + * + * @param text The generator statement content. + */ + public Generator(String text) { + this.text = text; + } + + /** Bean constructor. */ + public Generator() {} + + + //-------------------------------------------------------------------------------- + // Bean properties + //-------------------------------------------------------------------------------- + + /** + * Returns the URI of this generator statement. + * + * @return The URI of this generator statement. + */ + @Xml(format=ATTR) + public URI getUri() { + return uri; + } + + /** + * Sets the URI of this generator statement. + * + * <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 uri The URI of this generator statement. + * @return This object (for method chaining). + */ + @BeanProperty("uri") + public Generator uri(Object uri) { + this.uri = toURI(uri); + return this; + } + + /** + * Returns the version of this generator statement. + * + * @return The version of this generator statement. + */ + @Xml(format=ATTR) + public String getVersion() { + return version; + } + + /** + * Sets the version of this generator statement. + * + * @param version The version of this generator statement. + * @return This object (for method chaining). + */ + @BeanProperty("version") + public Generator version(String version) { + this.version = version; + return this; + } + + /** + * Returns the content of this generator statement. + * + * @return The content of this generator statement. + */ + @Xml(format=TEXT) + public String getText() { + return text; + } + + /** + * Sets the content of this generator statement. + * + * @param text The content of this generator statement. + * @return This object (for method chaining). + */ + @BeanProperty("text") + public Generator text(String text) { + this.text = text; + return this; + } + + + //-------------------------------------------------------------------------------- + // Overridden setters (to simplify method chaining) + //-------------------------------------------------------------------------------- + + @Override /* Common */ + public Generator base(Object base) { + super.base(base); + return this; + } + + @Override /* Common */ + public Generator lang(String lang) { + super.lang(lang); + 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/atom/Icon.java ---------------------------------------------------------------------- diff --git a/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/atom/Icon.java b/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/atom/Icon.java new file mode 100644 index 0000000..e16ae23 --- /dev/null +++ b/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/atom/Icon.java @@ -0,0 +1,127 @@ +// *************************************************************************************************************************** +// * 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 static org.apache.juneau.internal.StringUtils.*; +import static org.apache.juneau.xml.annotation.XmlFormat.*; + +import java.net.*; +import java.net.URI; + +import org.apache.juneau.*; +import org.apache.juneau.annotation.*; +import org.apache.juneau.xml.annotation.*; + +/** + * Represents an <code>atomIcon</code> construct in the RFC4287 specification. + * + * <h6 class='figure'>Schema</h6> + * <p class='bcode'> + * atomIcon = element atom:icon { + * atomCommonAttributes, + * (atomUri) + * } + * </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.Atom'>Atom</a> + * </ul> + * </li> + * <li class='jp'> + * <a class='doclink' href='package-summary.html#TOC'>org.apache.juneau.dto.atom</a> + * </li> + * </ul> + */ +@Bean(typeName="icon") +@SuppressWarnings("hiding") +public class Icon extends Common { + + private URI uri; + + + /** + * Normal constructor. + * + * <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 uri The URI of the icon. + */ + public Icon(Object uri) { + uri(uri); + } + + /** Bean constructor. */ + public Icon() {} + + + //-------------------------------------------------------------------------------- + // Bean properties + //-------------------------------------------------------------------------------- + + /** + * Returns the URI of this icon. + * + * @return The URI of this icon. + */ + @Xml(format=ELEMENTS) + public URI getUri() { + return uri; + } + + /** + * Sets the URI of this icon. + * + * <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 uri The URI of this icon. + * @return This object (for method chaining). + */ + @BeanProperty("uri") + public Icon uri(Object uri) { + this.uri = toURI(uri); + return this; + } + + + //-------------------------------------------------------------------------------- + // Overridden setters (to simplify method chaining) + //-------------------------------------------------------------------------------- + + @Override /* Common */ + public Icon base(Object base) { + super.base(base); + return this; + } + + @Override /* Common */ + public Icon lang(String lang) { + super.lang(lang); + 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/atom/Id.java ---------------------------------------------------------------------- diff --git a/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/atom/Id.java b/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/atom/Id.java new file mode 100644 index 0000000..01b194e --- /dev/null +++ b/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/atom/Id.java @@ -0,0 +1,107 @@ +// *************************************************************************************************************************** +// * 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 static org.apache.juneau.xml.annotation.XmlFormat.*; + +import org.apache.juneau.annotation.*; +import org.apache.juneau.xml.annotation.*; + +/** + * Represents an <code>atomId</code> construct in the RFC4287 specification. + * + * <h6 class='figure'>Schema</h6> + * <p class='bcode'> + * atomId = element atom:id { + * atomCommonAttributes, + * (atomUri) + * } + * </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.Atom'>Atom</a> + * </ul> + * </li> + * <li class='jp'> + * <a class='doclink' href='package-summary.html#TOC'>org.apache.juneau.dto.atom</a> + * </li> + * </ul> + */ +@Bean(typeName="id") +@SuppressWarnings("hiding") +public class Id extends Common { + + private String text; + + /** + * Normal constructor. + * + * @param text The id element contents. + */ + public Id(String text) { + text(text); + } + + /** Bean constructor. */ + public Id() {} + + + //-------------------------------------------------------------------------------- + // Bean properties + //-------------------------------------------------------------------------------- + + /** + * Returns the content of this identifier. + * + * @return The content of this identifier. + */ + @Xml(format=TEXT) + public String getText() { + return text; + } + + /** + * Sets the content of this identifier. + * + * @param text The content of this identifier. + * @return This object (for method chaining). + */ + @BeanProperty("text") + public Id text(String text) { + this.text = text; + return this; + } + + + //-------------------------------------------------------------------------------- + // Overridden setters (to simplify method chaining) + //-------------------------------------------------------------------------------- + + @Override /* Common */ + public Id base(Object base) { + super.base(base); + return this; + } + + @Override /* Common */ + public Id lang(String lang) { + super.lang(lang); + 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/atom/Link.java ---------------------------------------------------------------------- diff --git a/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/atom/Link.java b/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/atom/Link.java new file mode 100644 index 0000000..695f1c5 --- /dev/null +++ b/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/atom/Link.java @@ -0,0 +1,241 @@ +// *************************************************************************************************************************** +// * 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 static org.apache.juneau.xml.annotation.XmlFormat.*; + +import org.apache.juneau.annotation.*; +import org.apache.juneau.xml.annotation.*; + +/** + * Represents an <code>atomLink</code> construct in the RFC4287 specification. + * + * <h6 class='figure'>Schema</h6> + * <p class='bcode'> + * atomLink = + * element atom:link { + * atomCommonAttributes, + * attribute href { atomUri }, + * attribute rel { atomNCName | atomUri }?, + * attribute type { atomMediaType }?, + * attribute hreflang { atomLanguageTag }?, + * attribute title { text }?, + * attribute length { text }?, + * undefinedContent + * } + * </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.Atom'>Atom</a> + * </ul> + * </li> + * <li class='jp'> + * <a class='doclink' href='package-summary.html#TOC'>org.apache.juneau.dto.atom</a> + * </li> + * </ul> + */ +@Bean(typeName="link") +@SuppressWarnings("hiding") +public class Link extends Common { + + private String href; + private String rel; + private String type; + private String hreflang; + private String title; + private Integer length; + + + /** + * Normal constructor. + * + * @param rel The rel of the link. + * @param type The type of the link. + * @param href The URI of the link. + */ + public Link(String rel, String type, String href) { + rel(rel).type(type).href(href); + } + + /** Bean constructor. */ + public Link() {} + + + //-------------------------------------------------------------------------------- + // Bean properties + //-------------------------------------------------------------------------------- + + /** + * Returns the href of the target of this link. + * + * @return The href of the target of this link. + */ + @Xml(format=ATTR) + public String getHref() { + return href; + } + + /** + * Sets the href of the target of this link. + * + * @param href The href of the target of this link. + * @return This object (for method chaining). + */ + @BeanProperty("href") + public Link href(String href) { + this.href = href; + return this; + } + + /** + * Returns the rel of this link. + * + * @return The rel of this link. + */ + @Xml(format=ATTR) + public String getRel() { + return rel; + } + + /** + * Sets the rel of this link. + * + * @param rel The rel of this link. + * @return This object (for method chaining). + */ + @BeanProperty("rel") + public Link rel(String rel) { + this.rel = rel; + return this; + } + + /** + * Returns the content type of the target of this link. + * + * @return The content type of the target of this link. + */ + @Xml(format=ATTR) + public String getType() { + return type; + } + + /** + * Sets the content type of the target of this link. + * + * <p> + * Must be one of the following: + * <ul> + * <li><js>"text"</js> + * <li><js>"html"</js> + * <li><js>"xhtml"</js> + * <li><jk>null</jk> (defaults to <js>"text"</js>) + * </ul> + * + * @param type The content type of the target of this link. + * @return This object (for method chaining). + */ + @BeanProperty("type") + public Link type(String type) { + this.type = type; + return this; + } + + /** + * Returns the language of the target of this link. + * + * @return The language of the target of this link. + */ + @Xml(format=ATTR) + public String getHreflang() { + return hreflang; + } + + /** + * Sets the language of the target of this link. + * + * @param hreflang The language of the target of this link. + * @return This object (for method chaining). + */ + @BeanProperty("hreflang") + public Link hreflang(String hreflang) { + this.hreflang = hreflang; + return this; + } + + /** + * Returns the title of the target of this link. + * + * @return The title of the target of this link. + */ + @Xml(format=ATTR) + public String getTitle() { + return title; + } + + /** + * Sets the title of the target of this link. + * + * @param title The title of the target of this link. + * @return This object (for method chaining). + */ + @BeanProperty("title") + public Link title(String title) { + this.title = title; + return this; + } + + /** + * Returns the length of the contents of the target of this link. + * + * @return The length of the contents of the target of this link. + */ + @Xml(format=ATTR) + public Integer getLength() { + return length; + } + + /** + * Sets the length of the contents of the target of this link. + * + * @param length The length of the contents of the target of this link. + * @return This object (for method chaining). + */ + @BeanProperty("length") + public Link length(Integer length) { + this.length = length; + return this; + } + + + //-------------------------------------------------------------------------------- + // Overridden setters (to simplify method chaining) + //-------------------------------------------------------------------------------- + + @Override /* Common */ + public Link base(Object base) { + super.base(base); + return this; + } + + @Override /* Common */ + public Link lang(String lang) { + super.lang(lang); + 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/atom/Logo.java ---------------------------------------------------------------------- diff --git a/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/atom/Logo.java b/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/atom/Logo.java new file mode 100644 index 0000000..97e045e --- /dev/null +++ b/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/atom/Logo.java @@ -0,0 +1,127 @@ +// *************************************************************************************************************************** +// * 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 static org.apache.juneau.internal.StringUtils.*; +import static org.apache.juneau.xml.annotation.XmlFormat.*; + +import java.net.*; +import java.net.URI; + +import org.apache.juneau.*; +import org.apache.juneau.annotation.*; +import org.apache.juneau.xml.annotation.*; + +/** + * Represents an <code>atomLogo</code> construct in the RFC4287 specification. + * + * <h6 class='figure'>Schema</h6> + * <p class='bcode'> + * atomLogo = element atom:logo { + * atomCommonAttributes, + * (atomUri) + * } + * </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.Atom'>Atom</a> + * </ul> + * </li> + * <li class='jp'> + * <a class='doclink' href='package-summary.html#TOC'>org.apache.juneau.dto.atom</a> + * </li> + * </ul> + */ +@Bean(typeName="logo") +@SuppressWarnings("hiding") +public class Logo extends Common { + + private URI uri; + + + /** + * Normal constructor. + * + * <p> + * The value can be of any of the following types: {@link URI}, {@link URL}, {@link String}. + * <br>Strings must be valid URIs. + * + * <p> + * URIs defined by {@link UriResolver} can be used for values. + * + * @param uri The URI of the logo. + */ + public Logo(Object uri) { + uri(uri); + } + + /** Bean constructor. */ + public Logo() {} + + + //-------------------------------------------------------------------------------- + // Bean properties + //-------------------------------------------------------------------------------- + + /** + * Returns the URI of the logo. + * + * @return The URI of the logo. + */ + @Xml(format=ELEMENTS) + public URI getUri() { + return uri; + } + + /** + * Sets the URI of the logo. + * + * <p> + * The value can be of any of the following types: {@link URI}, {@link URL}, {@link String}. + * <br>Strings must be valid URIs. + * + * <p> + * URIs defined by {@link UriResolver} can be used for values. + * + * @param uri The URI of the logo. + * @return This object (for method chaining). + */ + @BeanProperty("uri") + public Logo uri(Object uri) { + this.uri = toURI(uri); + return this; + } + + + //-------------------------------------------------------------------------------- + // Overridden setters (to simplify method chaining) + //-------------------------------------------------------------------------------- + + @Override /* Common */ + public Logo base(Object base) { + super.base(base); + return this; + } + + @Override /* Common */ + public Logo lang(String lang) { + super.lang(lang); + 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/atom/Person.java ---------------------------------------------------------------------- diff --git a/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/atom/Person.java b/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/atom/Person.java new file mode 100644 index 0000000..f557a97 --- /dev/null +++ b/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/atom/Person.java @@ -0,0 +1,163 @@ +// *************************************************************************************************************************** +// * 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 static org.apache.juneau.internal.StringUtils.*; + +import java.net.*; +import java.net.URI; + +import org.apache.juneau.*; + +import org.apache.juneau.annotation.*; + +/** + * Represents an <code>atomPersonConstruct</code> construct in the RFC4287 specification. + * + * <h6 class='figure'>Schema</h6> + * <p class='bcode'> + * atomPersonConstruct = + * atomCommonAttributes, + * (element atom:name { text } + * & element atom:uri { atomUri }? + * & element atom:email { atomEmailAddress }? + * & extensionElement*) + * </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.Atom'>Atom</a> + * </ul> + * </li> + * <li class='jp'> + * <a class='doclink' href='package-summary.html#TOC'>org.apache.juneau.dto.atom</a> + * </li> + * </ul> + */ +@SuppressWarnings("hiding") +public class Person extends Common { + + private String name; + private URI uri; + private String email; + + + /** + * Normal constructor. + * + * @param name The name of the person. + */ + public Person(String name) { + name(name); + } + + /** Bean constructor. */ + public Person() {} + + + //-------------------------------------------------------------------------------- + // Bean properties + //-------------------------------------------------------------------------------- + + /** + * Returns the name of the person. + * + * @return The name of the person. + */ + public String getName() { + return name; + } + + /** + * Sets the name of the person. + * + * @param name The name of the person. + * @return This object (for method chaining). + */ + @BeanProperty("name") + public Person name(String name) { + this.name = name; + return this; + } + + /** + * Returns the URI of the person. + * + * @return The URI of the person. + */ + public URI getUri() { + return uri; + } + + /** + * Sets the URI of the person. + * + * <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 uri The URI of the person. + * @return This object (for method chaining). + */ + @BeanProperty("uri") + public Person uri(Object uri) { + this.uri = toURI(uri); + return this; + } + + /** + * Returns the email address of the person. + * + * @return The email address of the person. + */ + public String getEmail() { + return email; + } + + /** + * Sets the email address of the person. + * + * @param email The email address of the person. + * @return This object (for method chaining). + */ + @BeanProperty("email") + public Person email(String email) { + this.email = email; + return this; + } + + + //-------------------------------------------------------------------------------- + // Overridden setters (to simplify method chaining) + //-------------------------------------------------------------------------------- + + @Override /* Common */ + public Person base(Object base) { + super.base(base); + return this; + } + + @Override /* Common */ + public Person lang(String lang) { + super.lang(lang); + 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/atom/Source.java ---------------------------------------------------------------------- diff --git a/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/atom/Source.java b/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/atom/Source.java new file mode 100644 index 0000000..f86380b --- /dev/null +++ b/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/atom/Source.java @@ -0,0 +1,249 @@ +// *************************************************************************************************************************** +// * 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.util.*; + +import org.apache.juneau.annotation.*; + +/** + * Represents an <code>atomSource</code> construct in the RFC4287 specification. + * + * <h6 class='figure'>Schema</h6> + * <p class='bcode'> + * atomSource = + * element atom:source { + * atomCommonAttributes, + * (atomAuthor* + * & atomCategory* + * & atomContributor* + * & atomGenerator? + * & atomIcon? + * & atomId? + * & atomLink* + * & atomLogo? + * & atomRights? + * & atomSubtitle? + * & atomTitle? + * & atomUpdated? + * & extensionElement*) + * } + * </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.Atom'>Atom</a> + * </ul> + * </li> + * <li class='jp'> + * <a class='doclink' href='package-summary.html#TOC'>org.apache.juneau.dto.atom</a> + * </li> + * </ul> + */ +@SuppressWarnings("hiding") +public class Source extends CommonEntry { + + private Generator generator; + private Icon icon; + private Logo logo; + private Text subtitle; + + + //-------------------------------------------------------------------------------- + // Bean properties + //-------------------------------------------------------------------------------- + + /** + * Returns the generator info of this source. + * + * @return The generator info of this source. + */ + public Generator getGenerator() { + return generator; + } + + /** + * Sets the generator info of this source. + * + * @param generator The generator info of this source. + * @return This object (for method chaining). + */ + @BeanProperty("generator") + public Source generator(Generator generator) { + this.generator = generator; + return this; + } + + /** + * Returns the icon of this source. + * + * @return The icon of this source. + */ + public Icon getIcon() { + return icon; + } + + /** + * Sets the icon of this source. + * + * @param icon The icon of this source. + * @return This object (for method chaining). + */ + @BeanProperty("icon") + public Source icon(Icon icon) { + this.icon = icon; + return this; + } + + /** + * Returns the logo of this source. + * + * @return The logo of this source. + */ + public Logo getLogo() { + return logo; + } + + /** + * Sets the logo of this source. + * + * @param logo The logo of this source. + * @return This object (for method chaining). + */ + @BeanProperty("logo") + public Source logo(Logo logo) { + this.logo = logo; + return this; + } + + /** + * Returns the subtitle of this source. + * + * @return The subtitle of this source. + */ + public Text getSubtitle() { + return subtitle; + } + + /** + * Sets the subtitle of this source. + * + * @param subtitle The subtitle of this source. + * @return This object (for method chaining). + */ + @BeanProperty("subtitle") + public Source subtitle(Text subtitle) { + this.subtitle = subtitle; + return this; + } + + /** + * Sets the subtitle of this source. + * + * @param subtitle The subtitle of this source. + * @return This object (for method chaining). + */ + @BeanProperty("subtitle") + public Source subtitle(String subtitle) { + this.subtitle = new Text(subtitle); + return this; + } + + + //-------------------------------------------------------------------------------- + // Overridden setters (to simplify method chaining) + //-------------------------------------------------------------------------------- + + @Override /* CommonEntry */ + public Source authors(Person...authors) { + super.authors(authors); + return this; + } + + @Override /* CommonEntry */ + public Source categories(Category...categories) { + super.categories(categories); + return this; + } + + @Override /* CommonEntry */ + public Source contributors(Person...contributors) { + super.contributors(contributors); + return this; + } + + @Override /* CommonEntry */ + public Source id(Id id) { + super.id(id); + return this; + } + + @Override /* CommonEntry */ + public Source links(Link...links) { + super.links(links); + return this; + } + + @Override /* CommonEntry */ + public Source rights(Text rights) { + super.rights(rights); + return this; + } + + @Override /* CommonEntry */ + public Source rights(String rights) { + super.rights(rights); + return this; + } + + @Override /* CommonEntry */ + public Source title(Text title) { + super.title(title); + return this; + } + + @Override /* CommonEntry */ + public Source title(String title) { + super.title(title); + return this; + } + + @Override /* CommonEntry */ + public Source updated(Calendar updated) { + super.updated(updated); + return this; + } + + @Override /* CommonEntry */ + public Source updated(String updated) { + super.updated(updated); + return this; + } + + @Override /* Common */ + public Source base(Object base) { + super.base(base); + return this; + } + + @Override /* Common */ + public Source lang(String lang) { + super.lang(lang); + 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/atom/Text.java ---------------------------------------------------------------------- diff --git a/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/atom/Text.java b/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/atom/Text.java new file mode 100644 index 0000000..572e08a --- /dev/null +++ b/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/atom/Text.java @@ -0,0 +1,151 @@ +// *************************************************************************************************************************** +// * 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 static org.apache.juneau.xml.annotation.XmlFormat.*; + +import org.apache.juneau.annotation.*; +import org.apache.juneau.xml.annotation.*; + +/** + * Represents an <code>atomTextConstruct</code> construct in the RFC4287 specification. + * + * <h6 class='figure'>Schema</h6> + * <p class='bcode'> + * atomTextConstruct = atomPlainTextConstruct | atomXHTMLTextConstruct + * + * atomPlainTextConstruct = + * atomCommonAttributes, + * attribute type { "text" | "html" }?, + * text + * + * atomXHTMLTextConstruct = + * atomCommonAttributes, + * attribute type { "xhtml" }, + * xhtmlDiv + * + * xhtmlDiv = element xhtml:div { + * (attribute * { text } + * | text + * | anyXHTML)* + * } + * </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.Atom'>Atom</a> + * </ul> + * </li> + * <li class='jp'> + * <a class='doclink' href='package-summary.html#TOC'>org.apache.juneau.dto.atom</a> + * </li> + * </ul> + */ +@SuppressWarnings("hiding") +public class Text extends Common { + + private String type; + private String text; + + /** + * Normal content. + * + * @param type The content type of this content. + */ + public Text(String type) { + type(type); + } + + /** Bean constructor. */ + public Text() {} + + + //-------------------------------------------------------------------------------- + // Bean properties + //-------------------------------------------------------------------------------- + + /** + * Returns the content type of this content. + * + * @return The content type of this content. + */ + @Xml(format=ATTR) + public String getType() { + return type; + } + + /** + * Sets the content type of this content. + * + * <p> + * Must be one of the following: + * <ul> + * <li><js>"text"</js> + * <li><js>"html"</js> + * <li><js>"xhtml"</js> + * <li><jk>null</jk> (defaults to <js>"text"</js>) + * </ul> + * + * @param type The content type of this content. + * @return This object (for method chaining). + */ + @BeanProperty("type") + public Text type(String type) { + this.type = type; + return this; + } + + /** + * Returns the content of this content. + * + * @return The content of this content. + */ + @Xml(format=XMLTEXT) + public String getText() { + return text; + } + + /** + * Sets the content of this content. + * + * @param text The content of this content. + * @return This object (for method chaining). + */ + @BeanProperty("text") + public Text text(String text) { + this.text = text; + return this; + } + + + //-------------------------------------------------------------------------------- + // Overridden setters (to simplify method chaining) + //-------------------------------------------------------------------------------- + + @Override /* Common */ + public Text base(Object base) { + super.base(base); + return this; + } + + @Override /* Common */ + public Text lang(String lang) { + super.lang(lang); + 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/atom/Utils.java ---------------------------------------------------------------------- diff --git a/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/atom/Utils.java b/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/atom/Utils.java new file mode 100644 index 0000000..f42be90 --- /dev/null +++ b/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/atom/Utils.java @@ -0,0 +1,49 @@ +// *************************************************************************************************************************** +// * 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.util.*; + +import javax.xml.bind.*; + +/** + * Static utility methods for ATOM marshalling code. + * + * <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.Atom'>Atom</a> + * </ul> + * </li> + * <li class='jp'> + * <a class='doclink' href='package-summary.html#TOC'>org.apache.juneau.dto.atom</a> + * </li> + * </ul> + */ +class Utils { + + /** + * Converts an ISO8601 date-time string to a {@link Calendar}. + * + * @param lexicalXSDDateTime The ISO8601 date-time string. + * @return A new {@link Calendar} object. + */ + static final Calendar parseDateTime(String lexicalXSDDateTime) { + return DatatypeConverter.parseDateTime(lexicalXSDDateTime); + } + +} http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/75b0d8ee/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/atom/doc-files/Example_HTML.png ---------------------------------------------------------------------- diff --git a/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/atom/doc-files/Example_HTML.png b/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/atom/doc-files/Example_HTML.png new file mode 100644 index 0000000..18b3d52 Binary files /dev/null and b/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/atom/doc-files/Example_HTML.png differ http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/75b0d8ee/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/atom/package-info.java ---------------------------------------------------------------------- diff --git a/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/atom/package-info.java b/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/atom/package-info.java new file mode 100644 index 0000000..a0dad2a --- /dev/null +++ b/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/atom/package-info.java @@ -0,0 +1,23 @@ +// *************************************************************************************************************************** +// * 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. * +// *************************************************************************************************************************** +@XmlSchema( + prefix="atom", + xmlNs={ + @XmlNs(prefix="atom", namespaceURI="http://www.w3.org/2005/Atom/"), + @XmlNs(prefix="xml", namespaceURI="http://www.w3.org/XML/1998/namespace") + } +) +package org.apache.juneau.dto.atom; + +import org.apache.juneau.xml.annotation.*; + http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/75b0d8ee/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/atom/package.html ---------------------------------------------------------------------- diff --git a/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/atom/package.html b/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/atom/package.html new file mode 100644 index 0000000..5cd3f6a --- /dev/null +++ b/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/atom/package.html @@ -0,0 +1,574 @@ +<!DOCTYPE HTML> +<!-- +/*************************************************************************************************************************** + * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + * + ***************************************************************************************************************************/ + --> +<html> +<head> + <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> + <style type="text/css"> + /* For viewing in Page Designer */ + @IMPORT url("../../../../../../../javadoc.css"); + + /* For viewing in REST interface */ + @IMPORT url("../htdocs/javadoc.css"); + body { + margin: 20px; + } + </style> + <script> + /* Replace all @code and @link tags. */ + window.onload = function() { + document.body.innerHTML = document.body.innerHTML.replace(/\{\@code ([^\}]+)\}/g, '<code>$1</code>'); + document.body.innerHTML = document.body.innerHTML.replace(/\{\@link (([^\}]+)\.)?([^\.\}]+)\}/g, '<code>$3</code>'); + } + </script> +</head> +<body> +<p>ATOM Data Transfer Objects</p> +<script> + function toggle(x) { + var div = x.nextSibling; + while (div != null && div.nodeType != 1) + div = div.nextSibling; + if (div != null) { + var d = div.style.display; + if (d == 'block' || d == '') { + div.style.display = 'none'; + x.className += " closed"; + } else { + div.style.display = 'block'; + x.className = x.className.replace(/(?:^|\s)closed(?!\S)/g , '' ); + } + } + } +</script> +<a id='TOC'></a><h5 class='toc'>Table of Contents</h5> +<ol class='toc'> + <li><p><a class='doclink' href='#Overview'>Overview</a></p> + <ol> + <li><p><a class='doclink' href='#Serialize'>Serializing ATOM feeds</a></p> + <ol> + <li><p><a class='doclink' href='#AtomJson'>ATOM/JSON</a></p> + <li><p><a class='doclink' href='#AtomRdfXml'>ATOM/RDF/XML</a></p> + <li><p><a class='doclink' href='#AtomHtml'>ATOM/HTML</a></p> + </ol> + <li><p><a class='doclink' href='#Parse'>Parsing ATOM feeds</a></p> + </ol> +</ol> + + +<!-- ======================================================================================================== --> +<a id="Overview"></a> +<h2 class='topic' onclick='toggle(this)'>1 - Overview</h2> +<div class='topic'> + <p> + Juneau supports generation and consumption of ATOM feeds through the use of DTOs (Data Transfer Objects). + <br>It uses existing support for serializing and parsing POJOs to and from XML to define these ATOM objects. + </p> + <p> + The examples shown here are pulled from the <code>AtomFeedResource</code> class in the + <code>org.apache.juneau.sample.war</code> project. + </p> + + + <!-- ======================================================================================================== --> + <a id="Serialize"></a> + <h3 class='topic' onclick='toggle(this)'>1.1 - Serializing ATOM feeds</h3> + <div class='topic'> + <p> + The Juneau ATOM feed DTOs are simply beans with fluent-style setters. + <br>The following code shows a feed being created programmatically using the + {@link org.apache.juneau.dto.atom.AtomBuilder} class. + </p> + <p class='bcode'> + + <jk>import static</jk> org.apache.juneau.dto.atom.AtomBuilder.*; + + Feed feed = + <jsm>feed</jsm>(<js>"tag:juneau.apache.org"</js>, <js>"Juneau ATOM specification"</js>, <js>"2016-01-02T03:04:05Z"</js>) + .subtitle(<jsm>text</jsm>(<js>"html"</js>).text(<js>"Describes <em>stuff</em> about Juneau"</js>)) + .links( + <jsm>link</jsm>(<js>"alternate"</js>, <js>"text/html"</js>, <js>"http://juneau.apache.org"</js>).hreflang(<js>"en"</js>), + <jsm>link</jsm>(<js>"self"</js>, <js>"application/atom+xml"</js>, <js>"http://juneau.apache.org/feed.atom"</js>) + ) + .generator( + <jsm>generator</jsm>(<js>"Juneau"</js>).uri(<js>"http://juneau.apache.org"</js>).version(<js>"1.0"</js>) + ) + .entries( + <jsm>entry</jsm>(<js>"tag:juneau.sample.com,2013:1.2345"</js>, <js>"Juneau ATOM specification snapshot"</js>, <js>"2016-01-02T03:04:05Z"</js>) + .links( + <jsm>link</jsm>(<js>"alternate"</js>, <js>"text/html"</js>, <js>"http://juneau.apache.org/juneau.atom"</js>), + <jsm>link</jsm>(<js>"enclosure"</js>, <js>"audio/mpeg"</js>, <js>"http://juneau.apache.org/audio/juneau_podcast.mp3"</js>).length(1337) + ) + .published(<js>"2016-01-02T03:04:05Z"</js>) + .authors( + <jsm>person</jsm>(<js>"Jane Smith"</js>).uri(<js>"http://juneau.apache.org"</js>).email(<js>"[email protected]"</js>) + ) + .contributors( + <jsm>person</jsm>(<js>"John Smith"</js>) + ) + .content( + <jsm>content</jsm>(<js>"xhtml"</js>) + .lang(<js>"en"</js>) + .base(<js>"http://www.apache.org/"</js>) + .text(<js>"<div><p><i>[Update: Juneau supports ATOM.]</i></p></div>"</js>) + ) + ); + </p> + <p> + To serialize this to ATOM, use the {@link org.apache.juneau.xml.XmlSerializer} class: + </p> + + <h6 class='figure'>Example with no namespaces</h6> + <p class='bcode'> + <jc>// Create a serializer with readable output, no namespaces yet.</jc> + XmlSerializer s = <jk>new</jk> XmlSerializerBuilder().sq().ws().build(); + + <jc>// Serialize to ATOM/XML</jc> + String atomXml = s.serialize(feed); + </p> + + <h6 class='figure'>Results</h6> + <p class='bcode'> + <xt><feed></xt> + <xt><id></xt> + tag:juneau.apache.org + <xt></id></xt> + <xt><link</xt> <xa>href</xa>=<xs>'http://juneau.apache.org/'</xs> <xa>rel</xa>=<xs>'alternate'</xs> <xa>type</xa>=<xs>'text/html'</xs> <xa>hreflang</xa>=<xs>'en'</xs>/<xt>></xt> + <xt><link</xt> <xa>href</xa>=<xs>'http://juneau.apache.org/feed.atom'</xs> <xa>rel</xa>=<xs>'self'</xs> <xa>type</xa>=<xs>'application/atom+xml'</xs>/<xt>></xt> + <xt><title</xt> <xa>type</xa>=<xs>'text'</xs>></xt> + Juneau ATOM specification + <xt></title></xt> + <xt><updated></xt>2016-01-02T03:04:05Z<xt></updated></xt> + <xt><generator</xt> <xa>uri</xa>=<xs>'http://juneau.apache.org/'</xs> <xa>version</xa>=<xs>'1.0'</xs><xt>></xt> + Juneau + <xt></generator></xt> + <xt><subtitle</xt> <xa>type</xa>=<xs>'html'</xs><xt>></xt> + Describes <em>stuff</em> about Juneau + <xt></subtitle></xt> + <xt><entry></xt> + <xt><author></xt> + <xt><name></xt>Jane Smith<xt></name></xt> + <xt><uri></xt>http://juneau.apache.org/<xt></uri></xt> + <xt><email></xt>[email protected]<xt></email></xt> + <xt></author></xt> + <xt><contributor></xt> + <xt><name></xt>John Smith<xt></name></xt> + <xt></contributor></xt> + <xt><id></xt> + tag:juneau.apache.org + <xt></id></xt> + <xt><link</xt> <xa>href</xa>=<xs>'http://juneau.apache.org/juneau.atom'</xs> <xa>rel</xa>=<xs>'alternate'</xs> <xa>type</xa>=<xs>'text/html'</xs>/<xt>></xt> + <xt><link</xt> <xa>href</xa>=<xs>'http://juneau.apache.org/audio/juneau_podcast.mp3'</xs> <xa>rel</xa>=<xs>'enclosure'</xs> <xa>type</xa>=<xs>'audio/mpeg'</xs> <xa>length</xa>=<xs>'12345'</xs>/<xt>></xt> + <xt><title></xt> + Juneau ATOM specification snapshot + <xt></title></xt> + <xt><updated></xt>2016-01-02T03:04:05Z<xt></updated></xt> + <xt><content</xt> <xa>base</xa>=<xs>'http://www.apache.org/'</xs> <xa>lang</xa>=<xs>'en'</xs> <xa>type</xa>=<xs>'xhtml'</xs><xt>></xt> + <xt><div</xt> <xa>xmlns</xa>=<xs>"http://www.w3.org/1999/xhtml"</xs><xt>><p><i></xt>[Update: Juneau supports ATOM.]<xt></i></p></div></xt> + <xt></content></xt> + <xt><published></xt>2016-01-02T03:04:05Z<xt></published></xt> + <xt></entry></xt> + <xt></feed></xt> + </p> + + <p> + The following is the same, except with XML namespaces enabled: + </p> + + <h6 class='figure'>Example with namespaces</h6> + <p class='bcode'> + <jc>// Create a serializer with readable output with namespaces.</jc> + XmlSerializer s = <jk>new</jk> XmlSerializerBuilder().sq().ws().build(); + + <jc>// Serialize to ATOM/XML</jc> + String atomXml = s.serialize(feed); + </p> + + <h6 class='figure'>Results</h6> + <p class='bcode'> + <xt><atom:feed</xt> + <xa>xmlns</xa>=<xs>'http://www.apache.org/2013/Juneau'</xs> + <xa>xmlns:atom</xa>=<xs>'http://www.w3.org/2005/Atom/'</xs> + <xa>xmlns:xml</xa>=<xs>'http://www.w3.org/XML/1998/namespace'</xs> + <xa>xmlns:xsi</xa>=<xs>'http://www.w3.org/2001/XMLSchema-instance'</xs><xt>></xt> + <xt><atom:id></xt> + tag:juneau.apache.org + <xt></atom:id></xt> + <xt><atom:link</xt> <xa>href</xa>=<xs>'http://juneau.apache.org/'</xs> <xa>rel</xa>=<xs>'alternate'</xs> <xa>type</xa>=<xs>'text/html'</xs> <xa>hreflang</xa>=<xs>'en'</xs><xt>/></xt> + <xt><atom:link</xt> <xa>href</xa>=<xs>'http://juneau.apache.org/feed.atom'</xs> <xa>rel</xa>=<xs>'self'</xs> <xa>type</xa>=<xs>'application/atom+xml'</xs><xt>/></xt> + <xt><atom:title</xt> <xa>type</xa>=<xs>'text'</xs><xt>></xt> + Juneau ATOM specification + <xt></atom:title></xt> + <xt><atom:updated></xt>2016-01-02T03:04:05Z<xt></atom:updated></xt> + <xt><atom:generator</xt> <xa>uri</xa>=<xs>'http://juneau.apache.org/'</xs> <xa>version</xa>=<xs>'1.0'</xs><xt>></xt> + Juneau + <xt></atom:generator></xt> + <xt><atom:subtitle</xt> <xa>type</xa>=<xs>'html'</xs><xt>></xt> + Describes <em>stuff</em> about Juneau + <xt></atom:subtitle></xt> + <xt><atom:entry></xt> + <xt><atom:author></xt> + <xt><atom:name></xt>Jane Smith<xt></atom:name></xt> + <xt><atom:uri></xt>http://juneau.apache.org/<xt></atom:uri></xt> + <xt><atom:email></xt>[email protected]<xt></atom:email></xt> + <xt></atom:author></xt> + <xt><atom:contributor></xt> + <xt><atom:name></xt>John Smith<xt></atom:name></xt> + <xt></atom:contributor></xt> + <xt><atom:id></xt> + tag:juneau.apache.org + <xt></atom:id></xt> + <xt><atom:link</xt> <xa>href</xa>=<xs>'http://juneau.apache.org/juneau.atom'</xs> <xa>rel</xa>=<xs>'alternate'</xs> <xa>type</xa>=<xs>'text/html'</xs><xt>/></xt> + <xt><atom:link</xt> <xa>href</xa>=<xs>'http://juneau.apache.org/audio/juneau_podcast.mp3'</xs> <xa>rel</xa>=<xs>'enclosure'</xs> <xa>type</xa>=<xs>'audio/mpeg'</xs> <xa>length</xa>=<xs>'12345'</xs><xt>/></xt> + <xt><atom:title></xt> + Juneau ATOM specification snapshot + <xt></atom:title></xt> + <xt><atom:updated></xt>2016-01-02T03:04:05Z<xt></atom:updated></xt> + <xt><atom:content</xt> <xa>xml:base</xa>=<xs>'http://www.apache.org/'</xs> <xa>xml:lang</xa>=<xs>'en'</xs> <xa>type</xa>=<xs>'xhtml'</xs><xt>></xt> + <xt><div</xt> <xa>xmlns</xa>=<xs>"http://www.w3.org/1999/xhtml"</xs><xt>></xt><xt><p></xt><xt><i></xt>[Update: Juneau supports ATOM.]<xt></i></xt><xt></p></xt><xt></div></xt> + <xt></atom:content></xt> + <xt><atom:published></xt>2016-01-02T03:04:05Z<xt></atom:published></xt> + <xt></atom:entry></xt> + <xt></atom:feed></xt> + </p> + + <p> + The following is the same, except with XML namespaces enabled and the ATOM namespace as the default namespace: + </p> + + <h6 class='figure'>Example with namespaces with ATOM as the default namespace</h6> + <p class='bcode'> + <jc>// Create a serializer with readable output with namespaces.</jc> + XmlSerializer s = <jk>new</jk> XmlSerializerBuilder().sq().ws().defaultNamespaceUri(<js>"atom"</js>).build(); + + <jc>// Serialize to ATOM/XML</jc> + String atomXml = s.serialize(feed); + </p> + + <h6 class='figure'>Results</h6> + <p class='bcode'> + <xt><feed</xt> + <xa>xmlns</xa>=<xs>'http://www.w3.org/2005/Atom/'</xs> + <xa>xmlns:xml</xa>=<xs>'http://www.w3.org/XML/1998/namespace'</xs> + <xa>xmlns:xsi</xa>=<xs>'http://www.w3.org/2001/XMLSchema-instance'</xs><xt>></xt> + <xt><id></xt> + tag:juneau.apache.org + <xt></id></xt> + <xt><link</xt> <xa>href</xa>=<xs>'http://juneau.apache.org/'</xs> <xa>rel</xa>=<xs>'alternate'</xs> <xa>type</xa>=<xs>'text/html'</xs> <xa>hreflang</xa>=<xs>'en'</xs><xt>/></xt> + <xt><link</xt> <xa>href</xa>=<xs>'http://juneau.apache.org/feed.atom'</xs> <xa>rel</xa>=<xs>'self'</xs> <xa>type</xa>=<xs>'application/atom+xml'</xs><xt>/></xt> + <xt><title</xt> <xa>type</xa>=<xs>'text'</xs><xt>></xt> + Juneau ATOM specification + <xt></title></xt> + <xt><updated></xt>2016-01-02T03:04:05Z<xt></updated></xt> + <xt><generator</xt> <xa>uri</xa>=<xs>'http://juneau.apache.org/'</xs> <xa>version</xa>=<xs>'1.0'</xs><xt>></xt> + Juneau + <xt></generator></xt> + <xt><subtitle</xt> <xa>type</xa>=<xs>'html'</xs><xt>></xt> + Describes &lt;em&stuff&lt;/em&gt; about Juneau + <xt></subtitle></xt> + <xt><entry></xt> + <xt><author></xt> + <xt><name></xt>Jane Smith<xt></name></xt> + <xt><uri></xt>http://juneau.apache.org/<xt></uri></xt> + <xt><email></xt>[email protected]<xt></email></xt> + <xt></author></xt> + <xt><contributor></xt> + <xt><name></xt>John Smith<xt></name></xt> + <xt></contributor></xt> + <xt><id></xt> + tag:juneau.apache.org + <xt></id></xt> + <xt><link</xt> <xa>href</xa>=<xs>'http://juneau.apache.org/juneau.atom'</xs> <xa>rel</xa>=<xs>'alternate'</xs> <xa>type</xa>=<xs>'text/html'</xs><xt>/></xt> + <xt><link</xt> <xa>href</xa>=<xs>'http://juneau.apache.org/audio/juneau_podcast.mp3'</xs> <xa>rel</xa>=<xs>'enclosure'</xs> <xa>type</xa>=<xs>'audio/mpeg'</xs> <xa>length</xa>=<xs>'12345'</xs><xt>/></xt> + <xt><title></xt> + Juneau ATOM specification snapshot + <xt></title></xt> + <xt><updated></xt>2016-01-02T03:04:05Z<xt></updated></xt> + <xt><content</xt> <xa>xml:base</xa>=<xs>'http://www.apache.org/'</xs> <xa>xml:lang</xa>=<xs>'en'</xs> <xa>type</xa>=<xs>'xhtml'</xs><xt>></xt> + <xt><div</xt> <xa>xmlns</xa>=<xs>"http://www.w3.org/1999/xhtml"</xs><xt>></xt><xt><p></xt><xt><i></xt>[Update: Juneau supports ATOM.]<xt></i></xt><xt></p></xt><xt></div></xt> + <xt></content></xt> + <xt><published></xt>2016-01-02T03:04:05Z<xt></published></xt> + <xt></entry></xt> + <xt></feed></xt> + </p> + + + <!-- ======================================================================================================== --> + <a id="AtomJson"></a> + <h4 class='topic' onclick='toggle(this)'>1.1.1 - ATOM/JSON</h4> + <div class='topic'> + <p> + The {@link org.apache.juneau.json.JsonSerializer} class can also be used to produce ATOM in JSON format. + </p> + + <h6 class='figure'>ATOM/JSON example</h6> + <p class='bcode'> + <jc>// Get JSON serializer with readable output.</jc> + JsonSerializer s = JsonSerializer.<jsf>DEFAULT_LAX_READABLE</jsf>; + + <jc>// Serialize to ATOM/JSON</jc> + String atomJson = s.serialize(feed); + </p> + + <h6 class='figure'>Results</h6> + <p class='bcode'> + { + id: { + text: <js>'tag:juneau.apache.org'</js> + }, + links: [ + { + href: <js>'http://juneau.apache.org/'</js>, + rel: <js>'alternate'</js>, + type: <js>'text/html'</js>, + hreflang: <js>'en'</js> + }, + { + href: <js>'http://juneau.apache.org/juneau.atom'</js>, + rel: <js>'self'</js>, + type: <js>'application/atom+xml'</js> + } + ], + title: { + type: <js>'text'</js>, + text: <js>'Juneau ATOM specification'</js> + }, + updated: <js>'2016-01-02T03:04:05Z'</js>, + generator: { + uri: <js>'http://juneau.apache.org/'</js>, + version: <js>'1.0'</js>, + text: <js>'Juneau'</js> + }, + subtitle: { + type: <js>'html'</js>, + text: <js>'Describes <em>stuff</em> about Juneau'</js> + }, + entries: [ + { + authors: [ + { + name: <js>'James Bognar'</js>, + uri: <js>'http://juneau.apache.org/'</js>, + email: <js>'[email protected]'</js> + } + ], + contributors: [ + { + name: <js>'Barry M. Caceres'</js> + } + ], + id: { + text: <js>'tag:juneau.apache.org'</js> + }, + links: [ + { + href: <js>'http://juneau.apache.org/juneau.atom'</js>, + rel: <js>'alternate'</js>, + type: <js>'text/html'</js> + }, + { + href: <js>'http://juneau.apache.org/audio/juneau_podcast.mp3'</js>, + rel: <js>'enclosure'</js>, + type: <js>'audio/mpeg'</js>, + length: <jk>12345</jk> + } + ], + title: { + text: <js>'Juneau ATOM specification snapshot'</js> + }, + updated: <js>'2016-01-02T03:04:05Z'</js>, + content: { + base: <js>'http://www.apache.org/'</js>, + lang: <js>'en'</js>, + type: <js>'xhtml'</js>, + text: <js>'<div xmlns="http://www.w3.org/1999/xhtml"><p><i>[Update: Juneau supports ATOM.]</i></p></div>'</js> + }, + published: <js>'2016-01-02T03:04:05Z'</js> + } + ] + } + </p> + </div> + + + <!-- ======================================================================================================== --> + <a id="AtomRdfXml"></a> + <h4 class='topic' onclick='toggle(this)'>1.1.2 - ATOM/RDF/XML</h4> + <div class='topic'> + <p> + The {@link org.apache.juneau.jena.RdfSerializer} class and subclasses can also be used to produce ATOM + in various RDF formats. + </p> + + <h6 class='figure'>ATOM/RDF/XML example</h6> + <p class='bcode'> + <jc>// Get RDF/XML serializer with readable output.</jc> + RdfSerializer s = <jk>new</jk> RdfSerializerBuilder() + .xmlabbrev() + .ws() + .sq() + .property(RdfProperties.<jsf>RDF_rdfxml_tab</jsf>, 3) + .build(); + + <jc>// Serialize to ATOM/RDF/XML</jc> + String atomRdfXml = s.serialize(feed); + </p> + + <h6 class='figure'>Results</h6> + <p class='bcode'> + <xt><rdf:RDF</xt> + <xa>xmlns:rdf</xa>=<xs>'http://www.w3.org/1999/02/22-rdf-syntax-ns#'</xs> + <xa>xmlns:j</xa>=<xs>'http://www.apache.org/juneau/'</xs> + <xa>xmlns:jp</xa>=<xs>'http://www.apache.org/juneaubp/'</xs> + <xa>xmlns:atom</xa>=<xs>'http://www.w3.org/2005/Atom/'</xs> + <xa>xmlns:j.0</xa>=<xs>'http://www.w3.org/XML/1998/'</xs><xt>></xt> + <xt><rdf:Description></xt> + <xt><atom:id</xt> <xa>rdf:parseType</xa>=<xs>'Resource'</xs><xt>></xt> + <xt><atom:text></xt>tag:juneau.apache.org<xt></atom:text></xt> + <xt></atom:id></xt> + <xt><atom:links></xt> + <xt><rdf:Seq></xt> + <xt><rdf:li</xt> <xa>rdf:parseType</xa>=<xs>'Resource'</xs><xt>></xt> + <xt><atom:href></xt>http://juneau.apache.org/<xt></atom:href></xt> + <xt><atom:rel></xt>alternate<xt></atom:rel></xt> + <xt><atom:type></xt>text/html<xt></atom:type></xt> + <xt><atom:hreflang></xt>en<xt></atom:hreflang></xt> + <xt></rdf:li></xt> + <xt><rdf:li</xt> <xa>rdf:parseType</xa>=<xs>'Resource'</xs><xt>></xt> + <xt><atom:href></xt>http://juneau.apache.org/feed.atom<xt></atom:href></xt> + <xt><atom:rel></xt>self<xt></atom:rel></xt> + <xt><atom:type></xt>application/atom+xml<xt></atom:type></xt> + <xt></rdf:li></xt> + <xt></rdf:Seq></xt> + <xt></atom:links></xt> + <xt><atom:title</xt> <xa>rdf:parseType</xa>=<xs>'Resource'</xs><xt>></xt> + <xt><atom:type></xt>text<xt></atom:type></xt> + <xt><atom:text></xt>Juneau ATOM specification<xt></atom:text></xt> + <xt></atom:title></xt> + <xt><atom:updated></xt>2016-01-02T03:04:05Z<xt></atom:updated></xt> + <xt><atom:generator</xt> <xa>rdf:parseType</xa>=<xs>'Resource'</xs><xt>></xt> + <xt><atom:uri</xt> <xa>rdf:resource</xa>=<xs>'http://juneau.apache.org/'</xs><xt>/></xt> + <xt><atom:version></xt>1.0<xt></atom:version></xt> + <xt><atom:text></xt>Juneau<xt></atom:text></xt> + <xt></atom:generator></xt> + <xt><atom:subtitle</xt> <xa>rdf:parseType</xa>=<xs>'Resource'</xs><xt>></xt> + <xt><atom:type></xt>html<xt></atom:type></xt> + <xt><atom:text></xt>A &lt;em&gt;lot&lt;/em&gt; of effort went into making this effortless<xt></atom:text></xt> + <xt></atom:subtitle></xt> + <xt><atom:entries></xt> + <xt><rdf:Seq></xt> + <xt><rdf:li</xt> <xa>rdf:parseType</xa>=<xs>'Resource'</xs><xt>></xt> + <xt><atom:authors></xt> + <xt><rdf:Seq></xt> + <xt><rdf:li</xt> <xa>rdf:parseType</xa>=<xs>'Resource'</xs><xt>></xt> + <xt><atom:name></xt>James Bognar<xt></atom:name></xt> + <xt><atom:uri</xt> <xa>rdf:resource</xa>=<xs>'http://juneau.apache.org/'</xs><xt>/></xt> + <xt><atom:email></xt>[email protected]<xt></atom:email></xt> + <xt></rdf:li></xt> + <xt></rdf:Seq></xt> + <xt></atom:authors></xt> + <xt><atom:contributors></xt> + <xt><rdf:Seq></xt> + <xt><rdf:li</xt> <xa>rdf:parseType</xa>=<xs>'Resource'</xs><xt>></xt> + <xt><atom:name></xt>Barry M. Caceres<xt></atom:name></xt> + <xt></rdf:li></xt> + <xt></rdf:Seq></xt> + <xt></atom:contributors></xt> + <xt><atom:id</xt> <xa>rdf:parseType</xa>=<xs>'Resource'</xs><xt>></xt> + <xt><atom:text></xt>tag:juneau.apache.org<xt></atom:text></xt> + <xt></atom:id></xt> + <xt><atom:links></xt> + <xt><rdf:Seq></xt> + <xt><rdf:li</xt> <xa>rdf:parseType</xa>=<xs>'Resource'</xs><xt>></xt> + <xt><atom:href></xt>http://juneau.apache.org/juneau.atom<xt></atom:href></xt> + <xt><atom:rel></xt>alternate<xt></atom:rel></xt> + <xt><atom:type></xt>text/html<xt></atom:type></xt> + <xt></rdf:li></xt> + <xt><rdf:li</xt> <xa>rdf:parseType</xa>=<xs>'Resource'</xs><xt>></xt> + <xt><atom:href></xt>http://juneau.apache.org/audio/juneau_podcast.mp3<xt></atom:href></xt> + <xt><atom:rel></xt>enclosure<xt></atom:rel></xt> + <xt><atom:type></xt>audio/mpeg<xt></atom:type></xt> + <xt><atom:length></xt>12345<xt></atom:length></xt> + <xt></rdf:li></xt> + <xt></rdf:Seq></xt> + <xt></atom:links></xt> + <xt><atom:title</xt> <xa>rdf:parseType</xa>=<xs>'Resource'</xs><xt>></xt> + <xt><atom:text></xt>Juneau ATOM specification snapshot<xt></atom:text></xt> + <xt></atom:title></xt> + <xt><atom:updated></xt>2016-01-02T03:04:05Z<xt></atom:updated></xt> + <xt><atom:content</xt> <xa>rdf:parseType</xa>=<xs>'Resource'</xs><xt>></xt> + <xt><j.0:namespacebase</xt> <xa>rdf:resource</xa>=<xs>'http://www.apache.org/'</xs><xt>/></xt> + <xt><j.0:namespacelang></xt>en<xt></j.0:namespacelang></xt> + <xt><atom:type></xt>xhtml<xt></atom:type></xt> + <xt><atom:text></xt>&lt;div xmlns="http://www.w3.org/1999/xhtml"&gt;&lt;p&gt;&lt;i&gt;[Update: Juneau supports ATOM.]&lt;/i&gt;&lt;/p&gt;&lt;/div&gt;<xt></atom:text></xt> + <xt></atom:content></xt> + <xt><atom:published></xt>2016-01-02T03:04:05Z<xt></atom:published></xt> + <xt></rdf:li></xt> + <xt></rdf:Seq></xt> + <xt></atom:entries></xt> + <xt></rdf:Description></xt> + <xt></rdf:RDF></xt> + </p> + </div> + + + <!-- ======================================================================================================== --> + <a id="AtomHtml"></a> + <h4 class='topic' onclick='toggle(this)'>1.1.3 - ATOM/HTML</h4> + <div class='topic'> + <p> + The {@link org.apache.juneau.html.HtmlSerializer} class can be used to produce ATOM in HTML format. + </p> + <p> + The following is the output produced by the <code>AtomFeedResource</code> in the <code>org.apache.juneau.sample.war</code> project: + </p> + + <h6 class='figure'>Example ATOM/HTML results</h6> + <img class='bordered' src='doc-files/Example_HTML.png'> + </div> + </div> + + + <!-- ======================================================================================================== --> + <a id="Parse"></a> + <h3 class='topic' onclick='toggle(this)'>1.2 - Parsing ATOM feeds</h3> + <div class='topic'> + <p> + Use the {@link org.apache.juneau.xml.XmlParser} to convert ATOM/XML feeds back into their original POJOs: + </p> + <p class='bcode'> + <jc>// Create a serializer with readable output with namespaces</jc> + XmlSerializer s = XmlSerializer.<jsf>DEFAULT_SQ_READABLE</jsf>; + + <jc>// Serialize to ATOM/XML</jc> + String atomXml = s.serialize(feed); + + <jc>// Get an XML parser to convert it back into a POJO</jc> + XmlParser p = XmlParser.<jsf>DEFAULT</jsf>; + + <jc>// Convert the XML back into a POJO</jc> + Feed feed2 = p.parse(atomXml, Feed.<jk>class</jk>); + </p> + <p> + ATOM Feed objects can also be constructed from the other media types using the appropriate parsers. + </p> + </div> + +</div> +<p align="center"><i><b>*** fÃn ***</b></i></p> + +</body> +</html> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/75b0d8ee/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/cognos/Column.java ---------------------------------------------------------------------- diff --git a/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/cognos/Column.java b/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/cognos/Column.java new file mode 100644 index 0000000..a86ba4d --- /dev/null +++ b/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/cognos/Column.java @@ -0,0 +1,161 @@ +// *************************************************************************************************************************** +// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file * +// * distributed with this work for additional information regarding copyright ownership. The ASF licenses this file * +// * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance * +// * with the License. You may obtain a copy of the License at * +// * * +// * http://www.apache.org/licenses/LICENSE-2.0 * +// * * +// * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an * +// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * +// * specific language governing permissions and limitations under the License. * +// *************************************************************************************************************************** +package org.apache.juneau.dto.cognos; + +import org.apache.juneau.annotation.*; +import org.apache.juneau.transform.*; +import org.apache.juneau.xml.annotation.*; + +/** + * Represents a meta-data column in a Cognos dataset. + * + * <p> + * When serialized to XML, creates the following construct: + * <p class='bcode'> + * <xt><item</xt> <xa>name</xa>=<xs>'name'</xs> <xa>type</xa>=<xs>'xs:String'</xs> <xa>length</xa>=<xs>'255'</xs>/> + * </p> + */ +@SuppressWarnings({"rawtypes","hiding"}) +@Bean(typeName="item", properties="name,type,length") +public class Column { + + private String name, type; + private Integer length; + PojoSwap pojoSwap; + + /** Bean constructor. */ + public Column() {} + + /** + * Constructor. + * + * @param name The column name. + * @param type The column type (e.g. <js>"xs:String"</js>). + */ + public Column(String name, String type) { + this(name, type, null); + } + + /** + * Constructor. + * + * @param name The column name. + * @param type The column type (e.g. <js>"xs:String"</js>). + * @param length The column length (e.g. <code>255</code>). + */ + public Column(String name, String type, Integer length) { + this.name = name; + this.type = type; + this.length = length; + } + + /** + * Associates a POJO swap with this column. + * + * <p> + * Typically used to define columns that don't exist on the underlying beans being serialized. + * + * <p> + * For example, the <code>AddressBookResource</code> sample defined the following POJO swap to define an additional + * <js>"numAddresses"</js> column even though no such property exists on the serialized beans. + * <p class='bcode'> + * Column c = <jk>new</jk> Column(<js>"numAddresses"</js>, <js>"xs:int"</js>) + * .addPojoSwaps( + * <jk>new</jk> PojoSwap<Person,Integer>() { + * <ja>@Override</ja> + * <jk>public</jk> Integer swap(Person p) { + * <jk>return</jk> p.<jf>addresses</jf>.size(); + * } + * } + * ); + * </p> + * + * @param pojoSwap The POJO swap to associate with the column. + * @return This object (for method chaining). + */ + public Column addPojoSwap(PojoSwap pojoSwap) { + this.pojoSwap = pojoSwap; + return this; + } + + + //-------------------------------------------------------------------------------- + // Bean properties + //-------------------------------------------------------------------------------- + + /** + * Bean property getter: <property>name</property>. + * + * @return The value of the <property>name</property> property on this bean, or <jk>null</jk> if it is not set. + */ + @Xml(format=XmlFormat.ATTR) + public String getName() { + return name; + } + + /** + * Bean property setter: <property>name</property>. + * + * @param name The new value for the <property>name</property> property on this bean. + * @return This object (for method chaining). + */ + public Column setName(String name) { + this.name = name; + return this; + } + + /** + * Bean property getter: <property>type</property>. + * + * @return The value of the <property>type</property> property on this bean, or <jk>null</jk> if it is not set. + */ + @Xml(format=XmlFormat.ATTR) + public String getType() { + return type; + } + + /** + * Bean property setter: <property>type</property>. + * + * @param type The new value for the <property>type</property> property on this bean. + * @return This object (for method chaining). + */ + public Column setType(String type) { + this.type = type; + return this; + } + + /** + * Bean property getter: <property>length</property>. + * + * @return The value of the <property>length</property> property on this bean, or <jk>null</jk> if length is not + * applicable for the specified type. + */ + @Xml(format=XmlFormat.ATTR) + public Integer getLength() { + return length; + } + + /** + * Bean property setter: <property>length</property>. + * + * @param length The new value for the <property>length</property> property on this bean. + * Can be <jk>null</jk> if length is not applicable for the specified type. + * @return This object (for method chaining). + */ + public Column setLength(Integer length) { + this.length = length; + return this; + } +} +
