Package zmq
Class Msg
- java.lang.Object
-
- zmq.Msg
-
- Direct Known Subclasses:
Msg.Builder
public class Msg extends java.lang.Object
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
Msg.Builder
(package private) static class
Msg.Type
-
Field Summary
Fields Modifier and Type Field Description private java.nio.ByteBuffer
buf
static int
COMMAND
static int
CREDENTIAL
private java.nio.channels.SocketChannel
fileDesc
private int
flags
static int
IDENTITY
private Metadata
metadata
static int
MORE
private int
readIndex
static int
SHARED
private int
size
private Msg.Type
type
private int
writeIndex
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.nio.ByteBuffer
buf()
boolean
check()
byte[]
data()
Returns the message data.java.nio.channels.SocketChannel
fd()
int
flags()
byte
get()
byte
get(int index)
int
getBytes(int index, byte[] dst, int off, int len)
int
getBytes(int index, java.nio.ByteBuffer bb, int len)
int
getInt(int offset)
long
getLong(int offset)
Metadata
getMetadata()
int
getShort(int offset)
protected int
getWriteIndex()
boolean
hasMore()
void
initDelimiter()
boolean
isCommand()
boolean
isCredential()
boolean
isDelimiter()
boolean
isIdentity()
Msg
put(byte b)
Msg
put(byte[] src)
Msg
put(byte[] src, int off, int len)
Msg
put(int b)
protected Msg
put(int index, byte b)
Msg
put(java.nio.ByteBuffer src)
Msg
put(java.nio.ByteBuffer src, int off, int len)
Msg
putShortString(java.lang.String data)
Puts a string into the message, prefixed with its length.void
resetFlags(int f)
void
resetMetadata()
void
setFd(java.nio.channels.SocketChannel fileDesc)
void
setFlags(int flags)
Msg
setMetadata(Metadata metadata)
protected void
setWriteIndex(int writeIndex)
int
size()
java.lang.String
toString()
void
transfer(java.nio.ByteBuffer destination, int srcOffset, int srcLength)
-
-
-
Field Detail
-
MORE
public static final int MORE
- See Also:
- Constant Field Values
-
COMMAND
public static final int COMMAND
- See Also:
- Constant Field Values
-
CREDENTIAL
public static final int CREDENTIAL
- See Also:
- Constant Field Values
-
IDENTITY
public static final int IDENTITY
- See Also:
- Constant Field Values
-
SHARED
public static final int SHARED
- See Also:
- Constant Field Values
-
metadata
private Metadata metadata
-
flags
private int flags
-
type
private Msg.Type type
-
fileDesc
private java.nio.channels.SocketChannel fileDesc
-
size
private final int size
-
buf
private final java.nio.ByteBuffer buf
-
writeIndex
private int writeIndex
-
readIndex
private int readIndex
-
-
Method Detail
-
isIdentity
public boolean isIdentity()
-
isDelimiter
public boolean isDelimiter()
-
check
public boolean check()
-
flags
public int flags()
-
hasMore
public boolean hasMore()
-
isCommand
public boolean isCommand()
-
isCredential
public boolean isCredential()
-
setFlags
public void setFlags(int flags)
-
initDelimiter
public void initDelimiter()
-
data
public byte[] data()
Returns the message data. If possible, a reference to the data is returned, without copy. Otherwise a new byte array will be allocated and the data will be copied.- Returns:
- the message data.
-
buf
public java.nio.ByteBuffer buf()
-
size
public int size()
-
resetFlags
public void resetFlags(int f)
-
setFd
public void setFd(java.nio.channels.SocketChannel fileDesc)
-
fd
public java.nio.channels.SocketChannel fd()
-
getMetadata
public Metadata getMetadata()
-
resetMetadata
public void resetMetadata()
-
get
public byte get()
-
get
public byte get(int index)
-
put
public Msg put(byte b)
-
put
public Msg put(int b)
-
put
protected Msg put(int index, byte b)
-
put
public Msg put(byte[] src)
-
put
public Msg put(byte[] src, int off, int len)
-
put
public Msg put(java.nio.ByteBuffer src, int off, int len)
-
put
public Msg put(java.nio.ByteBuffer src)
-
getBytes
public int getBytes(int index, byte[] dst, int off, int len)
-
getBytes
public int getBytes(int index, java.nio.ByteBuffer bb, int len)
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
getWriteIndex
protected final int getWriteIndex()
-
setWriteIndex
protected final void setWriteIndex(int writeIndex)
-
getLong
public long getLong(int offset)
-
getInt
public int getInt(int offset)
-
getShort
public int getShort(int offset)
-
transfer
public void transfer(java.nio.ByteBuffer destination, int srcOffset, int srcLength)
-
putShortString
public Msg putShortString(java.lang.String data)
Puts a string into the message, prefixed with its length. Users shall size the message by adding 1 to the length of the string: It needs to be able to accommodate (data.length+1) more bytes.- Parameters:
data
- a string shorter than 256 characters. If null, defaults to a no-op.- Returns:
- the same message.
-
-