Class ConnectionConfigManager
- java.lang.Object
-
- jmri.beans.UnboundBean
-
- jmri.beans.Bean
-
- jmri.util.prefs.AbstractPreferencesManager
-
- jmri.jmrix.ConnectionConfigManager
-
- All Implemented Interfaces:
java.lang.Iterable<ConnectionConfig>
,BeanInterface
,PropertyChangeFirer
,PropertyChangeProvider
,JmriServiceProviderInterface
,PreferencesManager
public class ConnectionConfigManager extends AbstractPreferencesManager implements java.lang.Iterable<ConnectionConfig>
Manager for ConnectionConfig objects.
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
CLASS
static java.lang.String
CONNECTION
static java.lang.String
CONNECTIONS
static java.lang.String
MANUFACTURER
static java.lang.String
SYSTEM_NAME
static java.lang.String
USER_NAME
-
Fields inherited from class jmri.beans.Bean
propertyChangeSupport
-
-
Constructor Summary
Constructors Constructor Description ConnectionConfigManager()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
add(ConnectionConfig c)
Add aConnectionConfig
following the rules specified inCollection.add(java.lang.Object)
.java.lang.String
getConnectionManufacturer(java.lang.String connectionType)
Get the manufacturer that is supported by a connection type.java.lang.String[]
getConnectionManufacturers()
Get the list of known manufacturers.java.lang.String[]
getConnectionManufacturers(java.lang.String connectionType)
Get the list of all known manufacturers that a single connection type supports.ConnectionConfig[]
getConnections()
Get an Array ofConnectionConfig
objects.ConnectionConfig
getConnections(int index)
Get theConnectionConfig
at index following the rules specified inCollection.add(java.lang.Object)
.java.lang.String[]
getConnectionTypes(java.lang.String manufacturer)
Get the class names for classes supporting layout connections for the given manufacturer.java.util.Set<java.lang.Class<? extends PreferencesManager>>
getRequires()
Get the set of PreferencesManagers that must be initialized prior to initializing this PreferencesManager.void
initialize(Profile profile)
Initialize the PreferencesManager with preferences associated with the provided Profile.java.util.Iterator<ConnectionConfig>
iterator()
boolean
remove(ConnectionConfig c)
Remove aConnectionConfig
following the rules specified inCollection.add(java.lang.Object)
.void
savePreferences(Profile profile)
Save the preferences that this provider manages for the provided Profile.-
Methods inherited from class jmri.util.prefs.AbstractPreferencesManager
addInitializationException, getInitializationExceptions, getProvides, isInitialized, isInitializedWithExceptions, isInitializing, requireAllOther, requiresNoInitializedWithExceptions, requiresNoInitializedWithExceptions, setInitialized, setInitializing
-
Methods inherited from class jmri.beans.Bean
addPropertyChangeListener, addPropertyChangeListener, fireIndexedPropertyChange, fireIndexedPropertyChange, fireIndexedPropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getPropertyChangeListeners, getPropertyChangeListeners, isNotifyOnEDT, removePropertyChangeListener, removePropertyChangeListener
-
Methods inherited from class jmri.beans.UnboundBean
getIndexedProperty, getProperty, getPropertyNames, hasIndexedProperty, hasProperty, setIndexedProperty, setProperty
-
-
-
-
Field Detail
-
CONNECTIONS
public static final java.lang.String CONNECTIONS
- See Also:
- Constant Field Values
-
CONNECTION
public static final java.lang.String CONNECTION
- See Also:
- Constant Field Values
-
CLASS
public static final java.lang.String CLASS
- See Also:
- Constant Field Values
-
USER_NAME
public static final java.lang.String USER_NAME
- See Also:
- Constant Field Values
-
SYSTEM_NAME
public static final java.lang.String SYSTEM_NAME
- See Also:
- Constant Field Values
-
MANUFACTURER
public static final java.lang.String MANUFACTURER
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
ConnectionConfigManager
public ConnectionConfigManager()
-
-
Method Detail
-
initialize
public void initialize(Profile profile) throws HasConnectionButUnableToConnectException
Description copied from interface:PreferencesManager
Initialize the PreferencesManager with preferences associated with the provided Profile.Implementing classes should throw an InitializationException with a user readable localized message, since it most likely be displayed to the user. Implementing classes will still want to ensure that
PreferencesManager.isInitialized(jmri.profile.Profile)
orPreferencesManager.isInitializedWithExceptions(jmri.profile.Profile)
return true if throwing an InitializationException to ensure that the provider is not repeatedly initialized.- Specified by:
initialize
in interfacePreferencesManager
- Parameters:
profile
- the configuration profile used for this initialization; may be null to initialize for this user regardless of profile- Throws:
HasConnectionButUnableToConnectException
-
getRequires
@Nonnull public java.util.Set<java.lang.Class<? extends PreferencesManager>> getRequires()
Description copied from class:AbstractPreferencesManager
Get the set of PreferencesManagers that must be initialized prior to initializing this PreferencesManager. It is generally preferable to require an Interface or an abstract Class instead of a concrete Class, since that allows all (or any) concrete implementations of the required class to be initialized to provide required services for the requiring PreferencesManager instance.Note that for any set of PreferencesManagers with the same requirements, or with a circular dependency between each other, the order in which the PreferencesManagers in that set are initialized should be considered non-deterministic.
This implementation includes a default dependency on the
ConnectionConfigManager
.- Specified by:
getRequires
in interfacePreferencesManager
- Overrides:
getRequires
in classAbstractPreferencesManager
- Returns:
- An set of classes; if there are no dependencies, return an empty set instead of null; overriding implementations may add to this set directly
-
savePreferences
public void savePreferences(Profile profile)
Description copied from interface:PreferencesManager
Save the preferences that this provider manages for the provided Profile.- Specified by:
savePreferences
in interfacePreferencesManager
- Parameters:
profile
- the profile associated with the preferences to save; may be null to save preferences that apply to the current user regardless of profile
-
add
public boolean add(@Nonnull ConnectionConfig c) throws java.lang.NullPointerException
Add aConnectionConfig
following the rules specified inCollection.add(java.lang.Object)
.- Parameters:
c
- an existing ConnectionConfig- Returns:
- true if c was added, false otherwise
- Throws:
java.lang.NullPointerException
- if c is null
-
remove
public boolean remove(@Nonnull ConnectionConfig c)
Remove aConnectionConfig
following the rules specified inCollection.add(java.lang.Object)
.- Parameters:
c
- an existing ConnectionConfig- Returns:
- true if c was removed, false otherwise
-
getConnections
@Nonnull public ConnectionConfig[] getConnections()
Get an Array ofConnectionConfig
objects.- Returns:
- an Array, possibly empty if there are no ConnectionConfig objects.
-
getConnections
public ConnectionConfig getConnections(int index)
Get theConnectionConfig
at index following the rules specified inCollection.add(java.lang.Object)
.- Parameters:
index
- index of the ConnectionConfig to return- Returns:
- the ConnectionConfig at the specified location
-
iterator
public java.util.Iterator<ConnectionConfig> iterator()
- Specified by:
iterator
in interfacejava.lang.Iterable<ConnectionConfig>
-
getConnectionTypes
@Nonnull public java.lang.String[] getConnectionTypes(@Nonnull java.lang.String manufacturer)
Get the class names for classes supporting layout connections for the given manufacturer.- Parameters:
manufacturer
- the name of the manufacturer- Returns:
- An array of supporting class names; will return the list of internal connection classes if manufacturer is not a known manufacturer; the array may be empty if there are no supporting classes for the given manufacturer.
-
getConnectionManufacturers
@Nonnull public java.lang.String[] getConnectionManufacturers()
Get the list of known manufacturers.- Returns:
- An array of known manufacturers.
-
getConnectionManufacturer
@CheckForNull public java.lang.String getConnectionManufacturer(@Nonnull java.lang.String connectionType)
Get the manufacturer that is supported by a connection type. If there are multiple manufacturers supported by connectionType, returns only the first manufacturer.- Parameters:
connectionType
- the class name of a connection type.- Returns:
- the supported manufacturer. Returns null if no manufacturer is associated with the connectionType.
-
getConnectionManufacturers
@Nonnull public java.lang.String[] getConnectionManufacturers(@Nonnull java.lang.String connectionType)
Get the list of all known manufacturers that a single connection type supports.- Parameters:
connectionType
- the class name of a connection type.- Returns:
- an Array of supported manufacturers. Returns an empty Array if no manufacturer is associated with the connectionType.
-
-