001package org.apache.commons.digester3.rss;
002
003/*
004 * Licensed to the Apache Software Foundation (ASF) under one or more
005 * contributor license agreements.  See the NOTICE file distributed with
006 * this work for additional information regarding copyright ownership.
007 * The ASF licenses this file to You under the Apache License, Version 2.0
008 * (the "License"); you may not use this file except in compliance with
009 * the License.  You may obtain a copy of the License at
010 * 
011 *      http://www.apache.org/licenses/LICENSE-2.0
012 * 
013 * Unless required by applicable law or agreed to in writing, software
014 * distributed under the License is distributed on an "AS IS" BASIS,
015 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
016 * See the License for the specific language governing permissions and
017 * limitations under the License.
018 */
019
020import java.io.PrintWriter;
021import java.io.Serializable;
022
023/**
024 * <p>Implementation object representing an <strong>image</strong> in the
025 * <em>Rich Site Summary</em> DTD, version 0.91.  This class may be subclassed
026 * to further specialize its behavior.</p>
027 */
028public class Image
029    implements Serializable
030{
031
032    /**
033     * 
034     */
035    private static final long serialVersionUID = 7651966908064015194L;
036
037    // ------------------------------------------------------------- Properties
038
039    /**
040     * The image description (1-100 characters).
041     */
042    protected String description = null;
043
044    public String getDescription()
045    {
046        return ( this.description );
047    }
048
049    public void setDescription( String description )
050    {
051        this.description = description;
052    }
053
054    /**
055     * The image height in pixels (1-400).
056     */
057    protected int height = 31;
058
059    public int getHeight()
060    {
061        return ( this.height );
062    }
063
064    public void setHeight( int height )
065    {
066        this.height = height;
067    }
068
069    /**
070     * The image link (1-500 characters).
071     */
072    protected String link = null;
073
074    public String getLink()
075    {
076        return ( this.link );
077    }
078
079    public void setLink( String link )
080    {
081        this.link = link;
082    }
083
084    /**
085     * The image alternate text (1-100 characters).
086     */
087    protected String title = null;
088
089    public String getTitle()
090    {
091        return ( this.title );
092    }
093
094    public void setTitle( String title )
095    {
096        this.title = title;
097    }
098
099    /**
100     * The image location URL (1-500 characters).
101     */
102    protected String url = null;
103
104    public String getURL()
105    {
106        return ( this.url );
107    }
108
109    public void setURL( String url )
110    {
111        this.url = url;
112    }
113
114    /**
115     * The image width in pixels (1-400).
116     */
117    protected int width = 31;
118
119    public int getWidth()
120    {
121        return ( this.width );
122    }
123
124    public void setWidth( int width )
125    {
126        this.width = width;
127    }
128
129    // -------------------------------------------------------- Package Methods
130
131    /**
132     * Render this channel as XML conforming to the RSS 0.91 specification,
133     * to the specified writer.
134     *
135     * @param writer The writer to render output to
136     */
137    void render( PrintWriter writer )
138    {
139        writer.println( "    <image>" );
140
141        writer.print( "      <title>" );
142        writer.print( title );
143        writer.println( "</title>" );
144
145        writer.print( "      <url>" );
146        writer.print( url );
147        writer.println( "</url>" );
148
149        if ( link != null )
150        {
151            writer.print( "      <link>" );
152            writer.print( link );
153            writer.println( "</link>" );
154        }
155
156        writer.print( "      <width>" );
157        writer.print( width );
158        writer.println( "</width>" );
159
160        writer.print( "      <height>" );
161        writer.print( height );
162        writer.println( "</height>" );
163
164        if ( description != null )
165        {
166            writer.print( "      <description>" );
167            writer.print( description );
168            writer.println( "</description>" );
169        }
170
171        writer.println( "    </image>" );
172    }
173
174}