java.lang.Object
io.sf.carte.uparser.CommentRemovalHandler
io.sf.carte.uparser.MinificationHandler
- All Implemented Interfaces:
- ContentHandler<RuntimeException>,- ControlHandler<RuntimeException>,- TokenErrorHandler<RuntimeException>,- TokenHandler2,- TokenHandler3<RuntimeException>
A handler that minifies by removing comments and consecutive whitespace.
 
Example:
 String minify(String text) {
     String[] opening = { "/*", "<!--" };
     String[] closing = { "*/", "-->" };
     MinificationHandler handler = new MinificationHandler(text.length());
     TokenProducer tp = new TokenProducer(handler);
     tp.setHandleAllSeparators(false);
     try {
         tp.parseMultiComment(new StringReader(text), opening, closing);
     } catch (IOException e) {
     }
     return handler.getBuffer().toString();
 }
 - 
Constructor SummaryConstructorsConstructorDescriptionMinificationHandler(int bufSize) Construct the handler with the given initial buffer size.MinificationHandler(StringBuilder buffer) Construct the handler with the given buffer.
- 
Method SummaryMethods inherited from class io.sf.carte.uparser.CommentRemovalHandlercharacter, commented, endOfStream, error, escaped, getBuffer, getPreviousCodepoint, leftCurlyBracket, leftParenthesis, leftSquareBracket, quoted, quotedNewlineChar, quotedWithControl, rightCurlyBracket, rightParenthesis, rightSquareBracket, setPreviousCodepoint, tokenStart, wordMethods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface io.sf.carte.uparser.TokenHandler2endPunctuation, startPunctuation
- 
Constructor Details- 
MinificationHandlerpublic MinificationHandler(int bufSize) Construct the handler with the given initial buffer size.- Parameters:
- bufSize- the initial buffer size.
 
- 
MinificationHandlerConstruct the handler with the given buffer.- Parameters:
- buffer- the buffer.
 
 
- 
- 
Method Details- 
separatorpublic void separator(int index, int codePoint) Description copied from interface:TokenHandler2A separator (Zs, Zl and Zp unicode categories) was found.- Specified by:
- separatorin interface- ContentHandler<RuntimeException>
- Specified by:
- separatorin interface- TokenHandler2
- Overrides:
- separatorin class- CommentRemovalHandler
- Parameters:
- index- the index at which the separator was found.
- codePoint- the codepoint of the found separator.
 
- 
controlpublic void control(int index, int codePoint) Description copied from interface:TokenHandler2A control character codepoint was found.- Specified by:
- controlin interface- ControlHandler<RuntimeException>
- Specified by:
- controlin interface- TokenHandler2
- Overrides:
- controlin class- CommentRemovalHandler
- Parameters:
- index- the index at which the control codepoint was found.
- codePoint- the control codepoint.
 
 
-