本文整理汇总了Java中io.protostuff.StringSerializer.STRING.ser方法的典型用法代码示例。如果您正苦于以下问题:Java STRING.ser方法的具体用法?Java STRING.ser怎么用?Java STRING.ser使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类io.protostuff.StringSerializer.STRING
的用法示例。
在下文中一共展示了STRING.ser方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testInt
import io.protostuff.StringSerializer.STRING; //导入方法依赖的package包/类
public void testInt() throws Exception
{
for (int i : int_targets)
{
LinkedBuffer lb = new LinkedBuffer(256);
WriteSession session = new WriteSession(lb);
StringSerializer.writeInt(i, session, lb);
LinkedBuffer lb2 = new LinkedBuffer(1);
WriteSession session2 = new WriteSession(lb2);
StringSerializer.writeInt(i, session2, lb2);
byte[] buffered = session.toByteArray();
byte[] buffered_needed_to_grow = session2.toByteArray();
byte[] builtin = STRING.ser(Integer.toString(i));
assertEquals(builtin, buffered);
assertEquals(builtin, buffered_needed_to_grow);
}
}
示例2: testLong
import io.protostuff.StringSerializer.STRING; //导入方法依赖的package包/类
public void testLong() throws Exception
{
for (long i : long_targets)
{
LinkedBuffer lb = new LinkedBuffer(256);
WriteSession session = new WriteSession(lb);
StringSerializer.writeLong(i, session, lb);
LinkedBuffer lb2 = new LinkedBuffer(1);
WriteSession session2 = new WriteSession(lb2);
StringSerializer.writeLong(i, session2, lb2);
byte[] buffered = session.toByteArray();
byte[] buffered_needed_to_grow = session2.toByteArray();
byte[] builtin = STRING.ser(Long.toString(i));
assertEquals(builtin, buffered);
assertEquals(builtin, buffered_needed_to_grow);
}
}
示例3: testFloat
import io.protostuff.StringSerializer.STRING; //导入方法依赖的package包/类
public void testFloat() throws Exception
{
for (float i : float_targets)
{
LinkedBuffer lb = new LinkedBuffer(256);
WriteSession session = new WriteSession(lb);
StringSerializer.writeFloat(i, session, lb);
LinkedBuffer lb2 = new LinkedBuffer(1);
WriteSession session2 = new WriteSession(lb2);
StringSerializer.writeFloat(i, session2, lb2);
byte[] buffered = session.toByteArray();
byte[] buffered_needed_to_grow = session2.toByteArray();
byte[] builtin = STRING.ser(Float.toString(i));
assertEquals(builtin, buffered);
assertEquals(builtin, buffered_needed_to_grow);
}
}
示例4: testDouble
import io.protostuff.StringSerializer.STRING; //导入方法依赖的package包/类
public void testDouble() throws Exception
{
for (double i : double_targets)
{
LinkedBuffer lb = new LinkedBuffer(256);
WriteSession session = new WriteSession(lb);
StringSerializer.writeDouble(i, session, lb);
LinkedBuffer lb2 = new LinkedBuffer(1);
WriteSession session2 = new WriteSession(lb2);
StringSerializer.writeDouble(i, session2, lb2);
byte[] buffered = session.toByteArray();
byte[] buffered_needed_to_grow = session2.toByteArray();
byte[] builtin = STRING.ser(Double.toString(i));
assertEquals(builtin, buffered);
assertEquals(builtin, buffered_needed_to_grow);
}
}
示例5: testInt
import io.protostuff.StringSerializer.STRING; //导入方法依赖的package包/类
public void testInt() throws Exception
{
for (int i : int_targets)
{
ByteArrayOutputStream out = new ByteArrayOutputStream();
LinkedBuffer lb = new LinkedBuffer(BUF_SIZE);
WriteSession session = new WriteSession(lb, out);
StreamedStringSerializer.writeInt(i, session, lb);
LinkedBuffer.writeTo(out, lb);
ByteArrayOutputStream out2 = new ByteArrayOutputStream();
LinkedBuffer lb2 = new LinkedBuffer(NUM_BUF_SIZE);
WriteSession session2 = new WriteSession(lb2, out2);
StreamedStringSerializer.writeInt(i, session2, lb2);
LinkedBuffer.writeTo(out2, lb2);
byte[] buffered = out.toByteArray();
byte[] buffered_needed_to_flush = out2.toByteArray();
byte[] builtin = STRING.ser(Integer.toString(i));
assertEquals(builtin, buffered);
assertEquals(builtin, buffered_needed_to_flush);
}
}
示例6: testLong
import io.protostuff.StringSerializer.STRING; //导入方法依赖的package包/类
public void testLong() throws Exception
{
for (long i : long_targets)
{
ByteArrayOutputStream out = new ByteArrayOutputStream();
LinkedBuffer lb = new LinkedBuffer(BUF_SIZE);
WriteSession session = new WriteSession(lb, out);
StreamedStringSerializer.writeLong(i, session, lb);
LinkedBuffer.writeTo(out, lb);
ByteArrayOutputStream out2 = new ByteArrayOutputStream();
LinkedBuffer lb2 = new LinkedBuffer(NUM_BUF_SIZE);
WriteSession session2 = new WriteSession(lb2, out2);
StreamedStringSerializer.writeLong(i, session2, lb2);
LinkedBuffer.writeTo(out2, lb2);
byte[] buffered = out.toByteArray();
byte[] buffered_needed_to_flush = out2.toByteArray();
byte[] builtin = STRING.ser(Long.toString(i));
assertEquals(builtin, buffered);
assertEquals(builtin, buffered_needed_to_flush);
}
}
示例7: testFloat
import io.protostuff.StringSerializer.STRING; //导入方法依赖的package包/类
public void testFloat() throws Exception
{
for (float i : float_targets)
{
ByteArrayOutputStream out = new ByteArrayOutputStream();
LinkedBuffer lb = new LinkedBuffer(BUF_SIZE);
WriteSession session = new WriteSession(lb, out);
StreamedStringSerializer.writeFloat(i, session, lb);
LinkedBuffer.writeTo(out, lb);
ByteArrayOutputStream out2 = new ByteArrayOutputStream();
LinkedBuffer lb2 = new LinkedBuffer(NUM_BUF_SIZE);
WriteSession session2 = new WriteSession(lb2, out2);
StreamedStringSerializer.writeFloat(i, session2, lb2);
LinkedBuffer.writeTo(out2, lb2);
byte[] buffered = out.toByteArray();
byte[] buffered_needed_to_flush = out2.toByteArray();
byte[] builtin = STRING.ser(Float.toString(i));
assertEquals(builtin, buffered);
assertEquals(builtin, buffered_needed_to_flush);
}
}
示例8: testDouble
import io.protostuff.StringSerializer.STRING; //导入方法依赖的package包/类
public void testDouble() throws Exception
{
for (double i : double_targets)
{
ByteArrayOutputStream out = new ByteArrayOutputStream();
LinkedBuffer lb = new LinkedBuffer(BUF_SIZE);
WriteSession session = new WriteSession(lb, out);
StreamedStringSerializer.writeDouble(i, session, lb);
LinkedBuffer.writeTo(out, lb);
ByteArrayOutputStream out2 = new ByteArrayOutputStream();
LinkedBuffer lb2 = new LinkedBuffer(NUM_BUF_SIZE);
WriteSession session2 = new WriteSession(lb2, out2);
StreamedStringSerializer.writeDouble(i, session2, lb2);
LinkedBuffer.writeTo(out2, lb2);
byte[] buffered = out.toByteArray();
byte[] buffered_needed_to_flush = out2.toByteArray();
byte[] builtin = STRING.ser(Double.toString(i));
assertEquals(builtin, buffered);
assertEquals(builtin, buffered_needed_to_flush);
}
}
示例9: writeStringNoTag
import io.protostuff.StringSerializer.STRING; //导入方法依赖的package包/类
/**
* Write a {@code string} field to the stream.
*/
public void writeStringNoTag(final CharSequence value) throws IOException
{
// Unfortunately there does not appear to be any way to tell Java to encode
// UTF-8 directly into our buffer, so we have to let it create its own byte
// array and then copy.
final byte[] bytes = STRING.ser(value.toString());
writeRawVarint32(bytes.length);
writeRawBytes(bytes);
}
示例10: ba
import io.protostuff.StringSerializer.STRING; //导入方法依赖的package包/类
static byte[] ba(String text)
{
return STRING.ser(text);
}