Skip to content

Package: WriteOp

WriteOp

nameinstructionbranchcomplexitylinemethod
WriteOp(String, Object)
M: 6 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%
WriteOp(String, Object, ImageWriteParam)
M: 7 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%
WriteOp(String, Object, ImageWriteParam, IIOMetadata)
M: 50 C: 0
0%
M: 12 C: 0
0%
M: 7 C: 0
0%
M: 14 C: 0
0%
M: 1 C: 0
0%
WriteOp(String, String)
M: 8 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%
WriteOp(String, String, ImageWriteParam)
M: 9 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%
getFormat()
M: 3 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
getIIOMetadata()
M: 3 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
getImageWriteParam()
M: 3 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
getOutput()
M: 3 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
toString()
M: 16 C: 0
0%
M: 2 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%

Coverage

1: /*
2: * *********************************************************************************************************************
3: *
4: * Mistral: open source imaging engine
5: * http://tidalwave.it/projects/mistral
6: *
7: * Copyright (C) 2003 - 2023 by Tidalwave s.a.s. (http://tidalwave.it)
8: *
9: * *********************************************************************************************************************
10: *
11: * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
12: * the License. You may obtain a copy of the License at
13: *
14: * http://www.apache.org/licenses/LICENSE-2.0
15: *
16: * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
17: * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
18: * specific language governing permissions and limitations under the License.
19: *
20: * *********************************************************************************************************************
21: *
22: * git clone https://bitbucket.org/tidalwave/mistral-src
23: * git clone https://github.com/tidalwave-it/mistral-src
24: *
25: * *********************************************************************************************************************
26: */
27: package it.tidalwave.image.op;
28:
29: import java.io.File;
30: import java.io.OutputStream;
31: import java.nio.file.Path;
32: import javax.imageio.ImageWriteParam;
33: import javax.imageio.metadata.IIOMetadata;
34:
35: /***********************************************************************************************************************
36: *
37: * @author Fabrizio Giudici
38: *
39: **********************************************************************************************************************/
40: public class WriteOp extends Operation
41: {
42: private final String format;
43: private final Object output;
44: private final ImageWriteParam imageWriteParam;
45: private final IIOMetadata iioMetadata;
46:
47: /*******************************************************************************************************************
48: *
49: * Writes the image to a file.
50: *
51: * @param format the image format
52: * @param fileName the file name
53: *
54: ******************************************************************************************************************/
55: public WriteOp (final String format, final String fileName)
56: {
57: this(format, Path.of(fileName));
58: }
59:
60: /*******************************************************************************************************************
61: *
62: * Writes the image to a file.
63: *
64: * @param format the image format
65: * @param fileName the file name
66: * @param imageWriteParam the write parameters
67: *
68: ******************************************************************************************************************/
69: public WriteOp (final String format, final String fileName, final ImageWriteParam imageWriteParam)
70: {
71: this(format, Path.of(fileName), imageWriteParam);
72: }
73:
74: /*******************************************************************************************************************
75: *
76: * Writes the image to a Path or a OutputStream. In the latter case, note that
77: * the OutputStream is not closed.
78: *
79: * @param format the image format
80: * @param output the output object
81: *
82: ******************************************************************************************************************/
83: public WriteOp (final String format, final Object output)
84: {
85: this(format, output, null);
86: }
87:
88: /*******************************************************************************************************************
89: *
90: * Writes the image to a Path or a OutputStream. In the latter case, note that
91: * the OutputStream is not closed.
92: *
93: * @param format the image format
94: * @param output the output object
95: * @param imageWriteParam the write parameters
96: *
97: ******************************************************************************************************************/
98: public WriteOp (final String format, final Object output, final ImageWriteParam imageWriteParam)
99: {
100: this(format, output, imageWriteParam, null);
101: }
102:
103: /*******************************************************************************************************************
104: *
105: *
106: ******************************************************************************************************************/
107: public WriteOp (final String format,
108: Object output,
109: final ImageWriteParam imageWriteParam,
110: final IIOMetadata iioMetadata)
111: {
112:• if (format == null)
113: {
114: throw new IllegalArgumentException("null format");
115: }
116:
117:• if (output == null)
118: {
119: throw new IllegalArgumentException("null output");
120: }
121:
122:• if (!(output instanceof File) && !(output instanceof Path) && !(output instanceof OutputStream))
123: {
124: throw new IllegalArgumentException("output must be a File, a Path or a OutputStream");
125: }
126:
127:• if (output instanceof Path)
128: {
129: output = ((Path)output).toFile();
130: }
131:
132: this.format = format;
133: this.output = output;
134: this.imageWriteParam = imageWriteParam;
135: this.iioMetadata = iioMetadata;
136: }
137:
138: /*******************************************************************************************************************
139: *
140: *
141: ******************************************************************************************************************/
142: public String getFormat()
143: {
144: return format;
145: }
146:
147: /*******************************************************************************************************************
148: *
149: *
150: ******************************************************************************************************************/
151: public Object getOutput()
152: {
153: return output;
154: }
155:
156: /*******************************************************************************************************************
157: *
158: *
159: ******************************************************************************************************************/
160: public ImageWriteParam getImageWriteParam()
161: {
162: return imageWriteParam;
163: }
164:
165: /*******************************************************************************************************************
166: *
167: * Please note that this method is unsupported.
168: *
169: ******************************************************************************************************************/
170: public IIOMetadata getIIOMetadata()
171: {
172: return iioMetadata;
173: }
174:
175: /*******************************************************************************************************************
176: *
177: * {@inheritDoc}
178: *
179: ******************************************************************************************************************/
180: @Override
181: public String toString()
182: {
183:• return "WriteOp(" + format + ", " + ((output instanceof OutputStream) ? output.getClass() : output) + ", " +
184: imageWriteParam + ")";
185: }
186: }