- java.lang.Object
-
- com.github.robtimus.servlet.ServletUtils
-
public final class ServletUtils extends Object
A utility class for servlets.- Author:
- Rob Spoor
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static ServletInputStream
transform(ServletInputStream input, com.github.robtimus.io.function.IOFunction<? super ServletInputStream,? extends InputStream> transformation)
Transforms aServletInputStream
into a differentServletInputStream
.static ServletOutputStream
transform(ServletOutputStream output, com.github.robtimus.io.function.IOFunction<? super ServletOutputStream,? extends OutputStream> transformation)
Transforms aServletOutputStream
into a differentServletOutputStream
.static BufferedReader
transform(BufferedReader input, com.github.robtimus.io.function.IOFunction<? super BufferedReader,? extends Reader> transformation)
Transforms aBufferedReader
into a differentBufferedReader
.static PrintWriter
transform(PrintWriter output, com.github.robtimus.io.function.IOFunction<? super PrintWriter,? extends Writer> transformation)
Transforms aPrintWriter
into a differentPrintWriter
.
-
-
-
Method Detail
-
transform
public static ServletInputStream transform(ServletInputStream input, com.github.robtimus.io.function.IOFunction<? super ServletInputStream,? extends InputStream> transformation) throws IOException
Transforms aServletInputStream
into a differentServletInputStream
.The given transformation does not necessarily need to return a
ServletInputStream
. If it returns anInputStream
that is not aServletInputStream
, it will be wrapped automatically in a newServletInputStream
.- Parameters:
input
- TheServletInputStream
to transform.transformation
- The transformation to apply.- Returns:
- A
ServletInputStream
that is the result of applying the given transformation to the givenServletInputStream
. - Throws:
NullPointerException
- If the givenServletInputStream
or transformation isnull
.IOException
- If an I/O error occurred during the transformation.
-
transform
public static BufferedReader transform(BufferedReader input, com.github.robtimus.io.function.IOFunction<? super BufferedReader,? extends Reader> transformation) throws IOException
Transforms aBufferedReader
into a differentBufferedReader
.The given transformation does not necessarily need to return a
BufferedReader
. If it returns aReader
that is not aBufferedReader
, it will be wrapped automatically in a newBufferedReader
.- Parameters:
input
- TheBufferedReader
to transform.transformation
- The transformation to apply.- Returns:
- A
BufferedReader
that is the result of applying the given transformation to the givenBufferedReader
. - Throws:
NullPointerException
- If the givenBufferedReader
or transformation isnull
.IOException
- If an I/O error occurred during the transformation.
-
transform
public static ServletOutputStream transform(ServletOutputStream output, com.github.robtimus.io.function.IOFunction<? super ServletOutputStream,? extends OutputStream> transformation) throws IOException
Transforms aServletOutputStream
into a differentServletOutputStream
.The given transformation does not necessarily need to return a
ServletOutputStream
. If it returns anOutputStream
that is not aServletOutputStream
, it will be wrapped automatically in a newServletOutputStream
.- Parameters:
output
- TheServletOutputStream
to transform.transformation
- The transformation to apply.- Returns:
- A
ServletOutputStream
that is the result of applying the given transformation to the givenServletOutputStream
. - Throws:
NullPointerException
- If the givenServletOutputStream
or transformation isnull
.IOException
- If an I/O error occurred during the transformation.
-
transform
public static PrintWriter transform(PrintWriter output, com.github.robtimus.io.function.IOFunction<? super PrintWriter,? extends Writer> transformation) throws IOException
Transforms aPrintWriter
into a differentPrintWriter
.The given transformation does not necessarily need to return a
PrintWriter
. If it returns aWriter
that is not aPrintWriter
, it will be wrapped automatically in a newPrintWriter
.- Parameters:
output
- ThePrintWriter
to transform.transformation
- The transformation to apply.- Returns:
- A
PrintWriter
that is the result of applying the given transformation to the givenPrintWriter
. - Throws:
NullPointerException
- If the givenPrintWriter
or transformation isnull
.IOException
- If an I/O error occurred during the transformation.
-
-