The system value classes allow a Java™ program to retrieve and change system values and network attributes. You can also define your own group to contain the system values you want.
A SystemValue object primarily contains the following information:
Using the SystemValue class, retrieve a single system value by using the getValue() method and change a system value by using the setValue() method.
You can also retrieve group information about a particular system value:
Whenever the value of a system value is retrieved for the first time, the value is retrieved from the iSeries™ and cached. On subsequent retrievals, the cached value is returned. If the current iSeries value is what you want instead of the cached value, a clear() must be done to clear the current cache.
SystemValueList represents a list of system values on the specified iSeries server. The list is divided into several system-defined groups that allow the Java program to access a portion of the system values at a time.
SystemValueGroup represents a user-defined collection of system values and network attributes. Rather than a container, it is instead a factory for generating and maintaining unique collections of system values.
You can create a SystemValueGroup by specifying one of the system-defined groups (one of the constants in the SystemValueList class) or by specifying an array of system value names.
You can individually add the names of system values to include in the group by using the add() method. You can also remove them by using the remove() method.
Once the SystemValueGroup is populated with the required system value names, obtain the real SystemValue objects from the group by calling the getSystemValues() method. In this way, a SystemValueGroup object takes a set of system value names and generates a Vector of SystemValue objects, all having the system, group name, and group description of the SystemValueGroup.
To refresh a Vector of SystemValue objects all at once, use the refresh() method.
The following example shows how to create and retrieve a system value:
//Create an AS400 object AS400 sys = new AS400("mySystem.myCompany.com"); //Create a system value representing the current second on the system. SystemValue sysval = new SystemValue(sys, "QSECOND"); //Retrieve the value. String second = (String)sysval.getValue(); //At this point QSECOND is cached. Clear the cache to retrieve the most //up-to-date value from the system. sysval.clear(); second = (String)sysval.getValue(); //Create a system value list. SystemValueList list = new SystemValueList(sys); //Retrieve all the of the date/time system values. Vector vec = list.getGroup(SystemValueList.GROUP_DATTIM); //Disconnect from the system. sys.disconnectAllServices();
The following example shows how to build a group of system value names and then manipulate them:
//Create an AS400 object AS400 sys = new AS400("mySystem.myCompany.com"); //Create a system value group initially representing all of the network attributes on the system. String name = "My Group"; String description = "This is one of my system values."; SystemValueGroup svGroup = new SystemValueGroup(sys, name, description, SystemValueList.GROUP_NET); //Add some more system value names to the group and remove some we do not want. svGroup.add("QDATE"); svGroup.add("QTIME"); svGroup.remove("NETSERVER"); svGroup.remove("SYSNAME"); //Obtain the actual SystemValue objects. They are returned inside a Vector. Vector sysvals = svGroup.getSystemValues(); //You will notice that this is one of my system values. SystemValue mySystemValue = (SystemValue)sysvals.elementAt(0); System.out.println(mySystemValue.getName()+" - "+mySystemValue.getGroupDescription()); //We can add another SystemValue object from another system into the group. AS400 sys2 = new AS400("otherSystem.myCompany.com"); SystemValue sv = new SystemValue(sys2, "QDATE"); sysvals.addElement(sv); //Now refresh the entire group of system values all at once. //It does not matter if some system values are from different iSeries servers. //It does not matter if some system values were generated using SystemValueGroup and some were not. SystemValueGroup.refresh(sysvals); //Disconnect from the systems. sys.disconnectAllServices(); sys2.disconnectAllServices();