001package jmri.jmrix.jmriclient; 002 003import javax.annotation.Nonnull; 004import jmri.Reporter; 005 006/** 007 * Implement reporter manager for JMRIClient systems 008 * <p> 009 * System names are "prefixnnn", where prefix is the system prefix and nnn is 010 * the reporter number without padding. 011 * 012 * @author Paul Bender Copyright (C) 2011 013 */ 014public class JMRIClientReporterManager extends jmri.managers.AbstractReporterManager { 015 016 public JMRIClientReporterManager(JMRIClientSystemConnectionMemo memo) { 017 super(memo); 018 } 019 020 /** 021 * {@inheritDoc} 022 */ 023 @Override 024 @Nonnull 025 public JMRIClientSystemConnectionMemo getMemo() { 026 return (JMRIClientSystemConnectionMemo) memo; 027 } 028 029 @Override 030 @Nonnull 031 protected Reporter createNewReporter(@Nonnull String systemName, String userName) throws IllegalArgumentException { 032 int addr = Integer.parseInt(systemName.substring(getSystemPrefix().length() + 1)); 033 Reporter r = new JMRIClientReporter(addr, getMemo()); 034 r.setUserName(userName); 035 return r; 036 } 037 038 /** 039 * Validates to only numeric system names. 040 * {@inheritDoc} 041 */ 042 @Override 043 @Nonnull 044 public String validateSystemNameFormat(@Nonnull String name, @Nonnull java.util.Locale locale) throws jmri.NamedBean.BadSystemNameException { 045 return validateSystemNameFormatOnlyNumeric(name,locale); 046 } 047 048}