com.sas.util.transforms
Class EnumerationTransform

com.sas.util.transforms.EnumerationTransform
All Implemented Interfaces:
java.io.Serializable, java.util.Enumeration

public class EnumerationTransform
implements java.util.Enumeration, java.io.Serializable

An Enumeration which applies a transform to all the elements.

For example, you may have a Enumeration employees of Employee objects, and you want an Enumeration of employee last names (employee.getLastName()). You can use a EnumerationTransform to transform the Enumeration:

     Enumeration employees = db.getEmployees();
     Enumeration lastNames = new EnumerationTransform(employees,
                 new TransformInterface() {
                     public Object transform(Object obj) {
                         return ((Employee) obj).getLastName(); }
                 });
 

See Also:
Serialized Form

Constructor Summary
EnumerationTransform()
          Default no-arg constructor.
EnumerationTransform(java.util.Enumeration enumeration, com.sas.util.transforms.TransformInterface transform)
          Construct an EnumerationTransform which applies a transform to the elements of another Enumeration.
 
Method Summary
 boolean hasMoreElements()
          Test if the enumeration has completed.
 java.lang.Object nextElement()
          Return the next element in the base enumeration on which this EnumerationTransform was constructed.
 

Constructor Detail

EnumerationTransform

public EnumerationTransform()
Default no-arg constructor.


EnumerationTransform

public EnumerationTransform(java.util.Enumeration enumeration,
                            com.sas.util.transforms.TransformInterface transform)
Construct an EnumerationTransform which applies a transform to the elements of another Enumeration.

Parameters:
enumeration - the base enumeration which this EnumerationTransform transforms.
transform - the transform to apply to each element of the base enumeration.
Method Detail

hasMoreElements

public boolean hasMoreElements()
Test if the enumeration has completed.

Specified by:
hasMoreElements in interface java.util.Enumeration
Returns:
true if there are more elements in the base enumeration, else false.

nextElement

public java.lang.Object nextElement()
Return the next element in the base enumeration on which this EnumerationTransform was constructed.

Specified by:
nextElement in interface java.util.Enumeration
Returns:
the next element. If the transform is not null and it throws a TranformException, null is returned.



Copyright © 2009 SAS Institute Inc. All Rights Reserved.