org.zeromq
类 ZMsg

java.lang.Object
  继承者 org.zeromq.ZMsg
所有已实现的接口:
java.lang.Iterable<ZFrame>, java.util.Collection<ZFrame>, java.util.Deque<ZFrame>, java.util.Queue<ZFrame>

public class ZMsg
extends java.lang.Object
implements java.util.Deque<ZFrame>

The ZMsg class provides methods to send and receive multipart messages across 0MQ sockets. This class provides a list-like container interface, with methods to work with the overall container. ZMsg messages are composed of zero or more ZFrame objects.

 // Send a simple single-frame string message on a ZMQSocket "output" socket
 // object
 ZMsg.newStringMsg("Hello").send(output);
 
 // Add several frames into one message
 ZMsg msg = new ZMsg();
 for (int i = 0; i < 10; i++) {
     msg.addString("Frame" + i);
 }
 msg.send(output);
 
 // Receive message from ZMQSocket "input" socket object and iterate over frames
 ZMsg receivedMessage = ZMsg.recvMsg(input);
 for (ZFrame f : receivedMessage) {
     // Do something with frame f (of type ZFrame)
 }
 
Based on zmsg.c in czmq


构造方法摘要
ZMsg()
          Class Constructor
 
方法摘要
 boolean add(byte[] data)
           
 boolean add(java.lang.String stringValue)
           
 boolean add(ZFrame e)
           
 boolean addAll(java.util.Collection<? extends ZFrame> arg0)
           
 void addFirst(byte[] data)
           
 void addFirst(java.lang.String stringValue)
           
 void addFirst(ZFrame e)
           
 void addLast(byte[] data)
           
 void addLast(java.lang.String stringValue)
           
 void addLast(ZFrame e)
           
 void addString(java.lang.String str)
          Add a String as a new ZFrame to the end of list
 void clear()
           
 boolean contains(java.lang.Object o)
           
 boolean containsAll(java.util.Collection<?> arg0)
           
 long contentSize()
          Return total number of bytes contained in all ZFrames in this ZMsg
 java.util.Iterator<ZFrame> descendingIterator()
           
 void destroy()
          Destructor.
 void dump(java.lang.Appendable out)
          Dump the message in human readable format.
 ZMsg duplicate()
          Creates copy of this ZMsg.
 ZFrame element()
           
 boolean equals(java.lang.Object o)
           
 ZFrame getFirst()
           
 ZFrame getLast()
           
 int hashCode()
           
 boolean isEmpty()
           
 java.util.Iterator<ZFrame> iterator()
           
static ZMsg load(java.io.DataInputStream file)
          Load / append a ZMsg from an open DataInputStream
static ZMsg newStringMsg(java.lang.String... strings)
          Create a new ZMsg from one or more Strings
 boolean offer(ZFrame e)
           
 boolean offerFirst(ZFrame e)
           
 boolean offerLast(ZFrame e)
           
 ZFrame peek()
           
 ZFrame peekFirst()
           
 ZFrame peekLast()
           
 ZFrame poll()
           
 ZFrame pollFirst()
           
 ZFrame pollLast()
           
 ZFrame pop()
           
 java.lang.String popString()
          Pop a ZFrame and return the toString() representation of it.
 void push(byte[] data)
           
 void push(java.lang.String str)
           
 void push(ZFrame e)
           
static ZMsg recvMsg(ZMQ.Socket socket)
          Receives message from socket, returns ZMsg object or null if the recv was interrupted.
static ZMsg recvMsg(ZMQ.Socket socket, int flag)
          Receives message from socket, returns ZMsg object or null if the recv was interrupted.
 ZFrame remove()
           
 boolean remove(java.lang.Object o)
           
 boolean removeAll(java.util.Collection<?> arg0)
           
 ZFrame removeFirst()
           
 boolean removeFirstOccurrence(java.lang.Object o)
           
 ZFrame removeLast()
           
 boolean removeLastOccurrence(java.lang.Object o)
           
 boolean retainAll(java.util.Collection<?> arg0)
           
static boolean save(ZMsg msg, java.io.DataOutputStream file)
          Save message to an open data output stream.
 void send(ZMQ.Socket socket)
          Send message to 0MQ socket.
 void send(ZMQ.Socket socket, boolean destroy)
          Send message to 0MQ socket, destroys contents after sending if destroy param is set to true.
 int size()
           
 java.lang.Object[] toArray()
           
<T> T[]
toArray(T[] arg0)
           
 java.lang.String toString()
          Convert the message to a string, for use in debugging.
 ZFrame unwrap()
          Pop frame off front of message, caller now owns frame.
 void wrap(ZFrame frame)
          Push frame plus empty frame to front of message, before 1st frame.
 
从类 java.lang.Object 继承的方法
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

构造方法详细信息

ZMsg

public ZMsg()
Class Constructor

方法详细信息

destroy

public void destroy()
Destructor. Explicitly destroys all ZFrames contains in the ZMsg


contentSize

public long contentSize()
Return total number of bytes contained in all ZFrames in this ZMsg

返回:

addString

public void addString(java.lang.String str)
Add a String as a new ZFrame to the end of list

参数:
str - String to add to list

duplicate

public ZMsg duplicate()
Creates copy of this ZMsg. Also duplicates all frame content.

返回:
The duplicated ZMsg object, else null if this ZMsg contains an empty frame set

wrap

public void wrap(ZFrame frame)
Push frame plus empty frame to front of message, before 1st frame. Message takes ownership of frame, will destroy it when message is sent.

参数:
frame -

unwrap

public ZFrame unwrap()
Pop frame off front of message, caller now owns frame. If next frame is empty, pops and destroys that empty frame (e.g. useful when unwrapping ROUTER socket envelopes)

返回:
Unwrapped frame

send

public void send(ZMQ.Socket socket)
Send message to 0MQ socket.

参数:
socket - 0MQ socket to send ZMsg on.

send

public void send(ZMQ.Socket socket,
                 boolean destroy)
Send message to 0MQ socket, destroys contents after sending if destroy param is set to true. If the message has no frames, sends nothing but still destroy()s the ZMsg object

参数:
socket - 0MQ socket to send ZMsg on.

recvMsg

public static ZMsg recvMsg(ZMQ.Socket socket)
Receives message from socket, returns ZMsg object or null if the recv was interrupted. Does a blocking recv, if you want not to block then use the ZLoop class or ZMQ.Poller to check for socket input before receiving or recvMsg with flag ZMQ.DONTWAIT.

参数:
socket -
返回:

recvMsg

public static ZMsg recvMsg(ZMQ.Socket socket,
                           int flag)
Receives message from socket, returns ZMsg object or null if the recv was interrupted. Does a blocking recv, if you want not to block then use the ZLoop class or ZMQ.Poller to check for socket input before receiving.

参数:
socket -
flag - see ZMQ constants
返回:

save

public static boolean save(ZMsg msg,
                           java.io.DataOutputStream file)
Save message to an open data output stream. Data saved as: 4 bytes: number of frames For every frame: 4 bytes: byte size of frame data + n bytes: frame byte data

参数:
msg - ZMsg to save
file - DataOutputStream
返回:
True if saved OK, else false

load

public static ZMsg load(java.io.DataInputStream file)
Load / append a ZMsg from an open DataInputStream

参数:
file - DataInputStream connected to file
返回:
ZMsg object

newStringMsg

public static ZMsg newStringMsg(java.lang.String... strings)
Create a new ZMsg from one or more Strings

参数:
strings - Strings to add as frames.
返回:
ZMsg object

equals

public boolean equals(java.lang.Object o)
指定者:
接口 java.util.Collection<ZFrame> 中的 equals
覆盖:
java.lang.Object 中的 equals

hashCode

public int hashCode()
指定者:
接口 java.util.Collection<ZFrame> 中的 hashCode
覆盖:
java.lang.Object 中的 hashCode

dump

public void dump(java.lang.Appendable out)
Dump the message in human readable format. This should only be used for debugging and tracing, inefficient in handling large messages.


toString

public java.lang.String toString()
Convert the message to a string, for use in debugging.

覆盖:
java.lang.Object 中的 toString

addFirst

public void addFirst(java.lang.String stringValue)

addFirst

public void addFirst(byte[] data)

addLast

public void addLast(java.lang.String stringValue)

addLast

public void addLast(byte[] data)

push

public void push(java.lang.String str)

push

public void push(byte[] data)

add

public boolean add(java.lang.String stringValue)

add

public boolean add(byte[] data)

iterator

public java.util.Iterator<ZFrame> iterator()
指定者:
接口 java.lang.Iterable<ZFrame> 中的 iterator
指定者:
接口 java.util.Collection<ZFrame> 中的 iterator
指定者:
接口 java.util.Deque<ZFrame> 中的 iterator

addAll

public boolean addAll(java.util.Collection<? extends ZFrame> arg0)
指定者:
接口 java.util.Collection<ZFrame> 中的 addAll

clear

public void clear()
指定者:
接口 java.util.Collection<ZFrame> 中的 clear

containsAll

public boolean containsAll(java.util.Collection<?> arg0)
指定者:
接口 java.util.Collection<ZFrame> 中的 containsAll

isEmpty

public boolean isEmpty()
指定者:
接口 java.util.Collection<ZFrame> 中的 isEmpty

removeAll

public boolean removeAll(java.util.Collection<?> arg0)
指定者:
接口 java.util.Collection<ZFrame> 中的 removeAll

retainAll

public boolean retainAll(java.util.Collection<?> arg0)
指定者:
接口 java.util.Collection<ZFrame> 中的 retainAll

toArray

public java.lang.Object[] toArray()
指定者:
接口 java.util.Collection<ZFrame> 中的 toArray

toArray

public <T> T[] toArray(T[] arg0)
指定者:
接口 java.util.Collection<ZFrame> 中的 toArray

add

public boolean add(ZFrame e)
指定者:
接口 java.util.Collection<ZFrame> 中的 add
指定者:
接口 java.util.Deque<ZFrame> 中的 add
指定者:
接口 java.util.Queue<ZFrame> 中的 add

addFirst

public void addFirst(ZFrame e)
指定者:
接口 java.util.Deque<ZFrame> 中的 addFirst

addLast

public void addLast(ZFrame e)
指定者:
接口 java.util.Deque<ZFrame> 中的 addLast

contains

public boolean contains(java.lang.Object o)
指定者:
接口 java.util.Collection<ZFrame> 中的 contains
指定者:
接口 java.util.Deque<ZFrame> 中的 contains

descendingIterator

public java.util.Iterator<ZFrame> descendingIterator()
指定者:
接口 java.util.Deque<ZFrame> 中的 descendingIterator

element

public ZFrame element()
指定者:
接口 java.util.Deque<ZFrame> 中的 element
指定者:
接口 java.util.Queue<ZFrame> 中的 element

getFirst

public ZFrame getFirst()
指定者:
接口 java.util.Deque<ZFrame> 中的 getFirst

getLast

public ZFrame getLast()
指定者:
接口 java.util.Deque<ZFrame> 中的 getLast

offer

public boolean offer(ZFrame e)
指定者:
接口 java.util.Deque<ZFrame> 中的 offer
指定者:
接口 java.util.Queue<ZFrame> 中的 offer

offerFirst

public boolean offerFirst(ZFrame e)
指定者:
接口 java.util.Deque<ZFrame> 中的 offerFirst

offerLast

public boolean offerLast(ZFrame e)
指定者:
接口 java.util.Deque<ZFrame> 中的 offerLast

peek

public ZFrame peek()
指定者:
接口 java.util.Deque<ZFrame> 中的 peek
指定者:
接口 java.util.Queue<ZFrame> 中的 peek

peekFirst

public ZFrame peekFirst()
指定者:
接口 java.util.Deque<ZFrame> 中的 peekFirst

peekLast

public ZFrame peekLast()
指定者:
接口 java.util.Deque<ZFrame> 中的 peekLast

poll

public ZFrame poll()
指定者:
接口 java.util.Deque<ZFrame> 中的 poll
指定者:
接口 java.util.Queue<ZFrame> 中的 poll

pollFirst

public ZFrame pollFirst()
指定者:
接口 java.util.Deque<ZFrame> 中的 pollFirst

pollLast

public ZFrame pollLast()
指定者:
接口 java.util.Deque<ZFrame> 中的 pollLast

pop

public ZFrame pop()
指定者:
接口 java.util.Deque<ZFrame> 中的 pop

popString

public java.lang.String popString()
Pop a ZFrame and return the toString() representation of it.

返回:
toString version of pop'ed frame, or null if no frame exists.

push

public void push(ZFrame e)
指定者:
接口 java.util.Deque<ZFrame> 中的 push

remove

public ZFrame remove()
指定者:
接口 java.util.Deque<ZFrame> 中的 remove
指定者:
接口 java.util.Queue<ZFrame> 中的 remove

remove

public boolean remove(java.lang.Object o)
指定者:
接口 java.util.Collection<ZFrame> 中的 remove
指定者:
接口 java.util.Deque<ZFrame> 中的 remove

removeFirst

public ZFrame removeFirst()
指定者:
接口 java.util.Deque<ZFrame> 中的 removeFirst

removeFirstOccurrence

public boolean removeFirstOccurrence(java.lang.Object o)
指定者:
接口 java.util.Deque<ZFrame> 中的 removeFirstOccurrence

removeLast

public ZFrame removeLast()
指定者:
接口 java.util.Deque<ZFrame> 中的 removeLast

removeLastOccurrence

public boolean removeLastOccurrence(java.lang.Object o)
指定者:
接口 java.util.Deque<ZFrame> 中的 removeLastOccurrence

size

public int size()
指定者:
接口 java.util.Collection<ZFrame> 中的 size
指定者:
接口 java.util.Deque<ZFrame> 中的 size