com.ibm.security12.sun.security.action
Class GetLongAction

java.lang.Object
  |
  +--com.ibm.security12.sun.security.action.GetLongAction

public class GetLongAction
extends Object
implements PrivilegedAction

A convenience class for retrieving the Long value of a system property as a privileged action.

An instance of this class can be used as the argument of AccessController.doPrivileged.

The following code retrieves the Long value of the system property named "prop" as a privileged action. Since it does not pass a default value to be used in case the property "prop" is not defined, it has to check the result for null:

 Long tmp = (Integer)java.security.AccessController.doPrivileged
     (new sun.security.action.GetLongAction("prop"));
 long l;
 if (tmp != null) {
     l = tmp.longValue();
 }
 

The following code retrieves the Long value of the system property named "prop" as a privileged action, and also passes a default value to be used in case the property "prop" is not defined:

 long l = ((Long)java.security.AccessController.doPrivileged(
                         new GetLongAction("prop"))).longValue();
 

Since:
JDK1.2
Version:
1.4, 09/18/98
Author:
Roland Schemers
See Also:
java.security.PrivilegedAction, java.security.AccessController

Constructor Summary
GetLongAction(String theProp)
          Constructor that takes the name of the system property whose Long value needs to be determined.
GetLongAction(String theProp, long defaultVal)
          Constructor that takes the name of the system property and the default value of that property.
 
Method Summary
 Object run()
          Determines the Long value of the system property whose name was specified in the constructor.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GetLongAction

public GetLongAction(String theProp)
Constructor that takes the name of the system property whose Long value needs to be determined.
Parameters:
theProp - the name of the system property.

GetLongAction

public GetLongAction(String theProp,
                     long defaultVal)
Constructor that takes the name of the system property and the default value of that property.
Parameters:
theProp - the name of the system property.
defaulVal - the default value.
Method Detail

run

public Object run()
Determines the Long value of the system property whose name was specified in the constructor.

If there is no property of the specified name, or if the property does not have the correct numeric format, then a Long object representing the default value that was specified in the constructor is returned, or null if no default value was specified.

Specified by:
run in interface PrivilegedAction
Returns:
the Long value of the property.