Package org.gearman.common
Enum GearmanPacketMagic
- java.lang.Object
-
- java.lang.Enum<GearmanPacketMagic>
-
- org.gearman.common.GearmanPacketMagic
-
- All Implemented Interfaces:
Serializable
,Comparable<GearmanPacketMagic>
public enum GearmanPacketMagic extends Enum<GearmanPacketMagic>
Enum for the different magic codes that can appear at the beginning of a packet header.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
GearmanPacketMagic.BadMagicException
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static GearmanPacketMagic
fromBytes(byte[] bytes)
"\0REQ" == [ 00 52 45 51 ] == 5391697 "\0RES" == [ 00 52 45 53 ] == 5391699byte[]
toBytes()
static GearmanPacketMagic
valueOf(String name)
Returns the enum constant of this type with the specified name.static GearmanPacketMagic[]
values()
Returns an array containing the constants of this enum type, in the order they are declared.
-
-
-
Enum Constant Detail
-
REQ
public static final GearmanPacketMagic REQ
-
RES
public static final GearmanPacketMagic RES
-
-
Method Detail
-
values
public static GearmanPacketMagic[] 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 (GearmanPacketMagic c : GearmanPacketMagic.values()) System.out.println(c);
- Returns:
- an array containing the constants of this enum type, in the order they are declared
-
valueOf
public static GearmanPacketMagic 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
-
toBytes
public byte[] toBytes()
- Returns:
- the PacketMagic bytes
-
fromBytes
public static GearmanPacketMagic fromBytes(byte[] bytes)
"\0REQ" == [ 00 52 45 51 ] == 5391697 "\0RES" == [ 00 52 45 53 ] == 5391699- Parameters:
bytes
- array of bytes containing magic code for a packet- Throws:
GearmanPacketMagic.BadMagicException
- if byte array is not 4 bytes long
-
-