本文整理了Java中java.util.Formatter.badArgumentType()
方法的一些代码示例,展示了Formatter.badArgumentType()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Formatter.badArgumentType()
方法的具体详情如下:
包路径:java.util.Formatter
类名称:Formatter
方法名:badArgumentType
暂无
代码示例来源:origin: robovm/robovm
private void transformA(StringBuilder result) {
if (arg instanceof Float) {
result.append(Float.toHexString(((Float) arg).floatValue()));
} else if (arg instanceof Double) {
result.append(Double.toHexString(((Double) arg).doubleValue()));
} else {
throw badArgumentType();
}
if (!formatToken.isPrecisionSet()) {
return;
}
int precision = formatToken.getPrecision();
if (precision == 0) {
precision = 1;
}
int indexOfFirstFractionalDigit = result.indexOf(".") + 1;
int indexOfP = result.indexOf("p");
int fractionalLength = indexOfP - indexOfFirstFractionalDigit;
if (fractionalLength == precision) {
return;
}
if (fractionalLength < precision) {
char[] zeros = new char[precision - fractionalLength];
Arrays.fill(zeros, '0'); // %a shouldn't be localized.
result.insert(indexOfP, zeros);
return;
}
result.delete(indexOfFirstFractionalDigit + precision, indexOfP);
}
代码示例来源:origin: robovm/robovm
private CharSequence transformFromCharacter() {
if (arg == null) {
return padding("null", 0);
}
if (arg instanceof Character) {
return padding(String.valueOf(arg), 0);
} else if (arg instanceof Byte || arg instanceof Short || arg instanceof Integer) {
int codePoint = ((Number) arg).intValue();
if (!Character.isValidCodePoint(codePoint)) {
throw new IllegalFormatCodePointException(codePoint);
}
CharSequence result = (codePoint < Character.MIN_SUPPLEMENTARY_CODE_POINT)
? String.valueOf((char) codePoint)
: String.valueOf(Character.toChars(codePoint));
return padding(result, 0);
} else {
throw badArgumentType();
}
}
代码示例来源:origin: robovm/robovm
private CharSequence transformFromDateTime() {
if (arg == null) {
return transformFromNull();
}
Calendar calendar;
if (arg instanceof Calendar) {
calendar = (Calendar) arg;
} else {
Date date = null;
if (arg instanceof Long) {
date = new Date(((Long) arg).longValue());
} else if (arg instanceof Date) {
date = (Date) arg;
} else {
throw badArgumentType();
}
calendar = Calendar.getInstance(locale);
calendar.setTime(date);
}
StringBuilder result = new StringBuilder();
if (!appendT(result, formatToken.getDateSuffix(), calendar)) {
throw formatToken.unknownFormatConversionException();
}
return padding(result, 0);
}
代码示例来源:origin: robovm/robovm
value = ((Byte) arg).longValue();
} else {
throw badArgumentType();
代码示例来源:origin: robovm/robovm
throw badArgumentType();
代码示例来源:origin: MobiVM/robovm
private void transformA(StringBuilder result) {
if (arg instanceof Float) {
result.append(Float.toHexString(((Float) arg).floatValue()));
} else if (arg instanceof Double) {
result.append(Double.toHexString(((Double) arg).doubleValue()));
} else {
throw badArgumentType();
}
if (!formatToken.isPrecisionSet()) {
return;
}
int precision = formatToken.getPrecision();
if (precision == 0) {
precision = 1;
}
int indexOfFirstFractionalDigit = result.indexOf(".") + 1;
int indexOfP = result.indexOf("p");
int fractionalLength = indexOfP - indexOfFirstFractionalDigit;
if (fractionalLength == precision) {
return;
}
if (fractionalLength < precision) {
char[] zeros = new char[precision - fractionalLength];
Arrays.fill(zeros, '0'); // %a shouldn't be localized.
result.insert(indexOfP, zeros);
return;
}
result.delete(indexOfFirstFractionalDigit + precision, indexOfP);
}
代码示例来源:origin: ibinti/bugvm
private void transformA(StringBuilder result) {
if (arg instanceof Float) {
result.append(Float.toHexString(((Float) arg).floatValue()));
} else if (arg instanceof Double) {
result.append(Double.toHexString(((Double) arg).doubleValue()));
} else {
throw badArgumentType();
}
if (!formatToken.isPrecisionSet()) {
return;
}
int precision = formatToken.getPrecision();
if (precision == 0) {
precision = 1;
}
int indexOfFirstFractionalDigit = result.indexOf(".") + 1;
int indexOfP = result.indexOf("p");
int fractionalLength = indexOfP - indexOfFirstFractionalDigit;
if (fractionalLength == precision) {
return;
}
if (fractionalLength < precision) {
char[] zeros = new char[precision - fractionalLength];
Arrays.fill(zeros, '0'); // %a shouldn't be localized.
result.insert(indexOfP, zeros);
return;
}
result.delete(indexOfFirstFractionalDigit + precision, indexOfP);
}
代码示例来源:origin: com.gluonhq/robovm-rt
private void transformA(StringBuilder result) {
if (arg instanceof Float) {
result.append(Float.toHexString(((Float) arg).floatValue()));
} else if (arg instanceof Double) {
result.append(Double.toHexString(((Double) arg).doubleValue()));
} else {
throw badArgumentType();
}
if (!formatToken.isPrecisionSet()) {
return;
}
int precision = formatToken.getPrecision();
if (precision == 0) {
precision = 1;
}
int indexOfFirstFractionalDigit = result.indexOf(".") + 1;
int indexOfP = result.indexOf("p");
int fractionalLength = indexOfP - indexOfFirstFractionalDigit;
if (fractionalLength == precision) {
return;
}
if (fractionalLength < precision) {
char[] zeros = new char[precision - fractionalLength];
Arrays.fill(zeros, '0'); // %a shouldn't be localized.
result.insert(indexOfP, zeros);
return;
}
result.delete(indexOfFirstFractionalDigit + precision, indexOfP);
}
代码示例来源:origin: ibinti/bugvm
private CharSequence transformFromCharacter() {
if (arg == null) {
return padding("null", 0);
}
if (arg instanceof Character) {
return padding(String.valueOf(arg), 0);
} else if (arg instanceof Byte || arg instanceof Short || arg instanceof Integer) {
int codePoint = ((Number) arg).intValue();
if (!Character.isValidCodePoint(codePoint)) {
throw new IllegalFormatCodePointException(codePoint);
}
CharSequence result = (codePoint < Character.MIN_SUPPLEMENTARY_CODE_POINT)
? String.valueOf((char) codePoint)
: String.valueOf(Character.toChars(codePoint));
return padding(result, 0);
} else {
throw badArgumentType();
}
}
代码示例来源:origin: MobiVM/robovm
private CharSequence transformFromCharacter() {
if (arg == null) {
return padding("null", 0);
}
if (arg instanceof Character) {
return padding(String.valueOf(arg), 0);
} else if (arg instanceof Byte || arg instanceof Short || arg instanceof Integer) {
int codePoint = ((Number) arg).intValue();
if (!Character.isValidCodePoint(codePoint)) {
throw new IllegalFormatCodePointException(codePoint);
}
CharSequence result = (codePoint < Character.MIN_SUPPLEMENTARY_CODE_POINT)
? String.valueOf((char) codePoint)
: String.valueOf(Character.toChars(codePoint));
return padding(result, 0);
} else {
throw badArgumentType();
}
}
代码示例来源:origin: com.mobidevelop.robovm/robovm-rt
private CharSequence transformFromCharacter() {
if (arg == null) {
return padding("null", 0);
}
if (arg instanceof Character) {
return padding(String.valueOf(arg), 0);
} else if (arg instanceof Byte || arg instanceof Short || arg instanceof Integer) {
int codePoint = ((Number) arg).intValue();
if (!Character.isValidCodePoint(codePoint)) {
throw new IllegalFormatCodePointException(codePoint);
}
CharSequence result = (codePoint < Character.MIN_SUPPLEMENTARY_CODE_POINT)
? String.valueOf((char) codePoint)
: String.valueOf(Character.toChars(codePoint));
return padding(result, 0);
} else {
throw badArgumentType();
}
}
代码示例来源:origin: com.bugvm/bugvm-rt
private CharSequence transformFromCharacter() {
if (arg == null) {
return padding("null", 0);
}
if (arg instanceof Character) {
return padding(String.valueOf(arg), 0);
} else if (arg instanceof Byte || arg instanceof Short || arg instanceof Integer) {
int codePoint = ((Number) arg).intValue();
if (!Character.isValidCodePoint(codePoint)) {
throw new IllegalFormatCodePointException(codePoint);
}
CharSequence result = (codePoint < Character.MIN_SUPPLEMENTARY_CODE_POINT)
? String.valueOf((char) codePoint)
: String.valueOf(Character.toChars(codePoint));
return padding(result, 0);
} else {
throw badArgumentType();
}
}
代码示例来源:origin: com.gluonhq/robovm-rt
private CharSequence transformFromCharacter() {
if (arg == null) {
return padding("null", 0);
}
if (arg instanceof Character) {
return padding(String.valueOf(arg), 0);
} else if (arg instanceof Byte || arg instanceof Short || arg instanceof Integer) {
int codePoint = ((Number) arg).intValue();
if (!Character.isValidCodePoint(codePoint)) {
throw new IllegalFormatCodePointException(codePoint);
}
CharSequence result = (codePoint < Character.MIN_SUPPLEMENTARY_CODE_POINT)
? String.valueOf((char) codePoint)
: String.valueOf(Character.toChars(codePoint));
return padding(result, 0);
} else {
throw badArgumentType();
}
}
代码示例来源:origin: FlexoVM/flexovm
private CharSequence transformFromCharacter() {
if (arg == null) {
return padding("null", 0);
}
if (arg instanceof Character) {
return padding(String.valueOf(arg), 0);
} else if (arg instanceof Byte || arg instanceof Short || arg instanceof Integer) {
int codePoint = ((Number) arg).intValue();
if (!Character.isValidCodePoint(codePoint)) {
throw new IllegalFormatCodePointException(codePoint);
}
CharSequence result = (codePoint < Character.MIN_SUPPLEMENTARY_CODE_POINT)
? String.valueOf((char) codePoint)
: String.valueOf(Character.toChars(codePoint));
return padding(result, 0);
} else {
throw badArgumentType();
}
}
代码示例来源:origin: ibinti/bugvm
private CharSequence transformFromDateTime() {
if (arg == null) {
return transformFromNull();
}
Calendar calendar;
if (arg instanceof Calendar) {
calendar = (Calendar) arg;
} else {
Date date = null;
if (arg instanceof Long) {
date = new Date(((Long) arg).longValue());
} else if (arg instanceof Date) {
date = (Date) arg;
} else {
throw badArgumentType();
}
calendar = Calendar.getInstance(locale);
calendar.setTime(date);
}
StringBuilder result = new StringBuilder();
if (!appendT(result, formatToken.getDateSuffix(), calendar)) {
throw formatToken.unknownFormatConversionException();
}
return padding(result, 0);
}
代码示例来源:origin: MobiVM/robovm
private CharSequence transformFromDateTime() {
if (arg == null) {
return transformFromNull();
}
Calendar calendar;
if (arg instanceof Calendar) {
calendar = (Calendar) arg;
} else {
Date date = null;
if (arg instanceof Long) {
date = new Date(((Long) arg).longValue());
} else if (arg instanceof Date) {
date = (Date) arg;
} else {
throw badArgumentType();
}
calendar = Calendar.getInstance(locale);
calendar.setTime(date);
}
StringBuilder result = new StringBuilder();
if (!appendT(result, formatToken.getDateSuffix(), calendar)) {
throw formatToken.unknownFormatConversionException();
}
return padding(result, 0);
}
代码示例来源:origin: com.mobidevelop.robovm/robovm-rt
private CharSequence transformFromDateTime() {
if (arg == null) {
return transformFromNull();
}
Calendar calendar;
if (arg instanceof Calendar) {
calendar = (Calendar) arg;
} else {
Date date = null;
if (arg instanceof Long) {
date = new Date(((Long) arg).longValue());
} else if (arg instanceof Date) {
date = (Date) arg;
} else {
throw badArgumentType();
}
calendar = Calendar.getInstance(locale);
calendar.setTime(date);
}
StringBuilder result = new StringBuilder();
if (!appendT(result, formatToken.getDateSuffix(), calendar)) {
throw formatToken.unknownFormatConversionException();
}
return padding(result, 0);
}
代码示例来源:origin: com.gluonhq/robovm-rt
private CharSequence transformFromDateTime() {
if (arg == null) {
return transformFromNull();
}
Calendar calendar;
if (arg instanceof Calendar) {
calendar = (Calendar) arg;
} else {
Date date = null;
if (arg instanceof Long) {
date = new Date(((Long) arg).longValue());
} else if (arg instanceof Date) {
date = (Date) arg;
} else {
throw badArgumentType();
}
calendar = Calendar.getInstance(locale);
calendar.setTime(date);
}
StringBuilder result = new StringBuilder();
if (!appendT(result, formatToken.getDateSuffix(), calendar)) {
throw formatToken.unknownFormatConversionException();
}
return padding(result, 0);
}
代码示例来源:origin: com.bugvm/bugvm-rt
private CharSequence transformFromDateTime() {
if (arg == null) {
return transformFromNull();
}
Calendar calendar;
if (arg instanceof Calendar) {
calendar = (Calendar) arg;
} else {
Date date = null;
if (arg instanceof Long) {
date = new Date(((Long) arg).longValue());
} else if (arg instanceof Date) {
date = (Date) arg;
} else {
throw badArgumentType();
}
calendar = Calendar.getInstance(locale);
calendar.setTime(date);
}
StringBuilder result = new StringBuilder();
if (!appendT(result, formatToken.getDateSuffix(), calendar)) {
throw formatToken.unknownFormatConversionException();
}
return padding(result, 0);
}
代码示例来源:origin: FlexoVM/flexovm
private CharSequence transformFromDateTime() {
if (arg == null) {
return transformFromNull();
}
Calendar calendar;
if (arg instanceof Calendar) {
calendar = (Calendar) arg;
} else {
Date date = null;
if (arg instanceof Long) {
date = new Date(((Long) arg).longValue());
} else if (arg instanceof Date) {
date = (Date) arg;
} else {
throw badArgumentType();
}
calendar = Calendar.getInstance(locale);
calendar.setTime(date);
}
StringBuilder result = new StringBuilder();
if (!appendT(result, formatToken.getDateSuffix(), calendar)) {
throw formatToken.unknownFormatConversionException();
}
return padding(result, 0);
}
内容来源于网络,如有侵权,请联系作者删除!