KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > jaspersoft > jasperserver > api > metadata > common > service > impl > hibernate > persistent > CachedItem


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.service.impl.hibernate.persistent;
22
23 import java.sql.Blob JavaDoc;
24 import java.util.Date JavaDoc;
25 import java.util.Set JavaDoc;
26
27 import org.hibernate.Hibernate;
28
29 import com.jaspersoft.jasperserver.api.metadata.common.domain.util.StreamUtils;
30
31 /**
32  * @author Lucian Chirita (lucianc@users.sourceforge.net)
33  * @version $Id: CachedItem.java 3671 2006-06-13 16:45:49Z lucian $
34  *
35  * @hibernate.class table="repository_cache"
36  */

37 public class CachedItem {
38     private long id;
39     private String JavaDoc uri;
40     private String JavaDoc cacheName;
41     private int version;
42     private Blob JavaDoc data;
43     private CachedItem reference;
44     private Date JavaDoc versionDate;
45     private Set JavaDoc referrers;
46     
47     /**
48      * @hibernate.property column="data" type="blob"
49      */

50     public Blob JavaDoc getData() {
51         return data;
52     }
53     
54     public void setData(Blob JavaDoc data) {
55         this.data = data;
56     }
57     
58     public byte[] getDataBytes() {
59         return StreamUtils.readData(getData());
60     }
61
62     public void setDataBytes(byte[] bytes) {
63         Blob JavaDoc blob = Hibernate.createBlob(bytes);
64         setData(blob);
65     }
66     
67     /**
68      * @hibernate.id generator-class="identity"
69      */

70     public long getId() {
71         return id;
72     }
73     
74     public void setId(long id) {
75         this.id = id;
76     }
77     
78     /**
79      * @hibernate.property column="uri" type="string" length="200" not-null="true"
80      */

81     public String JavaDoc getUri() {
82         return uri;
83     }
84     
85     public void setUri(String JavaDoc uri) {
86         this.uri = uri;
87     }
88     
89     /**
90      * @hibernate.property column="version" not-null="true"
91      */

92     public int getVersion() {
93         return version;
94     }
95     
96     public void setVersion(int version) {
97         this.version = version;
98     }
99     
100     /**
101      * @hibernate.property column="cache_name" type="string" length="20" not-null="true"
102      */

103     public String JavaDoc getCacheName() {
104         return cacheName;
105     }
106     
107     public void setCacheName(String JavaDoc cacheName) {
108         this.cacheName = cacheName;
109     }
110     
111     /**
112      * @hibernate.many-to-one column="reference"
113      */

114     public CachedItem getReference() {
115         return reference;
116     }
117     
118     public void setReference(CachedItem reference) {
119         this.reference = reference;
120     }
121
122     public boolean isReference() {
123         return getReference() != null;
124     }
125
126     /**
127      * @hibernate.property
128      * column="version_date" type="timestamp" not-null="true"
129
130      * @return Returns the versionDate.
131      */

132     public Date JavaDoc getVersionDate() {
133         return versionDate;
134     }
135
136     /**
137      * @param versionDate The versionDate to set.
138      */

139     public void setVersionDate(Date JavaDoc versionDate) {
140         this.versionDate = versionDate;
141     }
142
143     public Set JavaDoc getReferrers() {
144         return referrers;
145     }
146
147     public void setReferrers(Set JavaDoc referrers) {
148         this.referrers = referrers;
149     }
150 }
151
Popular Tags