|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.jlab.coda.cMsg.cMsgUtilities
public class cMsgUtilities
This class stores methods which are neatly self-contained and may be used in more that one place.
Constructor Summary | |
---|---|
cMsgUtilities()
|
Method Summary | |
---|---|
static int |
bytesToInt(byte[] b,
int off)
Converts 4 bytes of a byte array into an integer. |
static long |
bytesToLong(byte[] b,
int off)
Converts 8 bytes of a byte array into a long. |
static short |
bytesToShort(byte[] b,
int off)
Converts 2 bytes of a byte array into a short. |
static java.lang.String |
constructServerName(java.lang.String s)
This method tests its input argument to see if it is in the proper format for a server; namely, "host:port". |
static void |
intToBytes(int intVal,
byte[] b,
int off)
Copies an integer value into 4 bytes of a byte array. |
static boolean |
isHostLocal(java.lang.String hostName)
Determine whether a given host name refers to the local host. |
static boolean |
isHostSame(java.lang.String hostName1,
java.lang.String hostName2)
Determine whether two given host names refers to the same host. |
static java.lang.String |
printError(int error,
int debug)
Method that returns and/or prints an error explanation. |
static int |
readSocketBytes(java.nio.ByteBuffer buffer,
java.nio.channels.SocketChannel channel,
int bytes,
int debug)
This methods reads a minimum of number of bytes from a channel into a buffer. |
static int |
readSocketBytesPlain(java.nio.ByteBuffer buffer,
java.nio.channels.SocketChannel channel,
int bytes)
This methods reads a minimum of number of bytes from a channel into a buffer. |
static void |
shortToBytes(short val,
byte[] b,
int off)
Copies a short value into 2 bytes of a byte array. |
static java.nio.channels.ByteChannel |
wrapChannel(java.nio.channels.ByteChannel channel)
This method wraps a SocketChannel so that the input and output streams derived from that channel do not block each other (SUN java bug id 4774871). |
static java.nio.channels.ByteChannel |
wrapChannel2(java.nio.channels.ByteChannel channel)
|
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public cMsgUtilities()
Method Detail |
---|
public static final int bytesToInt(byte[] b, int off)
b
- byte arrayoff
- offset into the byte array (0 = start at first element)
public static final void intToBytes(int intVal, byte[] b, int off)
intVal
- integer valueb
- byte arrayoff
- offset into the byte arraypublic static final short bytesToShort(byte[] b, int off)
b
- byte arrayoff
- offset into the byte array (0 = start at first element)
public static final void shortToBytes(short val, byte[] b, int off)
val
- short valueb
- byte arrayoff
- offset into the byte arraypublic static final long bytesToLong(byte[] b, int off)
b
- byte arrayoff
- offset into the byte array (0 = start at first element)
public static final boolean isHostLocal(java.lang.String hostName)
hostName
- host name that is checked to see if its local or notpublic static final boolean isHostSame(java.lang.String hostName1, java.lang.String hostName2)
hostName1
- host name that is checked to see if it is the same as the other arg or not.hostName2
- host name that is checked to see if it is the same as the other arg or not.public static final java.nio.channels.ByteChannel wrapChannel2(java.nio.channels.ByteChannel channel)
public static final java.nio.channels.ByteChannel wrapChannel(java.nio.channels.ByteChannel channel)
channel
- the SelectableChannel which has sync problems
public static final int readSocketBytesPlain(java.nio.ByteBuffer buffer, java.nio.channels.SocketChannel channel, int bytes) throws java.io.IOException
buffer
- a byte buffer which channel data is read intochannel
- nio socket communication channelbytes
- minimum number of bytes to read from channel
java.io.IOException
- If channel is closed or cannot be read frompublic static final int readSocketBytes(java.nio.ByteBuffer buffer, java.nio.channels.SocketChannel channel, int bytes, int debug) throws java.io.IOException
buffer
- a byte buffer which channel data is read intochannel
- nio socket communication channelbytes
- minimum number of bytes to read from channeldebug
- level of debug output
java.io.IOException
- If channel is closed or cannot be read frompublic static final java.lang.String printError(int error, int debug)
error
- error numberdebug
- level of debug output
public static final java.lang.String constructServerName(java.lang.String s) throws cMsgException
s
- input string of a possible server name
cMsgException
- if input string is not in the proper form (host:port)
or the host is unknown
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |