Package zmq.io
Class Metadata
java.lang.Object
zmq.io.Metadata
The metadata holder class.
The class is thread safe, as it uses a ConcurrentHashMap for the backend
Null value are transformed to empty string.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceCall backs during parsing process -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbyte[]bytes()Return the content of the metadata as a new byte array, using the specifications of the ZMTP protocolprivate byte[]bytes(ByteBuffer buf, int position, int length) private intReturn an approximate size of the serialization of the metadata, it will probably be higher if there is a lot of non ASCII value in it.voidclear()Removes all the properties.booleancontainsKey(String property) Returnstrueif this metada contains the property requestedentrySet()Returns aSetview of the properties contained in this metadata.booleanReturns the value for this property, ornullif it does not exist.inthashCode()booleanisEmpty()Returnstrueif this map contains no key-value mappings.keySet()Returns aSetview of the keys contained in this metadata.voidDefine the value for this property.intread(ByteBuffer msg, int offset, Metadata.ParseListener listener) Deserialize metadata from aByteBuffer, using the specifications of the ZMTP protocolintread(Msg msg, int offset, Metadata.ParseListener listener) Deserialize metadata from aMsg, using the specifications of the ZMTP protocolvoidRemoves the property for a name from this metada if it is present.voidDeprecated.voidintsize()Returns the number of properties.toString()values()Returns aCollectionview of the values contained in this metadata.voidwrite(OutputStream stream) Serialize metadata to an output stream, using the specifications of the ZMTP protocol
-
Field Details
-
IDENTITY
- See Also:
-
SOCKET_TYPE
- See Also:
-
USER_ID
- See Also:
-
PEER_ADDRESS
- See Also:
-
dictionary
-
-
Constructor Details
-
Metadata
public Metadata() -
Metadata
-
Metadata
-
-
Method Details
-
keySet
Returns aSetview of the keys contained in this metadata. The set is backed by the metadata, so changes to the map are reflected in the set, and vice-versa. If the metadata is modified while an iteration over the set is in progress (except through the iterator's ownremoveoperation), the results of the iteration are undefined. The set supports element removal, which removes the corresponding mapping from the metadata, via theIterator.remove,Set.remove,removeAll,retainAll, andclearoperations. It does not support theaddoraddAlloperations.- Returns:
- a set view of the keys contained in this metadata
-
entrySet
Returns aSetview of the properties contained in this metadata. The set is backed by the metadata, so changes to the metadata are reflected in the set, and vice-versa. If the metadata is modified while an iteration over the set is in progress (except through the iterator's ownremoveoperation, or through thesetValueoperation on a metadata property returned by the iterator) the results of the iteration are undefined. The set supports element removal, which removes the corresponding mapping from the metadata, via theIterator.remove,Set.remove,removeAll,retainAllandclearoperations. It does not support theaddoraddAlloperations.- Returns:
- a set view of the properties contained in this metadata
-
values
Returns aCollectionview of the values contained in this metadata. The collection is backed by the metadata, so changes to the map are reflected in the collection, and vice-versa. If the metadata is modified while an iteration over the collection is in progress (except through the iterator's ownremoveoperation), the results of the iteration are undefined. The collection supports element removal, which removes the corresponding property from the metadata, via theIterator.remove,Collection.remove,removeAll,retainAllandclearoperations. It does not support theaddoraddAlloperations.- Returns:
- a collection view of the values contained in this map
-
remove
Removes the property for a name from this metada if it is present.If this map permits null values, then a return value of
nulldoes not necessarily indicate that the map contained no mapping for the key; it's also possible that the map explicitly mapped the key tonull.The map will not contain a mapping for the specified key once the call returns.
- Parameters:
key- key whose mapping is to be removed from the map
-
get
Returns the value for this property, ornullif it does not exist.- Parameters:
property- the property name- Returns:
- the value of the property, or
nullif it does not exist.
-
set
Deprecated.Useput(String, String)insteadDefine the value for this property. If the value is null, an empty string is stored instead.- Parameters:
property- the property namevalue- value to be associated with the specified property
-
put
Define the value for this property. If the value is null, an empty string is stored instead.- Parameters:
property- the property namevalue- value to be associated with the specified property
-
hashCode
public int hashCode() -
equals
-
set
-
isEmpty
public boolean isEmpty()Returnstrueif this map contains no key-value mappings.- Returns:
trueif this map contains no key-value mappings
-
containsKey
Returnstrueif this metada contains the property requested- Parameters:
property- property the name of the property to be tested.- Returns:
trueif this metada contains the property
-
clear
public void clear()Removes all the properties. The map will be empty after this call returns. -
size
public int size()Returns the number of properties. If it contains more properties thanInteger.MAX_VALUEelements, returnsInteger.MAX_VALUE.- Returns:
- the number of properties
-
toString
-
bytes
public byte[] bytes()Return the content of the metadata as a new byte array, using the specifications of the ZMTP protocolproperty = name value name = OCTET 1*255name-char name-char = ALPHA | DIGIT | "-" | "_" | "." | "+" value = 4OCTET *OCTET ; Size in network byte order
- Returns:
- a new byte array
- Throws:
IllegalStateException- if the content can't be serialized
-
bytesSize
private int bytesSize()Return an approximate size of the serialization of the metadata, it will probably be higher if there is a lot of non ASCII value in it.- Returns:
- the size estimation
-
write
Serialize metadata to an output stream, using the specifications of the ZMTP protocolproperty = name value name = OCTET 1*255name-char name-char = ALPHA | DIGIT | "-" | "_" | "." | "+" value = 4OCTET *OCTET ; Size in network byte order
- Parameters:
stream-- Throws:
IOException- if an I/O error occurs.IllegalStateException- if one of the properties name size is bigger than 255
-
read
Deserialize metadata from aMsg, using the specifications of the ZMTP protocolproperty = name value name = OCTET 1*255name-char name-char = ALPHA | DIGIT | "-" | "_" | "." | "+" value = 4OCTET *OCTET ; Size in network byte order
- Parameters:
msg-offset-listener- an optionalMetadata.ParseListener, can be null.- Returns:
- 0 if successful. Otherwise, it returns
zmq.ZError.EPROTOor the error value from theMetadata.ParseListener.
-
read
Deserialize metadata from aByteBuffer, using the specifications of the ZMTP protocolproperty = name value name = OCTET 1*255name-char name-char = ALPHA | DIGIT | "-" | "_" | "." | "+" value = 4OCTET *OCTET ; Size in network byte order
- Parameters:
msg-offset-listener- an optionalMetadata.ParseListener, can be null.- Returns:
- 0 if successful. Otherwise, it returns
zmq.ZError.EPROTOor the error value from theMetadata.ParseListener.
-
bytes
-
put(String, String)instead