blob: 481383e2b7d188c7a4863beac35fbd62ba55ca12 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
|
/*******************************************************************************
* Copyright (c) 2004 - 2006 University Of British Columbia and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* University Of British Columbia - initial API and implementation
*******************************************************************************/
package org.eclipse.mylar.tasks.core;
import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.Serializable;
/**
* A class representing a local attachment.
*
* @author Jeff Pound
*/
public class LocalAttachment implements Serializable, ITaskAttachment {
private static final long serialVersionUID = -4477699536552617389L;
/** The report to which this attachment will be attached */
private RepositoryTaskData repositoryTaskData;
private String filePath;
private String comment = "";
private String description = "";
private String contentType = "";
private boolean isPatch = false;
private String filename;
private byte[] content;
private File file;
public String getComment() {
return comment;
}
public void setComment(String comment) {
this.comment = comment;
}
public String getContentType() {
return contentType;
}
public void setContentType(String contentType) {
this.contentType = contentType;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public boolean isPatch() {
return isPatch;
}
public void setPatch(boolean isPatch) {
this.isPatch = isPatch;
}
public RepositoryTaskData getReport() {
return repositoryTaskData;
}
public void setReport(RepositoryTaskData report) {
this.repositoryTaskData = report;
}
public String getFilePath() {
return filePath;
}
public void setFilePath(String filePath) {
this.filePath = filePath;
}
public String getFilename() {
return this.filename;
}
public void setFilename(String filename) {
this.filename = filename;
}
public InputStream createInputStream() throws IOException {
assert file != null || content != null;
return (file != null) ? new FileInputStream(file) : new ByteArrayInputStream(content);
}
public long getLength() {
assert file != null || content != null;
return (file != null) ? file.length() : content.length;
}
public void setFile(File file) {
this.file = file;
}
public void setContent(byte[] content) {
this.content = content;
}
}
|