当前位置: 首页>>代码示例>>Java>>正文


Java ObjectInputStream.readFields方法代码示例

本文整理汇总了Java中java.io.ObjectInputStream.readFields方法的典型用法代码示例。如果您正苦于以下问题:Java ObjectInputStream.readFields方法的具体用法?Java ObjectInputStream.readFields怎么用?Java ObjectInputStream.readFields使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.io.ObjectInputStream的用法示例。


在下文中一共展示了ObjectInputStream.readFields方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: 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();
  }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:24,代码来源:InvalidTargetObjectTypeException.java

示例2: readObject

import java.io.ObjectInputStream; //导入方法依赖的package包/类
private void readObject(ObjectInputStream s) throws ClassNotFoundException, IOException {
    this.map = new PropertyChangeListenerMap();

    ObjectInputStream.GetField fields = s.readFields();

    @SuppressWarnings("unchecked")
    Hashtable<String, PropertyChangeSupport> children = (Hashtable<String, PropertyChangeSupport>) fields.get("children", null);
    this.source = fields.get("source", null);
    fields.get("propertyChangeSupportSerializedDataVersion", 2);

    Object listenerOrNull;
    while (null != (listenerOrNull = s.readObject())) {
        this.map.add(null, (PropertyChangeListener)listenerOrNull);
    }
    if (children != null) {
        for (Entry<String, PropertyChangeSupport> entry : children.entrySet()) {
            for (PropertyChangeListener listener : entry.getValue().getPropertyChangeListeners()) {
                this.map.add(entry.getKey(), listener);
            }
        }
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:23,代码来源:PropertyChangeSupport.java

示例3: readObject

import java.io.ObjectInputStream; //导入方法依赖的package包/类
/**
 * Deserializes a {@link RoleResult} 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();
    roleList = (RoleList) fields.get("myRoleList", null);
    if (fields.defaulted("myRoleList"))
    {
      throw new NullPointerException("myRoleList");
    }
    unresolvedRoleList = (RoleUnresolvedList) fields.get("myRoleUnresList", null);
    if (fields.defaulted("myRoleUnresList"))
    {
      throw new NullPointerException("myRoleUnresList");
    }
  }
  else
  {
    // Read an object serialized in the new serial form
    //
    in.defaultReadObject();
  }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:29,代码来源:RoleResult.java

示例4: 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);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:21,代码来源:InetSocketAddress.java

示例5: readObject

import java.io.ObjectInputStream; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
private void readObject(ObjectInputStream in)
                    throws IOException, ClassNotFoundException {
    // We have to read serialized fields first.
    ObjectInputStream.GetField gf = in.readFields();
    name = (String)gf.get("name", null);
    entities = (NamedNodeMapImpl)gf.get("entities", null);
    notations = (NamedNodeMapImpl)gf.get("notations", null);
    elements = (NamedNodeMapImpl)gf.get("elements", null);
    publicID = (String)gf.get("publicID", null);
    systemID = (String)gf.get("systemID", null);
    internalSubset = (String)gf.get("internalSubset", null);
    doctypeNumber = gf.get("doctypeNumber", 0);

    Hashtable<String, UserDataRecord> ud =
            (Hashtable<String, UserDataRecord>)gf.get("userData", null);

    //convert the Hashtable back to HashMap
    if (ud != null) userData = new HashMap<>(ud);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:21,代码来源:DocumentTypeImpl.java

示例6: readObject

import java.io.ObjectInputStream; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
private void readObject(ObjectInputStream in)
    throws IOException, ClassNotFoundException
{
    // Don't call defaultReadObject()

    // Read in serialized fields
    ObjectInputStream.GetField gfields = in.readFields();

    // Get the one we want
    Vector<Permission> permissions =
            (Vector<Permission>)gfields.get("permissions", null);
    perms = new ArrayList<Permission>(permissions.size());
    perms.addAll(permissions);
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:16,代码来源:ServicePermission.java

示例7: readObject

import java.io.ObjectInputStream; //导入方法依赖的package包/类
@SuppressWarnings({ "unchecked", "deprecation" })
private void readObject(ObjectInputStream is) throws ClassNotFoundException, IOException
{
    GetField fields = is.readFields();
    if (fields.defaulted("versionsByLabel"))
    {
        // This is a V2.2 class
        // The old 'rootVersion' maps to the current 'rootVersion'
        this.versionsByLabel = (HashMap<String, Version>) fields.get("versions", new HashMap<String, Version>());
        // The old 'versionHistory' maps to the current 'versionHistory'
        this.versionHistory = (HashMap<String, String>) fields.get("versionHistory", new HashMap<String, String>());
        // Need this comparator as versionsByLabel is not a LinkedHashMap in this version 
        this.versionComparatorDesc = new VersionLabelComparator(); 
    }
    else if (fields.defaulted("versionComparatorDesc"))
    {
        // This is a V3.1.0 class
        // The old 'rootVersion' maps to the current 'rootVersion'
        this.versionsByLabel = (HashMap<String, Version>) fields.get("versionsByLabel", new HashMap<String, Version>());
        // The old 'versionHistory' maps to the current 'versionHistory'
        this.versionHistory = (HashMap<String, String>) fields.get("versionHistory", new HashMap<String, String>());
        // Need this comparator as versionsByLabel is not a LinkedHashMap in this version 
        this.versionComparatorDesc = new VersionLabelComparator(); 
    }
    else
    {
        // This is a V4.1.3 (and 4.0.2 HF) class
        // The old 'rootVersion' maps to the current 'rootVersion'
        this.versionsByLabel = (Map<String, Version>) fields.get("versionsByLabel", new LinkedHashMap<String, Version>());
        // The old 'versionHistory' maps to the current 'versionHistory'
        this.versionHistory = (HashMap<String, String>) fields.get("versionHistory", new HashMap<String, String>());
        this.versionComparatorDesc = (Comparator<Version>) fields.get("versionComparatorDesc", null); 
    }
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:35,代码来源:VersionHistoryImpl.java

示例8: 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 HashMap<String, List<UnresolvedPermission>>(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 ArrayList<>(vec.size());
        list.addAll(vec);

        // Add to Hashtable being serialized
        perms.put(e.getKey(), list);
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:29,代码来源:UnresolvedPermissionCollection.java

示例9: readObject

import java.io.ObjectInputStream; //导入方法依赖的package包/类
private void readObject(ObjectInputStream ois) throws IOException, ClassNotFoundException {
    ObjectInputStream.GetField gf = ois.readFields();
    String principalName = (String)gf.get("name", null);
    try {
        validate(principalName);
        this.name = principalName;
    } catch (NullPointerException e) {
        throw new InvalidObjectException(e.getMessage());
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:11,代码来源:JMXPrincipal.java

示例10: readObject

import java.io.ObjectInputStream; //导入方法依赖的package包/类
private void readObject(ObjectInputStream in)
    throws IOException, ClassNotFoundException
{
    // Don't call in.defaultReadObject()

    // Read in serialized fields
    ObjectInputStream.GetField gfields = in.readFields();

    // Get the one we want
    @SuppressWarnings("unchecked")
    Vector<SocketPermission> permissions = (Vector<SocketPermission>)gfields.get("permissions", null);
    perms = new ArrayList<SocketPermission>(permissions.size());
    perms.addAll(permissions);
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:15,代码来源:SocketPermission.java

示例11: readObject

import java.io.ObjectInputStream; //导入方法依赖的package包/类
/**
 * Reads the "cause" field from the stream.
 * And initializes the "cause" if it wasn't
 * done before.
 *
 * @param in stream used for deserialization
 * @throws IOException thrown by <code>ObjectInputStream</code>
 * @throws ClassNotFoundException  thrown by <code>ObjectInputStream</code>
 */
private void readObject(ObjectInputStream in)
        throws IOException, ClassNotFoundException
{
    ObjectInputStream.GetField fields = in.readFields();
    Throwable scause = (Throwable) fields.get("cause", null);

    if (super.getCause() == null && scause != null) {
        try {
            super.initCause(scause);
        } catch(IllegalStateException e) {
            throw new InvalidClassException("Inconsistent state: two causes");
        }
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:24,代码来源:XPathException.java

示例12: readObject

import java.io.ObjectInputStream; //导入方法依赖的package包/类
/**
 *  Overrides the default readObject implementation since we decided
 *  it would be cleaner not to serialize the entire tranformer
 *  factory.  [ ref bugzilla 12317 ]
 *  We need to check if the user defined class for URIResolver also
 *  implemented Serializable
 *  if yes then we need to deserialize the URIResolver
 *  Fix for bugzilla bug 22438
 */
@SuppressWarnings("unchecked")
private void  readObject(ObjectInputStream is)
  throws IOException, ClassNotFoundException
{
    SecurityManager security = System.getSecurityManager();
    if (security != null){
        String temp = SecuritySupport.getSystemProperty(DESERIALIZE_TRANSLET);
        if (temp == null || !(temp.length()==0 || temp.equalsIgnoreCase("true"))) {
            ErrorMsg err = new ErrorMsg(ErrorMsg.DESERIALIZE_TRANSLET_ERR);
            throw new UnsupportedOperationException(err.toString());
        }
    }

    // We have to read serialized fields first.
    ObjectInputStream.GetField gf = is.readFields();
    _name = (String)gf.get("_name", null);
    _bytecodes = (byte[][])gf.get("_bytecodes", null);
    _class = (Class[])gf.get("_class", null);
    _transletIndex = gf.get("_transletIndex", -1);

    _outputProperties = (Properties)gf.get("_outputProperties", null);
    _indentNumber = gf.get("_indentNumber", 0);

    if (is.readBoolean()) {
        _uriResolver = (URIResolver) is.readObject();
    }

    _tfactory = new TransformerFactoryImpl();
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:39,代码来源:TemplatesImpl.java

示例13: readObject

import java.io.ObjectInputStream; //导入方法依赖的package包/类
/**
 * Reads the "cause" field from the stream.
 * And initializes the "cause" if it wasn't
 * done before.
 *
 * @param in stream used for deserialization
 * @throws IOException thrown by {@code ObjectInputStream}
 * @throws ClassNotFoundException  thrown by {@code ObjectInputStream}
 */
private void readObject(ObjectInputStream in)
        throws IOException, ClassNotFoundException
{
    ObjectInputStream.GetField fields = in.readFields();
    Throwable scause = (Throwable) fields.get("cause", null);

    if (super.getCause() == null && scause != null) {
        try {
            super.initCause(scause);
        } catch(IllegalStateException e) {
            throw new InvalidClassException("Inconsistent state: two causes");
        }
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:24,代码来源:XPathException.java

示例14: 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);
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:28,代码来源:UnresolvedPermissionCollection.java

示例15: readObject

import java.io.ObjectInputStream; //导入方法依赖的package包/类
private void readObject(ObjectInputStream s)
    throws IOException, ClassNotFoundException {
    ObjectInputStream.GetField f = s.readFields();

    int newDesiredLocationX = f.get("desiredLocationX", 0);
    int newDesiredLocationY = f.get("desiredLocationY", 0);
    Point p = adjustPopupLocationToFitScreen(
            newDesiredLocationX, newDesiredLocationY);
    desiredLocationX = p.x;
    desiredLocationY = p.y;

    label = (String) f.get("label", null);
    paintBorder = f.get("paintBorder", false);
    margin = (Insets) f.get("margin", null);
    lightWeightPopup = f.get("lightWeightPopup", false);
    selectionModel = (SingleSelectionModel) f.get("selectionModel", null);

    Vector<?>          values = (Vector)s.readObject();
    int             indexCounter = 0;
    int             maxCounter = values.size();

    if(indexCounter < maxCounter && values.elementAt(indexCounter).
       equals("invoker")) {
        invoker = (Component)values.elementAt(++indexCounter);
        indexCounter++;
    }
    if(indexCounter < maxCounter && values.elementAt(indexCounter).
       equals("popup")) {
        popup = (Popup)values.elementAt(++indexCounter);
        indexCounter++;
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:33,代码来源:JPopupMenu.java


注:本文中的java.io.ObjectInputStream.readFields方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。