本文整理汇总了Java中java.io.ObjectInputStream.GetField方法的典型用法代码示例。如果您正苦于以下问题:Java ObjectInputStream.GetField方法的具体用法?Java ObjectInputStream.GetField怎么用?Java ObjectInputStream.GetField使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.io.ObjectInputStream
的用法示例。
在下文中一共展示了ObjectInputStream.GetField方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: readObject
import java.io.ObjectInputStream; //导入方法依赖的package包/类
private void readObject(ObjectInputStream in) throws IOException,
ClassNotFoundException {
// Don't call defaultReadObject()
// Read in serialized fields
ObjectInputStream.GetField gfields = in.readFields();
// Get allPermission
allPermission = (PermissionCollection) gfields.get("allPermission", null);
// Get permissions
// writeObject writes a Hashtable<Class<?>, PermissionCollection> for
// the perms key, so this cast is safe, unless the data is corrupt.
@SuppressWarnings("unchecked")
Hashtable<Class<?>, PermissionCollection> perms =
(Hashtable<Class<?>, PermissionCollection>)gfields.get("perms", null);
permsMap = new HashMap<Class<?>, PermissionCollection>(perms.size()*2);
permsMap.putAll(perms);
// Set hasUnresolved
UnresolvedPermissionCollection uc =
(UnresolvedPermissionCollection) permsMap.get(UnresolvedPermission.class);
hasUnresolved = (uc != null && uc.elements().hasMoreElements());
}
示例2: readFields
import java.io.ObjectInputStream; //导入方法依赖的package包/类
public ObjectInputStream.GetField readFields()
throws IOException, ClassNotFoundException, NotActiveException {
HashMap fieldValueMap = new HashMap();
// We were treating readFields same as defaultReadObject. It is
// incorrect if the state is readOptionalData. If this line
// is uncommented, it will throw a stream corrupted exception.
// _REVISIT_: The ideal fix would be to add a new state. In
// writeObject user may do one of the following
// 1. Call defaultWriteObject()
// 2. Put out optional fields
// 3. Call writeFields
// We have the state defined for (1) and (2) but not for (3), so
// we should ideally introduce a new state for 3 and have the
// beginDefaultReadObject do nothing.
//readObjectState.beginDefaultReadObject(this);
readFields(fieldValueMap);
readObjectState.endDefaultReadObject(this);
return new HookGetFields(fieldValueMap);
}
示例3: readObject
import java.io.ObjectInputStream; //导入方法依赖的package包/类
/**
* Deserializes an {@link InvalidTargetObjectTypeException} from an {@link ObjectInputStream}.
*/
private void readObject(ObjectInputStream in)
throws IOException, ClassNotFoundException {
if (compat)
{
// Read an object serialized in the old serial form
//
ObjectInputStream.GetField fields = in.readFields();
exception = (Exception) fields.get("relatedExcept", null);
if (fields.defaulted("relatedExcept"))
{
throw new NullPointerException("relatedExcept");
}
}
else
{
// Read an object serialized in the new serial form
//
in.defaultReadObject();
}
}
示例4: readObject
import java.io.ObjectInputStream; //导入方法依赖的package包/类
private void readObject(ObjectInputStream in)
throws IOException, ClassNotFoundException
{
// Don't call defaultReadObject()
// Read in serialized fields
ObjectInputStream.GetField gfields = in.readFields();
// Get all_allowed
all_allowed = gfields.get("all_allowed", false);
// Get permissions
@SuppressWarnings("unchecked")
Hashtable<String, PropertyPermission> permissions =
(Hashtable<String, PropertyPermission>)gfields.get("permissions", null);
perms = new HashMap<>(permissions.size()*2);
perms.putAll(permissions);
}
示例5: readObject
import java.io.ObjectInputStream; //导入方法依赖的package包/类
private void readObject(ObjectInputStream s) throws ClassNotFoundException, IOException {
this.map = new VetoableChangeListenerMap();
ObjectInputStream.GetField fields = s.readFields();
@SuppressWarnings("unchecked")
Hashtable<String, VetoableChangeSupport> children = (Hashtable<String, VetoableChangeSupport>)fields.get("children", null);
this.source = fields.get("source", null);
fields.get("vetoableChangeSupportSerializedDataVersion", 2);
Object listenerOrNull;
while (null != (listenerOrNull = s.readObject())) {
this.map.add(null, (VetoableChangeListener)listenerOrNull);
}
if (children != null) {
for (Entry<String, VetoableChangeSupport> entry : children.entrySet()) {
for (VetoableChangeListener listener : entry.getValue().getVetoableChangeListeners()) {
this.map.add(entry.getKey(), listener);
}
}
}
}
示例6: readObject
import java.io.ObjectInputStream; //导入方法依赖的package包/类
private void readObject(ObjectInputStream in)
throws IOException, ClassNotFoundException
{
// Don't call defaultReadObject()
ObjectInputStream.GetField oisFields = in.readFields();
final String oisHostname = (String)oisFields.get("hostname", null);
final InetAddress oisAddr = (InetAddress)oisFields.get("addr", null);
final int oisPort = oisFields.get("port", -1);
// Check that our invariants are satisfied
checkPort(oisPort);
if (oisHostname == null && oisAddr == null)
throw new InvalidObjectException("hostname and addr " +
"can't both be null");
InetSocketAddressHolder h = new InetSocketAddressHolder(oisHostname,
oisAddr,
oisPort);
UNSAFE.putObject(this, FIELDS_OFFSET, h);
}
示例7: readObject
import java.io.ObjectInputStream; //导入方法依赖的package包/类
/**
* readObject is called to restore the state of the
* {@code BatchUpdateException} from a stream.
*/
private void readObject(ObjectInputStream s)
throws IOException, ClassNotFoundException {
ObjectInputStream.GetField fields = s.readFields();
int[] tmp = (int[])fields.get("updateCounts", null);
long[] tmp2 = (long[])fields.get("longUpdateCounts", null);
if(tmp != null && tmp2 != null && tmp.length != tmp2.length)
throw new InvalidObjectException("update counts are not the expected size");
if (tmp != null)
updateCounts = tmp.clone();
if (tmp2 != null)
longUpdateCounts = tmp2.clone();
if(updateCounts == null && longUpdateCounts != null)
updateCounts = copyUpdateCount(longUpdateCounts);
if(longUpdateCounts == null && updateCounts != null)
longUpdateCounts = copyUpdateCount(updateCounts);
}
示例8: readObject
import java.io.ObjectInputStream; //导入方法依赖的package包/类
/**
* Deserializes this <code>Locale</code>.
* @param in the <code>ObjectInputStream</code> to read
* @throws IOException
* @throws ClassNotFoundException
* @throws IllformedLocaleException
* @since 1.7
*/
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
ObjectInputStream.GetField fields = in.readFields();
String language = (String)fields.get("language", "");
String script = (String)fields.get("script", "");
String country = (String)fields.get("country", "");
String variant = (String)fields.get("variant", "");
String extStr = (String)fields.get("extensions", "");
baseLocale = BaseLocale.getInstance(convertOldISOCodes(language), script, country, variant);
if (extStr.length() > 0) {
try {
InternalLocaleBuilder bldr = new InternalLocaleBuilder();
bldr.setExtensions(extStr);
localeExtensions = bldr.getLocaleExtensions();
} catch (LocaleSyntaxException e) {
throw new IllformedLocaleException(e.getMessage());
}
} else {
localeExtensions = null;
}
}
示例9: readObject
import java.io.ObjectInputStream; //导入方法依赖的package包/类
/**
* Reads default serializable fields to stream.
* @exception HeadlessException if
* <code>GraphicsEnvironment.isHeadless()</code> returns
* <code>true</code>
* @see java.awt.GraphicsEnvironment#isHeadless
*/
private void readObject(ObjectInputStream s)
throws ClassNotFoundException, IOException, HeadlessException
{
GraphicsEnvironment.checkHeadless();
// 4352819: Gotcha! Cannot use s.defaultReadObject here and
// then continue with reading optional data. Use GetField instead.
ObjectInputStream.GetField f = s.readFields();
// Old fields
scrollbarDisplayPolicy = f.get("scrollbarDisplayPolicy",
SCROLLBARS_AS_NEEDED);
hAdjustable = (ScrollPaneAdjustable)f.get("hAdjustable", null);
vAdjustable = (ScrollPaneAdjustable)f.get("vAdjustable", null);
// Since 1.4
wheelScrollingEnabled = f.get("wheelScrollingEnabled",
defaultWheelScroll);
// // Note to future maintainers
// if (f.defaulted("wheelScrollingEnabled")) {
// // We are reading pre-1.4 stream that doesn't have
// // optional data, not even the TC_ENDBLOCKDATA marker.
// // Reading anything after this point is unsafe as we will
// // read unrelated objects further down the stream (4352819).
// }
// else {
// // Reading data from 1.4 or later, it's ok to try to read
// // optional data as OptionalDataException with eof == true
// // will be correctly reported
// }
}
示例10: readObject
import java.io.ObjectInputStream; //导入方法依赖的package包/类
/**
* Deserializes a {@link ModelMBeanInfoSupport} from an {@link ObjectInputStream}.
*/
private void readObject(ObjectInputStream in)
throws IOException, ClassNotFoundException {
if (compat) {
// Read an object serialized in the old serial form
//
ObjectInputStream.GetField fields = in.readFields();
modelMBeanDescriptor =
(Descriptor) fields.get("modelMBeanDescriptor", null);
if (fields.defaulted("modelMBeanDescriptor")) {
throw new NullPointerException("modelMBeanDescriptor");
}
modelMBeanAttributes =
(MBeanAttributeInfo[]) fields.get("mmbAttributes", null);
if (fields.defaulted("mmbAttributes")) {
throw new NullPointerException("mmbAttributes");
}
modelMBeanConstructors =
(MBeanConstructorInfo[]) fields.get("mmbConstructors", null);
if (fields.defaulted("mmbConstructors")) {
throw new NullPointerException("mmbConstructors");
}
modelMBeanNotifications =
(MBeanNotificationInfo[]) fields.get("mmbNotifications", null);
if (fields.defaulted("mmbNotifications")) {
throw new NullPointerException("mmbNotifications");
}
modelMBeanOperations =
(MBeanOperationInfo[]) fields.get("mmbOperations", null);
if (fields.defaulted("mmbOperations")) {
throw new NullPointerException("mmbOperations");
}
} else {
// Read an object serialized in the new serial form
//
in.defaultReadObject();
}
}
示例11: readObject
import java.io.ObjectInputStream; //导入方法依赖的package包/类
/**
* Deserializes a {@link DescriptorSupport} from an {@link
* ObjectInputStream}.
*/
private void readObject(ObjectInputStream in)
throws IOException, ClassNotFoundException {
ObjectInputStream.GetField fields = in.readFields();
Map<String, Object> descriptor = cast(fields.get("descriptor", null));
init(null);
if (descriptor != null) {
descriptorMap.putAll(descriptor);
}
}
示例12: readObject
import java.io.ObjectInputStream; //导入方法依赖的package包/类
/**
* Reads the {@code ObjectInputStream} and an optional
* list of listeners to receive various events fired by
* the component; also reads a list of
* (possibly {@code null}) child windows.
* Unrecognized keys or values will be ignored.
*
* @param s the {@code ObjectInputStream} to read
* @exception HeadlessException if
* {@code GraphicsEnvironment.isHeadless} returns
* {@code true}
* @see java.awt.GraphicsEnvironment#isHeadless
* @see #writeObject
*/
private void readObject(ObjectInputStream s)
throws ClassNotFoundException, IOException, HeadlessException
{
GraphicsEnvironment.checkHeadless();
initDeserializedWindow();
ObjectInputStream.GetField f = s.readFields();
syncLWRequests = f.get("syncLWRequests", systemSyncLWRequests);
state = f.get("state", 0);
focusableWindowState = f.get("focusableWindowState", true);
windowSerializedDataVersion = f.get("windowSerializedDataVersion", 1);
locationByPlatform = f.get("locationByPlatform", locationByPlatformProp);
// Note: 1.4 (or later) doesn't use focusMgr
focusMgr = (FocusManager)f.get("focusMgr", null);
Dialog.ModalExclusionType et = (Dialog.ModalExclusionType)
f.get("modalExclusionType", Dialog.ModalExclusionType.NO_EXCLUDE);
setModalExclusionType(et); // since 6.0
boolean aot = f.get("alwaysOnTop", false);
if(aot) {
setAlwaysOnTop(aot); // since 1.5; subject to permission check
}
shape = (Shape)f.get("shape", null);
opacity = (Float)f.get("opacity", 1.0f);
this.securityWarningWidth = 0;
this.securityWarningHeight = 0;
this.securityWarningPointX = 2.0;
this.securityWarningPointY = 0.0;
this.securityWarningAlignmentX = RIGHT_ALIGNMENT;
this.securityWarningAlignmentY = TOP_ALIGNMENT;
deserializeResources(s);
}
示例13: readObject
import java.io.ObjectInputStream; //导入方法依赖的package包/类
private void readObject(ObjectInputStream s)
throws IOException, ClassNotFoundException {
ObjectInputStream.GetField fields = s.readFields();
@SuppressWarnings("unchecked")
Hashtable<String,PermissionCollection> permTable =
(Hashtable<String,PermissionCollection>)
(fields.get("perms", null));
if (permTable != null) {
perms = new ConcurrentHashMap<>(permTable);
} else {
perms = new ConcurrentHashMap<>();
}
}
示例14: readObject
import java.io.ObjectInputStream; //导入方法依赖的package包/类
/**
* Deserializes a {@link RelationTypeSupport} from an {@link ObjectInputStream}.
*/
private void readObject(ObjectInputStream in)
throws IOException, ClassNotFoundException {
if (compat)
{
// Read an object serialized in the old serial form
//
ObjectInputStream.GetField fields = in.readFields();
typeName = (String) fields.get("myTypeName", null);
if (fields.defaulted("myTypeName"))
{
throw new NullPointerException("myTypeName");
}
roleName2InfoMap = cast(fields.get("myRoleName2InfoMap", null));
if (fields.defaulted("myRoleName2InfoMap"))
{
throw new NullPointerException("myRoleName2InfoMap");
}
isInRelationService = fields.get("myIsInRelServFlg", false);
if (fields.defaulted("myIsInRelServFlg"))
{
throw new NullPointerException("myIsInRelServFlg");
}
}
else
{
// Read an object serialized in the new serial form
//
in.defaultReadObject();
}
}
示例15: readObject
import java.io.ObjectInputStream; //导入方法依赖的package包/类
private void readObject(ObjectInputStream in) throws IOException,
ClassNotFoundException {
// Don't call defaultReadObject()
// Read in serialized fields
ObjectInputStream.GetField gfields = in.readFields();
// Get permissions
@SuppressWarnings("unchecked")
// writeObject writes a Hashtable<String, Vector<UnresolvedPermission>>
// for the permissions key, so this cast is safe, unless the data is corrupt.
Hashtable<String, Vector<UnresolvedPermission>> permissions =
(Hashtable<String, Vector<UnresolvedPermission>>)
gfields.get("permissions", null);
perms = new ConcurrentHashMap<>(permissions.size()*2);
// Convert each entry (Vector) into a List
Set<Map.Entry<String, Vector<UnresolvedPermission>>> set = permissions.entrySet();
for (Map.Entry<String, Vector<UnresolvedPermission>> e : set) {
// Convert Vector into ArrayList
Vector<UnresolvedPermission> vec = e.getValue();
List<UnresolvedPermission> list = new CopyOnWriteArrayList<>(vec);
// Add to Hashtable being serialized
perms.put(e.getKey(), list);
}
}