View Javadoc

1   /*
2   Copyright 2010 James Pether Sörling Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. 
3   	$Id
4   */
5   
6   package com.hack23.cia.model.application.impl.common;
7   
8   import javax.persistence.Column;
9   import javax.persistence.DiscriminatorValue;
10  import javax.persistence.Entity;
11  import javax.persistence.Lob;
12  
13  import org.hibernate.annotations.Cache;
14  import org.hibernate.annotations.CacheConcurrencyStrategy;
15  
16  import com.hack23.cia.model.core.impl.AbstractResource;
17  
18  /***
19   * The Class ImageContent.
20   */
21  @Entity
22  @Cache(usage = CacheConcurrencyStrategy.READ_ONLY)
23  @DiscriminatorValue("ImageContent")
24  public class ImageContent extends AbstractResource {
25  
26      /*** The Constant serialVersionUID. */
27      private static final long serialVersionUID = 1L;
28  
29      /*** The file name. */
30      private String fileName;
31      
32      /*** The image content. */
33      private byte[] imageContent;
34      
35      /*** The mimetype. */   
36      private String mimetype;
37  
38      /***
39       * Instantiates a new image content.
40       */
41      public ImageContent() {
42          super();
43          setResourceType(ResourceType.Image);
44      }
45  
46  	/***
47  	 * Gets the file name.
48  	 *
49  	 * @return the file name
50  	 */
51  	public String getFileName() {
52  		return fileName;
53  	}
54  
55  	/***
56  	 * Gets the image content.
57  	 *
58  	 * @return the image content
59  	 */
60      @Lob
61      @Column(length=2097105200)
62  	public byte[] getImageContent() {
63  		return imageContent;
64  	}
65  
66  	/***
67  	 * Gets the mimetype.
68  	 *
69  	 * @return the mimetype
70  	 */
71  	public String getMimetype() {
72  		return mimetype;
73  	}
74  
75  	/***
76  	 * Sets the file name.
77  	 *
78  	 * @param fileName the new file name
79  	 */
80  	public void setFileName(final String fileName) {
81  		this.fileName = fileName;
82  	}
83  
84  	/***
85  	 * Sets the image content.
86  	 *
87  	 * @param imageContent the new image content
88  	 */
89  	public void setImageContent(final byte[] imageContent) {
90  		this.imageContent = imageContent;
91  	}
92  
93  	/***
94  	 * Sets the mimetype.
95  	 *
96  	 * @param mimetype the new mimetype
97  	 */
98  	public void setMimetype(final String mimetype) {
99  		this.mimetype = mimetype;
100 	}
101 
102 	/* (non-Javadoc)
103 	 * @see java.lang.Object#toString()
104 	 */
105 	@Override
106 	public String toString() {
107 		return "ImageContent [fileName=" + fileName + ", mimetype=" + mimetype
108 				+ "]";
109 	}
110 
111 }