com.alipay.remoting.util
Class ProtocolSwitch

java.lang.Object
  extended by com.alipay.remoting.util.ProtocolSwitch
All Implemented Interfaces:
Switch

public class ProtocolSwitch
extends Object
implements Switch

Switches used in protocol


Field Summary
static boolean CRC_SWITCH_DEFAULT_VALUE
           
static int CRC_SWITCH_INDEX
           
 
Constructor Summary
ProtocolSwitch()
           
 
Method Summary
static ProtocolSwitch create(int value)
          create an instance of ProtocolSwitch according to byte value
static ProtocolSwitch create(int[] index)
          create an instance of ProtocolSwitch according to switch index
 boolean isOn(int switchIndex)
          check switch whether on
static boolean isOn(int switchIndex, int value)
          check switch status whether on according to specified value
 void setBs(BitSet bs)
          Setter method for property bs.
static BitSet toBitSet(int value)
          from byte to bit set
 byte toByte()
          generate byte value according to the bit set in ProtocolSwitchStatus
static byte toByte(BitSet bs)
          from bit set to byte
 void turnOn(int switchIndex)
          api for user to turn on a feature
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CRC_SWITCH_INDEX

public static final int CRC_SWITCH_INDEX
See Also:
Constant Field Values

CRC_SWITCH_DEFAULT_VALUE

public static final boolean CRC_SWITCH_DEFAULT_VALUE
See Also:
Constant Field Values
Constructor Detail

ProtocolSwitch

public ProtocolSwitch()
Method Detail

turnOn

public void turnOn(int switchIndex)
Description copied from interface: Switch
api for user to turn on a feature

Specified by:
turnOn in interface Switch
Parameters:
switchIndex - the switch index of feature

isOn

public boolean isOn(int switchIndex)
Description copied from interface: Switch
check switch whether on

Specified by:
isOn in interface Switch
Returns:
true if either system setting is on or user setting is on

toByte

public byte toByte()
generate byte value according to the bit set in ProtocolSwitchStatus

Returns:

isOn

public static boolean isOn(int switchIndex,
                           int value)
check switch status whether on according to specified value

Parameters:
switchIndex -
value -
Returns:

create

public static ProtocolSwitch create(int value)
create an instance of ProtocolSwitch according to byte value

Parameters:
value -
Returns:
ProtocolSwitchStatus with initialized bit set.

create

public static ProtocolSwitch create(int[] index)
create an instance of ProtocolSwitch according to switch index

Parameters:
index - the switch index which you want to set true
Returns:
ProtocolSwitchStatus with initialized bit set.

toByte

public static byte toByte(BitSet bs)
from bit set to byte

Parameters:
bs -
Returns:
byte represent the bit set

toBitSet

public static BitSet toBitSet(int value)
from byte to bit set

Parameters:
value -
Returns:
bit set represent the byte

setBs

public void setBs(BitSet bs)
Setter method for property bs.

Parameters:
bs - value to be assigned to property bs


Copyright © 2018. All rights reserved.