本文整理了Java中io.vertx.core.buffer.Buffer.setString()
方法的一些代码示例,展示了Buffer.setString()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Buffer.setString()
方法的具体详情如下:
包路径:io.vertx.core.buffer.Buffer
类名称:Buffer
方法名:setString
[英]Sets the bytes at position pos in the Buffer to the value of str encoded in UTF-8.
The buffer will expand as necessary to accommodate any value written.
[中]将缓冲区中位置pos处的字节设置为UTF-8编码的str值。
缓冲区将根据需要扩展以容纳任何写入的值。
代码示例来源:origin: eclipse-vertx/vert.x
private void testSetBytesString(Buffer buff) throws Exception {
String str = TestUtils.randomUnicodeString(100);
buff.setString(50, str);
byte[] b1 = buff.getBytes(50, buff.length());
String str2 = new String(b1, "UTF-8");
assertEquals(str, str2);
assertNullPointerException(() -> Buffer.buffer(150).setString(0, null));
assertNullPointerException(() -> Buffer.buffer(150).setString(0, null, "UTF-8"));
//TODO setString with encoding
}
代码示例来源:origin: eclipse-vertx/vert.x
@Test
public void testSetOutOfBounds() throws Exception {
Buffer b = Buffer.buffer(numSets);
assertIndexOutOfBoundsException(() -> b.setByte(-1, (byte) 0));
assertIndexOutOfBoundsException(() -> b.setInt(-1, 0));
assertIndexOutOfBoundsException(() -> b.setLong(-1, 0));
assertIndexOutOfBoundsException(() -> b.setDouble(-1, 0));
assertIndexOutOfBoundsException(() -> b.setFloat(-1, 0));
assertIndexOutOfBoundsException(() -> b.setShort(-1, (short) 0));
assertIndexOutOfBoundsException(() -> b.setBuffer(-1, b));
assertIndexOutOfBoundsException(() -> b.setBuffer(0, b, -1, 0));
assertIndexOutOfBoundsException(() -> b.setBuffer(0, b, 0, -1));
assertIndexOutOfBoundsException(() -> b.setBytes(-1, TestUtils.randomByteArray(1)));
assertIndexOutOfBoundsException(() -> b.setBytes(-1, TestUtils.randomByteArray(1), -1, 0));
assertIndexOutOfBoundsException(() -> b.setBytes(-1, TestUtils.randomByteArray(1), 0, -1));
assertIndexOutOfBoundsException(() -> b.setString(-1, ""));
assertIndexOutOfBoundsException(() -> b.setString(-1, "", "UTF-8"));
}
代码示例来源:origin: io.vertx/vertx-core
private void testSetBytesString(Buffer buff) throws Exception {
String str = TestUtils.randomUnicodeString(100);
buff.setString(50, str);
byte[] b1 = buff.getBytes(50, buff.length());
String str2 = new String(b1, "UTF-8");
assertEquals(str, str2);
assertNullPointerException(() -> Buffer.buffer(150).setString(0, null));
assertNullPointerException(() -> Buffer.buffer(150).setString(0, null, "UTF-8"));
//TODO setString with encoding
}
代码示例来源:origin: io.vertx/vertx-rx-java
/**
* Sets the bytes at position <code>pos</code> in the Buffer to the value of <code>str</code> encoded in UTF-8.<p>
* The buffer will expand as necessary to accommodate any value written.
* @param pos
* @param str
* @return
*/
public io.vertx.rxjava.core.buffer.Buffer setString(int pos, String str) {
delegate.setString(pos, str);
return this;
}
代码示例来源:origin: io.vertx/vertx-rx-java
/**
* Sets the bytes at position <code>pos</code> in the Buffer to the value of <code>str</code> encoded in encoding <code>enc</code>.<p>
* The buffer will expand as necessary to accommodate any value written.
* @param pos
* @param str
* @param enc
* @return
*/
public io.vertx.rxjava.core.buffer.Buffer setString(int pos, String str, String enc) {
delegate.setString(pos, str, enc);
return this;
}
代码示例来源:origin: apiman/apiman
@Override
public void insert(int index, String string) {
nativeBuffer.setString(index, string);
}
代码示例来源:origin: vert-x3/vertx-rx
/**
* Sets the bytes at position <code>pos</code> in the Buffer to the value of <code>str</code> encoded in UTF-8.<p>
* The buffer will expand as necessary to accommodate any value written.
* @param pos
* @param str
* @return
*/
public io.vertx.rxjava.core.buffer.Buffer setString(int pos, String str) {
delegate.setString(pos, str);
return this;
}
代码示例来源:origin: vert-x3/vertx-rx
/**
* Sets the bytes at position <code>pos</code> in the Buffer to the value of <code>str</code> encoded in encoding <code>enc</code>.<p>
* The buffer will expand as necessary to accommodate any value written.
* @param pos
* @param str
* @param enc
* @return
*/
public io.vertx.rxjava.core.buffer.Buffer setString(int pos, String str, String enc) {
delegate.setString(pos, str, enc);
return this;
}
代码示例来源:origin: apiman/apiman
@Override
public void insert(int index, String string, String encoding) throws UnsupportedEncodingException {
nativeBuffer.setString(index, string, encoding);
}
代码示例来源:origin: io.vertx/vertx-core
@Test
public void testSetOutOfBounds() throws Exception {
Buffer b = Buffer.buffer(numSets);
assertIndexOutOfBoundsException(() -> b.setByte(-1, (byte) 0));
assertIndexOutOfBoundsException(() -> b.setInt(-1, 0));
assertIndexOutOfBoundsException(() -> b.setLong(-1, 0));
assertIndexOutOfBoundsException(() -> b.setDouble(-1, 0));
assertIndexOutOfBoundsException(() -> b.setFloat(-1, 0));
assertIndexOutOfBoundsException(() -> b.setShort(-1, (short) 0));
assertIndexOutOfBoundsException(() -> b.setBuffer(-1, b));
assertIndexOutOfBoundsException(() -> b.setBuffer(0, b, -1, 0));
assertIndexOutOfBoundsException(() -> b.setBuffer(0, b, 0, -1));
assertIndexOutOfBoundsException(() -> b.setBytes(-1, TestUtils.randomByteArray(1)));
assertIndexOutOfBoundsException(() -> b.setBytes(-1, TestUtils.randomByteArray(1), -1, 0));
assertIndexOutOfBoundsException(() -> b.setBytes(-1, TestUtils.randomByteArray(1), 0, -1));
assertIndexOutOfBoundsException(() -> b.setString(-1, ""));
assertIndexOutOfBoundsException(() -> b.setString(-1, "", "UTF-8"));
}
代码示例来源:origin: com.jukusoft/vertx-binary-serializer
buf.setString(_pos, value);
_pos += value.length() * 4;
} else if (clazz == SBoolean.class) {
buf.setString(_pos, value);
_pos += value.length() * 4;
} else if (clazz == SJsonArray.class) {
buf.setString(_pos, value);
_pos += value.length() * 4;
内容来源于网络,如有侵权,请联系作者删除!