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
-
Constructor Summary
ConstructorDescriptionConstructs an emptyLoopbackPortHub
.LoopbackPortHub
(String... aPorts) Constructs theLoopbackPortHub
with 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 theLoopbackPortHub
with 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:
ports
in interfacePortHub<LoopbackPort,
PortMetrics> - Returns:
- An array of available
Port
instances, if there are no ports than an empty array (size 0) is returned. - Throws:
IOException
- Thrown in case accessing the list ofPort
instances failed due to I/O problems.
-
toPort
Returns thePort
identified by the given alias.- Specified by:
toPort
in interfacePortHub<LoopbackPort,
PortMetrics> - Parameters:
aAlias
- The alias identifying the givenPort
.- Returns:
- The given
Port
. - Throws:
IOException
- Thrown in case accessing the list ofPort
instances failed due to I/O problems.
-
toPort
Returns thePort
identified by the given alias.- Specified by:
toPort
in interfacePortHub<LoopbackPort,
PortMetrics> - Parameters:
aAlias
- The alias identifying the givenPort
.aPortMetrics
- ThePortMetrics
to use when opening the port without providing any specific arguments.- Returns:
- The given
Port
. - Throws:
IOException
- Thrown in case accessing the list ofPort
instances failed due to I/O problems.
-