View Javadoc

1   package net.trajano.twiff.sample.web;
2   
3   import java.io.IOException;
4   import java.io.InputStream;
5   import java.io.Serializable;
6   import org.apache.commons.lang.builder.ToStringBuilder;
7   
8   /***
9    * Sample with upload
10   * 
11   * @author Archimedes Trajano
12   */
13  public class Upload implements Serializable {
14      /***
15       * The file data.
16       */
17      private byte[] file;
18  
19      /***
20       * The name.
21       */
22      private String name;
23  
24      /***
25       * @throws IOException
26       */
27      public Upload() throws IOException {
28          final InputStream resourceAsStream = getClass().getClassLoader().getResourceAsStream("poweredby.gif");
29          file = new byte[1024];
30          resourceAsStream.read(file);
31      }
32  
33      /***
34       * @return file
35       */
36      public final byte[] getFile() {
37          return file;
38      }
39  
40      /***
41       * @return the name
42       */
43      public final String getName() {
44          return name;
45      }
46  
47      /***
48       * @param file
49       *                   the file
50       */
51      public final void setFile(byte[] file) {
52          this.file = file;
53      }
54  
55      /***
56       * @param name
57       *                   the name
58       */
59      public final void setName(String name) {
60          this.name = name;
61      }
62  
63      /***
64       * Upload action
65       * 
66       * @return upload_done
67       */
68      public final String upload() {
69          return "upload_done";
70      }
71  
72      /***
73       * @see java.lang.Object#toString()
74       */
75      public String toString() {
76          return ToStringBuilder.reflectionToString(this);
77      }
78  }