- 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>
TheLoopbackPortHubis a plain implementation of aPortHubserving an infinite number ofLoopbackPortinstances: When callingtoPort(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
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.
-
-
-
Field Detail
-
_ports
protected Set<LoopbackPort> _ports
-
-
Constructor Detail
-
LoopbackPortHub
public LoopbackPortHub()
Constructs an emptyLoopbackPortHub. Add ports by callingtoPort(String).
-
LoopbackPortHub
public LoopbackPortHub(String... aPorts)
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 Detail
-
ports
public LoopbackPort[] ports() throws IOException
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
public LoopbackPort toPort(String aAlias) throws NoSuchPortExcpetion, IOException
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.
-
-