com.sun.grizzly.filter
Class CustomProtocolHelper

java.lang.Object
  extended by com.sun.grizzly.filter.CustomProtocolHelper

public class CustomProtocolHelper
extends Object

Varoius small ByteBuffer helpers for logging and ByteBuffer handling.

Version:
1.0
Author:
John Vieten 25.06.2008

Constructor Summary
CustomProtocolHelper()
           
 
Method Summary
static boolean byteBufferHasEnoughSpace(int neededBytes, ByteBuffer buf)
           
static ByteBuffer giveGrizzlyNewByteBuffer()
          Gives current Thread a completely new Bytebuffer of @see Message.MessageMaxLength
static void giveGrizzlyNewByteBuffer(ByteBuffer buf)
          Gives current Thread a completely new Bytebuffer of @see Message.MessageMaxLength with the given byteBuffer copied into it.
static boolean isPrintable(char c)
           
static void log(String msg)
           
static void logFine(String msg, Throwable t)
           
static Logger logger()
          Return the current Logger used Customprotocol.
static String printBuffer(String msg, ByteBuffer buffer)
          Print the contents of the buffer out to the PrintStream in hex and ASCII.
static ByteBuffer sliceBuffer(ByteBuffer byteBuffer, int start, int end)
           
static void startController(Controller controller)
           
static void stopController(Controller controller)
          Stop controller in seperate thread
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CustomProtocolHelper

public CustomProtocolHelper()
Method Detail

byteBufferHasEnoughSpace

public static boolean byteBufferHasEnoughSpace(int neededBytes,
                                               ByteBuffer buf)
Parameters:
neededBytes - number of bytes that the given buffer should be able to hold
buf - the bytebuffer which is queried for free space
Returns:
if buf can hold additinasl neededBytes

giveGrizzlyNewByteBuffer

public static ByteBuffer giveGrizzlyNewByteBuffer()
Gives current Thread a completely new Bytebuffer of @see Message.MessageMaxLength


giveGrizzlyNewByteBuffer

public static void giveGrizzlyNewByteBuffer(ByteBuffer buf)
Gives current Thread a completely new Bytebuffer of @see Message.MessageMaxLength with the given byteBuffer copied into it.

Parameters:
buf - the buffer which should be put into the newly created byteBuffer.

sliceBuffer

public static ByteBuffer sliceBuffer(ByteBuffer byteBuffer,
                                     int start,
                                     int end)

logger

public static Logger logger()
Return the current Logger used Customprotocol.


logFine

public static void logFine(String msg,
                           Throwable t)

log

public static void log(String msg)

printBuffer

public static String printBuffer(String msg,
                                 ByteBuffer buffer)
Print the contents of the buffer out to the PrintStream in hex and ASCII. Note this was taken from the java corba sources.

Parameters:
msg - The message to use as the header for this display
buffer - The ByteBuffer containing the data. The contents from 0 to buffer.position() are printed out. Remember to set position!

isPrintable

public static boolean isPrintable(char c)

startController

public static void startController(Controller controller)

stopController

public static void stopController(Controller controller)
Stop controller in seperate thread



Copyright © 2012 Oracle Corporation. All Rights Reserved.