本文整理汇总了Java中java.lang.Character.isDigit方法的典型用法代码示例。如果您正苦于以下问题:Java Character.isDigit方法的具体用法?Java Character.isDigit怎么用?Java Character.isDigit使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.lang.Character
的用法示例。
在下文中一共展示了Character.isDigit方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: isPrintable
import java.lang.Character; //导入方法依赖的package包/类
public static boolean isPrintable(char c)
{
if (Character.isJavaIdentifierStart(c)) {
// Letters and $ _
return true;
}
if (Character.isDigit(c)) {
return true;
}
switch (Character.getType(c)) {
case Character.MODIFIER_SYMBOL : return true; // ` ^
case Character.DASH_PUNCTUATION : return true; // -
case Character.MATH_SYMBOL : return true; // = ~ + | < >
case Character.OTHER_PUNCTUATION : return true; // [email protected]#%&*;':",./?
case Character.START_PUNCTUATION : return true; // ( [ {
case Character.END_PUNCTUATION : return true; // ) ] }
}
return false;
}
示例2: getIOSVersion
import java.lang.Character; //导入方法依赖的package包/类
@Nullable
public static String getIOSVersion(@Nullable final String ua) {
if (ua == null) return null;
StringBuilder versionBuilder = new StringBuilder(6);
int index = ua.indexOf("OS ");
if (index == -1) return null;
index += 3; // skip over "OS ".
if (!Character.isDigit(ua.charAt(index))) {
return null;
}
while (index < ua.length() && ua.charAt(index) != ' ') {
versionBuilder.append(ua.charAt(index));
index++;
}
return versionBuilder.toString().replace('_', '.');
}
示例3: parseKey
import java.lang.Character; //导入方法依赖的package包/类
/** Parsing keyword to raw key code. **/
public static Object parseKey(String key){
// note that parse algorithm makes all words upper case and removes spaces and duplicating symbols
try {
if (key.length() > 1 && Character.toUpperCase(key.charAt(0)) == 'R' && Character.isDigit(key.charAt(1)))
return Integer.parseInt(key.substring(1));
} catch (Exception e){ }
StringBuilder sb = new StringBuilder(key.toUpperCase());
// Ф1-24 -> F1-24
if(sb.length() > 1 && sb.charAt(0) == 'Ф' && Character.isDigit(sb.charAt(1)))
sb.setCharAt(0, 'F');
if (sb.length()>1 && sb.charAt(0) == 'Э') sb.setCharAt(0, 'Е');
for(int i=1; i < sb.length(); i++) {
if (sb.charAt(i) == ' ' || sb.charAt(i) == 'Ь' || sb.charAt(i - 1) == sb.charAt(i)) {
sb.deleteCharAt(i);
i--;
} else if (sb.charAt(i) == 'Э') {
sb.setCharAt(i, 'Е');
}
}
String code = keyMap.get(sb.toString());
if(code == null)
errors.add(key);
return code;
}
示例4: normalizeText
import java.lang.Character; //导入方法依赖的package包/类
private String normalizeText(String input) {
StringBuffer normalized_text = new StringBuffer();
for (int i = 0; i < input.length(); i++) {
if (Character.isLetter(input.charAt(i)) || (Character.isDigit(input.charAt(i))) || Character.isWhitespace(input.charAt(i))) {
normalized_text.append(input.charAt(i));
}
}
return normalized_text.toString();
}
示例5: getWindowsPhoneVersion
import java.lang.Character; //导入方法依赖的package包/类
public static String getWindowsPhoneVersion(String ua) {
if (ua == null) return null;
StringBuilder versionBuilder = new StringBuilder(6);
int index = ua.indexOf("OS ");
if (index == -1) return null;
index += 3; // skip over "OS ".
if (!Character.isDigit(ua.charAt(index))) {
return null;
}
while (index < ua.length() && ua.charAt(index) != ';') {
versionBuilder.append(ua.charAt(index));
index++;
}
return versionBuilder.toString();
}
示例6: invoke
import java.lang.Character; //导入方法依赖的package包/类
public Object invoke(Object reader, Object doublequote, Object opts, Object pendingForms) {
StringBuilder sb = new StringBuilder();
Reader r = (Reader) reader;
for(int ch = read1(r); ch != '"'; ch = read1(r))
{
if(ch == -1)
throw Util.runtimeException("EOF while reading string");
if(ch == '\\') //escape
{
ch = read1(r);
if(ch == -1)
throw Util.runtimeException("EOF while reading string");
switch(ch)
{
case 't':
ch = '\t';
break;
case 'r':
ch = '\r';
break;
case 'n':
ch = '\n';
break;
case '\\':
break;
case '"':
break;
case 'b':
ch = '\b';
break;
case 'f':
ch = '\f';
break;
case 'u':
{
ch = read1(r);
if (Character.digit(ch, 16) == -1)
throw Util.runtimeException("Invalid unicode escape: \\u" + (char) ch);
ch = readUnicodeChar((PushbackReader) r, ch, 16, 4, true);
break;
}
default:
{
if(Character.isDigit(ch))
{
ch = readUnicodeChar((PushbackReader) r, ch, 8, 3, false);
if(ch > 0377)
throw Util.runtimeException("Octal escape sequence must be in range [0, 377].");
}
else
throw Util.runtimeException("Unsupported escape character: \\" + (char) ch);
}
}
}
sb.append((char) ch);
}
return sb.toString();
}