Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

Source code: com/xpn/xwiki/render/macro/rss/RSSMacroParameters.java


1   /**
2    * ===================================================================
3    *
4    * Copyright (c) 2003 Ludovic Dubost, All rights reserved.
5    *
6    * This program is free software; you can redistribute it and/or
7    * modify it under the terms of the GNU General Public License
8    * as published by the Free Software Foundation; either version 2
9    * of the License, or (at your option) any later version.
10   *
11   * This program is distributed in the hope that it will be useful,
12   * but WITHOUT ANY WARRANTY; without even the implied warranty of
13   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14   * GNU General Public License for more details, published at
15   * http://www.gnu.org/copyleft/gpl.html or in gpl.txt in the
16   * root folder of this distribution.
17   *
18   * User: ludovic
19   * Date: 17 mars 2004
20   * Time: 15:10:09
21   */
22  
23  package com.xpn.xwiki.render.macro.rss;
24  
25  /**
26   * A simple bean which encapsulates macro parameters and does some logic,
27   * like making sure the <code>feed</code> property, a <code>String</code>
28   * is a well-formed URL, and evaluating the <code>count</code> property
29   * against a proposed number of items, in light of the possibility that
30   * <code>count</code> may not have been defined.
31   * @author Joe Germuska
32   * @version 0.2d
33   */
34  public class RSSMacroParameters
35  {
36  
37      public static final String DEFAULT_ALIGNMENT = "left";
38      public static final int UNDEFINED = -1;
39      private String feed = null;
40      private String align = DEFAULT_ALIGNMENT;
41      private boolean img = false;
42      private boolean css = false;
43      private int count = UNDEFINED;
44  
45      private java.net.URL feedURL = null;
46      private boolean full;
47      private boolean search;
48  
49      public String getFeed() {
50          return feed;
51      }
52      public void setFeed(String feed) throws java.net.MalformedURLException
53      {
54          this.feed = feed;
55          this.feedURL = new java.net.URL(feed);
56      }
57      public void setAlign(String align) {
58          this.align = align;
59      }
60      public String getAlign() {
61          return align;
62      }
63      public void setImg(boolean img) {
64          this.img = img;
65      }
66      public boolean isImg() {
67          return img;
68      }
69      public void setCss(boolean css) {
70          this.css = css;
71      }
72      public boolean isCss() {
73          return true;
74      }
75      public void setCount(int count) {
76          this.count = count;
77      }
78      public int getCount() {
79          return count;
80      }
81      public java.net.URL getFeedURL() {
82          return feedURL;
83      }
84  
85      /**
86       * Given <code>proposed</code> items and the current value of our
87       * <code>count</code> property, how many items should be processed?
88       * If <code>count</code> is undefined or greater than <code>proposed</code>,
89       * return <code>proposed</code>, otherwise return <code>count</code>.
90       * @param proposed
91       * @return
92       */
93      public int evalCount(int proposed)
94      {
95          if (this.count == UNDEFINED) return proposed;
96          if (this.count < proposed) return this.count;
97          return proposed;
98      }
99      public void setFull(boolean full) {
100         this.full = full;
101     }
102     public boolean isFull() {
103         return full;
104     }
105     public void setSearch(boolean search) {
106         this.search = search;
107     }
108     public boolean isSearch() {
109         return search;
110     }
111 
112 }