本文整理汇总了Java中java.io.DataOutput.writeByte方法的典型用法代码示例。如果您正苦于以下问题:Java DataOutput.writeByte方法的具体用法?Java DataOutput.writeByte怎么用?Java DataOutput.writeByte使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.io.DataOutput
的用法示例。
在下文中一共展示了DataOutput.writeByte方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: write
import java.io.DataOutput; //导入方法依赖的package包/类
/**
* Write the actual data contents of the tag, implemented in NBT extension classes
*/
void write(DataOutput output) throws IOException
{
if (!this.tagList.isEmpty())
{
this.tagType = ((NBTBase)this.tagList.get(0)).getId();
}
else
{
this.tagType = 0;
}
output.writeByte(this.tagType);
output.writeInt(this.tagList.size());
for (int i = 0; i < this.tagList.size(); ++i)
{
((NBTBase)this.tagList.get(i)).write(output);
}
}
示例2: writeChars
import java.io.DataOutput; //导入方法依赖的package包/类
private static void writeChars(DataOutput out,
String s, int start, int length)
throws IOException {
final int end = start + length;
for (int i = start; i < end; i++) {
int code = s.charAt(i);
if (code <= 0x7F) {
out.writeByte((byte)code);
} else if (code <= 0x07FF) {
out.writeByte((byte)(0xC0 | ((code >> 6) & 0x1F)));
out.writeByte((byte)(0x80 | code & 0x3F));
} else {
out.writeByte((byte)(0xE0 | ((code >> 12) & 0X0F)));
out.writeByte((byte)(0x80 | ((code >> 6) & 0x3F)));
out.writeByte((byte)(0x80 | (code & 0x3F)));
}
}
}
示例3: toData
import java.io.DataOutput; //导入方法依赖的package包/类
/**
* Send the contents of this instance to the DataOutput Required to be a
* {@link org.apache.geode.DataSerializable}Note: must be symmetric with
* {@link #fromData(DataInput)}in what it writes
*/
@Override
public void toData(DataOutput out) throws IOException {
super.toData(out);
short flags = computeCompressedShort();
out.writeShort(flags);
if (this.processorId != 0) {
out.writeInt(this.processorId);
}
if (this.processorType != 0) {
out.writeByte(this.processorType);
}
if (this.getTXUniqId() != TXManagerImpl.NOTX) {
out.writeInt(this.getTXUniqId());
}
if (this.getTXMemberId() != null) {
DataSerializer.writeObject(this.getTXMemberId(), out);
}
DataSerializer.writeString(this.regionPath, out);
out.writeBoolean(this.isTransactionDistributed);
}
示例4: write
import java.io.DataOutput; //导入方法依赖的package包/类
@Override
public void write(DataOutput out) throws IOException {
super.write(out);
// Write out the number of entries in the map
out.writeInt(instance.size());
// Then write out each key/value pair
for (Map.Entry<WritableComparable, Writable> e: instance.entrySet()) {
out.writeByte(getId(e.getKey().getClass()));
e.getKey().write(out);
out.writeByte(getId(e.getValue().getClass()));
e.getValue().write(out);
}
}
示例5: writeChars
import java.io.DataOutput; //导入方法依赖的package包/类
private static void writeChars(DataOutput out,
String s, int start, int length)
throws IOException {
final int end = start + length;
for (int i = start; i < end; i++) {
int code = s.charAt(i);
if (code >= 0x01 && code <= 0x7F) {
out.writeByte((byte)code);
} else if (code <= 0x07FF) {
out.writeByte((byte)(0xC0 | ((code >> 6) & 0x1F)));
out.writeByte((byte)(0x80 | code & 0x3F));
} else {
out.writeByte((byte)(0xE0 | ((code >> 12) & 0X0F)));
out.writeByte((byte)(0x80 | ((code >> 6) & 0x3F)));
out.writeByte((byte)(0x80 | (code & 0x3F)));
}
}
}
示例6: toData
import java.io.DataOutput; //导入方法依赖的package包/类
@Override
public void toData(DataOutput out) throws IOException {
super.toData(out);
DataSerializer.writeObject(getKey(), out);
DataSerializer.writeObject(this.cbArg, out);
out.writeByte(this.op.ordinal);
out.writeBoolean(this.notificationOnly);
DataSerializer.writeObject(this.bridgeContext, out);
DataSerializer.writeObject(this.originalSender, out);
DataSerializer.writeObject(this.eventId, out);
DataSerializer.writeObject(this.expectedOldValue, out);
if (this.filterInfo != null) {
InternalDataSerializer.invokeToData(this.filterInfo, out);
}
DataSerializer.writeObject(this.versionTag, out);
}
示例7: writeVLong
import java.io.DataOutput; //导入方法依赖的package包/类
/**
* Serializes a long to a binary stream with zero-compressed encoding. For -112 <= i <= 127, only
* one byte is used with the actual value. For other values of i, the first byte value indicates
* whether the long is positive or negative, and the number of bytes that follow. If the first
* byte value v is between -113 and -120, the following long is positive, with number of bytes
* that follow are -(v+112). If the first byte value v is between -121 and -128, the following
* long is negative, with number of bytes that follow are -(v+120). Bytes are stored in the
* high-non-zero-byte-first order.
* @param stream Binary output stream
* @param i Long to be serialized
* @throws java.io.IOException
*/
public static void writeVLong(DataOutput stream, long i) throws IOException {
if (i >= -112 && i <= 127) {
stream.writeByte((byte) i);
return;
}
int len = -112;
if (i < 0) {
i ^= -1L; // take one's complement'
len = -120;
}
long tmp = i;
while (tmp != 0) {
tmp = tmp >> 8;
len--;
}
stream.writeByte((byte) len);
len = (len < -120) ? -(len + 120) : -(len + 112);
for (int idx = len; idx != 0; idx--) {
int shiftbits = (idx - 1) * 8;
long mask = 0xFFL << shiftbits;
stream.writeByte((byte) ((i & mask) >> shiftbits));
}
}
示例8: toData
import java.io.DataOutput; //导入方法依赖的package包/类
@Override
public void toData(DataOutput out) throws IOException {
out.writeBoolean(this.hasKeys);
if (this.objectTypeArray != null) {
int numObjects = this.objects.size();
out.writeInt(numObjects);
for (int index = 0; index < numObjects; ++index) {
Object value = this.objects.get(index);
byte objectType = this.objectTypeArray[index];
if (this.hasKeys) {
DataSerializer.writeObject(this.keys.get(index), out);
}
if ((objectType == KEY_NOT_AT_SERVER)) {
out.writeByte(KEY_NOT_AT_SERVER);
} else if (objectType == EXCEPTION) {
out.writeByte(EXCEPTION);
} else {
out.writeByte(OBJECT);
}
if (objectType == OBJECT && value instanceof byte[]) {
out.write((byte[]) value);
} else if (objectType == EXCEPTION) {
// write exception as byte array so native clients can skip it
DataSerializer.writeByteArray(CacheServerHelper.serialize(value), out);
// write the exception string for native clients
DataSerializer.writeString(value.toString(), out);
} else {
DataSerializer.writeObject(value, out);
}
}
} else {
out.writeInt(0);
}
}
示例9: writeImpl
import java.io.DataOutput; //导入方法依赖的package包/类
@VisibleForTesting
void writeImpl(DataOutput out) throws IOException {
out.writeByte(VERSION);
owner.write(out);
renewer.write(out);
realUser.write(out);
WritableUtils.writeVLong(out, issueDate);
WritableUtils.writeVLong(out, maxDate);
WritableUtils.writeVInt(out, sequenceNumber);
WritableUtils.writeVInt(out, masterKeyId);
}
示例10: writeArrayLength
import java.io.DataOutput; //导入方法依赖的package包/类
public static void writeArrayLength(int len, DataOutput out) throws IOException {
if (len == -1) {
out.writeByte(NULL_ARRAY);
} else if (len <= MAX_BYTE_ARRAY_LEN) {
out.writeByte(len);
} else if (len <= 0xFFFF) {
out.writeByte(SHORT_ARRAY_LEN);
out.writeShort(len);
} else {
out.writeByte(INT_ARRAY_LEN);
out.writeInt(len);
}
}
示例11: writeVarlong
import java.io.DataOutput; //导入方法依赖的package包/类
/**
* Write the given integer following the variable-length zig-zag encoding from
* <a href="http://code.google.com/apis/protocolbuffers/docs/encoding.html"> Google Protocol Buffers</a>
* into the output.
*
* @param value The value to write
* @param out The output to write to
*/
public static void writeVarlong(long value, DataOutput out) throws IOException {
long v = (value << 1) ^ (value >> 63);
while ((v & 0xffffffffffffff80L) != 0L) {
out.writeByte(((int) v & 0x7f) | 0x80);
v >>>= 7;
}
out.writeByte((byte) v);
}
示例12: toData
import java.io.DataOutput; //导入方法依赖的package包/类
@Override
public void toData(DataOutput out) throws IOException {
super.toData(out);
byte b = 0;
if (this.versionTag != null) {
b |= HAS_VERSION;
}
if (this.versionTag instanceof DiskVersionTag) {
b |= PERSISTENT;
}
out.writeByte(b);
if (this.versionTag != null) {
InternalDataSerializer.invokeToData(this.versionTag, out);
}
}
示例13: toData
import java.io.DataOutput; //导入方法依赖的package包/类
public void toData(DataOutput out) throws IOException {
out.writeByte(this.entryBits);
byte flags = (this.versionTag != null) ? HAS_VERSION : 0;
flags |= (this.versionTag instanceof DiskVersionTag) ? PERSISTENT_VERSION : 0;
out.writeByte(flags);
DataSerializer.writeObject(this.key, out);
if (!EntryBits.isTombstone(this.entryBits)) {
DataSerializer.writeObjectAsByteArray(this.value, out);
}
out.writeLong(this.lastModified);
if (this.versionTag != null) {
InternalDataSerializer.invokeToData(this.versionTag, out);
}
}
示例14: writeEntry
import java.io.DataOutput; //导入方法依赖的package包/类
private static void writeEntry(String name, NBTBase data, DataOutput output) throws IOException
{
output.writeByte(data.getId());
if (data.getId() != 0)
{
output.writeUTF(name);
data.write(output);
}
}
示例15: write
import java.io.DataOutput; //导入方法依赖的package包/类
@Override
protected void write(final DataOutput output) throws IOException {
for(final String key : this.tags.keySet()) {
final Tag tag = this.tags.get(key);
output.writeByte(tag.type().id());
if(tag.type() != TagType.END) {
output.writeUTF(key);
tag.write(output);
}
}
output.writeByte(TagType.END.id());
}