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.xml.annotation.XmlFormat.*; 021 022import java.net.*; 023 024import org.apache.juneau.*; 025import org.apache.juneau.annotation.*; 026import org.apache.juneau.xml.annotation.*; 027 028/** 029 * Represents a small icon image for visual identification of a feed. 030 * 031 * <p> 032 * The icon element contains a URI reference to a small image that provides iconic visual 033 * identification for the feed. Icons are typically small, square images suitable for display 034 * in feed readers and aggregators. 035 * 036 * <p> 037 * Per RFC 4287 recommendations: 038 * <ul class='spaced-list'> 039 * <li>Should be square (aspect ratio of 1:1) 040 * <li>Should be small (e.g., 16x16, 32x32 pixels) 041 * <li>Common formats: PNG, ICO, GIF 042 * </ul> 043 * 044 * <h5 class='figure'>Schema</h5> 045 * <p class='bschema'> 046 * atomIcon = element atom:icon { 047 * atomCommonAttributes, 048 * (atomUri) 049 * } 050 * </p> 051 * 052 * <h5 class='section'>Example:</h5> 053 * <p class='bjava'> 054 * Icon <jv>icon</jv> = <jk>new</jk> Icon(<js>"http://example.org/icon.png"</js>); 055 * 056 * Feed <jv>feed</jv> = <jk>new</jk> Feed(...) 057 * .setIcon(<jv>icon</jv>); 058 * </p> 059 * 060 * <h5 class='section'>Specification:</h5> 061 * <p> 062 * Represents an <c>atomIcon</c> construct in the 063 * <a class="doclink" href="https://tools.ietf.org/html/rfc4287#section-4.2.5">RFC 4287 - Section 4.2.5</a> specification. 064 * 065 * <h5 class='section'>See Also:</h5><ul> 066 * <li class='link'><a class="doclink" href="https://juneau.apache.org/docs/topics/JuneauBeanAtom">juneau-bean-atom</a> 067 * <li class='extlink'><a class="doclink" href="https://tools.ietf.org/html/rfc4287">RFC 4287 - The Atom Syndication Format</a> 068 * </ul> 069 */ 070@Bean(typeName = "icon") 071public class Icon extends Common { 072 073 private URI uri; 074 075 /** Bean constructor. */ 076 public Icon() {} 077 078 /** 079 * Normal constructor. 080 * 081 * <p> 082 * The value can be of any of the following types: {@link URI}, {@link URL}, {@link String}. 083 * Strings must be valid URIs. 084 * 085 * <p> 086 * URIs defined by {@link UriResolver} can be used for values. 087 * 088 * @param uri The URI of the icon. 089 */ 090 public Icon(Object uri) { 091 setUri(uri); 092 } 093 094 /** 095 * Bean property getter: <property>uri</property>. 096 * 097 * <p> 098 * The URI of this icon. 099 * 100 * @return The property value, or <jk>null</jk> if it is not set. 101 */ 102 @Xml(format = TEXT) 103 public URI getUri() { return uri; } 104 105 @Override /* Overridden from Common */ 106 public Icon setBase(Object value) { 107 super.setBase(value); 108 return this; 109 } 110 111 @Override /* Overridden from Common */ 112 public Icon setLang(String value) { 113 super.setLang(value); 114 return this; 115 } 116 117 /** 118 * Bean property setter: <property>uri</property>. 119 * 120 * <p> 121 * The URI of this icon. 122 * 123 * <p> 124 * The value can be of any of the following types: {@link URI}, {@link URL}, {@link String}. 125 * Strings must be valid URIs. 126 * 127 * @param value 128 * The new value for this property. 129 * <br>Can be <jk>null</jk> to unset the property. 130 * @return This object 131 */ 132 public Icon setUri(Object value) { 133 this.uri = toUri(value); 134 return this; 135 } 136}