KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > idaremedia > antx > print > DisplayRequest


1 /**
2  * $Id: DisplayRequest.java 180 2007-03-15 12:56:38Z ssmc $
3  * Copyright 2002-2004 iDare Media, Inc. All rights reserved.
4  *
5  * Originally written by iDare Media, Inc. for release into the public domain. This
6  * library, source form and binary form, is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public License as published by the
8  * Free Software Foundation; either version 2.1 of the License, or (at your option) any
9  * later version.<p>
10  *
11  * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
12  * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13  * See the GNU LGPL (GNU Lesser General Public License) for more details.<p>
14  *
15  * You should have received a copy of the GNU Lesser General Public License along with this
16  * library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite
17  * 330, Boston, MA 02111-1307 USA. The LGPL can be found online at
18  * http://www.fsf.org/copyleft/lesser.html<p>
19  *
20  * This product has been influenced by several projects within the open-source community.
21  * The JWare developers wish to acknowledge the open-source community's support. For more
22  * information regarding the open-source products used within JWare, please visit the
23  * JWare website.
24  *----------------------------------------------------------------------------------------*
25  * WEBSITE- http://www.jware.info EMAIL- inquiries@jware.info
26  *----------------------------------------------------------------------------------------*
27  **/

28
29 package com.idaremedia.antx.print;
30
31 import org.apache.tools.ant.Project;
32 import org.apache.tools.ant.ProjectComponent;
33
34 import com.idaremedia.antx.AssertableDataType;
35 import com.idaremedia.antx.apis.Nameable;
36 import com.idaremedia.antx.apis.ProjectDependent;
37 import com.idaremedia.antx.apis.Requester;
38
39 /**
40  * Information to be displayed by a {@linkplain DisplayStrategy display strategy}.
41  *
42  * @since JWare/AntX 0.2
43  * @author ssmc, &copy;2002-2004 <a HREF="http://www.jware.info">iDare&nbsp;Media,&nbsp;Inc.</a>
44  * @version 0.5
45  * @.safety single
46  * @.group api,helper
47  * @see DisplayStrategy
48  **/

49
50 public final class DisplayRequest implements Nameable, ProjectDependent
51 {
52     /**
53      * Initializes a new empty display request.
54      **/

55     public DisplayRequest()
56     {
57     }
58
59
60     /**
61      * Initializes a new display request for given object.
62      * @param thing thing to be displayed
63      **/

64     public DisplayRequest(Object JavaDoc thing)
65     {
66         setObjectToBeDisplayed(thing);
67     }
68
69
70     /**
71      * Initializes a new display request for given named
72      * object in project.
73      * @param p enclosing project
74      * @param thing thing to be displayed
75      * @param id the thing's identifier (in build script)
76      **/

77     public DisplayRequest(Project p, String JavaDoc id, Object JavaDoc thing)
78     {
79         setObjectToBeDisplayed(thing);
80
81         setProject(p); //NB:do these *after* settin obj
82
setName(id);
83     }
84
85
86     /**
87      * Returns the thing-to-be-displayed's identifier.
88      * Will return <i>null</i> if never set.
89      **/

90     public String JavaDoc getName()
91     {
92         return m_Id;
93     }
94
95
96     /**
97      * Sets the thing-to-be-displayed's identifier. Use <i>null</i>
98      * to reset name to default setting.
99      * @param name thing's name
100      **/

101     public void setName(String JavaDoc name)
102     {
103         m_Id = name;
104     }
105
106
107     /**
108      * Returns the thing-to-be-displayed. Will return <i>null</i>
109      * if never set.
110      **/

111     public Object JavaDoc getObjectToBeDisplayed()
112     {
113         return m_thing;
114     }
115
116
117     /**
118      * Sets the thing-to-be-displayed.
119      * @param thing the ting
120      * @.sideeffect (Re)Sets this request's project if thing is ProjectComponent
121      * @.sideeffect (Re)Sets this request's name if thing is Nameable
122      **/

123     public void setObjectToBeDisplayed(Object JavaDoc thing)
124     {
125         m_thing = thing;
126
127         if (thing instanceof ProjectComponent) {
128             setProject(((ProjectComponent)thing).getProject());
129         }
130         if (thing instanceof AssertableDataType) {//NB:ordering explicit
131
setName(((AssertableDataType)thing).getId());
132         } else if (thing instanceof Nameable) {
133             setName(((Nameable)thing).getName());
134         }
135     }
136
137
138     /**
139      * Returns the filtering information for this request.
140      * Will return <i>null</i> if never set or was reset.
141      **/

142     public String JavaDoc getFilter()
143     {
144         return m_filter;
145     }
146
147
148     /**
149      * Sets the filtering information for this request. Exactly
150      * how this information is used depends on the strategy being
151      * used and the thing-to-be-displayed. Use <i>null</i> to
152      * unset a filter for a reused request.
153      * @param filter the opaque filter information
154      **/

155     public void setFilter(String JavaDoc filter)
156     {
157         m_filter = filter;
158     }
159
160
161     /**
162      * Returns this request's enclosing project. Will return
163      * <i>null</i> if never defined and no callback information
164      * set.
165      **/

166     public Project getProject()
167     {
168         Project project = m_project;
169         if (project==null && m_rqlink!=Requester.ANONYMOUS) {
170             project = m_rqlink.getProject();
171         }
172         return project;
173     }
174
175
176     /**
177      * Sets this request's enclosing project.
178      * @param project the enclosing project
179      **/

180     public void setProject(Project project)
181     {
182         m_project = project;
183         if (project!=null && m_rqlink==Requester.ANONYMOUS) {
184             m_rqlink = new Requester.ForProject(project);
185         }
186     }
187
188
189
190     /**
191      * Returns caller information if available. If never set explicitly,
192      * returns either an anonymous caller or a caller based on this
193      * request's project. Never returns <i>null</i>.
194      * @since JWare/AntX 0.5
195      **/

196     public Requester getCaller()
197     {
198         return m_rqlink;
199     }
200
201
202
203     /**
204      * Sets this request's user's callback information.
205      * @param clnt [optional] caller information.
206      * @since JWare/AntX 0.5
207      **/

208     public void setCaller(Requester clnt)
209     {
210         if (clnt!=null) {
211             m_rqlink = clnt;
212         } else {
213             m_rqlink = Requester.ANONYMOUS;
214         }
215     }
216
217
218     private Project m_project;
219     private Object JavaDoc m_thing;
220     private String JavaDoc m_filter;
221     private String JavaDoc m_Id;
222     private Requester m_rqlink = Requester.ANONYMOUS;
223 }
224
225 /* end-of-DisplayRequest.java */
226
Popular Tags