- 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 ServletInputStreamtransform(ServletInputStream input, com.github.robtimus.io.function.IOFunction<? super ServletInputStream,? extends InputStream> transformation)Transforms aServletInputStreaminto a differentServletInputStream.static ServletOutputStreamtransform(ServletOutputStream output, com.github.robtimus.io.function.IOFunction<? super ServletOutputStream,? extends OutputStream> transformation)Transforms aServletOutputStreaminto a differentServletOutputStream.static BufferedReadertransform(BufferedReader input, com.github.robtimus.io.function.IOFunction<? super BufferedReader,? extends Reader> transformation)Transforms aBufferedReaderinto a differentBufferedReader.static PrintWritertransform(PrintWriter output, com.github.robtimus.io.function.IOFunction<? super PrintWriter,? extends Writer> transformation)Transforms aPrintWriterinto 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 aServletInputStreaminto a differentServletInputStream.The given transformation does not necessarily need to return a
ServletInputStream. If it returns anInputStreamthat is not aServletInputStream, it will be wrapped automatically in a newServletInputStream.- Parameters:
input- TheServletInputStreamto transform.transformation- The transformation to apply.- Returns:
- A
ServletInputStreamthat is the result of applying the given transformation to the givenServletInputStream. - Throws:
NullPointerException- If the givenServletInputStreamor 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 aBufferedReaderinto a differentBufferedReader.The given transformation does not necessarily need to return a
BufferedReader. If it returns aReaderthat is not aBufferedReader, it will be wrapped automatically in a newBufferedReader.- Parameters:
input- TheBufferedReaderto transform.transformation- The transformation to apply.- Returns:
- A
BufferedReaderthat is the result of applying the given transformation to the givenBufferedReader. - Throws:
NullPointerException- If the givenBufferedReaderor 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 aServletOutputStreaminto a differentServletOutputStream.The given transformation does not necessarily need to return a
ServletOutputStream. If it returns anOutputStreamthat is not aServletOutputStream, it will be wrapped automatically in a newServletOutputStream.- Parameters:
output- TheServletOutputStreamto transform.transformation- The transformation to apply.- Returns:
- A
ServletOutputStreamthat is the result of applying the given transformation to the givenServletOutputStream. - Throws:
NullPointerException- If the givenServletOutputStreamor 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 aPrintWriterinto a differentPrintWriter.The given transformation does not necessarily need to return a
PrintWriter. If it returns aWriterthat is not aPrintWriter, it will be wrapped automatically in a newPrintWriter.- Parameters:
output- ThePrintWriterto transform.transformation- The transformation to apply.- Returns:
- A
PrintWriterthat is the result of applying the given transformation to the givenPrintWriter. - Throws:
NullPointerException- If the givenPrintWriteror transformation isnull.IOException- If an I/O error occurred during the transformation.
-
-