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

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

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

NumberUtils.smartParseInt介绍

[英]Provides a "smart" integer parsing routine that allows (decimal) numbers in string form with all kind of trailing characters to be parsed into an integer. Some trailing characters are understood as being part of the number, like "k" to denote a value in thousands, or "m" to denote a value in millions.

Characters recognized are: "k" and "M" to denote units of 1024, 10241024.
[中]提供一个“智能”整数解析例程,允许将字符串形式的(十进制)数字和所有类型的尾随字符解析为整数。一些尾随字符被理解为数字的一部分,比如“k”表示以千为单位的值,或者“m”表示以百万为单位的值。
识别出的字符是:“k”和“M”,表示1024、1024
1024的单位。

代码示例

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

/**
 * Provides a "smart" integer parsing routine that allows (decimal) numbers in
 * string form with all kind of trailing characters to be parsed into an
 * integer. Some trailing characters are understood as being part of the
 * number, like "k" to denote a value in thousands, or "m" to denote a value
 * in millions.
 * <p>
 * Characters recognized are: "k" and "M" to denote units of 1024, 1024*1024.
 * </p>
 * 
 * @param aText
 *          the text to parse into an integer value, cannot be
 *          <code>null</code>.
 * @return the integer value part of the given text, or 0 if the text couldn't
 *         be parsed.
 */
public static int smartParseInt( final String aText )
{
 return smartParseInt( aText, 0 );
}

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

/**
 * Provides a "smart" integer parsing routine that allows (decimal) numbers in
 * string form with all kind of trailing characters to be parsed into an
 * integer. Some trailing characters are understood as being part of the
 * number, like "k" to denote a value in thousands, or "m" to denote a value
 * in millions.
 * <p>
 * Characters recognized are: "k" and "M" to denote units of 1024, 1024*1024.
 * </p>
 * 
 * @param aText
 *          the text to parse into an integer value, cannot be
 *          <code>null</code>;
 * @param aDefault
 *          the default value to return in case the given text couldn't be
 *          parsed into a valid number.
 * @return the integer value part of the given text, or the given default
 *         value if the text couldn't be parsed.
 */
public static int smartParseInt( final String aText, final int aDefault )
{
 return smartParseInt( aText, UnitDefinition.BINARY, aDefault );
}

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

/**
 * Provides a "smart" integer parsing routine that allows (decimal) numbers in
 * string form with all kind of trailing characters to be parsed into an
 * integer. Some trailing characters are understood as being part of the
 * number, like "k" to denote a value in thousands, or "m" to denote a value
 * in millions.
 * 
 * @param aText
 *          the text to parse into an integer value, cannot be
 *          <code>null</code>;
 * @param aUnitDefinition
 *          the unit definition for "k" and "M" characters, should be either
 *          SI (units of 1000) or BINARY (units of 1024).
 * @return the integer value part of the given text, or 0 if the text couldn't
 *         be parsed.
 */
public static int smartParseInt( final String aText, final UnitDefinition aUnitDefinition )
{
 return smartParseInt( aText, aUnitDefinition, 0 );
}

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

/**
 * Returns the number of samples to take.
 *
 * @return the sample depth, >= 0.
 */
public int getSampleDepth()
{
 return NumberUtils.smartParseInt( this.sampleDepth.getText(), 1024 );
}

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

/**
 * @param aComboBox
 * @return
 */
static Integer getNumericValue( final JTextField aTextField )
{
 if ( aTextField == null )
 {
  return null;
 }
 String value = aTextField.getText();
 if ( value == null )
 {
  return null;
 }
 return Integer.valueOf( NumberUtils.smartParseInt( value ) );
}

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

/**
 * Determines which RLE-mode to use. There are up to four different RLE-modes
 * present in 'dogsbody' Verilog firmware.
 * <p>
 * The RLE-Encoding modes are:
 * </p>
 * <ol start="0">
 * <li>Issue {values} & {RLE-count} as pairs. Count inclusive of value
 * (<strike>backwards compatible</strike>);</li>
 * <li>Issue {values} & {RLE-count} as pairs. Count is <em>exclusive</em> of
 * value. Compatible with all clients;</li>
 * <li>Periodic. {values} reissued approximately every 256 {RLE-count} fields;
 * </li>
 * <li>Unlimited. {values} can be followed by unlimited numbers of
 * {RLE-counts}.</li>
 * </ol>
 * 
 * @return a RLE-mode, defaults to 1.
 */
private static int determineRleMode()
{
 return NumberUtils.smartParseInt( System.getProperty( "nl.lxtreme.ols.rle.mode" ), 1 );
}

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

/**
 * @param aComboBox
 * @return
 */
static Integer getNumericValue( final JComboBox aTextField )
{
 if ( aTextField == null )
 {
  return null;
 }
 Object value = aTextField.getSelectedItem();
 if ( value == null )
 {
  return null;
 }
 return Integer.valueOf( NumberUtils.smartParseInt( String.valueOf( value ) ) );
}

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

/**
 * @return the selected sample rate, in Hertz.
 */
private int getSelectedSampleRate()
{
 final String value = getComboBoxText( this.speedSelect );
 return NumberUtils.smartParseInt( value, UnitDefinition.SI, SumpProtocolConstants.CLOCK );
}

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

/**
 * Returns the sample rate of the generic device.
 *
 * @return the sample rate in Hertz (Hz), or -1 if not available.
 */
public int getSampleRate()
{
 if ( isTimingDataPresent() )
 {
  return NumberUtils.smartParseInt( this.sampleRate.getText(), UnitDefinition.SI, 1000000 );
 }
 return Ols.NOT_AVAILABLE;
}

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

toolTask.setParity( ( Parity )this.parity.getSelectedItem() );
toolTask.setStopBits( ( StopBits )this.stop.getSelectedItem() );
toolTask.setBitCount( NumberUtils.smartParseInt( ( String )this.bits.getSelectedItem(), 8 ) );

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

int baudrate = NumberUtils.smartParseInt( String.valueOf( this.portRateSelect.getSelectedItem() ) );

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

aSettings.putInt( "remPort", NumberUtils.smartParseInt( this.remPort.getText() ) );
aSettings.put( "port", String.valueOf( this.portSelect.getSelectedItem() ) );
aSettings.put( "portRate", String.valueOf( this.portRateSelect.getSelectedItem() ) );

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

final int delay = NumberUtils.smartParseInt( this.triggerDelay[stage].getText() );

相关文章