下面列出了java.io.ObjectInput#readUnsignedByte ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
/**
* Note the use of data2c: we reuse the array if the
* incoming array is the same length or smaller than
* the array length.
*
* @see java.io.Externalizable#readExternal
*/
public void readExternal(ObjectInput in) throws IOException
{
sqlScale = in.readUnsignedByte();
int size = in.readUnsignedByte();
/*
** Allocate a new array if the data to read
** is larger than the existing array, or if
** we don't have an array yet.
Need to use readFully below and NOT just read because read does not
guarantee getting size bytes back, whereas readFully does (unless EOF).
*/
if ((data2c == null) || size != data2c.length)
{
data2c = new byte[size];
}
in.readFully(data2c);
}
/**
* Note the use of data2c: we reuse the array if the
* incoming array is the same length or smaller than
* the array length.
*
* @see java.io.Externalizable#readExternal
*/
public void readExternal(ObjectInput in) throws IOException
{
sqlScale = in.readUnsignedByte();
int size = in.readUnsignedByte();
/*
** Allocate a new array if the data to read
** is larger than the existing array, or if
** we don't have an array yet.
Need to use readFully below and NOT just read because read does not
guarantee getting size bytes back, whereas readFully does (unless EOF).
*/
if ((data2c == null) || size != data2c.length)
{
data2c = new byte[size];
}
in.readFully(data2c);
}
/** {@inheritDoc} */
@Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
nodeId = U.readUuid(in);
updateSeq = in.readLong();
int size = in.readInt();
map = new GridPartitionStateMap();
for (int i = 0; i < size; i++) {
int ordinal = in.readUnsignedByte();
int part = in.readUnsignedShort();
put(part, GridDhtPartitionState.fromOrdinal(ordinal));
}
long ver = in.readLong();
int minorVer = in.readInt();
if (ver != 0)
top = new AffinityTopologyVersion(ver, minorVer);
}
/**
*
* To support efficient serialization for SmallMessage implementations,
* this utility method reads in the property flags from an ObjectInput
* stream. Flags are read in one byte at a time. Flags make use of
* sign-extension so that if the high-bit is set to 1 this indicates that
* another set of flags follows.
*
* @return The array of property flags.
*/
protected short[] readFlags(ObjectInput input) throws IOException
{
boolean hasNextFlag = true;
short[] flagsArray = new short[2];
int i = 0;
while (hasNextFlag)
{
short flags = (short)input.readUnsignedByte();
if (i == flagsArray.length)
{
short[] tempArray = new short[i*2];
System.arraycopy(flagsArray, 0, tempArray, 0, flagsArray.length);
flagsArray = tempArray;
}
flagsArray[i] = flags;
hasNextFlag = (flags & HAS_NEXT_FLAG) != 0;
i++;
}
return flagsArray;
}
/**
* Note the use of data2c: we reuse the array if the
* incoming array is the same length or smaller than
* the array length.
*
* @see java.io.Externalizable#readExternal
*/
public void readExternal(ObjectInput in) throws IOException
{
sqlScale = in.readUnsignedByte();
int size = in.readUnsignedByte();
/*
** Allocate a new array if the data to read
** is larger than the existing array, or if
** we don't have an array yet.
Need to use readFully below and NOT just read because read does not
guarantee getting size bytes back, whereas readFully does (unless EOF).
*/
if ((data2c == null) || size != data2c.length)
{
data2c = new byte[size];
}
in.readFully(data2c);
isNull = evaluateNull();
}
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
{
checksumAlgo = (byte) in.readUnsignedByte();
dataLength = in.readInt();
checksumValue = in.readLong();
initializeChecksumAlgo();
}
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
{
checksumAlgo = (byte) in.readUnsignedByte();
dataLength = in.readInt();
checksumValue = in.readLong();
initializeChecksumAlgo();
}
@Override
public void readExternal(ObjectInput in) throws IOException,ClassNotFoundException {
super.readExternal(in);
restrictionMethodName = readNullableString(in);
projectionMethodName = readNullableString(in);
constantRestrictionMethodName = readNullableString(in);
mapRefItem = in.readInt();
cloneMapItem = in.readInt();
int version = in.readUnsignedByte();
if (version < PROJECT_RESTRICT_OPERATION_V2)
reuseResult = (version == 1);
else
reuseResult = in.readBoolean();
doesProjection = in.readBoolean();
source = (SpliceOperation) in.readObject();
if (version >= PROJECT_RESTRICT_OPERATION_V2) {
filterPred = readNullableString(in);
int numexpressions = in.readInt();
if (numexpressions > 0) {
expressions = new String[numexpressions];
for (int i = 0; i < numexpressions; i++) {
expressions[i] = readNullableString(in);
}
}
hasGroupingFunction = in.readBoolean();
}
subqueryText = readNullableString(in);
}
/**
* Note the use of rawData: we reuse the array if the
* incoming array is the same length or smaller than
* the array length.
*
* @see java.io.Externalizable#readExternal
*/
public void readExternal(ObjectInput in) throws IOException {
if (in.readBoolean()) {
setCoreValue(null);
return;
}
// clear the previous value to ensure that the
// rawData value will be used
value = null;
rawScale = in.readUnsignedByte();
int size = in.readUnsignedByte();
/*
** Allocate a new array if the data to read
** is larger than the existing array, or if
** we don't have an array yet.
Need to use readFully below and NOT just read because read does not
guarantee getting size bytes back, whereas readFully does (unless EOF).
*/
if ((rawData == null) || size != rawData.length)
{
rawData = new byte[size];
}
in.readFully(rawData);
isNull = evaluateNull();
}
/**
* For Externalizable
*
* @see Externalizable
*/
public void readExternal(ObjectInput in)
throws IOException, ClassNotFoundException {
// do it the way we like
int len = in.readInt(); // IPv6 compatible
byte addr[] = new byte[len];
in.readFully(addr);
InetAddress inetAddr = InetAddress.getByAddress(addr);
int port = in.readInt();
this.hostName = DataSerializer.readString(in);
int flags = in.readUnsignedByte();
boolean sbEnabled = (flags & SB_ENABLED_MASK) != 0;
boolean elCoord = (flags & COORD_ENABLED_MASK) != 0;
this.isPartial = (flags & PARTIAL_ID_MASK) != 0;
this.dcPort = in.readInt();
this.vmPid = in.readInt();
this.vmKind = in.readInt();
this.vmViewId = in.readInt();
this.groups = DataSerializer.readStringArray(in);
this.name = DataSerializer.readString(in);
this.uniqueTag = DataSerializer.readString(in);
String durableId = DataSerializer.readString(in);
int durableTimeout = DataSerializer.readInteger(in).intValue();
this.durableClientAttributes = new DurableClientAttributes(durableId, durableTimeout);
readVersion(flags, in);
ipAddr = MemberFactory.newNetMember(inetAddr, port, sbEnabled, elCoord,
new MemberAttributes(dcPort, vmPid, vmKind, vmViewId, name, groups, durableClientAttributes));
((JGroupMember)ipAddr).getAddress().setVersionOrdinal(this.version);
Assert.assertTrue(this.vmKind > 0);
// [sumedh] loner VMs will have port as zero if no GFE client is connected
// e.g. with GFXD clients
Assert.assertTrue(vmKind == DistributionManager.LONER_DM_TYPE
|| getPort() > 0);
}
/**
* For Externalizable
*
* @see Externalizable
*/
public void readExternal(ObjectInput in)
throws IOException, ClassNotFoundException {
// do it the way we like
int len = in.readInt(); // IPv6 compatible
byte addr[] = new byte[len];
in.readFully(addr);
InetAddress inetAddr = InetAddress.getByAddress(addr);
int port = in.readInt();
this.hostName = DataSerializer.readString(in);
int flags = in.readUnsignedByte();
boolean sbEnabled = (flags & SB_ENABLED_MASK) != 0;
boolean elCoord = (flags & COORD_ENABLED_MASK) != 0;
this.isPartial = (flags & PARTIAL_ID_MASK) != 0;
this.dcPort = in.readInt();
this.vmPid = in.readInt();
this.vmKind = in.readInt();
this.vmViewId = in.readInt();
this.groups = DataSerializer.readStringArray(in);
this.name = DataSerializer.readString(in);
this.uniqueTag = DataSerializer.readString(in);
String durableId = DataSerializer.readString(in);
int durableTimeout = DataSerializer.readInteger(in).intValue();
this.durableClientAttributes = new DurableClientAttributes(durableId, durableTimeout);
readVersion(flags, in);
ipAddr = MemberFactory.newNetMember(inetAddr, port, sbEnabled, elCoord,
new MemberAttributes(dcPort, vmPid, vmKind, vmViewId, name, groups, durableClientAttributes));
((JGroupMember)ipAddr).getAddress().setVersionOrdinal(this.version);
Assert.assertTrue(this.vmKind > 0);
// [sumedh] loner VMs will have port as zero if no GFE client is connected
// e.g. with GFXD clients
Assert.assertTrue(vmKind == DistributionManager.LONER_DM_TYPE
|| getPort() > 0);
}