1 package org.jastacry.layer;
2
3 import java.io.IOException;
4 import java.io.InputStream;
5 import java.io.OutputStream;
6 import java.util.Objects;
7
8 import org.jastacry.JastacryException;
9
10
11
12
13
14
15
16
17 public class ReadWriteLayer extends AbstractBasicLayer
18 {
19
20
21
22 public static final String LAYERNAME = "ReadWrite Layer";
23
24
25
26
27 public ReadWriteLayer()
28 {
29 super(ReadWriteLayer.class, LAYERNAME);
30 }
31
32 @Override
33 public final void run()
34 {
35 logger.info("started thread");
36 try
37 {
38 int i;
39 while ((i = inputStream.read()) != -1)
40 {
41 outputStream.write(i);
42 }
43 logger.info("close stream");
44 outputStream.close();
45 }
46 catch (final IOException e)
47 {
48 logger.catching(e);
49 }
50 finally
51 {
52 endController.countDown();
53 }
54 logger.info("finished thread");
55 }
56
57 @Override
58 public final void encodeAndDecode(final InputStream inputStream, final OutputStream outputStream) throws JastacryException
59 {
60 throw new UnsupportedOperationException();
61 }
62
63
64
65
66
67
68 @Override
69 public final void init(final String data)
70 {
71
72 }
73
74
75
76
77
78
79 public boolean equals(final Object o)
80 {
81 return o == this || o instanceof ReadWriteLayer;
82 }
83
84
85
86
87
88 @Override
89 public int hashCode()
90 {
91 return Objects.hash();
92 }
93 }