Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.objectstyle.cayenne.access.util
Class DistinctResultIterator

    java.lang.Object
      org.objectstyle.cayenne.access.util.DistinctResultIterator

All Implemented Interfaces:
  ResultIterator

    public class DistinctResultIterator

extends java.lang.Object
implements ResultIterator

A ResultIterator that does in-memory filtering of rows to return only distinct rows. Distinct comparison is done by comparing ObjectIds created from each row. Internally DistinctResultIterator wraps another ResultIterator that provides the actual rows. The current limitation is that once switched to reading ids instead of rows (i.e. when "nextObjectId()" is called for the first time), it can't be used to read data rows again. This is pretty sensible for most things in Cayenne.

Since:
  1.2
Author:
  Andrus Adamchik

Field Summary
`protected boolean` | `compareFullRows`
`protected DbEntity` | `defaultEntity`
`protected java.util.Set` | `fetchedIds`
`protected java.util.Map` | `nextDataRow`
`protected boolean` | `readingIds`
`protected ResultIterator` | `wrappedIterator`

Constructor Summary
`DistinctResultIterator(ResultIterator wrappedIterator, DbEntity defaultEntity, boolean compareFullRows)` Creates new DistinctResultIterator wrapping another ResultIterator.

Method Summary
`void` | `close()` CLoses underlying ResultIterator.
`java.util.List` | `dataRows(boolean close)` Returns all data rows.
`int` | `getDataRowWidth()` Returns the number of columns in the result row.
`boolean` | `hasNextRow()` Returns true if there is at least one more record that can be read from the iterator.
`java.util.Map` | `nextDataRow()` Returns the next result row as a Map.
`java.util.Map` | `nextObjectId(DbEntity entity)` Returns a Map for the next ObjectId.
`void` | `skipDataRow()` Skips current data row instead of reading it.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### wrappedIterator

    protected ResultIterator wrappedIterator

### fetchedIds

    protected java.util.Set fetchedIds

### nextDataRow

    protected java.util.Map nextDataRow

### defaultEntity

    protected DbEntity defaultEntity

### compareFullRows

    protected boolean compareFullRows

### readingIds

    protected boolean readingIds

Constructor Detail

### DistinctResultIterator

    public DistinctResultIterator(ResultIterator wrappedIterator,
                                  DbEntity defaultEntity,
                                  boolean compareFullRows)
                           throws CayenneException

  Creates new DistinctResultIterator wrapping another ResultIterator.

  Parameters:
    `wrappedIterator` -
    `defaultEntity` - an entity needed to build ObjectIds for distinct comparison.
  Throws:
    `CayenneException`

Method Detail

### close

    public void close()
               throws CayenneException

  CLoses underlying ResultIterator.

  Specified by:
    `close` in interface `ResultIterator`
  Throws:
    `CayenneException`

### dataRows

    public java.util.List dataRows(boolean close)
                            throws CayenneException

  Returns all data rows.

  Specified by:
    `dataRows` in interface `ResultIterator`
  Throws:
    `CayenneException`

### getDataRowWidth

    public int getDataRowWidth()

  Description copied from interface: `ResultIterator`
  Returns the number of columns in the result row.

  Specified by:
    `getDataRowWidth` in interface `ResultIterator`

### hasNextRow

    public boolean hasNextRow()
                       throws CayenneException

  Description copied from interface: `ResultIterator`
  Returns true if there is at least one more record that can be read from the iterator.

  Specified by:
    `hasNextRow` in interface `ResultIterator`
  Throws:
    `CayenneException`

### nextDataRow

    public java.util.Map nextDataRow()
                              throws CayenneException

  Description copied from interface: `ResultIterator`
  Returns the next result row as a Map.

  Specified by:
    `nextDataRow` in interface `ResultIterator`
  Throws:
    `CayenneException`

### nextObjectId

    public java.util.Map nextObjectId(DbEntity entity)
                               throws CayenneException

  Returns a Map for the next ObjectId. After calling this method, calls to "nextDataRow()" will result in exceptions.

  Specified by:
    `nextObjectId` in interface `ResultIterator`
  Throws:
    `CayenneException`

### skipDataRow

    public void skipDataRow()
                     throws CayenneException

  Description copied from interface: `ResultIterator`
  Skips current data row instead of reading it.

  Specified by:
    `skipDataRow` in interface `ResultIterator`
  Throws:
    `CayenneException`

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2001-2006 ObjectStyle.org All Rights Reserved.