public class EnvironmentVariable
extends java.lang.Object
implements java.io.Serializable
This class can only access system-level environment variables. You must have *JOBCTL special authority to add, change, or delete system-level environment variables.
Every environment variable has a CCSID associated with it which describes the CCSID in which its contents are stored. The default CCSID is that of the current job.
Note that environment variables are different than system values, although they are often used for the same purpose. See SystemValue for more information on how to access system values.
The environment variable value and CCSID are cached after being read once. Call refreshValue() to force the value and CCSID to be refreshed.
The following example creates two EnvironmentVariables and sets and gets their values.
AS400 system = new AS400("mysystem"); EnvironmentVariable fg = new EnvironmentVariable(system, "FOREGROUND"); fg.setValue("RED"); EnvironmentVariable bg = new EnvironmentVariable(system, "BACKGROUND"); String background = bg.getValue();
EnvironmentVariableList
,
Serialized FormConstructor and Description |
---|
EnvironmentVariable()
Constructs an EnvironmentVariable object.
|
EnvironmentVariable(AS400 system)
Constructs an EnvironmentVariable object.
|
EnvironmentVariable(AS400 system,
char[] nameInCharArray)
Constructs an EnvironmentVariable object.
|
EnvironmentVariable(AS400 system,
java.lang.String name)
Constructs an EnvironmentVariable object.
|
Modifier and Type | Method and Description |
---|---|
void |
addPropertyChangeListener(java.beans.PropertyChangeListener listener)
Adds a PropertyChangeListener.
|
void |
delete()
Deletes the environment variable.
|
int |
getCCSID()
Returns the environment variable CCSID.
|
java.lang.String |
getName()
Returns the environment variable name.
|
java.lang.String |
getName(int stringType)
Returns the environment variable name.
|
AS400 |
getSystem()
Returns the system on which the environment variable exists.
|
java.lang.String |
getValue()
Returns the value of the environment variable.
|
java.lang.String |
getValue(int stringType)
Returns the value of the environment variable.
|
void |
refreshValue()
Refreshes the environment variable value and CCSID.
|
void |
removePropertyChangeListener(java.beans.PropertyChangeListener listener)
Removes the PropertyChangeListener.
|
void |
setName(java.lang.String name)
Sets the environment variable name.
|
void |
setName(java.lang.String name,
int stringType)
Sets the environment variable name.
|
void |
setSystem(AS400 system)
Sets the system for the environment variable.
|
void |
setValue(char[] value)
Sets the value of the environment variable.
|
void |
setValue(char[] value,
int ccsid)
Sets the value of the environment variable.
|
void |
setValue(char[] value,
int ccsid,
int stringType)
Sets the value of the environment variable.
|
void |
setValue(java.lang.String value)
Sets the value of the environment variable.
|
void |
setValue(java.lang.String value,
int ccsid)
Sets the value of the environment variable.
|
void |
setValue(java.lang.String value,
int ccsid,
int stringType)
Sets the value of the environment variable.
|
public EnvironmentVariable()
public EnvironmentVariable(AS400 system)
system
- The system on which the environment variable exists.public EnvironmentVariable(AS400 system, java.lang.String name)
Environment variable names are case sensitive and cannot contain spaces or equals signs (=).
system
- The system on which the environment variable exists.name
- The environment variable name.public EnvironmentVariable(AS400 system, char[] nameInCharArray)
Environment variable names are case sensitive and cannot contain spaces or equals signs (=).
system
- The system on which the environment variable exists.nameInCharArray
- The environment variable name in char array.public void addPropertyChangeListener(java.beans.PropertyChangeListener listener)
listener
- The listener object.public void delete() throws AS400SecurityException, ErrorCompletingRequestException, java.lang.InterruptedException, java.io.IOException, ObjectDoesNotExistException
AS400SecurityException
- If a security or authority error occurs.ErrorCompletingRequestException
- If an error occurs before the request is completed.java.lang.InterruptedException
- If this thread is interrupted.java.io.IOException
- If an error occurs while communicating with the system.ObjectDoesNotExistException
- If the object does not exist on the system.public int getCCSID() throws AS400SecurityException, ErrorCompletingRequestException, java.lang.InterruptedException, java.io.IOException, ObjectDoesNotExistException
AS400SecurityException
- If a security or authority error occurs.ErrorCompletingRequestException
- If an error occurs before the request is completed.java.lang.InterruptedException
- If this thread is interrupted.java.io.IOException
- If an error occurs while communicating with the system.ObjectDoesNotExistException
- If the object does not exist on the system.public java.lang.String getName()
public java.lang.String getName(int stringType)
stringType
- The environment variable bidi string type, as defined by the CDRA (Character Data Representation Architecture). See BidiStringType for more information and valid values.public AS400 getSystem()
public java.lang.String getValue() throws AS400SecurityException, ErrorCompletingRequestException, java.lang.InterruptedException, java.io.IOException, ObjectDoesNotExistException
AS400SecurityException
- If a security or authority error occurs.ErrorCompletingRequestException
- If an error occurs before the request is completed.java.lang.InterruptedException
- If this thread is interrupted.java.io.IOException
- If an error occurs while communicating with the system.ObjectDoesNotExistException
- If the object does not exist on the system.public java.lang.String getValue(int stringType) throws AS400SecurityException, ErrorCompletingRequestException, java.lang.InterruptedException, java.io.IOException, ObjectDoesNotExistException
stringType
- The environment variable bidi string type, as defined by the CDRA (Character Data Representation Architecture). See BidiStringType for more information and valid values.AS400SecurityException
- If a security or authority error occurs.ErrorCompletingRequestException
- If an error occurs before the request is completed.java.lang.InterruptedException
- If this thread is interrupted.java.io.IOException
- If an error occurs while communicating with the system.ObjectDoesNotExistException
- If the object does not exist on the system.public void refreshValue() throws AS400SecurityException, ErrorCompletingRequestException, java.lang.InterruptedException, java.io.IOException, ObjectDoesNotExistException
AS400SecurityException
- If a security or authority error occurs.ErrorCompletingRequestException
- If an error occurs before the request is completed.java.lang.InterruptedException
- If this thread is interrupted.java.io.IOException
- If an error occurs while communicating with the system.ObjectDoesNotExistException
- If the object does not exist on the system.public void removePropertyChangeListener(java.beans.PropertyChangeListener listener)
listener
- The listener object.public void setName(java.lang.String name)
Environment variable names are case sensitive and cannot contain spaces or equals signs (=).
name
- The environment variable name.public void setName(java.lang.String name, int stringType)
Environment variable names are case sensitive and cannot contain spaces or equals signs (=).
name
- The environment variable name.stringType
- The environment variable bidi string type, as defined by the CDRA (Character Data Representation Architecture). See BidiStringType for more information and valid values.public void setSystem(AS400 system)
system
- The system on which the environment variable exists.public void setValue(java.lang.String value) throws AS400SecurityException, ErrorCompletingRequestException, java.lang.InterruptedException, java.io.IOException, ObjectDoesNotExistException
value
- The value.AS400SecurityException
- If a security or authority error occurs.ErrorCompletingRequestException
- If an error occurs before the request is completed.java.lang.InterruptedException
- If this thread is interrupted.java.io.IOException
- If an error occurs while communicating with the system.ObjectDoesNotExistException
- If the object does not exist on the system.public void setValue(java.lang.String value, int ccsid) throws AS400SecurityException, ErrorCompletingRequestException, java.lang.InterruptedException, java.io.IOException, ObjectDoesNotExistException
value
- The value.ccsid
- The CCSID. Possible values are:
AS400SecurityException
- If a security or authority error occurs.ErrorCompletingRequestException
- If an error occurs before the request is completed.java.lang.InterruptedException
- If this thread is interrupted.java.io.IOException
- If an error occurs while communicating with the system.ObjectDoesNotExistException
- If the object does not exist on the system.public void setValue(java.lang.String value, int ccsid, int stringType) throws AS400SecurityException, ErrorCompletingRequestException, java.lang.InterruptedException, java.io.IOException, ObjectDoesNotExistException
value
- The value.ccsid
- The CCSID. Possible values are:
stringType
- The environment variable bidi string type, as defined by the CDRA (Character Data Representation Architecture). See BidiStringType for more information and valid values.AS400SecurityException
- If a security or authority error occurs.ErrorCompletingRequestException
- If an error occurs before the request is completed.java.lang.InterruptedException
- If this thread is interrupted.java.io.IOException
- If an error occurs while communicating with the system.ObjectDoesNotExistException
- If the object does not exist on the system.public void setValue(char[] value) throws AS400SecurityException, ErrorCompletingRequestException, java.lang.InterruptedException, java.io.IOException, ObjectDoesNotExistException
value
- The value (char array) .AS400SecurityException
- If a security or authority error occurs.ErrorCompletingRequestException
- If an error occurs before the request is completed.java.lang.InterruptedException
- If this thread is interrupted.java.io.IOException
- If an error occurs while communicating with the system.ObjectDoesNotExistException
- If the object does not exist on the system.public void setValue(char[] value, int ccsid) throws AS400SecurityException, ErrorCompletingRequestException, java.lang.InterruptedException, java.io.IOException, ObjectDoesNotExistException
value
- The value (char array).ccsid
- The CCSID. Possible values are:
AS400SecurityException
- If a security or authority error occurs.ErrorCompletingRequestException
- If an error occurs before the request is completed.java.lang.InterruptedException
- If this thread is interrupted.java.io.IOException
- If an error occurs while communicating with the system.ObjectDoesNotExistException
- If the object does not exist on the system.public void setValue(char[] value, int ccsid, int stringType) throws AS400SecurityException, ErrorCompletingRequestException, java.lang.InterruptedException, java.io.IOException, ObjectDoesNotExistException
value
- The value (char array).ccsid
- The CCSID. Possible values are:
stringType
- The environment variable bidi string type, as defined by the CDRA (Character Data Representation Architecture). See BidiStringType for more information and valid values.AS400SecurityException
- If a security or authority error occurs.ErrorCompletingRequestException
- If an error occurs before the request is completed.java.lang.InterruptedException
- If this thread is interrupted.java.io.IOException
- If an error occurs while communicating with the system.ObjectDoesNotExistException
- If the object does not exist on the system.