org.hd.d.pg2k.webSvr.util
Class XMLCompressionFilter

java.lang.Object
  extended by org.hd.d.pg2k.webSvr.util.XMLCompressionFilter
All Implemented Interfaces:
javax.servlet.Filter

public final class XMLCompressionFilter
extends java.lang.Object
implements javax.servlet.Filter

Compresses XML by removing redundant whitespace (etc). Should quickly reduce the size of many XML documents on the fly without changing their semantics.

This will allow document streaming (ie incremental processing) and will support flush() to allow the push of partial documents, although this may not be able to push partial XML atoms (eg partial elements and entities).

To avoid upsetting some older consumers of XML, such as old mobile phones and PDAs, this may avoid some transformations such as <x></x> to <x/>.

To avoid upsetting older HTML consumers of XHTML this may avoid some transformations such as <br /> to <br/>.


Field Summary
private  javax.servlet.FilterConfig config
          The filter configuration object we are associated with.
private  WebUtils.ServletLoggerWithFallback logger
          Our logger which falls back to System.out if servlet log not available; never null.
 
Constructor Summary
XMLCompressionFilter()
           
 
Method Summary
 void destroy()
          Take this filter out of service.
 void doFilter(javax.servlet.ServletRequest request, javax.servlet.ServletResponse response, javax.servlet.FilterChain chain)
          Compacts the (XML) reponse text when possible.
 javax.servlet.FilterConfig getFilterConfig()
           
 void init(javax.servlet.FilterConfig filterConfig)
          Place this filter into service.
 void setFilterConfig(javax.servlet.FilterConfig c)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

private final WebUtils.ServletLoggerWithFallback logger
Our logger which falls back to System.out if servlet log not available; never null.


config

private javax.servlet.FilterConfig config
The filter configuration object we are associated with. If this value is null, this filter instance is not currently configured.

Constructor Detail

XMLCompressionFilter

public XMLCompressionFilter()
Method Detail

getFilterConfig

public javax.servlet.FilterConfig getFilterConfig()

setFilterConfig

public void setFilterConfig(javax.servlet.FilterConfig c)

init

public void init(javax.servlet.FilterConfig filterConfig)
Place this filter into service.

Specified by:
init in interface javax.servlet.Filter
Parameters:
filterConfig - filter configuration object; null to unset

destroy

public void destroy()
Take this filter out of service.

Specified by:
destroy in interface javax.servlet.Filter

doFilter

public void doFilter(javax.servlet.ServletRequest request,
                     javax.servlet.ServletResponse response,
                     javax.servlet.FilterChain chain)
              throws java.io.IOException,
                     javax.servlet.ServletException
Compacts the (XML) reponse text when possible.

Specified by:
doFilter in interface javax.servlet.Filter
Throws:
java.io.IOException
javax.servlet.ServletException

DHD Multimedia Gallery V1.57.21

Copyright (c) 1996-2011, Damon Hart-Davis. All rights reserved.