private void validateChannelName ( final String channelName ) throws InvalidChannelName { if ( ! this . _isConsole ) { if ( ! TechType . hasValidTech ( channelName ) ) { throw new InvalidChannelName ( "Invalid channelName: " + channelName + ". Unknown tech." ) ; //$NON-NLS-1$ //$NON-NLS-2$ } // Check we have the expected hypen final int hypen = channelName . indexOf ( "-" ) ; //$NON-NLS-1$ if ( hypen == - 1 ) { throw new InvalidChannelName ( "Invalid channelName: " + channelName + ". Missing hypen." ) ; //$NON-NLS-1$ //$NON-NLS-2$ } // Check we have the expected slash final int slash = channelName . indexOf ( "/" ) ; //$NON-NLS-1$ if ( slash == - 1 ) { throw new InvalidChannelName ( "Invalid channelName: " + channelName + ". Missing slash." ) ; //$NON-NLS-1$ //$NON-NLS-2$ } // Check that the hypen is after the slash. if ( hypen < slash ) { throw new InvalidChannelName ( "Invalid channelName: " + channelName + ". Hypen must be after the slash." ) ; //$NON-NLS-1$ //$NON-NLS-2$ } // Check that there is at least one characters between the hypen and // the // slash if ( ( hypen - slash ) < 2 ) { throw new InvalidChannelName ( "Invalid channelName: " + channelName //$NON-NLS-1$ + ". Must be one character between the hypen and the slash." ) ; //$NON-NLS-1$ } // Check that the channel sequence number is at least 1 character // long. if ( ( channelName . length ( ) - hypen ) < 2 ) { throw new InvalidChannelName ( "Invalid channelName: " + channelName //$NON-NLS-1$ + ". The channel sequence number must be at least 1 character." ) ; //$NON-NLS-1$ } } }
validates the channel name . Validate is to be called after the channel has been cleaned .