View Javadoc

1   package com.eyeq.pivot4j.pentaho.repository;
2   
3   import java.io.IOException;
4   import java.io.Serializable;
5   import java.util.Date;
6   
7   import org.apache.commons.lang.NullArgumentException;
8   import org.pentaho.platform.api.repository2.unified.RepositoryFile;
9   
10  import com.eyeq.pivot4j.analytics.repository.AbstractReportFile;
11  import com.eyeq.pivot4j.analytics.repository.ReportFile;
12  
13  public class PentahoReportFile extends AbstractReportFile {
14  
15  	public static final String DEFAULT_EXTENSION = "pivot4j";
16  
17  	private RepositoryFile file;
18  
19  	private PentahoReportFile parent;
20  
21  	/**
22  	 * @param file
23  	 * @param parent
24  	 */
25  	public PentahoReportFile(RepositoryFile file, PentahoReportFile parent) {
26  		if (file == null) {
27  			throw new NullArgumentException("file");
28  		}
29  
30  		this.file = file;
31  		this.parent = parent;
32  	}
33  
34  	/**
35  	 * @return the file
36  	 */
37  	protected RepositoryFile getFile() {
38  		return file;
39  	}
40  
41  	/**
42  	 * @see com.eyeq.pivot4j.analytics.repository.AbstractReportFile#getId()
43  	 */
44  	@Override
45  	public Serializable getId() {
46  		return file.getId();
47  	}
48  
49  	/**
50  	 * @see com.eyeq.pivot4j.analytics.repository.ReportFile#getName()
51  	 */
52  	@Override
53  	public String getName() {
54  		return file.getName();
55  	}
56  
57  	/**
58  	 * @see com.eyeq.pivot4j.analytics.repository.ReportFile#getPath()
59  	 */
60  	@Override
61  	public String getPath() {
62  		return file.getPath().replaceAll(RepositoryFile.SEPARATOR,
63  				ReportFile.SEPARATOR);
64  	}
65  
66  	/**
67  	 * @see com.eyeq.pivot4j.analytics.repository.ReportFile#getParent()
68  	 */
69  	@Override
70  	public ReportFile getParent() throws IOException {
71  		return parent;
72  	}
73  
74  	/**
75  	 * @see com.eyeq.pivot4j.analytics.repository.ReportFile#isDirectory()
76  	 */
77  	@Override
78  	public boolean isDirectory() {
79  		return file.isFolder();
80  	}
81  
82  	/**
83  	 * @see com.eyeq.pivot4j.analytics.repository.ReportFile#getLastModifiedDate()
84  	 */
85  	@Override
86  	public Date getLastModifiedDate() {
87  		return file.getLastModifiedDate();
88  	}
89  
90  	/**
91  	 * @see com.eyeq.pivot4j.analytics.repository.ReportFile#getSize()
92  	 */
93  	@Override
94  	public long getSize() {
95  		return file.getFileSize();
96  	}
97  }