本文整理汇总了Java中java.io.ObjectOutputStream.writeFields方法的典型用法代码示例。如果您正苦于以下问题:Java ObjectOutputStream.writeFields方法的具体用法?Java ObjectOutputStream.writeFields怎么用?Java ObjectOutputStream.writeFields使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.io.ObjectOutputStream
的用法示例。
在下文中一共展示了ObjectOutputStream.writeFields方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: writeObject
import java.io.ObjectOutputStream; //导入方法依赖的package包/类
/**
* Serializes a {@link ModelMBeanNotificationInfo} 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("notificationDescriptor", notificationDescriptor);
fields.put("currClass", currClass);
out.writeFields();
} else {
// Serializes this instance in the new serial form
//
out.defaultWriteObject();
}
}
示例2: writeObject
import java.io.ObjectOutputStream; //导入方法依赖的package包/类
/**
* Serializes an {@link XMLParseException} 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("msgStr", getMessage());
out.writeFields();
}
else
{
// Serializes this instance in the new serial form
//
out.defaultWriteObject();
}
}
示例3: writeObject
import java.io.ObjectOutputStream; //导入方法依赖的package包/类
/**
* Save the {@code BigInteger} instance to a stream.
* The magnitude of a BigInteger is serialized as a byte array for
* historical reasons.
*
* @serialData two necessary fields are written as well as obsolete
* fields for compatibility with older versions.
*/
private void writeObject(ObjectOutputStream s) throws IOException {
// set the values of the Serializable fields
ObjectOutputStream.PutField fields = s.putFields();
fields.put("signum", signum);
fields.put("magnitude", magSerializedForm());
// The values written for cached fields are compatible with older
// versions, but are ignored in readObject so don't otherwise matter.
fields.put("bitCount", -1);
fields.put("bitLength", -1);
fields.put("lowestSetBit", -2);
fields.put("firstNonzeroByteNum", -2);
// save them
s.writeFields();
}
示例4: writeObject
import java.io.ObjectOutputStream; //导入方法依赖的package包/类
/**
* Serializes a {@link RoleUnresolved} 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("myRoleName", roleName);
fields.put("myRoleValue", roleValue);
fields.put("myPbType", problemType);
out.writeFields();
}
else
{
// Serializes this instance in the new serial form
//
out.defaultWriteObject();
}
}
示例5: writeObject
import java.io.ObjectOutputStream; //导入方法依赖的package包/类
/**
* @serialData Default fields.
*/
/*
* Writes the contents of the permsMap field out as a Hashtable for
* serialization compatibility with earlier releases. allPermission
* unchanged.
*/
private void writeObject(ObjectOutputStream out) throws IOException {
// Don't call out.defaultWriteObject()
// Copy perms into a Hashtable
Hashtable<Class<?>, PermissionCollection> perms =
new Hashtable<>(permsMap.size()*2); // no sync; estimate
synchronized (this) {
perms.putAll(permsMap);
}
// Write out serializable fields
ObjectOutputStream.PutField pfields = out.putFields();
pfields.put("allPermission", allPermission); // no sync; staleness OK
pfields.put("perms", perms);
out.writeFields();
}
示例6: writeObject
import java.io.ObjectOutputStream; //导入方法依赖的package包/类
/**
* Serializes a {@link NumericValueExp} 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("doubleVal", doubleValue());
fields.put("longVal", longValue());
fields.put("valIsLong", isLong());
out.writeFields();
}
else
{
// Serializes this instance in the new serial form
//
out.defaultWriteObject();
}
}
示例7: writeObject
import java.io.ObjectOutputStream; //导入方法依赖的package包/类
/**
* Serializes a {@link RoleResult} 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("myRoleList", roleList);
fields.put("myRoleUnresList", unresolvedRoleList);
out.writeFields();
}
else
{
// Serializes this instance in the new serial form
//
out.defaultWriteObject();
}
}
示例8: writeObject
import java.io.ObjectOutputStream; //导入方法依赖的package包/类
/**
* Writes serializable fields to stream.
*/
private void writeObject(ObjectOutputStream s)
throws IOException
{
Hashtable<String, Component> tab = new Hashtable<>();
int ncomponents = vector.size();
for (int i = 0; i < ncomponents; i++) {
Card card = (Card)vector.get(i);
tab.put(card.name, card.comp);
}
ObjectOutputStream.PutField f = s.putFields();
f.put("hgap", hgap);
f.put("vgap", vgap);
f.put("vector", vector);
f.put("currentCard", currentCard);
f.put("tab", tab);
s.writeFields();
}
示例9: writeObject
import java.io.ObjectOutputStream; //导入方法依赖的package包/类
/**
* 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();
}
}
示例10: writeObject
import java.io.ObjectOutputStream; //导入方法依赖的package包/类
/**
* @serialData "permissions" field (a Vector containing the SocketPermissions).
*/
/*
* 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<SocketPermission> permissions = new Vector<>(perms.size());
synchronized (this) {
permissions.addAll(perms);
}
ObjectOutputStream.PutField pfields = out.putFields();
pfields.put("permissions", permissions);
out.writeFields();
}
示例11: writeObject
import java.io.ObjectOutputStream; //导入方法依赖的package包/类
/**
* @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();
}
示例12: writeObject
import java.io.ObjectOutputStream; //导入方法依赖的package包/类
/** 重写序列化函数*/
private void writeObject(ObjectOutputStream out) throws IOException{
ObjectOutputStream.PutField putFields = out.putFields();
putFields.put("sessionId", Base64.encode(sessionId.getBytes()));
putFields.put("expired", expired);
System.out.println("self unserialization " + this.getClass());
out.writeFields();
}
示例13: writeObject
import java.io.ObjectOutputStream; //导入方法依赖的package包/类
/**
* 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();
}
示例14: writeObject
import java.io.ObjectOutputStream; //导入方法依赖的package包/类
/**
* @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);
}
示例15: writeObject
import java.io.ObjectOutputStream; //导入方法依赖的package包/类
/**
* @serialData Null terminated list of {@code VetoableChangeListeners}.
* <p>
* At serialization time we skip non-serializable listeners and
* only serialize the serializable listeners.
*/
private void writeObject(ObjectOutputStream s) throws IOException {
Hashtable<String, VetoableChangeSupport> children = null;
VetoableChangeListener[] listeners = null;
synchronized (this.map) {
for (Entry<String, VetoableChangeListener[]> entry : this.map.getEntries()) {
String property = entry.getKey();
if (property == null) {
listeners = entry.getValue();
} else {
if (children == null) {
children = new Hashtable<>();
}
VetoableChangeSupport vcs = new VetoableChangeSupport(this.source);
vcs.map.set(null, entry.getValue());
children.put(property, vcs);
}
}
}
ObjectOutputStream.PutField fields = s.putFields();
fields.put("children", children);
fields.put("source", this.source);
fields.put("vetoableChangeSupportSerializedDataVersion", 2);
s.writeFields();
if (listeners != null) {
for (VetoableChangeListener l : listeners) {
if (l instanceof Serializable) {
s.writeObject(l);
}
}
}
s.writeObject(null);
}