org.codehaus.groovy.grails.web.util
Class BoundedCharsAsEncodedBytesCounter

java.lang.Object
  extended by org.codehaus.groovy.grails.web.util.BoundedCharsAsEncodedBytesCounter

public class BoundedCharsAsEncodedBytesCounter
extends Object

Counts chars encoded as bytes up to a certain limit (capacity of byte buffer). size() returns the number of bytes, it will return -1 if the capacity was reached or an error occurred. this class is useful for calculating the content length of a HttpServletResponse before the response has been committed

Author:
Lari Hotari, Sagire Software Oy

Nested Class Summary
(package private)  class BoundedCharsAsEncodedBytesCounter.BoundedCharsAsEncodedBytesCounterWriter
           
 
Constructor Summary
BoundedCharsAsEncodedBytesCounter(int capacity, String encoding)
           
 
Method Summary
 Writer getCountingWriter()
           
 int size()
           
 void update(char[] buf)
           
 void update(char[] buf, int off, int len)
           
 void update(String str)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BoundedCharsAsEncodedBytesCounter

public BoundedCharsAsEncodedBytesCounter(int capacity,
                                         String encoding)
Method Detail

update

public void update(String str)

update

public void update(char[] buf)

update

public void update(char[] buf,
                   int off,
                   int len)

size

public int size()

getCountingWriter

public Writer getCountingWriter()


Copyright (c) 2005-2009 The Grails project