下面列出了java.io.ObjectInput#readFully ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
int num;
type=in.readInt();
if((num=in.readInt()) > 0) {
data=new byte[num];
in.readFully(data, 0, num);
}
if(in.readBoolean()) {
transaction=new Xid();
transaction.readExternal(in);
}
use_locks=in.readBoolean();
if(use_locks) {
if((num=in.readInt()) > 0) {
lock_info=new byte[num];
in.readFully(lock_info, 0, num);
}
lock_acquisition_timeout=in.readLong();
lock_lease_timeout=in.readLong();
}
}
/**
* For Externalizable
*
* @see java.io.Externalizable
*/
public void readExternal(ObjectInput in) throws IOException,
ClassNotFoundException {
// ipAddr = new IpAddress();
// ipAddr.readExternal(in);
// do it the way we like
int len = in.readInt(); // IPv6 compatible
byte addr[] = new byte[len];
in.readFully(addr);
InetAddress ia = InetAddress.getByAddress(addr);
int port = in.readInt();
byte flags = in.readByte();
ipAddr = new IpAddress(ia, port);
ipAddr.setFlags(flags);
ipAddr.readVersion(flags, in);
len = in.readInt();
if (len != 0) {
byte bytes[] = new byte[len];
in.readFully(bytes);
GFJGBasicAdapter.insertGemFireAttributes(ipAddr, new MemberAttributes(bytes));
}
}
@Override
public void readExternal(ObjectInput in) throws IOException,ClassNotFoundException {
offset = in.readInt();
length = in.readInt();
buffer = new byte[length];
if(length > 0) {
in.readFully(buffer);
}
hashSet = false;
if (buffer.length > 0) {
assertLengthCorrect(buffer, offset, length);
} else {
// If there's nothing in the buffer, reset offset and length
// to prevent ArrayIndexOutOfBoundsException
offset = length = 0;
}
}
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
int num;
type=in.readInt();
if((num=in.readInt()) > 0) {
data=new byte[num];
in.readFully(data, 0, num);
}
if(in.readBoolean()) {
transaction=new Xid();
transaction.readExternal(in);
}
use_locks=in.readBoolean();
if(use_locks) {
if((num=in.readInt()) > 0) {
lock_info=new byte[num];
in.readFully(lock_info, 0, num);
}
lock_acquisition_timeout=in.readLong();
lock_lease_timeout=in.readLong();
}
}
/**
* delegated to bit
*
* @exception IOException io exception
* @exception ClassNotFoundException class not found
*/
public final void readExternal(ObjectInput in) throws IOException
{
// need to clear stream first, in case this object is reused, and
// stream is set by previous use. Track 3794.
//stream = null;
//streamValueLength = -1;
_blobValue = null;
int len = SQLBinary.readBinaryLength(in);
if (len != 0)
{
dataValue = new byte[len];
in.readFully(dataValue);
}
else
{
readFromStream((InputStream) in);
}
}
@Override
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
super.readExternal(in);
byte[] serReq = new byte[in.readInt()];
in.readFully(serReq);
request = TOMMessage.bytesToMessage(serReq);
request.serializedMessage = serReq;
boolean signed = in.readBoolean();
if (signed) {
byte[] serReqSign = new byte[in.readInt()];
in.readFully(serReqSign);
request.serializedMessageSignature = serReqSign;
}
}
@Override
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
txn = SIDriver.driver().getOperationFactory().readTxn(in);
ah = (ActivationHolder) in.readObject();
schemaName = in.readUTF();
tableName = in.readUTF();
int iSize = in.readInt();
tentativeIndexList = new ArrayList<>(iSize);
for (int i = 0; i< iSize; i++) {
byte[] message = new byte[in.readInt()];
in.readFully(message);
tentativeIndexList.add(DDLMessage.TentativeIndex.parseFrom(message));
}
fix = in.readBoolean();
jobGroup = in.readUTF();
}
/**
* For Externalizable
*
* @see java.io.Externalizable
*/
public void readExternal(ObjectInput in) throws IOException,
ClassNotFoundException {
// ipAddr = new IpAddress();
// ipAddr.readExternal(in);
// do it the way we like
int len = in.readInt(); // IPv6 compatible
byte addr[] = new byte[len];
in.readFully(addr);
InetAddress ia = InetAddress.getByAddress(addr);
int port = in.readInt();
byte flags = in.readByte();
ipAddr = new IpAddress(ia, port);
ipAddr.setFlags(flags);
ipAddr.readVersion(flags, in);
len = in.readInt();
if (len != 0) {
byte bytes[] = new byte[len];
in.readFully(bytes);
GFJGBasicAdapter.insertGemFireAttributes(ipAddr, new MemberAttributes(bytes));
}
}
@Override
public TxnView readTxn(ObjectInput oi) throws IOException{
int size=oi.readInt();
byte[] txnData=new byte[size];
oi.readFully(txnData);
return decode(txnData,0,txnData.length);
}
/**
* @see java.io.Externalizable#readExternal
* @param in ObjectInput
* @throws IOException
*/
@Override
public void readExternal(ObjectInput in ) throws IOException {
int length = in.readInt();
message = new byte[length];
in.readFully(message);
}
@Override
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException{
super.readExternal(in);
int size=in.readInt();
sysColumnsRow=new byte[size];
in.readFully(sysColumnsRow);
}
/**
* The object implements the readExternal method to restore its
* contents by calling the methods of DataInput for primitive
* types and readObject for objects, strings and arrays. The
* readExternal method must read the values in the same sequence
* and with the same types as were written by writeExternal.
* @exception ClassNotFoundException If the class for an object being
* restored cannot be found.
*/
public void readExternal(ObjectInput in) throws IOException,
ClassNotFoundException {
String s = in.readUTF();
if (s == null || s.length() == 0) { // long mime type
byte[] ba = new byte[in.readInt()];
in.readFully(ba);
s = new String(ba);
}
try {
parse(s);
} catch(MimeTypeParseException e) {
throw new IOException(e.toString());
}
}
/**
* Read this object from a stream of stored objects.
*
* @param in read this.
*
* @exception IOException thrown on error
*/
public void readExternal( ObjectInput in ) throws IOException
{
int len = length = in.readInt();
offset = 0;
array = new byte[len];
in.readFully(array, 0, len);
}
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
{
int len = in.readByte();
this.globalId = new byte[len];
in.readFully(this.globalId);
len = in.readByte();
this.branchId = new byte[len];
in.readFully(this.branchId);
}
/**
* The object implements the readExternal method to restore its
* contents by calling the methods of DataInput for primitive
* types and readObject for objects, strings and arrays. The
* readExternal method must read the values in the same sequence
* and with the same types as were written by writeExternal.
* @exception ClassNotFoundException If the class for an object being
* restored cannot be found.
*/
public void readExternal(ObjectInput in) throws IOException,
ClassNotFoundException {
String s = in.readUTF();
if (s == null || s.length() == 0) { // long mime type
byte[] ba = new byte[in.readInt()];
in.readFully(ba);
s = new String(ba);
}
try {
parse(s);
} catch(MimeTypeParseException e) {
throw new IOException(e.toString());
}
}
/**
* The object implements the readExternal method to restore its
* contents by calling the methods of DataInput for primitive
* types and readObject for objects, strings and arrays. The
* readExternal method must read the values in the same sequence
* and with the same types as were written by writeExternal.
* @exception ClassNotFoundException If the class for an object being
* restored cannot be found.
*/
public void readExternal(ObjectInput in) throws IOException,
ClassNotFoundException {
String s = in.readUTF();
if (s == null || s.length() == 0) { // long mime type
byte[] ba = new byte[in.readInt()];
in.readFully(ba);
s = new String(ba);
}
try {
parse(s);
} catch(MimeTypeParseException e) {
throw new IOException(e.toString());
}
}
@Override
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
this.baseOffset = Platform.BYTE_ARRAY_OFFSET;
this.sizeInBytes = in.readInt();
this.numFields = in.readInt();
this.baseObject = new byte[sizeInBytes];
in.readFully((byte[]) baseObject);
}
@Override
public void readExternal(final ObjectInput in) throws IOException,
ClassNotFoundException {
id = in.readUTF();
version = in.readInt();
off = 0; // Note: offset always zero when de-serialized.
len = in.readInt();
b = new byte[len];
in.readFully(b);
}
/**
* 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);
}
public void readExternal(final ObjectInput in) throws IOException,
ClassNotFoundException {
final short version = ShortPacker.unpackShort(in);
switch (version) {
case VERSION0:
case VERSION1:
case VERSION2:
break;
default:
throw new IOException("Unknown version: " + version);
}
if (version < VERSION2) {
partitionId = (int) LongPacker.unpackLong(in);
} else {
partitionId = in.readInt();
}
sourcePartitionId = in.readInt(); // MAY be -1.
final int nresources = ShortPacker.unpackShort(in);
final int leftLen = (int) LongPacker.unpackLong(in);
final int rightLen = (int) LongPacker.unpackLong(in);
leftSeparatorKey = new byte[leftLen];
in.readFully(leftSeparatorKey);
if (rightLen != 0) {
rightSeparatorKey = new byte[rightLen];
in.readFully(rightSeparatorKey);
} else {
rightSeparatorKey = null;
}
cause = (IndexPartitionCause)in.readObject();
if (version < VERSION2) {
/* history = */in.readUTF();
}
resources = nresources>0 ? new IResourceMetadata[nresources] : null;
for (int j = 0; j < nresources; j++) {
final boolean isIndexSegment = in.readBoolean();
final String filename = in.readUTF();
// long nbytes = LongPacker.unpackLong(in);
final UUID uuid = new UUID(in.readLong()/*MSB*/,in.readLong()/*LSB*/);
final long createTime = in.readLong();
long commitTime = 0L;
if (version >= VERSION1 && !isIndexSegment) {
commitTime = in.readLong();
}
resources[j] = (isIndexSegment //
? new SegmentMetadata(filename, /*nbytes,*/ uuid, createTime) //
: new JournalMetadata(filename, /*nbytes,*/ uuid, createTime, commitTime) //
);
}
}