All Libraries | This Library | Package | Class | Use | Tree | Deprecated | Index | Grand Index | Help
|  | Components |
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.sas.collection
Class PredicateEnumeration

    com.sas.collection.PredicateEnumeration

All Implemented Interfaces:
  java.util.Enumeration

Direct Known Subclasses:
  StringPredicateEnumeration

    public class PredicateEnumeration

implements java.util.Enumeration

`PredicateEnumeration` filters an ``Enumeration`` by only returning items which satisfy a boolean predicate. `PredicateEnumeration` is a Decorator class. It takes in its constructor a primary `Enumeration` and a `PredicateInterface`. The `PredicateEnumeration` then acts as an `Enumeration`. It retrieves values from the primary `Enumeration`, but only returns items such that the specified boolean predicate returns `true`. Thus, the `PredicateEnumeration` acts as a way to filter another enumeration with a boolean test.

See Also:
  `StringPredicateEnumeration`

Constructor Summary
`PredicateEnumeration(java.util.Enumeration enumer, com.sas.util.PredicateInterface predicate)` Construct a `PredicateEnumeration` which filters another enumeration by guarding it's values with a predicate.

Method Summary
`boolean` | `hasMoreElements()` Returns `true` if there are more elements which satisfy the predicate.
`java.lang.Object` | `nextElement()` Returns the next element from the enumeration which satisfies the predicate.

Constructor Detail

### PredicateEnumeration

    public PredicateEnumeration(java.util.Enumeration enumer,
                                com.sas.util.PredicateInterface predicate)

  Construct a `PredicateEnumeration` which filters another enumeration by guarding it's values with a predicate. That is, this filter only returns items via `enumer.nextElement()` if the predicate is `true` for those items. `hasMoreElements()` works by performing a look-ahead and running the predicate (one time) on subsequent items until one is found which satisfies the predicate (it will be returned by the next call to `nextElement()`, or no more items exist.

  Parameters:
    `enumer` - the primary enumeration filtered by this `PredicateEnumeration`
    `predicate` - the predicate used to filter the primary enumertion. Only items which satisfy htis boolean predicate are returned by `nextElement()`

Method Detail

### hasMoreElements

    public boolean hasMoreElements()

  Returns `true` if there are more elements which satisfy the predicate.

  Specified by:
    `hasMoreElements` in interface `java.util.Enumeration`
  Returns:
    `true` if there are more elements which satisfy the predicate.

### nextElement

    public java.lang.Object nextElement()

  Returns the next element from the enumeration which satisfies the predicate.

  Specified by:
    `nextElement` in interface `java.util.Enumeration`
  Returns:
    the next element from the enumeration which satisfies the predicate.

All Libraries | This Library | Package | Class | Use | Tree | Deprecated | Index | Grand Index | Help
|  | Components |
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2009 SAS Institute Inc. All Rights Reserved.