nl.lxtreme.ols.util.NumberUtils.safeParseInt()方法的使用及代码示例

x33g5p2x  于2022-01-25 转载在 其他  
字(3.5k)|赞(0)|评价(0)|浏览(73)

本文整理了Java中nl.lxtreme.ols.util.NumberUtils.safeParseInt()方法的一些代码示例,展示了NumberUtils.safeParseInt()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。NumberUtils.safeParseInt()方法的具体详情如下:
包路径:nl.lxtreme.ols.util.NumberUtils
类名称:NumberUtils
方法名:safeParseInt

NumberUtils.safeParseInt介绍

[英]Parses the given text as an integer, avoiding runtime exceptions.
[中]将给定文本解析为整数,避免运行时异常。

代码示例

代码示例来源:origin: jawi/ols

/**
 * 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 );
}

代码示例来源:origin: jawi/ols

/**
 * Returns the number of channels in each sample.
 *
 * @return the channel count, >= 0.
 */
public int getChannelCount()
{
 return NumberUtils.safeParseInt( this.channelCount.getText(), 8 );
}

代码示例来源:origin: jawi/ols

/**
 * 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 );
}

代码示例来源:origin: jawi/ols

/**
 * 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 );
}

代码示例来源:origin: jawi/ols

/**
 * 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 );
}

代码示例来源:origin: jawi/ols

/**
 * {@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;
}

代码示例来源:origin: jawi/ols

/**
 * {@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 );
}

代码示例来源:origin: jawi/ols

size = safeParseInt( instrValue );
rate = safeParseInt( instrValue );
channels = safeParseInt( instrValue );
enabledChannels = safeParseInt( instrValue );

代码示例来源:origin: jawi/ols

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 )

代码示例来源:origin: jawi/ols

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 )

代码示例来源:origin: jawi/ols

if ( ( preferredPortRate != null ) && !"null".equals( preferredPortRate ) )
 int value = NumberUtils.safeParseInt( preferredPortRate, -1 );
 if ( ( value >= 0 ) && ( value < BAUDRATES.length ) )

相关文章