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 <c>atomContent</c> 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 * <ul class='seealso'> 066 * <li class='link'>{@doc juneau-dto.Atom} 067 * <li class='jp'>{@doc package-summary.html#TOC} 068 * </ul> 069 */ 070public class Content extends Text { 071 072 private URI src; 073 074 075 /** 076 * Normal content. 077 * 078 * @param type The content type of this content. 079 */ 080 public Content(String type) { 081 super(type); 082 } 083 084 /** 085 * Normal content. 086 */ 087 public Content() { 088 super(); 089 } 090 091 092 //----------------------------------------------------------------------------------------------------------------- 093 // Bean properties 094 //----------------------------------------------------------------------------------------------------------------- 095 096 /** 097 * Returns the source URI. 098 * 099 * @return the source URI. 100 */ 101 @Xml(format=ATTR) 102 public URI getSrc() { 103 return src; 104 } 105 106 /** 107 * Sets the source URI. 108 * 109 * <p> 110 * The value can be of any of the following types: {@link URI}, {@link URL}, {@link String}. 111 * Strings must be valid URIs. 112 * 113 * <p> 114 * URIs defined by {@link UriResolver} can be used for values. 115 * 116 * @param src The source URI. 117 * @return This object (for method chaining). 118 */ 119 @Beanp("src") 120 public Content src(Object src) { 121 this.src = toURI(src); 122 return this; 123 } 124 125 126 //----------------------------------------------------------------------------------------------------------------- 127 // Overridden setters (to simplify method chaining) 128 //----------------------------------------------------------------------------------------------------------------- 129 130 @Override /* Text */ 131 public Content text(String text) { 132 super.text(text); 133 return this; 134 } 135 136 @Override /* Text */ 137 public Content type(String type) { 138 super.type(type); 139 return this; 140 } 141 142 @Override /* Common */ 143 public Content base(Object base) { 144 super.base(base); 145 return this; 146 } 147 @Override /* Common */ 148 public Content lang(String lang) { 149 super.lang(lang); 150 return this; 151 } 152}