@Override void printf( String format, Object... args ) { out.format( format, args ); }
public PrintWriter format(String format, Object... args) { getResponseWriter().format(format, args); return this; } public PrintWriter format(Locale l, String format, Object... args) {
public PrintWriter format(Locale l, String format, Object... args) { getResponseWriter().format(l, format, args); return this; } };
@Override public PrintWriter format(Locale l, String format, Object... args) { return this.delegate.format(l, format, args); }
@Override public PrintWriter format(String format, Object... args) { return this.delegate.format(format, args); }
/** * Prints a formatted string. The behavior of this method is the same as * this writer's {@code #format(Locale, String, Object...)} method. * * @param l * the locale used in the method. No localization will be applied * if {@code l} is {@code null}. * @param format the format string (see {@link java.util.Formatter#format}) * @param args * the list of arguments passed to the formatter. If there are * more arguments than required by {@code format}, * additional arguments are ignored. * @return this writer. * @throws IllegalFormatException * if the format string is illegal or incompatible with the * arguments, if there are not enough arguments or if any other * error regarding the format string or arguments is detected. * @throws NullPointerException if {@code format == null} */ public PrintWriter printf(Locale l, String format, Object... args) { return format(l, format, args); }
/** * Prints a formatted string. The behavior of this method is the same as * this writer's {@code #format(String, Object...)} method. * * <p>The {@code Locale} used is the user's default locale. * See "<a href="../util/Locale.html#default_locale">Be wary of the default locale</a>". * * @param format the format string (see {@link java.util.Formatter#format}) * @param args * the list of arguments passed to the formatter. If there are * more arguments than required by {@code format}, * additional arguments are ignored. * @return this writer. * @throws IllegalFormatException * if the format string is illegal or incompatible with the * arguments, if there are not enough arguments or if any other * error regarding the format string or arguments is detected. * @throws NullPointerException if {@code format == null} */ public PrintWriter printf(String format, Object... args) { return format(format, args); }
/** * Formats {@code args} according to the format string {@code format}, and writes the result * to this stream. This method uses the user's default locale. * See "<a href="../util/Locale.html#default_locale">Be wary of the default locale</a>". * If automatic flushing is enabled then the buffer is flushed as well. * * @param format the format string (see {@link java.util.Formatter#format}) * @param args * the list of arguments passed to the formatter. If there are * more arguments than required by {@code format}, * additional arguments are ignored. * @return this writer. * @throws IllegalFormatException * if the format string is illegal or incompatible with the * arguments, if there are not enough arguments or if any other * error regarding the format string or arguments is detected. * @throws NullPointerException if {@code format == null} */ public PrintWriter format(String format, Object... args) { return format(Locale.getDefault(), format, args); }
try { writer = new PrintWriter(new FileOutputStream(outputFullFilename)); writer.format("package %s;\n\n", packageName); writer.println("public final class R {\n"); for (RType rType : rTypeResourceMap.keySet()) { writer.format(" public static final class %s {\n", rType.toString()); for (com.tencent.tinker.build.aapt.RDotTxtEntry rDotTxtEntry : rTypeResourceMap.get(rType)) { writer.format(" public static%s%s %s=%s;\n", isFinal ? " final " : " ", rDotTxtEntry.idType, rDotTxtEntry.name, rDotTxtEntry.idValue.trim());
@Override protected void write(OutputStream outputStream, @NonNull Pair<String, List<Uri>> content) throws IOException { final PrintWriter writer = new PrintWriter(new OutputStreamWriter(outputStream, ACRAConstants.UTF8)); writer.append(SECTION_START) .format(CONTENT_DISPOSITION, "ACRA_REPORT", "") .format(CONTENT_TYPE, contentType) .append(NEW_LINE) .append(content.first); for (Uri uri : content.second) { try { String name = UriUtils.getFileNameFromUri(context, uri); writer.append(SECTION_START) .format(CONTENT_DISPOSITION, "ACRA_ATTACHMENT", name) .format(CONTENT_TYPE, UriUtils.getMimeType(context, uri)) .append(NEW_LINE) .flush(); UriUtils.copyFromUri(context, outputStream, uri); } catch (FileNotFoundException e) { ACRA.log.w("Not sending attachment", e); } } writer.append(MESSAGE_END).flush(); } }
private TypePrinter<GraphQLUnionType> unionPrinter() { return (out, type, visibility) -> { if (isIntrospectionType(type)) { return; } printComments(out, type, ""); out.format("union %s%s = ", type.getName(), directivesString(type.getDirectives())); List<GraphQLOutputType> types = type.getTypes() .stream() .sorted(Comparator.comparing(GraphQLOutputType::getName)) .collect(toList()); for (int i = 0; i < types.size(); i++) { GraphQLOutputType objectType = types.get(i); if (i > 0) { out.format(" | "); } out.format("%s", objectType.getName()); } out.format("\n\n"); }; }
private TypePrinter<GraphQLEnumType> enumPrinter() { return (out, type, visibility) -> { if (isIntrospectionType(type)) { return; } printComments(out, type, ""); out.format("enum %s%s {\n", type.getName(), directivesString(type.getDirectives())); List<GraphQLEnumValueDefinition> values = type.getValues() .stream() .sorted(Comparator.comparing(GraphQLEnumValueDefinition::getName)) .collect(toList()); for (GraphQLEnumValueDefinition enumValueDefinition : values) { printComments(out, enumValueDefinition, " "); out.format(" %s%s\n", enumValueDefinition.getName(), directivesString(enumValueDefinition.getDirectives())); } out.format("}\n\n"); }; }
public void writeSVMLightFormat(PrintWriter writer) { for (RVFDatum<L, F> datum : this) { writer.print(this.labelIndex.indexOf(datum.label())); Counter<F> features = datum.asFeaturesCounter(); for (F feature : features.keySet()) { double count = features.getCount(feature); writer.format(Locale.ENGLISH, " %s:%f", this.featureIndex.indexOf(feature), count); } writer.println(); } }
private TypePrinter<GraphQLInputObjectType> inputObjectPrinter() { return (out, type, visibility) -> { if (isIntrospectionType(type)) { return; } printComments(out, type, ""); out.format("input %s%s {\n", type.getName(), directivesString(type.getDirectives())); visibility.getFieldDefinitions(type) .stream() .sorted(Comparator.comparing(GraphQLInputObjectField::getName)) .forEach(fd -> { printComments(out, fd, " "); out.format(" %s: %s", fd.getName(), typeString(fd.getType())); Object defaultValue = fd.getDefaultValue(); if (defaultValue != null) { String astValue = printAst(defaultValue, fd.getType()); out.format(" = %s", astValue); } out.format(directivesString(fd.getDirectives())); out.format("\n"); }); out.format("}\n\n"); }; }
private TypePrinter<GraphQLInterfaceType> interfacePrinter() { return (out, type, visibility) -> { if (isIntrospectionType(type)) { return; } printComments(out, type, ""); out.format("interface %s%s {\n", type.getName(), directivesString(type.getDirectives())); visibility.getFieldDefinitions(type) .stream() .sorted(Comparator.comparing(GraphQLFieldDefinition::getName)) .forEach(fd -> { printComments(out, fd, " "); out.format(" %s%s: %s%s\n", fd.getName(), argsString(fd.getArguments()), typeString(fd.getType()), directivesString(fd.getDirectives())); }); out.format("}\n\n"); }; }
private TypePrinter<GraphQLObjectType> objectPrinter() { return (out, type, visibility) -> { if (isIntrospectionType(type)) { return; } printComments(out, type, ""); if (type.getInterfaces().isEmpty()) { out.format("type %s%s {\n", type.getName(), directivesString(type.getDirectives())); } else { Stream<String> interfaceNames = type.getInterfaces() .stream() .map(GraphQLType::getName) .sorted(Comparator.naturalOrder()); out.format("type %s implements %s%s {\n", type.getName(), interfaceNames.collect(joining(" & ")), directivesString(type.getDirectives())); } visibility.getFieldDefinitions(type) .stream() .sorted(Comparator.comparing(GraphQLFieldDefinition::getName)) .forEach(fd -> { printComments(out, fd, " "); out.format(" %s%s: %s%s\n", fd.getName(), argsString(fd.getArguments()), typeString(fd.getType()), directivesString(fd.getDirectives())); }); out.format("}\n\n"); }; }
private TypePrinter<GraphQLScalarType> scalarPrinter() { return (out, type, visibility) -> { if (!options.isIncludeScalars()) { return; } boolean printScalar; if (ScalarInfo.isStandardScalar(type)) { printScalar = false; //noinspection RedundantIfStatement if (options.isIncludeExtendedScalars() && !ScalarInfo.isGraphqlSpecifiedScalar(type)) { printScalar = true; } } else { printScalar = true; } if (printScalar) { printComments(out, type, ""); out.format("scalar %s%s\n\n", type.getName(), directivesString(type.getDirectives())); } }; }