e7fc65aa2f4efee89ecbe3a6c2cb0b7948eb9bf4
[splitter-ng] / Splitter-ng / src / splitterng / CodingTask.java
1 package splitterng;
2
3 import java.nio.file.Path;
4 import java.util.Map;
5
6 public abstract class CodingTask {
7
8         protected Path filePath;
9         protected byte[] data;
10         
11         protected Map <Integer, Path>    fragmentPathsMap;
12         protected Map <Integer, byte []> dataFragmentMap = null;
13         protected Path outputDir;
14         
15         protected Map <String,Object> metadataMap;
16         protected SplitterCallback callback;
17         protected boolean codingFinished = false;
18         protected boolean codingSuccessfull = false;
19         protected String codingErrMsg = "";
20         protected boolean isFileTask = true;
21         
22         protected int fragmentsize;
23         protected int bufferSize;
24         protected long readins;
25         protected long readin = 0;
26         protected long writeout = 0;
27         protected long originalSize;
28         protected int truncate;
29         protected long readBytesTotal=0;
30         protected long writtenBytesTotal=0;
31         
32         protected byte [][] workingDataFragemnts;
33         
34         public abstract boolean hasDataToRead();
35         
36         public boolean isCodingFinished() {
37                 return codingFinished;
38         }       
39         
40         public abstract boolean isFileTask();
41
42         protected void setCodingFinished(boolean codingFinished) {
43                 this.codingFinished = codingFinished;
44         }
45         
46         public boolean isCodingSuccessfull() {
47                 return codingSuccessfull;
48         }
49
50         protected void setCodingSuccessfull(boolean codingSuccessfull) {
51                 this.codingSuccessfull = codingSuccessfull;
52         }
53
54         public String getCodingErrMsg() {
55                 return codingErrMsg;
56         }
57
58         public void setCodingErrMsg(String codingErrMsg) {
59                 this.codingErrMsg = codingErrMsg;
60         }
61
62         public SplitterCallback getCallback() {
63                 return callback;
64         }
65
66
67         public void setCallback(SplitterCallback callback) {
68                 this.callback = callback;
69         }
70
71
72         public Path getFilePath() {
73                 return filePath;
74         }
75
76
77         public void setFilePath(Path filePath) {
78                 this.filePath = filePath;
79         }
80
81         public byte [] getData() {
82                 return this.data;
83         }
84
85
86         public void setData(byte[] data) {
87                 this.data = data;
88         }
89
90         public Map<Integer, Path> getFragmentPaths() {
91                 return fragmentPathsMap;
92         }
93         
94         public Map<Integer, byte[]> getFragmentData() {
95                 return this.dataFragmentMap;
96         }
97
98         public void setFragmentPaths(Map<Integer, Path> fragmentPaths) {
99                 this.fragmentPathsMap = fragmentPaths;
100         }
101
102         public void setFragmentPath(Integer fragment_nr, Path fragment_path){
103                 fragmentPathsMap.put(fragment_nr, fragment_path);
104         }
105
106
107         public Map<String, Object> getMetadata() {
108                 return metadataMap;
109         }
110         public Object getMetadata(String key) {
111                 return metadataMap.get(key);
112         }
113
114         public void setMetadataMap(Map<String, Object> metadataMap) {
115                 this.metadataMap = metadataMap;
116         }
117         
118         public void setMetadata(String name, Object object) {
119                 this.metadataMap.put(name, object);
120         }
121
122
123 //      public boolean isEncodingTask() {
124 //              return isEncodingTask;
125 //      }
126 //
127 //
128 //      public void setEncodingTask(boolean isEncodingTask) {
129 //              this.isEncodingTask = isEncodingTask;
130 //      }
131 }
132