Java Code Examples for java.io.ObjectOutputStream#PutField

The following examples show how to use java.io.ObjectOutputStream#PutField . 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
/**
 * Serializes a {@link RoleInfo} to an {@link ObjectOutputStream}.
 */
private void writeObject(ObjectOutputStream out)
        throws IOException {
  if (compat)
  {
    // Serializes this instance in the old serial form
    //
    ObjectOutputStream.PutField fields = out.putFields();
    fields.put("myName", name);
    fields.put("myIsReadableFlg", isReadable);
    fields.put("myIsWritableFlg", isWritable);
    fields.put("myDescription", description);
    fields.put("myMinDegree", minDegree);
    fields.put("myMaxDegree", maxDegree);
    fields.put("myRefMBeanClassName", referencedMBeanClassName);
    out.writeFields();
  }
  else
  {
    // Serializes this instance in the new serial form
    //
    out.defaultWriteObject();
  }
}
 
Example 2
/**
 * Serializes an {@link MBeanServerNotificationFilter} to an {@link ObjectOutputStream}.
 */
private void writeObject(ObjectOutputStream out)
        throws IOException {
  if (compat)
  {
    // Serializes this instance in the old serial form
    //
    ObjectOutputStream.PutField fields = out.putFields();
    fields.put("mySelectObjNameList", selectedNames);
    fields.put("myDeselectObjNameList", deselectedNames);
    out.writeFields();
  }
  else
  {
    // Serializes this instance in the new serial form
    //
    out.defaultWriteObject();
  }
}
 
Example 3
/**
 * Serializes a {@link ModelMBeanAttributeInfo} to an {@link ObjectOutputStream}.
 */
private void writeObject(ObjectOutputStream out)
        throws IOException {
  if (compat)
  {
    // Serializes this instance in the old serial form
    //
    ObjectOutputStream.PutField fields = out.putFields();
    fields.put("attrDescriptor", attrDescriptor);
    fields.put("currClass", currClass);
    out.writeFields();
  }
  else
  {
    // Serializes this instance in the new serial form
    //
    out.defaultWriteObject();
  }
}
 
Example 4
/**
 * @serialData "permissions" field (a Vector containing the ServicePermissions).
 */
/*
 * Writes the contents of the perms field out as a Vector for
 * serialization compatibility with earlier releases.
 */
private void writeObject(ObjectOutputStream out) throws IOException {
    // Don't call out.defaultWriteObject()

    // Write out Vector
    Vector<Permission> permissions = new Vector<>(perms.size());

    synchronized (this) {
        permissions.addAll(perms);
    }

    ObjectOutputStream.PutField pfields = out.putFields();
    pfields.put("permissions", permissions);
    out.writeFields();
}
 
Example 5
Source Project: Java8CN   File: Inet6Address.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * default behavior is overridden in order to write the
 * scope_ifname field as a String, rather than a NetworkInterface
 * which is not serializable
 */
private synchronized void writeObject(ObjectOutputStream s)
    throws IOException
{
        String ifname = null;

    if (holder6.scope_ifname != null) {
        ifname = holder6.scope_ifname.getName();
        holder6.scope_ifname_set = true;
    }
    ObjectOutputStream.PutField pfields = s.putFields();
    pfields.put("ipaddress", holder6.ipaddress);
    pfields.put("scope_id", holder6.scope_id);
    pfields.put("scope_id_set", holder6.scope_id_set);
    pfields.put("scope_ifname_set", holder6.scope_ifname_set);
    pfields.put("ifname", ifname);
    s.writeFields();
}
 
Example 6
/**
 * Serializes a {@link ModelMBeanConstructorInfo} to an {@link ObjectOutputStream}.
 */
private void writeObject(ObjectOutputStream out)
        throws IOException {
  if (compat)
  {
    // Serializes this instance in the old serial form
    //
    ObjectOutputStream.PutField fields = out.putFields();
    fields.put("consDescriptor", consDescriptor);
    fields.put("currClass", currClass);
    out.writeFields();
  }
  else
  {
    // Serializes this instance in the new serial form
    //
    out.defaultWriteObject();
  }
}
 
Example 7
/**
 * Serializes a {@link Notification} to an {@link ObjectOutputStream}.
 */
private void writeObject(ObjectOutputStream out)
        throws IOException {
    if (compat) {
        // Serializes this instance in the old serial form
        //
        ObjectOutputStream.PutField fields = out.putFields();
        fields.put("type", type);
        fields.put("sequenceNumber", sequenceNumber);
        fields.put("timeStamp", timeStamp);
        fields.put("userData", userData);
        fields.put("message", message);
        fields.put("source", source);
        out.writeFields();
    } else {
        // Serializes this instance in the new serial form
        //
        out.defaultWriteObject();
    }
}
 
Example 8
/**
 * @serialData Default fields.
 */
/*
 * Writes the contents of the permsMap field out as a Hashtable for
 * serialization compatibility with earlier releases.
 */
private void writeObject(ObjectOutputStream out) throws IOException {
    // Don't call out.defaultWriteObject()

    // Copy perms into a Hashtable
    Hashtable<Permission, Permission> perms =
            new Hashtable<>(permsMap.size()*2);
    synchronized (this) {
        perms.putAll(permsMap);
    }

    // Write out serializable fields
    ObjectOutputStream.PutField pfields = out.putFields();
    pfields.put("perms", perms);
    out.writeFields();
}
 
Example 9
/**
 * Serializes a {@link RoleInfo} to an {@link ObjectOutputStream}.
 */
private void writeObject(ObjectOutputStream out)
        throws IOException {
  if (compat)
  {
    // Serializes this instance in the old serial form
    //
    ObjectOutputStream.PutField fields = out.putFields();
    fields.put("myName", name);
    fields.put("myIsReadableFlg", isReadable);
    fields.put("myIsWritableFlg", isWritable);
    fields.put("myDescription", description);
    fields.put("myMinDegree", minDegree);
    fields.put("myMaxDegree", maxDegree);
    fields.put("myRefMBeanClassName", referencedMBeanClassName);
    out.writeFields();
  }
  else
  {
    // Serializes this instance in the new serial form
    //
    out.defaultWriteObject();
  }
}
 
Example 10
/**
 * Serializes an {@link MBeanServerNotificationFilter} to an {@link ObjectOutputStream}.
 */
private void writeObject(ObjectOutputStream out)
        throws IOException {
  if (compat)
  {
    // Serializes this instance in the old serial form
    //
    ObjectOutputStream.PutField fields = out.putFields();
    fields.put("mySelectObjNameList", selectedNames);
    fields.put("myDeselectObjNameList", deselectedNames);
    out.writeFields();
  }
  else
  {
    // Serializes this instance in the new serial form
    //
    out.defaultWriteObject();
  }
}
 
Example 11
/**
 * @serialData Default fields.
 */
/*
 * Writes the contents of the perms field out as a Hashtable for
 * serialization compatibility with earlier releases. all_allowed
 * unchanged.
 */
private void writeObject(ObjectOutputStream out) throws IOException {
    // Don't call out.defaultWriteObject()

    // Copy perms into a Hashtable
    Hashtable<String, Permission> permissions =
        new Hashtable<>(perms.size()*2);
    synchronized (this) {
        permissions.putAll(perms);
    }

    // Write out serializable fields
    ObjectOutputStream.PutField pfields = out.putFields();
    pfields.put("all_allowed", all_allowed);
    pfields.put("permissions", permissions);
    out.writeFields();
}
 
Example 12
/**
 * Serializes a {@link RelationNotification} to an {@link ObjectOutputStream}.
 */
private void writeObject(ObjectOutputStream out)
        throws IOException {
  if (compat)
  {
    // Serializes this instance in the old serial form
    //
    ObjectOutputStream.PutField fields = out.putFields();
    fields.put("myNewRoleValue", newRoleValue);
    fields.put("myOldRoleValue", oldRoleValue);
    fields.put("myRelId", relationId);
    fields.put("myRelObjName", relationObjName);
    fields.put("myRelTypeName", relationTypeName);
    fields.put("myRoleName",roleName);
    fields.put("myUnregMBeanList", unregisterMBeanList);
    out.writeFields();
  }
  else
  {
    // Serializes this instance in the new serial form
    //
    out.defaultWriteObject();
  }
}
 
Example 13
private void writeObject(ObjectOutputStream out)
    throws IOException
{
    // Don't call defaultWriteObject()
     ObjectOutputStream.PutField pfields = out.putFields();
     pfields.put("hostname", holder.hostname);
     pfields.put("addr", holder.addr);
     pfields.put("port", holder.port);
     out.writeFields();
 }
 
Example 14
public ObjectOutputStream.PutField putFields()
    throws IOException {
    if (putFields == null) {
        putFields = new HookPutFields();
    }
    return putFields;
}
 
Example 15
public ObjectOutputStream.PutField putFields()
    throws IOException {
    if (putFields == null) {
        putFields = new HookPutFields();
    }
    return putFields;
}
 
Example 16
private synchronized void writeObject(ObjectOutputStream out) throws IOException {
	Hashtable<String, BundlePermission> hashtable = new Hashtable<String, BundlePermission>(permissions);
	ObjectOutputStream.PutField pfields = out.putFields();
	pfields.put("permissions", hashtable);
	pfields.put("all_allowed", all_allowed);
	out.writeFields();
}
 
Example 17
Source Project: ehcache3   File: PutFieldTest.java    License: Apache License 2.0 5 votes vote down vote up
private void writeObject(ObjectOutputStream out) throws IOException {
  ObjectOutputStream.PutField fields = out.putFields();
  fields.put("z", true);
  fields.put("b", (byte) 5);
  fields.put("c", '5');
  fields.put("s", (short) 5);
  fields.put("i", 5);
  fields.put("j", 5l);
  fields.put("f", 5.0f);
  fields.put("d", 5.0);
  fields.put("str", "5");
  out.writeFields();
}
 
Example 18
Source Project: openjdk-jdk9   File: Token.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
     * @serialData Serialized fields. Convert the List to Vector for backward compatibility.
     */
    private void writeObject(ObjectOutputStream out) throws IOException {
        // Convert List to Vector
        Vector<Token> vChildren = (children == null)? null : new Vector<>(children);

        // Write serialized fields
        ObjectOutputStream.PutField pf = out.putFields();
        pf.put("children", vChildren);
        out.writeFields();
}
 
Example 19
@java.io.Serial
private void writeObject(ObjectOutputStream out) throws IOException {
    ObjectOutputStream.PutField fields = out.putFields();
    fields.put("exception", super.getCause());
    out.writeFields();
}
 
Example 20
/*************************************************************/
/* Use the methods of PutField to map between Serializable fields
 * and actual fields of a Serializable class.
 */

abstract public ObjectOutputStream.PutField putFields() throws IOException;