Package org.restheart.utils
Class Minify
- java.lang.Object
-
- org.restheart.utils.Minify
-
public class Minify extends Object
Minify.java is written by Charles Bihis (www.whoischarles.com) and is adapted from JSMin.java written by John Reilly (www.inconspicuous.org) which is itself a translation of jsmin.c written by Douglas Crockford (www.crockford.com).
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classMinify.Actionstatic classMinify.UnterminatedCommentExceptionException to be thrown when an unterminated comment appears in the input.static classMinify.UnterminatedRegExpLiteralExceptionException to be thrown when an unterminated regular expression literal appears in the input.static classMinify.UnterminatedStringLiteralExceptionException to be thrown when an unterminated string literal appears in the input.
-
Constructor Summary
Constructors Constructor Description Minify()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidminify(InputStream in, OutputStream out)Takes an input stream to a JSON string and outputs minified JSON to the output stream.Stringminify(String json)Minifies the input JSON string.
-
-
-
Method Detail
-
minify
public String minify(String json)
Minifies the input JSON string. Takes the input JSON string and deletes the characters which are insignificant to JavaScipt. Comments will be removed, tabs will be replaced with spaces, carriage returns will be replaced with line feeds, and most spaces and line feeds will be removed. The result will be returned.- Parameters:
json- The JSON string for which to minify- Returns:
- A minified, yet functionally identical, version of the input JSON string
-
minify
public void minify(InputStream in, OutputStream out) throws IOException, Minify.UnterminatedRegExpLiteralException, Minify.UnterminatedCommentException, Minify.UnterminatedStringLiteralException
Takes an input stream to a JSON string and outputs minified JSON to the output stream. Takes the input JSON via the input stream and deletes the characters which are insignificant to JavaScript. Comments will be removed, tabs will be replaced with spaaces, carriage returns will be replaced with line feeds, and most spaces and line feeds will be removed. The result is streamed to the output stream.- Parameters:
in- TheInputStreamfrom which to get the un-minified JSONout- TheOutputStreamwhere the resulting minified JSON will be streamed to- Throws:
IOExceptionMinify.UnterminatedRegExpLiteralExceptionMinify.UnterminatedCommentExceptionMinify.UnterminatedStringLiteralException
-
-