Class | Line # | Actions | |||||
---|---|---|---|---|---|---|---|
BinaryStringEncoder | 37 | 0 | - | 0 | 0 |
1 | /* | |
2 | * See the NOTICE file distributed with this work for additional | |
3 | * information regarding copyright ownership. | |
4 | * | |
5 | * This is free software; you can redistribute it and/or modify it | |
6 | * under the terms of the GNU Lesser General Public License as | |
7 | * published by the Free Software Foundation; either version 2.1 of | |
8 | * the License, or (at your option) any later version. | |
9 | * | |
10 | * This software is distributed in the hope that it will be useful, | |
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
13 | * Lesser General Public License for more details. | |
14 | * | |
15 | * You should have received a copy of the GNU Lesser General Public | |
16 | * License along with this software; if not, write to the Free | |
17 | * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA | |
18 | * 02110-1301 USA, or see the FSF site: http://www.fsf.org. | |
19 | */ | |
20 | package org.xwiki.crypto; | |
21 | ||
22 | import java.io.FilterInputStream; | |
23 | import java.io.FilterOutputStream; | |
24 | import java.io.IOException; | |
25 | import java.io.InputStream; | |
26 | import java.io.OutputStream; | |
27 | ||
28 | import org.xwiki.component.annotation.Role; | |
29 | ||
30 | /** | |
31 | * Encoder to encode binary data to string data. | |
32 | * | |
33 | * @version $Id: 1d6fd3586b24ac7b5b477cecbb94c9c8eb6969e6 $ | |
34 | * @since 5.4M1 | |
35 | */ | |
36 | @Role | |
37 | public interface BinaryStringEncoder | |
38 | { | |
39 | /** | |
40 | * Return a decoding input stream based on this encoder. | |
41 | * | |
42 | * @param is an input stream to filter. | |
43 | * @return a filtered input stream based on this encoder. | |
44 | */ | |
45 | FilterInputStream getDecoderInputStream(InputStream is); | |
46 | ||
47 | /** | |
48 | * Return a encoding output stream based on this encoder. | |
49 | * | |
50 | * @param os an output stream to filter. | |
51 | * @return a filtered output stream based on this encoder. | |
52 | */ | |
53 | FilterOutputStream getEncoderOutputStream(OutputStream os); | |
54 | ||
55 | /** | |
56 | * Return a encoding output stream based on this encoder, wrapping lines at a fixed length. | |
57 | * | |
58 | * @param os an output stream to filter. | |
59 | * @param wrapAt maximum length of a line. | |
60 | * @return a filtered output stream based on this encoder. | |
61 | */ | |
62 | FilterOutputStream getEncoderOutputStream(OutputStream os, int wrapAt); | |
63 | ||
64 | /** | |
65 | * Encode input with this encoder and without any wrapping. | |
66 | * | |
67 | * @param input a byte array. | |
68 | * @return a string representing the encoded byte array. | |
69 | * @throws IOException on error. | |
70 | */ | |
71 | String encode(byte[] input) throws IOException; | |
72 | ||
73 | /** | |
74 | * Encode input with this encoder, wrapping line at a fixed length. | |
75 | * | |
76 | * @param input a byte array. | |
77 | * @param wrapAt maximum length of a line. | |
78 | * @return a string representing the encoded byte array. | |
79 | * @throws IOException on error. | |
80 | */ | |
81 | String encode(byte[] input, int wrapAt) throws IOException; | |
82 | ||
83 | /** | |
84 | * Encode input with this encoder and without any wrapping. | |
85 | * | |
86 | * @param input a byte array. | |
87 | * @param off offset to start with in the byte array. | |
88 | * @param len to encode in the byte array. | |
89 | * @return a string representing the encoded byte array. | |
90 | * @throws IOException on error. | |
91 | */ | |
92 | String encode(byte[] input, int off, int len) throws IOException; | |
93 | ||
94 | /** | |
95 | * Encode input with this encoder, wrapping line at a fixed length. | |
96 | * | |
97 | * @param input a byte array. | |
98 | * @param off offset to start with in the byte array. | |
99 | * @param len to encode in the byte array. | |
100 | * @param wrapAt maximum length of a line. | |
101 | * @return a string representing the encoded byte array. | |
102 | * @throws IOException on error. | |
103 | */ | |
104 | String encode(byte[] input, int off, int len, int wrapAt) throws IOException; | |
105 | ||
106 | /** | |
107 | * Decode input string to bytes, whitespace and line-feed are ignored. | |
108 | * | |
109 | * @param input a string to decode. | |
110 | * @return a bytes array. | |
111 | * @throws IOException on error. | |
112 | */ | |
113 | byte[] decode(String input) throws IOException; | |
114 | } |