Package nl.tudelft.simulation.zmq.message

# Class Message

java.lang.Object
nl.tudelft.simulation.zmq.message.Message

    public class Message
    extends Object

Message conversions. These take into account the endianness of the different values. Java is by default big-endian.

Copyright (c) 2002-2020 Delft University of Technology, Jaffalaan 5, 2628 BX Delft, the Netherlands. All rights reserved. See for project information https://simulation.tudelft.nl. The DSOL project is distributed under a three-clause BSD-style license, which can be found at https://simulation.tudelft.nl/dsol/3.0/license.html.

Author:
  Peter Jacobs, Alexander Verbraeck

## Field Summary

Fields
Modifier and Type | Field | Description
--- | --- | ---
`protected static byte` | `BOOLEAN_8` | boolean, sent / received as a byte; 0 = false, 1 = true.
`protected static int` | `BOOLEAN_HC` | hashcode of Boolean class.
`protected static byte` | `BYTE_8` | byte, 8 bit signed two's complement integer.
`protected static byte` | `BYTE_8_ARRAY_BIG_ENDIAN` | int-preceded byte array.
`protected static byte` | `BYTE_8_ARRAY_LITTLE_ENDIAN` | int-preceded byte array.
`protected static int` | `BYTE_ARRAY_HC` | hashcode of byte[] class.
`protected static int` | `BYTE_HC` | hashcode of Byte class.
`protected static byte` | `CHAR_16_BIG_ENDIAN` | char, 16-bit Unicode character.
`protected static byte` | `CHAR_16_LITTLE_ENDIAN` | char, 16-bit Unicode character.
`protected static int` | `CHAR_HC` | hashcode of Character class.
`protected static byte` | `DOUBLE_64_BIG_ENDIAN` | float, double-precision 64-bit IEEE 754 floating point.
`protected static byte` | `DOUBLE_64_LITTLE_ENDIAN` | float, double-precision 64-bit IEEE 754 floating point.
`protected static int` | `DOUBLE_HC` | hashcode of Double class.
`protected static byte` | `FLOAT_32_BIG_ENDIAN` | float, single-precision 32-bit IEEE 754 floating point.
`protected static byte` | `FLOAT_32_LITTLE_ENDIAN` | float, single-precision 32-bit IEEE 754 floating point.
`protected static int` | `FLOAT_HC` | hashcode of Float class.
`protected static byte` | `INT_32_BIG_ENDIAN` | int, 32 bit signed two's complement integer.
`protected static byte` | `INT_32_LITTLE_ENDIAN` | int, 32 bit signed two's complement integer.
`protected static int` | `INTEGER_HC` | hashcode of Integer class.
`protected static byte` | `LONG_64_BIG_ENDIAN` | long, 64 bit signed two's complement integer.
`protected static byte` | `LONG_64_LITTLE_ENDIAN` | long, 64 bit signed two's complement integer.
`protected static int` | `LONG_HC` | hashcode of Long class.
`protected static byte` | `SHORT_16_BIG_ENDIAN` | short, 16 bit signed two's complement integer.
`protected static byte` | `SHORT_16_LITTLE_ENDIAN` | short, 16 bit signed two's complement integer.
`protected static int` | `SHORT_HC` | hashcode of Short class.
`protected static byte` | `STRING_16_BIG_ENDIAN` | String, int-preceded char array of 16-bits characters.
`protected static byte` | `STRING_16_LITTLE_ENDIAN` | String, int-preceded char array of 16-bits characters.
`protected static byte` | `STRING_8_BIG_ENDIAN` | String, int-preceded byte array of 8-bits characters.
`protected static byte` | `STRING_8_LITTLE_ENDIAN` | String, int-preceded byte array of 8-bits characters.
`protected static int` | `STRING_HC` | hashcode of String class.
`protected static Charset` | `UTF16` | the UTF-16 charset.
`protected static Charset` | `UTF8` | the UTF-8 charset.

## Constructor Summary

Constructors
Constructor | Description
--- | ---
`Message()` |

## Method Summary

Modifier and Type | Method | Description
--- | --- | ---
`static Object[]` | `decode​(byte[] message)` | Decode the message into an object array.
`static byte[]` | `encode​(Object[] content)` | Encode the object array into a message.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Field Details

### BYTE_8

protected static final byte BYTE_8
byte, 8 bit signed two's complement integer.

See Also:
  Constant Field Values

### SHORT_16_BIG_ENDIAN

protected static final byte SHORT_16_BIG_ENDIAN
short, 16 bit signed two's complement integer.

See Also:
  Constant Field Values

### INT_32_BIG_ENDIAN

protected static final byte INT_32_BIG_ENDIAN
int, 32 bit signed two's complement integer.

See Also:
  Constant Field Values

### LONG_64_BIG_ENDIAN

protected static final byte LONG_64_BIG_ENDIAN
long, 64 bit signed two's complement integer.

See Also:
  Constant Field Values

### FLOAT_32_BIG_ENDIAN

protected static final byte FLOAT_32_BIG_ENDIAN
float, single-precision 32-bit IEEE 754 floating point.

See Also:
  Constant Field Values

### DOUBLE_64_BIG_ENDIAN

protected static final byte DOUBLE_64_BIG_ENDIAN
float, double-precision 64-bit IEEE 754 floating point.

See Also:
  Constant Field Values

### BOOLEAN_8

protected static final byte BOOLEAN_8
boolean, sent / received as a byte; 0 = false, 1 = true.

See Also:
  Constant Field Values

### CHAR_16_BIG_ENDIAN

protected static final byte CHAR_16_BIG_ENDIAN
char, 16-bit Unicode character.

See Also:
  Constant Field Values

### STRING_8_BIG_ENDIAN

protected static final byte STRING_8_BIG_ENDIAN
String, int-preceded byte array of 8-bits characters.

See Also:
  Constant Field Values

### STRING_16_BIG_ENDIAN

protected static final byte STRING_16_BIG_ENDIAN
String, int-preceded char array of 16-bits characters.

See Also:
  Constant Field Values

### BYTE_8_ARRAY_BIG_ENDIAN

protected static final byte BYTE_8_ARRAY_BIG_ENDIAN
int-preceded byte array.

See Also:
  Constant Field Values

### SHORT_16_LITTLE_ENDIAN

protected static final byte SHORT_16_LITTLE_ENDIAN
short, 16 bit signed two's complement integer.

See Also:
  Constant Field Values

### INT_32_LITTLE_ENDIAN

protected static final byte INT_32_LITTLE_ENDIAN
int, 32 bit signed two's complement integer.

See Also:
  Constant Field Values

### LONG_64_LITTLE_ENDIAN

protected static final byte LONG_64_LITTLE_ENDIAN
long, 64 bit signed two's complement integer.

See Also:
  Constant Field Values

### FLOAT_32_LITTLE_ENDIAN

protected static final byte FLOAT_32_LITTLE_ENDIAN
float, single-precision 32-bit IEEE 754 floating point.

See Also:
  Constant Field Values

### DOUBLE_64_LITTLE_ENDIAN

protected static final byte DOUBLE_64_LITTLE_ENDIAN
float, double-precision 64-bit IEEE 754 floating point.

See Also:
  Constant Field Values

### CHAR_16_LITTLE_ENDIAN

protected static final byte CHAR_16_LITTLE_ENDIAN
char, 16-bit Unicode character.

See Also:
  Constant Field Values

### STRING_8_LITTLE_ENDIAN

protected static final byte STRING_8_LITTLE_ENDIAN
String, int-preceded byte array of 8-bits characters.

See Also:
  Constant Field Values

### STRING_16_LITTLE_ENDIAN

protected static final byte STRING_16_LITTLE_ENDIAN
String, int-preceded char array of 16-bits characters.

See Also:
  Constant Field Values

### BYTE_8_ARRAY_LITTLE_ENDIAN

protected static final byte BYTE_8_ARRAY_LITTLE_ENDIAN
int-preceded byte array.

See Also:
  Constant Field Values

### BYTE_HC

protected static final int BYTE_HC
hashcode of Byte class.

### SHORT_HC

protected static final int SHORT_HC
hashcode of Short class.

### INTEGER_HC

protected static final int INTEGER_HC
hashcode of Integer class.

### LONG_HC

protected static final int LONG_HC
hashcode of Long class.

### FLOAT_HC

protected static final int FLOAT_HC
hashcode of Float class.

### DOUBLE_HC

protected static final int DOUBLE_HC
hashcode of Double class.

### BOOLEAN_HC

protected static final int BOOLEAN_HC
hashcode of Boolean class.

### CHAR_HC

protected static final int CHAR_HC
hashcode of Character class.

### STRING_HC

protected static final int STRING_HC
hashcode of String class.

### BYTE_ARRAY_HC

protected static final int BYTE_ARRAY_HC
hashcode of byte[] class.

### UTF8

protected static final Charset UTF8
the UTF-8 charset.

### UTF16

protected static final Charset UTF16
the UTF-16 charset.

## Constructor Details

### Message

public Message()

## Method Details

### encode

public static byte[] encode​(Object[] content) throws ZeroMQException
Encode the object array into a message.

Parameters:
  `content` - Object[]; the objects to encode
Returns:
  the zeroMQ message to send as a byte array
Throws:
  `ZeroMQException` - on unknown data type

### decode

public static Object[] decode​(byte[] message) throws ZeroMQException
Decode the message into an object array.

Parameters:
  `message` - byte[]; the ZeroMQ byte array to decode
Returns:
  an array of objects of the right type
Throws:
  `ZeroMQException` - on unknown data type