当前位置: 首页>>代码示例>>Java>>正文


Java StringParser.isInt方法代码示例

本文整理汇总了Java中com.helger.commons.string.StringParser.isInt方法的典型用法代码示例。如果您正苦于以下问题:Java StringParser.isInt方法的具体用法?Java StringParser.isInt怎么用?Java StringParser.isInt使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.helger.commons.string.StringParser的用法示例。


在下文中一共展示了StringParser.isInt方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: _extSplit

import com.helger.commons.string.StringParser; //导入方法依赖的package包/类
@Nonnull
@ReturnsMutableCopy
private static String [] _extSplit (@Nonnull final String s)
{
  final String [] aDotParts = StringHelper.getExplodedArray ('.', s, 2);
  if (aDotParts.length == 2)
  {
    // Dots always take precedence
    return aDotParts;
  }

  if (StringParser.isInt (aDotParts[0]))
  {
    // If it is numeric, use the dot parts anyway (e.g. for "5" or "-1")
    return aDotParts;
  }

  final String [] aDashParts = StringHelper.getExplodedArray ('-', s, 2);
  if (aDashParts.length == 1)
  {
    // Neither dot nor dash present
    return aDotParts;
  }

  // More matches for dash split! (e.g. "0-RC1")
  return aDashParts;
}
 
开发者ID:phax,项目名称:ph-commons,代码行数:28,代码来源:Version.java

示例2: _convertNumericCodes

import com.helger.commons.string.StringParser; //导入方法依赖的package包/类
private static String _convertNumericCodes (final String sNumericCode)
{
  if (StringHelper.hasNoText (sNumericCode))
    return null;

  final String sRealNumericCode = StringHelper.replaceAll (sNumericCode, '\n', ' ');
  // E.g. "22 to 25", "44 or 45", "21 to 23 or 31 to 33"
  final ICommonsList <String> ret = new CommonsArrayList <> ();

  // First split by "or"
  final String [] aOrParts = RegExHelper.getSplitToArray (sRealNumericCode, " or ");
  for (final String sOrPart : aOrParts)
  {
    if (sOrPart.contains (" to "))
    {
      // Split by "to"
      final String [] aToParts = RegExHelper.getSplitToArray (sOrPart, " to ");
      if (aToParts.length != 2)
        throw new IllegalStateException (sRealNumericCode +
                                         " ==> " +
                                         Arrays.toString (aToParts) +
                                         " ==> more than 2 parts");
      final int nFrom = StringParser.parseInt (aToParts[0].trim (), -1);
      final int nTo = StringParser.parseInt (aToParts[1].trim (), -1);
      if (nFrom == -1 || nTo == -1)
        throw new IllegalStateException (sRealNumericCode +
                                         " ==> " +
                                         Arrays.toString (aToParts) +
                                         " ==> not numeric");
      for (int i = nFrom; i <= nTo; ++i)
        ret.add (Integer.toString (i));
    }
    else
    {
      // Explicit value
      final String sRealOrPart = sOrPart.trim ();
      if (!StringParser.isInt (sRealOrPart))
        throw new IllegalStateException (sRealNumericCode + " ==> " + sRealOrPart + " is not numeric!");

      ret.add (sRealOrPart);
    }
  }
  return StringHelper.getImploded (",", ret);
}
 
开发者ID:phax,项目名称:ph-masterdata,代码行数:45,代码来源:MainReadPackageTypeCodeListExcel.java


注:本文中的com.helger.commons.string.StringParser.isInt方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。