Ejemplo n.º 1
0
        /// <summary>
        /// Reads default serializable fields to stream. </summary>
        /// <exception cref="HeadlessException"> if
        /// <code>GraphicsEnvironment.isHeadless()</code> returns
        /// <code>true</code> </exception>
        /// <seealso cref= java.awt.GraphicsEnvironment#isHeadless </seealso>
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: private void readObject(java.io.ObjectInputStream s) throws ClassNotFoundException, java.io.IOException, HeadlessException
        private void ReadObject(ObjectInputStream s)
        {
            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_Renamed = f.Get("scrollbarDisplayPolicy", SCROLLBARS_AS_NEEDED);
            HAdjustable_Renamed            = (ScrollPaneAdjustable)f.Get("hAdjustable", null);
            VAdjustable_Renamed            = (ScrollPaneAdjustable)f.Get("vAdjustable", null);

            // Since 1.4
            WheelScrollingEnabled_Renamed = 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
            //      }
        }
        /*
         * Reads in a Hashtable in which the values are Vectors of
         * UnresolvedPermissions and saves them in the perms field.
         */
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException
        private void ReadObject(ObjectInputStream @in)
        {
            // Don't call defaultReadObject()

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

            // Get permissions
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @SuppressWarnings("unchecked") Hashtable<String, Vector<UnresolvedPermission>> permissions = (Hashtable<String, Vector<UnresolvedPermission>>) gfields.get("permissions", null);
            Dictionary <String, Vector <UnresolvedPermission> > permissions = (Dictionary <String, Vector <UnresolvedPermission> >)gfields.Get("permissions", null);

            // writeObject writes a Hashtable<String, Vector<UnresolvedPermission>>
            // for the permissions key, so this cast is safe, unless the data is corrupt.
            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();

            foreach (Map_Entry <String, Vector <UnresolvedPermission> > e in set)
            {
                // Convert Vector into ArrayList
                Vector <UnresolvedPermission> vec  = e.Value;
                List <UnresolvedPermission>   list = new List <UnresolvedPermission>(vec.Size());
                list.AddAll(vec);

                // Add to Hashtable being serialized
                Perms.Put(e.Key, list);
            }
        }
Ejemplo n.º 3
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: private void readObject(java.io.ObjectInputStream s) throws ClassNotFoundException, java.io.IOException
        private void ReadObject(ObjectInputStream s)
        {
            this.Map = new PropertyChangeListenerMap();

            ObjectInputStream.GetField fields = s.ReadFields();

//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @SuppressWarnings("unchecked") java.util.Hashtable<String, PropertyChangeSupport> children = (java.util.Hashtable<String, PropertyChangeSupport>) fields.get("children", null);
            Dictionary <String, PropertyChangeSupport> children = (Dictionary <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)
            {
                foreach (Map_Entry <String, PropertyChangeSupport> entry in children)
                {
                    foreach (PropertyChangeListener listener in entry.Value.PropertyChangeListeners)
                    {
                        this.Map.Add(entry.Key, listener);
                    }
                }
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Reads serializable fields from stream.
        /// </summary>
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: private void readObject(java.io.ObjectInputStream s) throws ClassNotFoundException, java.io.IOException
        private void ReadObject(ObjectInputStream s)
        {
            ObjectInputStream.GetField f = s.ReadFields();

            Hgap_Renamed = f.Get("hgap", 0);
            Vgap_Renamed = f.Get("vgap", 0);

            if (f.Defaulted("vector"))
            {
                //  pre-1.4 stream
                Dictionary <String, Component> tab = (Hashtable)f.Get("tab", null);
                Vector = new List <>();
                if (tab != null && tab.Count > 0)
                {
                    for (IEnumerator <String> e = tab.Keys.GetEnumerator(); e.MoveNext();)
                    {
                        String    key  = (String)e.Current;
                        Component comp = (Component)tab[key];
                        Vector.Add(new Card(this, key, comp));
                        if (comp.Visible)
                        {
                            CurrentCard = Vector.Count - 1;
                        }
                    }
                }
            }
            else
            {
                Vector      = (ArrayList)f.Get("vector", null);
                CurrentCard = f.Get("currentCard", 0);
            }
        }
Ejemplo n.º 5
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException
        private void ReadObject(ObjectInputStream @in)
        {
            // Don't call defaultReadObject()
            ObjectInputStream.GetField oisFields = @in.ReadFields();
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final String oisHostname = (String)oisFields.get("hostname", null);
            String oisHostname = (String)oisFields.Get("hostname", null);
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final InetAddress oisAddr = (InetAddress)oisFields.get("addr", null);
            InetAddress oisAddr = (InetAddress)oisFields.Get("addr", null);
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final int oisPort = oisFields.get("port", -1);
            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);
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Deserializes this <code>DropTarget</code>. This method first performs
        /// default deserialization for all non-<code>transient</code> fields. An
        /// attempt is then made to deserialize this object's
        /// <code>DropTargetListener</code> as well. This is first attempted by
        /// deserializing the field <code>dtListener</code>, because, in releases
        /// prior to 1.4, a non-<code>transient</code> field of this name stored the
        /// <code>DropTargetListener</code>. If this fails, the next object in the
        /// stream is used instead.
        ///
        /// @since 1.4
        /// </summary>
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: private void readObject(java.io.ObjectInputStream s) throws ClassNotFoundException, java.io.IOException
        private void ReadObject(ObjectInputStream s)
        {
            ObjectInputStream.GetField f = s.ReadFields();

            try
            {
                DropTargetContext_Renamed = (DropTargetContext)f.Get("dropTargetContext", null);
            }
            catch (IllegalArgumentException)
            {
                // Pre-1.4 support. 'dropTargetContext' was previously transient
            }
            if (DropTargetContext_Renamed == null)
            {
                DropTargetContext_Renamed = CreateDropTargetContext();
            }

            Component_Renamed = (Component)f.Get("component", null);
            Actions           = f.Get("actions", DnDConstants.ACTION_COPY_OR_MOVE);
            Active_Renamed    = f.Get("active", true);

            // Pre-1.4 support. 'dtListener' was previously non-transient
            try
            {
                DtListener = (DropTargetListener)f.Get("dtListener", null);
            }
            catch (IllegalArgumentException)
            {
                // 1.4-compatible byte stream. 'dtListener' was written explicitly
                DtListener = (DropTargetListener)s.ReadObject();
            }
        }
Ejemplo n.º 7
0
        /// <summary>
        /// restore the state of this object from stream
        /// </summary>
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: private void readObject(java.io.ObjectInputStream s) throws java.io.IOException, ClassNotFoundException
        private void ReadObject(ObjectInputStream s)
        {
            ObjectInputStream.GetField fields = s.ReadFields();
            String actions = (String)fields.Get("actions", null);

            Init(actions);
        }
Ejemplo n.º 8
0
        /*
         * Reads in a Hashtable of Class/PermissionCollections and saves them in the
         * permsMap field. Reads in allPermission.
         */
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException
        private void ReadObject(ObjectInputStream @in)
        {
            // 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.
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @SuppressWarnings("unchecked") java.util.Hashtable<Class, PermissionCollection> perms = (java.util.Hashtable<Class, PermissionCollection>)gfields.get("perms", null);
            Dictionary <Class, PermissionCollection> perms = (Dictionary <Class, PermissionCollection>)gfields.Get("perms", null);

            PermsMap = new Dictionary <Class, PermissionCollection>(perms.Count * 2);
//JAVA TO C# CONVERTER TODO TASK: There is no .NET Dictionary equivalent to the Java 'putAll' method:
            PermsMap.putAll(perms);

            // Set hasUnresolved
            UnresolvedPermissionCollection uc = (UnresolvedPermissionCollection)PermsMap[typeof(UnresolvedPermission)];

//JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops:
            HasUnresolved = (uc != null && uc.Elements().hasMoreElements());
        }
Ejemplo n.º 9
0
        /// <summary>
        /// readObject is called to restore the state of the
        /// {@code BatchUpdateException} from a stream.
        /// </summary>
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: private void readObject(java.io.ObjectInputStream s) throws java.io.IOException, ClassNotFoundException
        private void ReadObject(ObjectInputStream s)
        {
            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_Renamed = tmp.clone();
            }
            if (tmp2 != null)
            {
                LongUpdateCounts = tmp2.clone();
            }
            if (UpdateCounts_Renamed == null && LongUpdateCounts != null)
            {
                UpdateCounts_Renamed = CopyUpdateCount(LongUpdateCounts);
            }
            if (LongUpdateCounts == null && UpdateCounts_Renamed != null)
            {
                LongUpdateCounts = CopyUpdateCount(UpdateCounts_Renamed);
            }
        }
Ejemplo n.º 10
0
        /// <summary>
        /// Deserializes this <code>DragSourceContext</code>. This method first
        /// performs default deserialization for all non-<code>transient</code>
        /// fields. This object's <code>Transferable</code> and
        /// <code>DragSourceListener</code> are then deserialized as well by using
        /// the next two objects in the stream. If the resulting
        /// <code>Transferable</code> is <code>null</code>, this object's
        /// <code>Transferable</code> is set to a dummy <code>Transferable</code>
        /// which supports no <code>DataFlavor</code>s.
        ///
        /// @since 1.4
        /// </summary>
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: private void readObject(java.io.ObjectInputStream s) throws ClassNotFoundException, java.io.IOException
        private void ReadObject(ObjectInputStream s)
        {
            ObjectInputStream.GetField f = s.ReadFields();

            DragGestureEvent newTrigger = (DragGestureEvent)f.Get("trigger", null);

            if (newTrigger == null)
            {
                throw new InvalidObjectException("Null trigger");
            }
            if (newTrigger.DragSource == null)
            {
                throw new InvalidObjectException("Null DragSource");
            }
            if (newTrigger.Component == null)
            {
                throw new InvalidObjectException("Null trigger component");
            }

            int newSourceActions = f.Get("sourceActions", 0) & (DnDConstants.ACTION_COPY_OR_MOVE | DnDConstants.ACTION_LINK);

            if (newSourceActions == DnDConstants.ACTION_NONE)
            {
                throw new InvalidObjectException("Invalid source actions");
            }
            int triggerActions = newTrigger.DragAction;

            if (triggerActions != DnDConstants.ACTION_COPY && triggerActions != DnDConstants.ACTION_MOVE && triggerActions != DnDConstants.ACTION_LINK)
            {
                throw new InvalidObjectException("No drag action");
            }
            Trigger_Renamed = newTrigger;

            Cursor_Renamed        = (Cursor)f.Get("cursor", null);
            UseCustomCursor       = f.Get("useCustomCursor", false);
            SourceActions_Renamed = newSourceActions;

            Transferable_Renamed = (Transferable)s.ReadObject();
            Listener             = (DragSourceListener)s.ReadObject();

            // Implementation assumes 'transferable' is never null.
            if (Transferable_Renamed == null)
            {
                if (EmptyTransferable == null)
                {
                    EmptyTransferable = new TransferableAnonymousInnerClassHelper(this);
                }
                Transferable_Renamed = EmptyTransferable;
            }
        }
Ejemplo n.º 11
0
        /// <summary>
        /// Deserializes this <code>DragGestureRecognizer</code>. This method first
        /// performs default deserialization for all non-<code>transient</code>
        /// fields. This object's <code>DragGestureListener</code> is then
        /// deserialized as well by using the next object in the stream.
        ///
        /// @since 1.4
        /// </summary>
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @SuppressWarnings("unchecked") private void readObject(java.io.ObjectInputStream s) throws ClassNotFoundException, java.io.IOException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
        private void ReadObject(ObjectInputStream s)
        {
            ObjectInputStream.GetField f = s.ReadFields();

            DragSource newDragSource = (DragSource)f.Get("dragSource", null);

            if (newDragSource == null)
            {
                throw new InvalidObjectException("null DragSource");
            }
            DragSource_Renamed = newDragSource;

            Component_Renamed     = (Component)f.Get("component", null);
            SourceActions_Renamed = f.Get("sourceActions", 0) & (DnDConstants.ACTION_COPY_OR_MOVE | DnDConstants.ACTION_LINK);
            Events = (List <InputEvent>)f.Get("events", new List <>(1));

            DragGestureListener = (DragGestureListener)s.ReadObject();
        }
Ejemplo n.º 12
0
        /*
         * Reads in a Hashtable of Permission/Permission and saves them in the
         * permsMap field.
         */
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException
        private void ReadObject(ObjectInputStream @in)
        {
            // Don't call defaultReadObject()

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

            // Get permissions
            // writeObject writes a Hashtable<Class<?>, PermissionCollection> for
            // the perms key, so this cast is safe, unless the data is corrupt.
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @SuppressWarnings("unchecked") java.util.Hashtable<Permission, Permission> perms = (java.util.Hashtable<Permission, Permission>)gfields.get("perms", null);
            Dictionary <Permission, Permission> perms = (Dictionary <Permission, Permission>)gfields.Get("perms", null);

            PermsMap = new Dictionary <Permission, Permission>(perms.Count * 2);
//JAVA TO C# CONVERTER TODO TASK: There is no .NET Dictionary equivalent to the Java 'putAll' method:
            PermsMap.putAll(perms);
        }
Ejemplo n.º 13
0
        /*
         * Reads in a Hashtable of PropertyPermissions and saves them in the
         * perms field. Reads in all_allowed.
         */
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException
        private void ReadObject(ObjectInputStream @in)
        {
            // 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
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @SuppressWarnings("unchecked") java.util.Hashtable<String, PropertyPermission> permissions = (java.util.Hashtable<String, PropertyPermission>)gfields.get("permissions", null);
            Dictionary <String, PropertyPermission> permissions = (Dictionary <String, PropertyPermission>)gfields.Get("permissions", null);

            Perms = new Dictionary <>(permissions.Size() * 2);
//JAVA TO C# CONVERTER TODO TASK: There is no .NET Dictionary equivalent to the Java 'putAll' method:
            Perms.putAll(permissions);
        }
Ejemplo n.º 14
0
        /// <summary>
        /// readObject is called to restore the state of the
        /// BasicPermissionCollection from a stream.
        /// </summary>
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException
        private void ReadObject(ObjectInputStream @in)
        {
            // Don't call defaultReadObject()

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

            // Get permissions
            // writeObject writes a Hashtable<String, Permission> for the
            // permissions key, so this cast is safe, unless the data is corrupt.
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @SuppressWarnings("unchecked") java.util.Hashtable<String, Permission> permissions = (java.util.Hashtable<String, Permission>)gfields.get("permissions", null);
            Dictionary <String, Permission> permissions = (Dictionary <String, Permission>)gfields.Get("permissions", null);

            Perms = new Dictionary <String, Permission>(permissions.Count * 2);
//JAVA TO C# CONVERTER TODO TASK: There is no .NET Dictionary equivalent to the Java 'putAll' method:
            Perms.putAll(permissions);

            // Get all_allowed
            All_allowed = gfields.Get("all_allowed", false);

            // Get permClass
            PermClass = (Class)gfields.Get("permClass", null);

            if (PermClass == null)
            {
                // set permClass
                IEnumerator <Permission> e = permissions.Values.GetEnumerator();
//JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops:
                if (e.hasMoreElements())
                {
//JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops:
                    Permission p = e.nextElement();
                    PermClass = p.GetType();
                }
            }
        }
Ejemplo n.º 15
0
        /// <summary>
        /// restore the state of this object from stream
        /// including the scope information, only if the
        /// scoped interface name is valid on this system
        /// </summary>
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: private void readObject(java.io.ObjectInputStream s) throws java.io.IOException, ClassNotFoundException
        private void ReadObject(ObjectInputStream s)
        {
            NetworkInterface scope_ifname = null;

            if (this.GetType().ClassLoader != null)
            {
                throw new SecurityException("invalid address type");
            }

            ObjectInputStream.GetField gf = s.ReadFields();
            sbyte[] ipaddress             = (sbyte[])gf.Get("ipaddress", null);
            int     scope_id         = (int)gf.Get("scope_id", -1);
            bool    scope_id_set     = (bool)gf.Get("scope_id_set", false);
            bool    scope_ifname_set = (bool)gf.Get("scope_ifname_set", false);
            String  ifname           = (String)gf.Get("ifname", null);

            if (ifname != null && !"".Equals(ifname))
            {
                try
                {
                    scope_ifname = NetworkInterface.GetByName(ifname);
                    if (scope_ifname == null)
                    {
                        /* the interface does not exist on this system, so we clear
                         * the scope information completely */
                        scope_id_set     = false;
                        scope_ifname_set = false;
                        scope_id         = 0;
                    }
                    else
                    {
                        scope_ifname_set = true;
                        try
                        {
                            scope_id = DeriveNumericScope(ipaddress, scope_ifname);
                        }
                        catch (UnknownHostException)
                        {
                            // typically should not happen, but it may be that
                            // the machine being used for deserialization has
                            // the same interface name but without IPv6 configured.
                        }
                    }
                }
                catch (SocketException)
                {
                }
            }

            /* if ifname was not supplied, then the numeric info is used */

            ipaddress = ipaddress.clone();

            // Check that our invariants are satisfied
            if (ipaddress.Length != INADDRSZ)
            {
                throw new InvalidObjectException("invalid address length: " + ipaddress.Length);
            }

            if (Holder_Renamed.Family != IPv6)
            {
                throw new InvalidObjectException("invalid address family type");
            }

            Inet6AddressHolder h = new Inet6AddressHolder(this, ipaddress, scope_id, scope_id_set, scope_ifname, scope_ifname_set);

            UNSAFE.putObject(this, FIELDS_OFFSET, h);
        }