本文整理了Java中java.io.ObjectInputStream.readFields()
方法的一些代码示例,展示了ObjectInputStream.readFields()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ObjectInputStream.readFields()
方法的具体详情如下:
包路径:java.io.ObjectInputStream
类名称:ObjectInputStream
方法名:readFields
[英]Reads the persistent fields of the object that is currently being read from the source stream. The values read are stored in a GetField object that provides access to the persistent fields. This GetField object is then returned.
[中]读取当前正在从源流读取的对象的持久字段。读取的值存储在GetField对象中,该对象提供对持久字段的访问。然后返回这个GetField对象。
代码示例来源:origin: org.osgi/org.osgi.core
private synchronized void readObject(java.io.ObjectInputStream in) throws IOException, ClassNotFoundException {
ObjectInputStream.GetField gfields = in.readFields();
@SuppressWarnings("unchecked")
Hashtable<String, BundlePermission> hashtable = (Hashtable<String, BundlePermission>) gfields.get("permissions", null);
permissions = new HashMap<String, BundlePermission>(hashtable);
all_allowed = gfields.get("all_allowed", false);
}
}
代码示例来源:origin: org.osgi/org.osgi.core
private synchronized void readObject(java.io.ObjectInputStream in) throws IOException, ClassNotFoundException {
ObjectInputStream.GetField gfields = in.readFields();
@SuppressWarnings("unchecked")
Hashtable<String, AdminPermission> hashtable = (Hashtable<String, AdminPermission>) gfields.get("permissions", null);
permissions = new HashMap<String, AdminPermission>(hashtable);
all_allowed = gfields.get("all_allowed", false);
}
}
代码示例来源:origin: robovm/robovm
@SuppressWarnings("unchecked") // we have to trust that keys are Ks and values are Vs
private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException {
GetField fields = stream.readFields();
comparator = (Comparator<? super K>) fields.get("comparator", null);
if (comparator == null) {
comparator = (Comparator<? super K>) NATURAL_ORDER;
}
int size = stream.readInt();
for (int i = 0; i < size; i++) {
putInternal((K) stream.readObject(), (V) stream.readObject());
}
}
代码示例来源:origin: robovm/robovm
/**
* Reconstitutes the instance from a stream (that is, deserializes it).
*/
private void readObject(java.io.ObjectInputStream s)
throws java.io.IOException, ClassNotFoundException,
java.io.InvalidObjectException {
// Note: This must be changed if any additional fields are defined
Object a = s.readFields().get("array", null);
if (a == null || !a.getClass().isArray())
throw new java.io.InvalidObjectException("Not array type");
if (a.getClass() != Object[].class)
a = Arrays.copyOf((Object[])a, Array.getLength(a), Object[].class);
unsafe.putObjectVolatile(this, arrayFieldOffset, a);
}
代码示例来源:origin: org.osgi/org.osgi.compendium
private synchronized void readObject(java.io.ObjectInputStream in) throws IOException, ClassNotFoundException {
ObjectInputStream.GetField gfields = in.readFields();
permissions = (HashMap<String, EndpointPermission>) gfields.get("permissions", new HashMap<String, EndpointPermission>());
all_allowed = gfields.get("all_allowed", false);
}
}
代码示例来源:origin: org.osgi/org.osgi.compendium
private synchronized void readObject(java.io.ObjectInputStream in) throws IOException, ClassNotFoundException {
ObjectInputStream.GetField gfields = in.readFields();
Hashtable<String, TopicPermission> hashtable = (Hashtable<String, TopicPermission>) gfields.get("permissions", null);
permissions = new HashMap<String, TopicPermission>(hashtable);
all_allowed = gfields.get("all_allowed", false);
}
}
代码示例来源:origin: org.osgi/org.osgi.core
private synchronized void readObject(java.io.ObjectInputStream in) throws IOException, ClassNotFoundException {
ObjectInputStream.GetField gfields = in.readFields();
@SuppressWarnings("unchecked")
HashMap<String, AdaptPermission> p = (HashMap<String, AdaptPermission>) gfields.get("permissions", null);
permissions = p;
all_allowed = gfields.get("all_allowed", false);
}
}
代码示例来源:origin: org.osgi/org.osgi.compendium
private synchronized void readObject(java.io.ObjectInputStream in) throws IOException, ClassNotFoundException {
ObjectInputStream.GetField gfields = in.readFields();
permissions = (HashMap<String, CoordinationPermission>) gfields.get("permissions", null);
all_allowed = gfields.get("all_allowed", false);
}
}
代码示例来源:origin: org.osgi/org.osgi.compendium
private synchronized void readObject(java.io.ObjectInputStream in) throws IOException, ClassNotFoundException {
ObjectInputStream.GetField gfields = in.readFields();
HashMap<String, SubsystemPermission> p = (HashMap<String, SubsystemPermission>) gfields.get("permissions", null);
permissions = p;
all_allowed = gfields.get("all_allowed", false);
}
}
代码示例来源:origin: org.osgi/org.osgi.core
private synchronized void readObject(java.io.ObjectInputStream in) throws IOException, ClassNotFoundException {
ObjectInputStream.GetField gfields = in.readFields();
@SuppressWarnings("unchecked")
Hashtable<String, ServicePermission> hashtable = (Hashtable<String, ServicePermission>) gfields.get("permissions", null);
permissions = new HashMap<String, ServicePermission>(hashtable);
all_allowed = gfields.get("all_allowed", false);
@SuppressWarnings("unchecked")
HashMap<String, ServicePermission> fp = (HashMap<String, ServicePermission>) gfields.get("filterPermissions", null);
filterPermissions = fp;
}
}
代码示例来源:origin: org.osgi/org.osgi.core
private synchronized void readObject(java.io.ObjectInputStream in) throws IOException, ClassNotFoundException {
ObjectInputStream.GetField gfields = in.readFields();
@SuppressWarnings("unchecked")
Hashtable<String, PackagePermission> hashtable = (Hashtable<String, PackagePermission>) gfields.get("permissions", null);
permissions = new HashMap<String, PackagePermission>(hashtable);
all_allowed = gfields.get("all_allowed", false);
@SuppressWarnings("unchecked")
HashMap<String, PackagePermission> fp = (HashMap<String, PackagePermission>) gfields.get("filterPermissions", null);
filterPermissions = fp;
}
}
代码示例来源:origin: robovm/robovm
@SuppressWarnings("unchecked")
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
ObjectInputStream.GetField readFields = in.readFields();
sourceBean = readFields.get("source", null);
listeners = new CopyOnWriteArrayList<PropertyChangeListener>();
Map<String, PropertyChangeSupport> children
= (Map<String, PropertyChangeSupport>) readFields.get("children", null);
if (children != null) {
for (Map.Entry<String, PropertyChangeSupport> entry : children.entrySet()) {
for (PropertyChangeListener p : entry.getValue().listeners) {
listeners.add(new PropertyChangeListenerProxy(entry.getKey(), p));
}
}
}
PropertyChangeListener listener;
while ((listener = (PropertyChangeListener) in.readObject()) != null) {
listeners.add(listener);
}
}
代码示例来源:origin: org.osgi/org.osgi.compendium
private synchronized void readObject(java.io.ObjectInputStream in) throws IOException, ClassNotFoundException {
ObjectInputStream.GetField gfields = in.readFields();
boolean hasElement = gfields.get("hasElement", false);
if (hasElement) { // old format
permissions = new HashMap<String, ConfigurationPermission>();
permissions.put("*", new ConfigurationPermission("*", ConfigurationPermission.CONFIGURE));
all_allowed = true;
} else {
permissions = (HashMap<String, ConfigurationPermission>) gfields.get("permissions", new HashMap<String, ConfigurationPermission>());
all_allowed = gfields.get("all_allowed", false);
}
}
}
代码示例来源:origin: org.osgi/org.osgi.core
private synchronized void readObject(java.io.ObjectInputStream in) throws IOException, ClassNotFoundException {
ObjectInputStream.GetField gfields = in.readFields();
@SuppressWarnings("unchecked")
HashMap<String, CapabilityPermission> p = (HashMap<String, CapabilityPermission>) gfields.get("permissions", null);
permissions = p;
all_allowed = gfields.get("all_allowed", false);
@SuppressWarnings("unchecked")
HashMap<String, CapabilityPermission> fp = (HashMap<String, CapabilityPermission>) gfields.get("filterPermissions", null);
filterPermissions = fp;
}
}
代码示例来源:origin: robovm/robovm
private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException {
ObjectInputStream.GetField fields = stream.readFields();
countryCode = (String) fields.get("country", "");
languageCode = (String) fields.get("language", "");
variantCode = (String) fields.get("variant", "");
}
}
代码示例来源:origin: robovm/robovm
private void readObject(ObjectInputStream in) throws IOException,
ClassNotFoundException {
ObjectInputStream.GetField fields = in.readFields();
int count = fields.get("count", 0);
char[] value = (char[]) fields.get("value", null);
set(value, count);
}
}
代码示例来源:origin: robovm/robovm
private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException {
ObjectInputStream.GetField fields = stream.readFields();
int version = fields.get("serialVersionOnStream", 0);
Date date;
if (version > 0) {
date = (Date) fields.get("defaultCenturyStart", new Date());
} else {
date = new Date();
}
set2DigitYearStart(date);
formatData = (DateFormatSymbols) fields.get("formatData", null);
pattern = (String) fields.get("pattern", "");
}
}
代码示例来源:origin: robovm/robovm
private void readObject(ObjectInputStream stream) throws IOException,
ClassNotFoundException {
ObjectInputStream.GetField fields = stream.readFields();
argumentNumbers = (int[]) fields.get("argumentNumbers", null);
formats = (Format[]) fields.get("formats", null);
locale = (Locale) fields.get("locale", null);
maxOffset = fields.get("maxOffset", 0);
int[] offsets = (int[]) fields.get("offsets", null);
String pattern = (String) fields.get("pattern", null);
int length;
if (maxOffset < 0) {
length = pattern.length() > 0 ? 1 : 0;
} else {
length = maxOffset
+ (offsets[maxOffset] == pattern.length() ? 1 : 2);
}
strings = new String[length];
int last = 0;
for (int i = 0; i <= maxOffset; i++) {
strings[i] = pattern.substring(last, offsets[i]);
last = offsets[i];
}
if (maxOffset + 1 < strings.length) {
strings[strings.length - 1] = pattern.substring(last, pattern
.length());
}
}
代码示例来源:origin: robovm/robovm
private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException {
ObjectInputStream.GetField fields = stream.readFields();
int addr = fields.get("address", 0);
ipaddress = new byte[4];
Memory.pokeInt(ipaddress, 0, addr, ByteOrder.BIG_ENDIAN);
hostName = (String) fields.get("hostName", null);
family = fields.get("family", 2);
}
代码示例来源:origin: wildfly/wildfly
private void readObject(ObjectInputStream ois) throws ClassNotFoundException, IOException {
final ObjectInputStream.GetField fields = ois.readFields();
try {
final Object identifierObj = fields.get("identifier", null);
// if not null, the old *Name fields will share backreferences with the fields of the identifier at a cost of 4 bytes
final EJBIdentifier identifier = identifierObj != null ? (EJBIdentifier) identifierObj : new EJBIdentifier(
(String) fields.get("appName", null),
(String) fields.get("moduleName", null),
(String) fields.get("beanName", null),
(String) fields.get("distinctName", null)
);
viewTypeSetter.set(this, fields.get("viewType", null));
identifierSetter.set(this, identifier);
affinitySetter.set(this, fields.get("affinity", Affinity.NONE));
} catch ( IOException | RuntimeException | Error e) {
throw e;
} catch (Throwable t) {
throw new UndeclaredThrowableException(t);
}
}
内容来源于网络,如有侵权,请联系作者删除!