blob: e997ab0a61b91289b8594a3a6da36cba241f8a66 [file] [log] [blame]
J. Duke319a3b92007-12-01 00:00:00 +00001/*
2 * Copyright 1997-2002 Sun Microsystems, Inc. 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. Sun designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * 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
26package sun.awt.image;
27
28import java.awt.image.ImageConsumer;
29
30class 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,
41 boolean stillinterested)
42 {
43 ImageConsumerQueue cqprev = null;
44 for (ImageConsumerQueue cq = cqbase; cq != null; cq = cq.next) {
45 if (cq.consumer == ic) {
46 if (cqprev == null) {
47 cqbase = cq.next;
48 } else {
49 cqprev.next = cq.next;
50 }
51 cq.interested = stillinterested;
52 break;
53 }
54 cqprev = cq;
55 }
56 return cqbase;
57 }
58
59 static boolean isConsumer(ImageConsumerQueue cqbase, ImageConsumer ic) {
60 for (ImageConsumerQueue cq = cqbase; cq != null; cq = cq.next) {
61 if (cq.consumer == ic) {
62 return true;
63 }
64 }
65 return false;
66 }
67
68 ImageConsumerQueue(InputStreamImageSource src, ImageConsumer ic) {
69 consumer = ic;
70 interested = true;
71 // ImageReps do their own security at access time.
72 if (ic instanceof ImageRepresentation) {
73 ImageRepresentation ir = (ImageRepresentation) ic;
74 if (ir.image.source != src) {
75 throw new SecurityException("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 ("[" + consumer +
90 ", " + (interested ? "" : "not ") + "interested" +
91 (securityContext != null ? ", " + securityContext : "") +
92 "]");
93 }
94}