KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > jaspersoft > jasperserver > util > ResourceBean


1 /*
2  * Copyright (C) 2006 JasperSoft http://www.jaspersoft.com
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; either version 2 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed WITHOUT ANY WARRANTY; and without the
10  * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11  * See the GNU General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License
14  * along with this program; if not, see http://www.gnu.org/licenses/gpl.txt
15  * or write to:
16  *
17  * Free Software Foundation, Inc.,
18  * 59 Temple Place - Suite 330,
19  * Boston, MA USA 02111-1307
20  */

21 package com.jaspersoft.jasperserver.util;
22
23 /**
24  * @author tkavanagh
25  * @version $Id: ResourceBean.java 3778 2006-06-21 15:10:39Z tony $
26  */

27
28 import java.util.Date JavaDoc;
29
30 /**
31  * The following information applies to all "bean" classes used to marshal and
32  * unmarshal between objects and xml.
33  *
34  * Castor is used to handle the marshal/unmarshal between java object and xml.
35  * To work nicely with castor, which will handle moving between an object bean
36  * and it's XML representation, we make sure that all methods conform to the
37  * get/set pattern. Particularly, we make sure that boolean methods do this.
38  * So, instead of hasData(), we will use getHasData() and setHasData(). This
39  * way castor's output XML is cleaner and easier to read.
40  *
41  * As an example, for a FileResource image the output took the following form:
42  *
43  * <?xml version="1.0" encoding="UTF-8"?>
44  * <file-resource-bean is-reference="false" is-new="false" version="0" has-data="false">
45  * <name>JRLogo</name>
46  * <resource-type>com.jaspersoft.jasperserver.api.metadata.common.domain.FileResource</resource-type>
47  * <creation-date>2006-05-16T18:20:30.000-07:00</creation-date>
48  * <uri-string>/images/JRLogo</uri-string>
49  * <parent-folder>/images</parent-folder>
50  * <label>JR logo</label>
51  * <description>JR logo</description>
52  * <file-type>img</file-type>
53  * </file-resource-bean>
54  *
55  * Primitive types (boolean, int) get written as attributes (ie. is-reference).
56  * Primitive type are always written out with a value. If they are un-set they
57  * receive a default value, in this example, of false or zero.
58  *
59  * Object types (String, Date) get written out as their "toString" values, and
60  * are written out as node elements (ie. <name>JRLogo</name>).
61  * If an object type is null, then there is no element written out. For,
62  * example, in the xml generated above referenceUri was null so you
63  * do not see it included in the output xml.
64  *
65  * // todo: move comments to ResourceBean
66  */

67
68 /**
69  *
70  * The classes that inherit from ResourceBean are used to go back and forth
71  * between the java objects they represent and XML. We are currently using
72  * the Castor library in order to marshal and unmarshal between java and
73  * XML.
74  *
75  * One thing to note is that Castor handles primitive fields such as int and
76  * boolean as XML attributes of the top level XML tag for the particular
77  * object. Castor automatically gives default values for these primitives.
78  * So, if something like boolean hasData() has not been explicitly set, Castor
79  * will give it a default value of "false". For int the default value is
80  * zero.
81  *
82  * Furthermore, if a String value such as String setDescrption() does not
83  * have a value (is null) it will not be included in the output (unmarshal)
84  * XML. So, this is different than how primitives are dealt with.
85  *
86  *
87  */

88
89 public abstract class ResourceBean {
90
91     /*
92      * The following come from the Resource interface
93      */

94     private String JavaDoc name;
95     private String JavaDoc label;
96     private String JavaDoc description;
97     private String JavaDoc uriString;
98     private String JavaDoc parentFolder;
99     private String JavaDoc resourceType; // this is package + classname
100
private boolean isNew;
101     private Date JavaDoc creationDate;
102     private int version;
103     
104     /*
105      * Special export-import processing variables.
106      *
107      * The following variables are added to simplify export-import processing
108      *
109      * Regarding isUriReference:
110      * // todo: ### redo these comments
111      * FileResource has similar field. This is to
112      * help with other resources such as data sources
113      * which can be local to a ReportUnit or a reference
114      * (ie essentially the same as a link)
115      */

116     
117     private String JavaDoc productReleaseVersion; // JasperServer version compatability
118

119     private boolean isUriReference; // see comments above
120

121     private String JavaDoc resourceBeanType; // hold the class name
122

123     /*
124      * getters and setters
125      */

126     
127     public String JavaDoc getName() {
128         return name;
129     }
130
131     public void setName(String JavaDoc name) {
132         this.name = name;
133     }
134
135     public String JavaDoc getLabel() {
136         return label;
137     }
138
139     public void setLabel(String JavaDoc label) {
140         this.label = label;
141     }
142
143     public String JavaDoc getDescription() {
144         return description;
145     }
146
147     public void setDescription(String JavaDoc description) {
148         this.description = description;
149     }
150
151     public String JavaDoc getUriString() {
152         return uriString;
153     }
154     
155     public void setUriString(String JavaDoc uriString) {
156         this.uriString = uriString;
157     }
158
159     public String JavaDoc getParentFolder() {
160         return parentFolder;
161     }
162
163     public void setParentFolder(String JavaDoc parentFolder) {
164         this.parentFolder = parentFolder;
165     }
166
167     public String JavaDoc getResourceType() {
168         return resourceType;
169     }
170     
171     public void setResourceType(String JavaDoc resourceType) {
172         this.resourceType = resourceType;
173     }
174     
175     public boolean getIsNew() {
176         return isNew;
177     }
178     
179     public void setIsNew(boolean isNew) {
180         this.isNew = isNew;
181     }
182     
183     public Date JavaDoc getCreationDate() {
184         return creationDate;
185     }
186     
187     public void setCreationDate(Date JavaDoc creationDate) {
188         this.creationDate = creationDate;
189     }
190
191     public int getVersion() {
192         return version;
193     }
194     
195     public void setVersion(int version) {
196         this.version = version;
197     }
198     
199     public String JavaDoc getProductReleaseVersion() {
200         return productReleaseVersion;
201     }
202
203     public void setProductReleaseVersion(String JavaDoc productReleaseVersion) {
204         this.productReleaseVersion = productReleaseVersion;
205     }
206
207     public boolean getIsUriReference() {
208         return isUriReference;
209     }
210
211     public void setIsUriReference(boolean isUriReference) {
212         this.isUriReference = isUriReference;
213     }
214
215     public String JavaDoc getResourceBeanType() {
216         return resourceBeanType;
217     }
218
219     public void setResourceBeanType(String JavaDoc resourceBeanType) {
220         this.resourceBeanType = resourceBeanType;
221     }
222 }
223
Popular Tags