public class ZMsg extends Object implements Iterable<ZFrame>, Deque<ZFrame>
// 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| Constructor and Description |
|---|
ZMsg()
Class Constructor
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
add(byte[] data) |
boolean |
add(String stringValue) |
boolean |
add(ZFrame e) |
boolean |
addAll(Collection<? extends ZFrame> arg0) |
void |
addFirst(byte[] data) |
void |
addFirst(String stringValue) |
void |
addFirst(ZFrame e) |
void |
addLast(byte[] data) |
void |
addLast(String stringValue) |
void |
addLast(ZFrame e) |
void |
addString(String str)
Add a String as a new ZFrame to the end of list
|
void |
clear() |
boolean |
contains(Object o) |
boolean |
containsAll(Collection<?> arg0) |
long |
contentSize() |
Iterator<ZFrame> |
descendingIterator() |
void |
destroy()
Destructor.
|
void |
dump() |
void |
dump(Appendable out)
Dump the message in human readable format.
|
ZMsg |
duplicate()
Creates copy of this ZMsg.
|
ZFrame |
element() |
boolean |
equals(Object o) |
ZFrame |
getFirst() |
ZFrame |
getLast() |
int |
hashCode() |
boolean |
isEmpty() |
Iterator<ZFrame> |
iterator() |
static ZMsg |
load(DataInputStream file)
Load / append a ZMsg from an open DataInputStream
|
static ZMsg |
newStringMsg(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() |
String |
popString()
Pop a ZFrame and return the toString() representation of it.
|
void |
push(byte[] data) |
void |
push(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(Object o) |
boolean |
removeAll(Collection<?> arg0) |
ZFrame |
removeFirst() |
boolean |
removeFirstOccurrence(Object o) |
ZFrame |
removeLast() |
boolean |
removeLastOccurrence(Object o) |
boolean |
retainAll(Collection<?> arg0) |
static boolean |
save(ZMsg msg,
DataOutputStream file)
Save message to an open data output stream.
|
boolean |
send(ZMQ.Socket socket)
Send message to 0MQ socket.
|
boolean |
send(ZMQ.Socket socket,
boolean destroy)
Send message to 0MQ socket, destroys contents after sending if destroy param is set to true.
|
int |
size() |
Object[] |
toArray() |
<T> T[] |
toArray(T[] arg0) |
String |
toString()
Returns pretty string representation of multipart message:
[ frame0, frame1, ..., frameN ]
|
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.
|
public void destroy()
public long contentSize()
public void addString(String str)
str - String to add to listpublic ZMsg duplicate()
public void wrap(ZFrame frame)
frame - public ZFrame unwrap()
public boolean send(ZMQ.Socket socket)
socket - 0MQ socket to send ZMsg on.public boolean send(ZMQ.Socket socket, boolean destroy)
socket - 0MQ socket to send ZMsg on.public static ZMsg recvMsg(ZMQ.Socket socket)
socket - public static ZMsg recvMsg(ZMQ.Socket socket, int flag)
socket - flag - see ZMQ constantspublic static boolean save(ZMsg msg, DataOutputStream file)
msg - ZMsg to savefile - DataOutputStreampublic static ZMsg load(DataInputStream file)
file - DataInputStream connected to filepublic static ZMsg newStringMsg(String... strings)
strings - Strings to add as frames.public boolean equals(Object o)
equals in interface Collection<ZFrame>equals in class Objectpublic int hashCode()
hashCode in interface Collection<ZFrame>hashCode in class Objectpublic void dump(Appendable out)
public void dump()
public void addFirst(String stringValue)
public void addFirst(byte[] data)
public void addLast(String stringValue)
public void addLast(byte[] data)
public void push(String str)
public void push(byte[] data)
public boolean add(String stringValue)
public boolean add(byte[] data)
public boolean addAll(Collection<? extends ZFrame> arg0)
addAll in interface Collection<ZFrame>public void clear()
clear in interface Collection<ZFrame>public boolean containsAll(Collection<?> arg0)
containsAll in interface Collection<ZFrame>public boolean isEmpty()
isEmpty in interface Collection<ZFrame>public boolean removeAll(Collection<?> arg0)
removeAll in interface Collection<ZFrame>public boolean retainAll(Collection<?> arg0)
retainAll in interface Collection<ZFrame>public Object[] toArray()
toArray in interface Collection<ZFrame>public <T> T[] toArray(T[] arg0)
toArray in interface Collection<ZFrame>public boolean add(ZFrame e)
public boolean contains(Object o)
public Iterator<ZFrame> descendingIterator()
descendingIterator in interface Deque<ZFrame>public ZFrame element()
public boolean offer(ZFrame e)
public boolean offerFirst(ZFrame e)
offerFirst in interface Deque<ZFrame>public ZFrame peek()
public ZFrame poll()
public String popString()
public ZFrame remove()
public boolean remove(Object o)
public ZFrame removeFirst()
removeFirst in interface Deque<ZFrame>public boolean removeFirstOccurrence(Object o)
removeFirstOccurrence in interface Deque<ZFrame>public ZFrame removeLast()
removeLast in interface Deque<ZFrame>public boolean removeLastOccurrence(Object o)
removeLastOccurrence in interface Deque<ZFrame>public int size()
Copyright © 2014. All rights reserved.