Skip to content
Permalink
Browse files

fix: validate system names in managers

  • Loading branch information...
rhwood committed Jul 13, 2019
1 parent 6e5397b commit 47d0643ffd23eec7b47c7e95818720d45a962a44
@@ -242,7 +242,7 @@ public default String validateSystemNamePrefix(@Nonnull String name, @Nonnull Lo
@CheckReturnValue
@Nonnull
public default String validateTrimmedSystemNameFormat(@Nonnull String name, @Nonnull Locale locale) {
name = validateSystemNameFormat(name, locale);
name = validateSystemNamePrefix(name, locale);
String prefix = getSystemNamePrefix();
String suffix = name.substring(prefix.length());
if (!suffix.equals(suffix.trim())) {
@@ -1,5 +1,6 @@
package jmri.jmrix.rps;

import java.util.Locale;
import jmri.JmriException;
import jmri.Reporter;
import org.slf4j.Logger;
@@ -53,13 +54,21 @@ public String createSystemName(String curAddress, String prefix) throws JmriExce
}
return sys;
}


/**
* {@inheritDoc}
*/
@Override
public String validateSystemNameFormat(String name, Locale locale) {
return memo.validateSystemNameFormat(name, this, locale);
}

/**
* {@inheritDoc}
*/
@Override
public NameValidity validSystemNameFormat(String systemName) {
return (memo.validSystemNameFormat(systemName, typeLetter()));
return memo.validSystemNameFormat(systemName, typeLetter());
}

/**
@@ -1,5 +1,6 @@
package jmri.jmrix.rps;

import java.util.Locale;
import jmri.JmriException;
import jmri.Sensor;
import org.slf4j.Logger;
@@ -70,13 +71,21 @@ public String createSystemName(String curAddress, String prefix) throws JmriExce
}
return sys;
}


/**
* {@inheritDoc}
*/
@Override
public String validateSystemNameFormat(String name, Locale locale) {
return memo.validateSystemNameFormat(name, this, locale);
}

/**
* {@inheritDoc}
*/
@Override
public NameValidity validSystemNameFormat(String systemName) {
return (memo.validSystemNameFormat(systemName, typeLetter()));
return memo.validSystemNameFormat(systemName, typeLetter());
}

/**
@@ -116,7 +116,7 @@ public boolean provides(Class<?> type) {
* @param locale the locale for user messages
* @return name, unchanged
*/
public String validSystemNameFormat(String name, Manager manager, Locale locale) {
public String validateSystemNameFormat(String name, Manager manager, Locale locale) {
manager.validateSystemNamePrefix(name, locale);
String[] points = name.substring(manager.getSystemNamePrefix().length()).split(";");
if (points.length < 3) {

0 comments on commit 47d0643

Please sign in to comment.
You can’t perform that action at this time.