View Javadoc

1   package org.apache.commons.digester3.rss;
2   
3   /*
4    * Licensed to the Apache Software Foundation (ASF) under one or more
5    * contributor license agreements.  See the NOTICE file distributed with
6    * this work for additional information regarding copyright ownership.
7    * The ASF licenses this file to You under the Apache License, Version 2.0
8    * (the "License"); you may not use this file except in compliance with
9    * the License.  You may obtain a copy of the License at
10   * 
11   *      http://www.apache.org/licenses/LICENSE-2.0
12   * 
13   * Unless required by applicable law or agreed to in writing, software
14   * distributed under the License is distributed on an "AS IS" BASIS,
15   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16   * See the License for the specific language governing permissions and
17   * limitations under the License.
18   */
19  
20  import java.io.PrintWriter;
21  import java.io.Serializable;
22  
23  /**
24   * <p>Implementation object representing an <strong>image</strong> in the
25   * <em>Rich Site Summary</em> DTD, version 0.91.  This class may be subclassed
26   * to further specialize its behavior.</p>
27   */
28  public class Image
29      implements Serializable
30  {
31  
32      /**
33       * 
34       */
35      private static final long serialVersionUID = 7651966908064015194L;
36  
37      // ------------------------------------------------------------- Properties
38  
39      /**
40       * The image description (1-100 characters).
41       */
42      protected String description = null;
43  
44      public String getDescription()
45      {
46          return ( this.description );
47      }
48  
49      public void setDescription( String description )
50      {
51          this.description = description;
52      }
53  
54      /**
55       * The image height in pixels (1-400).
56       */
57      protected int height = 31;
58  
59      public int getHeight()
60      {
61          return ( this.height );
62      }
63  
64      public void setHeight( int height )
65      {
66          this.height = height;
67      }
68  
69      /**
70       * The image link (1-500 characters).
71       */
72      protected String link = null;
73  
74      public String getLink()
75      {
76          return ( this.link );
77      }
78  
79      public void setLink( String link )
80      {
81          this.link = link;
82      }
83  
84      /**
85       * The image alternate text (1-100 characters).
86       */
87      protected String title = null;
88  
89      public String getTitle()
90      {
91          return ( this.title );
92      }
93  
94      public void setTitle( String title )
95      {
96          this.title = title;
97      }
98  
99      /**
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 }