Java Code Examples for java.io.ObjectOutputStream#writeBoolean()

The following examples show how to use java.io.ObjectOutputStream#writeBoolean() . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
/**
 * Writes a map of (<code>Comparable</code>, <code>Paint</code>)
 * elements to a stream.
 *
 * @param map  the map (<code>null</code> permitted).
 *
 * @param out
 * @throws IOException
 *
 * @see #readPaintMap(ObjectInputStream)
 */
private void writePaintMap(Map map, ObjectOutputStream out)
        throws IOException {
    if (map == null) {
        out.writeBoolean(true);
    }
    else {
        out.writeBoolean(false);
        Set keys = map.keySet();
        int count = keys.size();
        out.writeInt(count);
        Iterator iterator = keys.iterator();
        while (iterator.hasNext()) {
            Comparable key = (Comparable) iterator.next();
            out.writeObject(key);
            SerialUtilities.writePaint((Paint) map.get(key), out);
        }
    }
}
 
Example 2
/**
 * Writes a Constructor or Method object.
 *
 * Methods and Constructors are not serializable, so we must serialize
 * information about the class, the name, and the parameters and
 * recreate upon deserialization.
 */
private static void writeMember(ObjectOutputStream out, Member member)
    throws IOException
{
    if (member == null) {
        out.writeBoolean(false);
        return;
    }
    out.writeBoolean(true);
    if (!(member instanceof Method || member instanceof Constructor))
        throw new IllegalArgumentException("not Method or Constructor");
    out.writeBoolean(member instanceof Method);
    out.writeObject(member.getName());
    out.writeObject(member.getDeclaringClass());
    if (member instanceof Method) {
        writeParameters(out, ((Method) member).getParameterTypes());
    } else {
        writeParameters(out, ((Constructor<?>) member).getParameterTypes());
    }
}
 
Example 3
/**
 * Writes a map of (<code>Comparable</code>, <code>Paint</code>)
 * elements to a stream.
 *
 * @param map  the map (<code>null</code> permitted).
 *
 * @param out
 * @throws IOException
 *
 * @see #readPaintMap(ObjectInputStream)
 */
private void writePaintMap(Map map, ObjectOutputStream out)
        throws IOException {
    if (map == null) {
        out.writeBoolean(true);
    }
    else {
        out.writeBoolean(false);
        Set keys = map.keySet();
        int count = keys.size();
        out.writeInt(count);
        Iterator iterator = keys.iterator();
        while (iterator.hasNext()) {
            Comparable key = (Comparable) iterator.next();
            out.writeObject(key);
            SerialUtilities.writePaint((Paint) map.get(key), out);
        }
    }
}
 
Example 4
@Override
public void save(ObjectOutputStream oos) throws IOException {
  oos.writeUTF(userId);
  oos.writeUTF(name);
  oos.writeUTF(dn);
  oos.writeBoolean(isInitialized);
  oos.writeBoolean(isInitializedHIA);
  oos.writeObject(a005Certificate);
  oos.writeObject(e002Certificate);
  oos.writeObject(x002Certificate);
  oos.writeObject(a005PrivateKey);
  oos.writeObject(e002PrivateKey);
  oos.writeObject(x002PrivateKey);
  oos.flush();
  oos.close();
  needSave = false;
}
 
Example 5
/**
 * 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.writeBoolean(false);
        }
        oout.flush();
        for (int j = 0; j < ncycles; j++) {
            oin.readBoolean();
        }
    }
}
 
Example 6
private void writeObject(ObjectOutputStream 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);
}
 
Example 7
private void writeObject(ObjectOutputStream out) throws IOException
{
	log.debug("Serializing PortletState [action={}]", action);

	out.writeObject(id);
	out.writeBoolean(action);
	out.writeBoolean(secure);
	out.writeObject(parameters);
	out.writeObject(portletMode.toString());
	out.writeObject(windowState.toString());
}
 
Example 8
Source Project: tomcatsrc   File: SingleSignOnEntry.java    License: Apache License 2.0 5 votes vote down vote up
private void writeObject(ObjectOutputStream out) throws IOException {
    out.defaultWriteObject();
    if (principal instanceof Serializable) {
        out.writeBoolean(true);
        out.writeObject(principal);
    } else {
        out.writeBoolean(false);
    }
}
 
Example 9
/** 将cookie写到对象流中 */
private void writeObject(ObjectOutputStream out) throws IOException {
    out.writeObject(this.cookie.name());
    out.writeObject(this.cookie.value());
    out.writeLong(this.cookie.expiresAt());
    out.writeObject(this.cookie.domain());
    out.writeObject(this.cookie.path());
    out.writeBoolean(this.cookie.secure());
    out.writeBoolean(this.cookie.httpOnly());
    out.writeBoolean(this.cookie.hostOnly());
    out.writeBoolean(this.cookie.persistent());
}
 
Example 10
/**
 * Custom serialization routine used during serialization of a
 * Session/PersistenceContext for increased performance.
 *
 * @param oos The stream to which we should write the serial data.
 * @throws IOException
 */
void serialize(ObjectOutputStream oos) throws IOException {
	oos.writeObject( identifier );
	oos.writeObject( rootEntityName );
	oos.writeObject( entityName );
	oos.writeObject( identifierType );
	oos.writeBoolean( isBatchLoadable );
	oos.writeObject( entityMode.toString() );
}
 
Example 11
void writeObject(ObjectOutputStream out) throws IOException {
    out.writeBoolean(lockContentionMonitoringEnabled);
    out.writeInt(nProfiledThreadsLimit);
    out.writeInt(stackDepthLimit);
    out.writeInt(samplingInterval);
    out.writeInt(objAllocStackSamplingInterval);
    out.writeInt(objAllocStackSamplingDepth);
    out.writeBoolean(runGCOnGetResultsInMemoryProfiling);
    out.writeBoolean(waitTrackingEnabled);
    out.writeBoolean(sleepTrackingEnabled);
    out.writeBoolean(threadsSamplingEnabled);
    out.writeInt(threadsSamplingFrequency);
}
 
Example 12
private void writeObject(ObjectOutputStream out) throws IOException {
    out.writeObject(cookie.getName());
    out.writeObject(cookie.getValue());
    out.writeObject(cookie.getComment());
    out.writeObject(cookie.getDomain());
    out.writeObject(cookie.getExpiryDate());
    out.writeObject(cookie.getPath());
    out.writeInt(cookie.getVersion());
    out.writeBoolean(cookie.isSecure());
}
 
Example 13
Source Project: flink   File: StateDescriptor.java    License: Apache License 2.0 5 votes vote down vote up
private void writeObject(final ObjectOutputStream out) throws IOException {
	// write all the non-transient fields
	out.defaultWriteObject();

	// write the non-serializable default value field
	if (defaultValue == null) {
		// we don't have a default value
		out.writeBoolean(false);
	} else {
		TypeSerializer<T> serializer = serializerAtomicReference.get();
		checkNotNull(serializer, "Serializer not initialized.");

		// we have a default value
		out.writeBoolean(true);

		byte[] serializedDefaultValue;
		try (ByteArrayOutputStream baos = new ByteArrayOutputStream();
				DataOutputViewStreamWrapper outView = new DataOutputViewStreamWrapper(baos)) {

			TypeSerializer<T> duplicateSerializer = serializer.duplicate();
			duplicateSerializer.serialize(defaultValue, outView);

			outView.flush();
			serializedDefaultValue = baos.toByteArray();
		}
		catch (Exception e) {
			throw new IOException("Unable to serialize default value of type " +
					defaultValue.getClass().getSimpleName() + ".", e);
		}

		out.writeInt(serializedDefaultValue.length);
		out.write(serializedDefaultValue);
	}
}
 
Example 14
private void writeObject(ObjectOutputStream stream) throws IOException {

        stream.writeObject(logDir.toAbsolutePath().toString());
        stream.writeObject(outputDir.toAbsolutePath().toString());
        stream.writeObject(validationDir.toAbsolutePath().toString());

        stream.writeBoolean(outputRequired);
        stream.writeBoolean(validationRequired);
    }
 
Example 15
Source Project: stynico   File: SerializableHttpCookie.java    License: MIT License 5 votes vote down vote up
private void writeObject(ObjectOutputStream out) throws IOException {
    out.writeObject(cookie.name());
    out.writeObject(cookie.value());
    out.writeLong(cookie.expiresAt());
    out.writeObject(cookie.domain());
    out.writeObject(cookie.path());
    out.writeBoolean(cookie.secure());
    out.writeBoolean(cookie.httpOnly());
    out.writeBoolean(cookie.hostOnly());
    out.writeBoolean(cookie.persistent());
}
 
Example 16
public void saveState(ObjectOutputStream objectOutputStream)
		throws IOException {

	// Store filter, serializable
	objectOutputStream.writeObject(currentFilter);

	// Store data source instance settings using settings framework
	SettingsHelper.storeSettings(objectOutputStream, this.dataSource);

	objectOutputStream.writeBoolean(isChecked());
}
 
Example 17
Source Project: flink   File: StateDescriptor.java    License: Apache License 2.0 5 votes vote down vote up
private void writeObject(final ObjectOutputStream out) throws IOException {
	// write all the non-transient fields
	out.defaultWriteObject();

	// write the non-serializable default value field
	if (defaultValue == null) {
		// we don't have a default value
		out.writeBoolean(false);
	} else {
		TypeSerializer<T> serializer = serializerAtomicReference.get();
		checkNotNull(serializer, "Serializer not initialized.");

		// we have a default value
		out.writeBoolean(true);

		byte[] serializedDefaultValue;
		try (ByteArrayOutputStream baos = new ByteArrayOutputStream();
				DataOutputViewStreamWrapper outView = new DataOutputViewStreamWrapper(baos)) {

			TypeSerializer<T> duplicateSerializer = serializer.duplicate();
			duplicateSerializer.serialize(defaultValue, outView);

			outView.flush();
			serializedDefaultValue = baos.toByteArray();
		}
		catch (Exception e) {
			throw new IOException("Unable to serialize default value of type " +
					defaultValue.getClass().getSimpleName() + ".", e);
		}

		out.writeInt(serializedDefaultValue.length);
		out.write(serializedDefaultValue);
	}
}
 
Example 18
private void writeObject(ObjectOutputStream out) throws IOException
{
    out.writeObject(cookie.name());
    out.writeObject(cookie.value());
    out.writeLong(cookie.expiresAt());
    out.writeObject(cookie.domain());
    out.writeObject(cookie.path());
    out.writeBoolean(cookie.secure());
    out.writeBoolean(cookie.httpOnly());
    out.writeBoolean(cookie.hostOnly());
    out.writeBoolean(cookie.persistent());
}
 
Example 19
private void writeObject(ObjectOutputStream stream) throws IOException {		
stream.writeInt(mAllAtoms);
stream.writeInt(mAllBonds);
stream.writeBoolean(mIsFragment);
for (int atom=0; atom<mAllAtoms; atom++) {
	stream.writeInt(mAtomicNo[atom]);
	stream.writeInt(mAtomCharge[atom]);
	stream.writeInt(mAtomMass[atom]);
	stream.writeInt(mAtomFlags[atom] & ~cAtomFlagsHelper);
	stream.writeInt(mAtomQueryFeatures[atom]);
	stream.writeDouble(mCoordinates[atom].x);	// for compatibility with earlier double based coords
	stream.writeDouble(mCoordinates[atom].y);
	stream.writeDouble(mCoordinates[atom].z);
	stream.writeInt(mAtomMapNo[atom]);

	if (mAtomList != null && mAtomList[atom] != null) {
		stream.writeInt(mAtomList[atom].length);
		for (int i=0; i<mAtomList[atom].length; i++)
			stream.writeInt(mAtomList[atom][i]);
		}
	else
		stream.writeInt(0);

	if (mAtomCustomLabel != null && mAtomCustomLabel[atom] != null) {
		stream.writeInt(mAtomCustomLabel[atom].length);
		for (int i=0; i<mAtomCustomLabel[atom].length; i++)
			stream.writeByte(mAtomCustomLabel[atom][i]);
		}
	else
		stream.writeInt(0);
	}
for (int bond=0; bond<mAllBonds;bond++) {
	stream.writeInt(mBondAtom[0][bond]);
	stream.writeInt(mBondAtom[1][bond]);
	stream.writeInt(mBondType[bond]);
	stream.writeInt(mBondFlags[bond]);
	stream.writeInt(mBondQueryFeatures[bond]);
	}

stream.writeObject(mName);
}
 
Example 20
private void writeObject(ObjectOutputStream oos) throws IOException {
    LOG.trace("Serializing reference to {}", this);
    oos.writeUTF(entityType.getInterfaceName());
    oos.writeBoolean(loaded);
    oos.writeObject(reference);
}