/** * Parses the given text as an integer, avoiding runtime exceptions. * * @param aText * the text to parse as an integer, can be <code>null</code> or * empty. * @return the numeric representation of the given text, or -1 if the text * could not be parsed correctly as integer. * @see #safeParseInt(String, int) */ public static int safeParseInt( final String aText ) { return safeParseInt( aText, -1 ); }
/** * Returns the number of channels in each sample. * * @return the channel count, >= 0. */ public int getChannelCount() { return NumberUtils.safeParseInt( this.channelCount.getText(), 8 ); }
/** * Returns the width (in bytes) of each sample. * * @return the sample width, in bytes, >= 0. */ public int getSampleWidth() { return NumberUtils.safeParseInt( this.sampleWidth.getText(), 1 ); }
/** * Returns the new element height. * * @return the new element height, in pixels. */ public int getElementHeight() { int defaultValue = UIManager.getInt( UIManagerKeys.CHANNEL_HEIGHT ); return NumberUtils.safeParseInt( this.heightEditor.getText(), defaultValue ); }
/** * Returns the new signal height. * * @return the new signal height, in pixels. */ public int getSignalHeight() { int defaultValue = UIManager.getInt( UIManagerKeys.DIGITAL_SIGNAL_HEIGHT ); return NumberUtils.safeParseInt( this.signalHeightEditor.getText(), defaultValue ); }
/** * {@inheritDoc} */ @Override protected JMenuItem createMenuItem( final String aName ) { int idx = NumberUtils.safeParseInt( aName ); if ( idx >= 0 ) { final Action action = this.controller.getAction( GotoNthCursorAction.getID( idx ) ); return new JMenuItem( action ); } return null; }
/** * {@inheritDoc} */ @Override protected void prepareToolTask( final ToolTask<AcquisitionResult> aToolTask ) { int[] channels = new int[this.lines.length]; for ( int i = 0; i < channels.length; i++ ) { channels[i] = this.lines[i].getSelectedIndex(); } int clockSpeed = NumberUtils.safeParseInt( this.clockSpeed.getText() ); final LineDecoderTask toolTask = ( LineDecoderTask )aToolTask; toolTask.setLineDecoder( ( LineDecoder )this.lineDecoders.getSelectedItem() ); toolTask.setChannels( channels ); toolTask.setInverted( this.inverted.isSelected() ); toolTask.setRecoverClock( this.recoverClock.isSelected() ); toolTask.setClockSpeed( clockSpeed ); }
size = safeParseInt( instrValue ); rate = safeParseInt( instrValue ); channels = safeParseInt( instrValue ); enabledChannels = safeParseInt( instrValue );
size = safeParseInt( instrValue ); rate = safeParseInt( instrValue ); channels = safeParseInt( instrValue ); enabledChannels = safeParseInt( instrValue ); final int idx = safeParseInt( instrKey.substring( 6 ) ); final long pos = Long.parseLong( instrValue ); if ( pos > Long.MIN_VALUE )
size = safeParseInt( instrValue ); rate = safeParseInt( instrValue ); channels = safeParseInt( instrValue ); enabledChannels = safeParseInt( instrValue ); final int idx = safeParseInt( instrKey.substring( 6 ) ); final long pos = Long.parseLong( instrValue ); if ( pos > Long.MIN_VALUE )
if ( ( preferredPortRate != null ) && !"null".equals( preferredPortRate ) ) int value = NumberUtils.safeParseInt( preferredPortRate, -1 ); if ( ( value >= 0 ) && ( value < BAUDRATES.length ) )