java.lang.Object
org.refcodes.serial.LoopbackPortHub
org.refcodes.serial.CrossoverLoopbackPortHub
- All Implemented Interfaces:
PortHub<LoopbackPort,
PortMetrics>
A
CrossoverLoopbackPortHub
is an in-memory implementation of a
PortHub
which's Port
instances loop their output directly to
the "connected" LoopbackPortHub
counterpart Port
instances
("other end of the wire"). The counterpart Port
instances have the
same alias so it is easy to retrieve the crossover LoopbackPort
instances. This is suitable for cases using a some kind of frequent handshake
between a transmitter and a receiver on the same line where we have to
simulate a bidirectional in-memory communication between two ports.-
Field Summary
Fields inherited from class org.refcodes.serial.LoopbackPortHub
_ports
-
Constructor Summary
ConstructorDescriptionCrossoverLoopbackPortHub
(LoopbackPortHub aCrossoverPortHub) Constructs aCrossoverLoopbackPortHub
with the givenLoopbackPortHub
as counterpart.CrossoverLoopbackPortHub
(LoopbackPortHub aCrossoverPortHub, String... aPorts) Constructs aCrossoverLoopbackPortHub
with the givenLoopbackPortHub
as counterpart and the given ports (e.g. ports with the given port aliases). -
Method Summary
-
Constructor Details
-
CrossoverLoopbackPortHub
Constructs aCrossoverLoopbackPortHub
with the givenLoopbackPortHub
as counterpart.- Parameters:
aCrossoverPortHub
- TheCrossoverLoopbackPortHub
's counterpartLoopbackPortHub
.
-
CrossoverLoopbackPortHub
Constructs aCrossoverLoopbackPortHub
with the givenLoopbackPortHub
as counterpart and the given ports (e.g. ports with the given port aliases).- Parameters:
aCrossoverPortHub
- TheCrossoverLoopbackPortHub
's counterpartLoopbackPortHub
.aPorts
- The ports to be created initially.
-
-
Method Details
-
toPort
Returns thePort
identified by the given alias.- Specified by:
toPort
in interfacePortHub<LoopbackPort,
PortMetrics> - Overrides:
toPort
in classLoopbackPortHub
- 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 ofPort
instances failed due to I/O problems.
-
ports
Lists the available ports of the system.- Specified by:
ports
in interfacePortHub<LoopbackPort,
PortMetrics> - Overrides:
ports
in classLoopbackPortHub
- 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.
-