下面列出了java.io.ObjectInputStream#readShort ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
/**
* Run benchmark for given number of batches, with given number of cycles
* for each batch.
*/
void doReps(ObjectOutputStream oout, ObjectInputStream oin,
StreamBuffer sbuf, int nbatches, int ncycles)
throws Exception
{
for (int i = 0; i < nbatches; i++) {
sbuf.reset();
for (int j = 0; j < ncycles; j++) {
oout.writeShort(0);
}
oout.flush();
for (int j = 0; j < ncycles; j++) {
oin.readShort();
}
}
}
private void readObject(ObjectInputStream in)
throws IOException, ClassNotFoundException
{
z = in.readBoolean();
b = in.readByte();
c = in.readChar();
s = in.readShort();
i = in.readInt();
f = in.readFloat();
j = in.readLong();
d = in.readDouble();
str = (String) in.readObject();
parent = in.readObject();
left = in.readObject();
right = in.readObject();
}
/**
* Run benchmark for given number of batches, with given number of cycles
* for each batch.
*/
void doReps(ObjectOutputStream oout, ObjectInputStream oin,
StreamBuffer sbuf, int nbatches, int ncycles)
throws Exception
{
for (int i = 0; i < nbatches; i++) {
sbuf.reset();
for (int j = 0; j < ncycles; j++) {
oout.writeShort(0);
}
oout.flush();
for (int j = 0; j < ncycles; j++) {
oin.readShort();
}
}
}
/**
* Run benchmark for given number of batches, with given number of cycles
* for each batch.
*/
void doReps(ObjectOutputStream oout, ObjectInputStream oin,
StreamBuffer sbuf, int nbatches, int ncycles)
throws Exception
{
for (int i = 0; i < nbatches; i++) {
sbuf.reset();
for (int j = 0; j < ncycles; j++) {
oout.writeShort(0);
}
oout.flush();
for (int j = 0; j < ncycles; j++) {
oin.readShort();
}
}
}
private void readObject(ObjectInputStream in)
throws IOException, ClassNotFoundException
{
z = in.readBoolean();
b = in.readByte();
c = in.readChar();
s = in.readShort();
i = in.readInt();
f = in.readFloat();
j = in.readLong();
d = in.readDouble();
str = (String) in.readObject();
parent = in.readObject();
left = in.readObject();
right = in.readObject();
}
private void readObject(ObjectInputStream in)
throws IOException, ClassNotFoundException
{
z = in.readBoolean();
b = in.readByte();
c = in.readChar();
s = in.readShort();
i = in.readInt();
f = in.readFloat();
j = in.readLong();
d = in.readDouble();
str = (String) in.readObject();
parent = in.readObject();
left = in.readObject();
right = in.readObject();
}
private void readObject(ObjectInputStream in)
throws IOException, ClassNotFoundException
{
z = in.readBoolean();
b = in.readByte();
c = in.readChar();
s = in.readShort();
i = in.readInt();
f = in.readFloat();
j = in.readLong();
d = in.readDouble();
str = (String) in.readObject();
parent = in.readObject();
left = in.readObject();
right = in.readObject();
}
/**
* Run benchmark for given number of batches, with given number of cycles
* for each batch.
*/
void doReps(ObjectOutputStream oout, ObjectInputStream oin,
StreamBuffer sbuf, int nbatches, int ncycles)
throws Exception
{
for (int i = 0; i < nbatches; i++) {
sbuf.reset();
for (int j = 0; j < ncycles; j++) {
oout.writeShort(0);
}
oout.flush();
for (int j = 0; j < ncycles; j++) {
oin.readShort();
}
}
}
/**
* Run benchmark for given number of batches, with given number of cycles
* for each batch.
*/
void doReps(ObjectOutputStream oout, ObjectInputStream oin,
StreamBuffer sbuf, int nbatches, int ncycles)
throws Exception
{
for (int i = 0; i < nbatches; i++) {
sbuf.reset();
for (int j = 0; j < ncycles; j++) {
oout.writeShort(0);
}
oout.flush();
for (int j = 0; j < ncycles; j++) {
oin.readShort();
}
}
}
/**
* Run benchmark for given number of batches, with given number of cycles
* for each batch.
*/
void doReps(ObjectOutputStream oout, ObjectInputStream oin,
StreamBuffer sbuf, int nbatches, int ncycles)
throws Exception
{
for (int i = 0; i < nbatches; i++) {
sbuf.reset();
for (int j = 0; j < ncycles; j++) {
oout.writeShort(0);
}
oout.flush();
for (int j = 0; j < ncycles; j++) {
oin.readShort();
}
}
}
private void readObject(ObjectInputStream in)
throws IOException, ClassNotFoundException
{
z = in.readBoolean();
b = in.readByte();
c = in.readChar();
s = in.readShort();
i = in.readInt();
f = in.readFloat();
j = in.readLong();
d = in.readDouble();
str = (String) in.readObject();
parent = in.readObject();
left = in.readObject();
right = in.readObject();
}
/**
* Run benchmark for given number of batches, with given number of cycles
* for each batch.
*/
void doReps(ObjectOutputStream oout, ObjectInputStream oin,
StreamBuffer sbuf, int nbatches, int ncycles)
throws Exception
{
for (int i = 0; i < nbatches; i++) {
sbuf.reset();
for (int j = 0; j < ncycles; j++) {
oout.writeShort(0);
}
oout.flush();
for (int j = 0; j < ncycles; j++) {
oin.readShort();
}
}
}
private void readObject(ObjectInputStream in)
throws IOException, ClassNotFoundException
{
z = in.readBoolean();
b = in.readByte();
c = in.readChar();
s = in.readShort();
i = in.readInt();
f = in.readFloat();
j = in.readLong();
d = in.readDouble();
str = (String) in.readObject();
parent = in.readObject();
left = in.readObject();
right = in.readObject();
}
private void readObject(ObjectInputStream in)
throws IOException, ClassNotFoundException
{
z = in.readBoolean();
b = in.readByte();
c = in.readChar();
s = in.readShort();
i = in.readInt();
f = in.readFloat();
j = in.readLong();
d = in.readDouble();
str = (String) in.readObject();
parent = in.readObject();
left = in.readObject();
right = in.readObject();
}
private void readObject(final ObjectInputStream aInputStream)
throws ClassNotFoundException, IOException {
final byte[] adapterBytes = new byte[aInputStream.readUnsignedShort()];
aInputStream.readFully(adapterBytes);
final byte[] indexBytes = new byte[aInputStream.readUnsignedShort()];
aInputStream.readFully(indexBytes);
newAdapter = (RasterDataAdapter) PersistenceUtils.fromBinary(adapterBytes);
index = (Index) PersistenceUtils.fromBinary(indexBytes);
oldAdapterId = aInputStream.readShort();
newAdapterId = aInputStream.readShort();
indexNames = new String[] {index.getName()};
}
/**
* Reads an array of parameter types from the stream.
*/
private static Class<?>[] readParameters(ObjectInputStream in)
throws IOException, ClassNotFoundException
{
Class<?>[] result = new Class[in.readShort()];
for (int i=0; i < result.length; i++) {
if (!in.readBoolean()) {
result[i] = (Class<?>) in.readObject();
continue;
}
result[i] = primitives[in.readByte()];
}
return result;
}
@Override
public final void read(ObjectInputStream is, int count) throws IOException {
for (int i=0; i<count; ++i) {
final long value = is.readLong();
this.values.put(i, value);
if (value != defaultValueAsLong) {
final short zoneId = is.readShort();
this.zoneIds.put(i, zoneId);
}
}
}
private void readObject(final ObjectInputStream aInputStream)
throws ClassNotFoundException, IOException {
final byte[] adapterBytes = new byte[aInputStream.readShort()];
aInputStream.readFully(adapterBytes);
final byte[] indexBytes = new byte[aInputStream.readShort()];
aInputStream.readFully(indexBytes);
newAdapter = (RasterDataAdapter) PersistenceUtils.fromBinary(adapterBytes);
index = (Index) PersistenceUtils.fromBinary(indexBytes);
writableSerializer = newAdapter.createWritableSerializer();
}
@Override
public final void read(ObjectInputStream is, int count) throws IOException {
for (int i=0; i<count; ++i) {
final long value = is.readLong();
this.values[i] = value;
if (value != defaultValueAsLong) {
this.zoneIds[i] = is.readShort();
}
}
}
public NodeInstance readNodeInstance(MarshallerReaderContext context,
NodeInstanceContainer nodeInstanceContainer,
WorkflowProcessInstance processInstance) throws IOException {
ObjectInputStream stream = context.stream;
String id = stream.readUTF();
long nodeId = stream.readLong();
int nodeType = stream.readShort();
NodeInstanceImpl nodeInstance = readNodeInstanceContent(nodeType,
stream, context, processInstance);
nodeInstance.setNodeId(nodeId);
nodeInstance.setNodeInstanceContainer(nodeInstanceContainer);
nodeInstance.setProcessInstance((org.jbpm.workflow.instance.WorkflowProcessInstance) processInstance);
nodeInstance.setId(id);
switch (nodeType) {
case PersisterEnums.COMPOSITE_NODE_INSTANCE:
case PersisterEnums.DYNAMIC_NODE_INSTANCE:
int nbVariables = stream.readInt();
if (nbVariables > 0) {
Context variableScope = ((org.jbpm.process.core.Process) ((org.jbpm.process.instance.ProcessInstance)
processInstance).getProcess()).getDefaultContext(VariableScope.VARIABLE_SCOPE);
VariableScopeInstance variableScopeInstance = (VariableScopeInstance) ((CompositeContextNodeInstance) nodeInstance).getContextInstance(variableScope);
for (int i = 0; i < nbVariables; i++) {
String name = stream.readUTF();
try {
Object value = stream.readObject();
variableScopeInstance.internalSetVariable(name, value);
} catch (ClassNotFoundException e) {
throw new IllegalArgumentException("Could not reload variable " + name);
}
}
}
while (stream.readShort() == PersisterEnums.NODE_INSTANCE) {
readNodeInstance(context,
(CompositeContextNodeInstance) nodeInstance,
processInstance);
}
int exclusiveGroupInstances = stream.readInt();
for (int i = 0; i < exclusiveGroupInstances; i++) {
ExclusiveGroupInstance exclusiveGroupInstance = new ExclusiveGroupInstance();
((org.jbpm.process.instance.ProcessInstance) processInstance).addContextInstance(ExclusiveGroup.EXCLUSIVE_GROUP, exclusiveGroupInstance);
int nodeInstances = stream.readInt();
for (int j = 0; j < nodeInstances; j++) {
String nodeInstanceId = stream.readUTF();
NodeInstance groupNodeInstance = processInstance.getNodeInstance(nodeInstanceId);
if (groupNodeInstance == null) {
throw new IllegalArgumentException("Could not find node instance when deserializing exclusive group instance: " + nodeInstanceId);
}
exclusiveGroupInstance.addNodeInstance(groupNodeInstance);
}
}
break;
case PersisterEnums.FOR_EACH_NODE_INSTANCE:
while (stream.readShort() == PersisterEnums.NODE_INSTANCE) {
readNodeInstance(context,
(ForEachNodeInstance) nodeInstance,
processInstance);
}
break;
default:
// do nothing
}
return nodeInstance;
}