01: /*
02: * @(#)GetBooleanAction.java 1.13 06/10/10
03: *
04: * Copyright 1990-2006 Sun Microsystems, Inc. All Rights Reserved.
05: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER
06: *
07: * This program is free software; you can redistribute it and/or
08: * modify it under the terms of the GNU General Public License version
09: * 2 only, as published by the Free Software Foundation.
10: *
11: * This program is distributed in the hope that it will be useful, but
12: * WITHOUT ANY WARRANTY; without even the implied warranty of
13: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14: * General Public License version 2 for more details (a copy is
15: * included at /legal/license.txt).
16: *
17: * You should have received a copy of the GNU General Public License
18: * version 2 along with this work; if not, write to the Free Software
19: * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20: * 02110-1301 USA
21: *
22: * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
23: * Clara, CA 95054 or visit www.sun.com if you need additional
24: * information or have any questions.
25: *
26: */
27:
28: package sun.security.action;
29:
30: /**
31: * A convenience class for retrieving the boolean value of a system property
32: * as a privileged action.
33: *
34: * <p>An instance of this class can be used as the argument of
35: * <code>AccessController.doPrivileged</code>.
36: *
37: * <p>The following code retrieves the boolean value of the system
38: * property named <code>"prop"</code> as a privileged action: <p>
39: *
40: * <pre>
41: * boolean b = ((Boolean)java.security.AccessController.doPrivileged(
42: * new GetBooleanAction("prop"))).booleanValue();
43: * </pre>
44: *
45: * @author Roland Schemers
46: * @version 1.6, 02/02/00
47: * @see java.security.PrivilegedAction
48: * @see java.security.AccessController
49: * @since JDK1.2
50: */
51:
52: public class GetBooleanAction implements java.security.PrivilegedAction {
53: private String theProp;
54:
55: /**
56: * Constructor that takes the name of the system property whose boolean
57: * value needs to be determined.
58: *
59: * @param theProp the name of the system property.
60: */
61: public GetBooleanAction(String theProp) {
62: this .theProp = theProp;
63: }
64:
65: /**
66: * Determines the boolean value of the system property whose name was
67: * specified in the constructor.
68: *
69: * @return the <code>Boolean</code> value of the system property.
70: */
71: public Object run() {
72: return new Boolean(Boolean.getBoolean(theProp));
73: }
74: }
|