org.zeromq
类 ZFrame

java.lang.Object
  继承者 org.zeromq.ZFrame

public class ZFrame
extends java.lang.Object

ZFrame The ZFrame class provides methods to send and receive single message frames across 0MQ sockets. A 'frame' corresponds to one underlying zmq_msg_t in the libzmq code. When you read a frame from a socket, the more() method indicates if the frame is part of an unfinished multipart message. The send() method normally destroys the frame, but with the ZFRAME_REUSE flag, you can send the same frame many times. Frames are binary, and this class has no special support for text data. Based on zframe.c in


构造方法摘要
ZFrame()
           
ZFrame(byte[] data)
           
ZFrame(java.nio.ByteBuffer buffer)
           
ZFrame(java.lang.String data)
           
 
方法摘要
 int capacity()
           
 void destroy()
          Destructor.
 ZFrame duplicate()
          Creates a new frame that duplicates an existing frame
 boolean equals(java.lang.Object o)
           
 byte[] getData()
           
 boolean hasData()
          Convenience method to ascertain if this frame contains some message data
 int hashCode()
           
 boolean hasMore()
           
static ZFrame recvFrame(ZMQ.Socket socket)
          Receives single frame from socket, returns the received frame object, or null if the recv was interrupted.
static ZFrame recvFrame(ZMQ.Socket socket, int flags)
          Receive a new frame off the socket, Returns newly-allocated frame, or null if there was no input waiting, or if the read was interrupted.
 void reset(byte[] data)
          Sets new contents for frame
 void reset(java.lang.String data)
          Sets new contents for frame
 boolean send(ZMQ.Socket socket, int flags)
          Method to call org.zeromq.Socket send() method.
 int size()
          Returns byte size of frame, if set, else 0
 boolean streq(java.lang.String str)
          String equals.
 java.lang.String strhex()
          Returns frame data as a printable hex string
 java.lang.String toString()
          Returns a human - readable representation of frame's data
 
从类 java.lang.Object 继承的方法
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

构造方法详细信息

ZFrame

public ZFrame()

ZFrame

public ZFrame(byte[] data)

ZFrame

public ZFrame(java.nio.ByteBuffer buffer)

ZFrame

public ZFrame(java.lang.String data)
方法详细信息

capacity

public int capacity()

destroy

public void destroy()
Destructor.


getData

public byte[] getData()
返回:
the data

hasMore

public boolean hasMore()
返回:
More flag, true if last read had MORE message parts to come

size

public int size()
Returns byte size of frame, if set, else 0

返回:
Number of bytes in frame data, else 0

hasData

public boolean hasData()
Convenience method to ascertain if this frame contains some message data

返回:
True if frame contains data

send

public boolean send(ZMQ.Socket socket,
                    int flags)
Method to call org.zeromq.Socket send() method.

参数:
socket - 0MQ socket to send on
flags - Valid send() method flags, defined in org.zeromq.ZMQ class
返回:
True if success, else False

duplicate

public ZFrame duplicate()
Creates a new frame that duplicates an existing frame

返回:
Duplicate of frame; message contents copied into new byte array

reset

public void reset(byte[] data)
Sets new contents for frame

参数:
data - New byte array contents for frame

reset

public void reset(java.lang.String data)
Sets new contents for frame

参数:
data - String contents for frame

strhex

public java.lang.String strhex()
Returns frame data as a printable hex string

返回:

streq

public boolean streq(java.lang.String str)
String equals. Uses String compareTo for the comparison (lexigraphical)

参数:
str - String to compare with frame data
返回:
True if frame body data matches given string

equals

public boolean equals(java.lang.Object o)
覆盖:
java.lang.Object 中的 equals

hashCode

public int hashCode()
覆盖:
java.lang.Object 中的 hashCode

toString

public java.lang.String toString()
Returns a human - readable representation of frame's data

覆盖:
java.lang.Object 中的 toString
返回:
A text string or hex-encoded string if data contains any non-printable ASCII characters

recvFrame

public static ZFrame recvFrame(ZMQ.Socket socket)
Receives single frame from socket, returns the received frame object, or null if the recv was interrupted. Does a blocking recv, if you want to not block then use recvFrame(socket, ZMQ.DONTWAIT);

参数:
socket - Socket to read from
返回:
received frame, else null

recvFrame

public static ZFrame recvFrame(ZMQ.Socket socket,
                               int flags)
Receive a new frame off the socket, Returns newly-allocated frame, or null if there was no input waiting, or if the read was interrupted.

参数:
socket - Socket to read from
flags - Pass flags to 0MQ socket.recv call
返回:
received frame, else null