KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > info > magnolia > cms > beans > runtime > File


1 /**
2  *
3  * Magnolia and its source-code is licensed under the LGPL.
4  * You may copy, adapt, and redistribute this file for commercial or non-commercial use.
5  * When copying, adapting, or redistributing this document in keeping with the guidelines above,
6  * you are required to provide proper attribution to obinary.
7  * If you reproduce or distribute the document without making any substantive modifications to its content,
8  * please use the following attribution line:
9  *
10  * Copyright 1993-2006 obinary Ltd. (http://www.obinary.com) All rights reserved.
11  *
12  */

13 package info.magnolia.cms.beans.runtime;
14
15 import info.magnolia.cms.core.NodeData;
16
17 import java.io.InputStream JavaDoc;
18
19 import javax.jcr.RepositoryException;
20
21 import org.apache.commons.lang.math.NumberUtils;
22
23
24 /**
25  * @author Sameer Charles
26  * @version 1.1
27  */

28 public class File {
29
30     private NodeData data;
31
32     private String JavaDoc extension;
33
34     private String JavaDoc fileName;
35
36     private String JavaDoc contentType;
37
38     private String JavaDoc nodeDataTemplate;
39
40     private int size;
41
42     public void setProperties(NodeData properties) {
43         this.setNodeDataTemplate(properties.getAttribute("nodeDataTemplate")); //$NON-NLS-1$
44
this.setExtension(properties.getAttribute("extension")); //$NON-NLS-1$
45
this.setFileName(properties.getAttribute("fileName")); //$NON-NLS-1$
46
this.setContentType(properties.getAttribute("contentType")); //$NON-NLS-1$
47

48         String JavaDoc sizeString = properties.getAttribute("size"); //$NON-NLS-1$
49
if (NumberUtils.isNumber(sizeString)) {
50             this.setSize(Integer.parseInt(sizeString));
51         }
52
53     }
54
55     public String JavaDoc getExtension() {
56         return extension;
57     }
58
59     public void setExtension(String JavaDoc extension) {
60         this.extension = extension;
61     }
62
63     public String JavaDoc getFileName() {
64         return fileName;
65     }
66
67     public void setFileName(String JavaDoc fileName) {
68         this.fileName = fileName;
69     }
70
71     public String JavaDoc getContentType() {
72         return contentType;
73     }
74
75     public void setContentType(String JavaDoc contentType) {
76         this.contentType = contentType;
77     }
78
79     public String JavaDoc getNodeDataTemplate() {
80         return nodeDataTemplate;
81     }
82
83     public void setNodeDataTemplate(String JavaDoc nodeDataTemplate) {
84         this.nodeDataTemplate = nodeDataTemplate;
85     }
86
87     public int getSize() {
88         return size;
89     }
90
91     public void setSize(int size) {
92         this.size = size;
93     }
94
95     public NodeData getNodeData() {
96         return this.data;
97     }
98
99     public void setNodeData(NodeData data) {
100         this.data = data;
101     }
102
103     public InputStream JavaDoc getStream() {
104         try {
105             return this.data.getValue().getStream();
106         }
107         catch (RepositoryException re) {
108             return null;
109         }
110     }
111 }
112
Popular Tags