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 ReverseLayer extends AbstractBasicLayer
18 {
19
20
21
22 private static final int SHIFTBITS = 24;
23
24
25
26
27 private static final int MASKBITS = 0x00000FF;
28
29
30
31
32 public static final String LAYERNAME = "Reverse Layer";
33
34
35
36
37 public ReverseLayer()
38 {
39 super(ReverseLayer.class, LAYERNAME);
40 }
41
42
43
44
45
46
47 @Override
48 public final void init(final String data)
49 {
50
51 }
52
53
54
55
56
57
58
59
60 public final void encodeAndDecode(final InputStream inputStream, final OutputStream outputStream) throws JastacryException
61 {
62 try
63 {
64 int iChar;
65 while ((iChar = inputStream.read()) != -1)
66 {
67 iChar = rangeCheck(iChar);
68 iChar = Integer.reverse(iChar);
69 iChar >>= SHIFTBITS;
70 iChar &= MASKBITS;
71 outputStream.write(iChar);
72 }
73 logger.info("close pipe");
74 outputStream.close();
75 }
76 catch (IOException e)
77 {
78 throw (JastacryExceptionl#JastacryException">JastacryException) new JastacryException("encodeAndDecode failed").initCause(e);
79 }
80 }
81
82
83
84
85
86
87 @Override
88 public boolean equals(final Object o)
89 {
90 return o == this || o instanceof ReverseLayer;
91 }
92
93
94
95
96
97 @Override
98 public int hashCode()
99 {
100 return Objects.hash();
101 }
102 }