Package gnu.io.rfc2217
Class ComPortCommand
- java.lang.Object
-
- gnu.io.rfc2217.ComPortCommand
-
- Direct Known Subclasses:
BaudRateCommand
,ControlCommand
,DataSizeCommand
,FlowControlResumeCommand
,FlowControlSuspendCommand
,LineStateMaskCommand
,ModemStateMaskCommand
,NotifyLineStateCommand
,NotifyModemStateCommand
,ParityCommand
,PurgeDataCommand
,SignatureCommand
,StopSizeCommand
public abstract class ComPortCommand extends java.lang.Object
Superclass for RFC 2217 commands. Instances of this class (and all subclasses) are immutable.- See Also:
- RFC 2217
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
ComPortCommand(java.lang.String name, int command, int[] bytes)
Constructor.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description boolean
equals(java.lang.Object obj)
int[]
getBytes()
Get the encoding of this instance.int
getCommand()
Get the command byte.java.lang.String
getName()
Get the human-readable name of this option.int
hashCode()
boolean
isServerCommand()
Determine if this command is client-to-server or server-to-client.abstract java.lang.String
toString()
Get the human-readable description of this option.abstract void
visit(ComPortCommandSwitch sw)
Apply visitor pattern.
-
-
-
Constructor Detail
-
ComPortCommand
protected ComPortCommand(java.lang.String name, int command, int[] bytes)
Constructor.- Parameters:
name
- human readable name of this commandcommand
- requiredCOM-PORT-OPTION
command byte value (must be the client-to-server value)bytes
- encoded command starting with theCOM-PORT-OPTION
byte NullPointerException ifbytes
is null IllegalArgumentException ifbytes
has length that is too short or too long IllegalArgumentException ifbytes[0]
is notRFC2217.COM_PORT_OPTION
IllegalArgumentException ifcommand
is greater than or equal toRFC2217.SERVER_OFFSET
IllegalArgumentException ifbytes[1]
is notcommand
orcommand
+RFC2217.SERVER_OFFSET
-
-
Method Detail
-
isServerCommand
public final boolean isServerCommand()
Determine if this command is client-to-server or server-to-client.- Returns:
- true if this command is sent from the server to the client, false for the opposite
-
getBytes
public final int[] getBytes()
Get the encoding of this instance.- Returns:
- encoding starting with
COM-PORT-OPTION
-
getCommand
public final int getCommand()
Get the command byte.- Returns:
- RFC 2217-defined byte value for this command
-
getName
public java.lang.String getName()
Get the human-readable name of this option.
-
toString
public abstract java.lang.String toString()
Get the human-readable description of this option.- Overrides:
toString
in classjava.lang.Object
-
visit
public abstract void visit(ComPortCommandSwitch sw)
Apply visitor pattern.- Parameters:
sw
- visitor switch handler
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
-