Java Code Examples for java.io.ObjectOutputStream#putFields()
The following examples show how to use
java.io.ObjectOutputStream#putFields() .
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
Source File: Notification.java From JDKSourceCode1.8 with MIT License | 6 votes |
/** * 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 2
Source File: RelationTypeSupport.java From Java8CN with Apache License 2.0 | 6 votes |
/** * Serializes a {@link RelationTypeSupport} 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("myTypeName", typeName); fields.put("myRoleName2InfoMap", roleName2InfoMap); fields.put("myIsInRelServFlg", isInRelationService); out.writeFields(); } else { // Serializes this instance in the new serial form // out.defaultWriteObject(); } }
Example 3
Source File: Permissions.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
/** * @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); perms.putAll(permsMap); // Write out serializable fields ObjectOutputStream.PutField pfields = out.putFields(); pfields.put("perms", perms); out.writeFields(); }
Example 4
Source File: DocumentTypeImpl.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
/** * @serialData Serialized fields. Convert Map to Hashtable for backward * compatibility. */ private void writeObject(ObjectOutputStream out) throws IOException { // Convert the HashMap to Hashtable Hashtable<String, UserDataRecord> ud = (userData == null)? null : new Hashtable<>(userData); // Write serialized fields ObjectOutputStream.PutField pf = out.putFields(); pf.put("name", name); pf.put("entities", entities); pf.put("notations", notations); pf.put("elements", elements); pf.put("publicID", publicID); pf.put("systemID", systemID); pf.put("internalSubset", internalSubset); pf.put("doctypeNumber", doctypeNumber); pf.put("userData", ud); out.writeFields(); }
Example 5
Source File: GetPutFieldTrees.java From jdk8u_jdk with GNU General Public License v2.0 | 6 votes |
private void writeObject(ObjectOutputStream out) throws IOException { ObjectOutputStream.PutField fields = out.putFields(); fields.put("z", z); fields.put("b", b); fields.put("c", c); fields.put("s", s); fields.put("i", i); fields.put("f", f); fields.put("j", j); fields.put("d", d); fields.put("str", str); fields.put("parent", parent); fields.put("left", left); fields.put("right", right); out.writeFields(); }
Example 6
Source File: ModelMBeanAttributeInfo.java From jdk8u60 with GNU General Public License v2.0 | 6 votes |
/** * 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 7
Source File: ModelMBeanAttributeInfo.java From openjdk-8 with GNU General Public License v2.0 | 6 votes |
/** * 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 8
Source File: Role.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
/** * Serializes a {@link Role} 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("myObjNameList", objectNameList); out.writeFields(); } else { // Serializes this instance in the new serial form // out.defaultWriteObject(); } }
Example 9
Source File: ModelMBeanOperationInfo.java From jdk1.8-source-analysis with Apache License 2.0 | 6 votes |
/** * Serializes a {@link ModelMBeanOperationInfo} 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("operationDescriptor", operationDescriptor); fields.put("currClass", currClass); out.writeFields(); } else { // Serializes this instance in the new serial form // out.defaultWriteObject(); } }
Example 10
Source File: ServicePermission.java From jdk8u60 with GNU General Public License v2.0 | 6 votes |
/** * @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 11
Source File: GetPutFieldTrees.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 6 votes |
private void writeObject(ObjectOutputStream out) throws IOException { ObjectOutputStream.PutField fields = out.putFields(); fields.put("z", z); fields.put("b", b); fields.put("c", c); fields.put("s", s); fields.put("i", i); fields.put("f", f); fields.put("j", j); fields.put("d", d); fields.put("str", str); fields.put("parent", parent); fields.put("left", left); fields.put("right", right); out.writeFields(); }
Example 12
Source File: BatchUpdateException.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
/** * writeObject is called to save the state of the {@code BatchUpdateException} * to a stream. */ private void writeObject(ObjectOutputStream s) throws IOException, ClassNotFoundException { ObjectOutputStream.PutField fields = s.putFields(); fields.put("updateCounts", updateCounts); fields.put("longUpdateCounts", longUpdateCounts); s.writeFields(); }
Example 13
Source File: Locale.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
/** * Serializes this <code>Locale</code> to the specified <code>ObjectOutputStream</code>. * @param out the <code>ObjectOutputStream</code> to write * @throws IOException * @since 1.7 */ private void writeObject(ObjectOutputStream out) throws IOException { ObjectOutputStream.PutField fields = out.putFields(); fields.put("language", baseLocale.getLanguage()); fields.put("script", baseLocale.getScript()); fields.put("country", baseLocale.getRegion()); fields.put("variant", baseLocale.getVariant()); fields.put("extensions", localeExtensions == null ? "" : localeExtensions.getID()); fields.put("hashcode", -1); // place holder just for backward support out.writeFields(); }
Example 14
Source File: Locale.java From jdk-1.7-annotated with Apache License 2.0 | 5 votes |
/** * Serializes this <code>Locale</code> to the specified <code>ObjectOutputStream</code>. * @param out the <code>ObjectOutputStream</code> to write * @throws IOException * @since 1.7 */ private void writeObject(ObjectOutputStream out) throws IOException { ObjectOutputStream.PutField fields = out.putFields(); fields.put("language", baseLocale.getLanguage()); fields.put("script", baseLocale.getScript()); fields.put("country", baseLocale.getRegion()); fields.put("variant", baseLocale.getVariant()); fields.put("extensions", localeExtensions == null ? "" : localeExtensions.getID()); fields.put("hashcode", -1); // place holder just for backward support out.writeFields(); }
Example 15
Source File: BatchUpdateException.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
/** * writeObject is called to save the state of the {@code BatchUpdateException} * to a stream. */ private void writeObject(ObjectOutputStream s) throws IOException, ClassNotFoundException { ObjectOutputStream.PutField fields = s.putFields(); fields.put("updateCounts", updateCounts); fields.put("longUpdateCounts", longUpdateCounts); s.writeFields(); }
Example 16
Source File: BatchUpdateException.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
/** * writeObject is called to save the state of the {@code BatchUpdateException} * to a stream. */ private void writeObject(ObjectOutputStream s) throws IOException, ClassNotFoundException { ObjectOutputStream.PutField fields = s.putFields(); fields.put("updateCounts", updateCounts); fields.put("longUpdateCounts", longUpdateCounts); s.writeFields(); }
Example 17
Source File: AdminPermission.java From concierge with Eclipse Public License 1.0 | 5 votes |
private synchronized void writeObject(ObjectOutputStream out) throws IOException { Hashtable<String, AdminPermission> hashtable = new Hashtable<String, AdminPermission>(permissions); ObjectOutputStream.PutField pfields = out.putFields(); pfields.put("permissions", hashtable); pfields.put("all_allowed", all_allowed); out.writeFields(); }
Example 18
Source File: PropertyChangeSupport.java From jdk1.8-source-analysis with Apache License 2.0 | 5 votes |
/** * @serialData Null terminated list of <code>PropertyChangeListeners</code>. * <p> * At serialization time we skip non-serializable listeners and * only serialize the serializable listeners. */ private void writeObject(ObjectOutputStream s) throws IOException { Hashtable<String, PropertyChangeSupport> children = null; PropertyChangeListener[] listeners = null; synchronized (this.map) { for (Entry<String, PropertyChangeListener[]> entry : this.map.getEntries()) { String property = entry.getKey(); if (property == null) { listeners = entry.getValue(); } else { if (children == null) { children = new Hashtable<>(); } PropertyChangeSupport pcs = new PropertyChangeSupport(this.source); pcs.map.set(null, entry.getValue()); children.put(property, pcs); } } } ObjectOutputStream.PutField fields = s.putFields(); fields.put("children", children); fields.put("source", this.source); fields.put("propertyChangeSupportSerializedDataVersion", 2); s.writeFields(); if (listeners != null) { for (PropertyChangeListener l : listeners) { if (l instanceof Serializable) { s.writeObject(l); } } } s.writeObject(null); }
Example 19
Source File: Locale.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
/** * Serializes this <code>Locale</code> to the specified <code>ObjectOutputStream</code>. * @param out the <code>ObjectOutputStream</code> to write * @throws IOException * @since 1.7 */ private void writeObject(ObjectOutputStream out) throws IOException { ObjectOutputStream.PutField fields = out.putFields(); fields.put("language", baseLocale.getLanguage()); fields.put("script", baseLocale.getScript()); fields.put("country", baseLocale.getRegion()); fields.put("variant", baseLocale.getVariant()); fields.put("extensions", localeExtensions == null ? "" : localeExtensions.getID()); fields.put("hashcode", -1); // place holder just for backward support out.writeFields(); }
Example 20
Source File: DescriptorSupport.java From jdk8u-jdk with GNU General Public License v2.0 | 4 votes |
/** * Serializes a {@link DescriptorSupport} to an {@link ObjectOutputStream}. */ /* If you set jmx.serial.form to "1.2.0" or "1.2.1", then we are bug-compatible with those versions. Specifically, field names are forced to lower-case before being written. This contradicts the spec, which, though it does not mention serialization explicitly, does say that the case of field names is preserved. But in 1.2.0 and 1.2.1, this requirement was not met. Instead, field names in the descriptor map were forced to lower case. Those versions expect this to have happened to a descriptor they deserialize and e.g. getFieldValue will not find a field whose name is spelt with a different case. */ private void writeObject(ObjectOutputStream out) throws IOException { ObjectOutputStream.PutField fields = out.putFields(); boolean compat = "1.0".equals(serialForm); if (compat) fields.put("currClass", currClass); /* Purge the field "targetObject" from the DescriptorSupport before * serializing since the referenced object is typically not * serializable. We do this here rather than purging the "descriptor" * variable below because that HashMap doesn't do case-insensitivity. * See CR 6332962. */ SortedMap<String, Object> startMap = descriptorMap; if (startMap.containsKey("targetObject")) { startMap = new TreeMap<String, Object>(descriptorMap); startMap.remove("targetObject"); } final HashMap<String, Object> descriptor; if (compat || "1.2.0".equals(serialForm) || "1.2.1".equals(serialForm)) { descriptor = new HashMap<String, Object>(); for (Map.Entry<String, Object> entry : startMap.entrySet()) descriptor.put(entry.getKey().toLowerCase(), entry.getValue()); } else descriptor = new HashMap<String, Object>(startMap); fields.put("descriptor", descriptor); out.writeFields(); }