本文整理了Java中okhttp3.internal.Util.format()
方法的一些代码示例,展示了Util.format()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Util.format()
方法的具体详情如下:
包路径:okhttp3.internal.Util
类名称:Util
方法名:format
[英]Returns a Locale#US formatted String.
[中]返回区域设置#US格式的字符串。
代码示例来源:origin: square/okhttp
public NamedRunnable(String format, Object... args) {
this.name = Util.format(format, args);
}
代码示例来源:origin: square/okhttp
@Override public String format(LogRecord record) {
return Util.format("%s%n", record.getMessage());
}
});
代码示例来源:origin: square/okhttp
static IllegalArgumentException illegalArgument(String message, Object... args) {
throw new IllegalArgumentException(format(message, args));
}
代码示例来源:origin: square/okhttp
static IOException ioException(String message, Object... args) throws IOException {
throw new IOException(format(message, args));
}
代码示例来源:origin: square/okhttp
static void checkValue(String value, String name) {
if (value == null) throw new NullPointerException("value for name " + name + " == null");
for (int i = 0, length = value.length(); i < length; i++) {
char c = value.charAt(i);
if ((c <= '\u001f' && c != '\t') || c >= '\u007f') {
throw new IllegalArgumentException(Util.format(
"Unexpected char %#04x at %d in %s value: %s", (int) c, i, name, value));
}
}
}
代码示例来源:origin: square/okhttp
static void checkName(String name) {
if (name == null) throw new NullPointerException("name == null");
if (name.isEmpty()) throw new IllegalArgumentException("name is empty");
for (int i = 0, length = name.length(); i < length; i++) {
char c = name.charAt(i);
if (c <= '\u0020' || c >= '\u007f') {
throw new IllegalArgumentException(Util.format(
"Unexpected char %#04x at %d in header name: %s", (int) c, i, name));
}
}
}
代码示例来源:origin: com.squareup.okhttp3/okhttp
public NamedRunnable(String format, Object... args) {
this.name = Util.format(format, args);
}
代码示例来源:origin: square/okhttp
/**
* Returns human-readable representation of HTTP/2 frame headers.
*
* <p>The format is:
*
* <pre>
* direction streamID length type flags
* </pre>
*
* Where direction is {@code <<} for inbound and {@code >>} for outbound.
*
* <p>For example, the following would indicate a HEAD request sent from the client.
* <pre>
* {@code
* << 0x0000000f 12 HEADERS END_HEADERS|END_STREAM
* }
* </pre>
*/
static String frameLog(boolean inbound, int streamId, int length, byte type, byte flags) {
String formattedType = type < FRAME_NAMES.length ? FRAME_NAMES[type] : format("0x%02x", type);
String formattedFlags = formatFlags(type, flags);
return format("%s 0x%08x %5d %-13s %s", inbound ? "<<" : ">>", streamId, length,
formattedType, formattedFlags);
}
代码示例来源:origin: com.squareup.okhttp3/okhttp
static IOException ioException(String message, Object... args) throws IOException {
throw new IOException(format(message, args));
}
代码示例来源:origin: com.squareup.okhttp3/okhttp
static IllegalArgumentException illegalArgument(String message, Object... args) {
throw new IllegalArgumentException(format(message, args));
}
代码示例来源:origin: com.squareup.okhttp3/okhttp
static void checkValue(String value, String name) {
if (value == null) throw new NullPointerException("value for name " + name + " == null");
for (int i = 0, length = value.length(); i < length; i++) {
char c = value.charAt(i);
if ((c <= '\u001f' && c != '\t') || c >= '\u007f') {
throw new IllegalArgumentException(Util.format(
"Unexpected char %#04x at %d in %s value: %s", (int) c, i, name, value));
}
}
}
代码示例来源:origin: com.squareup.okhttp3/okhttp
static void checkName(String name) {
if (name == null) throw new NullPointerException("name == null");
if (name.isEmpty()) throw new IllegalArgumentException("name is empty");
for (int i = 0, length = name.length(); i < length; i++) {
char c = name.charAt(i);
if (c <= '\u0020' || c >= '\u007f') {
throw new IllegalArgumentException(Util.format(
"Unexpected char %#04x at %d in header name: %s", (int) c, i, name));
}
}
}
代码示例来源:origin: square/okhttp
@Override public String toString() {
return Util.format("%s: %s", name.utf8(), value.utf8());
}
}
代码示例来源:origin: com.squareup.okhttp3/okhttp
/**
* Returns human-readable representation of HTTP/2 frame headers.
*
* <p>The format is:
*
* <pre>
* direction streamID length type flags
* </pre>
*
* Where direction is {@code <<} for inbound and {@code >>} for outbound.
*
* <p>For example, the following would indicate a HEAD request sent from the client.
* <pre>
* {@code
* << 0x0000000f 12 HEADERS END_HEADERS|END_STREAM
* }
* </pre>
*/
static String frameLog(boolean inbound, int streamId, int length, byte type, byte flags) {
String formattedType = type < FRAME_NAMES.length ? FRAME_NAMES[type] : format("0x%02x", type);
String formattedFlags = formatFlags(type, flags);
return format("%s 0x%08x %5d %-13s %s", inbound ? "<<" : ">>", streamId, length,
formattedType, formattedFlags);
}
代码示例来源:origin: square/okhttp
public synchronized void connectionPreface() throws IOException {
if (closed) throw new IOException("closed");
if (!client) return; // Nothing to write; servers don't send connection headers!
if (logger.isLoggable(FINE)) {
logger.fine(format(">> CONNECTION %s", CONNECTION_PREFACE.hex()));
}
sink.write(CONNECTION_PREFACE.toByteArray());
sink.flush();
}
代码示例来源:origin: com.squareup.okhttp3/okhttp
public synchronized void connectionPreface() throws IOException {
if (closed) throw new IOException("closed");
if (!client) return; // Nothing to write; servers don't send connection headers!
if (logger.isLoggable(FINE)) {
logger.fine(format(">> CONNECTION %s", CONNECTION_PREFACE.hex()));
}
sink.write(CONNECTION_PREFACE.toByteArray());
sink.flush();
}
代码示例来源:origin: com.squareup.okhttp3/okhttp
@Override public String toString() {
return Util.format("%s: %s", name.utf8(), value.utf8());
}
}
代码示例来源:origin: square/okhttp
Util.threadFactory(Util.format("OkHttp %s Writer", connectionName), false));
if (builder.pingIntervalMillis != 0) {
writerExecutor.scheduleAtFixedRate(new PingRunnable(false, 0, 0),
Util.threadFactory(Util.format("OkHttp %s Push Observer", connectionName), true));
peerSettings.set(Settings.INITIAL_WINDOW_SIZE, DEFAULT_INITIAL_WINDOW_SIZE);
peerSettings.set(Settings.MAX_FRAME_SIZE, Http2.INITIAL_MAX_FRAME_SIZE);
代码示例来源:origin: square/okhttp
public void readConnectionPreface(Handler handler) throws IOException {
if (client) {
// The client reads the initial SETTINGS frame.
if (!nextFrame(true, handler)) {
throw ioException("Required SETTINGS preface not received");
}
} else {
// The server reads the CONNECTION_PREFACE byte string.
ByteString connectionPreface = source.readByteString(CONNECTION_PREFACE.size());
if (logger.isLoggable(FINE)) logger.fine(format("<< CONNECTION %s", connectionPreface.hex()));
if (!CONNECTION_PREFACE.equals(connectionPreface)) {
throw ioException("Expected a connection header but was %s", connectionPreface.utf8());
}
}
}
代码示例来源:origin: com.squareup.okhttp3/okhttp
public void readConnectionPreface(Handler handler) throws IOException {
if (client) {
// The client reads the initial SETTINGS frame.
if (!nextFrame(true, handler)) {
throw ioException("Required SETTINGS preface not received");
}
} else {
// The server reads the CONNECTION_PREFACE byte string.
ByteString connectionPreface = source.readByteString(CONNECTION_PREFACE.size());
if (logger.isLoggable(FINE)) logger.fine(format("<< CONNECTION %s", connectionPreface.hex()));
if (!CONNECTION_PREFACE.equals(connectionPreface)) {
throw ioException("Expected a connection header but was %s", connectionPreface.utf8());
}
}
}
内容来源于网络,如有侵权,请联系作者删除!