|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.kuka.roboticsAPI.controllerModel.sunrise.connectionLib.MessageUtilities
public final class MessageUtilities
Utility class for message sending and receiving.
| Field Summary | |
|---|---|
static String |
SEG_BEGIN
Segment begin parameter string. |
static String |
SEG_END
Segment end parameter string. |
| Method Summary | |
|---|---|
static void |
addSegment(String segmentType,
String segmentVersion,
int checksum,
Message message,
Message messageToAddAsSegment)
Adds a message as a segment into an existing message. |
static void |
checkSize(long bytes,
int maxLength)
Checks if the given size is too big for sending. |
static void |
closeSegment(Message message)
Closes a message segment. |
static Message |
generateErrorMessage(long id,
Throwable cause)
Generates an error message from a Java exception. |
static Message |
getSegment(Message message,
int segmentIndex,
String segmentName)
gets the specified segment within the message as a message object. |
static int |
getSegmentCount(Message message)
gets the amount of segments within the message. |
static Message |
receiveMessageFromStream(InputStream inputStream,
int messageLength)
Receives a message from a stream. |
static Message |
receiveMessageFromStream(InputStream inputStream,
int messageLength,
FastByteBuffer buffer)
Receives a message from a stream. |
static Message |
receiveMessageFromStreamChecked(InputStream inputStream,
int messageLength)
Receives a message from a stream. |
static Message |
receiveMessageFromStreamChecked(InputStream inputStream,
int messageLength,
FastByteBuffer buffer)
Receives a message from a stream. |
static int |
receiveMessageLengthFromStream(InputStream inputStream)
Receives the length of a message from a stream. |
static int |
receiveMessageLengthFromStream(InputStream inputStream,
FastByteBuffer lengthBuffer)
Receives the length of a message from a stream. |
static Throwable |
recoverException(Message errorMessage)
Returns the causing exception from an error message, as generated by generateErrorMessage(long, Throwable). |
static void |
sendMessageOverStream(OutputStream outputStream,
Message message)
Writes a message to a stream. |
static void |
sendMessageOverStream(OutputStream outputStream,
Message message,
FastByteBuffer messageBuffer,
FastByteBuffer lengthBuffer,
int maxLength)
Writes a message to a stream. |
static void |
startSegment(ISegment segment,
Message message)
Starts a message segment. |
static void |
startSegment(String segmentType,
String segmentVersion,
int checksum,
Message message)
Starts a message segment. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final String SEG_END
public static final String SEG_BEGIN
| Method Detail |
|---|
public static Message receiveMessageFromStream(InputStream inputStream,
int messageLength)
throws IOException
receiveMessageLengthFromStream should be called to determine the length of the message before.
inputStream - The input stream.messageLength - The length of the message.
IOException - If an I/O error occurred.
IllegalArgumentException - exception if message is too big
public static Message receiveMessageFromStreamChecked(InputStream inputStream,
int messageLength)
throws IOException,
MessageDeserializationException
receiveMessageLengthFromStream should be called to determine the length of the message before.
inputStream - The input stream.messageLength - The length of the message.
IOException - if an I/O error occurred
MessageDeserializationException - if an error occurred during message deserialization
public static Message receiveMessageFromStream(InputStream inputStream,
int messageLength,
FastByteBuffer buffer)
throws IOException
receiveMessageLengthFromStream should be called to determine the length of the message before.
inputStream - The input stream.messageLength - The length of the message.buffer - The buffer which is used to receive the message.
IOException - if an I/O error occurred
public static Message receiveMessageFromStreamChecked(InputStream inputStream,
int messageLength,
FastByteBuffer buffer)
throws IOException,
MessageDeserializationException
receiveMessageLengthFromStream should be called to determine the length of the message before.
inputStream - The input stream.messageLength - The length of the message.buffer - The buffer which is used to receive the message.
IOException - if an I/O error occurred
MessageDeserializationException - if an error occurred during message deserialization
public static int receiveMessageLengthFromStream(InputStream inputStream)
throws IOException
inputStream - The stream.
IOException - If an error occurs.
public static int receiveMessageLengthFromStream(InputStream inputStream,
FastByteBuffer lengthBuffer)
throws IOException
inputStream - The stream.lengthBuffer - The buffer used to receive the length.
IOException - If an error occurs.
public static void checkSize(long bytes,
int maxLength)
Throws an exception if file is too big.
bytes - The byte count.maxLength - The maximum length allowed for a message.
public static void sendMessageOverStream(OutputStream outputStream,
Message message)
throws IOException
outputStream - The stream.message - The message.
IOException - If an error occurs.
public static void sendMessageOverStream(OutputStream outputStream,
Message message,
FastByteBuffer messageBuffer,
FastByteBuffer lengthBuffer,
int maxLength)
throws IOException
outputStream - The stream.message - The message.messageBuffer - The buffer for writing the message.lengthBuffer - The buffer for writing the length of the message.maxLength - The maximum length allowed for a message.
IOException - If an error occurs.public static void closeSegment(Message message)
message - The message.
public static void startSegment(ISegment segment,
Message message)
segment - The segment holding the segment data.message - The message.
public static void startSegment(String segmentType,
String segmentVersion,
int checksum,
Message message)
segmentType - The type of the segment.segmentVersion - The version of the segment.checksum - The checksum for the segment.message - The message.
public static void addSegment(String segmentType,
String segmentVersion,
int checksum,
Message message,
Message messageToAddAsSegment)
segmentType - The type of the segment.segmentVersion - The version of the segment.checksum - The checksum for the segment.message - the message that will contain the added segment afterwards.messageToAddAsSegment - the message that should be added as a segment.public static int getSegmentCount(Message message)
message - the message that contains the segments.
public static Message getSegment(Message message,
int segmentIndex,
String segmentName)
message - the message containing the segment.segmentIndex - the index of the segment in the message that should be returned.segmentName - name of the segment
public static Message generateErrorMessage(long id,
Throwable cause)
MessageType.Error and
the given ID. The message parameters will be as follows:
Throwable.getMessage(), or an empty string if the message is nullObjectOutputStream
id - The id for the error message. If the error occurred in reaction to a request message, this id should
usually be the id of the original request message.cause - the causing exception
public static Throwable recoverException(Message errorMessage)
generateErrorMessage(long, Throwable).
errorMessage - the error message
IllegalArgumentException - if the type of the given message is not MessageType.Error.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||