Package br.com.caelum.seleniumdsl.search

Source Code of br.com.caelum.seleniumdsl.search.Search

package br.com.caelum.seleniumdsl.search;

import java.util.ArrayList;
import java.util.List;

import br.com.caelum.seleniumdsl.table.Row;
import br.com.caelum.seleniumdsl.table.Table;


public class Search implements RowMatcher {

  protected List<Matcher> matchers = new ArrayList<Matcher>();
  private Table table;
  private int currentRow = 0;
  private int rowCount;
 
  protected void where(String name, Matcher matcher) {
    matcher.setColumn(name);
    matchers.add(matcher);
  }
 
  protected Matcher equals(String content) {
    return new EqualsMatcher(content);
  }
 
  protected Matcher containsAll(String...contents) {
    return new ContainsAllMatcher(contents);
  }
 
  public void setTable(Table table) {
    this.table = table;
    this.rowCount = table.getRowCount();
  }
 
  public Row next() {
    OUTTER:
    for (currentRow++; currentRow <= rowCount; currentRow++) {
      Row row = table.row(currentRow);
      for (Matcher matcher : matchers) {
        if(!matcher.matches(row))
          continue OUTTER;
      }
      return row;
    }
    return null;
  }
}
TOP

Related Classes of br.com.caelum.seleniumdsl.search.Search

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.