View Javadoc
1   package emissary.id;
2   
3   import java.io.Serializable;
4   import java.util.HashMap;
5   import java.util.Map;
6   
7   /**
8    * Basic unit of communication between an IdPlace and an IdEngine
9    */
10  public class WorkUnit implements Serializable {
11      // Serializable
12      static final long serialVersionUID = -990149336476881472L;
13  
14      protected String filename;
15      protected byte[] data;
16      protected byte[] header;
17      protected byte[] footer;
18      protected String currentForm;
19      protected Map<String, String> params = new HashMap<>();
20  
21  
22      public WorkUnit() {}
23  
24      public WorkUnit(final String filename, final byte[] data) {
25          setFilename(filename);
26          setData(data);
27      }
28  
29      public WorkUnit(final String filename, final byte[] data, final String currentForm) {
30          this(filename, data);
31          setCurrentForm(currentForm);
32      }
33  
34      public WorkUnit(final String f, final byte[] hd, final byte[] data, final byte[] ft, final String currentForm) {
35          setFilename(f);
36          setHeader(hd);
37          setData(data);
38          setFooter(ft);
39          setCurrentForm(currentForm);
40      }
41  
42      /**
43       * Gets the value of filename
44       *
45       * @return the value of filename
46       */
47      public String getFilename() {
48          return this.filename;
49      }
50  
51      /**
52       * Sets the value of filename
53       *
54       * @param argFilename Value to assign to this.filename
55       */
56      public void setFilename(final String argFilename) {
57          this.filename = argFilename;
58      }
59  
60      /**
61       * Gets the value of data
62       *
63       * @return the value of data
64       */
65      public byte[] getData() {
66          return this.data;
67      }
68  
69      /**
70       * Sets the value of data
71       *
72       * @param argData Value to assign to this.data
73       */
74      public void setData(final byte[] argData) {
75          this.data = argData;
76      }
77  
78      /**
79       * Gets the value of currentForm
80       *
81       * @return the value of currentForm
82       */
83      public String getCurrentForm() {
84          return this.currentForm;
85      }
86  
87      /**
88       * Sets the value of currentForm
89       *
90       * @param argCurrentForm Value to assign to this.currentForm
91       */
92      public void setCurrentForm(final String argCurrentForm) {
93          this.currentForm = argCurrentForm;
94      }
95  
96      /**
97       * Gets the value of header[]
98       *
99       * @return the value of header[]
100      */
101     public byte[] getHeader() {
102         return this.header;
103     }
104 
105     /**
106      * Sets the value of header[]
107      *
108      * @param argHeader Value to assign to this.header[]
109      */
110     public void setHeader(final byte[] argHeader) {
111         this.header = argHeader;
112     }
113 
114     /**
115      * Gets the value of footer[]
116      *
117      * @return the value of footer[]
118      */
119     public byte[] getFooter() {
120         return this.footer;
121     }
122 
123     /**
124      * Sets the value of footer[]
125      *
126      * @param argFooter Value to assign to this.footer[]
127      */
128     public void setFooter(final byte[] argFooter) {
129         this.footer = argFooter;
130     }
131 
132     /**
133      * Add a parameter to control the work
134      */
135     public void addParameter(final String key, final String value) {
136         this.params.put(key, value);
137     }
138 
139     /**
140      * Add a bunch of parameters to control the work
141      */
142     public void addParameters(final Map<String, String> m) {
143         this.params.putAll(m);
144     }
145 
146     /**
147      * Retrieve a parameter
148      */
149     public String getParameter(final String key) {
150         return this.params.get(key);
151     }
152 
153     /**
154      * Get all parameters
155      */
156     public Map<String, String> getParameters() {
157         return new HashMap<>(this.params);
158     }
159 }