001// *************************************************************************************************************************** 002// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file * 003// * distributed with this work for additional information regarding copyright ownership. The ASF licenses this file * 004// * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance * 005// * with the License. You may obtain a copy of the License at * 006// * * 007// * http://www.apache.org/licenses/LICENSE-2.0 * 008// * * 009// * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an * 010// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * 011// * specific language governing permissions and limitations under the License. * 012// *************************************************************************************************************************** 013package org.apache.juneau.dto.atom; 014 015import static org.apache.juneau.internal.StringUtils.*; 016import static org.apache.juneau.xml.annotation.XmlFormat.*; 017 018import java.net.*; 019import java.net.URI; 020 021import org.apache.juneau.*; 022import org.apache.juneau.annotation.*; 023import org.apache.juneau.xml.annotation.*; 024 025/** 026 * Represents an <code>atomContent</code> construct in the RFC4287 specification. 027 * 028 * <h5 class='figure'>Schema</h5> 029 * <p class='bcode w800'> 030 * atomContent = atomInlineTextContent 031 * | atomInlineXHTMLContent 032 * | atomInlineOtherContent 033 * | atomOutOfLineContent 034 * 035 * atomInlineTextContent = 036 * element atom:content { 037 * atomCommonAttributes, 038 * attribute type { "text" | "html" }?, 039 * (text)* 040 * } 041 * 042 * atomInlineXHTMLContent = 043 * element atom:content { 044 * atomCommonAttributes, 045 * attribute type { "xhtml" }, 046 * xhtmlDiv 047 * } 048 * 049 * atomInlineOtherContent = 050 * element atom:content { 051 * atomCommonAttributes, 052 * attribute type { atomMediaType }?, 053 * (text|anyElement)* 054 * } 055 * 056 * atomOutOfLineContent = 057 * element atom:content { 058 * atomCommonAttributes, 059 * attribute type { atomMediaType }?, 060 * attribute src { atomUri }, 061 * empty 062 * } 063 * </p> 064 * 065 * <h5 class='section'>See Also:</h5> 066 * <ul class='doctree'> 067 * <li class='link'>{@doc juneau-dto.Atom} 068 * <li class='jp'>{@doc package-summary.html#TOC} 069 * </ul> 070 */ 071public class Content extends Text { 072 073 private URI src; 074 075 076 /** 077 * Normal content. 078 * 079 * @param type The content type of this content. 080 */ 081 public Content(String type) { 082 super(type); 083 } 084 085 /** 086 * Normal content. 087 */ 088 public Content() { 089 super(); 090 } 091 092 093 //----------------------------------------------------------------------------------------------------------------- 094 // Bean properties 095 //----------------------------------------------------------------------------------------------------------------- 096 097 /** 098 * Returns the source URI. 099 * 100 * @return the source URI. 101 */ 102 @Xml(format=ATTR) 103 public URI getSrc() { 104 return src; 105 } 106 107 /** 108 * Sets the source URI. 109 * 110 * <p> 111 * The value can be of any of the following types: {@link URI}, {@link URL}, {@link String}. 112 * Strings must be valid URIs. 113 * 114 * <p> 115 * URIs defined by {@link UriResolver} can be used for values. 116 * 117 * @param src The source URI. 118 * @return This object (for method chaining). 119 */ 120 @BeanProperty("src") 121 public Content src(Object src) { 122 this.src = toURI(src); 123 return this; 124 } 125 126 127 //----------------------------------------------------------------------------------------------------------------- 128 // Overridden setters (to simplify method chaining) 129 //----------------------------------------------------------------------------------------------------------------- 130 131 @Override /* Text */ 132 public Content text(String text) { 133 super.text(text); 134 return this; 135 } 136 137 @Override /* Text */ 138 public Content type(String type) { 139 super.type(type); 140 return this; 141 } 142 143 @Override /* Common */ 144 public Content base(Object base) { 145 super.base(base); 146 return this; 147 } 148 @Override /* Common */ 149 public Content lang(String lang) { 150 super.lang(lang); 151 return this; 152 } 153}