java.lang.Object
org.refcodes.serial.LoopbackPortHub
- All Implemented Interfaces:
PortHub<LoopbackPort,PortMetrics>
- Direct Known Subclasses:
CrossoverLoopbackPortHub
public class LoopbackPortHub extends Object implements PortHub<LoopbackPort,PortMetrics>
The
LoopbackPortHub is a plain implementation of a PortHub
serving an infinite number of LoopbackPort instances: When calling
toPort(String) and the such port is unknown, then it is created (and
from then on known).-
Field Summary
Fields Modifier and Type Field Description protected Set<LoopbackPort>_ports -
Constructor Summary
Constructors Constructor Description LoopbackPortHub()Constructs an emptyLoopbackPortHub.LoopbackPortHub(String... aPorts)Constructs theLoopbackPortHubwith the given ports (e.g. ports with the given port aliases). -
Method Summary
Modifier and Type Method Description LoopbackPort[]ports()Lists the available TTY-/COM-Ports of the system.LoopbackPorttoPort(String aAlias)Returns thePortidentified by the given alias.
-
Field Details
-
_ports
-
-
Constructor Details
-
LoopbackPortHub
public LoopbackPortHub()Constructs an emptyLoopbackPortHub. Add ports by callingtoPort(String). -
LoopbackPortHub
Constructs theLoopbackPortHubwith the given ports (e.g. ports with the given port aliases).- Parameters:
aPorts- The aliases for the ports to be contained within thisPortHub.
-
-
Method Details
-
ports
Lists the available TTY-/COM-Ports of the system.- Specified by:
portsin interfacePortHub<LoopbackPort,PortMetrics>- Returns:
- An array of available
Portinstances. - Throws:
IOException- Thrown in case accessing the list ofPortinstances failed due to I/O problems.
-
toPort
Returns thePortidentified by the given alias.- Specified by:
toPortin interfacePortHub<LoopbackPort,PortMetrics>- Parameters:
aAlias- The alias identifying the givenPort.- Returns:
- The given
Port. - Throws:
NoSuchPortExcpetion- thrown in case there is no such port found.IOException- Thrown in case accessing the list ofPortinstances failed due to I/O problems.
-