01: package uk.org.ponder.byteutil;
02:
03: /** A ByteWrap class that allows a little extra "air". Its sole action is to override the
04: * <code>ensureCapacity</code> method so it reserves a specified amount of extra space
05: * whenever it is called upon, in addition to the amount explicitly requested.
06: * The amount of extra space to be reserved is set by a call to the <code>setAir</code> method.
07: */
08:
09: public class AirByteWrap extends ByteWrap {
10: private int air;
11:
12: /** Sets the amount of extra space to be reserved by a call to <code>ensureCapacity</code>.
13: * @param air The amount of extra space to be reserved.
14: */
15: public void setAir(int air) {
16: this .air = air;
17: }
18:
19: /** This method is overridden from <code>ByteWrap</code> to reserve extra space
20: * as specified to <code>setAir</code>.
21: * @param capacity The capacity explicitly requested.
22: */
23: public void ensureCapacity(int capacity) {
24: super.ensureCapacity(capacity + air);
25: size = capacity;
26: }
27: }
|