- java.lang.Object
-
- java.lang.Enum<MagicBytes>
-
- org.refcodes.serial.MagicBytes
-
- All Implemented Interfaces:
Serializable,Comparable<MagicBytes>,org.refcodes.mixin.MagicBytesAccessor,MagicBytesAccessor
public enum MagicBytes extends Enum<MagicBytes> implements MagicBytesAccessor
TheMagicBytesenumeration provides various predefined magic bytes for common use cases. Some magic bytes may be combined using theMagicBytesAccessor.toMagicBytes()method to create magic bytes with more semantic information.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.refcodes.serial.MagicBytesAccessor
MagicBytesAccessor.MagicBytesBuilder<B extends MagicBytesAccessor.MagicBytesBuilder<B>>, MagicBytesAccessor.MagicBytesMutator, MagicBytesAccessor.MagicBytesProperty
-
-
Enum Constant Summary
Enum Constants Enum Constant Description ACKNOWLEDGEMagic bytes identifying a transmission acknowledge, same asAscii.ACK.ACKNOWLEDGEABLE_REQUESTIdentifies a request expecting an acknowledgeable response (acknowledge to be sent sent for the succeeding response).ACKNOWLEDGEABLE_RESPONSEIdentifies an acknowledgeable response in reply to a request (acknowledge to be sent for the response).ACKNOWLEDGEABLE_TRANSMISSIONIdentifies an acknowledgeable transmission (acknowledge to be sent).CLEAR_TO_SENDMagic bytes identifying a Clear-to-Send transmission, same asAscii.ACK.LAST_PACKETMagic bytes identifying a last transmission package, same asAscii.ETX.PACKETMagic bytes identifying an transmission package, same asAscii.STX.PINGIdentifies a simple ping request to be responded by a fire-and-forgetPONG(not to be acknowledged).PONGIdentifies a a fire-and-forget pong (not to be acknowledged) reply in response to a simplePINGrequest.READY_TO_RECEIVEMagic bytes identifying a Ready-to-Receive transmission, same asAscii.ENQ.READY_TO_SENDMagic bytes identifying a Ready-to-Send transmission, same asAscii.ENQ.REQUESTIdentifies a request expecting a fire-and-forget response (no acknowledge to be sent for the succeeding response).REQUEST_DISMISSEDSent when a request was received but dismissed by a receiver .RESPONSEIdentifies a fire-and-forget response in reply to a request (no acknowledge to be sent for the response).RESPONSE_ACKNOWLEDGEIdentifies an acknowledge in reply to a response.TRANSMISSIONIdentifies a fire-and-forget transmission (no acknowledge sent).TRANSMISSION_DISMISSEDSent in case a transmission was received and dismissed by a receiver.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description byte[]getMagicBytes()static byte[]toMagicBytes(MagicBytes... aMagicBytes)Constructs magic bytes from the providedMagicByteselements to be concatenated to a single magic bytes sequence.static MagicBytesvalueOf(String name)Returns the enum constant of this type with the specified name.static MagicBytes[]values()Returns an array containing the constants of this enum type, in the order they are declared.-
Methods inherited from class java.lang.Enum
clone, compareTo, equals, finalize, getDeclaringClass, hashCode, name, ordinal, toString, valueOf
-
Methods inherited from interface org.refcodes.serial.MagicBytesAccessor
toMagicBytes, toMagicBytes
-
-
-
-
Enum Constant Detail
-
ACKNOWLEDGE
public static final MagicBytes ACKNOWLEDGE
Magic bytes identifying a transmission acknowledge, same asAscii.ACK.
-
CLEAR_TO_SEND
public static final MagicBytes CLEAR_TO_SEND
Magic bytes identifying a Clear-to-Send transmission, same asAscii.ACK.
-
LAST_PACKET
public static final MagicBytes LAST_PACKET
Magic bytes identifying a last transmission package, same asAscii.ETX.
-
PACKET
public static final MagicBytes PACKET
Magic bytes identifying an transmission package, same asAscii.STX.
-
READY_TO_RECEIVE
public static final MagicBytes READY_TO_RECEIVE
Magic bytes identifying a Ready-to-Receive transmission, same asAscii.ENQ.
-
READY_TO_SEND
public static final MagicBytes READY_TO_SEND
Magic bytes identifying a Ready-to-Send transmission, same asAscii.ENQ.
-
TRANSMISSION
public static final MagicBytes TRANSMISSION
Identifies a fire-and-forget transmission (no acknowledge sent).
-
REQUEST
public static final MagicBytes REQUEST
Identifies a request expecting a fire-and-forget response (no acknowledge to be sent for the succeeding response).
-
RESPONSE
public static final MagicBytes RESPONSE
Identifies a fire-and-forget response in reply to a request (no acknowledge to be sent for the response).
-
RESPONSE_ACKNOWLEDGE
public static final MagicBytes RESPONSE_ACKNOWLEDGE
Identifies an acknowledge in reply to a response.
-
ACKNOWLEDGEABLE_TRANSMISSION
public static final MagicBytes ACKNOWLEDGEABLE_TRANSMISSION
Identifies an acknowledgeable transmission (acknowledge to be sent).
-
ACKNOWLEDGEABLE_REQUEST
public static final MagicBytes ACKNOWLEDGEABLE_REQUEST
Identifies a request expecting an acknowledgeable response (acknowledge to be sent sent for the succeeding response).
-
ACKNOWLEDGEABLE_RESPONSE
public static final MagicBytes ACKNOWLEDGEABLE_RESPONSE
Identifies an acknowledgeable response in reply to a request (acknowledge to be sent for the response).
-
TRANSMISSION_DISMISSED
public static final MagicBytes TRANSMISSION_DISMISSED
Sent in case a transmission was received and dismissed by a receiver.
-
REQUEST_DISMISSED
public static final MagicBytes REQUEST_DISMISSED
Sent when a request was received but dismissed by a receiver .
-
PING
public static final MagicBytes PING
Identifies a simple ping request to be responded by a fire-and-forgetPONG(not to be acknowledged).
-
PONG
public static final MagicBytes PONG
Identifies a a fire-and-forget pong (not to be acknowledged) reply in response to a simplePINGrequest.
-
-
Method Detail
-
values
public static MagicBytes[] values()
Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:for (MagicBytes c : MagicBytes.values()) System.out.println(c);
- Returns:
- an array containing the constants of this enum type, in the order they are declared
-
valueOf
public static MagicBytes valueOf(String name)
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)- Parameters:
name- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
IllegalArgumentException- if this enum type has no constant with the specified nameNullPointerException- if the argument is null
-
getMagicBytes
public byte[] getMagicBytes()
- Specified by:
getMagicBytesin interfaceorg.refcodes.mixin.MagicBytesAccessor
-
toMagicBytes
public static byte[] toMagicBytes(MagicBytes... aMagicBytes)
Constructs magic bytes from the providedMagicByteselements to be concatenated to a single magic bytes sequence.- Parameters:
aMagicBytes- TheMagicByteselements from which to create the magic bytes.- Returns:
- The accordingly created magic bytes.
-
-