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 public class RotateLayer extends AbstractBasicLayer
17 {
18
19
20
21
22 public static final String LAYERNAME = "Rotate Layer";
23
24
25
26
27 private int offset;
28
29
30
31
32 public RotateLayer()
33 {
34 super(RotateLayer.class, LAYERNAME);
35 }
36
37
38
39
40
41
42 @Override
43 public final void init(final String data)
44 {
45 this.offset = Integer.parseInt(data);
46 }
47
48
49
50
51
52
53
54
55 @Override
56 public final void encStream(final InputStream inputStream, final OutputStream outputStream) throws JastacryException
57 {
58 try
59 {
60 int iChar;
61 while ((iChar = inputStream.read()) != -1)
62 {
63 iChar += this.offset;
64 iChar = rangeCheck(iChar);
65 outputStream.write(iChar);
66 }
67 logger.info("close pipe");
68 outputStream.close();
69 }
70 catch (IOException e)
71 {
72 throw (JastacryExceptionl#JastacryException">JastacryException) new JastacryException("encStream failed").initCause(e);
73 }
74 }
75
76
77
78
79
80
81
82
83 @Override
84 public final void decStream(final InputStream inputStream, final OutputStream outputStream) throws JastacryException
85 {
86 try
87 {
88 int iChar;
89 while ((iChar = inputStream.read()) != -1)
90 {
91 iChar -= this.offset;
92 iChar = rangeCheck(iChar);
93 outputStream.write(iChar);
94 }
95 logger.info("close pipe");
96 outputStream.close();
97 }
98 catch (IOException e)
99 {
100 throw (JastacryExceptionl#JastacryException">JastacryException) new JastacryException("decStream failed").initCause(e);
101 }
102 }
103
104 @Override
105 public final void encodeAndDecode(final InputStream inputStream, final OutputStream outputStream) throws JastacryException
106 {
107 throw new UnsupportedOperationException();
108 }
109
110
111
112
113
114
115 @Override
116 public boolean equals(final Object o)
117 {
118 return o == this || o instanceof RotateLayer/org/jastacry/layer/RotateLayer.html#RotateLayer">RotateLayer && ((RotateLayer) o).offset == this.offset;
119 }
120
121
122
123
124
125 @Override
126 public int hashCode()
127 {
128 return Objects.hash(offset);
129 }
130 }