1 package org.apache.maven.doxia.wrapper;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import java.io.OutputStream;
23 import java.util.Objects;
24
25 import static org.codehaus.plexus.util.StringUtils.isEmpty;
26
27
28
29
30
31
32 public class OutputStreamWrapper
33 extends AbstractWrapper
34 {
35
36 static final long serialVersionUID = 3329037527245430610L;
37
38 private final OutputStream out;
39
40 private final String encoding;
41
42
43
44
45
46
47
48
49 private OutputStreamWrapper( OutputStream out, String format, String encoding, String[] supportedFormat )
50 {
51 super( format, supportedFormat );
52
53 if ( getFormat().equalsIgnoreCase( AUTO_FORMAT ) )
54 {
55 throw new IllegalArgumentException( "output format is required" );
56 }
57
58 this.out = out;
59 this.encoding = encoding;
60 }
61
62
63
64
65 public OutputStream getOutputStream()
66 {
67 return this.out;
68 }
69
70
71
72
73 public String getEncoding()
74 {
75 return encoding;
76 }
77
78
79
80
81
82
83
84
85 public static OutputStreamWrapper valueOf( OutputStream out, String format, String encoding,
86 String[] supportedFormat )
87 {
88 Objects.requireNonNull( out, "output writer is required" );
89 if ( isEmpty( format ) )
90 {
91 throw new IllegalArgumentException( "output format is required" );
92 }
93
94 return new OutputStreamWrapper( out, format, encoding, supportedFormat );
95 }
96 }