KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > jaspersoft > jasperserver > api > metadata > common > domain > client > ResourceImpl


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.api.metadata.common.domain.client;
22
23 import java.util.Date JavaDoc;
24 import java.util.List JavaDoc;
25
26 import com.jaspersoft.jasperserver.api.metadata.common.domain.Folder;
27 import com.jaspersoft.jasperserver.api.metadata.common.domain.Resource;
28
29
30 /**
31  * @author Teodor Danciu (teodord@users.sourceforge.net)
32  * @version $Id: ResourceImpl.java 3811 2006-06-23 13:00:21Z swood $
33  */

34 public abstract class ResourceImpl implements Resource
35 {
36     private int version;
37     private Date JavaDoc creationDate;
38     private String JavaDoc name;
39     private String JavaDoc label;
40     private String JavaDoc description;
41     private String JavaDoc folderUri;
42     private transient String JavaDoc uri;
43
44     protected ResourceImpl() {
45         version = VERSION_NEW;
46     }
47
48     public String JavaDoc getName()
49     {
50         return name;
51     }
52
53     public void setName(String JavaDoc name)
54     {
55         uri = null;
56         this.name = name;
57     }
58
59     public String JavaDoc getLabel()
60     {
61         return label;
62     }
63
64     public void setLabel(String JavaDoc label)
65     {
66         this.label = label;
67     }
68
69     public String JavaDoc getDescription()
70     {
71         return description;
72     }
73
74     public void setDescription(String JavaDoc description)
75     {
76         this.description = description;
77     }
78
79     public String JavaDoc getURIString()
80     {
81         if (uri == null) {
82             StringBuffer JavaDoc sb = new StringBuffer JavaDoc();
83             if (getParentFolder() != null && !getParentFolder().equals(Folder.SEPARATOR))
84                 sb.append(getParentFolder());
85             sb.append(Folder.SEPARATOR);
86             if (!getName().equals(Folder.SEPARATOR))
87                 sb.append(getName());
88             uri = sb.toString();
89         }
90         return uri;
91     }
92
93     public void setURIString(String JavaDoc uri)
94     {
95         this.uri = uri;
96     }
97
98     /* (non-Javadoc)
99      * @see com.jaspersoft.jasperserver.api.metadata.common.domain.InternalURI#getPath()
100      */

101     public String JavaDoc getPath() {
102         return getURIString();
103     }
104
105     /* (non-Javadoc)
106      * @see com.jaspersoft.jasperserver.api.metadata.common.domain.InternalURI#getProtocol()
107      */

108     public String JavaDoc getProtocol() {
109         return Resource.URI_PROTOCOL;
110     }
111
112     /* (non-Javadoc)
113      * @see com.jaspersoft.jasperserver.api.metadata.common.domain.InternalURI#getURI()
114      */

115     public String JavaDoc getURI() {
116         return getProtocol() + ":" + getPath();
117     }
118     
119     public String JavaDoc getParentURI() {
120         return getParentFolder() == null ? null : getProtocol() + ":" + getParentFolder();
121     }
122     
123     public String JavaDoc getParentPath() {
124         return getParentFolder() == null ? null : getParentFolder();
125     }
126
127     public String JavaDoc getParentFolder() {
128         return folderUri;
129     }
130
131     public void setParentFolder(Folder folder) {
132         this.uri = null;
133         folderUri = (folder == null ? null : folder.getURIString());
134     }
135
136     public void setParentFolder(String JavaDoc folderURI) {
137         this.uri = null;
138         folderUri = folderURI;
139     }
140
141     public List JavaDoc getAttributes()
142     {
143         // TODO Auto-generated method stub
144
return null;
145     }
146
147     public int getVersion() {
148         return version;
149     }
150
151     public void setVersion(int version) {
152         this.version = version;
153     }
154
155     public String JavaDoc getResourceType() {
156         return getImplementingItf().getName();
157     }
158
159     protected abstract Class JavaDoc getImplementingItf();
160
161     public Date JavaDoc getCreationDate() {
162         return creationDate;
163     }
164
165     public void setCreationDate(Date JavaDoc creationDate) {
166         this.creationDate = creationDate;
167     }
168
169     public boolean isNew() {
170         return version == VERSION_NEW;
171     }
172 }
173
Popular Tags