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

The following are Jave code examples for showing how to use writeBoolean() of the java.io.ObjectOutputStream class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: jdk8u-jdk   File: Booleans.java   View Source Code Vote up 6 votes
/**
 * 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 2
Project: lams   File: EntityEntry.java   View Source Code Vote up 6 votes
/**
 * 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 java.io.IOException If a stream error occurs
 */
public void serialize(ObjectOutputStream oos) throws IOException {
	Status previousStatus = getPreviousStatus();
	oos.writeObject( getEntityName() );
	oos.writeObject( id );
	oos.writeObject( getStatus().name() );
	oos.writeObject( (previousStatus == null ? "" : previousStatus.name()) );
	// todo : potentially look at optimizing these two arrays
	oos.writeObject( loadedState );
	oos.writeObject( getDeletedState() );
	oos.writeObject( version );
	oos.writeObject( getLockMode().toString() );
	oos.writeBoolean( isExistsInDatabase() );
	oos.writeBoolean( isBeingReplicated() );
	oos.writeBoolean( isLoadedWithLazyPropertiesUnfetched() );
}
 
Example 3
Project: openjdk-jdk10   File: Booleans.java   View Source Code Vote up 6 votes
/**
 * 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 4
Project: parabuild-ci   File: CategoryAxis.java   View Source Code Vote up 6 votes
/**
 * 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 5
Project: TPlayer   File: SerializableCookie.java   View Source Code Vote up 5 votes
private void writeObject(ObjectOutputStream out) throws IOException {
    out.defaultWriteObject();
    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 6
Project: GitHub   File: SerializableCookie.java   View Source Code Vote up 5 votes
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 7
Project: lazycat   File: SingleSignOnEntry.java   View Source Code Vote up 5 votes
private void writeObject(ObjectOutputStream out) throws IOException {
	out.defaultWriteObject();
	if (principal instanceof Serializable) {
		out.writeBoolean(true);
		out.writeObject(principal);
	} else {
		out.writeBoolean(false);
	}
}
 
Example 8
Project: XDroid-Databinding   File: SerializableHttpCookie.java   View Source Code Vote up 5 votes
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 9
Project: weak-semi-crf-naacl2016   File: GlobalNetworkParam.java   View Source Code Vote up 5 votes
private void writeObject(ObjectOutputStream out) throws IOException{
	out.writeObject(this._featureIntMap);
	out.writeObject(this._feature2rep);
	out.writeObject(this._weights);
	out.writeInt(this._size);
	out.writeInt(this._fixedFeaturesSize);
	out.writeBoolean(this._locked);
}
 
Example 10
Project: android-project-gallery   File: SerializableCookie.java   View Source Code Vote up 5 votes
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 11
Project: basicapp   File: SerializableCookie.java   View Source Code Vote up 5 votes
private void writeObject(ObjectOutputStream out) throws IOException {
    out.writeObject(cookie.name());
    out.writeObject(cookie.value());
    out.writeLong(cookie.persistent() ? cookie.expiresAt() : NON_VALID_EXPIRES_AT);
    out.writeObject(cookie.domain());
    out.writeObject(cookie.path());
    out.writeBoolean(cookie.secure());
    out.writeBoolean(cookie.httpOnly());
    out.writeBoolean(cookie.hostOnly());
}
 
Example 12
Project: incubator-netbeans   File: InitiateProfilingCommand.java   View Source Code Vote up 5 votes
void writeObject(ObjectOutputStream out) throws IOException {
    out.writeInt(instrType);
    out.writeInt(classNames.length);

    for (int i = 0; i < classNames.length; i++) {
        out.writeUTF(classNames[i]);
    }

    out.writeBoolean(instrSpawnedThreads);
    out.writeBoolean(startProfilingPointsActive);
    out.writeObject(profilingPointIDs);
    out.writeObject(profilingPointHandlers);
    out.writeObject(profilingPointInfos);
}
 
Example 13
Project: whackpad   File: UintMap.java   View Source Code Vote up 5 votes
private void writeObject(ObjectOutputStream out)
    throws IOException
{
    out.defaultWriteObject();

    int count = keyCount;
    if (count != 0) {
        boolean hasIntValues = (ivaluesShift != 0);
        boolean hasObjectValues = (values != null);
        out.writeBoolean(hasIntValues);
        out.writeBoolean(hasObjectValues);

        for (int i = 0; count != 0; ++i) {
            int key = keys[i];
            if (key != EMPTY && key != DELETED) {
                --count;
                out.writeInt(key);
                if (hasIntValues) {
                    out.writeInt(keys[ivaluesShift + i]);
                }
                if (hasObjectValues) {
                    out.writeObject(values[i]);
                }
            }
        }
    }
}
 
Example 14
Project: AndroidAsyncHTTP   File: SerializableCookie.java   View Source Code Vote up 5 votes
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 15
Project: XinFramework   File: EntityCookie.java   View Source Code Vote up 5 votes
private void writeObject(ObjectOutputStream out) throws IOException {
    out.defaultWriteObject();
    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
Project: stynico   File: SerializableHttpCookie.java   View Source Code Vote up 5 votes
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 17
Project: openjdk-jdk10   File: TemplatesImpl.java   View Source Code Vote up 5 votes
/**
 *  This is to fix bugzilla bug 22438
 *  If the user defined class implements URIResolver and Serializable
 *  then we want it to get serialized
 */
private void writeObject(ObjectOutputStream os)
    throws IOException, ClassNotFoundException {
    if (_auxClasses != null) {
        //throw with the same message as when Hashtable was used for compatibility.
        throw new NotSerializableException(
                "com.sun.org.apache.xalan.internal.xsltc.runtime.Hashtable");
    }

    // Write serialized fields
    ObjectOutputStream.PutField pf = os.putFields();
    pf.put("_name", _name);
    pf.put("_bytecodes", _bytecodes);
    pf.put("_class", _class);
    pf.put("_transletIndex", _transletIndex);
    pf.put("_outputProperties", _outputProperties);
    pf.put("_indentNumber", _indentNumber);
    os.writeFields();

    if (_uriResolver instanceof Serializable) {
        os.writeBoolean(true);
        os.writeObject((Serializable) _uriResolver);
    }
    else {
        os.writeBoolean(false);
    }
}
 
Example 18
Project: weak-semi-crf-naacl2016   File: FeatureManager.java   View Source Code Vote up 4 votes
private void writeObject(ObjectOutputStream oos) throws IOException{
	oos.writeObject(this._param_g);
	oos.writeBoolean(this._cacheEnabled);
	oos.writeInt(this._numThreads);
}
 
Example 19
Project: keepass2android   File: AbstractReferenceMap.java   View Source Code Vote up 3 votes
/**
 * Replaces the superclass method to store the state of this class.
 * <p>
 * Serialization is not one of the JDK's nicest topics. Normal serialization will
 * initialise the superclass before the subclass. Sometimes however, this isn't
 * what you want, as in this case the <code>put()</code> method on read can be
 * affected by subclass state.
 * <p>
 * The solution adopted here is to serialize the state data of this class in
 * this protected method. This method must be called by the
 * <code>writeObject()</code> of the first serializable subclass.
 * <p>
 * Subclasses may override if they have a specific field that must be present
 * on read before this implementation will work. Generally, the read determines
 * what must be serialized here, if anything.
 * 
 * @param out  the output stream
 */
protected void doWriteObject(ObjectOutputStream out) throws IOException {
    out.writeInt(keyType);
    out.writeInt(valueType);
    out.writeBoolean(purgeValues);
    out.writeFloat(loadFactor);
    out.writeInt(data.length);
    for (MapIterator it = mapIterator(); it.hasNext();) {
        out.writeObject(it.next());
        out.writeObject(it.getValue());
    }
    out.writeObject(null);  // null terminate map
    // do not call super.doWriteObject() as code there doesn't work for reference map
}
 
Example 20
Project: HCFCore   File: AbstractReferenceMap.java   View Source Code Vote up 3 votes
/**
 * Replaces the superclass method to store the state of this class.
 * <p>
 * Serialization is not one of the JDK's nicest topics. Normal serialization will
 * initialise the superclass before the subclass. Sometimes however, this isn't
 * what you want, as in this case the <code>put()</code> method on read can be
 * affected by subclass state.
 * <p>
 * The solution adopted here is to serialize the state data of this class in
 * this protected method. This method must be called by the
 * <code>writeObject()</code> of the first serializable subclass.
 * <p>
 * Subclasses may override if they have a specific field that must be present
 * on read before this implementation will work. Generally, the read determines
 * what must be serialized here, if anything.
 *
 * @param out  the output stream
 * @throws IOException if an error occurs while writing to the stream
 */
@Override
protected void doWriteObject(final ObjectOutputStream out) throws IOException {
    out.writeInt(keyType.value);
    out.writeInt(valueType.value);
    out.writeBoolean(purgeValues);
    out.writeFloat(loadFactor);
    out.writeInt(data.length);
    for (final MapIterator<K, V> it = mapIterator(); it.hasNext();) {
        out.writeObject(it.next());
        out.writeObject(it.getValue());
    }
    out.writeObject(null);  // null terminate map
    // do not call super.doWriteObject() as code there doesn't work for reference map
}