package net.acomputerdog.core.java;

public class MemBuffer {
    private static final int DEFAULT_BUFFER_SIZE = 1000000;

    private byte[] buffer = null;

    public void createBuffer(int size) {
        if (!isAllocated()) {
            buffer = new byte[size];
        }
    }

    public void createBuffer() {
        createBuffer(DEFAULT_BUFFER_SIZE);
    }

    public void destroyBuffer() {
        buffer = null;
    }

    public void freeBuffer() {
        destroyBuffer();
        System.gc();
    }

    public void resetBuffer(int size) {
        freeBuffer();
        createBuffer(size);
    }

    public void resetBuffer() {
        resetBuffer(DEFAULT_BUFFER_SIZE);
    }

    public boolean isAllocated() {
        return buffer != null;
    }

    public int getBufferSize() {
        return buffer == null ? 0 : buffer.length;
    }
}

@@ -34,157 +34,477 @@
 a;%0A%0A
-public class MemBuffer %7B%0A    private static final int DEFAULT_BUFFER_SIZE = 1000000;%0A%0A    private byte%5B%5D buffer = null;%0A%0A    public void createBuffer
+/**%0A * A class used to create a %22buffer%22 of allocated heap memory.%0A */%0Apublic class MemBuffer %7B%0A    /**%0A     * Default amount of memory to buffer (1MB)%0A     */%0A    private static final int DEFAULT_BUFFER_SIZE = 1000000;%0A%0A    /**%0A     * The actual buffer%0A     */%0A    private byte%5B%5D buffer = null;%0A%0A    /**%0A     * Allocate a buffer of the specified size, if a buffer does not already exist%0A     *%0A     * @param size The size of the buffer%0A     */%0A    public void allocate
 (int
@@ -604,32 +604,76 @@
     
-public void createBuffer
+/**%0A     * Allocate a buffer of 1MB%0A     */%0A    public void allocate
 () %7B
@@ -681,28 +681,24 @@
         
-createBuffer
+allocate
 (DEFAULT
@@ -711,32 +711,137 @@
 R_SIZE);%0A    %7D%0A%0A
+    /**%0A     * Deallocates the buffer.  Does not automatically free memory, but does mark for GC%0A     */%0A
     public void 
@@ -842,27 +842,24 @@
  void de
-stroyBuffer
+allocate
 () %7B%0A   
@@ -877,32 +877,98 @@
  = null;%0A    %7D%0A%0A
+    /**%0A     * Deallocate the buffer and trigger full GC.%0A     */%0A
     public void 
@@ -971,22 +971,16 @@
 oid free
-Buffer
 () %7B%0A   
@@ -990,19 +990,16 @@
   de
-stroyBuffer
+allocate
 ();%0A
@@ -1018,32 +1018,151 @@
 em.gc();%0A    %7D%0A%0A
+    /**%0A     * Frees the buffer and reallocates a new one%0A     *%0A     * @param size The size of the new buffer%0A     */%0A
     public void 
@@ -1166,22 +1166,16 @@
 id reset
-Buffer
 (int siz
@@ -1195,52 +1195,467 @@
 free
-Buffer();%0A        createBuffer(size);%0A    %7D%0A
+();%0A        allocate(size);%0A    %7D%0A%0A    /**%0A     * Frees the buffer and reallocates one of 1MB%0A     */%0A    public void reset() %7B%0A        reset(DEFAULT_BUFFER_SIZE);%0A    %7D%0A%0A    /**%0A     * Deallocates the buffer and reallocates a new one%0A     *%0A     * @param size The size of the new buffer%0A     */%0A    public void resetQuick(int size) %7B%0A        deallocate();%0A        allocate(size);%0A    %7D%0A%0A    /**%0A     * Deallocates the buffer and reallocates on of 1MB%0A     */
 %0A   
@@ -1672,22 +1672,21 @@
 id reset
-Buffer
+Quick
 () %7B%0A   
@@ -1695,22 +1695,21 @@
    reset
-Buffer
+Quick
 (DEFAULT
@@ -1738,76 +1738,385 @@
     
-public boolean isAllocated() %7B%0A        return buffer != null;%0A    %7D%0A
+/**%0A     * Checks if this MemBuffer currently has an allocated buffer%0A     * @return Return true if this MemBuffer has an active buffer.%0A     */%0A    public boolean isAllocated() %7B%0A        return buffer != null;%0A    %7D%0A%0A    /**%0A     * Gets the size of the allocated buffer (in bytes)%0A     * @return Return the size of the allocated buffer, or 0 if no buffer is allocated.%0A     */
 %0A   

Comment and rename methods in MemBuffer