本文整理了Java中io.protostuff.WriteSink.writeByteArray()
方法的一些代码示例,展示了WriteSink.writeByteArray()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。WriteSink.writeByteArray()
方法的具体详情如下:
包路径:io.protostuff.WriteSink
类名称:WriteSink
方法名:writeByteArray
暂无
代码示例来源:origin: protostuff/protostuff
public LinkedBuffer packBytes(byte[] src, int offset, int length, WriteSession session, LinkedBuffer lb)
throws IOException
{
return sink.writeByteArray(src, offset, length, session, lb);
}
代码示例来源:origin: protostuff/protostuff
private void writeB64(String name, byte[] value, int offset, int length,
boolean repeated) throws IOException
{
tail = sink.writeByte(END_TAG, this,
sink.writeStrAscii(name, this,
sink.writeByteArray(START_SLASH_TAG, this,
sink.writeByteArrayB64(value, offset, length, this,
sink.writeByte(END_TAG, this,
sink.writeStrAscii(name, this,
sink.writeByte(START_TAG, this, tail)))))));
}
代码示例来源:origin: protostuff/protostuff
JsonXOutput writeCommaAndStartObject() throws IOException
{
tail = sink.writeByteArray(COMMA_AND_START_OBJECT, this, tail);
return this;
}
代码示例来源:origin: protostuff/protostuff
public abstract LinkedBuffer writeByteArray(final byte[] value,
final int offset, final int length, final WriteSession session, final LinkedBuffer lb)
throws IOException;
代码示例来源:origin: protostuff/protostuff
@Override
public void writeByteArray(int fieldNumber, byte[] value, boolean repeated) throws IOException
{
tail = sink.writeByteArray(
value,
this,
writeField(
fieldNumber,
value.length,
tail));
}
代码示例来源:origin: protostuff/protostuff
@Override
public void writeByteRange(boolean utf8String, int fieldNumber, byte[] value, int offset, int length,
boolean repeated) throws IOException
{
tail = sink.writeByteArray(
value, offset, length,
this,
writeField(
fieldNumber,
length,
tail));
}
代码示例来源:origin: protostuff/protostuff
YamlOutput writeSequenceDelim() throws IOException
{
tail = sink.writeByteArray(
DASH_AND_SPACE,
this,
newLine(
indent,
sink,
this,
tail));
indent = inc(indent, 2);
return this;
}
代码示例来源:origin: protostuff/protostuff
static LinkedBuffer writeTag(final String name, final boolean repeated,
final WriteSink sink, final WriteSession session, LinkedBuffer lb)
throws IOException
{
lb = sink.writeStrAscii(name,
session,
sink.writeByte(
EXCLAMATION,
session,
lb));
if (repeated)
return sink.writeByteArray(EMPTY_ARRAY, session, lb);
return lb;
}
代码示例来源:origin: protostuff/protostuff
@Override
public void writeBool(int fieldNumber, boolean value, boolean repeated) throws IOException
{
final String name = schema.getFieldName(fieldNumber);
tail = sink.writeByte(END_TAG, this,
sink.writeStrAscii(name, this,
sink.writeByteArray(START_SLASH_TAG, this,
sink.writeByteArray(value ? TRUE : FALSE, this,
sink.writeByte(END_TAG, this,
sink.writeStrAscii(name, this,
sink.writeByte(START_TAG, this, tail)))))));
}
代码示例来源:origin: protostuff/protostuff
@Override
public void writeByteRange(boolean utf8String, int fieldNumber, byte[] value,
int offset, int length, boolean repeated) throws IOException
{
tail = sink.writeByteArray(
value, offset, length,
this,
sink.writeVarInt32(
length,
this,
sink.writeVarInt32(
makeTag(fieldNumber, WIRETYPE_LENGTH_DELIMITED),
this,
tail)));
}
代码示例来源:origin: protostuff/protostuff
@Override
public void writeByteArray(int fieldNumber, byte[] bytes, boolean repeated) throws IOException
{
tail = sink.writeByteArray(
bytes, 0, bytes.length,
this,
sink.writeVarInt32(
bytes.length,
this,
sink.writeVarInt32(
makeTag(fieldNumber, WIRETYPE_LENGTH_DELIMITED),
this,
tail)));
/*
* tail = writeTagAndByteArray( makeTag(fieldNumber, WIRETYPE_LENGTH_DELIMITED), bytes, this, tail);
*/
}
代码示例来源:origin: protostuff/protostuff
@Override
public void writeByteRange(boolean utf8String, int fieldNumber, byte[] value,
int offset, int length, boolean repeated) throws IOException
{
if (!utf8String)
{
// B64 encode
writeB64(schema.getFieldName(fieldNumber), value, offset, length, repeated);
return;
}
// write direct
final String name = schema.getFieldName(fieldNumber);
tail = sink.writeByte(END_TAG, this,
sink.writeStrAscii(name, this,
sink.writeByteArray(START_SLASH_TAG, this,
sink.writeByteArray(value, offset, length, this,
sink.writeByte(END_TAG, this,
sink.writeStrAscii(name, this,
sink.writeByte(START_TAG, this, tail)))))));
}
代码示例来源:origin: protostuff/protostuff
private LinkedBuffer writeField(final int number, final LinkedBuffer lb)
throws IOException
{
if (numeric)
{
final int len = stringSize(number);
numBuf[0] = (byte) len;
numBuf[1] = (byte) ((len >>> 8) & 0xFF);
return sink.writeStrFromInt(
number,
this,
sink.writeByteArray(
numBuf, 0, 2,
this,
lb));
}
return sink.writeStrUTF8FixedDelimited(
schema.getFieldName(number),
true,
this,
lb);
}
代码示例来源:origin: protostuff/protostuff
/**
* Serializes the {@code message} into an {@link OutputStream} using the given schema.
*
* @return the size of the message
*/
public static <T> int writeTo(final OutputStream out, final T message,
final Schema<T> schema, final LinkedBuffer buffer) throws IOException
{
if (buffer.start != buffer.offset)
throw new IllegalArgumentException("Buffer previously used and had not been reset.");
final XmlXOutput output = new XmlXOutput(buffer, out, schema);
final String name = schema.messageName();
// header and start root element
output.tail = output.sink.writeByte(XmlXOutput.END_TAG, output,
output.sink.writeStrAscii(name, output,
output.sink.writeByte(XmlXOutput.START_TAG, output,
output.sink.writeByteArray(HEADER, output, output.tail))));
schema.writeTo(output, message);
// end root element
output.tail = output.sink.writeByte(XmlXOutput.END_TAG, output,
output.sink.writeStrAscii(name, output,
output.sink.writeByteArray(XmlXOutput.START_SLASH_TAG, output, output.tail)));
LinkedBuffer.writeTo(out, buffer);
return output.size;
}
代码示例来源:origin: protostuff/protostuff
@Override
public void writeFloat(int fieldNumber, float value, boolean repeated) throws IOException
{
final String name = schema.getFieldName(fieldNumber);
tail = sink.writeByte(END_TAG, this,
sink.writeStrAscii(name, this,
sink.writeByteArray(START_SLASH_TAG, this,
sink.writeStrFromFloat(value, this,
sink.writeByte(END_TAG, this,
sink.writeStrAscii(name, this,
sink.writeByte(START_TAG, this, tail)))))));
}
代码示例来源:origin: protostuff/protostuff
@Override
public void writeInt32(int fieldNumber, int value, boolean repeated) throws IOException
{
final String name = schema.getFieldName(fieldNumber);
tail = sink.writeByte(END_TAG, this,
sink.writeStrAscii(name, this,
sink.writeByteArray(START_SLASH_TAG, this,
sink.writeStrFromInt(value, this,
sink.writeByte(END_TAG, this,
sink.writeStrAscii(name, this,
sink.writeByte(START_TAG, this, tail)))))));
}
代码示例来源:origin: protostuff/protostuff
@Override
public void writeInt64(int fieldNumber, long value, boolean repeated) throws IOException
{
final String name = schema.getFieldName(fieldNumber);
tail = sink.writeByte(END_TAG, this,
sink.writeStrAscii(name, this,
sink.writeByteArray(START_SLASH_TAG, this,
sink.writeStrFromLong(value, this,
sink.writeByte(END_TAG, this,
sink.writeStrAscii(name, this,
sink.writeByte(START_TAG, this, tail)))))));
}
代码示例来源:origin: protostuff/protostuff
@Override
public void writeDouble(int fieldNumber, double value, boolean repeated) throws IOException
{
final String name = schema.getFieldName(fieldNumber);
tail = sink.writeByte(END_TAG, this,
sink.writeStrAscii(name, this,
sink.writeByteArray(START_SLASH_TAG, this,
sink.writeStrFromDouble(value, this,
sink.writeByte(END_TAG, this,
sink.writeStrAscii(name, this,
sink.writeByte(START_TAG, this, tail)))))));
}
代码示例来源:origin: protostuff/protostuff
@Override
public void writeString(int fieldNumber, CharSequence value, boolean repeated) throws IOException
{
final String name = schema.getFieldName(fieldNumber);
tail = sink.writeByte(END_TAG, this,
sink.writeStrAscii(name, this,
sink.writeByteArray(START_SLASH_TAG, this,
sink.writeStrUTF8(value, this,
sink.writeByte(END_TAG, this,
sink.writeStrAscii(name, this,
sink.writeByte(START_TAG, this, tail)))))));
}
代码示例来源:origin: protostuff/protostuff
@Override
public <T> void writeObject(int fieldNumber, T value, Schema<T> schema, boolean repeated)
throws IOException
{
final Schema<?> lastSchema = this.schema;
this.schema = schema;
final String name = lastSchema.getFieldName(fieldNumber);
// start tag
tail = sink.writeByte(END_TAG, this,
sink.writeStrAscii(name, this,
sink.writeByte(START_TAG, this, tail)));
schema.writeTo(this, value);
// end tag
tail = sink.writeByte(END_TAG, this,
sink.writeStrAscii(name, this,
sink.writeByteArray(START_SLASH_TAG, this, tail)));
// restore state
this.schema = lastSchema;
}
内容来源于网络,如有侵权,请联系作者删除!