001/* 002 * Licensed to the Apache Software Foundation (ASF) under one or more 003 * contributor license agreements. See the NOTICE file distributed with 004 * this work for additional information regarding copyright ownership. 005 * The ASF licenses this file to You under the Apache License, Version 2.0 006 * (the "License"); you may not use this file except in compliance with 007 * the License. You may obtain a copy of the License at 008 * 009 * http://www.apache.org/licenses/LICENSE-2.0 010 * 011 * Unless required by applicable law or agreed to in writing, software 012 * distributed under the License is distributed on an "AS IS" BASIS, 013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 014 * See the License for the specific language governing permissions and 015 * limitations under the License. 016 */ 017package org.apache.juneau.bean.atom; 018 019import static org.apache.juneau.commons.utils.StringUtils.*; 020import static org.apache.juneau.marshall.xml.XmlFormat.*; 021 022import java.net.*; 023 024import org.apache.juneau.marshall.*; 025import org.apache.juneau.marshall.xml.*; 026 027/** 028 * Represents a small icon image for visual identification of a feed. 029 * 030 * <p> 031 * The icon element contains a URI reference to a small image that provides iconic visual 032 * identification for the feed. Icons are typically small, square images suitable for display 033 * in feed readers and aggregators. 034 * 035 * <p> 036 * Per RFC 4287 recommendations: 037 * <ul class='spaced-list'> 038 * <li>Should be square (aspect ratio of 1:1) 039 * <li>Should be small (e.g., 16x16, 32x32 pixels) 040 * <li>Common formats: PNG, ICO, GIF 041 * </ul> 042 * 043 * <h5 class='figure'>Schema</h5> 044 * <p class='bschema'> 045 * atomIcon = element atom:icon { 046 * atomCommonAttributes, 047 * (atomUri) 048 * } 049 * </p> 050 * 051 * <h5 class='section'>Example:</h5> 052 * <p class='bjava'> 053 * Icon <jv>icon</jv> = <jk>new</jk> Icon(<js>"http://example.org/icon.png"</js>); 054 * 055 * Feed <jv>feed</jv> = <jk>new</jk> Feed(...) 056 * .setIcon(<jv>icon</jv>); 057 * </p> 058 * 059 * <h5 class='section'>Specification:</h5> 060 * <p> 061 * Represents an <c>atomIcon</c> construct in the 062 * <a class="doclink" href="https://tools.ietf.org/html/rfc4287#section-4.2.5">RFC 4287 - Section 4.2.5</a> specification. 063 * 064 * <h5 class='section'>See Also:</h5><ul> 065 * <li class='link'><a class="doclink" href="https://juneau.apache.org/docs/topics/JuneauBeanAtom">juneau-bean-atom</a> 066 * <li class='extlink'><a class="doclink" href="https://tools.ietf.org/html/rfc4287">RFC 4287 - The Atom Syndication Format</a> 067 * </ul> 068 */ 069@Marshalled(typeName = "icon") 070public class Icon extends Common { 071 072 private URI uri; 073 074 /** Bean constructor. */ 075 public Icon() {} 076 077 /** 078 * Normal constructor. 079 * 080 * <p> 081 * The value can be of any of the following types: {@link URI}, {@link URL}, {@link String}. 082 * Strings must be valid URIs. 083 * 084 * <p> 085 * URIs defined by {@link UriResolver} can be used for values. 086 * 087 * @param uri The URI of the icon. Can be <jk>null</jk> to leave the property unset. 088 */ 089 public Icon(Object uri) { 090 setUri(uri); 091 } 092 093 /** 094 * Bean property getter: <property>uri</property>. 095 * 096 * <p> 097 * The URI of this icon. 098 * 099 * @return The property value, or <jk>null</jk> if it is not set. 100 */ 101 @Xml(format = TEXT) 102 public URI getUri() { return uri; } 103 104 @Override /* Overridden from Common */ 105 public Icon setBase(Object value) { 106 super.setBase(value); 107 return this; 108 } 109 110 @Override /* Overridden from Common */ 111 public Icon setLang(String value) { 112 super.setLang(value); 113 return this; 114 } 115 116 /** 117 * Bean property setter: <property>uri</property>. 118 * 119 * <p> 120 * The URI of this icon. 121 * 122 * <p> 123 * The value can be of any of the following types: {@link URI}, {@link URL}, {@link String}. 124 * Strings must be valid URIs. 125 * 126 * @param value 127 * The new value for this property. 128 * <br>Can be <jk>null</jk> to unset the property. 129 * @return This object 130 */ 131 public Icon setUri(Object value) { 132 this.uri = toUri(value); 133 return this; 134 } 135}