本文整理汇总了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;
}
示例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);
}