01: /*
02: * Copyright 1997-2002 Sun Microsystems, Inc. All Rights Reserved.
03: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
04: *
05: * This code is free software; you can redistribute it and/or modify it
06: * under the terms of the GNU General Public License version 2 only, as
07: * published by the Free Software Foundation. Sun designates this
08: * particular file as subject to the "Classpath" exception as provided
09: * by Sun 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
22: * CA 95054 USA or visit www.sun.com if you need additional information or
23: * have any questions.
24: */
25:
26: package sun.awt.image;
27:
28: import java.awt.image.ImageConsumer;
29:
30: class ImageConsumerQueue {
31: ImageConsumerQueue next;
32:
33: ImageConsumer consumer;
34: boolean interested;
35:
36: Object securityContext;
37: boolean secure;
38:
39: static ImageConsumerQueue removeConsumer(ImageConsumerQueue cqbase,
40: ImageConsumer ic, boolean stillinterested) {
41: ImageConsumerQueue cqprev = null;
42: for (ImageConsumerQueue cq = cqbase; cq != null; cq = cq.next) {
43: if (cq.consumer == ic) {
44: if (cqprev == null) {
45: cqbase = cq.next;
46: } else {
47: cqprev.next = cq.next;
48: }
49: cq.interested = stillinterested;
50: break;
51: }
52: cqprev = cq;
53: }
54: return cqbase;
55: }
56:
57: static boolean isConsumer(ImageConsumerQueue cqbase,
58: ImageConsumer ic) {
59: for (ImageConsumerQueue cq = cqbase; cq != null; cq = cq.next) {
60: if (cq.consumer == ic) {
61: return true;
62: }
63: }
64: return false;
65: }
66:
67: ImageConsumerQueue(InputStreamImageSource src, ImageConsumer ic) {
68: consumer = ic;
69: interested = true;
70: // ImageReps do their own security at access time.
71: if (ic instanceof ImageRepresentation) {
72: ImageRepresentation ir = (ImageRepresentation) ic;
73: if (ir.image.source != src) {
74: throw new SecurityException(
75: "ImageRep added to wrong image source");
76: }
77: secure = true;
78: } else {
79: SecurityManager security = System.getSecurityManager();
80: if (security != null) {
81: securityContext = security.getSecurityContext();
82: } else {
83: securityContext = null;
84: }
85: }
86: }
87:
88: public String toString() {
89: return ("["
90: + consumer
91: + ", "
92: + (interested ? "" : "not ")
93: + "interested"
94: + (securityContext != null ? ", " + securityContext
95: : "") + "]");
96: }
97: }
|