gov.nasa.worldwind.util
Class BufferStateHandler
java.lang.Object
gov.nasa.worldwind.util.BufferStateHandler
public class BufferStateHandler
- extends java.lang.Object
BufferStateHandler is a utility class which encapsulates the common pattern of saving and restoring the essential
mutable properties of a Buffer: its position and limit.
BufferStateHandler saves and restores Buffer properties on an internal stack, enabling the caller to save and restore
a nested series of Buffer states. Here is a typical usage pattern for BufferStateHandler:
Buffer myBuffer;
BufferStateHandler bsh = new BufferStateHandler();
bsh.pushState(myBuffer);
try
{
  // Perform the desired operations on myBuffer.
}
finally
{
  bsh.popState(myBuffer);
}
|
Constructor Summary |
BufferStateHandler()
Constructs a new BufferStateHandler, initializing its internal stack. |
|
Method Summary |
boolean |
popState(java.nio.Buffer buffer)
Pop the state off the top of this BufferStateHandler's internal stack and apply it to the specified buffer's,
decrementing the stack size by one. |
void |
pushState(java.nio.Buffer buffer)
Push the specified buffer's state to the top of this BufferStateHandler's internal stack, incrementing the stack
size by one. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
stack
protected java.util.ArrayList<BufferStateHandler.BufferState> stack
BufferStateHandler
public BufferStateHandler()
- Constructs a new BufferStateHandler, initializing its internal stack.
popState
public boolean popState(java.nio.Buffer buffer)
- Pop the state off the top of this BufferStateHandler's internal stack and apply it to the specified buffer's,
decrementing the stack size by one. If the stack is empty, this returns false.
- Parameters:
buffer - the buffer who's state is restored from the top of the stack.
- Returns:
- true if the stack had at least one state to pop, and false otherwise.
- Throws:
java.lang.IllegalArgumentException - if buffer is null.
pushState
public void pushState(java.nio.Buffer buffer)
- Push the specified buffer's state to the top of this BufferStateHandler's internal stack, incrementing the stack
size by one.
- Parameters:
buffer - the buffer who's state is saved to the top of the stack.
- Throws:
java.lang.IllegalArgumentException - if buffer is null.