Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  package com.datastax.driver.mapping;
  
  import java.util.Iterator;
  import java.util.List;
  
A ResultSet mapped to an entity class.
 
 public class Result<T> implements Iterable<T> {
 
     private final ResultSet rs;
     private final EntityMapper<T> mapper;
     private final int protocolVersion;
 
     Result(ResultSet rsEntityMapper<T> mapperint protocolVersion) {
         this. = rs;
         this. = mapper;
         this. = protocolVersion;
     }
 
     private T map(Row row) {
         T entity = .newEntity();
         for (ColumnMapper<T> cm : .allColumns()) {
             ByteBuffer bytes = row.getBytesUnsafe(cm.getColumnName());
             if (bytes != null)
                 cm.setValue(entitycm.getDataType().deserialize(bytes));
         }
         return entity;
     }

    
Test whether this mapped result set has more results.

Returns:
whether this mapped result set has more results.
 
     public boolean isExhausted() {
         return .isExhausted();
     }

    
Returns the next result (i.e. the entity corresponding to the next row in the result set).

Returns:
the next result in this mapped result set or null if it is exhausted.
 
     public T one() {
         Row row = .one();
         return row == null ? null : map(row);
     }

    
Returns all the remaining results (entities) in this mapped result set as a list.

Returns:
a list containing the remaining results of this mapped result set. The returned list is empty if and only the result set is exhausted.
 
     public List<T> all() {
         List<Rowrows = .all();
         List<T> entities = new ArrayList<T>(rows.size());
         for (Row row : rows) {
             entities.add(map(row));
         }
         return entities;
     }

    
An iterator over the entities of this mapped result set. The java.util.Iterator.next() method is equivalent to calling one(). So this iterator will consume results and after a full iteration, the mapped result set (and underlying ResultSet) will be empty. The returned iterator does not support the java.util.Iterator.remove() method.

Returns:
an iterator that will consume and return the remaining rows of this mapped result set.
 
     public Iterator<T> iterator() {
         return new Iterator<T>() {
             private final Iterator<RowrowIterator = .iterator();
 
             public boolean hasNext() {
                 return .hasNext();
             }
 
             public T next() {
                 return map(.next());
             }
 
             public void remove() {
                 throw new UnsupportedOperationException();
             }
        };
    }

    
Returns information on the execution of this query.

The returned object includes basic information such as the queried hosts, but also the Cassandra query trace if tracing was enabled for the query.

Returns:
the execution info for this query.
    public ExecutionInfo getExecutionInfo() {
        return .getExecutionInfo();
    }
New to GrepCode? Check out our FAQ X