java.lang.Object
org.refcodes.serial.LoopbackPortHub
- All Implemented Interfaces:
PortHub<LoopbackPort,PortMetrics>
- Direct Known Subclasses:
CrossoverLoopbackPortHub
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 -
Constructor Summary
ConstructorsConstructorDescriptionConstructs an emptyLoopbackPortHub.LoopbackPortHub(String... aPorts) Constructs theLoopbackPortHubwith the given ports (e.g. ports with the given port aliases). -
Method Summary
-
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 ports of the system.- Specified by:
portsin interfacePortHub<LoopbackPort,PortMetrics> - Returns:
- An array of available
Portinstances, if there are no ports than an empty array (size 0) is returned. - 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:
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.aPortMetrics- ThePortMetricsto use when opening the port without providing any specific arguments.- Returns:
- The given
Port. - Throws:
IOException- Thrown in case accessing the list ofPortinstances failed due to I/O problems.
-