java.util.Formatter.padding()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(6.0k)|赞(0)|评价(0)|浏览(149)

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

Formatter.padding介绍

暂无

代码示例

代码示例来源:origin: robovm/robovm

private CharSequence transformFromNull() {
  formatToken.flagZero = false;
  return padding("null", 0);
}

代码示例来源:origin: robovm/robovm

private CharSequence transformFromPercent() {
  return padding("%", 0);
}

代码示例来源:origin: robovm/robovm

private CharSequence transformFromBoolean() {
  CharSequence result;
  if (arg instanceof Boolean) {
    result = arg.toString();
  } else if (arg == null) {
    result = "false";
  } else {
    result = "true";
  }
  return padding(result, 0);
}

代码示例来源:origin: robovm/robovm

private CharSequence transformFromHashCode() {
  CharSequence result;
  if (arg == null) {
    result = "null";
  } else {
    result = Integer.toHexString(arg.hashCode());
  }
  return padding(result, 0);
}

代码示例来源:origin: robovm/robovm

private StringBuilder wrapParentheses(StringBuilder result) {
  result.setCharAt(0, '('); // Replace the '-'.
  if (formatToken.flagZero) {
    formatToken.setWidth(formatToken.getWidth() - 1);
    result = (StringBuilder) padding(result, 1);
    result.append(')');
  } else {
    result.append(')');
    result = (StringBuilder) padding(result, 0);
  }
  return result;
}

代码示例来源: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 transformFromSpecialNumber(double d) {
  String source = null;
  if (Double.isNaN(d)) {
    source = "NaN";
  } else if (d == Double.POSITIVE_INFINITY) {
    if (formatToken.flagPlus) {
      source = "+Infinity";
    } else if (formatToken.flagSpace) {
      source = " Infinity";
    } else {
      source = "Infinity";
    }
  } else if (d == Double.NEGATIVE_INFINITY) {
    if (formatToken.flagParenthesis) {
      source = "(Infinity)";
    } else {
      source = "-Infinity";
    }
  } else {
    return null;
  }
  formatToken.setPrecision(FormatToken.UNSET);
  formatToken.flagZero = false;
  return padding(source, 0);
}

代码示例来源:origin: robovm/robovm

startIndex++;
return padding(result, startIndex);

代码示例来源: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

private CharSequence transformFromString() {
  if (arg instanceof Formattable) {
    int flags = 0;
    if (formatToken.flagMinus) {
      flags |= FormattableFlags.LEFT_JUSTIFY;
    }
    if (formatToken.flagSharp) {
      flags |= FormattableFlags.ALTERNATE;
    }
    if (Character.isUpperCase(formatToken.getConversionType())) {
      flags |= FormattableFlags.UPPERCASE;
    }
    ((Formattable) arg).formatTo(this, flags, formatToken.getWidth(),
        formatToken.getPrecision());
    // all actions have been taken out in the
    // Formattable.formatTo, thus there is nothing to do, just
    // returns null, which tells the Parser to add nothing to the
    // output.
    return null;
  }
  CharSequence result = arg != null ? arg.toString() : "null";
  return padding(result, 0);
}

代码示例来源:origin: robovm/robovm

return padding(result, startIndex);

代码示例来源:origin: robovm/robovm

startIndex += 2;
return padding(result, startIndex);

代码示例来源:origin: ibinti/bugvm

private CharSequence transformFromBoolean() {
  CharSequence result;
  if (arg instanceof Boolean) {
    result = arg.toString();
  } else if (arg == null) {
    result = "false";
  } else {
    result = "true";
  }
  return padding(result, 0);
}

代码示例来源:origin: com.mobidevelop.robovm/robovm-rt

private CharSequence transformFromBoolean() {
  CharSequence result;
  if (arg instanceof Boolean) {
    result = arg.toString();
  } else if (arg == null) {
    result = "false";
  } else {
    result = "true";
  }
  return padding(result, 0);
}

代码示例来源:origin: MobiVM/robovm

private CharSequence transformFromBoolean() {
  CharSequence result;
  if (arg instanceof Boolean) {
    result = arg.toString();
  } else if (arg == null) {
    result = "false";
  } else {
    result = "true";
  }
  return padding(result, 0);
}

代码示例来源:origin: MobiVM/robovm

private CharSequence transformFromHashCode() {
  CharSequence result;
  if (arg == null) {
    result = "null";
  } else {
    result = Integer.toHexString(arg.hashCode());
  }
  return padding(result, 0);
}

代码示例来源:origin: ibinti/bugvm

private CharSequence transformFromHashCode() {
  CharSequence result;
  if (arg == null) {
    result = "null";
  } else {
    result = Integer.toHexString(arg.hashCode());
  }
  return padding(result, 0);
}

代码示例来源:origin: MobiVM/robovm

private StringBuilder wrapParentheses(StringBuilder result) {
  result.setCharAt(0, '('); // Replace the '-'.
  if (formatToken.flagZero) {
    formatToken.setWidth(formatToken.getWidth() - 1);
    result = (StringBuilder) padding(result, 1);
    result.append(')');
  } else {
    result.append(')');
    result = (StringBuilder) padding(result, 0);
  }
  return result;
}

代码示例来源:origin: ibinti/bugvm

private StringBuilder wrapParentheses(StringBuilder result) {
  result.setCharAt(0, '('); // Replace the '-'.
  if (formatToken.flagZero) {
    formatToken.setWidth(formatToken.getWidth() - 1);
    result = (StringBuilder) padding(result, 1);
    result.append(')');
  } else {
    result.append(')');
    result = (StringBuilder) padding(result, 0);
  }
  return result;
}

代码示例来源:origin: com.mobidevelop.robovm/robovm-rt

private StringBuilder wrapParentheses(StringBuilder result) {
  result.setCharAt(0, '('); // Replace the '-'.
  if (formatToken.flagZero) {
    formatToken.setWidth(formatToken.getWidth() - 1);
    result = (StringBuilder) padding(result, 1);
    result.append(')');
  } else {
    result.append(')');
    result = (StringBuilder) padding(result, 0);
  }
  return result;
}

相关文章