1 /*
2 * Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
340 if (newComponent == null) {
341 throw new InvalidObjectException("null component");
342 }
343 component = newComponent;
344
345 Point newOrigin = (Point)f.get("origin", null);
346 if (newOrigin == null) {
347 throw new InvalidObjectException("null origin");
348 }
349 origin = newOrigin;
350
351 int newAction = f.get("action", 0);
352 if (newAction != DnDConstants.ACTION_COPY &&
353 newAction != DnDConstants.ACTION_MOVE &&
354 newAction != DnDConstants.ACTION_LINK) {
355 throw new InvalidObjectException("bad action");
356 }
357 action = newAction;
358
359 // Pre-1.4 support. 'events' was previously non-transient
360 List newEvents;
361 try {
362 newEvents = (List)f.get("events", null);
363 } catch (IllegalArgumentException e) {
364 // 1.4-compatible byte stream. 'events' was written explicitly
365 newEvents = (List)s.readObject();
366 }
367
368 // Implementation assumes 'events' is never null.
369 if (newEvents != null && newEvents.isEmpty()) {
370 // Constructor treats empty events list as invalid value
371 // Throw exception if serialized list is empty
372 throw new InvalidObjectException("empty list of events");
373 } else if (newEvents == null) {
374 newEvents = Collections.emptyList();
375 }
376 events = newEvents;
377 }
378
379 /*
|
1 /*
2 * Copyright (c) 1998, 2014, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
340 if (newComponent == null) {
341 throw new InvalidObjectException("null component");
342 }
343 component = newComponent;
344
345 Point newOrigin = (Point)f.get("origin", null);
346 if (newOrigin == null) {
347 throw new InvalidObjectException("null origin");
348 }
349 origin = newOrigin;
350
351 int newAction = f.get("action", 0);
352 if (newAction != DnDConstants.ACTION_COPY &&
353 newAction != DnDConstants.ACTION_MOVE &&
354 newAction != DnDConstants.ACTION_LINK) {
355 throw new InvalidObjectException("bad action");
356 }
357 action = newAction;
358
359 // Pre-1.4 support. 'events' was previously non-transient
360 @SuppressWarnings("rawtypes")
361 List newEvents;
362 try {
363 newEvents = (List)f.get("events", null);
364 } catch (IllegalArgumentException e) {
365 // 1.4-compatible byte stream. 'events' was written explicitly
366 newEvents = (List)s.readObject();
367 }
368
369 // Implementation assumes 'events' is never null.
370 if (newEvents != null && newEvents.isEmpty()) {
371 // Constructor treats empty events list as invalid value
372 // Throw exception if serialized list is empty
373 throw new InvalidObjectException("empty list of events");
374 } else if (newEvents == null) {
375 newEvents = Collections.emptyList();
376 }
377 events = newEvents;
378 }
379
380 /*
|