com.ibm.as400.access
Class EnvironmentVariableList

java.lang.Object
  extended by com.ibm.as400.access.EnvironmentVariableList
All Implemented Interfaces:
Serializable

public class EnvironmentVariableList
extends Object
implements Serializable

The EnvironmentVariableList class represents a list of IBM i system-level environment variables.

This class can only access system-level environment variables. You must have *JOBCTL special authority to add, change, or delete system-level environment variables.

This example gets the list of environment variables as a java.util.Properties object:

    AS400 system = new AS400("mysystem");
    EnvironmentVariableList evList = new EnvironmentVariableList(system);
    Properties p = evList.getProperties();
 

This example uses an Enumeration to print the list of environment variable names and values:

    AS400 system = new AS400("mysystem");
    EnvironmentVariableList evList = new EnvironmentVariableList(system);
    Enumeration list = evList.getEnvironmentVariables();
    while (list.hasMoreElements())
    {
        EnvironmentVariable ev = (EnvironmentVariable)list.nextElement();
        System.out.println(ev.getName() + "=" + ev.getValue());
    }
 

See Also:
EnvironmentVariable, Serialized Form

Constructor Summary
Constructor and Description
EnvironmentVariableList()
          Constructs a EnvironmentVariableList object.
EnvironmentVariableList(AS400 system)
          Constructs a EnvironmentVariableList object.
 
Method Summary
Modifier and Type Method and Description
 void addPropertyChangeListener(PropertyChangeListener listener)
          Adds a PropertyChangeListener.
 Enumeration getEnvironmentVariables()
          Returns an enumeration that contains an EnvironmentVariable object for each environment variable on the system.
 Properties getProperties()
          Returns a new Properties object which contains an entry for each environment variable in the list.
 AS400 getSystem()
          Returns the system on which the environment variable list exists.
 void removePropertyChangeListener(PropertyChangeListener listener)
          Removes a PropertyChangeListener.
 void setProperties(Properties properties)
          Sets the value of each environment variable defined in a Properties object.
 void setProperties(Properties properties, int stringType)
          Sets the value of each environment variable defined in a Properties object.
 void setSystem(AS400 system)
          Sets the system for the environment variable list.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

EnvironmentVariableList

public EnvironmentVariableList()
Constructs a EnvironmentVariableList object.


EnvironmentVariableList

public EnvironmentVariableList(AS400 system)
Constructs a EnvironmentVariableList object.

Parameters:
system - The system.
Method Detail

addPropertyChangeListener

public void addPropertyChangeListener(PropertyChangeListener listener)
Adds a PropertyChangeListener. The specified PropertyChangeListener's propertyChange() method will be called each time the value of any bound property is changed.

Parameters:
listener - The listener object.

getEnvironmentVariables

public Enumeration getEnvironmentVariables()
                                    throws AS400SecurityException,
                                           ErrorCompletingRequestException,
                                           InterruptedException,
                                           IOException,
                                           ObjectDoesNotExistException
Returns an enumeration that contains an EnvironmentVariable object for each environment variable on the system.

Throws:
AS400SecurityException - If a security or authority error occurs.
ErrorCompletingRequestException - If an error occurs before the request is completed.
InterruptedException - If this thread is interrupted.
IOException - If an error occurs while communicating with the system.
ObjectDoesNotExistException - If the object does not exist on the system.

getProperties

public Properties getProperties()
                         throws AS400SecurityException,
                                ErrorCompletingRequestException,
                                InterruptedException,
                                IOException,
                                ObjectDoesNotExistException
Returns a new Properties object which contains an entry for each environment variable in the list.

Returns:
The new Properties object.
Throws:
AS400SecurityException - If a security or authority error occurs.
ErrorCompletingRequestException - If an error occurs before the request is completed.
InterruptedException - If this thread is interrupted.
IOException - If an error occurs while communicating with the system.
ObjectDoesNotExistException - If the object does not exist on the system.

getSystem

public AS400 getSystem()
Returns the system on which the environment variable list exists.

Returns:
The system on which the environment variable list exists. If the system has not been set, null is returned.

removePropertyChangeListener

public void removePropertyChangeListener(PropertyChangeListener listener)
Removes a PropertyChangeListener.

Parameters:
listener - The listener object.

setProperties

public void setProperties(Properties properties)
                   throws AS400SecurityException,
                          ErrorCompletingRequestException,
                          InterruptedException,
                          IOException,
                          ObjectDoesNotExistException
Sets the value of each environment variable defined in a Properties object.

Parameters:
properties - The Properties object.
Throws:
AS400SecurityException - If a security or authority error occurs.
ErrorCompletingRequestException - If an error occurs before the request is completed.
InterruptedException - If this thread is interrupted.
IOException - If an error occurs while communicating with the system.
ObjectDoesNotExistException - If the object does not exist on the system.

setProperties

public void setProperties(Properties properties,
                          int stringType)
                   throws AS400SecurityException,
                          ErrorCompletingRequestException,
                          InterruptedException,
                          IOException,
                          ObjectDoesNotExistException
Sets the value of each environment variable defined in a Properties object.

Parameters:
properties - The Properties object.
stringType - The environment variable bidi string type, as defined by the CDRA (Character Data Representataion Architecture). See BidiStringType for more information and valid values.
Throws:
AS400SecurityException - If a security or authority error occurs.
ErrorCompletingRequestException - If an error occurs before the request is completed.
InterruptedException - If this thread is interrupted.
IOException - If an error occurs while communicating with the system.
ObjectDoesNotExistException - If the object does not exist on the system.

setSystem

public void setSystem(AS400 system)
Sets the system for the environment variable list. The system cannot be changed once a connection is made to the system.

Parameters:
system - The system on which the environment variable list exists.