http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/e6bf97a8/juneau-core/src/main/java/org/apache/juneau/dto/atom/Category.java ---------------------------------------------------------------------- diff --git a/juneau-core/src/main/java/org/apache/juneau/dto/atom/Category.java b/juneau-core/src/main/java/org/apache/juneau/dto/atom/Category.java new file mode 100644 index 0000000..2dce6c6 --- /dev/null +++ b/juneau-core/src/main/java/org/apache/juneau/dto/atom/Category.java @@ -0,0 +1,141 @@ +/*************************************************************************************************************************** + * 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 java.net.*; + +import org.apache.juneau.xml.annotation.*; + +/** + * Represents an <code>atomCategory</code> construct in the RFC4287 specification. + * <p> + * <h6 class='figure'>Schema</h6> + * <p class='bcode'> + * atomCategory = + * element atom:category { + * atomCommonAttributes, + * attribute term { text }, + * attribute scheme { atomUri }?, + * attribute label { text }?, + * undefinedContent + * } + * </p> + * <p> + * Refer to {@link org.apache.juneau.dto.atom} for further information about ATOM support. + * </p> + * + * @author James Bognar ([email protected]) + */ +@Xml(name="category") +public class Category extends Common { + + private String term; + private URI scheme; + private String label; + + /** + * Normal constructor. + * @param term The category term. + */ + public Category(String term) { + this.term = term; + } + + /** Bean constructor. */ + public Category() {} + + + //-------------------------------------------------------------------------------- + // Bean properties + //-------------------------------------------------------------------------------- + + /** + * @return The category term. + */ + @Xml(format=ATTR) + public String getTerm() { + return term; + } + + /** + * Sets the category term. + * + * @param term The category term. + * @return This object (for method chaining). + */ + public Category setTerm(String term) { + this.term = term; + return this; + } + + /** + * Returns the category scheme. + * + * @return The category scheme. + */ + @Xml(format=ATTR) + public URI getScheme() { + return scheme; + } + + /** + * Sets the category scheme. + * + * @param scheme The category scheme. + * @return This object (for method chaining). + */ + public Category setScheme(URI scheme) { + this.scheme = scheme; + return this; + } + + /** + * Returns the category label. + * + * @return The category label. + */ + @Xml(format=ATTR) + public String getLabel() { + return label; + } + + /** + * Sets the category label. + * + * @param label The category label. + * @return This object (for method chaining). + */ + public Category setLabel(String label) { + this.label = label; + return this; + } + + + //-------------------------------------------------------------------------------- + // Overridden setters (to simplify method chaining) + //-------------------------------------------------------------------------------- + + @Override /* Common */ + public Category setBase(URI base) { + super.setBase(base); + return this; + } + + @Override /* Common */ + public Category setLang(String lang) { + super.setLang(lang); + return this; + } +}
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/e6bf97a8/juneau-core/src/main/java/org/apache/juneau/dto/atom/Common.java ---------------------------------------------------------------------- diff --git a/juneau-core/src/main/java/org/apache/juneau/dto/atom/Common.java b/juneau-core/src/main/java/org/apache/juneau/dto/atom/Common.java new file mode 100644 index 0000000..05118e4 --- /dev/null +++ b/juneau-core/src/main/java/org/apache/juneau/dto/atom/Common.java @@ -0,0 +1,88 @@ +/*************************************************************************************************************************** + * 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 java.net.*; + +import org.apache.juneau.xml.annotation.*; + +/** + * Represents an <code>atomCommonAttributes</code> construct in the RFC4287 specification. + * <p> + * <h6 class='figure'>Schema</h6> + * <p class='bcode'> + * atomCommonAttributes = + * attribute xml:base { atomUri }?, + * attribute xml:lang { atomLanguageTag }?, + * undefinedAttribute* + * </p> + * <p> + * Refer to {@link org.apache.juneau.dto.atom} for further information about ATOM support. + * </p> + * + * @author James Bognar ([email protected]) + */ +public abstract class Common { + + private URI base; + private String lang; + + + //-------------------------------------------------------------------------------- + // Bean properties + //-------------------------------------------------------------------------------- + + /** + * Returns the uri base of this object. + * + * @return The URI base of this object. + */ + @Xml(prefix="xml", format=ATTR) + public URI getBase() { + return base; + } + + /** + * Sets the URI base of this object. + * + * @param base The URI base of this object. + * @return This object (for method chaining). + */ + public Common setBase(URI base) { + this.base = base; + return this; + } + + /** + * Returns the language of this object. + * + * @return The language of this object. + */ + @Xml(prefix="xml", format=ATTR) + public String getLang() { + return lang; + } + + /** + * Sets the language of this object. + * + * @param lang The language of this object. + * @return This object (for method chaining). + */ + public Common setLang(String lang) { + this.lang = lang; + return this; + } +} http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/e6bf97a8/juneau-core/src/main/java/org/apache/juneau/dto/atom/CommonEntry.java ---------------------------------------------------------------------- diff --git a/juneau-core/src/main/java/org/apache/juneau/dto/atom/CommonEntry.java b/juneau-core/src/main/java/org/apache/juneau/dto/atom/CommonEntry.java new file mode 100644 index 0000000..ea60789 --- /dev/null +++ b/juneau-core/src/main/java/org/apache/juneau/dto/atom/CommonEntry.java @@ -0,0 +1,280 @@ +/*************************************************************************************************************************** + * 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 java.util.*; + +import org.apache.juneau.annotation.*; +import org.apache.juneau.transforms.*; +import org.apache.juneau.xml.annotation.*; + +/** + * Parent class of {@link Entry}, {@link Feed}, and {@link Source} + * <p> + * Refer to {@link org.apache.juneau.dto.atom} for further information about ATOM support. + * </p> + * + * @author James Bognar ([email protected]) + */ +@SuppressWarnings("hiding") +public class CommonEntry extends Common { + + private List<Person> authors; + private List<Category> categories; + private List<Person> contributors; + private Id id; + private List<Link> links; + private Text rights; + private Text title; + private Calendar updated; + + + /** + * Normal constructor. + * @param id The ID of this object. + * @param title The title of this object. + * @param updated The updated timestamp of this object. + */ + public CommonEntry(Id id, Text title, Calendar updated) { + this.id = id; + this.title = title; + this.updated = updated; + } + + /** Bean constructor. */ + public CommonEntry() {} + + + //-------------------------------------------------------------------------------- + // Bean properties + //-------------------------------------------------------------------------------- + + /** + * Returns the list of authors for this object. + * + * @return The list of authors for this object. + */ + @Xml(format=COLLAPSED, childName="author") + public List<Person> getAuthors() { + return authors; + } + + /** + * Sets the list of authors for this object. + * + * @param authors The list of authors for this object. + * @return This object (for method chaining). + */ + public CommonEntry setAuthors(List<Person> authors) { + this.authors = authors; + return this; + } + + /** + * Adds one or more authors to the list of authors of this object. + * + * @param authors The author to add to the list. + * @return This object (for method chaining). + */ + public CommonEntry addAuthors(Person...authors) { + if (this.authors == null) + this.authors = new LinkedList<Person>(); + this.authors.addAll(Arrays.asList(authors)); + return this; + } + + /** + * Returns the list of categories of this object. + * + * @return The list of categories of this object. + */ + @Xml(format=COLLAPSED, childName="category") + public List<Category> getCatetories() { + return categories; + } + + /** + * Sets the list of categories of this object. + * + * @param categories The list of categories of this object. + * @return This object (for method chaining). + */ + public CommonEntry setCategories(List<Category> categories) { + this.categories = categories; + return this; + } + + /** + * Adds one or more categories to the list of categories of this object. + * + * @param categories The categories to add to the list. + * @return This object (for method chaining). + */ + public CommonEntry addCategories(Category...categories) { + if (this.categories == null) + this.categories = new LinkedList<Category>(); + this.categories.addAll(Arrays.asList(categories)); + return this; + } + + /** + * Returns the list of contributors of this object. + * + * @return The list of contributors of this object. + */ + @Xml(format=COLLAPSED, childName="contributor") + public List<Person> getContributors() { + return contributors; + } + + /** + * Sets the list of contributors of this object. + * + * @param contributors The list of contributors of this object. + * @return This object (for method chaining). + */ + public CommonEntry setContributors(List<Person> contributors) { + this.contributors = contributors; + return this; + } + + /** + * Adds one or more contributors to the list of contributors of this object. + * + * @param contributors The contributor to add to the list. + * @return This object (for method chaining). + */ + public CommonEntry addContributors(Person...contributors) { + if (this.contributors == null) + this.contributors = new LinkedList<Person>(); + this.contributors.addAll(Arrays.asList(contributors)); + return this; + } + + /** + * Returns the ID of this object. + * + * @return The ID of this object. + */ + public Id getId() { + return id; + } + + /** + * Sets the ID of this object. + * + * @param id The ID of this object. + * @return This object (for method chaining). + */ + public CommonEntry setId(Id id) { + this.id = id; + return this; + } + + /** + * Returns the list of links of this object. + * + * @return The list of links of this object. + */ + @Xml(format=COLLAPSED) + public List<Link> getLinks() { + return links; + } + + /** + * Sets the list of links of this object. + * + * @param links The list of links of this object. + * @return This object (for method chaining). + */ + public CommonEntry setLinks(List<Link> links) { + this.links = links; + return this; + } + + /** + * Adds one or more links to the list of links of this object. + * + * @param links The links to add to the list. + * @return This object (for method chaining). + */ + public CommonEntry addLinks(Link...links) { + if (this.links == null) + this.links = new LinkedList<Link>(); + this.links.addAll(Arrays.asList(links)); + return this; + } + + /** + * Returns the rights statement of this object. + * + * @return The rights statement of this object. + */ + public Text getRights() { + return rights; + } + + /** + * Sets the rights statement of this object. + * + * @param rights The rights statement of this object. + * @return This object (for method chaining). + */ + public CommonEntry setRights(Text rights) { + this.rights = rights; + return this; + } + + /** + * Returns the title of this object. + * + * @return The title of this object. + */ + public Text getTitle() { + return title; + } + + /** + * Sets the title of this object. + * + * @param title The title of this object. + * @return This object (for method chaining). + */ + public CommonEntry setTitle(Text title) { + this.title = title; + return this; + } + + /** + * Returns the update timestamp of this object. + * + * @return The update timestamp of this object. + */ + @BeanProperty(transform=CalendarTransform.ISO8601DT.class) + public Calendar getUpdated() { + return updated; + } + + /** + * Sets the update timestamp of this object. + * + * @param updated The update timestamp of this object. + * @return This object (for method chaining). + */ + public CommonEntry setUpdated(Calendar updated) { + this.updated = updated; + return this; + } +} http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/e6bf97a8/juneau-core/src/main/java/org/apache/juneau/dto/atom/Content.java ---------------------------------------------------------------------- diff --git a/juneau-core/src/main/java/org/apache/juneau/dto/atom/Content.java b/juneau-core/src/main/java/org/apache/juneau/dto/atom/Content.java new file mode 100644 index 0000000..f290564 --- /dev/null +++ b/juneau-core/src/main/java/org/apache/juneau/dto/atom/Content.java @@ -0,0 +1,148 @@ +/*************************************************************************************************************************** + * 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 java.net.*; + +import org.apache.juneau.xml.annotation.*; + +/** + * Represents an <code>atomContent</code> construct in the RFC4287 specification. + * <p> + * + * <h6 class='figure'>Schema</h6> + * <p class='bcode'> + * atomContent = atomInlineTextContent + * | atomInlineXHTMLContent + * | atomInlineOtherContent + * | atomOutOfLineContent + * + * atomInlineTextContent = + * element atom:content { + * atomCommonAttributes, + * attribute type { "text" | "html" }?, + * (text)* + * } + * + * atomInlineXHTMLContent = + * element atom:content { + * atomCommonAttributes, + * attribute type { "xhtml" }, + * xhtmlDiv + * } + * + * atomInlineOtherContent = + * element atom:content { + * atomCommonAttributes, + * attribute type { atomMediaType }?, + * (text|anyElement)* + * } + * + * atomOutOfLineContent = + * element atom:content { + * atomCommonAttributes, + * attribute type { atomMediaType }?, + * attribute src { atomUri }, + * empty + * } + * </p> + * <p> + * Refer to {@link org.apache.juneau.dto.atom} for further information about ATOM support. + * </p> + * + * @author James Bognar ([email protected]) + */ +public class Content extends Text { + + private URI src; + + + /** + * Normal content. + * + * @param type The content type of this content. + * @param content The content of this content. + */ + public Content(String type, String content) { + super(type, content); + } + + /** + * Normal content. + * + * @param content The content of this content. + */ + public Content(String content) { + super(content); + } + + /** Bean constructor. */ + public Content() {} + + + //-------------------------------------------------------------------------------- + // Bean properties + //-------------------------------------------------------------------------------- + + /** + * Returns the source URI. + * + * @return the source URI. + */ + @Xml(format=ATTR) + public URI getSrc() { + return src; + } + + /** + * Sets the source URI. + * + * @param src The source URI. + * @return This object (for method chaining). + */ + public Content setSrc(URI src) { + this.src = src; + return this; + } + + + //-------------------------------------------------------------------------------- + // Overridden setters (to simplify method chaining) + //-------------------------------------------------------------------------------- + + @Override /* Text */ + public Content setText(String text) { + super.setText(text); + return this; + } + + @Override /* Text */ + public Content setType(String type) { + super.setType(type); + return this; + } + + @Override /* Common */ + public Content setBase(URI base) { + super.setBase(base); + return this; + } + + @Override /* Common */ + public Content setLang(String lang) { + super.setLang(lang); + return this; + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/e6bf97a8/juneau-core/src/main/java/org/apache/juneau/dto/atom/Entry.java ---------------------------------------------------------------------- diff --git a/juneau-core/src/main/java/org/apache/juneau/dto/atom/Entry.java b/juneau-core/src/main/java/org/apache/juneau/dto/atom/Entry.java new file mode 100644 index 0000000..9fc4111 --- /dev/null +++ b/juneau-core/src/main/java/org/apache/juneau/dto/atom/Entry.java @@ -0,0 +1,247 @@ +/*************************************************************************************************************************** + * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + ***************************************************************************************************************************/ +package org.apache.juneau.dto.atom; + +import java.net.URI; +import java.util.*; + +import org.apache.juneau.annotation.*; +import org.apache.juneau.transforms.*; +import org.apache.juneau.xml.annotation.*; + +/** + * Represents an <code>atomEntry</code> construct in the RFC4287 specification. + * <p> + * <h6 class='figure'>Schema</h6> + * <p class='bcode'> + * atomEntry = + * element atom:entry { + * atomCommonAttributes, + * (atomAuthor* + * & atomCategory* + * & atomContent? + * & atomContributor* + * & atomId + * & atomLink* + * & atomPublished? + * & atomRights? + * & atomSource? + * & atomSummary? + * & atomTitle + * & atomUpdated + * & extensionElement*) + * } + * </p> + * <p> + * Refer to {@link org.apache.juneau.dto.atom} for further information about ATOM support. + * </p> + * + * @author James Bognar ([email protected]) + */ +@Xml(name="entry") +public class Entry extends CommonEntry { + + private Content content; + private Calendar published; + private Source source; + private Text summary; + + /** + * Normal constructor. + * + * @param id The ID of this entry. + * @param title The title of this entry. + * @param updated The updated timestamp of this entry. + */ + public Entry(Id id, Text title, Calendar updated) { + super(id, title, updated); + } + + /** Bean constructor. */ + public Entry() {} + + + //-------------------------------------------------------------------------------- + // Bean properties + //-------------------------------------------------------------------------------- + + /** + * Returns the content of this entry. + * + * @return The content of this entry. + */ + public Content getContent() { + return content; + } + + /** + * Sets the content of this entry. + * + * @param content The content of this entry. + * @return This object (for method chaining). + */ + public Entry setContent(Content content) { + this.content = content; + return this; + } + + /** + * Returns the publish timestamp of this entry. + * + * @return The publish timestamp of this entry. + */ + @BeanProperty(transform=CalendarTransform.ISO8601DT.class) + public Calendar getPublished() { + return published; + } + + /** + * Sets the publish timestamp of this entry. + * + * @param published The publish timestamp of this entry. + * @return This object (for method chaining). + */ + public Entry setPublished(Calendar published) { + this.published = published; + return this; + } + + /** + * Returns the source of this entry. + * + * @return The source of this entry. + */ + public Source getSource() { + return source; + } + + /** + * Sets the source of this entry. + * + * @param source The source of this entry. + * @return This object (for method chaining). + */ + public Entry setSource(Source source) { + this.source = source; + return this; + } + + /** + * Returns the summary of this entry. + * + * @return The summary of this entry. + */ + public Text getSummary() { + return summary; + } + + /** + * Sets the summary of this entry. + * + * @param summary The summary of this entry. + * @return This object (for method chaining). + */ + public Entry setSummary(Text summary) { + this.summary = summary; + return this; + } + + + //-------------------------------------------------------------------------------- + // Overridden setters (to simplify method chaining) + //-------------------------------------------------------------------------------- + + @Override /* CommonEntry */ + public Entry setAuthors(List<Person> authors) { + super.setAuthors(authors); + return this; + } + + @Override /* CommonEntry */ + public Entry addAuthors(Person...authors) { + super.addAuthors(authors); + return this; + } + + @Override /* CommonEntry */ + public Entry setCategories(List<Category> categories) { + super.setCategories(categories); + return this; + } + + @Override /* CommonEntry */ + public Entry addCategories(Category...categories) { + super.addCategories(categories); + return this; + } + + @Override /* CommonEntry */ + public Entry setContributors(List<Person> contributors) { + super.setContributors(contributors); + return this; + } + + @Override /* CommonEntry */ + public Entry addContributors(Person...contributors) { + super.addContributors(contributors); + return this; + } + + @Override /* CommonEntry */ + public Entry setId(Id id) { + super.setId(id); + return this; + } + + @Override /* CommonEntry */ + public Entry setLinks(List<Link> links) { + super.setLinks(links); + return this; + } + + @Override /* CommonEntry */ + public Entry addLinks(Link...links) { + super.addLinks(links); + return this; + } + + @Override /* CommonEntry */ + public Entry setRights(Text rights) { + super.setRights(rights); + return this; + } + + @Override /* CommonEntry */ + public Entry setTitle(Text title) { + super.setTitle(title); + return this; + } + + @Override /* CommonEntry */ + public Entry setUpdated(Calendar updated) { + super.setUpdated(updated); + return this; + } + + @Override /* Common */ + public Entry setBase(URI base) { + super.setBase(base); + return this; + } + + @Override /* Common */ + public Entry setLang(String lang) { + super.setLang(lang); + return this; + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/e6bf97a8/juneau-core/src/main/java/org/apache/juneau/dto/atom/Feed.java ---------------------------------------------------------------------- diff --git a/juneau-core/src/main/java/org/apache/juneau/dto/atom/Feed.java b/juneau-core/src/main/java/org/apache/juneau/dto/atom/Feed.java new file mode 100644 index 0000000..4d458c9 --- /dev/null +++ b/juneau-core/src/main/java/org/apache/juneau/dto/atom/Feed.java @@ -0,0 +1,288 @@ +/*************************************************************************************************************************** + * 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 java.net.URI; +import java.util.*; + +import org.apache.juneau.annotation.*; +import org.apache.juneau.xml.annotation.*; + +/** + * Top-level ATOM feed object. + * <p> + * Represents an <code>atomFeed</code> construct in the RFC4287 specification. + * <p> + * <h6 class='figure'>Schema</h6> + * <p class='bcode'> + * atomFeed = + * element atom:feed { + * atomCommonAttributes, + * (atomAuthor* + * & atomCategory* + * & atomContributor* + * & atomGenerator? + * & atomIcon? + * & atomId + * & atomLink* + * & atomLogo? + * & atomRights? + * & atomSubtitle? + * & atomTitle + * & atomUpdated + * & extensionElement*), + * atomEntry* + * } + * </p> + * <p> + * Refer to {@link org.apache.juneau.dto.atom} for further information about ATOM support. + * </p> + * + * @author James Bognar ([email protected]) + */ +@Xml(name="feed") +@SuppressWarnings("hiding") +public class Feed extends CommonEntry { + + private Generator generator; // atomGenerator? + private Icon icon; // atomIcon? + private Logo logo; // atomLogo? + private Text subtitle; // atomSubtitle? + private List<Entry> entries; // atomEntry* + + /** + * Normal constructor. + * + * @param id The feed identifier. + * @param title The feed title. + * @param updated The feed updated timestamp. + */ + public Feed(Id id, Text title, Calendar updated) { + super(id, title, updated); + } + + /** Bean constructor. */ + public Feed() {} + + + //-------------------------------------------------------------------------------- + // Bean properties + //-------------------------------------------------------------------------------- + + /** + * Returns generator information on this feed. + * + * @return The generator information on this feed. + */ + public Generator getGenerator() { + return generator; + } + + /** + * Sets the generator information on this feed. + * + * @param generator The generator information on this feed. + * @return This object (for method chaining). + */ + public Feed setGenerator(Generator generator) { + this.generator = generator; + return this; + } + + /** + * Returns the feed icon. + * + * @return The feed icon. + */ + public Icon getIcon() { + return icon; + } + + /** + * Sets the feed icon. + * + * @param icon The feed icon. + * @return This object (for method chaining). + */ + public Feed setIcon(Icon icon) { + this.icon = icon; + return this; + } + + /** + * Returns the feed logo. + * + * @return The feed logo. + */ + public Logo getLogo() { + return logo; + } + + /** + * Sets the feed logo. + * + * @param logo The feed logo. + * @return This object (for method chaining). + */ + public Feed setLogo(Logo logo) { + this.logo = logo; + return this; + } + + /** + * Returns the feed subtitle. + * + * @return The feed subtitle. + */ + @BeanProperty(name="subtitle") + public Text getSubTitle() { + return subtitle; + } + + /** + * Sets the feed subtitle. + * + * @param subtitle The feed subtitle. + * @return This object (for method chaining). + */ + @BeanProperty(name="subtitle") + public Feed setSubTitle(Text subtitle) { + this.subtitle = subtitle; + return this; + } + + /** + * Returns the entries in the feed. + * + * @return The entries in the feed. + */ + @Xml(format=COLLAPSED) + public List<Entry> getEntries() { + return entries; + } + + /** + * Sets the entries in the feed. + * + * @param entries The entries in the feed. + * @return This object (for method chaining). + */ + public Feed setEntries(List<Entry> entries) { + this.entries = entries; + return this; + } + + /** + * Adds an entry to the list of entries in the feed. + * + * @param entries The entries to add to the list of entries in the feed.s + * @return This object (for method chaining). + */ + public Feed addEntries(Entry...entries) { + if (this.entries == null) + this.entries = new LinkedList<Entry>(); + this.entries.addAll(Arrays.asList(entries)); + return this; + } + + + //-------------------------------------------------------------------------------- + // Overridden setters (to simplify method chaining) + //-------------------------------------------------------------------------------- + + @Override /* CommonEntry */ + public Feed setAuthors(List<Person> authors) { + super.setAuthors(authors); + return this; + } + + @Override /* CommonEntry */ + public Feed addAuthors(Person...authors) { + super.addAuthors(authors); + return this; + } + + @Override /* CommonEntry */ + public Feed setCategories(List<Category> categories) { + super.setCategories(categories); + return this; + } + + @Override /* CommonEntry */ + public Feed addCategories(Category...categories) { + super.addCategories(categories); + return this; + } + + @Override /* CommonEntry */ + public Feed setContributors(List<Person> contributors) { + super.setContributors(contributors); + return this; + } + + @Override /* CommonEntry */ + public Feed addContributors(Person...contributors) { + super.addContributors(contributors); + return this; + } + + @Override /* CommonEntry */ + public Feed setId(Id id) { + super.setId(id); + return this; + } + + @Override /* CommonEntry */ + public Feed setLinks(List<Link> links) { + super.setLinks(links); + return this; + } + + @Override /* CommonEntry */ + public Feed addLinks(Link...links) { + super.addLinks(links); + return this; + } + + @Override /* CommonEntry */ + public Feed setRights(Text rights) { + super.setRights(rights); + return this; + } + + @Override /* CommonEntry */ + public Feed setTitle(Text title) { + super.setTitle(title); + return this; + } + + @Override /* CommonEntry */ + public Feed setUpdated(Calendar updated) { + super.setUpdated(updated); + return this; + } + + @Override /* Common */ + public Feed setBase(URI base) { + super.setBase(base); + return this; + } + + @Override /* Common */ + public Feed setLang(String lang) { + super.setLang(lang); + return this; + } +} http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/e6bf97a8/juneau-core/src/main/java/org/apache/juneau/dto/atom/Generator.java ---------------------------------------------------------------------- diff --git a/juneau-core/src/main/java/org/apache/juneau/dto/atom/Generator.java b/juneau-core/src/main/java/org/apache/juneau/dto/atom/Generator.java new file mode 100644 index 0000000..1f8788a --- /dev/null +++ b/juneau-core/src/main/java/org/apache/juneau/dto/atom/Generator.java @@ -0,0 +1,143 @@ +/*************************************************************************************************************************** + * 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 java.net.*; + +import org.apache.juneau.xml.annotation.*; + +/** + * Represents an <code>atomGenerator</code> construct in the RFC4287 specification. + * <p> + * <h6 class='figure'>Schema</h6> + * <p class='bcode'> + * atomGenerator = element atom:generator { + * atomCommonAttributes, + * attribute uri { atomUri }?, + * attribute version { text }?, + * text + * } + * </p> + * <p> + * Refer to {@link org.apache.juneau.dto.atom} for further information about ATOM support. + * </p> + * + * @author James Bognar ([email protected]) + */ +@Xml(name="generator") +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. + * + * @param uri The URI of this generator statement. + * @return This object (for method chaining). + */ + public Generator setUri(URI uri) { + this.uri = 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). + */ + public Generator setVersion(String version) { + this.version = version; + return this; + } + + /** + * Returns the content of this generator statement. + * + * @return The content of this generator statement. + */ + @Xml(format=CONTENT) + 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). + */ + public Generator setText(String text) { + this.text = text; + return this; + } + + + //-------------------------------------------------------------------------------- + // Overridden setters (to simplify method chaining) + //-------------------------------------------------------------------------------- + + @Override /* Common */ + public Generator setBase(URI base) { + super.setBase(base); + return this; + } + + @Override /* Common */ + public Generator setLang(String lang) { + super.setLang(lang); + return this; + } +} http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/e6bf97a8/juneau-core/src/main/java/org/apache/juneau/dto/atom/Icon.java ---------------------------------------------------------------------- diff --git a/juneau-core/src/main/java/org/apache/juneau/dto/atom/Icon.java b/juneau-core/src/main/java/org/apache/juneau/dto/atom/Icon.java new file mode 100644 index 0000000..de37033 --- /dev/null +++ b/juneau-core/src/main/java/org/apache/juneau/dto/atom/Icon.java @@ -0,0 +1,97 @@ +/*************************************************************************************************************************** + * 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 java.net.*; + +import org.apache.juneau.xml.annotation.*; + +/** + * Represents an <code>atomIcon</code> construct in the RFC4287 specification. + * <p> + * <h6 class='figure'>Schema</h6> + * <p class='bcode'> + * atomIcon = element atom:icon { + * atomCommonAttributes, + * (atomUri) + * } + * </p> + * <p> + * Refer to {@link org.apache.juneau.dto.atom} for further information about ATOM support. + * </p> + * + * @author James Bognar ([email protected]) + */ +@Xml(name="icon") +public class Icon extends Common { + + private URI uri; + + + /** + * Normal constructor. + * + * @param uri The URI of the icon. + */ + public Icon(URI uri) { + this.uri = uri; + } + + /** Bean constructor. */ + public Icon() {} + + + //-------------------------------------------------------------------------------- + // Bean properties + //-------------------------------------------------------------------------------- + + /** + * Returns the URI of this icon. + * + * @return The URI of this icon. + */ + @Xml(format=CONTENT) + public URI getUri() { + return uri; + } + + /** + * Sets the URI of this icon. + * + * @param uri The URI of this icon. + * @return This object (for method chaining). + */ + public Icon setUri(URI uri) { + this.uri = uri; + return this; + } + + + //-------------------------------------------------------------------------------- + // Overridden setters (to simplify method chaining) + //-------------------------------------------------------------------------------- + + @Override /* Common */ + public Icon setBase(URI base) { + super.setBase(base); + return this; + } + + @Override /* Common */ + public Icon setLang(String lang) { + super.setLang(lang); + return this; + } +} http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/e6bf97a8/juneau-core/src/main/java/org/apache/juneau/dto/atom/Id.java ---------------------------------------------------------------------- diff --git a/juneau-core/src/main/java/org/apache/juneau/dto/atom/Id.java b/juneau-core/src/main/java/org/apache/juneau/dto/atom/Id.java new file mode 100644 index 0000000..416487c --- /dev/null +++ b/juneau-core/src/main/java/org/apache/juneau/dto/atom/Id.java @@ -0,0 +1,96 @@ +/*************************************************************************************************************************** + * 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 java.net.*; + +import org.apache.juneau.xml.annotation.*; + +/** + * Represents an <code>atomId</code> construct in the RFC4287 specification. + * <p> + * <h6 class='figure'>Schema</h6> + * <p class='bcode'> + * atomId = element atom:id { + * atomCommonAttributes, + * (atomUri) + * } + * </p> + * <p> + * Refer to {@link org.apache.juneau.dto.atom} for further information about ATOM support. + * </p> + * + * @author James Bognar ([email protected]) + */ +@Xml(name="id") +public class Id extends Common { + + private String text; + + /** + * Normal constructor. + * + * @param text The id element contents. + */ + public Id(String text) { + this.text = text; + } + + /** Bean constructor. */ + public Id() {} + + + //-------------------------------------------------------------------------------- + // Bean properties + //-------------------------------------------------------------------------------- + + /** + * Returns the content of this identifier. + * + * @return The content of this identifier. + */ + @Xml(format=CONTENT) + public String getText() { + return text; + } + + /** + * Sets the content of this identifier. + * + * @param text The content of this identifier. + * @return This object (for method chaining). + */ + public Id setText(String text) { + this.text = text; + return this; + } + + + //-------------------------------------------------------------------------------- + // Overridden setters (to simplify method chaining) + //-------------------------------------------------------------------------------- + + @Override /* Common */ + public Id setBase(URI base) { + super.setBase(base); + return this; + } + + @Override /* Common */ + public Id setLang(String lang) { + super.setLang(lang); + return this; + } +} http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/e6bf97a8/juneau-core/src/main/java/org/apache/juneau/dto/atom/Link.java ---------------------------------------------------------------------- diff --git a/juneau-core/src/main/java/org/apache/juneau/dto/atom/Link.java b/juneau-core/src/main/java/org/apache/juneau/dto/atom/Link.java new file mode 100644 index 0000000..0bc711c --- /dev/null +++ b/juneau-core/src/main/java/org/apache/juneau/dto/atom/Link.java @@ -0,0 +1,226 @@ +/*************************************************************************************************************************** + * 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 java.net.*; + +import org.apache.juneau.xml.annotation.*; + +/** + * Represents an <code>atomLink</code> construct in the RFC4287 specification. + * <p> + * <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> + * <p> + * Refer to {@link org.apache.juneau.dto.atom} for further information about ATOM support. + * </p> + * + * @author James Bognar ([email protected]) + */ +@Xml(name="link") +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) { + this.rel = rel; + this.type = type; + this.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). + */ + public Link setHref(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 rell of this link. + * @return This object (for method chaining). + */ + public Link setRel(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). + */ + public Link setType(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). + */ + public Link setHreflang(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). + */ + public Link setTitle(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). + */ + public Link setLength(Integer length) { + this.length = length; + return this; + } + + + //-------------------------------------------------------------------------------- + // Overridden setters (to simplify method chaining) + //-------------------------------------------------------------------------------- + + @Override /* Common */ + public Link setBase(URI base) { + super.setBase(base); + return this; + } + + @Override /* Common */ + public Link setLang(String lang) { + super.setLang(lang); + return this; + } +} http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/e6bf97a8/juneau-core/src/main/java/org/apache/juneau/dto/atom/Logo.java ---------------------------------------------------------------------- diff --git a/juneau-core/src/main/java/org/apache/juneau/dto/atom/Logo.java b/juneau-core/src/main/java/org/apache/juneau/dto/atom/Logo.java new file mode 100644 index 0000000..a2e80fa --- /dev/null +++ b/juneau-core/src/main/java/org/apache/juneau/dto/atom/Logo.java @@ -0,0 +1,97 @@ +/*************************************************************************************************************************** + * 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 java.net.*; + +import org.apache.juneau.xml.annotation.*; + +/** + * Represents an <code>atomLogo</code> construct in the RFC4287 specification. + * <p> + * <h6 class='figure'>Schema</h6> + * <p class='bcode'> + * atomLogo = element atom:logo { + * atomCommonAttributes, + * (atomUri) + * } + * </p> + * <p> + * Refer to {@link org.apache.juneau.dto.atom} for further information about ATOM support. + * </p> + * + * @author James Bognar ([email protected]) + */ +@Xml(name="logo") +public class Logo extends Common { + + private URI uri; + + + /** + * Normal constructor. + * + * @param uri The URI of the logo. + */ + public Logo(URI uri) { + this.uri = uri; + } + + /** Bean constructor. */ + public Logo() {} + + + //-------------------------------------------------------------------------------- + // Bean properties + //-------------------------------------------------------------------------------- + + /** + * Returns the URI of the logo. + * + * @return The URI of the logo. + */ + @Xml(format=CONTENT) + public URI getUri() { + return uri; + } + + /** + * Sets the URI of the logo. + * + * @param uri The URI of the logo. + * @return This object (for method chaining). + */ + public Logo setUri(URI uri) { + this.uri = uri; + return this; + } + + + //-------------------------------------------------------------------------------- + // Overridden setters (to simplify method chaining) + //-------------------------------------------------------------------------------- + + @Override /* Common */ + public Logo setBase(URI base) { + super.setBase(base); + return this; + } + + @Override /* Common */ + public Logo setLang(String lang) { + super.setLang(lang); + return this; + } +} http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/e6bf97a8/juneau-core/src/main/java/org/apache/juneau/dto/atom/Person.java ---------------------------------------------------------------------- diff --git a/juneau-core/src/main/java/org/apache/juneau/dto/atom/Person.java b/juneau-core/src/main/java/org/apache/juneau/dto/atom/Person.java new file mode 100644 index 0000000..cc539bc --- /dev/null +++ b/juneau-core/src/main/java/org/apache/juneau/dto/atom/Person.java @@ -0,0 +1,135 @@ +/*************************************************************************************************************************** + * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + ***************************************************************************************************************************/ +package org.apache.juneau.dto.atom; + +import java.net.*; + +/** + * Represents an <code>atomPersonConstruct</code> construct in the RFC4287 specification. + * <p> + * <h6 class='figure'>Schema</h6> + * <p class='bcode'> + * atomPersonConstruct = + * atomCommonAttributes, + * (element atom:name { text } + * & element atom:uri { atomUri }? + * & element atom:email { atomEmailAddress }? + * & extensionElement*) + * </p> + * <p> + * Refer to {@link org.apache.juneau.dto.atom} for further information about ATOM support. + * </p> + * + * @author James Bognar ([email protected]) + */ +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) { + this.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). + */ + public Person setName(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. + * + * @param uri The URI of the person. + * @return This object (for method chaining). + */ + public Person setUri(URI uri) { + this.uri = 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). + */ + public Person setEmail(String email) { + this.email = email; + return this; + } + + + //-------------------------------------------------------------------------------- + // Overridden setters (to simplify method chaining) + //-------------------------------------------------------------------------------- + + @Override /* Common */ + public Person setBase(URI base) { + super.setBase(base); + return this; + } + + @Override /* Common */ + public Person setLang(String lang) { + super.setLang(lang); + return this; + } +} http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/e6bf97a8/juneau-core/src/main/java/org/apache/juneau/dto/atom/Source.java ---------------------------------------------------------------------- diff --git a/juneau-core/src/main/java/org/apache/juneau/dto/atom/Source.java b/juneau-core/src/main/java/org/apache/juneau/dto/atom/Source.java new file mode 100644 index 0000000..9521676 --- /dev/null +++ b/juneau-core/src/main/java/org/apache/juneau/dto/atom/Source.java @@ -0,0 +1,227 @@ +/*************************************************************************************************************************** + * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + ***************************************************************************************************************************/ +package org.apache.juneau.dto.atom; + +import java.net.*; +import java.util.*; + +/** + * Represents an <code>atomSource</code> construct in the RFC4287 specification. + * <p> + * <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> + * <p> + * Refer to {@link org.apache.juneau.dto.atom} for further information about ATOM support. + * </p> + * + * @author James Bognar ([email protected]) + */ +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). + */ + public Source setGenerator(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). + */ + public Source setIcon(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). + */ + public Source setLogo(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). + */ + public Source setSubtitle(Text subtitle) { + this.subtitle = subtitle; + return this; + } + + + //-------------------------------------------------------------------------------- + // Overridden setters (to simplify method chaining) + //-------------------------------------------------------------------------------- + + @Override /* CommonEntry */ + public Source setAuthors(List<Person> authors) { + super.setAuthors(authors); + return this; + } + + @Override /* CommonEntry */ + public Source addAuthors(Person...authors) { + super.addAuthors(authors); + return this; + } + + @Override /* CommonEntry */ + public Source setCategories(List<Category> categories) { + super.setCategories(categories); + return this; + } + + @Override /* CommonEntry */ + public Source addCategories(Category...categories) { + super.addCategories(categories); + return this; + } + + @Override /* CommonEntry */ + public Source setContributors(List<Person> contributors) { + super.setContributors(contributors); + return this; + } + + @Override /* CommonEntry */ + public Source addContributors(Person...contributors) { + super.addContributors(contributors); + return this; + } + + @Override /* CommonEntry */ + public Source setId(Id id) { + super.setId(id); + return this; + } + + @Override /* CommonEntry */ + public Source setLinks(List<Link> links) { + super.setLinks(links); + return this; + } + + @Override /* CommonEntry */ + public Source addLinks(Link...links) { + super.addLinks(links); + return this; + } + + @Override /* CommonEntry */ + public Source setRights(Text rights) { + super.setRights(rights); + return this; + } + + @Override /* CommonEntry */ + public Source setTitle(Text title) { + super.setTitle(title); + return this; + } + + @Override /* CommonEntry */ + public Source setUpdated(Calendar updated) { + super.setUpdated(updated); + return this; + } + + @Override /* Common */ + public Source setBase(URI base) { + super.setBase(base); + return this; + } + + @Override /* Common */ + public Source setLang(String lang) { + super.setLang(lang); + return this; + } +} http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/e6bf97a8/juneau-core/src/main/java/org/apache/juneau/dto/atom/Text.java ---------------------------------------------------------------------- diff --git a/juneau-core/src/main/java/org/apache/juneau/dto/atom/Text.java b/juneau-core/src/main/java/org/apache/juneau/dto/atom/Text.java new file mode 100644 index 0000000..28d473e --- /dev/null +++ b/juneau-core/src/main/java/org/apache/juneau/dto/atom/Text.java @@ -0,0 +1,183 @@ +/*************************************************************************************************************************** + * 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.XmlUtils.*; +import static org.apache.juneau.xml.annotation.XmlFormat.*; + +import java.net.*; + +import javax.xml.stream.*; + +import org.apache.juneau.xml.*; +import org.apache.juneau.xml.annotation.*; + +/** + * Represents an <code>atomTextConstruct</code> construct in the RFC4287 specification. + * <p> + * <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> + * <p> + * Refer to {@link org.apache.juneau.dto.atom} for further information about ATOM support. + * </p> + * + * @author James Bognar ([email protected]) + */ +public class Text extends Common { + + private String type; + String text; + + + /** + * Normal content. + * + * @param type The content type of this content. + * @param text The text of this content. + */ + public Text(String type, String text) { + this.type = type; + this.text = text; + } + + /** + * Normal content. + * + * @param text The text of this content. + */ + public Text(String text) { + this.text = text; + } + + /** 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). + */ + public Text setType(String type) { + this.type = type; + return this; + } + + /** + * Returns the content of this content. + * + * @return The content of this content. + */ + @Xml(format=CONTENT, contentHandler=TextContentHandler.class) + public String getText() { + return text; + } + + /** + * Sets the content of this content. + * + * @param text The content of this content. + * @return This object (for method chaining). + */ + public Text setText(String text) { + this.text = text; + return this; + } + + + //-------------------------------------------------------------------------------- + // Overridden setters (to simplify method chaining) + //-------------------------------------------------------------------------------- + + @Override /* Common */ + public Text setBase(URI base) { + super.setBase(base); + return this; + } + + @Override /* Common */ + public Text setLang(String lang) { + super.setLang(lang); + return this; + } + + /** + * Specialized content handler for correctly handling XML element content based + * on the <code>type</code> attribute of the element. + * <p> + * If the <code>type</code> attribute is <js>"xhtml"</js> the content is treated + * as XML. Otherwise, it's treated as plain text. + */ + public static class TextContentHandler implements XmlContentHandler<Text> { + + @Override /* XmlContentHandler */ + public void parse(XMLStreamReader r, Text text) throws Exception { + String type = text.type; + if (type != null && type.equals("xhtml")) + text.text = decode(readXmlContents(r).trim()); + else + text.text = decode(r.getElementText().trim()); + } + + @Override /* XmlContentHandler */ + public void serialize(XmlWriter w, Text text) throws Exception { + String type = text.type; + String content = text.text; + if (type != null && type.equals("xhtml")) + w.encodeTextInvalidChars(content); + else + w.encodeText(content); + } + } +} http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/e6bf97a8/juneau-core/src/main/java/org/apache/juneau/dto/atom/doc-files/Example_HTML.png ---------------------------------------------------------------------- diff --git a/juneau-core/src/main/java/org/apache/juneau/dto/atom/doc-files/Example_HTML.png b/juneau-core/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/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/e6bf97a8/juneau-core/src/main/java/org/apache/juneau/dto/atom/package-info.java ---------------------------------------------------------------------- diff --git a/juneau-core/src/main/java/org/apache/juneau/dto/atom/package-info.java b/juneau-core/src/main/java/org/apache/juneau/dto/atom/package-info.java new file mode 100644 index 0000000..8b27b77 --- /dev/null +++ b/juneau-core/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.*; +
