Package org.molgenis.util.tuple

Examples of org.molgenis.util.tuple.Tuple


      ExcelSheetReader sheetReader = excelReader.getSheet("Sheet1");
      try
      {
        Iterator<Tuple> it = sheetReader.iterator();
        assertTrue(it.hasNext());
        Tuple tuple1 = it.next();
        assertEquals(tuple1.getString("col1"), row1.getString("col1"));
        assertEquals(tuple1.getString("col2"), row1.getString("col2"));
        assertEquals(tuple1.getString("col3"), row1.getString("col3"));
        assertTrue(it.hasNext());
        Tuple tuple2 = it.next();
        assertEquals(tuple2.getString("col1"), row2.getString("col1"));
        assertEquals(tuple2.getString("col2"), row2.getString("col2"));
        assertEquals(tuple2.getString("col3"), row2.getString("col3"));
        assertFalse(it.hasNext());
      }
      finally
      {
        IOUtils.closeQuietly(sheetReader);
View Full Code Here


    assertEquals(table.getColumns().get(1).getName(), "lastName");

    assertEquals(2, table.getCount(), 2);

    List<Tuple> rows = table.getRows();
    Tuple row = rows.get(0);
    assertEquals(row.getNrCols(), 2);
    assertEquals(row.getString("firstName"), "lucky");
    assertEquals(row.getString("lastName"), "luke");

    row = rows.get(1);
    assertEquals(2, row.getNrCols(), 2);
    assertEquals(row.getString("firstName"), "calamity");
    assertEquals(row.getString("lastName"), "jane");
  }
View Full Code Here

  @Test
  public void addCellProcessor_data() throws IOException
  {
    CellProcessor processor = when(mock(CellProcessor.class).processData()).thenReturn(true).getMock();

    Tuple dataTuple = mock(Tuple.class);
    when(dataTuple.getNrCols()).thenReturn(2);
    when(dataTuple.get(0)).thenReturn("val1");
    when(dataTuple.get(1)).thenReturn("val2");

    CsvWriter csvWriter = new CsvWriter(new StringWriter());
    try
    {
      csvWriter.addCellProcessor(processor);
View Full Code Here

  @Test
  public void addCellProcessor_header() throws IOException
  {
    CellProcessor processor = when(mock(CellProcessor.class).processHeader()).thenReturn(true).getMock();
    Tuple headerTuple = mock(Tuple.class);
    when(headerTuple.getNrCols()).thenReturn(2);
    when(headerTuple.getColNames()).thenReturn(Arrays.asList("col1", "col2"));

    KeyValueTuple row1 = new KeyValueTuple();
    row1.set("col1", "val1");
    row1.set("col2", "val2");
View Full Code Here

  @Test
  public void addCellProcessor_data() throws IOException
  {
    CellProcessor processor = when(mock(CellProcessor.class).processData()).thenReturn(true).getMock();

    Tuple dataTuple = mock(Tuple.class);
    when(dataTuple.hasColNames()).thenReturn(true);
    when(dataTuple.getNrCols()).thenReturn(2);
    when(dataTuple.get("col1")).thenReturn("val1");
    when(dataTuple.get("col2")).thenReturn("val2");
    when(dataTuple.getColNames()).thenReturn(Arrays.asList("col1", "col2"));

    OutputStream os = mock(OutputStream.class);
    ExcelWriter excelWriter = new ExcelWriter(os);
    excelWriter.addCellProcessor(processor);
    try
View Full Code Here

  public void iterator()
  {
    Iterator<Tuple> it = excelSheetReader.iterator();
    assertTrue(it.hasNext());

    Tuple row1 = it.next();
    assertEquals(row1.get("col1"), "val1");
    assertEquals(row1.get("col2"), "val2");
    assertTrue(it.hasNext());

    Tuple row2 = it.next();
    assertEquals(row2.get("col1"), "val3");
    assertEquals(row2.get("col2"), "val4");
    assertTrue(it.hasNext());

    Tuple row3 = it.next();
    assertEquals(row3.get("col1"), "XXX");
    assertEquals(row3.get("col2"), "val6");
    assertTrue(it.hasNext());

    // test number cell (col1) and formula cell (col2)
    Tuple row4 = it.next();
    assertEquals(row4.get("col1"), "1.2");
    assertEquals(row4.get("col2"), "2.4");
    assertFalse(it.hasNext());
  }
View Full Code Here

    assertEquals(colNamesIt.next(), "col2");

    Iterator<Tuple> it = excelSheetReader.iterator();
    assertTrue(it.hasNext());

    Tuple row1 = it.next();
    assertEquals(row1.get("col1"), "val1");
    assertEquals(row1.get("col2"), "val2");
    assertTrue(it.hasNext());

    Tuple row2 = it.next();
    assertEquals(row2.get("col1"), "val3");
    assertEquals(row2.get("col2"), "val4");
    assertTrue(it.hasNext());

    Tuple row3 = it.next();
    assertEquals(row3.get("col1"), "XXX");
    assertEquals(row3.get("col2"), "val6");
    assertTrue(it.hasNext());

    // test number cell (col1) and formula cell (col2)
    Tuple row4 = it.next();
    assertEquals(row4.get("col1"), "1.2");
    assertEquals(row4.get("col2"), "2.4");
    assertFalse(it.hasNext());
  }
View Full Code Here

  @Override
  public Tuple next()
  {

    Tuple tuple;
    try
    {
      List<Field> columns = tupleTable.getColumns();

      if (tupleTable.isFirstColumnFixed())
View Full Code Here

      rulesList = QueryRuleUtil.fromRESTstring(URLDecoder.decode(request.getQueryString(), "UTF-8"));
    }
    // use 'post'
    else
    {
      Tuple requestTuple = new HttpServletRequestTuple(request);
      StringBuilder queryStringBuilder = new StringBuilder();
      for (String name : requestTuple.getColNames())
      {
        queryStringBuilder.append(URLDecoder.decode(name, "UTF-8")).append('=');
        queryStringBuilder.append(URLDecoder.decode(requestTuple.getString(name), "UTF-8"));
      }
      String queryString = queryStringBuilder.toString();
      logger.debug("handle find query via http-post with parameters: " + queryString);
      rulesList = QueryRuleUtil.fromRESTstring(queryString);
    }
View Full Code Here

        }

        @Override
        public Tuple next()
        {
          Tuple tuple = get();
          getNext = true;
          return tuple;
        }

        private Tuple get()
View Full Code Here

TOP

Related Classes of org.molgenis.util.tuple.Tuple

Copyright © 2018 www.massapicom. 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.