Skip to content

Commit f61ffce

Browse files
wimjongmanThePrez
authored andcommitted
typesafety: SystemStatus.getSystemPools() #42
Fixed Signed-off-by: Wim Jongman <[email protected]>
1 parent 4028472 commit f61ffce

File tree

1 file changed

+31
-11
lines changed

1 file changed

+31
-11
lines changed

src/main/java/com/ibm/as400/access/SystemStatus.java

+31-11
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,12 @@
2020
import java.beans.VetoableChangeSupport;
2121
import java.io.IOException;
2222
import java.io.Serializable;
23+
import java.util.ArrayList;
24+
import java.util.Collections;
2325
import java.util.Date;
2426
import java.util.Enumeration;
27+
import java.util.List;
2528
import java.util.TimeZone;
26-
import java.util.Vector;
2729

2830
/**
2931
Provides access to a group of statistics that represent the current status of the system.
@@ -40,8 +42,8 @@ public class SystemStatus implements Serializable
4042

4143
// The receiver variables retrieved for each format. Index zero will be set to the last format retrieved.
4244
byte[][] receiverVariables_ = new byte[4][];
43-
// A vector of SystemPool object retrieved from the system.
44-
private Vector poolsVector_;
45+
// A list of SystemPool object retrieved from the system.
46+
private List<SystemPool> poolsList_;
4547

4648
// Flag indicating if we have connected to the system yet.
4749
private transient boolean connected_ = false;
@@ -790,23 +792,39 @@ public String getSystemName() throws AS400SecurityException, ErrorCompletingRequ
790792
Converter conv = new Converter(system_.getJobCcsid(), system_);
791793
return conv.byteArrayToString(receiverVariables_[0], 16, 8).trim();
792794
}
795+
796+
/**
797+
Returns an enumeration containing a SystemPool object for each system pool.
798+
@return An enumeration containing a SystemPool object for each system pool.
799+
@exception AS400SecurityException If a security or authority error occurs.
800+
@exception ErrorCompletingRequestException If an error occurs before the request is completed.
801+
@exception InterruptedException If this thread is interrupted.
802+
@exception IOException If an error occurs while communicating with the system.
803+
@exception ObjectDoesNotExistException If the object does not exist on the system.
804+
@deprecated see getSystemPoolsList()
805+
@see #getSystemPoolsList()
806+
**/
807+
public Enumeration<SystemPool> getSystemPools() throws AS400SecurityException, ErrorCompletingRequestException, InterruptedException, IOException, ObjectDoesNotExistException
808+
{
809+
return Collections.enumeration(getSystemPoolsList());
810+
}
793811

794812
/**
795-
Returns an enumeration containing a SystemPool object for each system pool.
796-
@return An enumeration containing a SystemPool object for each system pool.
813+
Returns a list containing a SystemPool object for each system pool.
814+
@return A list containing a SystemPool object for each system pool.
797815
@exception AS400SecurityException If a security or authority error occurs.
798816
@exception ErrorCompletingRequestException If an error occurs before the request is completed.
799817
@exception InterruptedException If this thread is interrupted.
800818
@exception IOException If an error occurs while communicating with the system.
801819
@exception ObjectDoesNotExistException If the object does not exist on the system.
802820
**/
803-
public Enumeration getSystemPools() throws AS400SecurityException, ErrorCompletingRequestException, InterruptedException, IOException, ObjectDoesNotExistException
821+
public List<SystemPool> getSystemPoolsList() throws AS400SecurityException, ErrorCompletingRequestException, InterruptedException, IOException, ObjectDoesNotExistException
804822
{
805823
loadInformation(3);
806824

807825
// If we've already retrieved the pools, just return it.
808-
if (poolsVector_ != null) return poolsVector_.elements();
809-
poolsVector_ = new Vector();
826+
if (poolsList_ != null) return poolsList_;
827+
poolsList_ = new ArrayList<SystemPool>();
810828

811829
// Parse the pool information.
812830
int number = BinaryConverter.byteArrayToInt(receiverVariables_[3], 32);
@@ -827,11 +845,13 @@ public Enumeration getSystemPools() throws AS400SecurityException, ErrorCompleti
827845
String poolName = new CharConverter(system_.getJobCcsid(), system_).byteArrayToString(poolInformation, 44, 10);
828846
systemPool = new SystemPool(system_, poolName);
829847
}
830-
poolsVector_.addElement(systemPool);
848+
poolsList_.add(systemPool);
831849
offset += length;
832850
}
833-
return poolsVector_.elements();
851+
return poolsList_;
834852
}
853+
854+
835855

836856

837857
private static final int FORMAT_DTS = AS400Timestamp.FORMAT_DTS; // *DTS format
@@ -1047,7 +1067,7 @@ public void refreshCache()
10471067
// Clear the receiver variables;
10481068
receiverVariables_ = new byte[4][];
10491069
// Clear the vector of pools.
1050-
poolsVector_ = null;
1070+
poolsList_ = null;
10511071
}
10521072

10531073
/**

0 commit comments

Comments
 (0)