- java.lang.Object
-
- org.refcodes.serial.LoopbackPortHub
-
- org.refcodes.serial.CrossoverLoopbackPortHub
-
- All Implemented Interfaces:
PortHub<LoopbackPort,PortMetrics>
public class CrossoverLoopbackPortHub extends LoopbackPortHub
ACrossoverLoopbackPortHubis an in-memory implementation of aPortHubwhich'sPortinstances loop their output directly to the "connected"LoopbackPortHubcounterpartPortinstances ("other end of the wire"). The counterpartPortinstances have the same alias so it is easy to retrieve the crossoverLoopbackPortinstances. 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
Constructors Constructor Description CrossoverLoopbackPortHub(LoopbackPortHub aCrossoverPortHub)Constructs aCrossoverLoopbackPortHubwith the givenLoopbackPortHubas counterpart.CrossoverLoopbackPortHub(LoopbackPortHub aCrossoverPortHub, String... aPorts)Constructs aCrossoverLoopbackPortHubwith the givenLoopbackPortHubas counterpart and the given ports (e.g. ports with the given port aliases).
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description LoopbackPort[]ports()Lists the available ports of the system.LoopbackPorttoPort(String aAlias)Returns thePortidentified by the given alias.
-
-
-
Constructor Detail
-
CrossoverLoopbackPortHub
public CrossoverLoopbackPortHub(LoopbackPortHub aCrossoverPortHub)
Constructs aCrossoverLoopbackPortHubwith the givenLoopbackPortHubas counterpart.- Parameters:
aCrossoverPortHub- TheCrossoverLoopbackPortHub's counterpartLoopbackPortHub.
-
CrossoverLoopbackPortHub
public CrossoverLoopbackPortHub(LoopbackPortHub aCrossoverPortHub, String... aPorts)
Constructs aCrossoverLoopbackPortHubwith the givenLoopbackPortHubas 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 Detail
-
toPort
public LoopbackPort toPort(String aAlias) throws NoSuchPortExcpetion, IOException
Returns thePortidentified by the given alias.- Specified by:
toPortin interfacePortHub<LoopbackPort,PortMetrics>- Overrides:
toPortin 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 ofPortinstances failed due to I/O problems.
-
ports
public LoopbackPort[] ports() throws IOException
Lists the available ports of the system.- Specified by:
portsin interfacePortHub<LoopbackPort,PortMetrics>- Overrides:
portsin classLoopbackPortHub- 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.
-
-