下面列出了java.io.ObjectOutput#writeShort ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
public void writeExternal(final ObjectOutput out) throws IOException {
if (val2iv == null)
throw new IllegalStateException();
if (iv2val == null)
throw new IllegalStateException();
out.writeShort(currentVersion);
switch (currentVersion) {
// case VERSION0:
// writeVersion0(out);
// break;
// case VERSION1:
// writeVersion1(out);
// break;
case VERSION2:
writeVersion2(out);
break;
default:
throw new AssertionError();
}
}
public void writeExternal(ObjectOutput out) throws IOException {
if(method_name != null) {
out.writeBoolean(true);
out.writeUTF(method_name);
}
else {
out.writeBoolean(false);
out.writeShort(method_id);
}
out.writeObject(args);
out.writeShort(mode);
switch(mode) {
case OLD:
break;
case METHOD:
out.writeObject(method.getParameterTypes());
out.writeObject(method.getDeclaringClass());
break;
case TYPES:
out.writeObject(types);
break;
case SIGNATURE:
out.writeObject(signature);
break;
case ID:
break;
default:
if(log.isErrorEnabled()) log.error(ExternalStrings.MethodCall_MODE__0__IS_INVALID, mode);
break;
}
if(payload != null) {
out.writeBoolean(true);
out.writeObject(payload);
}
else {
out.writeBoolean(false);
}
}
@Override
public void writeExternal(ObjectOutput out) throws IOException {
out.writeShort(Character.reverseBytes((char) this.nbrruns));
for (int k = 0; k < 2 * this.nbrruns; ++k) {
out.writeShort(Character.reverseBytes(this.valueslength.get(k)));
}
}
/**
* Marshal value to an ObjectOutput sink using RMI's serialization
* format for parameters or return values.
*/
protected static void marshalValue(Class<?> type, Object value,
ObjectOutput out)
throws IOException
{
if (type.isPrimitive()) {
if (type == int.class) {
out.writeInt(((Integer) value).intValue());
} else if (type == boolean.class) {
out.writeBoolean(((Boolean) value).booleanValue());
} else if (type == byte.class) {
out.writeByte(((Byte) value).byteValue());
} else if (type == char.class) {
out.writeChar(((Character) value).charValue());
} else if (type == short.class) {
out.writeShort(((Short) value).shortValue());
} else if (type == long.class) {
out.writeLong(((Long) value).longValue());
} else if (type == float.class) {
out.writeFloat(((Float) value).floatValue());
} else if (type == double.class) {
out.writeDouble(((Double) value).doubleValue());
} else {
throw new Error("Unrecognized primitive type: " + type);
}
} else {
out.writeObject(value);
}
}
@Override
public void writeExternal(ObjectOutput objectOutput) throws IOException {
short len = (short) (messageArgs == null ? 0 : messageArgs.length);
objectOutput.writeShort(len);
for (int i = 0; i < len; i++) {
objectOutput.writeUTF(messageArgs[i]);
}
}
public void send(byte code, ObjectOutput out) throws IOException {
JClientRequestInfo info = new JRMPClientRequestInfoImpl();
for (int i = 0; i < cis.length; i++) {
cis[i].send_request(info);
}
Collection c = info.get_all_request_service_context();
out.writeShort(c.size());
for (Iterator it = c.iterator(); it.hasNext(); ) {
out.writeObject(it.next());
}
}
/**
* Write an XML value.
* @param out The stream to which we're writing.
*/
public void writeExternal(ObjectOutput out) throws IOException
{
// never called when value is null
if (SanityManager.DEBUG)
SanityManager.ASSERT(!isNull());
// Write out the XML store impl id.
out.writeShort(UTF8_IMPL_ID);
// Now write out the data.
xmlStringValue.writeExternal(out);
}
public void writeExternal( ObjectOutput out ) throws IOException {
out.writeObject( value );
out.writeBoolean( isExplicitlySet );
out.writeBoolean( explicitSetEnabled );
out.writeObject( rangeTypes );
out.writeObject( defaultValuesByTraits );
out.writeObject( defaultValueByClass );
out.writeShort( position );
}
@Override
public void writeExternal(ObjectOutput out) throws IOException {
out.write(this.cardinality & 0xFF);
out.write((this.cardinality >>> 8) & 0xFF);
if (BufferUtil.isBackedBySimpleArray(content)) {
char[] a = content.array();
for (int k = 0; k < this.cardinality; ++k) {
out.writeShort(Character.reverseBytes(a[k]));
}
} else {
for (int k = 0; k < this.cardinality; ++k) {
out.writeShort(Character.reverseBytes(content.get(k)));
}
}
}
@Override
public void writeExternal(final ObjectOutput out) throws IOException {
// write out the version of the serialized data for future use
out.writeByte(2);
final boolean hasExec = handler.executor != null && handler.executor != JNDIContext.globalExecutor();
out.writeBoolean(hasExec);
if (hasExec) {
out.writeInt(handler.executor.getMaximumPoolSize());
final BlockingQueue<Runnable> queue = handler.executor.getQueue();
out.writeInt(queue.size() + queue.remainingCapacity());
}
handler.client.setMetaData(metaData);
handler.client.writeExternal(out);
final EJBMetaDataImpl ejb = handler.ejb;
out.writeObject(ejb.homeClass);
out.writeObject(ejb.remoteClass);
out.writeObject(ejb.keyClass);
out.writeByte(ejb.type);
out.writeUTF(ejb.deploymentID);
out.writeShort(ejb.deploymentCode);
handler.server.setMetaData(metaData);
handler.server.writeExternal(out);
/// out.writeObject( handler.primaryKey );
}
private void writeFrenchRev(ObjectOutput out)
throws IOException {
FrenchRepublicanCalendar cal = (FrenchRepublicanCalendar) this.obj;
out.writeInt(cal.getYear());
out.writeShort(cal.getDayOfYear());
}
public void send(byte code, ObjectOutput out) throws IOException {
JClientRequestInfo info = new JRMPClientRequestInfoImpl();
for (int i = 0; i < cis.length; i++) {
cis[i].send_request(info);
}
Collection c = info.get_all_request_service_context();
out.writeShort(c.size());
for (Iterator it = c.iterator(); it.hasNext(); ) {
out.writeObject(it.next());
}
}
public void writeExternal(ObjectOutput out) throws IOException {
out.writeBoolean(z);
out.writeByte(b);
out.writeChar(c);
out.writeShort(s);
out.writeInt(i);
out.writeFloat(f);
out.writeLong(j);
out.writeDouble(d);
out.writeObject(str);
out.writeObject(parent);
out.writeObject(left);
out.writeObject(right);
}
/**
* Write an XML value.
* @param out The stream to which we're writing.
*/
public void writeExternal(ObjectOutput out) throws IOException
{
// never called when value is null
if (SanityManager.DEBUG)
SanityManager.ASSERT(!isNull());
// Write out the XML store impl id.
out.writeShort(UTF8_IMPL_ID);
// Now write out the data.
xmlStringValue.writeExternal(out);
}
@Override
public void writeExternal(ObjectOutput out) throws IOException {
out.writeShort(fixedLen);
}
@Override
protected void serializedNonNullValue(T o, ObjectOutput out) throws IOException
{
out.writeShort(this.shortValueOf(o));
}
@Override
public void writeExternal(ObjectOutput out) throws IOException {
out.writeShort(fixedLen);
}
@Override
public void serializeNonNullAggregateDataValue(Nullable valueWrappedInNullable, ObjectOutput out) throws IOException
{
out.writeShort(((MutableNumber)valueWrappedInNullable).shortValue());
}
@Override
public void writeExternal(ObjectOutput objectOutput) throws IOException {
objectOutput.writeShort(fEvalFlags);
objectOutput.writeObject(vector);
}
@Override
public void writeExternal(final ObjectOutput out) throws IOException {
out.writeInt(currentVersion);
out.writeLong(addrMetadata);
out.writeLong(addrRoot);
out.writeLong(addrBloomFilter);
out.writeInt(height);
if (currentVersion <= VERSION1) {
if (nnodes > Integer.MAX_VALUE)
throw new RuntimeException();
if (nleaves > Integer.MAX_VALUE)
throw new RuntimeException();
if (nentries > Integer.MAX_VALUE)
throw new RuntimeException();
out.writeInt((int)nnodes);
out.writeInt((int)nleaves);
out.writeInt((int)nentries);
} else {
out.writeLong(nnodes);
out.writeLong(nleaves);
out.writeLong(nentries);
out.writeLong(recordVersion);
}
out.writeLong(counter);
/*
* 8 bytes follow.
*/
out.writeShort(indexType.getCode());
out.writeShort(0/* unused */);
out.writeInt(0/* unused */);
/*
* 8 bytes follow.
*/
out.writeLong(0L/* unused */);
/*
* Additional space added in VERSION2.
*/
for (int i = 0; i < 10; i++) {
out.writeLong(0L/* unused */);
}
}