- 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.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.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.
-
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.
-
-
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.
-
-